[FFmpeg-devel] [PATCH] mpeg12enc: fix wrong size when copying A53_CC side-data into output

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri May 16 04:15:09 EEST 2025


Jacob Lifshay:
> Fixes: https://trac.ffmpeg.org/ticket/11591
> 
> Signed-off-by: Jacob Lifshay <programmerjake at gmail.com>
> ---
>  libavcodec/mpeg12enc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
> index 8364368fde..e48437eb8a 100644
> --- a/libavcodec/mpeg12enc.c
> +++ b/libavcodec/mpeg12enc.c
> @@ -472,7 +472,7 @@ static int mpeg1_encode_picture_header(MPVMainEncContext *const m)
>                      (side_data->size / 3 & A53_MAX_CC_COUNT) | 0x40); // flags, cc_count
>                  put_bits(&s->pb, 8, 0xff);                  // em_data
>  
> -                ff_copy_bits(&s->pb, side_data->data, side_data->size);
> +                ff_copy_bits(&s->pb, side_data->data, side_data->size * 8);
>  
>                  put_bits(&s->pb, 8, 0xff);                  // marker_bits
>              } else {

Thanks for this patch (and for the bug report; and sorry for causing you
trouble). Your patch was also my first attempt to fix this, but
unfortunately ff_copy_bits() may overread, yet the side data buffer need
not be padded, so my patch simply reverts the ff_copy_bits().

- Andreas



More information about the ffmpeg-devel mailing list