diff mbox series

[FFmpeg-devel,v3,1/4] libavutil/dovi_meta: Add nlq_pivots to AVDOVIDataMapping

Message ID 20220617203519.74426-2-tcChlisop0@gmail.com
State New
Headers show
Series DOVI: Add NLQ pivots to AVDOVIDataMapping | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

quietvoid June 17, 2022, 8:35 p.m. UTC
The NLQ pivots are not documented but should be present
in the header for profile 7 RPU format.
It has been verified using Dolby's verification toolkit.

Signed-off-by: quietvoid <tcChlisop0@gmail.com>
---
 libavcodec/dovi_rpu.c | 9 ++++++++-
 libavutil/dovi_meta.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/dovi_rpu.c b/libavcodec/dovi_rpu.c
index a87562c8a3..31e87cfbcc 100644
--- a/libavcodec/dovi_rpu.c
+++ b/libavcodec/dovi_rpu.c
@@ -117,7 +117,7 @@  int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame)
     /* Copy only the parts of these structs known to us at compiler-time. */
 #define COPY(t, a, b, last) memcpy(a, b, offsetof(t, last) + sizeof((b)->last))
     COPY(AVDOVIRpuDataHeader, av_dovi_get_header(dovi), &s->header, disable_residual_flag);
-    COPY(AVDOVIDataMapping, av_dovi_get_mapping(dovi), s->mapping, nlq[2].linear_deadzone_threshold);
+    COPY(AVDOVIDataMapping, av_dovi_get_mapping(dovi), s->mapping, nlq_pivots[1]);
     COPY(AVDOVIColorMetadata, av_dovi_get_color(dovi), s->color, source_diagonal);
     return 0;
 }
@@ -315,7 +315,14 @@  int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size)
         }
 
         if (use_nlq) {
+            int nlq_pivot = 0;
             vdr->mapping.nlq_method_idc = get_bits(gb, 3);
+
+            for (int i = 0; i < 2; i++) {
+                nlq_pivot += get_bits(gb, hdr->bl_bit_depth);
+                vdr->mapping.nlq_pivots[i] = av_clip_uint16(nlq_pivot);
+            }
+
             /**
              * The patent mentions another legal value, NLQ_MU_LAW, but it's
              * not documented anywhere how to parse or apply that type of NLQ.
diff --git a/libavutil/dovi_meta.h b/libavutil/dovi_meta.h
index 3d11e02bff..6afc7b055a 100644
--- a/libavutil/dovi_meta.h
+++ b/libavutil/dovi_meta.h
@@ -147,6 +147,7 @@  typedef struct AVDOVIDataMapping {
     uint32_t num_x_partitions;
     uint32_t num_y_partitions;
     AVDOVINLQParams nlq[3]; /* per component */
+    uint16_t nlq_pivots[2]; /* nlq_pred_pivot_value */
 } AVDOVIDataMapping;
 
 /**