[FFmpeg-trac] #6649(avcodec:new): DNxHR 444 encoding crashes because of wrong macroblock size

FFmpeg trac at avcodec.org
Mon Sep 11 22:08:58 EEST 2017


#6649: DNxHR 444 encoding crashes because of wrong macroblock size
-------------------------------------+-------------------------------------
             Reporter:  devernay     |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:  avcodec      |                  Version:  git-
             Keywords:  DNxHD DNxHR  |  master
             Blocking:               |               Blocked By:
Analyzed by developer:  0            |  Reproduced by developer:  0
-------------------------------------+-------------------------------------
 Summary of the bug:
 I get a crash when encoding DNxHR 444 with an image height which is not a
 multiple of 16 (eg 1920x1080)
 How to reproduce:
 This does not seem to occur using the command-line ffmpeg utility, but
 using the ffmpeg API.

 The bug seems to be at line:
 https://github.com/FFmpeg/FFmpeg/commit/f078bc4c5e6675a93166a7e5b23feb5b04ac9320
 #diff-f75ae6c1ad5f3f6c90ed8741497d2ce1R754

 It supposes that the macroblock size for 10-bit images is 8 instead of 16,
 which looks wrong, given the fact that the macroblock size is always 16
 according to
 https://github.com/FFmpeg/FFmpeg/blob/f078bc4c5e6675a93166a7e5b23feb5b04ac9320/libavcodec/dnxhdenc.c#L475
 the following two-line patch fixes the crash/bug, but this should be
 reviewed by Paul B Mahol, who commited
 https://github.com/FFmpeg/FFmpeg/commit/f078bc4c5e6675a93166a7e5b23feb5b04ac9320
 :

 {{{
 --- ffmpeg-3.3.3/libavcodec/dnxhdenc.c  2017-07-29 19:49:30.000000000
 +0200
 +++ ffmpeg-3.3.3.new/libavcodec/dnxhdenc.c      2017-09-11
 19:41:13.000000000 +0200
 @@ -751,10 +751,10 @@
          ptr_y = &ctx->edge_buf_y[0];
          ptr_u = &ctx->edge_buf_uv[0][0];
          ptr_v = &ctx->edge_buf_uv[1][0];
 -    } else if (ctx->bit_depth == 10 && vdsp->emulated_edge_mc && ((mb_x
 << 3) + 8 > ctx->m.avctx->width ||
 -                                                                  (mb_y
 << 3) + 8 > ctx->m.avctx->height)) {
 -        int y_w = ctx->m.avctx->width  - (mb_x << 3);
 -        int y_h = ctx->m.avctx->height - (mb_y << 3);
 +    } else if (ctx->bit_depth == 10 && vdsp->emulated_edge_mc && ((mb_x
 << 4) + 16 > ctx->m.avctx->width ||
 +                                                                  (mb_y
 << 4) + 16 > ctx->m.avctx->height)) {
 +        int y_w = ctx->m.avctx->width  - (mb_x << 4);
 +        int y_h = ctx->m.avctx->height - (mb_y << 4);
          int uv_w = ctx->is_444 ? y_w : (y_w + 1) / 2;
          int uv_h = y_h;
          linesize = 16;
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/6649>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list