diff mbox series

[FFmpeg-devel,v2] avcodec/dpxenc: stop hardcoding color trc/primaries

Message ID 20210601191828.6957-1-val.zapod.vz@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2] avcodec/dpxenc: stop hardcoding color trc/primaries | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Valerii Zapodovnikov June 1, 2021, 7:18 p.m. UTC
Updated FATE hashes and added gamma 2.8. Also please note that FATE
samples are useless. I also fixed gamma 2.2 to System M.
Also this does not do YCbCr stuff, so no matrices are here.
Fixes more or less #6023, except for printing density stuff.

Co-authored-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/dpxenc.c           | 38 +++++++++++++++++++++++++++++++++--
 tests/ref/lavf/dpx            |  2 +-
 tests/ref/lavf/gbrp10le.dpx   |  2 +-
 tests/ref/lavf/gbrp12le.dpx   |  2 +-
 tests/ref/lavf/rgb48le.dpx    |  2 +-
 tests/ref/lavf/rgb48le_10.dpx |  2 +-
 tests/ref/lavf/rgba64le.dpx   |  2 +-
 7 files changed, 42 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c
index fa8b7d5ddc..90a47dc21e 100644
--- a/libavcodec/dpxenc.c
+++ b/libavcodec/dpxenc.c
@@ -174,6 +174,40 @@  static void encode_gbrp12(AVCodecContext *avctx, const AVFrame *pic, uint8_t *ds
     }
 }
 
