[FFmpeg-devel] [PATCH 1/2] Support HDR dynamic metdata (HDR10+) in HEVC decoder.

Mohammad Izadi moh.izadi at gmail.com
Thu Jan 3 22:05:40 EET 2019


---
 libavcodec/hevc_sei.c | 219 ++++++++++++++++++++++++++++++++++++++++--
 libavcodec/hevc_sei.h |  46 +++++++++
 libavcodec/hevcdec.c  | 195 +++++++++++++++++++++++++++++++++++++
 3 files changed, 454 insertions(+), 6 deletions(-)

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index c59bd4321e..da6f8257b8 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -206,10 +206,207 @@ static int decode_registered_user_data_closed_caption(HEVCSEIA53Caption *s, GetB
     return 0;
 }
 
-static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitContext *gb,
+static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s, GetBitContext *gb,
+                                                        void *logctx, int size)
+{
+    const int luminance_den = 10000;
+    const int peak_luminance_den = 15;
+    const int rgb_den = 100000;
+    const int fraction_pixel_den = 1000;
+    const int knee_point_den = 4095;
+    const int bezier_anchor_den = 1023;
+    const int saturation_weight_den = 8;
+
+    int bits_left = size * 8;
+    int w, i, j;
+
+    if (bits_left < 2)
+        return AVERROR_INVALIDDATA;
+
+    s->num_windows = get_bits(gb, 2);
+    bits_left -= 2;
+    if (s->num_windows < 1 || s->num_windows > 3) {
+        av_log(logctx, AV_LOG_ERROR, "num_windows=%d, must be in [1, 3]\n",
+               s->num_windows);
+        return AVERROR_INVALIDDATA;
+    }
+
+    if (bits_left < ((19 * 8 + 1) * (s->num_windows - 1)))
+        return AVERROR(EINVAL);
+    for (w = 1; w < s->num_windows; w++) {
+        s->params[w].window_upper_left_corner_x.num = get_bits(gb, 16);
+        s->params[w].window_upper_left_corner_y.num = get_bits(gb, 16);
+        s->params[w].window_lower_right_corner_x.num = get_bits(gb, 16);
+        s->params[w].window_lower_right_corner_y.num = get_bits(gb, 16);
+        // The corners are set to absolute coordinates here. They should be
+        // converted to the relative coordinates (in [0, 1]) in the decoder.
+        s->params[w].window_upper_left_corner_x.den = 1;
+        s->params[w].window_upper_left_corner_y.den = 1;
+        s->params[w].window_lower_right_corner_x.den = 1;
+        s->params[w].window_lower_right_corner_y.den = 1;
+
+        s->params[w].center_of_ellipse_x = get_bits(gb, 16);
+        s->params[w].center_of_ellipse_y = get_bits(gb, 16);
+        s->params[w].rotation_angle = get_bits(gb, 8);
+        s->params[w].semimajor_axis_internal_ellipse = get_bits(gb, 16);
+        s->params[w].semimajor_axis_external_ellipse = get_bits(gb, 16);
+        s->params[w].semiminor_axis_external_ellipse = get_bits(gb, 16);
+        s->params[w].overlap_process_option = get_bits(gb, 1);
+        bits_left -= 19 * 8 + 1;
+    }
+
+    if (bits_left < 28)
+        return AVERROR(EINVAL);
+    s->targeted_system_display_maximum_luminance.num = get_bits(gb, 27);
+    s->targeted_system_display_maximum_luminance.den = luminance_den;
+    s->targeted_system_display_actual_peak_luminance_flag = get_bits(gb, 1);
+    bits_left -= 28;
+
+    if (s->targeted_system_display_actual_peak_luminance_flag) {
+        int rows, cols;
+        if (bits_left < 10)
+            return AVERROR(EINVAL);
+        rows = get_bits(gb, 5);
+        cols = get_bits(gb, 5);
+        if (((rows < 2) && (rows > 25)) || ((cols < 2) && (cols > 25))) {
+            av_log(logctx, AV_LOG_ERROR, "num_rows=%d, num_cols=%d, they must "
+                   "be in [2, 25] for "
+                   "targeted_system_display_actual_peak_luminance\n",
+                   rows, cols);
+            return AVERROR_INVALIDDATA;
+        }
+        s->num_rows_targeted_system_display_actual_peak_luminance = rows;
+        s->num_cols_targeted_system_display_actual_peak_luminance = cols;
+        bits_left -= 10;
+
+        if (bits_left < (rows * cols * 4))
+            return AVERROR(EINVAL);
+
+        for (i = 0; i < rows; i++) {
+            for (j = 0; j < cols; j++) {
+                s->targeted_system_display_actual_peak_luminance[i][j].num =
+                    get_bits(gb, 4);
+                s->targeted_system_display_actual_peak_luminance[i][j].den =
+                    peak_luminance_den;
+            }
+        }
+        bits_left -= (rows * cols * 4);
+    }
+    for (w = 0; w < s->num_windows; w++) {
+        if (bits_left < (3 * 17 + 17 + 4))
+            return AVERROR(EINVAL);
+        for (i = 0; i < 3; i++) {
+            s->params[w].maxscl[i].num = get_bits(gb, 17);
+            s->params[w].maxscl[i].den = rgb_den;
+        }
+        s->params[w].average_maxrgb.num = get_bits(gb, 17);
+        s->params[w].average_maxrgb.den = rgb_den;
+        s->params[w].num_distribution_maxrgb_percentiles = get_bits(gb, 4);
+        bits_left -= (3 * 17 + 17 + 4);
+
+        if (bits_left <
+            (s->params[w].num_distribution_maxrgb_percentiles * 24))
+            return AVERROR(EINVAL);
+        for (i = 0; i < s->params[w].num_distribution_maxrgb_percentiles; i++) {
+            s->params[w].distribution_maxrgb[i].percentage = get_bits(gb, 7);
+            s->params[w].distribution_maxrgb[i].percentile.num =
+                get_bits(gb, 17);
+            s->params[w].distribution_maxrgb[i].percentile.den = rgb_den;
+        }
+        bits_left -= (s->params[w].num_distribution_maxrgb_percentiles * 24);
+
+        if (bits_left < 10)
+            return AVERROR(EINVAL);
+        s->params[w].fraction_bright_pixels.num = get_bits(gb, 10);
+        s->params[w].fraction_bright_pixels.den = fraction_pixel_den;
+        bits_left -= 10;
+    }
+    if (bits_left < 1)
+        return AVERROR(EINVAL);
+    s->mastering_display_actual_peak_luminance_flag = get_bits(gb, 1);
+    bits_left--;
+    if (s->mastering_display_actual_peak_luminance_flag) {
+        int rows, cols;
+        if (bits_left < 10)
+            return AVERROR(EINVAL);
+        rows = get_bits(gb, 5);
+        cols = get_bits(gb, 5);
+        if (((rows < 2) && (rows > 25)) || ((cols < 2) && (cols > 25))) {
+            av_log(logctx, AV_LOG_ERROR, "num_rows=%d, num_cols=%d, they must "
+                   "be in [2, 25] for "
+                   "mastering_display_actual_peak_luminance\n",
+                   rows, cols);
+            return AVERROR_INVALIDDATA;
+        }
+        s->num_rows_mastering_display_actual_peak_luminance = rows;
+        s->num_cols_mastering_display_actual_peak_luminance = cols;
+        bits_left -= 10;
+
+        if (bits_left < (rows * cols * 4))
+            return AVERROR(EINVAL);
+
+        for (i = 0; i < rows; i++) {
+            for (j = 0; j < cols; j++) {
+                s->mastering_display_actual_peak_luminance[i][j].num =
+                    get_bits(gb, 4);
+                s->mastering_display_actual_peak_luminance[i][j].den =
+                    peak_luminance_den;
+            }
+        }
+        bits_left -= (rows * cols * 4);
+    }
+
+    for (w = 0; w < s->num_windows; w++) {
+        if (bits_left < 1)
+            return AVERROR(EINVAL);
+        s->params[w].tone_mapping_flag = get_bits(gb, 1);
+        bits_left--;
+        if (s->params[w].tone_mapping_flag) {
+            if (bits_left < 28)
+                return AVERROR(EINVAL);
+            s->params[w].knee_point_x.num = get_bits(gb, 12);
+            s->params[w].knee_point_x.den = knee_point_den;
+            s->params[w].knee_point_y.num = get_bits(gb, 12);
+            s->params[w].knee_point_y.den = knee_point_den;
+            s->params[w].num_bezier_curve_anchors = get_bits(gb, 4);
+            bits_left -= 28;
+
+            if (bits_left < (s->params[w].num_bezier_curve_anchors * 10))
+                return AVERROR(EINVAL);
+            for (i = 0; i < s->params[w].num_bezier_curve_anchors; i++) {
+                s->params[w].bezier_curve_anchors[i].num = get_bits(gb, 10);
+                s->params[w].bezier_curve_anchors[i].den = bezier_anchor_den;
+            }
+            bits_left -= (s->params[w].num_bezier_curve_anchors * 10);
+        }
+
+        if (bits_left < 1)
+            return AVERROR(EINVAL);
+        s->params[w].color_saturation_mapping_flag = get_bits(gb, 1);
+        bits_left--;
+        if (s->params[w].color_saturation_mapping_flag) {
+            if (bits_left < 6)
+                return AVERROR(EINVAL);
+            s->params[w].color_saturation_weight.num = get_bits(gb, 6);
+            s->params[w].color_saturation_weight.den = saturation_weight_den;
+            bits_left -= 6;
+        }
+    }
+
+    s->present = 1;
+
+    skip_bits(gb, bits_left);
+
+    return 0;
+}
+
+static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s,
+                                                         GetBitContext *gb,
+                                                         void *logctx,
                                                          int size)
 {
-    uint32_t country_code;
+    uint8_t country_code;
+    uint16_t provider_code;
     uint32_t user_identifier;
 
     if (size < 7)
@@ -222,11 +419,21 @@ static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitConte
         size--;
     }
 
