[FFmpeg-devel] [PATCH] avcodec/leaddec: support format 0x1006

Leo Izen leo.izen at gmail.com
Wed Jan 15 09:56:52 EET 2025


On 1/15/25 2:10 AM, Peter Ross wrote:
> Fixes ticket #10658.
> ---
>   libavcodec/leaddec.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/leaddec.c b/libavcodec/leaddec.c
> index 88387902ca..12e27061e9 100644
> --- a/libavcodec/leaddec.c
> +++ b/libavcodec/leaddec.c
> @@ -164,6 +164,10 @@ static int lead_decode_frame(AVCodecContext *avctx, AVFrame * frame,
>       case 0x1000:
>           avctx->pix_fmt = AV_PIX_FMT_YUV420P;
>           break;
> +    case 0x1006:
> +        fields = 2;
> +        avctx->pix_fmt = AV_PIX_FMT_YUV420P;
> +        break;
>       case 0x2000:
>           avctx->pix_fmt = AV_PIX_FMT_YUV444P;
>           break;
> @@ -237,7 +241,8 @@ static int lead_decode_frame(AVCodecContext *avctx, AVFrame * frame,
>                           return ret;
>                   }
>       } else if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) {
> -        for (int mb_y = 0; mb_y < (avctx->height + 15) / 16; mb_y++)
> +        for (int f = 0; f < fields; f++)
> +        for (int mb_y = 0; mb_y < (avctx->height + 15) / fields / 16; mb_y++)

Did you ever test this on frames with an odd macroblock height?

Consider, e.g. height=360. (height + 15) / 16 = 23
but (height + 15) / 2 / 16 = 11

This means this inner loop runs 11 times, so with the outer loop, it'll 
run 22 times, but the height is 23 macroblocks. How do we avoid missing 
the bottom row of macroblocks in this case?


>               for (int mb_x = 0; mb_x < (avctx->width + 15) / 16; mb_x++)
>                   for (int b = 0; b < (yuv20p_half ? 4 : 6); b++) {
>                       int luma_block = yuv20p_half ? 2 : 4;
> @@ -258,8 +263,8 @@ static int lead_decode_frame(AVCodecContext *avctx, AVFrame * frame,
>   
>                       ret = decode_block(s, &gb, dc_vlc, dc_bits, ac_vlc, ac_bits,
>                           dc_pred + plane, dequant[!(b < 4)],
> -                        frame->data[plane] + y*frame->linesize[plane] + x,
> -                        (yuv20p_half && b < 2 ? 2 : 1) * frame->linesize[plane]);
> +                        frame->data[plane] + (f + y*fields)*frame->linesize[plane] + x,
> +                        (yuv20p_half && b < 2 ? 2 : 1) * fields * frame->linesize[plane]);
>                       if (ret < 0)
>                           return ret;
>   
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-devel mailing list