[FFmpeg-trac] #9038(undetermined:new): kmsgrab: the parsing of `format_modifier` is problematic

FFmpeg trac at avcodec.org
Sun Dec 20 21:06:37 EET 2020


#9038: kmsgrab: the parsing of `format_modifier` is problematic
-------------------------------------+-------------------------------------
             Reporter:  xry111       |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 The parsing of `format_modifier` from command line is problematic.

 In the parsing of those option with `AV_OPT_TYPE_INT64` type, the value is
 firstly parsed into a `double`.  However in this case `format_modifier` is
 a bit mask.  For example, with my Intel iGPU I need
 `I915_FORMAT_MOD_X_TILED`, which is effectively `(1 << 56) | 1`.

 The value is $2^{56} + 1$, but as all we know the precision of `double` is
 only 52 bits.  So $2^{56} + 1$ is truncated to $2^{56}$, which is wrong.

 How to reproduce:

 Add one line of code to output `drm_format_modifier`:

 {{{
 av_log(avctx, AV_LOG_DEBUG, "format modifier = %ld\n", ctx->drm_format_m
 odifier);
 }}}

 Build and run `ffmpeg`, to grab the screen:

 {{{
 % ffmpeg -f kmsgrab -format_modifier 72057594037927937 -i - -vf
 'hwdownload,format=bgr0' output.mp4 -loglevel 114514 2>&1 | tee log
 }}}

 Inspect the log:

 {{{
 % grep modifier log
 Reading option '-format_modifier' ... matched as AVOption
 'format_modifier' with argument '72057594037927937'.
 [kmsgrab @ 0x654b40] format modifier = 72057594037927936
 }}}

 Inspect the video:

 {{{
 ffplay output.mp4
 }}}

 The result is a broken video, because of the incorrect `format_modifier`
 value.

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


More information about the FFmpeg-trac mailing list