lavc/libxvid: workaround for bug in libxvidcore

libxvidcore calculate number of threads basing on video height.
If height is small enough it allocates 0 bytes long memory and
writes to it.
Setting thread_count to 0 uses 1 thread and skips bugged code.

Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Lukasz Marek 2014-11-24 01:12:06 +01:00 committed by Michael Niedermayer
parent 4f69477870
commit 4a0b1d9245
1 changed files with 13 additions and 0 deletions

View File

@ -471,6 +471,19 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
xvid_enc_create.num_zones = 0;
xvid_enc_create.num_threads = avctx->thread_count;
#if (XVID_VERSION <= 0x010303) && (XVID_VERSION >= 0x010300)
/* workaround for a bug in libxvidcore */
if (avctx->height <= 16) {
if (avctx->thread_count < 2) {
xvid_enc_create.num_threads = 0;
} else {
av_log(avctx, AV_LOG_ERROR,
"Too small height for threads > 1.");
ret = AVERROR(EINVAL);
goto fail;
}
}
#endif
xvid_enc_create.plugins = plugins;
xvid_enc_create.num_plugins = 0;