[FFmpeg-devel] [PATCH 3/3] lavc/libxvid: workaround for bug in libxvidcore

Lukasz Marek lukasz.m.luki2 at gmail.com
Mon Nov 24 01:20:26 CET 2014


On 24.11.2014 01:17, Lukasz Marek wrote:
> 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 at gmail.com>
> ---
>   libavcodec/libxvid.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
>
> diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
> index 70d52b9..efe7b8a 100644
> --- a/libavcodec/libxvid.c
> +++ b/libavcodec/libxvid.c

I created a patch for xvid, but I have problem to contact them. But I 
will eventually.

Code to reproduce:

...

AVCodec *selected = NULL;

int main(void)
{
     avcodec_register_all();
         AVCodec *codec = NULL;
         AVCodecContext *ctx;
         av_log_set_level(AV_LOG_ERROR);
         selected = avcodec_find_encoder_by_name("libxvid");
         while (codec = av_codec_next(codec)) {
             if (av_codec_is_decoder(codec))
                 continue;
             if (selected && strcmp(selected->name, codec->name))
                 continue;
             if (codec->type == AVMEDIA_TYPE_AUDIO)
                 continue;
             ctx = avcodec_alloc_context3(NULL);
             if (codec->type == AVMEDIA_TYPE_VIDEO) {
                 ctx->pix_fmt = AV_PIX_FMT_NONE;
                 if (codec->pix_fmts)
                     ctx->pix_fmt = codec->pix_fmts[0];
                 if (ctx->pix_fmt == AV_PIX_FMT_NONE)
                     ctx->pix_fmt = AV_PIX_FMT_RGB24;
                 ctx->width = 2;
                 ctx->height = 2;
             }
             if (avcodec_open2(ctx, codec, NULL) < 0)
                 printf("%s failed\n", codec->name);

             avcodec_close(ctx);
             avcodec_free_context(&ctx);
         }
}



More information about the ffmpeg-devel mailing list