-    skip_bits(gb, 8);
-    skip_bits(gb, 8);
-
+    provider_code = get_bits(gb, 16);
     user_identifier = get_bits_long(gb, 32);
 
+    // Check for dynamic metadata - HDR10+(SMPTE 2094-40).
+    if ((provider_code == 0x003C) &&
+        ((user_identifier & 0xFFFFFF00) == 0x00010400)) {
+        s->dynamic_hdr_plus.itu_t_t35_country_code =
+            country_code;
+        s->dynamic_hdr_plus.application_version =
+            (uint8_t)((user_identifier & 0x000000FF));
+
+        return decode_registered_user_data_dynamic_hdr_plus(
+            &s->dynamic_hdr_plus, gb, logctx, size);
+    }
+
     switch (user_identifier) {
         case MKBETAG('G', 'A', '9', '4'):
             return decode_registered_user_data_closed_caption(&s->a53_caption, gb, size);
@@ -292,7 +499,7 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s,
     case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS:
         return decode_nal_sei_active_parameter_sets(s, gb, logctx);
     case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
-        return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, size);
+        return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, logctx, size);
     case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
         return decode_nal_sei_alternative_transfer(&s->alternative_transfer, gb);
     default:
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index 2fec00ace0..ef235560d1 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -23,6 +23,7 @@
 
 #include <stdint.h>
 