+static int get_dpx_pri(int color_pri)
+{
+    switch (color_pri) {
+    case AVCOL_PRI_BT709:
+        return 6;
+    case AVCOL_PRI_SMPTE240M:
+    case AVCOL_PRI_SMPTE170M:
+        return 9;
+    case AVCOL_PRI_BT470BG:
+        return 10;
+    default:
+        return 0;
+    }
+}
+
+static int get_dpx_trc(int color_trc)
+{
+    switch (color_trc) {
+    case AVCOL_TRC_LINEAR:
+        return 2;
+    case AVCOL_TRC_BT709:
+        return 6;
+    case AVCOL_TRC_SMPTE240M:
+    case AVCOL_TRC_SMPTE170M:
+        return 9;
+    case AVCOL_TRC_GAMMA22:
+        return 8;
+    case AVCOL_TRC_GAMMA28:
+        return 7;
+    default:
+        return 0;
+    }
+}
+
 static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                         const AVFrame *frame, int *got_packet)
 {
@@ -219,8 +253,8 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     write32(buf + 772, avctx->width);
     write32(buf + 776, avctx->height);
     buf[800] = s->descriptor;
-    buf[801] = 2; /* linear transfer */
-    buf[802] = 2; /* linear colorimetric */
+    buf[801] = get_dpx_trc(avctx->color_trc);
+    buf[802] = get_dpx_pri(avctx->color_primaries);
     buf[803] = s->bits_per_component;
     write16(buf + 804, (s->bits_per_component == 10 || s->bits_per_component == 12) ?
                        1 : 0); /* packing method */
diff --git a/tests/ref/lavf/dpx b/tests/ref/lavf/dpx
index 68fe25afcd..39e513430a 100644
--- a/tests/ref/lavf/dpx
+++ b/tests/ref/lavf/dpx
@@ -1,3 +1,3 @@ 
-4c8880d5835ffb5fe37c1ed8c8d404de *tests/data/images/dpx/02.dpx
+233e219cbfa61e0b77f8e4fad05b2404 *tests/data/images/dpx/02.dpx
 tests/data/images/dpx/%02d.dpx CRC=0x6da01946
 305792 tests/data/images/dpx/02.dpx
diff --git a/tests/ref/lavf/gbrp10le.dpx b/tests/ref/lavf/gbrp10le.dpx
index b33da34e20..16ac9ebc66 100644
--- a/tests/ref/lavf/gbrp10le.dpx
+++ b/tests/ref/lavf/gbrp10le.dpx
@@ -1,3 +1,3 @@ 
-7ca935d5d5e00c54acbc85565d3039b6 *tests/data/images/gbrp10le.dpx/02.gbrp10le.dpx
+69b9da05fa73a4495ea04ce5f45b51d6 *tests/data/images/gbrp10le.dpx/02.gbrp10le.dpx
 tests/data/images/gbrp10le.dpx/%02d.gbrp10le.dpx CRC=0xe6663fba
 407168 tests/data/images/gbrp10le.dpx/02.gbrp10le.dpx
diff --git a/tests/ref/lavf/gbrp12le.dpx b/tests/ref/lavf/gbrp12le.dpx
index e2e794ecc6..8b9dae4fbc 100644
--- a/tests/ref/lavf/gbrp12le.dpx
+++ b/tests/ref/lavf/gbrp12le.dpx
@@ -1,3 +1,3 @@ 
-a4cfea1797c928f2eff73573e559675d *tests/data/images/gbrp12le.dpx/02.gbrp12le.dpx
+056a0852dcd8e4d8727114df4a247dd4 *tests/data/images/gbrp12le.dpx/02.gbrp12le.dpx
 tests/data/images/gbrp12le.dpx/%02d.gbrp12le.dpx CRC=0x1c755633
 609920 tests/data/images/gbrp12le.dpx/02.gbrp12le.dpx
diff --git a/tests/ref/lavf/rgb48le.dpx b/tests/ref/lavf/rgb48le.dpx
index 073153898a..803bb0f5e6 100644
--- a/tests/ref/lavf/rgb48le.dpx
+++ b/tests/ref/lavf/rgb48le.dpx
@@ -1,3 +1,3 @@ 
-075963c3c08978b6a20555ba09161434 *tests/data/images/rgb48le.dpx/02.rgb48le.dpx
+6e7d757279eaa914a92be107f8f01077 *tests/data/images/rgb48le.dpx/02.rgb48le.dpx
 tests/data/images/rgb48le.dpx/%02d.rgb48le.dpx CRC=0xe5b9c023
 609920 tests/data/images/rgb48le.dpx/02.rgb48le.dpx
diff --git a/tests/ref/lavf/rgb48le_10.dpx b/tests/ref/lavf/rgb48le_10.dpx
index ce36e5079f..dfeb059787 100644
--- a/tests/ref/lavf/rgb48le_10.dpx
+++ b/tests/ref/lavf/rgb48le_10.dpx
@@ -1,3 +1,3 @@ 
-b9f22728f8ff393bf30cf6cbd624fa95 *tests/data/images/rgb48le_10.dpx/02.rgb48le_10.dpx
+097c4ff8138d76bffa51c1e8c36ea90f *tests/data/images/rgb48le_10.dpx/02.rgb48le_10.dpx
 tests/data/images/rgb48le_10.dpx/%02d.rgb48le_10.dpx CRC=0xf38d5830
 407168 tests/data/images/rgb48le_10.dpx/02.rgb48le_10.dpx
diff --git a/tests/ref/lavf/rgba64le.dpx b/tests/ref/lavf/rgba64le.dpx
index b4092c9fd8..82771c41bd 100644
--- a/tests/ref/lavf/rgba64le.dpx
+++ b/tests/ref/lavf/rgba64le.dpx
@@ -1,3 +1,3 @@ 
-545603630f30dec2768c8ae8d12eb8ea *tests/data/images/rgba64le.dpx/02.rgba64le.dpx
+51ccad3d05c1cef9db958adf01c9b55f *tests/data/images/rgba64le.dpx/02.rgba64le.dpx
 tests/data/images/rgba64le.dpx/%02d.rgba64le.dpx CRC=0xe72ce131
 812672 tests/data/images/rgba64le.dpx/02.rgba64le.dpx