Opened 8 years ago

Last modified 3 years ago

#6023 open enhancement

support Transfer characteristic in DPX encoder

Reported by: dave rice Owned by: Elon Musk
Priority: wish Component: avcodec
Version: git-master Keywords: dpx
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Currently the DPX encoder only hardcodes a value when writing transfer characteristics. In the encoder a '2' is written [1] in this value which according to the DPX spec [2] means 'linear'.

In this command I'm trying to create a bt709 DPX but the output is simply 'linear'.

ffmpeg -f lavfi -i testsrc -color_trc bt709 -vframes 1 test.dpx
ffmpeg version N-44102-g457e933 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-457e933 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-chromaprint --enable-ffplay --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
  libavutil      55. 43.100 / 55. 43.100
  libavcodec     57. 68.100 / 57. 68.100
  libavformat    57. 60.100 / 57. 60.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 68.100 /  6. 68.100
  libavresample   3.  2.  0 /  3.  2.  0
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, lavfi, from 'testsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'test.dpx':
  Metadata:
    encoder         : Lavf57.60.100
    Stream #0:0: Video: dpx, rgb24(unknown/unknown/bt709), 320x240 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.68.100 dpx
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> dpx (native))
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=21.8x    
video:227kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

[1] https://github.com/FFmpeg/FFmpeg/blob/e06ef9aa5fe8a423ab58997f0c99112bb415b947/libavcodec/dpxenc.c#L221
[2] https://web.archive.org/web/20050706060025/http://www.smpte.org/smpte_store/standards/pdf/s268m.pdf.

Change History (4)

comment:1 by Elon Musk, 8 years ago

Priority: normalwish
Type: defectenhancement

comment:2 by Balling, 4 years ago

Status: newopen

Yes. Indeed, it writes linear for something THAT CANNOT be linear. Ridiculous. You cannot see it in ffplay, since it does not support linear, but mpv (that does support linear) is broken (since mpv uses ffmpeg and ffmpeg added support for reading linear and stuff in 0539f15bbb86c5e81af56454c94e2eddefd34b7c)!! WTF.

On the other hand looks like chroma sitting in mpv is wrong if you will look into the zero of testsrc (chroma_location=unspecified of course).

Also -color_trc bt709 on RGB (which on linear makes no sense, IMHO unless it is decoding tranfer). Sigh, why it so problematic?? Also, there is a color range problem. 8232e01e41488bc3f4504b3de241106a4cca7cb7

Also Colorimetric specification: 2 (0x02) does not even exist!! What?? Primaries are already linear!

Descriptor:                          50 (0x32) - R,G,B
00321    Transfer characteristic:             2 (0x02) - Linear
00322    Colorimetric specification:          2 (0x02) - 
00323    Bit depth:                           8 (0x08) - integer
00324    Packing:                             0 (0x0000) - Packed
00326    Encoding:                            0 (0x0000) - Raw

I propose to change to

6 CCIR 709-1

the first and CCIR 709-1 primaries (that is value 6).

Last edited 4 years ago by Balling (previous) (diff)

comment:3 by Balling, 3 years ago

https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210601191828.6957-1-val.zapod.vz@gmail.com/

I reimplemented Paul's patch with some fixes. No support for printing density (WTF is that anyway?) and log transfer, while one of the samples is actually LOG in FATE (cyan.dpx). Also this will oversaturate ffmpeg created samples as they all were writing linear transfer, but ffplay does not support this, so of course when patches to support decoding were merged... Anyway, that can be simply fixed cause ffmpeg was also writing non-existant 2 value in primaries! LOL.

Also this DOES not include any YCbCr stuff! Or WCG/HDR from new DPX standard.

Last edited 3 years ago by Balling (previous) (diff)

comment:4 by Balling, 3 years ago

Owner: set to Elon Musk

Can you apply my patch, it has you co-authored?

Note: See TracTickets for help on using tickets.