+#include "libavutil/rational.h"
 #include "get_bits.h"
 
 /**
@@ -94,6 +95,50 @@ typedef struct HEVCSEIMasteringDisplay {
     uint32_t min_luminance;
 } HEVCSEIMasteringDisplay;
 
+typedef struct HEVCSEIDynamicHDRPlus{
+    int present;
+    uint8_t itu_t_t35_country_code;
+    uint8_t application_version;
+    uint8_t num_windows;
+    struct {
+        AVRational window_upper_left_corner_x;
+        AVRational window_upper_left_corner_y;
+        AVRational window_lower_right_corner_x;
+        AVRational window_lower_right_corner_y;
+        uint16_t center_of_ellipse_x;
+        uint16_t center_of_ellipse_y;
+        uint8_t rotation_angle;
+        uint16_t semimajor_axis_internal_ellipse;
+        uint16_t semimajor_axis_external_ellipse;
+        uint16_t semiminor_axis_external_ellipse;
+        uint8_t overlap_process_option;
+        AVRational maxscl[3];
+        AVRational average_maxrgb;
+        uint8_t num_distribution_maxrgb_percentiles;
+        struct {
+            uint8_t percentage;
+            AVRational percentile;
+        } distribution_maxrgb[15];
+        AVRational fraction_bright_pixels;
+        uint8_t tone_mapping_flag;
+        AVRational knee_point_x;
+        AVRational knee_point_y;
+        uint8_t num_bezier_curve_anchors;
+        AVRational bezier_curve_anchors[15];
+        uint8_t color_saturation_mapping_flag;
+        AVRational color_saturation_weight;
+    } params[3];
+    AVRational targeted_system_display_maximum_luminance;
+    uint8_t targeted_system_display_actual_peak_luminance_flag;
+    uint8_t num_rows_targeted_system_display_actual_peak_luminance;
+    uint8_t num_cols_targeted_system_display_actual_peak_luminance;
+    AVRational targeted_system_display_actual_peak_luminance[25][25];
+    uint8_t mastering_display_actual_peak_luminance_flag;
+    uint8_t num_rows_mastering_display_actual_peak_luminance;
+    uint8_t num_cols_mastering_display_actual_peak_luminance;
+    AVRational mastering_display_actual_peak_luminance[25][25];
+} HEVCSEIDynamicHDRPlus;
+
 typedef struct HEVCSEIContentLight {
     int present;
     uint16_t max_content_light_level;
@@ -109,6 +154,7 @@ typedef struct HEVCSEI {
     HEVCSEIPictureHash picture_hash;
     HEVCSEIFramePacking frame_packing;
     HEVCSEIDisplayOrientation display_orientation;
+    HEVCSEIDynamicHDRPlus dynamic_hdr_plus;
     HEVCSEIPictureTiming picture_timing;
     HEVCSEIA53Caption a53_caption;
     HEVCSEIMasteringDisplay mastering_display;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 10bf2563c0..9bd84687e6 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -28,6 +28,7 @@
 #include "libavutil/display.h"
 #include "libavutil/internal.h"
 #include "libavutil/mastering_display_metadata.h"
+#include "libavutil/hdr_dynamic_metadata.h"
 #include "libavutil/md5.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -2769,6 +2770,200 @@ static int set_side_data(HEVCContext *s)
         s->avctx->color_trc = out->color_trc = s->sei.alternative_transfer.preferred_transfer_characteristics;
     }
 
+    if (s->sei.dynamic_hdr_plus.present) {
+        int w, i, j;
+        AVDynamicHDRPlus *metadata =
+            av_dynamic_hdr_plus_create_side_data(out);
+        if (!metadata) return AVERROR(ENOMEM);
+
+        metadata->itu_t_t35_country_code = s->sei.dynamic_hdr_plus.itu_t_t35_country_code;
+        metadata->application_version = s->sei.dynamic_hdr_plus.application_version;
+        metadata->num_windows = s->sei.dynamic_hdr_plus.num_windows;
+        metadata->targeted_system_display_maximum_luminance.num =
+            s->sei.dynamic_hdr_plus.targeted_system_display_maximum_luminance.num;
+        metadata->targeted_system_display_maximum_luminance.den =
+            s->sei.dynamic_hdr_plus.targeted_system_display_maximum_luminance.den;
+        metadata->targeted_system_display_actual_peak_luminance_flag =
+            s->sei.dynamic_hdr_plus.targeted_system_display_actual_peak_luminance_flag;
+        metadata->mastering_display_actual_peak_luminance_flag =
+            s->sei.dynamic_hdr_plus.mastering_display_actual_peak_luminance_flag;
+        if (metadata->targeted_system_display_actual_peak_luminance_flag){
+            metadata->num_rows_targeted_system_display_actual_peak_luminance =
+                s->sei.dynamic_hdr_plus.num_rows_targeted_system_display_actual_peak_luminance;
+            metadata->num_cols_targeted_system_display_actual_peak_luminance =
+                s->sei.dynamic_hdr_plus.num_cols_targeted_system_display_actual_peak_luminance;
+            for (i = 0;
+                 i < metadata->num_rows_targeted_system_display_actual_peak_luminance;
+                 i++){
+                for (j = 0;
+                     j < metadata->num_cols_targeted_system_display_actual_peak_luminance;
+                     j++){
+                    metadata->targeted_system_display_actual_peak_luminance[i][j].num =
+                        s->sei.dynamic_hdr_plus.targeted_system_display_actual_peak_luminance[i][j].num;
+                    metadata->targeted_system_display_actual_peak_luminance[i][j].den =
+                        s->sei.dynamic_hdr_plus.targeted_system_display_actual_peak_luminance[i][j].den;
+                }
+            }
+        }
+        if (metadata->mastering_display_actual_peak_luminance_flag){
+            metadata->num_rows_mastering_display_actual_peak_luminance =
+                s->sei.dynamic_hdr_plus.num_rows_mastering_display_actual_peak_luminance;
+            metadata->num_cols_mastering_display_actual_peak_luminance =
+                s->sei.dynamic_hdr_plus.num_cols_mastering_display_actual_peak_luminance;
+            for (i = 0;
+                 i < metadata->num_rows_mastering_display_actual_peak_luminance;
+                 i++){
+                for (j = 0;
+                     j < metadata->num_cols_mastering_display_actual_peak_luminance;
+                     j++){
+                    metadata->mastering_display_actual_peak_luminance[i][j].num =
+                        s->sei.dynamic_hdr_plus.mastering_display_actual_peak_luminance[i][j].num;
+                    metadata->mastering_display_actual_peak_luminance[i][j].den =
+                        s->sei.dynamic_hdr_plus.mastering_display_actual_peak_luminance[i][j].den;
+                }
+            }
+        }
+        // Convert coordinates to relative coordinate in [0, 1].
+        for (w = 0; w < metadata->num_windows; w++) {
+            if (w==0){
+                metadata->params[0].window_upper_left_corner_x.num  = 0;
+                metadata->params[0].window_upper_left_corner_y.num  = 0;
+                metadata->params[0].window_lower_right_corner_x.num = out->width-1;
+                metadata->params[0].window_lower_right_corner_y.num = out->height-1;
+            }else{
+                metadata->params[0].window_upper_left_corner_x.num  =
+                    s->sei.dynamic_hdr_plus.params[0].window_upper_left_corner_x.num;
+                metadata->params[0].window_upper_left_corner_y.num  =
+                    s->sei.dynamic_hdr_plus.params[0].window_upper_left_corner_y.num;
+                metadata->params[0].window_lower_right_corner_x.num =
+                    s->sei.dynamic_hdr_plus.params[0].window_lower_right_corner_x.num;
+                metadata->params[0].window_lower_right_corner_y.num =
+                    s->sei.dynamic_hdr_plus.params[0].window_lower_right_corner_y.num;
+            }
+            metadata->params[w].window_upper_left_corner_x.den = out->width-1;
+            metadata->params[w].window_upper_left_corner_y.den = out->height-1;
+            metadata->params[w].window_lower_right_corner_x.den = out->width-1;
+            metadata->params[w].window_lower_right_corner_y.den = out->height-1;
+        }
+
+        metadata->targeted_system_display_maximum_luminance =
+            s->sei.dynamic_hdr_plus.targeted_system_display_maximum_luminance;
+        metadata->targeted_system_display_actual_peak_luminance_flag =
+            s->sei.dynamic_hdr_plus.targeted_system_display_actual_peak_luminance_flag;
+        metadata->mastering_display_actual_peak_luminance_flag =
+            s->sei.dynamic_hdr_plus.mastering_display_actual_peak_luminance_flag;
+        av_log(s->avctx, AV_LOG_DEBUG, "HDR10+(SMPTE 2094-40):{\n");
+        av_log(s->avctx, AV_LOG_DEBUG,
+               "targeted_system_display_maximum_luminance=%5.4f\n"
+               "targeted_system_display_actual_peak_luminance_flag=%d\n"
+               "mastering_display_actual_peak_luminance_flag=%d\n",
+               av_q2d(metadata->targeted_system_display_maximum_luminance),
+               metadata->targeted_system_display_actual_peak_luminance_flag,
+               metadata->mastering_display_actual_peak_luminance_flag);
+
+        for (w = 0; w < metadata->num_windows; w++) {
+            metadata->params[w].center_of_ellipse_x =
+                s->sei.dynamic_hdr_plus.params[w].center_of_ellipse_x;
+            metadata->params[w].center_of_ellipse_y =
+                s->sei.dynamic_hdr_plus.params[w].center_of_ellipse_y;
+            metadata->params[w].rotation_angle =
+                s->sei.dynamic_hdr_plus.params[w].rotation_angle;
+            metadata->params[w].semimajor_axis_internal_ellipse =
+                s->sei.dynamic_hdr_plus.params[w].semimajor_axis_internal_ellipse;
+            metadata->params[w].semimajor_axis_external_ellipse =
+                s->sei.dynamic_hdr_plus.params[w].semimajor_axis_external_ellipse;
+            metadata->params[w].semiminor_axis_external_ellipse =
+                s->sei.dynamic_hdr_plus.params[w].semiminor_axis_external_ellipse;
+            metadata->params[w].overlap_process_option =
+                s->sei.dynamic_hdr_plus.params[w].overlap_process_option;
+            for (i = 0; i < 3; i++){
+                metadata->params[w].maxscl[i].num =
+                    s->sei.dynamic_hdr_plus.params[w].maxscl[i].num;
+                metadata->params[w].maxscl[i].den =
+                    s->sei.dynamic_hdr_plus.params[w].maxscl[i].den;
+            }
+            metadata->params[w].average_maxrgb.num =
+                s->sei.dynamic_hdr_plus.params[w].average_maxrgb.num;
+            metadata->params[w].average_maxrgb.den =
+                s->sei.dynamic_hdr_plus.params[w].average_maxrgb.den;
+            metadata->params[w].num_distribution_maxrgb_percentiles =
+                s->sei.dynamic_hdr_plus.params[w].num_distribution_maxrgb_percentiles;
+            metadata->params[w].fraction_bright_pixels.num =
+                s->sei.dynamic_hdr_plus.params[w].fraction_bright_pixels.num;
+            metadata->params[w].fraction_bright_pixels.den =
+                s->sei.dynamic_hdr_plus.params[w].fraction_bright_pixels.den;
+            metadata->params[w].tone_mapping_flag =
+                s->sei.dynamic_hdr_plus.params[w].tone_mapping_flag;
+            metadata->params[w].knee_point_x.num =
+                s->sei.dynamic_hdr_plus.params[w].knee_point_x.num;
+            metadata->params[w].knee_point_x.den =
+                s->sei.dynamic_hdr_plus.params[w].knee_point_x.den;
+            metadata->params[w].knee_point_y.num =
+                s->sei.dynamic_hdr_plus.params[w].knee_point_y.num;
+            metadata->params[w].knee_point_y.den =
+                s->sei.dynamic_hdr_plus.params[w].knee_point_y.den;
+            metadata->params[w].num_bezier_curve_anchors =
+                s->sei.dynamic_hdr_plus.params[w].num_bezier_curve_anchors;
+            metadata->params[w].color_saturation_mapping_flag =
+                s->sei.dynamic_hdr_plus.params[w].color_saturation_mapping_flag;
+            metadata->params[w].color_saturation_weight.num =
+                s->sei.dynamic_hdr_plus.params[w].color_saturation_weight.num;
+            metadata->params[w].color_saturation_weight.den =
+                s->sei.dynamic_hdr_plus.params[w].color_saturation_weight.den;
+            av_log(s->avctx, AV_LOG_DEBUG,
+                   "window[%d]:{\nBox(%d,%d,%d,%d) "
+                   "maxscl=RGB(%5.4f,%5.4f,%5.4f)  average_maxrgb=%5.4f "
+                   "fraction_bright_pixels=%5.4f ", w,
+                   metadata->params[w].window_upper_left_corner_x.num,
+                   metadata->params[w].window_upper_left_corner_y.num,
+                   metadata->params[w].window_lower_right_corner_x.num,
+                   metadata->params[w].window_lower_right_corner_y.num,
+                   av_q2d(metadata->params[w].maxscl[0]),
+                   av_q2d(metadata->params[w].maxscl[1]),
+                   av_q2d(metadata->params[w].maxscl[2]),
+                   av_q2d(metadata->params[w].average_maxrgb),
+                   av_q2d(metadata->params[w].fraction_bright_pixels));
+            av_log(s->avctx, AV_LOG_DEBUG, "distribution_maxrgb[");
+            for (i = 0;
+                 i < metadata->params[w].num_distribution_maxrgb_percentiles;
+                 i++) {
+                metadata->params[w].distribution_maxrgb[i].percentage =
+                    s->sei.dynamic_hdr_plus.params[w].distribution_maxrgb[i].percentage;
+                metadata->params[w].distribution_maxrgb[i].percentile.num =
+                    s->sei.dynamic_hdr_plus.params[w].distribution_maxrgb[i].percentile.num;
+                metadata->params[w].distribution_maxrgb[i].percentile.den =
+                    s->sei.dynamic_hdr_plus.params[w].distribution_maxrgb[i].percentile.den;
+                av_log(s->avctx, AV_LOG_DEBUG, "(%d,%5.4f)",
+                       metadata->params[w].distribution_maxrgb[i].percentage,
+                       av_q2d(metadata->params[w].distribution_maxrgb[i].percentile));
+            }
+            av_log(s->avctx, AV_LOG_DEBUG, "] ");
+            if (metadata->params[w].tone_mapping_flag) {
+                av_log(s->avctx, AV_LOG_DEBUG, "knee_point(%5.4f,%5.4f) ",
+                       av_q2d(metadata->params[w].knee_point_x),
+                       av_q2d(metadata->params[w].knee_point_y));
+            }
+            av_log(s->avctx, AV_LOG_DEBUG, "bezier_curve_anchors(");
+            for (i = 0; i < metadata->params[w].num_bezier_curve_anchors; i++) {
+                metadata->params[w].bezier_curve_anchors[i].num =
+                    s->sei.dynamic_hdr_plus.params[w].bezier_curve_anchors[i].num;
+                metadata->params[w].bezier_curve_anchors[i].den =
+                    s->sei.dynamic_hdr_plus.params[w].bezier_curve_anchors[i].den;
+                av_log(s->avctx, AV_LOG_DEBUG, "%5.4f ",
+                       av_q2d(metadata->params[w].bezier_curve_anchors[i]));
+            }
+            av_log(s->avctx, AV_LOG_DEBUG, ")");
+            if (metadata->params[w].color_saturation_mapping_flag) {
+                av_log(s->avctx, AV_LOG_DEBUG,
+                       " color_saturation_weight=%5.4f",
+                       av_q2d(metadata->params[w].color_saturation_weight));
+            }
+            av_log(s->avctx, AV_LOG_DEBUG, "}\n");
+        }
+        av_log(s->avctx, AV_LOG_DEBUG,
+               "} End of HDR10+ (SMPTE 2094-40)\n");
+    }
+
     return 0;
 }
 
-- 
2.20.1.415.g653613c723-goog



More information about the ffmpeg-devel mailing list