From patchwork Mon Jan 27 19:08:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mohammad Izadi X-Patchwork-Id: 17588 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 167BA4477E4 for ; Mon, 27 Jan 2020 21:34:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E622268AD3F; Mon, 27 Jan 2020 21:34:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0A7D56880AF for ; Mon, 27 Jan 2020 21:34:26 +0200 (EET) Received: by mail-qv1-f50.google.com with SMTP id l14so5047977qvu.12 for ; Mon, 27 Jan 2020 11:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DyTthxrSo5ljN5ksfg14guvDGLZaUx7xWI9GMlTzBxg=; b=FS3vjje65mv8J86E3dgyni15+VC/We1yjcANbR+4fqJVmb/O5UcwdZ5FB6zEAzR5B4 hToTHII+SLRnmHUhkCrSoUow5oYzlLndiSxih2Pme8tKM4Yy0yTnk93/6EANbpQ2Hycr ZxSxKjgUXEHNbEmtj3Pao+T2CQoLvzOFSb2RYjru4tCgGt+UUy3KWWjRxL8IVgSOHQyo eEXzVXQ5c3MPa1IbDsna0XwUOwLTls/2Gm7V6gb1yiCnaB22PNey8WbYan5Xx/GG2W6R ABHk2jhYhICW1c0xJrlwwfJGeWa6R/W560NNiPBLcUHOUyYxDAbq5QP2St/1zTWZbfmb H+Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DyTthxrSo5ljN5ksfg14guvDGLZaUx7xWI9GMlTzBxg=; b=Iagys56Um84YX+GmD4d6647xPUwgMPq3Wve+d5KFgTA/G3J6CWrwxFEsHei0C7x6kd Q10Dtn18huM+s+GlrUKY5nQNYnZhtWS2JuS2mz2XJAvcsR+xasHKBZLnt+cS4yz/khEu DX6CgLsP2weqYZG4UQ747hHvyL3NPYBJRFO+sfRY5rd7kEKApZisoy6lHT+CLP6jF460 iicpcFhjqQf170vO7T49whd0kd0jyCIWQpHB1HMlIY3RtjL0J8yAXpHv3lIqXBGT7ZxW XTXAQtzx/AhaZxuKMhJisjgussVyhp6deyediSPXolwKT4Z1YGabI+mbYNQsoszX3NsC BbCw== X-Gm-Message-State: APjAAAXDayVvk3pcR2dHqarPwCgYdPDa6Q0sADD3sixzhHxUiC6rGBEB BqsvElPavSydlSpN/pHxlbMCUh0= X-Google-Smtp-Source: APXvYqwsrQ4z+ODdJYFLv9kho0LN4NZsx6HrcfMm39AO2GkSsVdsYfEcktMm0jN6e3KEyMcB+xEL2A== X-Received: by 2002:aa7:92c7:: with SMTP id k7mr123941pfa.8.1580152126096; Mon, 27 Jan 2020 11:08:46 -0800 (PST) Received: from izadi.mtv.corp.google.com ([2620:0:1000:4001:366c:3b00:ff02:a7ea]) by smtp.gmail.com with ESMTPSA id j21sm15765427pji.7.2020.01.27.11.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 11:08:45 -0800 (PST) From: Mohammad Izadi To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 Jan 2020 11:08:32 -0800 Message-Id: <20200127190832.224284-1-moh.izadi@gmail.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] Update HDR10+ metadata structure. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Mohammad Izadi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Mohammad Izadi Trying to read HDR10+ metadata from HEVC/SEI and pass it to packet side data in the follow-up CLs. --- libavutil/hdr_dynamic_metadata.c | 386 +++++++++++++++++++++++++++++++ libavutil/hdr_dynamic_metadata.h | 51 +++- libavutil/version.h | 2 +- 3 files changed, 431 insertions(+), 8 deletions(-) diff --git a/libavutil/hdr_dynamic_metadata.c b/libavutil/hdr_dynamic_metadata.c index 0fa1ee82de..e321a22af8 100644 --- a/libavutil/hdr_dynamic_metadata.c +++ b/libavutil/hdr_dynamic_metadata.c @@ -21,6 +21,19 @@ #include "hdr_dynamic_metadata.h" #include "mem.h" +static const uint8_t usa_country_code = 0xB5; +static const uint16_t smpte_provider_code = 0x003C; +static const uint16_t smpte2094_40_provider_oriented_code = 0x0001; +static const uint16_t smpte2094_40_application_identifier = 0x04; + +static const int64_t luminance_den = 1; +static const int32_t peak_luminance_den = 15; +static const int64_t rgb_den = 100000; +static const int32_t fraction_pixel_den = 1000; +static const int32_t knee_point_den = 4095; +static const int32_t bezier_anchor_den = 1023; +static const int32_t saturation_weight_den = 8; + AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size) { AVDynamicHDRPlus *hdr_plus = av_mallocz(sizeof(AVDynamicHDRPlus)); @@ -33,6 +46,48 @@ AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size) return hdr_plus; } +AVDynamicHDRPlus *av_dynamic_hdr_plus(GetBitContext *gb, size_t *size) +{ + uint8_t country_code; + uint16_t provider_code; + uint16_t provider_oriented_code; + uint8_t application_identifier; + uint8_t application_version; + AVDynamicHDRPlus *hdr_plus; + int err; + + if (get_bits_left(gb) < 7) + return NULL; + + country_code = get_bits(gb, 8); + provider_code = get_bits(gb, 16); + + if (country_code != usa_country_code || + provider_code != smpte_provider_code) + return NULL; + + // A/341 Amendment – 2094-40 + provider_oriented_code = get_bits(gb, 16); + application_identifier = get_bits(gb, 8); + application_version = get_bits(gb, 8); + if (provider_oriented_code != smpte2094_40_provider_oriented_code || + application_identifier != smpte2094_40_application_identifier) + return NULL; + + hdr_plus = av_dynamic_hdr_plus_alloc(size); + if (!hdr_plus) + return NULL; + + hdr_plus->application_version = application_version; + err = decode_itu_t_t35_to_dynamic_hdr_plus(gb, hdr_plus); + if (err < 0) { + av_freep(&hdr_plus); + return NULL; + } + + return hdr_plus; +} + AVDynamicHDRPlus *av_dynamic_hdr_plus_create_side_data(AVFrame *frame) { AVFrameSideData *side_data = av_frame_new_side_data(frame, @@ -43,5 +98,336 @@ AVDynamicHDRPlus *av_dynamic_hdr_plus_create_side_data(AVFrame *frame) memset(side_data->data, 0, sizeof(AVDynamicHDRPlus)); + return (AVDynamicHDRPlus *)side_data->data; } + +int decode_itu_t_t35_to_dynamic_hdr_plus(GetBitContext *gb, AVDynamicHDRPlus *s) +{ + int w, i, j; + + if (get_bits_left(gb) < 2) + return AVERROR_INVALIDDATA; + s->num_windows = get_bits(gb, 2); + + if (s->num_windows < 1 || s->num_windows > 3) { + return AVERROR_INVALIDDATA; + } + + if (get_bits_left(gb) < ((19 * 8 + 1) * (s->num_windows - 1))) + return AVERROR_INVALIDDATA; + 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_bits1(gb); + } + + if (get_bits_left(gb) < 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_bits1(gb); + + if (s->targeted_system_display_actual_peak_luminance_flag) { + int rows, cols; + if (get_bits_left(gb) < 10) + return AVERROR(EINVAL); + rows = get_bits(gb, 5); + cols = get_bits(gb, 5); + if (((rows < 2) || (rows > 25)) || ((cols < 2) || (cols > 25))) { + return AVERROR_INVALIDDATA; + } + s->num_rows_targeted_system_display_actual_peak_luminance = rows; + s->num_cols_targeted_system_display_actual_peak_luminance = cols; + + if (get_bits_left(gb) < (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; + } + } + } + for (w = 0; w < s->num_windows; w++) { + if (get_bits_left(gb) < (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); + + if (get_bits_left(gb) < + (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; + } + + if (get_bits_left(gb) < 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; + } + if (get_bits_left(gb) < 1) + return AVERROR(EINVAL); + s->mastering_display_actual_peak_luminance_flag = get_bits1(gb); + if (s->mastering_display_actual_peak_luminance_flag) { + int rows, cols; + if (get_bits_left(gb) < 10) + return AVERROR(EINVAL); + rows = get_bits(gb, 5); + cols = get_bits(gb, 5); + if (((rows < 2) || (rows > 25)) || ((cols < 2) || (cols > 25))) { + return AVERROR_INVALIDDATA; + } + s->num_rows_mastering_display_actual_peak_luminance = rows; + s->num_cols_mastering_display_actual_peak_luminance = cols; + + if (get_bits_left(gb) < (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; + } + } + } + + for (w = 0; w < s->num_windows; w++) { + if (get_bits_left(gb) < 1) + return AVERROR(EINVAL); + s->params[w].tone_mapping_flag = get_bits1(gb); + if (s->params[w].tone_mapping_flag) { + if (get_bits_left(gb) < 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); + + if (get_bits_left(gb) < (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; + } + } + + if (get_bits_left(gb) < 1) + return AVERROR(EINVAL); + s->params[w].color_saturation_mapping_flag = get_bits1(gb); + if (s->params[w].color_saturation_mapping_flag) { + if (get_bits_left(gb) < 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; + } + } + + skip_bits(gb, get_bits_left(gb)); + + return 0; +} + +int get_encoded_dynamic_hdr_plus_buffer_size(const AVDynamicHDRPlus *s) { + int bit_count = 0; + int w, size; + + if (!s) + return 0; + + // 7 bytes for country code, provider code, and user identifier. + bit_count += 56; + + if (s->num_windows < 1 || s->num_windows > 3) + return 0; + // Count bits for window params. + bit_count += 2 + ((19 * 8 + 1) * (s->num_windows - 1)); + + bit_count += 28; + if (s->targeted_system_display_actual_peak_luminance_flag) { + int rows, cols; + rows = s->num_rows_targeted_system_display_actual_peak_luminance; + cols = s->num_rows_targeted_system_display_actual_peak_luminance; + if (((rows < 2) || (rows > 25)) || ((cols < 2) || (cols > 25))) + return 0; + + bit_count += (10 + rows * cols * 4); + } + for (w = 0; w < s->num_windows; w++) { + bit_count += (3 * 17 + 17 + 4 + 10) + + (s->params[w].num_distribution_maxrgb_percentiles * 24); + } + bit_count++; + + if (s->mastering_display_actual_peak_luminance_flag) { + int rows, cols; + rows = s->num_rows_mastering_display_actual_peak_luminance; + cols = s->num_cols_mastering_display_actual_peak_luminance; + if (((rows < 2) || (rows > 25)) || ((cols < 2) || (cols > 25))) + return 0; + + bit_count += (10 + rows * cols * 4); + } + + for (w = 0; w < s->num_windows; w++) { + bit_count++; + if (s->params[w].tone_mapping_flag) + bit_count += (28 + s->params[w].num_bezier_curve_anchors * 10); + + bit_count++; + if (s->params[w].color_saturation_mapping_flag) + bit_count += 6; + } + size = bit_count / 8; + if (bit_count % 8 != 0) + size++; + return size; +} + +int encode_dynamic_hdr_plus_to_itu_t_t35(const AVDynamicHDRPlus *s, PutBitContext *pb) +{ + int w, i, j; + if (!s) + return AVERROR(EINVAL); + + if (put_bits_left(pb) < get_encoded_dynamic_hdr_plus_buffer_size(s)) + return AVERROR(EINVAL); + put_bits(pb, 8, usa_country_code); + + put_bits(pb, 16, smpte_provider_code); + put_bits(pb, 16, smpte2094_40_provider_oriented_code); + put_bits(pb, 8, smpte2094_40_application_identifier); + put_bits(pb, 8, s->application_version); + + put_bits(pb, 2, s->num_windows); + + for (w = 1; w < s->num_windows; w++) { + put_bits(pb, 16, s->params[w].window_upper_left_corner_x.num / + s->params[w].window_upper_left_corner_x.den); + put_bits(pb, 16, s->params[w].window_upper_left_corner_y.num / + s->params[w].window_upper_left_corner_y.den); + put_bits(pb, 16, s->params[w].window_lower_right_corner_x.num / + s->params[w].window_lower_right_corner_x.den); + put_bits(pb, 16, s->params[w].window_lower_right_corner_y.num / + s->params[w].window_lower_right_corner_y.den); + put_bits(pb, 16, s->params[w].center_of_ellipse_x); + put_bits(pb, 16, s->params[w].center_of_ellipse_y); + put_bits(pb, 8, s->params[w].rotation_angle); + put_bits(pb, 16, s->params[w].semimajor_axis_internal_ellipse); + put_bits(pb, 16, s->params[w].semimajor_axis_external_ellipse); + put_bits(pb, 16, s->params[w].semiminor_axis_external_ellipse); + put_bits(pb, 1, s->params[w].overlap_process_option); + } + put_bits(pb, 27, + s->targeted_system_display_maximum_luminance.num * luminance_den / + s->targeted_system_display_maximum_luminance.den); + put_bits(pb, 1, s->targeted_system_display_actual_peak_luminance_flag); + if (s->targeted_system_display_actual_peak_luminance_flag) { + int rows, cols; + rows = s->num_rows_targeted_system_display_actual_peak_luminance; + cols = s->num_cols_targeted_system_display_actual_peak_luminance; + put_bits(pb, 5, rows); + put_bits(pb, 5, cols); + for (i = 0; i < rows; i++) { + for (j = 0; j < cols; j++) { + put_bits( + pb, 4, + s->targeted_system_display_actual_peak_luminance[i][j].num * + peak_luminance_den / + s->targeted_system_display_actual_peak_luminance[i][j] + .den); + } + } + } + for (w = 0; w < s->num_windows; w++) { + for (i = 0; i < 3; i++) { + put_bits(pb, 17, + s->params[w].maxscl[i].num * rgb_den / + s->params[w].maxscl[i].den); + } + put_bits(pb, 17, + s->params[w].average_maxrgb.num * rgb_den / + s->params[w].average_maxrgb.den); + put_bits(pb, 4, s->params[w].num_distribution_maxrgb_percentiles); + + for (i = 0; i < s->params[w].num_distribution_maxrgb_percentiles; i++) { + put_bits(pb, 7, s->params[w].distribution_maxrgb[i].percentage); + put_bits(pb, 17, + s->params[w].distribution_maxrgb[i].percentile.num * + rgb_den / + s->params[w].distribution_maxrgb[i].percentile.den); + } + put_bits(pb, 10, + s->params[w].fraction_bright_pixels.num * fraction_pixel_den / + s->params[w].fraction_bright_pixels.den); + } + put_bits(pb, 1, s->mastering_display_actual_peak_luminance_flag); + if (s->mastering_display_actual_peak_luminance_flag) { + int rows, cols; + rows = s->num_rows_mastering_display_actual_peak_luminance; + cols = s->num_cols_mastering_display_actual_peak_luminance; + put_bits(pb, 5, rows); + put_bits(pb, 5, cols); + for (i = 0; i < rows; i++) { + for (j = 0; j < cols; j++) { + put_bits( + pb, 4, + s->mastering_display_actual_peak_luminance[i][j].num * + peak_luminance_den / + s->mastering_display_actual_peak_luminance[i][j].den); + } + } + } + + for (w = 0; w < s->num_windows; w++) { + put_bits(pb, 1, s->params[w].tone_mapping_flag); + if (s->params[w].tone_mapping_flag) { + put_bits(pb, 12, + s->params[w].knee_point_x.num * knee_point_den / + s->params[w].knee_point_x.den); + put_bits(pb, 12, + s->params[w].knee_point_y.num * knee_point_den / + s->params[w].knee_point_y.den); + put_bits(pb, 4, s->params[w].num_bezier_curve_anchors); + for (i = 0; i < s->params[w].num_bezier_curve_anchors; i++) { + put_bits(pb, 10, + s->params[w].bezier_curve_anchors[i].num * + bezier_anchor_den / + s->params[w].bezier_curve_anchors[i].den); + } + } + put_bits(pb, 1, s->params[w].color_saturation_mapping_flag); + if (s->params[w].color_saturation_mapping_flag) + put_bits(pb, 6, + s->params[w].color_saturation_weight.num * + saturation_weight_den / + s->params[w].color_saturation_weight.den); + } + flush_put_bits(pb); + return 0; +} diff --git a/libavutil/hdr_dynamic_metadata.h b/libavutil/hdr_dynamic_metadata.h index 2d72de56ae..4e075f2f58 100644 --- a/libavutil/hdr_dynamic_metadata.h +++ b/libavutil/hdr_dynamic_metadata.h @@ -23,6 +23,8 @@ #include "frame.h" #include "rational.h" +#include "libavcodec/get_bits.h" +#include "libavcodec/put_bits.h" /** * Option for overlapping elliptical pixel selectors in an image. @@ -241,11 +243,6 @@ typedef struct AVHDRPlusColorTransformParams { * the public ABI. */ typedef struct AVDynamicHDRPlus { - /** - * Country code by Rec. ITU-T T.35 Annex A. The value shall be 0xB5. - */ - uint8_t itu_t_t35_country_code; - /** * Application version in the application defining document in ST-2094 * suite. The value shall be set to 0. @@ -265,7 +262,7 @@ typedef struct AVDynamicHDRPlus { /** * The nominal maximum display luminance of the targeted system display, - * in units of 0.0001 candelas per square metre. The value shall be in + * in units of 1 candelas per square metre. The value shall be in * the range of 0 to 10000, inclusive. */ AVRational targeted_system_display_maximum_luminance; @@ -322,14 +319,27 @@ typedef struct AVDynamicHDRPlus { AVRational mastering_display_actual_peak_luminance[25][25]; } AVDynamicHDRPlus; +/** + * Allocate an AVDynamicHDRPlus structure and set its fields to + * the values decoded from the user data registered ITU-T T.35. + * The resulting struct can be freed using av_freep(). + * + * @return An AVDynamicHDRPlus filled with decoded values or NULL + * on failure. + */ +AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size); + /** * Allocate an AVDynamicHDRPlus structure and set its fields to * default values. The resulting struct can be freed using av_freep(). + * @param gb The input bit stream. + * @param size The size of allocated memory for the returned + * AVDynamicHDRPlus structure. * * @return An AVDynamicHDRPlus filled with default values or NULL * on failure. */ -AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size); +AVDynamicHDRPlus *av_dynamic_hdr_plus(GetBitContext *gb, size_t *size); /** * Allocate a complete AVDynamicHDRPlus and add it to the frame. @@ -340,4 +350,31 @@ AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size); */ AVDynamicHDRPlus *av_dynamic_hdr_plus_create_side_data(AVFrame *frame); +/** + * Decode the user data registered ITU-T T.35 to AVDynamicHDRPlus. + * @param gb The bit content to be decoded. + * @param s The decoded AVDynamicHDRPlus structure. + * + * @return 0 if succeed. Otherwise, returns the appropriate AVERROR. + */ +int decode_itu_t_t35_to_dynamic_hdr_plus(GetBitContext *gb, AVDynamicHDRPlus *s); + +/** + * Get the size of buffer required to save the encoded bit stream of + * AVDynamicHDRPlus in the form of the user data registered ITU-T T.35. + * @param s The AVDynamicHDRPlus structure. + * + * @return The size of bit stream required for encoding. 0 if the data is invalid. + */ +int get_encoded_dynamic_hdr_plus_buffer_size(const AVDynamicHDRPlus *s); + +/** + * Encode AVDynamicHDRPlus to the user data registered ITU-T T.35. + * @param s The AVDynamicHDRPlus structure to be encoded. + * @param pb The encoded bit stream. + * + * @return 0 if succeed. Otherwise, returns the appropriate AVERROR. + */ +int encode_dynamic_hdr_plus_to_itu_t_t35(const AVDynamicHDRPlus *s, PutBitContext *pb); + #endif /* AVUTIL_HDR_DYNAMIC_METADATA_H */ diff --git a/libavutil/version.h b/libavutil/version.h index af8f614aff..2bc1b98615 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 38 +#define LIBAVUTIL_VERSION_MINOR 39 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \