|
|
|
@ -35,6 +35,7 @@ |
|
|
|
|
|
|
|
|
|
#include "atsc_a53.h" |
|
|
|
|
#include "avcodec.h" |
|
|
|
|
#include "decode.h" |
|
|
|
|
#include "dynamic_hdr_vivid.h" |
|
|
|
|
#include "get_bits.h" |
|
|
|
|
#include "golomb.h" |
|
|
|
@ -515,6 +516,7 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, |
|
|
|
|
int seed) |
|
|
|
|
{ |
|
|
|
|
H2645SEIFramePacking *fp = &sei->frame_packing; |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
if (fp->present && |
|
|
|
|
is_frame_packing_type_valid(fp->arrangement_type, codec_id) && |
|
|
|
@ -710,56 +712,63 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, |
|
|
|
|
const int chroma_den = 50000; |
|
|
|
|
const int luma_den = 10000; |
|
|
|
|
int i; |
|
|
|
|
AVMasteringDisplayMetadata *metadata = |
|
|
|
|
av_mastering_display_metadata_create_side_data(frame); |
|
|
|
|
if (!metadata) |
|
|
|
|
return AVERROR(ENOMEM); |
|
|
|
|
AVMasteringDisplayMetadata *metadata; |
|
|
|
|
|
|
|
|
|
ret = ff_decode_mastering_display_new(avctx, frame, &metadata); |
|
|
|
|
if (ret < 0) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) { |
|
|
|
|
const int j = mapping[i]; |
|
|
|
|
metadata->display_primaries[i][0].num = sei->mastering_display.display_primaries[j][0]; |
|
|
|
|
metadata->display_primaries[i][0].den = chroma_den; |
|
|
|
|
metadata->display_primaries[i][1].num = sei->mastering_display.display_primaries[j][1]; |
|
|
|
|
metadata->display_primaries[i][1].den = chroma_den; |
|
|
|
|
if (metadata) { |
|
|
|
|
for (i = 0; i < 3; i++) { |
|
|
|
|
const int j = mapping[i]; |
|
|
|
|
metadata->display_primaries[i][0].num = sei->mastering_display.display_primaries[j][0]; |
|
|
|
|
metadata->display_primaries[i][0].den = chroma_den; |
|
|
|
|
metadata->display_primaries[i][1].num = sei->mastering_display.display_primaries[j][1]; |
|
|
|
|
metadata->display_primaries[i][1].den = chroma_den; |
|
|
|
|
} |
|
|
|
|
metadata->white_point[0].num = sei->mastering_display.white_point[0]; |
|
|
|
|
metadata->white_point[0].den = chroma_den; |
|
|
|
|
metadata->white_point[1].num = sei->mastering_display.white_point[1]; |
|
|
|
|
metadata->white_point[1].den = chroma_den; |
|
|
|
|
|
|
|
|
|
metadata->max_luminance.num = sei->mastering_display.max_luminance; |
|
|
|
|
metadata->max_luminance.den = luma_den; |
|
|
|
|
metadata->min_luminance.num = sei->mastering_display.min_luminance; |
|
|
|
|
metadata->min_luminance.den = luma_den; |
|
|
|
|
metadata->has_luminance = 1; |
|
|
|
|
metadata->has_primaries = 1; |
|
|
|
|
|
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n"); |
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, |
|
|
|
|
"r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n", |
|
|
|
|
av_q2d(metadata->display_primaries[0][0]), |
|
|
|
|
av_q2d(metadata->display_primaries[0][1]), |
|
|
|
|
av_q2d(metadata->display_primaries[1][0]), |
|
|
|
|
av_q2d(metadata->display_primaries[1][1]), |
|
|
|
|
av_q2d(metadata->display_primaries[2][0]), |
|
|
|
|
av_q2d(metadata->display_primaries[2][1]), |
|
|
|
|
av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1])); |
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, |
|
|
|
|
"min_luminance=%f, max_luminance=%f\n", |
|
|
|
|
av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance)); |
|
|
|
|
} |
|
|
|
|
metadata->white_point[0].num = sei->mastering_display.white_point[0]; |
|
|
|
|
metadata->white_point[0].den = chroma_den; |
|
|
|
|
metadata->white_point[1].num = sei->mastering_display.white_point[1]; |
|
|
|
|
metadata->white_point[1].den = chroma_den; |
|
|
|
|
|
|
|
|
|
metadata->max_luminance.num = sei->mastering_display.max_luminance; |
|
|
|
|
metadata->max_luminance.den = luma_den; |
|
|
|
|
metadata->min_luminance.num = sei->mastering_display.min_luminance; |
|
|
|
|
metadata->min_luminance.den = luma_den; |
|
|
|
|
metadata->has_luminance = 1; |
|
|
|
|
metadata->has_primaries = 1; |
|
|
|
|
|
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n"); |
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, |
|
|
|
|
"r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n", |
|
|
|
|
av_q2d(metadata->display_primaries[0][0]), |
|
|
|
|
av_q2d(metadata->display_primaries[0][1]), |
|
|
|
|
av_q2d(metadata->display_primaries[1][0]), |
|
|
|
|
av_q2d(metadata->display_primaries[1][1]), |
|
|
|
|
av_q2d(metadata->display_primaries[2][0]), |
|
|
|
|
av_q2d(metadata->display_primaries[2][1]), |
|
|
|
|
av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1])); |
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, |
|
|
|
|
"min_luminance=%f, max_luminance=%f\n", |
|
|
|
|
av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (sei->content_light.present) { |
|
|
|
|
AVContentLightMetadata *metadata = |
|
|
|
|
av_content_light_metadata_create_side_data(frame); |
|
|
|
|
if (!metadata) |
|
|
|
|
return AVERROR(ENOMEM); |
|
|
|
|
metadata->MaxCLL = sei->content_light.max_content_light_level; |
|
|
|
|
metadata->MaxFALL = sei->content_light.max_pic_average_light_level; |
|
|
|
|
AVContentLightMetadata *metadata; |
|
|
|
|
|
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, "Content Light Level Metadata:\n"); |
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, "MaxCLL=%d, MaxFALL=%d\n", |
|
|
|
|
metadata->MaxCLL, metadata->MaxFALL); |
|
|
|
|
ret = ff_decode_content_light_new(avctx, frame, &metadata); |
|
|
|
|
if (ret < 0) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
if (metadata) { |
|
|
|
|
metadata->MaxCLL = sei->content_light.max_content_light_level; |
|
|
|
|
metadata->MaxFALL = sei->content_light.max_pic_average_light_level; |
|
|
|
|
|
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, "Content Light Level Metadata:\n"); |
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, "MaxCLL=%d, MaxFALL=%d\n", |
|
|
|
|
metadata->MaxCLL, metadata->MaxFALL); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|