Downscaling and Colorimetry

Anything related to video and my tools that is not a support request.
Post Reply
DAE avatar
Aleron Ives
Posts: 126
Joined: Fri May 31, 2013 8:36 pm

Downscaling and Colorimetry

Post by Aleron Ives »

Hi Don, I have a question regarding the "Colorimetry" field reported by your tools. As I understand it, HD (720p+) video uses BT.709, while SD video uses various standards, depending on the source format. DGIndexNV will report e.g. "Colorimetry: BT.709 [1]*" for HD, where the star means BT.709 is assumed based on the resolution and not explicitly declared.

If you're downscaling an HD source to SD, I believe you're supposed to indicate that the video is BT.709, so the playback device doesn't incorrectly assume BT.601 or some other SD standard; however, x264 has three related settings:

Code: Select all

      --colorprim <string>    Specify color primaries ["undef"]
                                  - undef, bt709, bt470m, bt470bg, smpte170m,
                                    smpte240m, film, bt2020, smpte428,
                                    smpte431, smpte432
      --transfer <string>     Specify transfer characteristics ["undef"]
                                  - undef, bt709, bt470m, bt470bg, smpte170m,
                                    smpte240m, linear, log100, log316,
                                    iec61966-2-4, bt1361e, iec61966-2-1,
                                    bt2020-10, bt2020-12, smpte2084, smpte428,
                                    arib-std-b67
      --colormatrix <string>  Specify color matrix setting ["???"]
                                  - undef, bt709, fcc, bt470bg, smpte170m,
                                    smpte240m, GBR, YCgCo, bt2020nc, bt2020c,
                                    smpte2085, chroma-derived-nc,
                                    chroma-derived-c, ICtCp
Are you supposed to set all three to bt709, only the --colormatrix flag, or something else? The x264 help says you invoke the VUI settings at your own risk, so I'd rather not make things worse compared to not declaring anything at all, if I can help it. :lol:
User avatar
Rocky
Posts: 3556
Joined: Fri Sep 06, 2019 12:57 pm

Downscaling and Colorimetry

Post by Rocky »

Aleron Ives wrote:
Thu Dec 09, 2021 7:23 pm
Hi Don, ...
DG does philosophy, quantum theory, and pays for stuff ( :salute: ). Mysterious. I'll try to answer.

DGDecNV just reports what it sees in the stream. DGSource() does make available the three variables you mentioned in Avisynth+ frame properties:

env->propSetInt(props, "_Matrix", (int64_t)m_decoder.coded_matrix_coefficients, paReplace);
env->propSetInt(props, "_Primaries", (int64_t)m_decoder.coded_colour_primaries, paReplace);
env->propSetInt(props, "_Transfer", (int64_t)m_decoder.coded_transfer_characteristics, paReplace);

You are free to use that information but DGDecNV cannot vouch for its accuracy. If in doubt, don't set anything.

What else?
DAE avatar
Aleron Ives
Posts: 126
Joined: Fri May 31, 2013 8:36 pm

Downscaling and Colorimetry

Post by Aleron Ives »

Thanks for the reply. I guess my main question is: DGIndexNV reports just "Colorimetry", but x264 has three different settings. As a rule of thumb, if the source doesn't specify anything, so DGIndexNV just reports a guess based on the resolution, you shouldn't specify any of those flags in the downscaled version; however, if the source does specify e.g. BT.709, should you set all three flags with x264, or should you only specify --colormatrix? My first guess is that you use the term "Colorimetry" as an umbrella term for all three settings, so all three x264 settings should be used if the source has an explicit setting, but I wanted to be sure that's how your terminology works. As you said, when in doubt, set nothing.

I'm still using ye olde AviSynth, so I guess I can't see the values of all three fields via DGSource(). :?
User avatar
Rocky
Posts: 3556
Joined: Fri Sep 06, 2019 12:57 pm

Downscaling and Colorimetry

Post by Rocky »

Aleron Ives wrote:
Fri Dec 10, 2021 3:12 am
Thanks for the reply. I guess my main question is: DGIndexNV reports just "Colorimetry", but x264 has three different settings. As a rule of thumb, if the source doesn't specify anything, so DGIndexNV just reports a guess based on the resolution, you shouldn't specify any of those flags in the downscaled version; however, if the source does specify e.g. BT.709, should you set all three flags with x264, or should you only specify --colormatrix? My first guess is that you use the term "Colorimetry" as an umbrella term for all three settings, so all three x264 settings should be used if the source has an explicit setting, but I wanted to be sure that's how your terminology works. As you said, when in doubt, set nothing.

I'm still using ye olde AviSynth, so I guess I can't see the values of all three fields via DGSource(). :?
The Colorimetry field in the info dialog is based off the matrix coefficients specified in the stream. If you need access to all the three values (primaries, matrix, transfer) then they are given in the DGI file COLORIMETRY line (also in AVS+ frame properties). It's unlikely a stream would specify one of those variables as 709 and not the others.
DAE avatar
Aleron Ives
Posts: 126
Joined: Fri May 31, 2013 8:36 pm

Downscaling and Colorimetry

Post by Aleron Ives »

OK, that's what I expected. Thanks! o7
Post Reply