[x265] [PATCH][master] Add CLI option for simplifying colorimetry parameters
Alex Giladi
alex.giladi at gmail.com
Fri Feb 26 19:46:24 UTC 2021
Nitpicking: p->vui.bEnableChromaLocInfoPresentFlag = 1; appears in each
statement -- shouldn't it go above the switch statement?
On Fri, Feb 26, 2021 at 8:35 AM Aruna Matheswaran <
aruna at multicorewareinc.com> wrote:
>
>
> On Fri, Feb 26, 2021 at 4:35 PM Niranjan Bala <
> niranjan at multicorewareinc.com> wrote:
>
>> From 980823a240b95d2fd88c50e2bf30185ef6b0f18b Mon Sep 17 00:00:00 2001
>> From: Niranjan <niranjan at multicorewareinc.com>
>> Date: Fri, 5 Feb 2021 00:24:30 +0530
>> Subject: [PATCH] Add CLI option for simplifying colorimetry parameters
>>
>> The CLI option covers commonly used combinations of color primaries,
>> transfer characteristics, color matrix, range of luma and chroma signals,
>> and chroma sample location
>> ---
>> doc/reST/cli.rst | 72 ++++++++++++++
>> source/CMakeLists.txt | 2 +-
>> source/common/param.cpp | 161 +++++++++++++++++++++++++++++++
>> source/test/regression-tests.txt | 1 +
>> source/x265cli.cpp | 22 +++++
>> source/x265cli.h | 1 +
>> 6 files changed, 258 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
>> index f19a28734..45757e576 100755
>> --- a/doc/reST/cli.rst
>> +++ b/doc/reST/cli.rst
>> @@ -2386,6 +2386,78 @@ VUI fields must be manually specified.
>> Values in the range 0..12. See D.3.3 of the HEVC spec. for a detailed
>> explanation.
>> Required for HLG (Hybrid Log Gamma) signaling. Not signaled by default.
>>
>> +.. option:: --video-signal-type-preset <string>
>> +
>> + Specify combinations of color primaries, transfer characteristics,
>> color matrix,
>> + range of luma and chroma signals, and chroma sample location.
>> + String format: <system-id>[:<color-volume>]
>> +
>> + system-id options and their corresponding values:
>> +
>> +----------------+---------------------------------------------------------------+
>> + | system-id | Value
>> |
>> +
>> +================+===============================================================+
>> + | BT601_525 | --colorprim smpte170m --transfer smpte170m
>> |
>> + | | --colormatrix smpte170m --range limited --chromaloc
>> 0 |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT601_626 | --colorprim bt470bg --transfer smpte170m
>> --colormatrix bt470bg|
>> + | | --range limited --chromaloc 0
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT709_YCC | --colorprim bt709 --transfer bt709 --colormatrix
>> bt709 |
>> + | | --range limited --chromaloc 0
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT709_RGB | --colorprim bt709 --transfer bt709 --colormatrix gbr
>> |
>> + | | --range limited
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT2020_YCC_NCL | --colorprim bt2020 --transfer bt2020-10
>> --colormatrix bt709 |
>> + | | --range limited --chromaloc 2
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT2020_RGB | --colorprim bt2020 --transfer smpte2084
>> --colormatrix bt2020nc|
>> + | | --range limited
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT2100_PQ_YCC | --colorprim bt2020 --transfer smpte2084
>> --colormatrix bt2020nc|
>> + | | --range limited --chromaloc 2
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT2100_PQ_ICTCP| --colorprim bt2020 --transfer smpte2084
>> --colormatrix ictcp |
>> + | | --range limited --chromaloc 2
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT2100_PQ_RGB | --colorprim bt2020 --transfer smpte2084
>> --colormatrix gbr |
>> + | | --range limited
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT2100_HLG_YCC | --colorprim bt2020 --transfer arib-std-b67
>> |
>> + | | --colormatrix bt2020nc --range limited --chromaloc 2
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT2100_HLG_RGB | --colorprim bt2020 --transfer arib-std-b67
>> --colormatrix gbr |
>> + | | --range limited
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | FR709_RGB | --colorprim bt709 --transfer bt709 --colormatrix gbr
>> |
>> + | | --range full
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | FR2020_RGB | --colorprim bt2020 --transfer bt2020-10
>> --colormatrix gbr |
>> + | | --range full
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | FRP3D65_YCC | --colorprim smpte432 --transfer bt709 --colormatrix
>> smpte170m |
>> + | | --range full --chromaloc 1
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> +
>> + color-volume options and their corresponding values:
>> +
>> +----------------+---------------------------------------------------------------+
>> + | color-volume | Value
>> |
>> +
>> +================+===============================================================+
>> + | P3D65x1000n0005| --master-display
>> G(13250,34500)B(7500,3000)R(34000,16000) |
>> + | | WP(15635,16450)L(10000000,5)
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | P3D65x4000n005 | --master-display
>> G(13250,34500)B(7500,3000)R(34000,16000) |
>> + | | WP(15635,16450)L(40000000,50)
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> + | BT2100x108n0005| --master-display
>> G(8500,39850)B(6550,2300)R(34000,146000) |
>> + | | WP(15635,16450)L(10000000,1)
>> |
>> +
>> +----------------+---------------------------------------------------------------+
>> +
>> + Note: The color-volume options can be used only with the system-id
>> options BT2100_PQ_YCC,
>> + BT2100_PQ_ICTCP, and BT2100_PQ_RGB. It is incompatible with other
>> options.
>> +
>> + **CLI ONLY**
>> +
>> Bitstream options
>> =================
>>
>> diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
>> index 95218f5dc..a407271b4 100755
>> --- a/source/CMakeLists.txt
>> +++ b/source/CMakeLists.txt
>> @@ -29,7 +29,7 @@ option(NATIVE_BUILD "Target the build CPU" OFF)
>> option(STATIC_LINK_CRT "Statically link C runtime for release builds"
>> OFF)
>> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
>> # X265_BUILD must be incremented each time the public API is changed
>> -set(X265_BUILD 198)
>> +set(X265_BUILD 199)
>>
> [AM] Why build update? I don't see any API change in the patch.
>
>> configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>> "${PROJECT_BINARY_DIR}/x265.def")
>> configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
>> diff --git a/source/common/param.cpp b/source/common/param.cpp
>> index 47a7a7c47..ce914ba42 100755
>> --- a/source/common/param.cpp
>> +++ b/source/common/param.cpp
>> @@ -1381,6 +1381,167 @@ int x265_param_parse(x265_param* p, const char*
>> name, const char* value)
>> OPT("vbv-live-multi-pass") p->bliveVBV2pass = atobool(value);
>> OPT("min-vbv-fullness") p->minVbvFullness = atof(value);
>> OPT("max-vbv-fullness") p->maxVbvFullness = atof(value);
>> + OPT("video-signal-type-preset")
>> + {
>> + char systemId[20] = {};
>> + char colorVolume[20] = {};
>> + sscanf(value, "%[^:]:%s", systemId, colorVolume);
>> + p->vui.bEnableVideoSignalTypePresentFlag = 1;
>> + p->vui.bEnableColorDescriptionPresentFlag = 1;
>> + if (!strcmp(systemId, "BT601_525"))
>> + {
>> + p->vui.bEnableChromaLocInfoPresentFlag = 1;
>> + p->vui.colorPrimaries = 6;
>> + p->vui.transferCharacteristics = 6;
>> + p->vui.matrixCoeffs = 6;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + p->vui.chromaSampleLocTypeTopField = 0;
>> + p->vui.chromaSampleLocTypeBottomField =
>> p->vui.chromaSampleLocTypeTopField;
>> + }
>> + else if (!strcmp(systemId, "BT601_626"))
>> + {
>> + p->vui.bEnableChromaLocInfoPresentFlag = 1;
>> + p->vui.colorPrimaries = 5;
>> + p->vui.transferCharacteristics = 6;
>> + p->vui.matrixCoeffs = 5;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + p->vui.chromaSampleLocTypeTopField = 0;
>> + p->vui.chromaSampleLocTypeBottomField =
>> p->vui.chromaSampleLocTypeTopField;
>> + }
>> + else if (!strcmp(systemId, "BT709_YCC"))
>> + {
>> + p->vui.bEnableChromaLocInfoPresentFlag = 1;
>> + p->vui.colorPrimaries = 1;
>> + p->vui.transferCharacteristics = 1;
>> + p->vui.matrixCoeffs = 1;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + p->vui.chromaSampleLocTypeTopField = 0;
>> + p->vui.chromaSampleLocTypeBottomField =
>> p->vui.chromaSampleLocTypeTopField;
>> + }
>> + else if (!strcmp(systemId, "BT709_RGB"))
>> + {
>> + p->vui.colorPrimaries = 1;
>> + p->vui.transferCharacteristics = 1;
>> + p->vui.matrixCoeffs = 0;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + }
>> + else if (!strcmp(systemId, "BT2020_YCC_NCL"))
>> + {
>> + p->vui.bEnableChromaLocInfoPresentFlag = 1;
>> + p->vui.colorPrimaries = 9;
>> + p->vui.transferCharacteristics = 14;
>> + p->vui.matrixCoeffs = 1;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + p->vui.chromaSampleLocTypeTopField = 2;
>> + p->vui.chromaSampleLocTypeBottomField =
>> p->vui.chromaSampleLocTypeTopField;
>> + }
>> + else if (!strcmp(systemId, "BT2020_RGB"))
>> + {
>> + p->vui.colorPrimaries = 9;
>> + p->vui.transferCharacteristics = 16;
>> + p->vui.matrixCoeffs = 9;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + }
>> + else if (!strcmp(systemId, "BT2100_PQ_YCC"))
>> + {
>> + p->vui.bEnableChromaLocInfoPresentFlag = 1;
>> + p->vui.colorPrimaries = 9;
>> + p->vui.transferCharacteristics = 16;
>> + p->vui.matrixCoeffs = 9;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + p->vui.chromaSampleLocTypeTopField = 2;
>> + p->vui.chromaSampleLocTypeBottomField =
>> p->vui.chromaSampleLocTypeTopField;
>> + }
>> + else if (!strcmp(systemId, "BT2100_PQ_ICTCP"))
>> + {
>> + p->vui.bEnableChromaLocInfoPresentFlag = 1;
>> + p->vui.colorPrimaries = 9;
>> + p->vui.transferCharacteristics = 16;
>> + p->vui.matrixCoeffs = 14;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + p->vui.chromaSampleLocTypeTopField = 2;
>> + p->vui.chromaSampleLocTypeBottomField =
>> p->vui.chromaSampleLocTypeTopField;
>> + }
>> + else if (!strcmp(systemId, "BT2100_PQ_RGB"))
>> + {
>> + p->vui.colorPrimaries = 9;
>> + p->vui.transferCharacteristics = 16;
>> + p->vui.matrixCoeffs = 0;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + }
>> + else if (!strcmp(systemId, "BT2100_HLG_YCC"))
>> + {
>> + p->vui.bEnableChromaLocInfoPresentFlag = 1;
>> + p->vui.colorPrimaries = 9;
>> + p->vui.transferCharacteristics = 18;
>> + p->vui.matrixCoeffs = 9;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + p->vui.chromaSampleLocTypeTopField = 2;
>> + p->vui.chromaSampleLocTypeBottomField =
>> p->vui.chromaSampleLocTypeTopField;
>> + }
>> + else if (!strcmp(systemId, "BT2100_HLG_RGB"))
>> + {
>> + p->vui.colorPrimaries = 9;
>> + p->vui.transferCharacteristics = 18;
>> + p->vui.matrixCoeffs = 0;
>> + p->vui.bEnableVideoFullRangeFlag = 0;
>> + }
>> + else if (!strcmp(systemId, "FR709_RGB"))
>> + {
>> + p->vui.colorPrimaries = 1;
>> + p->vui.transferCharacteristics = 1;
>> + p->vui.matrixCoeffs = 0;
>> + p->vui.bEnableVideoFullRangeFlag = 1;
>> + }
>> + else if (!strcmp(systemId, "FR2020_RGB"))
>> + {
>> + p->vui.colorPrimaries = 9;
>> + p->vui.transferCharacteristics = 14;
>> + p->vui.matrixCoeffs = 0;
>> + p->vui.bEnableVideoFullRangeFlag = 1;
>> + }
>> + else if (!strcmp(systemId, "FRP3D65_YCC"))
>> + {
>> + p->vui.bEnableChromaLocInfoPresentFlag = 1;
>> + p->vui.colorPrimaries = 12;
>> + p->vui.transferCharacteristics = 1;
>> + p->vui.matrixCoeffs = 6;
>> + p->vui.bEnableVideoFullRangeFlag = 1;
>> + p->vui.chromaSampleLocTypeTopField = 1;
>> + p->vui.chromaSampleLocTypeBottomField =
>> p->vui.chromaSampleLocTypeTopField;
>> + }
>> + else
>> + {
>> + bError = true;
>> + }
>>
> [AM] This long list of conditional statements shall be replaced with a
> lookup table. It will enable better readability and eliminate code
> duplication.
>
>> +
>> + if (colorVolume[0] != '\0')
>> + {
>> + if (!strcmp(systemId, "BT2100_PQ_YCC") ||
>> !strcmp(systemId, "BT2100_PQ_ICTCP") || !strcmp(systemId, "BT2100_PQ_RGB"))
>> + {
>> + if (!strcmp(colorVolume, "P3D65x1000n0005"))
>> + {
>> + p->masteringDisplayColorVolume =
>> "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,5)";
>> + }
>> + else if (!strcmp(colorVolume, "P3D65x4000n005"))
>> + {
>> + p->masteringDisplayColorVolume =
>> "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(40000000,50)";
>> + }
>> + else if (!strcmp(colorVolume, "BT2100x108n0005"))
>> + {
>> + p->masteringDisplayColorVolume =
>> "G(8500,39850)B(6550,2300)R(34000,146000)WP(15635,16450)L(10000000,1)";
>> + }
>> + else
>> + {
>> + bError = true;
>> + }
>> + }
>> + else
>> + {
>> + bError = true;
>> + }
>> + }
>> + }
>> else
>> return X265_PARAM_BAD_NAME;
>> }
>> diff --git a/source/test/regression-tests.txt
>> b/source/test/regression-tests.txt
>> index 26f6b7ed3..a4fcab87f 100644
>> --- a/source/test/regression-tests.txt
>> +++ b/source/test/regression-tests.txt
>> @@ -165,6 +165,7 @@ crowd_run_1920x1080_50.yuv, --preset faster --ctu 32
>> --rskip 2 --rskip-edge-thre
>> crowd_run_1920x1080_50.yuv, --preset fast --ctu 64 --rskip 2
>> --rskip-edge-threshold 5 --aq-mode 4
>> crowd_run_1920x1080_50.yuv, --preset slow --ctu 32 --rskip 2
>> --rskip-edge-threshold 5 --hist-scenecut --hist-threshold 0.1
>> crowd_run_1920x1080_50.yuv, --preset slower --ctu 16 --rskip 2
>> --rskip-edge-threshold 5 --hist-scenecut --hist-threshold 0.1 --aq-mode 4
>> +crowd_run_1920x1080_50.yuv, --preset ultrafast
>> --video-signal-type-preset BT2100_PQ_YCC:BT2100x108n0005
>>
>> # Main12 intraCost overflow bug test
>> 720p50_parkrun_ter.y4m,--preset medium
>> diff --git a/source/x265cli.cpp b/source/x265cli.cpp
>> index c28dd7f8c..cfb832d2e 100755
>> --- a/source/x265cli.cpp
>> +++ b/source/x265cli.cpp
>> @@ -313,6 +313,28 @@ namespace X265_NS {
>> H0(" --master-display <string> SMPTE ST 2086 master
>> display color volume info SEI (HDR)\n");
>> H0(" format:
>> G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\n");
>> H0(" --max-cll <string> Specify content light level
>> info SEI as \"cll,fall\" (HDR).\n");
>> + H0(" --video-signal-type-preset <string> Specify
>> combinations of color primaries, transfer characteristics, color matrix,
>> range of luma and chroma signals, and chroma sample location\n");
>> + H0(" format:
>> <system-id>[:<color-volume>]\n");
>> + H0(" The color-volume
>> can be used only with the system-id options BT2100_PQ_YCC, BT2100_PQ_ICTCP,
>> and BT2100_PQ_RGB.\n");
>> + H0(" system-id
>> options and their corresponding values:\n");
>> + H0(" BT601_525:
>> --colorprim smpte170m --transfer smpte170m --colormatrix smpte170m
>> --range limited --chromaloc 0\n");
>> + H0(" BT601_626:
>> --colorprim bt470bg --transfer smpte170m --colormatrix bt470bg --range
>> limited --chromaloc 0\n");
>> + H0(" BT709_YCC:
>> --colorprim bt709 --transfer bt709 --colormatrix bt709 --range limited
>> --chromaloc 0\n");
>> + H0(" BT709_RGB:
>> --colorprim bt709 --transfer bt709 --colormatrix gbr --range limited\n");
>> + H0("
>> BT2020_YCC_NCL: --colorprim bt2020 --transfer bt2020-10 --colormatrix
>> bt709 --range limited --chromaloc 2\n");
>> + H0(" BT2020_RGB:
>> --colorprim bt2020 --transfer smpte2084 --colormatrix bt2020nc --range
>> limited\n");
>> + H0(" BT2100_PQ_YCC:
>> --colorprim bt2020 --transfer smpte2084 --colormatrix bt2020nc --range
>> limited --chromaloc 2\n");
>> + H0("
>> BT2100_PQ_ICTCP: --colorprim bt2020 --transfer smpte2084 --colormatrix
>> ictcp --range limited --chromaloc 2\n");
>> + H0(" BT2100_PQ_RGB:
>> --colorprim bt2020 --transfer smpte2084 --colormatrix gbr --range
>> limited\n");
>> + H0("
>> BT2100_HLG_YCC: --colorprim bt2020 --transfer arib-std-b67 --colormatrix
>> bt2020nc --range limited --chromaloc 2\n");
>> + H0("
>> BT2100_HLG_RGB: --colorprim bt2020 --transfer arib-std-b67 --colormatrix
>> gbr --range limited\n");
>> + H0(" FR709_RGB:
>> --colorprim bt709 --transfer bt709 --colormatrix gbr --range full\n");
>> + H0(" FR2020_RGB:
>> --colorprim bt2020 --transfer bt2020-10 --colormatrix gbr --range
>> full\n");
>> + H0(" FRP3D65_YCC:
>> --colorprim smpte432 --transfer bt709 --colormatrix smpte170m --range
>> full --chromaloc 1\n");
>> + H0(" color-volume
>> options and their corresponding values:\n");
>> + H0("
>> P3D65x1000n0005: --master-display
>> G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,5)\n");
>> + H0("
>> P3D65x4000n005: --master-display
>> G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(40000000,50)\n");
>> + H0("
>> BT2100x108n0005: --master-display
>> G(8500,39850)B(6550,2300)R(34000,146000)WP(15635,16450)L(10000000,1)\n");
>> H0(" --[no-]cll Emit content light level
>> info SEI. Default %s\n", OPT(param->bEmitCLL));
>> H0(" --[no-]hdr10 Control dumping of HDR10
>> SEI packet. If max-cll or master-display has non-zero values, this is
>> enabled. Default %s\n", OPT(param->bEmitHDR10SEI));
>> H0(" --[no-]hdr-opt Add luma and chroma offsets
>> for HDR/WCG content. Default %s. Now deprecated.\n", OPT(param->bHDROpt));
>> diff --git a/source/x265cli.h b/source/x265cli.h
>> index a24d25435..3d2480374 100644
>> --- a/source/x265cli.h
>> +++ b/source/x265cli.h
>> @@ -249,6 +249,7 @@ static const struct option long_options[] =
>> { "crop-rect", required_argument, NULL, 0 }, /* DEPRECATED */
>> { "master-display", required_argument, NULL, 0 },
>> { "max-cll", required_argument, NULL, 0 },
>> + {"video-signal-type-preset", required_argument, NULL, 0 },
>> { "min-luma", required_argument, NULL, 0 },
>> { "max-luma", required_argument, NULL, 0 },
>> { "log2-max-poc-lsb", required_argument, NULL, 8 },
>> --
>> 2.18.0.windows.1
>>
>>
>> --
>>
>> Thanks & Regards
>> *Niranjan Kumar B*
>> Video Codec Engineer
>> Media & AI Analytics
>> +91 958 511 1449
>> <https://multicorewareinc.com/>
>> _______________________________________________
>> x265-devel mailing list
>> x265-devel at videolan.org
>> https://mailman.videolan.org/listinfo/x265-devel
>>
>
>
> --
> Regards,
> *Aruna Matheswaran,*
> Video Codec Engineer,
> Media & AI analytics BU,
>
>
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20210226/40f6bbe2/attachment-0001.html>
More information about the x265-devel
mailing list