|
|
|
@ -26,6 +26,7 @@ |
|
|
|
|
#include "libavutil/attributes.h" |
|
|
|
|
#include "libavutil/common.h" |
|
|
|
|
#include "libavutil/display.h" |
|
|
|
|
#include "libavutil/film_grain_params.h" |
|
|
|
|
#include "libavutil/internal.h" |
|
|
|
|
#include "libavutil/mastering_display_metadata.h" |
|
|
|
|
#include "libavutil/md5.h" |
|
|
|
@ -2880,6 +2881,61 @@ static int set_side_data(HEVCContext *s) |
|
|
|
|
s->sei.timecode.num_clock_ts = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (s->sei.film_grain_characteristics.present && |
|
|
|
|
(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN)) { |
|
|
|
|
HEVCSEIFilmGrainCharacteristics *fgc = &s->sei.film_grain_characteristics; |
|
|
|
|
AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(out); |
|
|
|
|
if (!fgp) |
|
|
|
|
return AVERROR(ENOMEM); |
|
|
|
|
|
|
|
|
|
fgp->type = AV_FILM_GRAIN_PARAMS_H274; |
|
|
|
|
|
|
|
|
|
fgp->codec.h274.model_id = fgc->model_id; |
|
|
|
|
if (fgc->separate_colour_description_present_flag) { |
|
|
|
|
fgp->codec.h274.bit_depth_luma = fgc->bit_depth_luma; |
|
|
|
|
fgp->codec.h274.bit_depth_chroma = fgc->bit_depth_chroma; |
|
|
|
|
fgp->codec.h274.color_range = fgc->full_range + 1; |
|
|
|
|
fgp->codec.h274.color_primaries = fgc->color_primaries; |
|
|
|
|
fgp->codec.h274.color_trc = fgc->transfer_characteristics; |
|
|
|
|
fgp->codec.h274.color_space = fgc->matrix_coeffs; |
|
|
|
|
} else { |
|
|
|
|
const HEVCSPS *sps = s->ps.sps; |
|
|
|
|
const VUI *vui = &sps->vui; |
|
|
|
|
fgp->codec.h274.bit_depth_luma = sps->bit_depth; |
|
|
|
|
fgp->codec.h274.bit_depth_chroma = sps->bit_depth_chroma; |
|
|
|
|
if (vui->video_signal_type_present_flag) |
|
|
|
|
fgp->codec.h274.color_range = vui->video_full_range_flag + 1; |
|
|
|
|
else |
|
|
|
|
fgp->codec.h274.color_range = AVCOL_RANGE_UNSPECIFIED; |
|
|
|
|
if (vui->colour_description_present_flag) { |
|
|
|
|
fgp->codec.h274.color_primaries = vui->colour_primaries; |
|
|
|
|
fgp->codec.h274.color_trc = vui->transfer_characteristic; |
|
|
|
|
fgp->codec.h274.color_space = vui->matrix_coeffs; |
|
|
|
|
} else { |
|
|
|
|
fgp->codec.h274.color_primaries = AVCOL_PRI_UNSPECIFIED; |
|
|
|
|
fgp->codec.h274.color_trc = AVCOL_TRC_UNSPECIFIED; |
|
|
|
|
fgp->codec.h274.color_space = AVCOL_SPC_UNSPECIFIED; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
fgp->codec.h274.blending_mode_id = fgc->blending_mode_id; |
|
|
|
|
fgp->codec.h274.log2_scale_factor = fgc->log2_scale_factor; |
|
|
|
|
|
|
|
|
|
memcpy(&fgp->codec.h274.component_model_present, &fgc->comp_model_present_flag, |
|
|
|
|
sizeof(fgp->codec.h274.component_model_present)); |
|
|
|
|
memcpy(&fgp->codec.h274.num_intensity_intervals, &fgc->num_intensity_intervals, |
|
|
|
|
sizeof(fgp->codec.h274.num_intensity_intervals)); |
|
|
|
|
memcpy(&fgp->codec.h274.num_model_values, &fgc->num_model_values, |
|
|
|
|
sizeof(fgp->codec.h274.num_model_values)); |
|
|
|
|
memcpy(&fgp->codec.h274.intensity_interval_lower_bound, &fgc->intensity_interval_lower_bound, |
|
|
|
|
sizeof(fgp->codec.h274.intensity_interval_lower_bound)); |
|
|
|
|
memcpy(&fgp->codec.h274.intensity_interval_upper_bound, &fgc->intensity_interval_upper_bound, |
|
|
|
|
sizeof(fgp->codec.h274.intensity_interval_upper_bound)); |
|
|
|
|
memcpy(&fgp->codec.h274.comp_model_value, &fgc->comp_model_value, |
|
|
|
|
sizeof(fgp->codec.h274.comp_model_value)); |
|
|
|
|
|
|
|
|
|
fgc->present = fgc->persistence_flag; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (s->sei.dynamic_hdr_plus.info) { |
|
|
|
|
AVBufferRef *info_ref = av_buffer_ref(s->sei.dynamic_hdr_plus.info); |
|
|
|
|
if (!info_ref) |
|
|
|
|