Re: [FFmpeg-devel] [PATCH 1/6] fate: Add dpx-probe test
> On 10 Dec 2020, at 23:41, Paul B Mahol wrote: > > I strongly disagree, make use of money project got. > Limiting size of samples is not gonna to be productive at all. > > On Fri, Dec 11, 2020 at 12:37 AM Carl Eugen Hoyos > wrote: > >> Am Do., 10. Dez. 2020 um 13:22 Uhr schrieb Paul B Mahol >> : >>> >>> I already uploaded the other file to servers. >> >> We can still remove it. >> >> Downloading the fate suite takes very long and it will get bigger no >> matter the year. Is there anything I can do to unblock this? I am very happy for the second smaller size/resolution sample to be used instead. Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 3/6] avcodec/dpx: Read SMPTE timecode from DPX
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 29 + tests/ref/fate/dpx-probe | 7 +++ 2 files changed, 36 insertions(+) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 7e3ac0af2e..51428459ef 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat.h" #include "libavutil/imgutils.h" +#include "libavutil/timecode.h" #include "bytestream.h" #include "avcodec.h" #include "internal.h" @@ -239,6 +240,34 @@ static int decode_frame(AVCodecContext *avctx, } } +/* SMPTE TC from television header */ +if (offset >= 1920 + 4) { +uint32_t tc; +uint32_t *tc_sd; +char tcbuf[AV_TIMECODE_STR_SIZE]; + +buf = avpkt->data + 1920; +// read32 to native endian, av_bswap32 to opposite of native for +// compatibility with av_timecode_make_smpte_tc_string2 etc +tc = av_bswap32(read32(, endian)); + +if (i != 0x) { +AVFrameSideData *tcside = +av_frame_new_side_data(p, AV_FRAME_DATA_S12M_TIMECODE, + sizeof(uint32_t) * 4); +if (!tcside) +return AVERROR(ENOMEM); + +tc_sd = (uint32_t*)tcside->data; +tc_sd[0] = 1; +tc_sd[1] = tc; + +av_timecode_make_smpte_tc_string2(tcbuf, avctx->framerate, + tc_sd[1], 0, 0); +av_dict_set(>metadata, "timecode", tcbuf, 0); +} +} + switch (descriptor) { case 6: // Y elements = 1; diff --git a/tests/ref/fate/dpx-probe b/tests/ref/fate/dpx-probe index 0f9ac9e633..81718326d6 100644 --- a/tests/ref/fate/dpx-probe +++ b/tests/ref/fate/dpx-probe @@ -27,8 +27,15 @@ color_space=unknown color_primaries=unknown color_transfer=unknown chroma_location=unspecified +TAG:timecode=00:00:01:18 TAG:Creator=Apple Compressor TAG:Input Device= +[SIDE_DATA] +side_data_type=SMPTE 12-1 timecode +[TIMECODE] +value=00:00:01:18 +[/TIMECODE] +[/SIDE_DATA] [/FRAME] [STREAM] index=0 -- 2.29.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 6/6] avcodec/dpx: Fix B film scans from Lasergraphics Inc
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 7b18141f97..bd431ccbcb 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -167,7 +167,7 @@ static int decode_frame(AVCodecContext *avctx, int x, y, stride, i, j, ret; int w, h, bits_per_color, descriptor, elements, packing; int yuv, color_trc, color_spec; -int encoding, need_align = 0; +int encoding, need_align = 0, unpadded_10bit = 0; unsigned int rgbBuffer = 0; int n_datum = 0; @@ -574,6 +574,12 @@ static int decode_frame(AVCodecContext *avctx, input_device[32] = '\0'; av_dict_set(>metadata, "Input Device", input_device, 0); +// Some devices do not pad 10bit samples to whole 32bit words per row +if (!memcmp(input_device, "Scanity", 7) || +!memcmp(creator, "Lasergraphics Inc.", 18)) { +unpadded_10bit = 1; +} + // Move pointer to offset from start of file buf = avpkt->data + offset; @@ -606,7 +612,7 @@ static int decode_frame(AVCodecContext *avctx, read10in32(, , _datum, endian, shift); } -if (memcmp(input_device, "Scanity", 7)) +if (!unpadded_10bit) n_datum = 0; for (i = 0; i < elements; i++) ptr[i] += p->linesize[i]; -- 2.29.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/6] fate: Add dpx-probe test
> On 10 Dec 2020, at 12:21, Paul B Mahol wrote: > > I already uploaded the other file to servers. Ah, sorry about that. > > And I doubt it hurts at all in 2020. > Also I doubt one can overwrite files that easily. I have sent the V2. It is all exactly the same except it is set up for the smaller test file and I have fixed the big endian thing. Should I send a V3 which adjusts it back to the larger file again? Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 5/6] avcodec/dpx: Read color information from DPX header
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 127 +-- tests/ref/fate/dpx-probe | 8 +-- 2 files changed, 127 insertions(+), 8 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 577171258a..7b18141f97 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -28,6 +28,38 @@ #include "avcodec.h" #include "internal.h" +enum DPX_TRC { +DPX_TRC_USER_DEFINED = 0, +DPX_TRC_PRINTING_DENSITY = 1, +DPX_TRC_LINEAR = 2, +DPX_TRC_LOGARITHMIC= 3, +DPX_TRC_UNSPECIFIED_VIDEO = 4, +DPX_TRC_SMPTE_274 = 5, +DPX_TRC_ITU_R_709_4= 6, +DPX_TRC_ITU_R_601_625 = 7, +DPX_TRC_ITU_R_601_525 = 8, +DPX_TRC_SMPTE_170 = 9, +DPX_TRC_ITU_R_624_4_PAL= 10, +DPX_TRC_Z_LINEAR = 11, +DPX_TRC_Z_HOMOGENEOUS = 12, +}; + +enum DPX_COL_SPEC { +DPX_COL_SPEC_USER_DEFINED = 0, +DPX_COL_SPEC_PRINTING_DENSITY = 1, +/* 2 = N/A */ +/* 3 = N/A */ +DPX_COL_SPEC_UNSPECIFIED_VIDEO = 4, +DPX_COL_SPEC_SMPTE_274 = 5, +DPX_COL_SPEC_ITU_R_709_4= 6, +DPX_COL_SPEC_ITU_R_601_625 = 7, +DPX_COL_SPEC_ITU_R_601_525 = 8, +DPX_COL_SPEC_SMPTE_170 = 9, +DPX_COL_SPEC_ITU_R_624_4_PAL= 10, +/* 11 = N/A */ +/* 12 = N/A */ +}; + static unsigned int read16(const uint8_t **ptr, int is_big) { unsigned int temp; @@ -134,6 +166,7 @@ static int decode_frame(AVCodecContext *avctx, int magic_num, endian; int x, y, stride, i, j, ret; int w, h, bits_per_color, descriptor, elements, packing; +int yuv, color_trc, color_spec; int encoding, need_align = 0; unsigned int rgbBuffer = 0; @@ -193,6 +226,8 @@ static int decode_frame(AVCodecContext *avctx, // Need to end in 0x320 to read the descriptor buf += 20; descriptor = buf[0]; +color_trc = buf[1]; +color_spec = buf[2]; // Need to end in 0x323 to read the bits per color buf += 3; @@ -294,18 +329,26 @@ static int decode_frame(AVCodecContext *avctx, switch (descriptor) { case 6: // Y elements = 1; +yuv = 1; +break; +case 50: // RGB +elements = 3; break; case 52: // ABGR case 51: // RGBA -case 103: // UYVA elements = 4; break; -case 50: // RGB +case 100: // UYVY422 +elements = 2; +yuv = 1; +break; case 102: // UYV444 elements = 3; +yuv = 1; break; -case 100: // UYVY422 -elements = 2; +case 103: // UYVA +elements = 4; +yuv = 1; break; default: avpriv_report_missing_feature(avctx, "Descriptor %d", descriptor); @@ -349,6 +392,82 @@ static int decode_frame(AVCodecContext *avctx, return AVERROR_INVALIDDATA; } +switch (color_trc) { +case DPX_TRC_LINEAR: +avctx->color_trc = AVCOL_TRC_LINEAR; +break; +case DPX_TRC_SMPTE_274: +case DPX_TRC_ITU_R_709_4: +avctx->color_trc = AVCOL_TRC_BT709; +break; +case DPX_TRC_ITU_R_601_625: +case DPX_TRC_ITU_R_601_525: +case DPX_TRC_SMPTE_170: +avctx->color_trc = AVCOL_TRC_SMPTE170M; +break; +case DPX_TRC_ITU_R_624_4_PAL: +avctx->color_trc = AVCOL_TRC_GAMMA28; +break; +case DPX_TRC_USER_DEFINED: +case DPX_TRC_UNSPECIFIED_VIDEO: +/* Nothing to do */ +break; +default: +av_log(avctx, AV_LOG_VERBOSE, "Cannot map DPX transfer characteristic " +"%d to color_trc.\n", color_trc); +break; +} + +switch (color_spec) { +case DPX_COL_SPEC_SMPTE_274: +case DPX_COL_SPEC_ITU_R_709_4: +avctx->color_primaries = AVCOL_PRI_BT709; +break; +case DPX_COL_SPEC_ITU_R_601_625: +case DPX_COL_SPEC_ITU_R_624_4_PAL: +avctx->color_primaries = AVCOL_PRI_BT470BG; +break; +case DPX_COL_SPEC_ITU_R_601_525: +case DPX_COL_SPEC_SMPTE_170: +avctx->color_primaries = AVCOL_PRI_SMPTE170M; +break; +case DPX_COL_SPEC_USER_DEFINED: +case DPX_COL_SPEC_UNSPECIFIED_VIDEO: +/* Nothing to do */ +break; +default: +av_log(avctx, AV_LOG_VERBOSE, "Cannot map DPX color specification " +"%d to color_primaries.\n", color_spec); +break; +} + +if (yuv) { +switch (color_spec) { +case DPX_COL_SPEC_SMPTE_274: +case DPX_COL_SPEC_ITU_R_709_4: +avctx->colorspace = AVCOL_SPC_BT709; +break; +case DPX_COL_SPEC_ITU_R_601_625: +case DPX_COL_SPEC_ITU_R_624_4_PAL: +avctx->colorspace = AVCOL_SPC_BT470BG; +break; +case DPX_COL_SPEC_ITU_R_601_525: +case DPX_COL_SPEC_SMPTE_170: +avc
[FFmpeg-devel] [PATCH v2 4/6] avcodec/dpx: Report color_range from DPX header
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 25 - tests/ref/fate/dpx-probe | 4 ++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 51428459ef..577171258a 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -132,7 +132,7 @@ static int decode_frame(AVCodecContext *avctx, unsigned int offset; int magic_num, endian; -int x, y, stride, i, ret; +int x, y, stride, i, j, ret; int w, h, bits_per_color, descriptor, elements, packing; int encoding, need_align = 0; @@ -268,6 +268,29 @@ static int decode_frame(AVCodecContext *avctx, } } +/* color range from television header */ +if (offset >= 1964 + 4) { +buf = avpkt->data + 1952; +i = read32(, endian); + +buf = avpkt->data + 1964; +j = read32(, endian); + +if (i != 0x && j != 0x) { +float minCV, maxCV; +minCV = av_int2float(i); +maxCV = av_int2float(j); +if (bits_per_color >= 1 && +minCV == 0.0f && maxCV == ((1<color_range = AVCOL_RANGE_JPEG; +} else if (bits_per_color >= 8 && + minCV == (1 <<(bits_per_color - 4)) && + maxCV == (235<<(bits_per_color - 8))) { +avctx->color_range = AVCOL_RANGE_MPEG; +} +} +} + switch (descriptor) { case 6: // Y elements = 1; diff --git a/tests/ref/fate/dpx-probe b/tests/ref/fate/dpx-probe index 81718326d6..79fa16bd20 100644 --- a/tests/ref/fate/dpx-probe +++ b/tests/ref/fate/dpx-probe @@ -22,7 +22,7 @@ display_picture_number=0 interlaced_frame=0 top_field_first=0 repeat_pict=0 -color_range=unknown +color_range=pc color_space=unknown color_primaries=unknown color_transfer=unknown @@ -55,7 +55,7 @@ sample_aspect_ratio=1:1 display_aspect_ratio=16:9 pix_fmt=gbrp10 level=-99 -color_range=unknown +color_range=pc color_space=unknown color_transfer=unknown color_primaries=unknown -- 2.29.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 2/6] avcodec/dpx: Read alternative frame rate from television header
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index b1833ed9ef..7e3ac0af2e 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -216,10 +216,23 @@ static int decode_frame(AVCodecContext *avctx, else avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; +/* preferred frame rate from Motion-picture film header */ if (offset >= 1724 + 4) { buf = avpkt->data + 1724; i = read32(, endian); -if(i) { +if(i && i != 0x) { +AVRational q = av_d2q(av_int2float(i), 4096); +if (q.num > 0 && q.den > 0) +avctx->framerate = q; +} +} + +/* alternative frame rate from television header */ +if (offset >= 1940 + 4 && +!(avctx->framerate.num && avctx->framerate.den)) { +buf = avpkt->data + 1940; +i = read32(, endian); +if(i && i != 0x) { AVRational q = av_d2q(av_int2float(i), 4096); if (q.num > 0 && q.den > 0) avctx->framerate = q; -- 2.29.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/6] fate: Add dpx-probe test
Signed-off-by: Harry Mallon --- tests/fate/image.mak | 4 ++ tests/ref/fate/dpx-probe | 85 2 files changed, 89 insertions(+) create mode 100644 tests/ref/fate/dpx-probe diff --git a/tests/fate/image.mak b/tests/fate/image.mak index 22072a62f1..a24c054c25 100644 --- a/tests/fate/image.mak +++ b/tests/fate/image.mak @@ -97,6 +97,10 @@ fate-dpx: CMD = framecrc -i $(TARGET_SAMPLES)/dpx/lighthouse_rgb48.dpx FATE_SAMPLES_AVCONV-$(call PARSERDEMDEC, DPX, IMAGE2PIPE, DPX) += fate-dpxparser fate-dpxparser: CMD = framecrc -f image2pipe -i $(TARGET_SAMPLES)/dpx/lena_4x_concat.dpx -sws_flags +accurate_rnd+bitexact +FATE_IMAGE-$(call DEMDEC, IMAGE2, DPX) += fate-dpx-probe +fate-dpx-probe: SRC = $(TARGET_SAMPLES)/dpx/cyan.dpx +fate-dpx-probe: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_frames -print_format default -bitexact -v 0 -i "$(SRC)" | sed -e "s/gbrp10le/gbrp10/" + FATE_EXR += fate-exr-slice-raw fate-exr-slice-raw: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgba_slice_raw.exr -pix_fmt gbrapf32le diff --git a/tests/ref/fate/dpx-probe b/tests/ref/fate/dpx-probe new file mode 100644 index 00..0f9ac9e633 --- /dev/null +++ b/tests/ref/fate/dpx-probe @@ -0,0 +1,85 @@ +[FRAME] +media_type=video +stream_index=0 +key_frame=1 +pkt_pts=0 +pkt_pts_time=0.00 +pkt_dts=0 +pkt_dts_time=0.00 +best_effort_timestamp=0 +best_effort_timestamp_time=0.00 +pkt_duration=1 +pkt_duration_time=0.04 +pkt_pos=0 +pkt_size=8768 +width=16 +height=9 +pix_fmt=gbrp10 +sample_aspect_ratio=1:1 +pict_type=? +coded_picture_number=0 +display_picture_number=0 +interlaced_frame=0 +top_field_first=0 +repeat_pict=0 +color_range=unknown +color_space=unknown +color_primaries=unknown +color_transfer=unknown +chroma_location=unspecified +TAG:Creator=Apple Compressor +TAG:Input Device= +[/FRAME] +[STREAM] +index=0 +codec_name=dpx +profile=unknown +codec_type=video +codec_time_base=1/24 +codec_tag_string=[0][0][0][0] +codec_tag=0x +width=16 +height=9 +coded_width=16 +coded_height=9 +closed_captions=0 +has_b_frames=0 +sample_aspect_ratio=1:1 +display_aspect_ratio=16:9 +pix_fmt=gbrp10 +level=-99 +color_range=unknown +color_space=unknown +color_transfer=unknown +color_primaries=unknown +chroma_location=unspecified +field_order=unknown +timecode=N/A +refs=1 +id=N/A +r_frame_rate=24/1 +avg_frame_rate=0/0 +time_base=1/25 +start_pts=N/A +start_time=N/A +duration_ts=N/A +duration=N/A +bit_rate=N/A +max_bit_rate=N/A +bits_per_raw_sample=10 +nb_frames=N/A +nb_read_frames=1 +nb_read_packets=N/A +DISPOSITION:default=0 +DISPOSITION:dub=0 +DISPOSITION:original=0 +DISPOSITION:comment=0 +DISPOSITION:lyrics=0 +DISPOSITION:karaoke=0 +DISPOSITION:forced=0 +DISPOSITION:hearing_impaired=0 +DISPOSITION:visual_impaired=0 +DISPOSITION:clean_effects=0 +DISPOSITION:attached_pic=0 +DISPOSITION:timed_thumbnails=0 +[/STREAM] -- 2.29.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/6] fate: Add dpx-probe test
Hi Paul etc, I attach a smaller file (it will need the width height etc changing in the test which I will send as a V2 in a couple of mins). Harry cyan.dpx Description: Binary data > On 10 Dec 2020, at 11:51, Paul B Mahol wrote: > > File is fine, gonna apply this with ffprobe improved test. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/6] avcodec/dpx: Read alternative frame rate from television header
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index b1833ed9ef..7e3ac0af2e 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -216,10 +216,23 @@ static int decode_frame(AVCodecContext *avctx, else avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; +/* preferred frame rate from Motion-picture film header */ if (offset >= 1724 + 4) { buf = avpkt->data + 1724; i = read32(, endian); -if(i) { +if(i && i != 0x) { +AVRational q = av_d2q(av_int2float(i), 4096); +if (q.num > 0 && q.den > 0) +avctx->framerate = q; +} +} + +/* alternative frame rate from television header */ +if (offset >= 1940 + 4 && +!(avctx->framerate.num && avctx->framerate.den)) { +buf = avpkt->data + 1940; +i = read32(, endian); +if(i && i != 0x) { AVRational q = av_d2q(av_int2float(i), 4096); if (q.num > 0 && q.den > 0) avctx->framerate = q; -- 2.29.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/6] fate: Add dpx-probe test
Signed-off-by: Harry Mallon --- tests/fate/image.mak | 4 ++ tests/ref/fate/dpx-probe | 85 2 files changed, 89 insertions(+) create mode 100644 tests/ref/fate/dpx-probe diff --git a/tests/fate/image.mak b/tests/fate/image.mak index 22072a62f1..d18054d3d8 100644 --- a/tests/fate/image.mak +++ b/tests/fate/image.mak @@ -97,6 +97,10 @@ fate-dpx: CMD = framecrc -i $(TARGET_SAMPLES)/dpx/lighthouse_rgb48.dpx FATE_SAMPLES_AVCONV-$(call PARSERDEMDEC, DPX, IMAGE2PIPE, DPX) += fate-dpxparser fate-dpxparser: CMD = framecrc -f image2pipe -i $(TARGET_SAMPLES)/dpx/lena_4x_concat.dpx -sws_flags +accurate_rnd+bitexact +FATE_IMAGE-$(call DEMDEC, IMAGE2, DPX) += fate-dpx-probe +fate-dpx-probe: SRC = $(TARGET_SAMPLES)/dpx/cyan.dpx +fate-dpx-probe: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_frames -print_format default -bitexact -v 0 -i "$(SRC)" + FATE_EXR += fate-exr-slice-raw fate-exr-slice-raw: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgba_slice_raw.exr -pix_fmt gbrapf32le diff --git a/tests/ref/fate/dpx-probe b/tests/ref/fate/dpx-probe new file mode 100644 index 00..a69c45ad29 --- /dev/null +++ b/tests/ref/fate/dpx-probe @@ -0,0 +1,85 @@ +[FRAME] +media_type=video +stream_index=0 +key_frame=1 +pkt_pts=0 +pkt_pts_time=0.00 +pkt_dts=0 +pkt_dts_time=0.00 +best_effort_timestamp=0 +best_effort_timestamp_time=0.00 +pkt_duration=1 +pkt_duration_time=0.04 +pkt_pos=0 +pkt_size=419072 +width=428 +height=240 +pix_fmt=gbrp10le +sample_aspect_ratio=1:1 +pict_type=? +coded_picture_number=0 +display_picture_number=0 +interlaced_frame=0 +top_field_first=0 +repeat_pict=0 +color_range=unknown +color_space=unknown +color_primaries=unknown +color_transfer=unknown +chroma_location=unspecified +TAG:Creator=Apple Compressor +TAG:Input Device= +[/FRAME] +[STREAM] +index=0 +codec_name=dpx +profile=unknown +codec_type=video +codec_time_base=1/24 +codec_tag_string=[0][0][0][0] +codec_tag=0x +width=428 +height=240 +coded_width=428 +coded_height=240 +closed_captions=0 +has_b_frames=0 +sample_aspect_ratio=1:1 +display_aspect_ratio=107:60 +pix_fmt=gbrp10le +level=-99 +color_range=unknown +color_space=unknown +color_transfer=unknown +color_primaries=unknown +chroma_location=unspecified +field_order=unknown +timecode=N/A +refs=1 +id=N/A +r_frame_rate=24/1 +avg_frame_rate=0/0 +time_base=1/25 +start_pts=N/A +start_time=N/A +duration_ts=N/A +duration=N/A +bit_rate=N/A +max_bit_rate=N/A +bits_per_raw_sample=10 +nb_frames=N/A +nb_read_frames=1 +nb_read_packets=N/A +DISPOSITION:default=0 +DISPOSITION:dub=0 +DISPOSITION:original=0 +DISPOSITION:comment=0 +DISPOSITION:lyrics=0 +DISPOSITION:karaoke=0 +DISPOSITION:forced=0 +DISPOSITION:hearing_impaired=0 +DISPOSITION:visual_impaired=0 +DISPOSITION:clean_effects=0 +DISPOSITION:attached_pic=0 +DISPOSITION:timed_thumbnails=0 +[/STREAM] -- 2.29.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/6] avcodec/dpx: Read color information from DPX header
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 127 +-- tests/ref/fate/dpx-probe | 8 +-- 2 files changed, 127 insertions(+), 8 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 577171258a..7b18141f97 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -28,6 +28,38 @@ #include "avcodec.h" #include "internal.h" +enum DPX_TRC { +DPX_TRC_USER_DEFINED = 0, +DPX_TRC_PRINTING_DENSITY = 1, +DPX_TRC_LINEAR = 2, +DPX_TRC_LOGARITHMIC= 3, +DPX_TRC_UNSPECIFIED_VIDEO = 4, +DPX_TRC_SMPTE_274 = 5, +DPX_TRC_ITU_R_709_4= 6, +DPX_TRC_ITU_R_601_625 = 7, +DPX_TRC_ITU_R_601_525 = 8, +DPX_TRC_SMPTE_170 = 9, +DPX_TRC_ITU_R_624_4_PAL= 10, +DPX_TRC_Z_LINEAR = 11, +DPX_TRC_Z_HOMOGENEOUS = 12, +}; + +enum DPX_COL_SPEC { +DPX_COL_SPEC_USER_DEFINED = 0, +DPX_COL_SPEC_PRINTING_DENSITY = 1, +/* 2 = N/A */ +/* 3 = N/A */ +DPX_COL_SPEC_UNSPECIFIED_VIDEO = 4, +DPX_COL_SPEC_SMPTE_274 = 5, +DPX_COL_SPEC_ITU_R_709_4= 6, +DPX_COL_SPEC_ITU_R_601_625 = 7, +DPX_COL_SPEC_ITU_R_601_525 = 8, +DPX_COL_SPEC_SMPTE_170 = 9, +DPX_COL_SPEC_ITU_R_624_4_PAL= 10, +/* 11 = N/A */ +/* 12 = N/A */ +}; + static unsigned int read16(const uint8_t **ptr, int is_big) { unsigned int temp; @@ -134,6 +166,7 @@ static int decode_frame(AVCodecContext *avctx, int magic_num, endian; int x, y, stride, i, j, ret; int w, h, bits_per_color, descriptor, elements, packing; +int yuv, color_trc, color_spec; int encoding, need_align = 0; unsigned int rgbBuffer = 0; @@ -193,6 +226,8 @@ static int decode_frame(AVCodecContext *avctx, // Need to end in 0x320 to read the descriptor buf += 20; descriptor = buf[0]; +color_trc = buf[1]; +color_spec = buf[2]; // Need to end in 0x323 to read the bits per color buf += 3; @@ -294,18 +329,26 @@ static int decode_frame(AVCodecContext *avctx, switch (descriptor) { case 6: // Y elements = 1; +yuv = 1; +break; +case 50: // RGB +elements = 3; break; case 52: // ABGR case 51: // RGBA -case 103: // UYVA elements = 4; break; -case 50: // RGB +case 100: // UYVY422 +elements = 2; +yuv = 1; +break; case 102: // UYV444 elements = 3; +yuv = 1; break; -case 100: // UYVY422 -elements = 2; +case 103: // UYVA +elements = 4; +yuv = 1; break; default: avpriv_report_missing_feature(avctx, "Descriptor %d", descriptor); @@ -349,6 +392,82 @@ static int decode_frame(AVCodecContext *avctx, return AVERROR_INVALIDDATA; } +switch (color_trc) { +case DPX_TRC_LINEAR: +avctx->color_trc = AVCOL_TRC_LINEAR; +break; +case DPX_TRC_SMPTE_274: +case DPX_TRC_ITU_R_709_4: +avctx->color_trc = AVCOL_TRC_BT709; +break; +case DPX_TRC_ITU_R_601_625: +case DPX_TRC_ITU_R_601_525: +case DPX_TRC_SMPTE_170: +avctx->color_trc = AVCOL_TRC_SMPTE170M; +break; +case DPX_TRC_ITU_R_624_4_PAL: +avctx->color_trc = AVCOL_TRC_GAMMA28; +break; +case DPX_TRC_USER_DEFINED: +case DPX_TRC_UNSPECIFIED_VIDEO: +/* Nothing to do */ +break; +default: +av_log(avctx, AV_LOG_VERBOSE, "Cannot map DPX transfer characteristic " +"%d to color_trc.\n", color_trc); +break; +} + +switch (color_spec) { +case DPX_COL_SPEC_SMPTE_274: +case DPX_COL_SPEC_ITU_R_709_4: +avctx->color_primaries = AVCOL_PRI_BT709; +break; +case DPX_COL_SPEC_ITU_R_601_625: +case DPX_COL_SPEC_ITU_R_624_4_PAL: +avctx->color_primaries = AVCOL_PRI_BT470BG; +break; +case DPX_COL_SPEC_ITU_R_601_525: +case DPX_COL_SPEC_SMPTE_170: +avctx->color_primaries = AVCOL_PRI_SMPTE170M; +break; +case DPX_COL_SPEC_USER_DEFINED: +case DPX_COL_SPEC_UNSPECIFIED_VIDEO: +/* Nothing to do */ +break; +default: +av_log(avctx, AV_LOG_VERBOSE, "Cannot map DPX color specification " +"%d to color_primaries.\n", color_spec); +break; +} + +if (yuv) { +switch (color_spec) { +case DPX_COL_SPEC_SMPTE_274: +case DPX_COL_SPEC_ITU_R_709_4: +avctx->colorspace = AVCOL_SPC_BT709; +break; +case DPX_COL_SPEC_ITU_R_601_625: +case DPX_COL_SPEC_ITU_R_624_4_PAL: +avctx->colorspace = AVCOL_SPC_BT470BG; +break; +case DPX_COL_SPEC_ITU_R_601_525: +case DPX_COL_SPEC_SMPTE_170: +avc
[FFmpeg-devel] [PATCH 3/6] avcodec/dpx: Read SMPTE timecode from DPX
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 29 + tests/ref/fate/dpx-probe | 7 +++ 2 files changed, 36 insertions(+) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 7e3ac0af2e..51428459ef 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat.h" #include "libavutil/imgutils.h" +#include "libavutil/timecode.h" #include "bytestream.h" #include "avcodec.h" #include "internal.h" @@ -239,6 +240,34 @@ static int decode_frame(AVCodecContext *avctx, } } +/* SMPTE TC from television header */ +if (offset >= 1920 + 4) { +uint32_t tc; +uint32_t *tc_sd; +char tcbuf[AV_TIMECODE_STR_SIZE]; + +buf = avpkt->data + 1920; +// read32 to native endian, av_bswap32 to opposite of native for +// compatibility with av_timecode_make_smpte_tc_string2 etc +tc = av_bswap32(read32(, endian)); + +if (i != 0x) { +AVFrameSideData *tcside = +av_frame_new_side_data(p, AV_FRAME_DATA_S12M_TIMECODE, + sizeof(uint32_t) * 4); +if (!tcside) +return AVERROR(ENOMEM); + +tc_sd = (uint32_t*)tcside->data; +tc_sd[0] = 1; +tc_sd[1] = tc; + +av_timecode_make_smpte_tc_string2(tcbuf, avctx->framerate, + tc_sd[1], 0, 0); +av_dict_set(>metadata, "timecode", tcbuf, 0); +} +} + switch (descriptor) { case 6: // Y elements = 1; diff --git a/tests/ref/fate/dpx-probe b/tests/ref/fate/dpx-probe index a69c45ad29..9365bce644 100644 --- a/tests/ref/fate/dpx-probe +++ b/tests/ref/fate/dpx-probe @@ -27,8 +27,15 @@ color_space=unknown color_primaries=unknown color_transfer=unknown chroma_location=unspecified +TAG:timecode=00:00:01:18 TAG:Creator=Apple Compressor TAG:Input Device= +[SIDE_DATA] +side_data_type=SMPTE 12-1 timecode +[TIMECODE] +value=00:00:01:18 +[/TIMECODE] +[/SIDE_DATA] [/FRAME] [STREAM] index=0 -- 2.29.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/6] avcodec/dpx: Fix B film scans from Lasergraphics Inc
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 7b18141f97..bd431ccbcb 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -167,7 +167,7 @@ static int decode_frame(AVCodecContext *avctx, int x, y, stride, i, j, ret; int w, h, bits_per_color, descriptor, elements, packing; int yuv, color_trc, color_spec; -int encoding, need_align = 0; +int encoding, need_align = 0, unpadded_10bit = 0; unsigned int rgbBuffer = 0; int n_datum = 0; @@ -574,6 +574,12 @@ static int decode_frame(AVCodecContext *avctx, input_device[32] = '\0'; av_dict_set(>metadata, "Input Device", input_device, 0); +// Some devices do not pad 10bit samples to whole 32bit words per row +if (!memcmp(input_device, "Scanity", 7) || +!memcmp(creator, "Lasergraphics Inc.", 18)) { +unpadded_10bit = 1; +} + // Move pointer to offset from start of file buf = avpkt->data + offset; @@ -606,7 +612,7 @@ static int decode_frame(AVCodecContext *avctx, read10in32(, , _datum, endian, shift); } -if (memcmp(input_device, "Scanity", 7)) +if (!unpadded_10bit) n_datum = 0; for (i = 0; i < elements; i++) ptr[i] += p->linesize[i]; -- 2.29.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/6] avcodec/dpx: Report color_range from DPX header
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 25 - tests/ref/fate/dpx-probe | 4 ++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 51428459ef..577171258a 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -132,7 +132,7 @@ static int decode_frame(AVCodecContext *avctx, unsigned int offset; int magic_num, endian; -int x, y, stride, i, ret; +int x, y, stride, i, j, ret; int w, h, bits_per_color, descriptor, elements, packing; int encoding, need_align = 0; @@ -268,6 +268,29 @@ static int decode_frame(AVCodecContext *avctx, } } +/* color range from television header */ +if (offset >= 1964 + 4) { +buf = avpkt->data + 1952; +i = read32(, endian); + +buf = avpkt->data + 1964; +j = read32(, endian); + +if (i != 0x && j != 0x) { +float minCV, maxCV; +minCV = av_int2float(i); +maxCV = av_int2float(j); +if (bits_per_color >= 1 && +minCV == 0.0f && maxCV == ((1<color_range = AVCOL_RANGE_JPEG; +} else if (bits_per_color >= 8 && + minCV == (1 <<(bits_per_color - 4)) && + maxCV == (235<<(bits_per_color - 8))) { +avctx->color_range = AVCOL_RANGE_MPEG; +} +} +} + switch (descriptor) { case 6: // Y elements = 1; diff --git a/tests/ref/fate/dpx-probe b/tests/ref/fate/dpx-probe index 9365bce644..a45990e333 100644 --- a/tests/ref/fate/dpx-probe +++ b/tests/ref/fate/dpx-probe @@ -22,7 +22,7 @@ display_picture_number=0 interlaced_frame=0 top_field_first=0 repeat_pict=0 -color_range=unknown +color_range=pc color_space=unknown color_primaries=unknown color_transfer=unknown @@ -55,7 +55,7 @@ sample_aspect_ratio=1:1 display_aspect_ratio=107:60 pix_fmt=gbrp10le level=-99 -color_range=unknown +color_range=pc color_space=unknown color_transfer=unknown color_primaries=unknown -- 2.29.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Support HDR10+ metadata for HEVC.
> On 23 Oct 2020, at 05:57, Mohammad Izadi > wrote: > > Any comments? > > Thanks, > Mohammad > > > On Tue, Oct 13, 2020 at 4:53 PM Mohammad Izadi wrote: > >> From: Mohammad Izadi >> >> [..] Hi Mohammad, Your change is in Patchwork here https://patchwork.ffmpeg.org/project/ffmpeg/patch/20201013235345.2609036-1-iz...@google.com/ It seems the automatic testing was not able to apply your patches on top of master. Maybe they need to be rebased? Best, Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/dpxenc: stop hardcoding color trc/primaries
>> >>> >>> [..] >>> +static int get_dpx_pri(int color_pri) >>> +{ >>> +switch (color_pri) { >>> +case AVCOL_PRI_BT709: >>> +return 6; >>> +case AVCOL_PRI_SMPTE240M: >>> +case AVCOL_PRI_SMPTE170M: >>> +return 9; >> >> I think perhaps this should be 8 (ITU 601 525), rather than 9 (Composite >> video SMPTE 170M), but I am not sure? > > The smpte170m is explicitly mention in specification, so make sure you use > latest version of it. Let me try to explain myself a little better. AVCOL_PRI_SMPTE170M does not mean SMPTE170M, it means SMPTE170M, ITU-R BT601-6 525, ITU-R BT1358 525 or ITU-R BT1700 NTSC (see pixfmt.h). We will have to pick a DPX option though, which could either be 9 (SMPTE170M) or 8 (ITU-R 601 525). My guess is that the ITU 601 standard would be the most obvious choice. I guess it probably doesn't matter as the options amount to the same thing, DPX does prefer that the two bytes match in V2.0 though. > >> >>> +case AVCOL_PRI_BT470BG: >>> +return 10; >> >> Perhaps this should be 7 (ITU 601 625), rather than 10 (ITU 624-4 Composite >> video PAL), again not sure which is most widely used? > > see first comment. The primaries of ITU 624-4 PAL and ITU 601 625 are the same here, so choosing between 7 and 10 is difficult. I wonder whether the ITU 601 option is the least surprising. BT470BG is not explicitly mentioned in the DPX specification. > >> >>> +default: >>> +return 0; >>> +} >>> +} >> >> In DPX files containing colour difference information the colorspace would >> also be keyed off the value returned from this function. Perhaps it should >> be taken into account here (for files containing YCbCr)? > > Sorry, this does not make sense, the color_prim/trc is meaningfull for both > yuv and rgb. In FFMPEG we have 3 things AVColorPrimaries, AVColorTransferCharacteristic and AVColorSpace. In DPX we have only two; Transfer Characteristic and Colorimetric Specification. If we were to read these values when decoding dpx files we would choose what to set for AVColorSpace (the YCbCr matrix) based on the Colorimetric Specification. I think that should mean that we should take the AVColorSpace and the AVColorPrimaries into consideration when choosing what to put in this byte, when writing YUV DPX files. > >> >>> + >>> +static int get_dpx_trc(int color_trc) >>> +{ >>> +switch (color_trc) { >>> +case AVCOL_TRC_LINEAR: >>> +return 2; >>> +case AVCOL_TRC_BT709: >>> +return 6; >>> +case AVCOL_TRC_SMPTE240M: >>> +case AVCOL_TRC_SMPTE170M: >>> +return 9; >> >> This value could be 7, 8 or 9. From my reading of the spec the best might be >> to take colour_primaries into account and do something like: >> >> if (AVCOL_PRI_BT470BG) return 7 (ITU 601 625) >> else return 8 (ITU 601 525) >> > > see first comment. See my first comment > >>> +case AVCOL_TRC_GAMMA22: >>> +return 10; >> >> 10 is ITU 624-4 Composite video PAL, which says it has gamma = 2.8 >> (AVCOL_TRC_GAMMA28). >> https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.624-4-1990-PDF-E.pdf >> > > Hmm i will double check. > >>> +default: >>> +return 0; >>> +} >>> +} >>> + >>> >>> [..] >>> >> [..] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/dpxenc: stop hardcoding color trc/primaries
> On 7 Oct 2020, at 22:02, Paul B Mahol wrote: > > Signed-off-by: Paul B Mahol > --- > libavcodec/dpxenc.c | 36 ++-- > tests/ref/lavf/dpx | 2 +- > 2 files changed, 35 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c > index a5960334d5..56840a8d33 100644 > --- a/libavcodec/dpxenc.c > +++ b/libavcodec/dpxenc.c > @@ -173,6 +173,38 @@ static void encode_gbrp12(AVCodecContext *avctx, const > AVFrame *pic, uint16_t *d > } > } > > +static int get_dpx_pri(int color_pri) > +{ > +switch (color_pri) { > +case AVCOL_PRI_BT709: > +return 6; > +case AVCOL_PRI_SMPTE240M: > +case AVCOL_PRI_SMPTE170M: > +return 9; I think perhaps this should be 8 (ITU 601 525), rather than 9 (Composite video SMPTE 170M), but I am not sure? > +case AVCOL_PRI_BT470BG: > +return 10; Perhaps this should be 7 (ITU 601 625), rather than 10 (ITU 624-4 Composite video PAL), again not sure which is most widely used? > +default: > +return 0; > +} > +} In DPX files containing colour difference information the colorspace would also be keyed off the value returned from this function. Perhaps it should be taken into account here (for files containing YCbCr)? > + > +static int get_dpx_trc(int color_trc) > +{ > +switch (color_trc) { > +case AVCOL_TRC_LINEAR: > +return 2; > +case AVCOL_TRC_BT709: > +return 6; > +case AVCOL_TRC_SMPTE240M: > +case AVCOL_TRC_SMPTE170M: > +return 9; This value could be 7, 8 or 9. From my reading of the spec the best might be to take colour_primaries into account and do something like: if (AVCOL_PRI_BT470BG) return 7 (ITU 601 625) else return 8 (ITU 601 525) > +case AVCOL_TRC_GAMMA22: > +return 10; 10 is ITU 624-4 Composite video PAL, which says it has gamma = 2.8 (AVCOL_TRC_GAMMA28). https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.624-4-1990-PDF-E.pdf > +default: > +return 0; > +} > +} > + > > [..] > Best, Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 3/3] avformat/mxfdec: Read Apple private Content Light Level from MXF
> On 30 Sep 2020, at 08:32, Michael Niedermayer wrote: > > On Thu, Sep 17, 2020 at 10:49:31PM +0200, Tomas Härdin wrote: >> mån 2020-09-14 klockan 12:23 +0200 skrev Tomas Härdin: >>> ons 2020-09-09 klockan 15:56 +0100 skrev Harry Mallon: >>>> * As embedded by Apple Compressor >>>> >>>> Signed-off-by: Harry Mallon >>>> --- >>>> libavformat/mxfdec.c| 27 + >>>> tests/fate/mxf.mak | 4 + >>>> tests/ref/fate/mxf-probe-applehdr10 | 169 >>>> >>> >>> Sweet, I don't have to write the test myself .) >>> >>> Just ran FATE, the entire patch set works fine. We just need to get >>> that sample into the sample suite then all three of them can be >>> pushed. >>> I'll see what I can do. >> >> FATE suite updated, FATE passes -> patchset pushed > > fails on big endian > > --- src/tests/ref/fate/mxf-probe-applehdr10 2020-09-28 23:21:12.291897976 > +0200 > +++ tests/data/fate/mxf-probe-applehdr10 2020-09-30 09:31:38.614653806 > +0200 > @@ -14,7 +14,7 @@ > has_b_frames=0 > sample_aspect_ratio=1:1 > display_aspect_ratio=16:9 > -pix_fmt=yuv422p10le > +pix_fmt=yuv422p10be > level=-99 > color_range=tv > color_space=bt2020nc > Test mxf-probe-applehdr10 failed. Look at > tests/data/fate/mxf-probe-applehdr10.err for details. > src/tests/Makefile:255: recipe for target 'fate-mxf-probe-applehdr10' failed > make: *** [fate-mxf-probe-applehdr10] Error 1 It seems fair that the pixel type is in native endian. I'm not really familiar enough with FATE to provide a patch to fix this though. Do any other FATE tests have wildcards or two versions for big and little endian? > > [...] > Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] avcodec/dpx: Read alternative frame rate from television header
> On 14 Aug 2020, at 11:03, Harry Mallon wrote: > > Signed-off-by: Harry Mallon > --- > libavcodec/dpx.c | 15 ++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c > index b1833ed9ef..7e3ac0af2e 100644 > --- a/libavcodec/dpx.c > +++ b/libavcodec/dpx.c > @@ -216,10 +216,23 @@ static int decode_frame(AVCodecContext *avctx, > else > avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; > > +/* preferred frame rate from Motion-picture film header */ > if (offset >= 1724 + 4) { > buf = avpkt->data + 1724; > i = read32(, endian); > -if(i) { > +if(i && i != 0x) { > +AVRational q = av_d2q(av_int2float(i), 4096); > +if (q.num > 0 && q.den > 0) > +avctx->framerate = q; > +} > +} > + > +/* alternative frame rate from television header */ > +if (offset >= 1940 + 4 && > +!(avctx->framerate.num && avctx->framerate.den)) { > +buf = avpkt->data + 1940; > +i = read32(, endian); > +if(i && i != 0x) { > AVRational q = av_d2q(av_int2float(i), 4096); > if (q.num > 0 && q.den > 0) > avctx->framerate = q; > -- > 2.28.0 > Bump, does anyone have anything on this? Best, Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avcodec/videotoolboxenc: Set profile (main/main10) on HEVC encode
Signed-off-by: Harry Mallon --- libavcodec/videotoolboxenc.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index e89cfaeed8..212f41b19a 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -1114,15 +1114,12 @@ static int vtenc_create_encoder(AVCodecContext *avctx, } } -if (vtctx->codec_id == AV_CODEC_ID_H264) { -// kVTCompressionPropertyKey_ProfileLevel is not available for HEVC -if (profile_level) { -status = VTSessionSetProperty(vtctx->session, -kVTCompressionPropertyKey_ProfileLevel, -profile_level); -if (status) { -av_log(avctx, AV_LOG_ERROR, "Error setting profile/level property: %d. Output will be encoded using a supported profile/level combination.\n", status); -} +if (profile_level) { +status = VTSessionSetProperty(vtctx->session, + kVTCompressionPropertyKey_ProfileLevel, + profile_level); +if (status) { +av_log(avctx, AV_LOG_ERROR, "Error setting profile/level property: %d. Output will be encoded using a supported profile/level combination.\n", status); } } -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec/videotoolboxenc: Allow full range 10bit pixel format input
Signed-off-by: Harry Mallon --- libavcodec/videotoolboxenc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 212f41b19a..fe0c98300b 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -789,7 +789,6 @@ static int get_cv_pixel_format(AVCodecContext* avctx, *av_pixel_format = range == AVCOL_RANGE_JPEG ? kCVPixelFormatType_420YpCbCr10BiPlanarFullRange : kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange; -*av_pixel_format = kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange; } else { return AVERROR(EINVAL); } -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 2/3] avformat/mxfenc: Write Mastering Display Colour Volume to MXF
Described in Annex B SMPTE ST 2067-21:2020 Signed-off-by: Harry Mallon --- libavformat/mxfenc.c | 50 +++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 733c747a9a..cbb0fc5a6a 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -44,6 +44,7 @@ #include "libavutil/random_seed.h" #include "libavutil/timecode.h" #include "libavutil/avassert.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/pixdesc.h" #include "libavutil/time_internal.h" #include "libavcodec/bytestream.h" @@ -505,6 +506,7 @@ static void mxf_write_primer_pack(AVFormatContext *s) AVIOContext *pb = s->pb; int local_tag_number, i = 0; int avc_tags_count = 0; +int mastering_tags_count = 0; local_tag_number = FF_ARRAY_ELEMS(mxf_local_tag_batch); local_tag_number += mxf->store_user_comments * FF_ARRAY_ELEMS(mxf_user_comments_local_tag); @@ -513,10 +515,15 @@ static void mxf_write_primer_pack(AVFormatContext *s) MXFStreamContext *sc = s->streams[i]->priv_data; if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_H264 && !sc->avc_intra) { avc_tags_count = FF_ARRAY_ELEMS(mxf_avc_subdescriptor_local_tags); -local_tag_number += avc_tags_count; +} +if (av_stream_get_side_data(s->streams[i], AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL)) { +mastering_tags_count = FF_ARRAY_ELEMS(ff_mxf_mastering_display_local_tags); } } +local_tag_number += avc_tags_count; +local_tag_number += mastering_tags_count; + avio_write(pb, primer_pack_key, 16); klv_encode_ber_length(pb, local_tag_number * 18 + 8); @@ -534,6 +541,8 @@ static void mxf_write_primer_pack(AVFormatContext *s) } if (avc_tags_count > 0) mxf_write_local_tags(pb, mxf_avc_subdescriptor_local_tags, avc_tags_count); +if (mastering_tags_count > 0) +mxf_write_local_tags(pb, ff_mxf_mastering_display_local_tags, mastering_tags_count); } static void mxf_write_local_tag(AVIOContext *pb, int size, int tag) @@ -1043,6 +1052,16 @@ static const UID mxf_generic_sound_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0 static const UID mxf_avc_subdescriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6E,0x00 }; +static inline uint16_t rescale_mastering_chroma(AVRational q) +{ +return av_clip_uint16(av_rescale(q.num, FF_MXF_MASTERING_CHROMA_DEN, q.den)); +} + +static inline uint32_t rescale_mastering_luma(AVRational q) +{ +return av_rescale(q.num, FF_MXF_MASTERING_LUMA_DEN, q.den); +} + static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key) { MXFStreamContext *sc = st->priv_data; @@ -1055,6 +1074,7 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID const MXFCodecUL *color_trc_ul; const MXFCodecUL *color_space_ul; int64_t pos = mxf_write_generic_desc(s, st, key); +uint8_t *side_data; color_primaries_ul = mxf_get_codec_ul_by_id(ff_mxf_color_primaries_uls, st->codecpar->color_primaries); color_trc_ul = mxf_get_codec_ul_by_id(ff_mxf_color_trc_uls, st->codecpar->color_trc); @@ -1223,6 +1243,34 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID mxf_write_local_tag(pb, 16, 0x3201); avio_write(pb, *sc->codec_ul, 16); +// Mastering Display metadata +side_data = av_stream_get_side_data(st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL); +if (side_data) { +const AVMasteringDisplayMetadata *metadata = (const AVMasteringDisplayMetadata*)side_data; +if (metadata->has_primaries) { +mxf_write_local_tag(pb, 12, ff_mxf_mastering_display_local_tags[0].local_tag); +avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[0][0])); +avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[0][1])); +avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[1][0])); +avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[1][1])); +avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[2][0])); +avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[2][1])); +mxf_write_local_tag(pb, 4, ff_mxf_mastering_display_local_tags[1].local_tag); +avio_wb16(pb, rescale_mastering_chroma(metadata->white_point[0])); +avio_wb16(pb, rescale_mastering_chroma(metadata->white_point[1])); +} else { +av_log(NULL, AV_LOG_VERBOSE, "Not writing mastering display primaries. Missing data.\n"); +} +if (metadata->has_luminance
[FFmpeg-devel] [PATCH v2 3/3] avformat/mxfdec: Read Apple private Content Light Level from MXF
* As embedded by Apple Compressor Signed-off-by: Harry Mallon --- libavformat/mxfdec.c| 27 + tests/fate/mxf.mak | 4 + tests/ref/fate/mxf-probe-applehdr10 | 169 3 files changed, 200 insertions(+) create mode 100644 tests/ref/fate/mxf-probe-applehdr10 diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 8d315620bc..d16a7af0df 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -216,6 +216,8 @@ typedef struct MXFDescriptor { UID color_trc_ul; UID color_space_ul; AVMasteringDisplayMetadata *mastering; +AVContentLightMetadata *coll; +size_t coll_size; } MXFDescriptor; typedef struct MXFIndexTableSegment { @@ -321,6 +323,7 @@ static const uint8_t mxf_canopus_essence_element_key[] = { 0x06,0x0e,0x2b,0x static const uint8_t mxf_system_item_key_cp[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 }; static const uint8_t mxf_system_item_key_gc[] = { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x03,0x01,0x14 }; static const uint8_t mxf_klv_key[] = { 0x06,0x0e,0x2b,0x34 }; +static const uint8_t mxf_apple_coll_prefix[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01 }; /* complete keys to match */ static const uint8_t mxf_crypto_source_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 }; static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 }; @@ -331,6 +334,8 @@ static const uint8_t mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x static const uint8_t mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }; static const uint8_t mxf_indirect_value_utf16le[] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }; static const uint8_t mxf_indirect_value_utf16be[] = { 0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }; +static const uint8_t mxf_apple_coll_max_cll[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x01 }; +static const uint8_t mxf_apple_coll_max_fall[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x02 }; #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y))) @@ -341,6 +346,7 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx) case Descriptor: av_freep(&((MXFDescriptor *)*ctx)->extradata); av_freep(&((MXFDescriptor *)*ctx)->mastering); +av_freep(&((MXFDescriptor *)*ctx)->coll); break; case MultipleDescriptor: av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs); @@ -1312,6 +1318,19 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int descriptor->mastering->has_luminance = 1; } } +if (IS_KLV_KEY(uid, mxf_apple_coll_prefix)) { +if (!descriptor->coll) { +descriptor->coll = av_content_light_metadata_alloc(>coll_size); +if (!descriptor->coll) +return AVERROR(ENOMEM); +} +if (IS_KLV_KEY(uid, mxf_apple_coll_max_cll)) { +descriptor->coll->MaxCLL = avio_rb16(pb); +} +if (IS_KLV_KEY(uid, mxf_apple_coll_max_fall)) { +descriptor->coll->MaxFALL = avio_rb16(pb); +} +} break; } return 0; @@ -2580,6 +2599,14 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) goto fail_and_free; descriptor->mastering = NULL; } +if (descriptor->coll) { +ret = av_stream_add_side_data(st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, + (uint8_t *)descriptor->coll, + descriptor->coll_size); +if (ret < 0) +goto fail_and_free; +descriptor->coll = NULL; +} } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul); /* Only overwrite existing codec ID if it is unset or A-law, which is the default according to SMPTE RP 224. */ diff --git a/tests/fate/mxf.mak b/tests/fate/mxf.mak index 4aafc1f578..3adef939dc 100644 --- a/tests/fate/mxf.mak +++ b/tests/fate/mxf.mak @@ -33,6 +33,10 @@ FATE_MXF_PROBE-$(call ENCDEC2, DVVIDEO, PCM_S16LE, MXF) += fate-mxf-probe-dv25 fate-mxf-probe-dv25: SRC = $(TARGET_SAMPLES)/mxf
[FFmpeg-devel] [PATCH v2 1/3] avformat/mxfdec: Read Mastering Display Colour Volume from MXF
Described in Annex B SMPTE ST 2067-21:2020 Signed-off-by: Harry Mallon --- libavformat/mxf.c| 11 ++ libavformat/mxf.h| 11 ++ libavformat/mxfdec.c | 48 libavformat/mxfenc.c | 5 - 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/libavformat/mxf.c b/libavformat/mxf.c index e51fc48a84..88f69ebcfb 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -22,6 +22,17 @@ #include "libavutil/common.h" #include "mxf.h" +const uint8_t ff_mxf_mastering_display_prefix[13] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01 }; + +/* be careful to update references to this array if reordering */ +/* local tags are dynamic and must not clash with others in mxfenc.c */ +const MXFLocalTagPair ff_mxf_mastering_display_local_tags[4] = { +{ 0x8301, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00 }}, /* Mastering Display Primaries */ +{ 0x8302, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00 }}, /* Mastering Display White Point Chromaticity */ +{ 0x8303, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00 }}, /* Mastering Display Maximum Luminance */ +{ 0x8304, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00 }} /* Mastering Display Minimum Luminance */ +}; + /** * SMPTE RP224 http://www.smpte-ra.org/mdd/index.html */ diff --git a/libavformat/mxf.h b/libavformat/mxf.h index fc587f19f0..7fa10bcca1 100644 --- a/libavformat/mxf.h +++ b/libavformat/mxf.h @@ -78,6 +78,17 @@ typedef enum { RawVWrap } MXFWrappingIndicatorType; +typedef struct MXFLocalTagPair { +int local_tag; +UID uid; +} MXFLocalTagPair; + +extern const uint8_t ff_mxf_mastering_display_prefix[13]; +extern const MXFLocalTagPair ff_mxf_mastering_display_local_tags[4]; + +#define FF_MXF_MASTERING_CHROMA_DEN 5 +#define FF_MXF_MASTERING_LUMA_DEN 1 + typedef struct MXFCodecUL { UID uid; unsigned matching_len; diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 6f6e8d586c..8d315620bc 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -28,6 +28,7 @@ * SMPTE 381M Mapping MPEG Streams into the MXF Generic Container * SMPTE 382M Mapping AES3 and Broadcast Wave Audio into the MXF Generic Container * SMPTE 383M Mapping DV-DIF Data to the MXF Generic Container + * SMPTE 2067-21 Interoperable Master Format — Application #2E * * Principle * Search for Track numbers which will identify essence element KLV packets. @@ -47,6 +48,7 @@ #include "libavutil/aes.h" #include "libavutil/avassert.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/mathematics.h" #include "libavcodec/bytestream.h" #include "libavutil/intreadwrite.h" @@ -213,6 +215,7 @@ typedef struct MXFDescriptor { UID color_primaries_ul; UID color_trc_ul; UID color_space_ul; +AVMasteringDisplayMetadata *mastering; } MXFDescriptor; typedef struct MXFIndexTableSegment { @@ -337,6 +340,7 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx) switch ((*ctx)->type) { case Descriptor: av_freep(&((MXFDescriptor *)*ctx)->extradata); +av_freep(&((MXFDescriptor *)*ctx)->mastering); break; case MultipleDescriptor: av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs); @@ -1272,6 +1276,42 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K) descriptor->pix_fmt = AV_PIX_FMT_XYZ12; } +if (IS_KLV_KEY(uid, ff_mxf_mastering_display_prefix)) { +if (!descriptor->mastering) { +descriptor->mastering = av_mastering_display_metadata_alloc(); +if (!descriptor->mastering) +return AVERROR(ENOMEM); +} +if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[0].uid)) { +for (int i = 0; i < 3; i++) { +/* Order: large x, large y, other (i.e. RGB) */ +descriptor->mastering->display_primaries[i][0] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN); +descriptor->mastering->display_primaries[i][1] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN); +} +/* Check we have seen mxf_mastering_display_white_point_chromaticity */ +if (descriptor->mastering->white_point[0].den != 0) +descriptor->mastering->has_primaries = 1; +} +if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[1].uid)) { +descriptor->mastering->whit
Re: [FFmpeg-devel] [PATCH 3/3] avformat/mxfdec: Read Apple private Content Light Level from MXF
> On 7 Sep 2020, at 10:46, Tomas Härdin wrote: > > mån 2020-08-31 klockan 20:07 +0100 skrev Harry Mallon: >> * As embedded by Apple Compressor > > This needs a sample since it isn't part of any official spec, so that > we can have a test for this. > >> +if (IS_KLV_KEY(uid, mxf_coll_apple_max_cll)) { >> +if (!descriptor->coll) { >> +descriptor->coll = >> av_content_light_metadata_alloc(>coll_size); >> +if (!descriptor->coll) >> +return AVERROR(ENOMEM); >> +} > > Duplicated allocation here as well. See my comment on PATCH 1/3. > Sample and FATE test in v2. Best, Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3] avformat/mxfenc: Write Mastering Display Colour Volume to MXF
> On 3 Sep 2020, at 07:31, Marton Balint wrote: > > On Mon, 31 Aug 2020, Harry Mallon wrote: > >> [..] >> }; >> +static const MXFLocalTagPair mxf_mastering_display_local_tags[] = { >> +{ 0x8201, >> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00}}, >> /* Mastering Display Primaries */ >> +{ 0x8202, >> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00}}, >> /* Mastering Display White Point Chromaticity */ >> +{ 0x8203, >> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00}}, >> /* Mastering Display Maximum Luminance */ >> +{ 0x8204, >> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00}}, >> /* Mastering Display Minimum Luminance */ > > Ain't these collide with AVC subdescriptor local tags? Yep, doh. Fixed in v2. > >> +}; >> + >> static void mxf_write_uuid(AVIOContext *pb, enum MXFMetadataSetType type, >> int value) >> { >>avio_write(pb, uuid_base, 12); >> @@ -510,6 +518,7 @@ static void mxf_write_primer_pack(AVFormatContext *s) >>AVIOContext *pb = s->pb; >>int local_tag_number, i = 0; >>int avc_tags_count = 0; >> +int mastering_tags_count = 0; >> >>local_tag_number = FF_ARRAY_ELEMS(mxf_local_tag_batch); >>local_tag_number += mxf->store_user_comments * >> FF_ARRAY_ELEMS(mxf_user_comments_local_tag); >> @@ -522,6 +531,15 @@ static void mxf_write_primer_pack(AVFormatContext *s) >>} >>} >> +for (i = 0; i < s->nb_streams; i++) { >> +uint8_t *side_data = av_stream_get_side_data(s->streams[i], >> AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL); > > You can get rid of the side_data temporary variable and use the function call > directly in the if condition. This and other comments fixed in v2 (also Tomas' comments) > >> +if (side_data) { >> +mastering_tags_count = >> FF_ARRAY_ELEMS(mxf_mastering_display_local_tags); >> +local_tag_number += mastering_tags_count; >> +break; >> +} >> +} > > [..] >> + Thanks for the review Best, Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avformat/mxfdec: Read Mastering Display Colour Volume from MXF
> On 7 Sep 2020, at 10:40, Tomas Härdin wrote: > > mån 2020-08-31 klockan 20:07 +0100 skrev Harry Mallon: >> +static const uint8_t mxf_mastering_display_primaries[]= { >> 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00 >> }; >> +static const uint8_t mxf_mastering_display_white_point_chromaticity[] = { >> 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00 >> }; >> +static const uint8_t mxf_mastering_display_maximum_luminance[]= { >> 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00 >> }; >> +static const uint8_t mxf_mastering_display_minimum_luminance[]= { >> 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00 >> }; > > I can't find any of these ULs in any of the specs I have on hand. Are > they all defined in 2067-21? ULs for for example primaries are already > defined in RP210 (06.0E.2B.34.01.01.01.09.04.01.02.01.01.06.00.00) and > RP224 (06.0E.2B.34.04.01.01.06.04.01.01.01.03.00.00.00). SMPTEST 2067-21:2020 (available free atm https://ieeexplore.ieee.org/stamp/stamp.jsp?tp==9097487), Annex B. The UIDs are split over multiple lines, preventing easy grepping. :) > > >> @@ -1272,6 +1280,60 @@ static int mxf_read_generic_descriptor(void *arg, >> AVIOContext *pb, int tag, int >> rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K) >> descriptor->pix_fmt = AV_PIX_FMT_XYZ12; >> } >> +if (IS_KLV_KEY(uid, mxf_mastering_display_primaries)) { >> +const int chroma_den = 5; > > I see this and luma_den used both here and in the mxfenc patch. Since > they're the same values, consider defining them as macros in mxf.h > instead. Done in v2. > >> +int i; >> +if (!descriptor->mastering) { >> +descriptor->mastering = >> av_mastering_display_metadata_alloc(); >> +if (!descriptor->mastering) >> +return AVERROR(ENOMEM); >> +} > > This exact code appears four times, should be de-duplicated. You could > for example do IS_KLV_KEY() with a prefix of all four keys > (0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01) > before these four IS_KLV_KEY() ifs. Done in v2. Best, Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavcodec/options_table: Add missing colorspace options
> On 8 Sep 2020, at 14:29, Gyan Doshi wrote: > > On 08-09-2020 06:23 pm, Harry Mallon wrote: >> >> >>> On 8 Sep 2020, at 13:08, Gyan Doshi wrote: >>> >>> Hi Harry, >>> >>> On 06-09-2020 04:24 pm, Gyan Doshi wrote: >>>> >>>> On 06-09-2020 02:59 pm, Harry Mallon wrote: >>>>> Is there anything I need to do to move this forwards? I think it is >>>>> relatively uncontroversial? >>>> Agreed. Will push in 3 days if there are no objections. >>> Can you link to some doc references for the entries you added? >>> >> I'm not 100% sure what you mean, do you mean add some links to the >> doc/codecs.texi file, or just for the mailing list? ICtCp is definitely in >> ITU-R Rec 2100, I'm not sure about the others. It just seemed to me that >> they were missing from the command line arguments (and I needed to manually >> set ICtCp for something). > > For the ML, at present. Ideally, the canonical standard docs. Avoid > Wikipedia, forum posts..etc > Well ICtCp (which is the one I am interested in) is in ITU-R BT.2100 https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2100-2-201807-I!!PDF-E.pdf I am not sure where the chroma-derived ones come from. They are all already supported in ffmpeg (https://github.com/FFmpeg/FFmpeg/commit/f3571048669bf876681499f49e9df492f05f73c6), just they were missing from this specific command line option. Best, Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavcodec/options_table: Add missing colorspace options
> On 8 Sep 2020, at 13:08, Gyan Doshi wrote: > > Hi Harry, > > On 06-09-2020 04:24 pm, Gyan Doshi wrote: >> >> >> On 06-09-2020 02:59 pm, Harry Mallon wrote: >>> Is there anything I need to do to move this forwards? I think it is >>> relatively uncontroversial? >> >> Agreed. Will push in 3 days if there are no objections. > > Can you link to some doc references for the entries you added? > I'm not 100% sure what you mean, do you mean add some links to the doc/codecs.texi file, or just for the mailing list? ICtCp is definitely in ITU-R Rec 2100, I'm not sure about the others. It just seemed to me that they were missing from the command line arguments (and I needed to manually set ICtCp for something). Best, Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavcodec/options_table: Add missing colorspace options
Is there anything I need to do to move this forwards? I think it is relatively uncontroversial? Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Support HDR10+ metadata for HEVC.
> On 12 Aug 2020, at 21:58, Vittorio Giovara wrote: > > On Wed, Aug 12, 2020 at 6:40 PM Mohammad Izadi wrote: > >> Vittorio, >> >> What is the next step for me? >> >> Thanks, >> Mohammad >> > > Hi, I don't have any more comments for the patch, except that it would be > nice if there were some kind of fate testing. > See for example cf1cae58b015427918ecfa507a045aae4cf398fd, which is > similarly exporting metadata information from an input file to stdout. > The test will make sure that future changes won't break this functionality. So are we waiting on a small file size example to be added to fate? Or is there something else required here? I am also interested in HDR10+ and could help trying patches out. Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avformat/mxfdec: Read Mastering Display Colour Volume from MXF
Described in Annex B SMPTE ST 2067-21:2020 Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 70 1 file changed, 70 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 6f6e8d586c..a7a1e74a0a 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -28,6 +28,7 @@ * SMPTE 381M Mapping MPEG Streams into the MXF Generic Container * SMPTE 382M Mapping AES3 and Broadcast Wave Audio into the MXF Generic Container * SMPTE 383M Mapping DV-DIF Data to the MXF Generic Container + * SMPTE 2067-21 Interoperable Master Format — Application #2E * * Principle * Search for Track numbers which will identify essence element KLV packets. @@ -47,6 +48,7 @@ #include "libavutil/aes.h" #include "libavutil/avassert.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/mathematics.h" #include "libavcodec/bytestream.h" #include "libavutil/intreadwrite.h" @@ -213,6 +215,7 @@ typedef struct MXFDescriptor { UID color_primaries_ul; UID color_trc_ul; UID color_space_ul; +AVMasteringDisplayMetadata *mastering; } MXFDescriptor; typedef struct MXFIndexTableSegment { @@ -328,6 +331,10 @@ static const uint8_t mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x static const uint8_t mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }; static const uint8_t mxf_indirect_value_utf16le[] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }; static const uint8_t mxf_indirect_value_utf16be[] = { 0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }; +static const uint8_t mxf_mastering_display_primaries[]= { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00 }; +static const uint8_t mxf_mastering_display_white_point_chromaticity[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00 }; +static const uint8_t mxf_mastering_display_maximum_luminance[]= { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00 }; +static const uint8_t mxf_mastering_display_minimum_luminance[]= { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00 }; #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y))) @@ -337,6 +344,7 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx) switch ((*ctx)->type) { case Descriptor: av_freep(&((MXFDescriptor *)*ctx)->extradata); +av_freep(&((MXFDescriptor *)*ctx)->mastering); break; case MultipleDescriptor: av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs); @@ -1272,6 +1280,60 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K) descriptor->pix_fmt = AV_PIX_FMT_XYZ12; } +if (IS_KLV_KEY(uid, mxf_mastering_display_primaries)) { +const int chroma_den = 5; +int i; +if (!descriptor->mastering) { +descriptor->mastering = av_mastering_display_metadata_alloc(); +if (!descriptor->mastering) +return AVERROR(ENOMEM); +} +for (i = 0; i < 3; i++) { +/* Order: large x, large y, other (i.e. RGB) */ +descriptor->mastering->display_primaries[i][0] = av_make_q(avio_rb16(pb), chroma_den); +descriptor->mastering->display_primaries[i][1] = av_make_q(avio_rb16(pb), chroma_den); +} +/* Check we have seen mxf_mastering_display_white_point_chromaticity */ +if (descriptor->mastering->white_point[0].den != 0) +descriptor->mastering->has_primaries = 1; +} +if (IS_KLV_KEY(uid, mxf_mastering_display_white_point_chromaticity)) { +const int chroma_den = 5; +if (!descriptor->mastering) { +descriptor->mastering = av_mastering_display_metadata_alloc(); +if (!descriptor->mastering) +return AVERROR(ENOMEM); +} +descriptor->mastering->white_point[0] = av_make_q(avio_rb16(pb), chroma_den); +descriptor->mastering->white_point[1] = av_make_q(avio_rb16(pb), chroma_den); +/* Check we have seen mxf_mastering_display_primaries */ +if (descriptor->mastering->display_primaries[0][0].den != 0) +descriptor->mastering->has_primaries = 1; +} +if (IS_KLV_KEY(uid, mxf_mastering_display_maximum_luminance)) { +const int luma_den = 1; +
[FFmpeg-devel] [PATCH 3/3] avformat/mxfdec: Read Apple private Content Light Level from MXF
* As embedded by Apple Compressor Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 29 + 1 file changed, 29 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index a7a1e74a0a..58a11384b4 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -216,6 +216,8 @@ typedef struct MXFDescriptor { UID color_trc_ul; UID color_space_ul; AVMasteringDisplayMetadata *mastering; +AVContentLightMetadata *coll; +size_t coll_size; } MXFDescriptor; typedef struct MXFIndexTableSegment { @@ -335,6 +337,8 @@ static const uint8_t mxf_mastering_display_primaries[] = { 0x06,0 static const uint8_t mxf_mastering_display_white_point_chromaticity[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00 }; static const uint8_t mxf_mastering_display_maximum_luminance[]= { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00 }; static const uint8_t mxf_mastering_display_minimum_luminance[]= { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00 }; +static const uint8_t mxf_coll_apple_max_cll[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x01 }; +static const uint8_t mxf_coll_apple_max_fall[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x02 }; #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y))) @@ -345,6 +349,7 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx) case Descriptor: av_freep(&((MXFDescriptor *)*ctx)->extradata); av_freep(&((MXFDescriptor *)*ctx)->mastering); +av_freep(&((MXFDescriptor *)*ctx)->coll); break; case MultipleDescriptor: av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs); @@ -1334,6 +1339,22 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int if (descriptor->mastering->max_luminance.den != 0) descriptor->mastering->has_luminance = 1; } +if (IS_KLV_KEY(uid, mxf_coll_apple_max_cll)) { +if (!descriptor->coll) { +descriptor->coll = av_content_light_metadata_alloc(>coll_size); +if (!descriptor->coll) +return AVERROR(ENOMEM); +} +descriptor->coll->MaxCLL = avio_rb16(pb); +} +if (IS_KLV_KEY(uid, mxf_coll_apple_max_fall)) { +if (!descriptor->coll) { +descriptor->coll = av_content_light_metadata_alloc(>coll_size); +if (!descriptor->coll) +return AVERROR(ENOMEM); +} +descriptor->coll->MaxFALL = avio_rb16(pb); +} break; } return 0; @@ -2602,6 +2623,14 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) goto fail_and_free; descriptor->mastering = NULL; } +if (descriptor->coll) { +ret = av_stream_add_side_data(st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, + (uint8_t *)descriptor->coll, + descriptor->coll_size); +if (ret < 0) +goto fail_and_free; +descriptor->coll = NULL; +} } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul); /* Only overwrite existing codec ID if it is unset or A-law, which is the default according to SMPTE RP 224. */ -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] avformat/mxfenc: Write Mastering Display Colour Volume to MXF
Described in Annex B SMPTE ST 2067-21:2020 Signed-off-by: Harry Mallon --- libavformat/mxfenc.c | 56 1 file changed, 56 insertions(+) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index e495b5ba0e..fe1ecb6705 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -44,6 +44,7 @@ #include "libavutil/random_seed.h" #include "libavutil/timecode.h" #include "libavutil/avassert.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/pixdesc.h" #include "libavutil/time_internal.h" #include "libavcodec/bytestream.h" @@ -421,6 +422,13 @@ static const MXFLocalTagPair mxf_user_comments_local_tag[] = { { 0x5003, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x02,0x01,0x02,0x0A,0x01,0x00,0x00}}, /* Value */ }; +static const MXFLocalTagPair mxf_mastering_display_local_tags[] = { +{ 0x8201, {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00}}, /* Mastering Display Primaries */ +{ 0x8202, {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00}}, /* Mastering Display White Point Chromaticity */ +{ 0x8203, {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00}}, /* Mastering Display Maximum Luminance */ +{ 0x8204, {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00}}, /* Mastering Display Minimum Luminance */ +}; + static void mxf_write_uuid(AVIOContext *pb, enum MXFMetadataSetType type, int value) { avio_write(pb, uuid_base, 12); @@ -510,6 +518,7 @@ static void mxf_write_primer_pack(AVFormatContext *s) AVIOContext *pb = s->pb; int local_tag_number, i = 0; int avc_tags_count = 0; +int mastering_tags_count = 0; local_tag_number = FF_ARRAY_ELEMS(mxf_local_tag_batch); local_tag_number += mxf->store_user_comments * FF_ARRAY_ELEMS(mxf_user_comments_local_tag); @@ -522,6 +531,15 @@ static void mxf_write_primer_pack(AVFormatContext *s) } } +for (i = 0; i < s->nb_streams; i++) { +uint8_t *side_data = av_stream_get_side_data(s->streams[i], AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL); +if (side_data) { +mastering_tags_count = FF_ARRAY_ELEMS(mxf_mastering_display_local_tags); +local_tag_number += mastering_tags_count; +break; +} +} + avio_write(pb, primer_pack_key, 16); klv_encode_ber_length(pb, local_tag_number * 18 + 8); @@ -539,6 +557,8 @@ static void mxf_write_primer_pack(AVFormatContext *s) } if (avc_tags_count > 0) mxf_write_local_tags(pb, mxf_avc_subdescriptor_local_tags, avc_tags_count); +if (mastering_tags_count > 0) +mxf_write_local_tags(pb, mxf_mastering_display_local_tags, mastering_tags_count); } static void mxf_write_local_tag(AVIOContext *pb, int size, int tag) @@ -1048,6 +1068,11 @@ static const UID mxf_generic_sound_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0 static const UID mxf_avc_subdescriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6E,0x00 }; +static inline int64_t rescale_mastering(AVRational q, int b) +{ +return av_rescale(q.num, b, q.den); +} + static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key) { MXFStreamContext *sc = st->priv_data; @@ -1060,6 +1085,7 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID const MXFCodecUL *color_trc_ul; const MXFCodecUL *color_space_ul; int64_t pos = mxf_write_generic_desc(s, st, key); +uint8_t *side_data; color_primaries_ul = mxf_get_codec_ul_by_id(ff_mxf_color_primaries_uls, st->codecpar->color_primaries); color_trc_ul = mxf_get_codec_ul_by_id(ff_mxf_color_trc_uls, st->codecpar->color_trc); @@ -1228,6 +1254,36 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID mxf_write_local_tag(pb, 16, 0x3201); avio_write(pb, *sc->codec_ul, 16); +// Mastering Display metadata +side_data = av_stream_get_side_data(st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL); +if (side_data) { +const AVMasteringDisplayMetadata *metadata = (const AVMasteringDisplayMetadata*)side_data; +const int chroma_den = 5; +const int luma_den = 1; +if (metadata->has_primaries) { +mxf_write_local_tag(pb, 12, 0x8201); +avio_wb16(pb, rescale_mastering(metadata->display_primaries[0][0], chroma_den)); +avio_wb16(pb, rescale_mastering(metadata->display_primaries[0][1], chroma_den)); +avio_wb16(pb, rescale_mastering(metadata->display_primaries[1][0], chroma_den)); +avio_wb16(pb, rescale_mastering(metadata->display_primaries[1][1], chroma_den)); +av
Re: [FFmpeg-devel] [PATCH 8/8] RFC: editing HDR properties in H.265 metadata BSF
> On 23 Aug 2020, at 23:33, Mark Thompson wrote: > > --- > Setting HDR properties is a useful feature, but it's very unclear what we > want it to actually look like to the user. Not all encoders and decoders > support it, so it's essentially required that the implementation happen at > the bitstream filter level so that we can support all codecs in the same way. > This is several patches mashed together to invite comments on a bitstream > filter approach. Mastering display data behaves similarly to color_range, color_primaries, color_trc and colorspace in that some formats allow use to set it on frame, some on the stream, some on the container but it is a property of the contained pictures. I notice that color data can be set per frame and per stream already and I don’t fully understand how these interact if converting between data in frame (e.g HEVC SEI in stream in hev1) or data in header (e.g. MOV mdcv tag or HEVC SEI in hvc1 format). Content light level data is a little different as it describes the stream in which the image is contained and ffmpeg image filters would affect it. It it however still a property of the whole stream. I guess my question is how to provide a good experience converting between hvc1, hev1, prores in movs, av1 etc etc when the data has to be moved between frame and stream. > > […] > > Thoughts invited on any of this. As you point out MDCV and CLLI are relevant to so many codecs and container formats that anything with hevc_ etc would be confusing as adapting configs for different formats would require extra work (e.g. read from av1, write to hevc bitstream filters). I an pretty new to FFMPEG to please ignore any of this that makes no sense :) Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v5 2/2] libavformat/mxfenc: color_range should be inclusive
> On 24 Aug 2020, at 09:30, Tomas Härdin wrote: > > tor 2020-08-20 klockan 14:58 +0100 skrev Harry Mallon: >> MXF CDCI color range was being set to (1<component_depth) - 1 >> for full range but it should be (1<component_depth) is 0 is >> a valid value. > > Grammar here is a bit strange. Do you mean 0 is a valid value? Looks OK > besides this Sorry, it is meant to read ‘as 0 is a valid value’. Shall I change in a new version? Thanks for being attentive and speedy with my patches btw. Sending things into FFMPEG has been pretty painless. :) Harry. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] libavfilter/vf_libvmaf: document log_fmt = csv
Signed-off-by: Harry Mallon --- doc/filters.texi | 2 +- libavfilter/vf_libvmaf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index d8cd45066a..610cb09a8c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -12870,7 +12870,7 @@ Default value: @code{"/usr/local/share/model/vmaf_v0.6.1.pkl"} Set the file path to be used to store logs. @item log_fmt -Set the format of the log file (xml or json). +Set the format of the log file (csv, json or xml). @item enable_transform This option can enable/disable the @code{score_transform} applied to the final predicted VMAF score, diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c index 14c3216b3a..4d49127efc 100644 --- a/libavfilter/vf_libvmaf.c +++ b/libavfilter/vf_libvmaf.c @@ -74,7 +74,7 @@ typedef struct LIBVMAFContext { static const AVOption libvmaf_options[] = { {"model_path", "Set the model to be used for computing vmaf.", OFFSET(model_path), AV_OPT_TYPE_STRING, {.str="/usr/local/share/model/vmaf_v0.6.1.pkl"}, 0, 1, FLAGS}, {"log_path", "Set the file path to be used to store logs.", OFFSET(log_path), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS}, -{"log_fmt", "Set the format of the log (xml or json).", OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS}, +{"log_fmt", "Set the format of the log (csv, json or xml).", OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS}, {"enable_transform", "Enables transform for computing vmaf.", OFFSET(enable_transform), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS}, {"phone_model", "Invokes the phone model that will generate higher VMAF scores.", OFFSET(phone_model), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS}, {"psnr", "Enables computing psnr along with vmaf.", OFFSET(psnr), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS}, -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 1/2] avformat/mxfdec: Read video range from CDCIEssenceDescriptor
* Capture black_ref, white_ref and color_range and recognise full and narrow range. Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 37 ++ tests/ref/fate/mxf-probe-dnxhd | 2 +- tests/ref/fate/mxf-probe-dv25 | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4b56984b77..7e1686f0df 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -199,6 +199,9 @@ typedef struct MXFDescriptor { int bits_per_sample; int64_t duration; /* ContainerDuration optional property */ unsigned int component_depth; +unsigned int black_ref_level; +unsigned int white_ref_level; +unsigned int color_range; unsigned int horiz_subsampling; unsigned int vert_subsampling; UID *sub_descriptors_refs; @@ -1222,6 +1225,15 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; +case 0x3304: +descriptor->black_ref_level = avio_rb32(pb); +break; +case 0x3305: +descriptor->white_ref_level = avio_rb32(pb); +break; +case 0x3306: +descriptor->color_range = avio_rb32(pb); +break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; @@ -2157,6 +2169,30 @@ static int mxf_add_metadata_stream(MXFContext *mxf, MXFTrack *track) return 0; } +static enum AVColorRange mxf_get_color_range(MXFContext *mxf, MXFDescriptor *descriptor) +{ +if (descriptor->black_ref_level || descriptor->white_ref_level || descriptor->color_range) { +/* CDCI range metadata */ +if (!descriptor->component_depth) +return AVCOL_RANGE_UNSPECIFIED; +if (descriptor->black_ref_level == 0 && +descriptor->white_ref_level == ((1<component_depth) - 1) && +(descriptor->color_range== (1<component_depth) || + descriptor->color_range== ((1<component_depth) - 1))) +return AVCOL_RANGE_JPEG; +if (descriptor->component_depth >= 8 && +descriptor->black_ref_level == (1 <<(descriptor->component_depth - 4)) && +descriptor->white_ref_level == (235<<(descriptor->component_depth - 8)) && +descriptor->color_range == ((14<<(descriptor->component_depth - 4)) + 1)) +return AVCOL_RANGE_MPEG; +avpriv_request_sample(mxf->fc, "Unrecognized CDCI color range (color diff range %d, b %d, w %d, depth %d)", + descriptor->color_range, descriptor->black_ref_level, + descriptor->white_ref_level, descriptor->component_depth); +} + +return AVCOL_RANGE_UNSPECIFIED; +} + static int mxf_parse_structural_metadata(MXFContext *mxf) { MXFPackage *material_package = NULL; @@ -2492,6 +2528,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) } if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) st->display_aspect_ratio = descriptor->aspect_ratio; +st->codecpar->color_range = mxf_get_color_range(mxf, descriptor); st->codecpar->color_primaries = mxf_get_codec_ul(ff_mxf_color_primaries_uls, >color_primaries_ul)->id; st->codecpar->color_trc = mxf_get_codec_ul(ff_mxf_color_trc_uls, >color_trc_ul)->id; st->codecpar->color_space = mxf_get_codec_ul(ff_mxf_color_space_uls, >color_space_ul)->id; diff --git a/tests/ref/fate/mxf-probe-dnxhd b/tests/ref/fate/mxf-probe-dnxhd index 012d3ea1d9..5a6221b1d5 100644 --- a/tests/ref/fate/mxf-probe-dnxhd +++ b/tests/ref/fate/mxf-probe-dnxhd @@ -124,7 +124,7 @@ sample_aspect_ratio=1:1 display_aspect_ratio=4:3 pix_fmt=yuv422p level=-99 -color_range=unknown +color_range=tv color_space=bt709 color_transfer=bt709 color_primaries=bt709 diff --git a/tests/ref/fate/mxf-probe-dv25 b/tests/ref/fate/mxf-probe-dv25 index 810f145f41..ffd26c4dfd 100644 --- a/tests/ref/fate/mxf-probe-dv25 +++ b/tests/ref/fate/mxf-probe-dv25 @@ -16,7 +16,7 @@ sample_aspect_ratio=16:15 display_aspect_ratio=4:3 pix_fmt=yuv420p level=-99 -color_range=unknown +color_range=tv color_space=unknown color_transfer=bt470m color_primaries=unknown -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 2/2] libavformat/mxfenc: color_range should be inclusive
MXF CDCI color range was being set to (1<component_depth) - 1 for full range but it should be (1<component_depth) is 0 is a valid value. Signed-off-by: Harry Mallon --- libavformat/mxfenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index a38fa6b983..e495b5ba0e 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1160,7 +1160,7 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED) { int black = 0, white = (1<component_depth) - 1, -color = (1<component_depth) - 1; +color = (1<component_depth); if (st->codecpar->color_range == AVCOL_RANGE_MPEG) { black = 1 << (sc->component_depth - 4); white = 235 << (sc->component_depth - 8); -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavfilter/vf_libvmaf: document log_fmt = csv
Signed-off-by: Harry Mallon --- libavfilter/vf_libvmaf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c index 14c3216b3a..4d49127efc 100644 --- a/libavfilter/vf_libvmaf.c +++ b/libavfilter/vf_libvmaf.c @@ -74,7 +74,7 @@ typedef struct LIBVMAFContext { static const AVOption libvmaf_options[] = { {"model_path", "Set the model to be used for computing vmaf.", OFFSET(model_path), AV_OPT_TYPE_STRING, {.str="/usr/local/share/model/vmaf_v0.6.1.pkl"}, 0, 1, FLAGS}, {"log_path", "Set the file path to be used to store logs.", OFFSET(log_path), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS}, -{"log_fmt", "Set the format of the log (xml or json).", OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS}, +{"log_fmt", "Set the format of the log (csv, json or xml).", OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS}, {"enable_transform", "Enables transform for computing vmaf.", OFFSET(enable_transform), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS}, {"phone_model", "Invokes the phone model that will generate higher VMAF scores.", OFFSET(phone_model), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS}, {"psnr", "Enables computing psnr along with vmaf.", OFFSET(psnr), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS}, -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavcodec/options_table: Add missing colorspace options
* chroma-derived-nc / chroma-derived-c and ictcp Signed-off-by: Harry Mallon --- doc/codecs.texi| 6 ++ libavcodec/options_table.h | 33 ++--- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/doc/codecs.texi b/doc/codecs.texi index c092aadc0e..1da2590795 100644 --- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -1110,6 +1110,12 @@ BT.2020 NCL BT.2020 CL @item smpte2085 SMPTE 2085 +@item chroma-derived-nc +Chroma-derived NCL +@item chroma-derived-c +Chroma-derived CL +@item ictcp +ICtCp @end table @item color_range @var{integer} (@emph{decoding/encoding,video}) diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 1d0db1b5a4..66bda42663 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -381,21 +381,24 @@ static const AVOption avcodec_options[] = { {"bt2020_12bit", "BT.2020 - 12 bit", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_BT2020_12 },INT_MIN, INT_MAX, V|E|D, "color_trc_type"}, {"smpte428_1", "SMPTE 428-1", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_SMPTE428 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"}, {"colorspace", "color space", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64 = AVCOL_SPC_UNSPECIFIED }, 0, INT_MAX, V|E|D, "colorspace_type"}, -{"rgb", "RGB", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_RGB }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt709", "BT.709", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT709 }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"unknown", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"fcc", "FCC", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_FCC }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt470bg", "BT.470 BG", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT470BG }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"smpte170m", "SMPTE 170 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_SMPTE170M }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"smpte240m", "SMPTE 240 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_SMPTE240M }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"ycgco", "YCGCO", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_YCGCO }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt2020nc","BT.2020 NCL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_NCL }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt2020c", "BT.2020 CL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_CL }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"smpte2085", "SMPTE 2085", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_SMPTE2085 }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"unspecified", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"ycocg", "YCGCO", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_YCGCO }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt2020_ncl", "BT.2020 NCL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_NCL }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt2020_cl", "BT.2020 CL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_CL }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"rgb", "RGB",0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_RGB },INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"bt709", "BT.709", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT709 }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"unknown", "Unspecified",0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_UNSPECIFIED },INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"fcc", "FCC",0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_FCC },INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"bt470bg", "BT.470 BG", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT470BG },INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"smpte170m", "SMPTE 170 M",0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_SMPTE170M }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"smpte240m", "SMPTE 240 M",0, AV_OPT_
[FFmpeg-devel] [PATCH] libavcodec/proresdec2: Setup qmat_chroma according to RDD36
Signed-off-by: Harry Mallon --- libavcodec/proresdec2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index d5fbfc6711..4e1d0dd3f1 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -289,7 +289,7 @@ static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, } permute(ctx->qmat_chroma, ctx->prodsp.idct_permutation, ptr); } else { -memset(ctx->qmat_chroma, 4, 64); +memcpy(ctx->qmat_chroma, ctx->qmat_luma, 64); } return hdr_size; -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavcodec/options_table: Add missing colorspace options
* chroma-derived-nc / chroma-derived-c and ictcp Signed-off-by: Harry Mallon --- doc/codecs.texi| 6 ++ libavcodec/options_table.h | 33 ++--- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/doc/codecs.texi b/doc/codecs.texi index c092aadc0e..1da2590795 100644 --- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -1110,6 +1110,12 @@ BT.2020 NCL BT.2020 CL @item smpte2085 SMPTE 2085 +@item chroma-derived-nc +Chroma-derived NCL +@item chroma-derived-c +Chroma-derived CL +@item ictcp +ICtCp @end table @item color_range @var{integer} (@emph{decoding/encoding,video}) diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 1d0db1b5a4..66bda42663 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -381,21 +381,24 @@ static const AVOption avcodec_options[] = { {"bt2020_12bit", "BT.2020 - 12 bit", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_BT2020_12 },INT_MIN, INT_MAX, V|E|D, "color_trc_type"}, {"smpte428_1", "SMPTE 428-1", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_SMPTE428 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"}, {"colorspace", "color space", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64 = AVCOL_SPC_UNSPECIFIED }, 0, INT_MAX, V|E|D, "colorspace_type"}, -{"rgb", "RGB", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_RGB }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt709", "BT.709", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT709 }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"unknown", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"fcc", "FCC", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_FCC }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt470bg", "BT.470 BG", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT470BG }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"smpte170m", "SMPTE 170 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_SMPTE170M }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"smpte240m", "SMPTE 240 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_SMPTE240M }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"ycgco", "YCGCO", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_YCGCO }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt2020nc","BT.2020 NCL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_NCL }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt2020c", "BT.2020 CL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_CL }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"smpte2085", "SMPTE 2085", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_SMPTE2085 }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"unspecified", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"ycocg", "YCGCO", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_YCGCO }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt2020_ncl", "BT.2020 NCL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_NCL }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, -{"bt2020_cl", "BT.2020 CL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_CL }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"rgb", "RGB",0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_RGB },INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"bt709", "BT.709", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT709 }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"unknown", "Unspecified",0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_UNSPECIFIED },INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"fcc", "FCC",0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_FCC },INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"bt470bg", "BT.470 BG", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT470BG },INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"smpte170m", "SMPTE 170 M",0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_SMPTE170M }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"}, +{"smpte240m", "SMPTE 240 M",0, AV_OPT_TYPE_CONST,
Re: [FFmpeg-devel] [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor
> On 14 Aug 2020, at 22:33, Harry Mallon wrote: > > > > >> On 14 Aug 2020, at 11:53, Tomas Härdin wrote: >> >> tor 2020-08-13 klockan 22:21 +0200 skrev Marton Balint: >>> >>> On Thu, 13 Aug 2020, Tomas Härdin wrote: >>> >>>> tor 2020-08-13 klockan 11:04 +0100 skrev Harry Mallon: >>>>> Here is an updated patch (now hopefully going with correct email headers). >>>> >>>> It would be nice if in the future you either attach the patch or make >>>> the entire email the patch itself. I've had to trim these first couple >>>> of lines in each of the patches so far, after doing "git am" on the >>>> .mbox from saving your messages >>>> >>>>> From 5866d0dc5536a6ea3f6a899c3d09f19df083c16a Mon Sep 17 00:00:00 2001 >>>>> >>>>> From: Harry Mallon >>>>> Date: Wed, 12 Aug 2020 10:26:23 +0100 >>>>> Subject: [PATCH v4] avformat/mxfdec: Read video range from >>>>> PictureDescriptor >>>>> >>>>> * Capture black_ref, white_ref and color_range and recognise >>>>> full and narrow range. >>>>> >>>>> Signed-off-by: Harry Mallon >>>>> --- >>>>> libavformat/mxfdec.c | 29 + >>>>> tests/ref/fate/mxf-probe-dnxhd | 2 +- >>>>> tests/ref/fate/mxf-probe-dv25 | 2 +- >>>>> 3 files changed, 31 insertions(+), 2 deletions(-) >>>> >>>> Looks good to me. Running FATE atm, will push in a day if there are no >>>> objections. >>> >>> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4328/01_Bad_Frame_2.24.mxf >>> is not detected correctly for some reason. >>> >>> The MXF specs seems ambigous: >>> >>> Color Range is a Property, whose unsigned 32-bit integer value shall >>> specify the number of distinct values allowed for color difference >>> samples. >>> >>> So probably 2^depth color range should also be accepted as full range. >> >> This sounds correct. Do we have any sample using 2^depth-1? If not then >> we should just go with 2^depth until such a sample emerges. >> >> /Tomas > > I based it on what mxfenc.c already did, I can try to find some other samples. > > Harry > >> OK, I have checked back with the docs. * I agree that 2^depth is correct for mxf color_range * 2^depth-1 has been used in FFMPEG since n4.1 (avformat/mxfenc: add white/black ref /color range 6d0339096e10f6753049f2a5cbfd7ba69e5f8bcd) so maybe we should keep the off-by-one case, I don't mind either way. I was checking some other MXF files I have here and one is full-range RGB J2K, rather than YUV. There are separate range metadata in RGBAEssenceDescriptor compared to CDCIEssenceDescriptor. Is there a way to get the stream component depth from this area of code (as RGBA only has component_max and component_min, no component_depth like CDCI) or somehow to pass the min/max to the codec to parse? e.g in my file (RGB J2K with RGBAEssenceDesc) component_max is 4095 and component_min is 0, but I don't think the pixel format has been set to 12bit yet so it would seem premature to set the range to full. Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor
> On 14 Aug 2020, at 11:53, Tomas Härdin wrote: > > tor 2020-08-13 klockan 22:21 +0200 skrev Marton Balint: >> >> On Thu, 13 Aug 2020, Tomas Härdin wrote: >> >>> tor 2020-08-13 klockan 11:04 +0100 skrev Harry Mallon: >>>> Here is an updated patch (now hopefully going with correct email headers). >>> >>> It would be nice if in the future you either attach the patch or make >>> the entire email the patch itself. I've had to trim these first couple >>> of lines in each of the patches so far, after doing "git am" on the >>> .mbox from saving your messages >>> >>>> From 5866d0dc5536a6ea3f6a899c3d09f19df083c16a Mon Sep 17 00:00:00 2001 >>>> >>>> From: Harry Mallon >>>> Date: Wed, 12 Aug 2020 10:26:23 +0100 >>>> Subject: [PATCH v4] avformat/mxfdec: Read video range from >>>> PictureDescriptor >>>> >>>> * Capture black_ref, white_ref and color_range and recognise >>>> full and narrow range. >>>> >>>> Signed-off-by: Harry Mallon >>>> --- >>>> libavformat/mxfdec.c | 29 + >>>> tests/ref/fate/mxf-probe-dnxhd | 2 +- >>>> tests/ref/fate/mxf-probe-dv25 | 2 +- >>>> 3 files changed, 31 insertions(+), 2 deletions(-) >>> >>> Looks good to me. Running FATE atm, will push in a day if there are no >>> objections. >> >> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4328/01_Bad_Frame_2.24.mxf >> is not detected correctly for some reason. >> >> The MXF specs seems ambigous: >> >> Color Range is a Property, whose unsigned 32-bit integer value shall >> specify the number of distinct values allowed for color difference >> samples. >> >> So probably 2^depth color range should also be accepted as full range. > > This sounds correct. Do we have any sample using 2^depth-1? If not then > we should just go with 2^depth until such a sample emerges. > > /Tomas I based it on what mxfenc.c already did, I can try to find some other samples. Harry > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avcodec/dpx: Read alternative frame rate from television header
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index b1833ed9ef..7e3ac0af2e 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -216,10 +216,23 @@ static int decode_frame(AVCodecContext *avctx, else avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; +/* preferred frame rate from Motion-picture film header */ if (offset >= 1724 + 4) { buf = avpkt->data + 1724; i = read32(, endian); -if(i) { +if(i && i != 0x) { +AVRational q = av_d2q(av_int2float(i), 4096); +if (q.num > 0 && q.den > 0) +avctx->framerate = q; +} +} + +/* alternative frame rate from television header */ +if (offset >= 1940 + 4 && +!(avctx->framerate.num && avctx->framerate.den)) { +buf = avpkt->data + 1940; +i = read32(, endian); +if(i && i != 0x) { AVRational q = av_d2q(av_int2float(i), 4096); if (q.num > 0 && q.den > 0) avctx->framerate = q; -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/dpx: Read alternative frame rate from television header
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index b1833ed9ef..694deb27c5 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -216,10 +216,22 @@ static int decode_frame(AVCodecContext *avctx, else avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; +/* preferred frame rate from Motion-picture film header */ if (offset >= 1724 + 4) { buf = avpkt->data + 1724; i = read32(, endian); -if(i) { +if(i && i != 0x) { +AVRational q = av_d2q(av_int2float(i), 4096); +if (q.num > 0 && q.den > 0) +avctx->framerate = q; +} +} + +/* alternative frame rate from television header */ +if (!(avctx->framerate.num && avctx->framerate.den) && offset >= 1940 + 4) { +buf = avpkt->data + 1940; +i = read32(, endian); +if(i && i != 0x) { AVRational q = av_d2q(av_int2float(i), 4096); if (q.num > 0 && q.den > 0) avctx->framerate = q; -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/dpx: Read alternative frame rate from television header
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index b1833ed9ef..694deb27c5 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -216,10 +216,22 @@ static int decode_frame(AVCodecContext *avctx, else avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; +/* preferred frame rate from Motion-picture film header */ if (offset >= 1724 + 4) { buf = avpkt->data + 1724; i = read32(, endian); -if(i) { +if(i && i != 0x) { +AVRational q = av_d2q(av_int2float(i), 4096); +if (q.num > 0 && q.den > 0) +avctx->framerate = q; +} +} + +/* alternative frame rate from television header */ +if (!(avctx->framerate.num && avctx->framerate.den) && offset >= 1940 + 4) { +buf = avpkt->data + 1940; +i = read32(, endian); +if(i && i != 0x) { AVRational q = av_d2q(av_int2float(i), 4096); if (q.num > 0 && q.den > 0) avctx->framerate = q; -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor
Here is an updated patch (now hopefully going with correct email headers). From 5866d0dc5536a6ea3f6a899c3d09f19df083c16a Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Wed, 12 Aug 2020 10:26:23 +0100 Subject: [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor * Capture black_ref, white_ref and color_range and recognise full and narrow range. Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 29 + tests/ref/fate/mxf-probe-dnxhd | 2 +- tests/ref/fate/mxf-probe-dv25 | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4b56984b77..0831ad5768 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -199,6 +199,9 @@ typedef struct MXFDescriptor { int bits_per_sample; int64_t duration; /* ContainerDuration optional property */ unsigned int component_depth; +unsigned int black_ref_level; +unsigned int white_ref_level; +unsigned int color_range; unsigned int horiz_subsampling; unsigned int vert_subsampling; UID *sub_descriptors_refs; @@ -1222,6 +1225,15 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; +case 0x3304: +descriptor->black_ref_level = avio_rb32(pb); +break; +case 0x3305: +descriptor->white_ref_level = avio_rb32(pb); +break; +case 0x3306: +descriptor->color_range = avio_rb32(pb); +break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; @@ -2492,6 +2504,23 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) } if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) st->display_aspect_ratio = descriptor->aspect_ratio; +if (descriptor->component_depth && +descriptor->black_ref_level == 0 && +descriptor->white_ref_level == ((1<component_depth) - 1) && +descriptor->color_range == ((1<component_depth) - 1)) { +st->codecpar->color_range = AVCOL_RANGE_JPEG; +} +else if (descriptor->component_depth >= 8 && + descriptor->black_ref_level == (1 <<(descriptor->component_depth - 4)) && + descriptor->white_ref_level == (235<<(descriptor->component_depth - 8)) && + descriptor->color_range == ((14<<(descriptor->component_depth - 4)) + 1)) { +st->codecpar->color_range = AVCOL_RANGE_MPEG; +} +else if (descriptor->black_ref_level || descriptor->white_ref_level || descriptor->color_range) { +avpriv_request_sample(mxf->fc, "Unrecognized color range (range %d, b %d, w %d, depth %d)", + descriptor->color_range, descriptor->black_ref_level, + descriptor->white_ref_level, descriptor->component_depth); +} st->codecpar->color_primaries = mxf_get_codec_ul(ff_mxf_color_primaries_uls, >color_primaries_ul)->id; st->codecpar->color_trc = mxf_get_codec_ul(ff_mxf_color_trc_uls, >color_trc_ul)->id; st->codecpar->color_space = mxf_get_codec_ul(ff_mxf_color_space_uls, >color_space_ul)->id; diff --git a/tests/ref/fate/mxf-probe-dnxhd b/tests/ref/fate/mxf-probe-dnxhd index 012d3ea1d9..5a6221b1d5 100644 --- a/tests/ref/fate/mxf-probe-dnxhd +++ b/tests/ref/fate/mxf-probe-dnxhd @@ -124,7 +124,7 @@ sample_aspect_ratio=1:1 display_aspect_ratio=4:3 pix_fmt=yuv422p level=-99 -color_range=unknown +color_range=tv color_space=bt709 color_transfer=bt709 color_primaries=bt709 diff --git a/tests/ref/fate/mxf-probe-dv25 b/tests/ref/fate/mxf-probe-dv25 index 810f145f41..ffd26c4dfd 100644 --- a/tests/ref/fate/mxf-probe-dv25 +++ b/tests/ref/fate/mxf-probe-dv25 @@ -16,7 +16,7 @@ sample_aspect_ratio=16:15 display_aspect_ratio=4:3 pix_fmt=yuv420p level=-99 -color_range=unknown +color_range=tv color_space=unknown color_transfer=bt470m color_primaries=unknown -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3] avformat/mxfdec: Read video range from PictureDescriptor
> On 12 Aug 2020, at 14:59, Tomas Härdin wrote: > > ons 2020-08-12 klockan 13:43 +0100 skrev Harry Mallon: >> @@ -2492,6 +2504,18 @@ static int mxf_parse_structural_metadata(MXFContext >> *mxf) >> } >> if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) >> st->display_aspect_ratio = descriptor->aspect_ratio; >> +if (descriptor->component_depth && >> +descriptor->black_ref_level == 0 && >> +descriptor->white_ref_level == >> ((1<component_depth) - 1) && >> +descriptor->color_range == >> ((1<component_depth) - 1)) { >> +st->codecpar->color_range = AVCOL_RANGE_JPEG; >> +} >> +else if (descriptor->component_depth >= 8 && >> + descriptor->black_ref_level == (1 >> <<(descriptor->component_depth - 4)) && >> + descriptor->white_ref_level == >> (235<<(descriptor->component_depth - 8)) && >> + descriptor->color_range == >> ((14<<(descriptor->component_depth - 4)) + 1)) { >> +st->codecpar->color_range = AVCOL_RANGE_MPEG; >> +} > > Put a warning here in case levels are set but neither of these two ifs > are true, perhaps using avpriv_request_sample(). I can imagine there's > encoders that put off-by-one values in here. I'd like to see such files > first though before we widen these if clauses, so we can put the > samples in FATE. > > I'm testing the previous patch. Will push that one once FATE passes. > > /Tomas > Thanks Tomas, here is an updated V4 From 5866d0dc5536a6ea3f6a899c3d09f19df083c16a Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Wed, 12 Aug 2020 10:26:23 +0100 Subject: [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor * Capture black_ref, white_ref and color_range and recognise full and narrow range. Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 29 + tests/ref/fate/mxf-probe-dnxhd | 2 +- tests/ref/fate/mxf-probe-dv25 | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4b56984b77..0831ad5768 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -199,6 +199,9 @@ typedef struct MXFDescriptor { int bits_per_sample; int64_t duration; /* ContainerDuration optional property */ unsigned int component_depth; +unsigned int black_ref_level; +unsigned int white_ref_level; +unsigned int color_range; unsigned int horiz_subsampling; unsigned int vert_subsampling; UID *sub_descriptors_refs; @@ -1222,6 +1225,15 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; +case 0x3304: +descriptor->black_ref_level = avio_rb32(pb); +break; +case 0x3305: +descriptor->white_ref_level = avio_rb32(pb); +break; +case 0x3306: +descriptor->color_range = avio_rb32(pb); +break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; @@ -2492,6 +2504,23 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) } if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) st->display_aspect_ratio = descriptor->aspect_ratio; +if (descriptor->component_depth && +descriptor->black_ref_level == 0 && +descriptor->white_ref_level == ((1<component_depth) - 1) && +descriptor->color_range == ((1<component_depth) - 1)) { +st->codecpar->color_range = AVCOL_RANGE_JPEG; +} +else if (descriptor->component_depth >= 8 && + descriptor->black_ref_level == (1 <<(descriptor->component_depth - 4)) && + descriptor->white_ref_level == (235<<(descriptor->component_depth - 8)) && + descriptor->color_range == ((14<<(descriptor->component_depth - 4)) + 1)) { +st->codecpar->color_range = AVCOL_RANGE_MPEG; +} +else if (descriptor->black_ref_level || descriptor->white_ref_level || descriptor->color_range) { +avpriv_request_sample(mxf->fc, "Unrecognized color range (range %d, b %d, w %d, depth %d)", + des
[FFmpeg-devel] [PATCH v3] avformat/mxfdec: Read video range from PictureDescriptor
I'm very sorry for the noise, I just thought of a way that the last patch could be troublesome. Fixed here. From 31ce817887ec84907b3aadb5dc1657b01b8d0dbd Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Wed, 12 Aug 2020 10:26:23 +0100 Subject: [PATCH v3] avformat/mxfdec: Read video range from PictureDescriptor * Capture black_ref, white_ref and color_range and recognise full and narrow range. Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 24 tests/ref/fate/mxf-probe-dnxhd | 2 +- tests/ref/fate/mxf-probe-dv25 | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4b56984b77..172210acfe 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -199,6 +199,9 @@ typedef struct MXFDescriptor { int bits_per_sample; int64_t duration; /* ContainerDuration optional property */ unsigned int component_depth; +unsigned int black_ref_level; +unsigned int white_ref_level; +unsigned int color_range; unsigned int horiz_subsampling; unsigned int vert_subsampling; UID *sub_descriptors_refs; @@ -1222,6 +1225,15 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; +case 0x3304: +descriptor->black_ref_level = avio_rb32(pb); +break; +case 0x3305: +descriptor->white_ref_level = avio_rb32(pb); +break; +case 0x3306: +descriptor->color_range = avio_rb32(pb); +break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; @@ -2492,6 +2504,18 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) } if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) st->display_aspect_ratio = descriptor->aspect_ratio; +if (descriptor->component_depth && +descriptor->black_ref_level == 0 && +descriptor->white_ref_level == ((1<component_depth) - 1) && +descriptor->color_range == ((1<component_depth) - 1)) { +st->codecpar->color_range = AVCOL_RANGE_JPEG; +} +else if (descriptor->component_depth >= 8 && + descriptor->black_ref_level == (1 <<(descriptor->component_depth - 4)) && + descriptor->white_ref_level == (235<<(descriptor->component_depth - 8)) && + descriptor->color_range == ((14<<(descriptor->component_depth - 4)) + 1)) { +st->codecpar->color_range = AVCOL_RANGE_MPEG; +} st->codecpar->color_primaries = mxf_get_codec_ul(ff_mxf_color_primaries_uls, >color_primaries_ul)->id; st->codecpar->color_trc = mxf_get_codec_ul(ff_mxf_color_trc_uls, >color_trc_ul)->id; st->codecpar->color_space = mxf_get_codec_ul(ff_mxf_color_space_uls, >color_space_ul)->id; diff --git a/tests/ref/fate/mxf-probe-dnxhd b/tests/ref/fate/mxf-probe-dnxhd index 012d3ea1d9..5a6221b1d5 100644 --- a/tests/ref/fate/mxf-probe-dnxhd +++ b/tests/ref/fate/mxf-probe-dnxhd @@ -124,7 +124,7 @@ sample_aspect_ratio=1:1 display_aspect_ratio=4:3 pix_fmt=yuv422p level=-99 -color_range=unknown +color_range=tv color_space=bt709 color_transfer=bt709 color_primaries=bt709 diff --git a/tests/ref/fate/mxf-probe-dv25 b/tests/ref/fate/mxf-probe-dv25 index 810f145f41..ffd26c4dfd 100644 --- a/tests/ref/fate/mxf-probe-dv25 +++ b/tests/ref/fate/mxf-probe-dv25 @@ -16,7 +16,7 @@ sample_aspect_ratio=16:15 display_aspect_ratio=4:3 pix_fmt=yuv420p level=-99 -color_range=unknown +color_range=tv color_space=unknown color_transfer=bt470m color_primaries=unknown -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avformat/mxfdec: Read video range from PictureDescriptor
Rebased the patch on master (it didn't build before) and fixed FATE. From ac8d7884b036b504d07f38815de1c163c5e1691e Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Wed, 12 Aug 2020 10:26:23 +0100 Subject: [PATCH v2] avformat/mxfdec: Read video range from PictureDescriptor * Capture black_ref, white_ref and color_range and recognise full and narrow range. Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 22 ++ tests/ref/fate/mxf-probe-dnxhd | 2 +- tests/ref/fate/mxf-probe-dv25 | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4b56984b77..7e77fbca10 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -199,6 +199,9 @@ typedef struct MXFDescriptor { int bits_per_sample; int64_t duration; /* ContainerDuration optional property */ unsigned int component_depth; +unsigned int black_ref_level; +unsigned int white_ref_level; +unsigned int color_range; unsigned int horiz_subsampling; unsigned int vert_subsampling; UID *sub_descriptors_refs; @@ -1222,6 +1225,15 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; +case 0x3304: +descriptor->black_ref_level = avio_rb32(pb); +break; +case 0x3305: +descriptor->white_ref_level = avio_rb32(pb); +break; +case 0x3306: +descriptor->color_range = avio_rb32(pb); +break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; @@ -2492,6 +2504,16 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) } if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) st->display_aspect_ratio = descriptor->aspect_ratio; +if (descriptor->black_ref_level == 0 && +descriptor->white_ref_level == ((1<component_depth) - 1) && +descriptor->color_range == ((1<component_depth) - 1)) { +st->codecpar->color_range = AVCOL_RANGE_JPEG; +} +else if (descriptor->black_ref_level == (1 <<(descriptor->component_depth - 4)) && + descriptor->white_ref_level == (235<<(descriptor->component_depth - 8)) && + descriptor->color_range == ((14<<(descriptor->component_depth - 4)) + 1)) { +st->codecpar->color_range = AVCOL_RANGE_MPEG; +} st->codecpar->color_primaries = mxf_get_codec_ul(ff_mxf_color_primaries_uls, >color_primaries_ul)->id; st->codecpar->color_trc = mxf_get_codec_ul(ff_mxf_color_trc_uls, >color_trc_ul)->id; st->codecpar->color_space = mxf_get_codec_ul(ff_mxf_color_space_uls, >color_space_ul)->id; diff --git a/tests/ref/fate/mxf-probe-dnxhd b/tests/ref/fate/mxf-probe-dnxhd index 012d3ea1d9..5a6221b1d5 100644 --- a/tests/ref/fate/mxf-probe-dnxhd +++ b/tests/ref/fate/mxf-probe-dnxhd @@ -124,7 +124,7 @@ sample_aspect_ratio=1:1 display_aspect_ratio=4:3 pix_fmt=yuv422p level=-99 -color_range=unknown +color_range=tv color_space=bt709 color_transfer=bt709 color_primaries=bt709 diff --git a/tests/ref/fate/mxf-probe-dv25 b/tests/ref/fate/mxf-probe-dv25 index 810f145f41..ffd26c4dfd 100644 --- a/tests/ref/fate/mxf-probe-dv25 +++ b/tests/ref/fate/mxf-probe-dv25 @@ -16,7 +16,7 @@ sample_aspect_ratio=16:15 display_aspect_ratio=4:3 pix_fmt=yuv420p level=-99 -color_range=unknown +color_range=tv color_space=unknown color_transfer=bt470m color_primaries=unknown -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/mxfdec: Read video range from PictureDescriptor
Thanks to Tomas for reviewing these MXF patches. Here is another. FFMPEG already writes out the three range tags. This just reads them in. Best, Harry From c49f77d1e887d8c84752df11213dcf5afa8f761e Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Wed, 12 Aug 2020 10:26:23 +0100 Subject: [PATCH] avformat/mxfdec: Read video range from PictureDescriptor * Capture black_ref, white_ref and color_range and recognise full and narrow range. Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index fa9dcab658..9d2563239e 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -201,6 +201,9 @@ typedef struct MXFDescriptor { int bits_per_sample; int64_t duration; /* ContainerDuration optional property */ unsigned int component_depth; +unsigned int black_ref_level; +unsigned int white_ref_level; +unsigned int color_range; unsigned int horiz_subsampling; unsigned int vert_subsampling; UID *sub_descriptors_refs; @@ -1230,6 +1233,15 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; +case 0x3304: +descriptor->black_ref_level = avio_rb32(pb); +break; +case 0x3305: +descriptor->white_ref_level = avio_rb32(pb); +break; +case 0x3306: +descriptor->color_range = avio_rb32(pb); +break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; @@ -2557,6 +2569,16 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) st->codecpar->color_primaries = mxf_get_codec_ul(ff_mxf_color_primaries_uls, >color_primaries_ul)->id; st->codecpar->color_trc = mxf_get_codec_ul(ff_mxf_color_trc_uls, >color_trc_ul)->id; st->codecpar->color_space = mxf_get_codec_ul(ff_mxf_color_space_uls, >color_space_ul)->id; +if (descriptor->black_ref_level == 0 && +descriptor->white_ref_level == ((1<component_depth) - 1) && +descriptor->color_range == ((1<component_depth) - 1)) { +st->codecpar->color_range = AVCOL_RANGE_JPEG; +} +else if (descriptor->black_ref_level == (1 <<(descriptor->component_depth - 4)) && + descriptor->white_ref_level == (235<<(descriptor->component_depth - 8)) && + descriptor->color_range == ((14<<(descriptor->component_depth - 4)) + 1)) { +st->codecpar->color_range = AVCOL_RANGE_MPEG; +} if (descriptor->mastering) { ret = av_stream_add_side_data(st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, (uint8_t *)descriptor->mastering, -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/mxfenc: Write color metadata to MXF
I attach a patch to apply the colour metadata that was read in my previous commit during mxf encoding. ffmpeg previously wrote the transfer characteristic only, and not for all supported transfer curves. Now it will do transfer characteristic, colour primaries and colour space. Best, Harry From de460620b73379d5a869baa98e49a5d0f67d9ebb Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Tue, 28 Jul 2020 10:33:19 +0100 Subject: [PATCH] avformat/mxfenc: Write color metadata to MXF Writes color_primaries, color_trc and color_space to mxf headers. ULs are from https://registry.smpte-ra.org/ site. Signed-off-by: Harry Mallon --- libavformat/mxfenc.c | 58 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 5a3a609bf6..a38fa6b983 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -553,11 +553,10 @@ static void mxf_write_metadata_key(AVIOContext *pb, unsigned int value) avio_wb24(pb, value); } -static const MXFCodecUL *mxf_get_data_definition_ul(int type) +static const MXFCodecUL *mxf_get_codec_ul_by_id(const MXFCodecUL *uls, int id) { -const MXFCodecUL *uls = ff_mxf_data_definition_uls; while (uls->uid[0]) { -if (type == uls->id) +if (id == uls->id) break; uls++; } @@ -847,7 +846,7 @@ static void mxf_write_common_fields(AVFormatContext *s, AVStream *st) if (st == mxf->timecode_track) avio_write(pb, smpte_12m_timecode_track_data_ul, 16); else { -const MXFCodecUL *data_def_ul = mxf_get_data_definition_ul(st->codecpar->codec_type); +const MXFCodecUL *data_def_ul = mxf_get_codec_ul_by_id(ff_mxf_data_definition_uls, st->codecpar->codec_type); avio_write(pb, data_def_ul->uid, 16); } @@ -1049,34 +1048,6 @@ static const UID mxf_generic_sound_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0 static const UID mxf_avc_subdescriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6E,0x00 }; -static int get_trc(UID ul, enum AVColorTransferCharacteristic trc) -{ -switch (trc){ -case AVCOL_TRC_GAMMA28 : -case AVCOL_TRC_GAMMA22 : -memcpy(ul, ((UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00}), 16); -return 0; -case AVCOL_TRC_BT709 : -case AVCOL_TRC_SMPTE170M : -memcpy(ul, ((UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x02,0x00,0x00}), 16); -return 0; -case AVCOL_TRC_SMPTE240M : -memcpy(ul, ((UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x03,0x00,0x00}), 16); -return 0; -case AVCOL_TRC_BT1361_ECG: -memcpy(ul, ((UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x05,0x00,0x00}), 16); -return 0; -case AVCOL_TRC_LINEAR: -memcpy(ul, ((UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x06,0x00,0x00}), 16); -return 0; -case AVCOL_TRC_SMPTE428 : -memcpy(ul, ((UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x08,0x04,0x01,0x01,0x01,0x01,0x07,0x00,0x00}), 16); -return 0; -default: -return -1; -} -} - static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key) { MXFStreamContext *sc = st->priv_data; @@ -1085,10 +1056,14 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID int stored_height = (st->codecpar->height+15)/16*16; int display_height; int f1, f2; -UID transfer_ul = {0}; +const MXFCodecUL *color_primaries_ul; +const MXFCodecUL *color_trc_ul; +const MXFCodecUL *color_space_ul; int64_t pos = mxf_write_generic_desc(s, st, key); -get_trc(transfer_ul, st->codecpar->color_trc); +color_primaries_ul = mxf_get_codec_ul_by_id(ff_mxf_color_primaries_uls, st->codecpar->color_primaries); +color_trc_ul = mxf_get_codec_ul_by_id(ff_mxf_color_trc_uls, st->codecpar->color_trc); +color_space_ul = mxf_get_codec_ul_by_id(ff_mxf_color_space_uls, st->codecpar->color_space); if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO) { if (st->codecpar->height == 1080) @@ -1235,10 +1210,19 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID avio_wb32(pb, sc->aspect_ratio.num); avio_wb32(pb, sc->aspect_ratio.den); -//Transfer characteristic -if (transfer_ul[0]) { +if (color_primaries_ul->uid[0]) { +mxf_write_local_tag(pb, 16, 0x3219); +avio_write(pb, color_primaries_ul->uid, 16); +}; + +if (color_trc_ul->uid[0]) { mxf_write_local_tag(pb, 16, 0x3210); -avio_write(pb, transfer_ul, 16); +avio_write(pb, color_trc_ul->uid, 16); +}; + +if (color_space_ul->u
[FFmpeg-devel] [PATCH v2] avformat/mxfdec: Read color metadata from MXF
Hi, V2 fixes all the fate tests (I didn't know to download the test footage before. Doh). The following patch adds reading colour metadata (transfer, primaries and colour space) from standard MXF files. I wrote it without seeing the other patch but it turned out very similar to this one that was never merged. https://patchwork.ffmpeg.org/project/ffmpeg/patch/1474694344-31167-1-git-send-email-ste...@strobe.cc/ . Thanks. Harry From d16966e6b0a6367a5e5445987c0449fb1150785a Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Mon, 27 Jul 2020 15:52:17 +0100 Subject: [PATCH] avformat/mxfdec: Read color metadata from MXF Reads color_primaries, color_trc and color_space from mxf headers. ULs are from https://registry.smpte-ra.org/ site. Signed-off-by: Harry Mallon --- libavformat/mxf.c | 49 + libavformat/mxf.h | 3 ++ libavformat/mxfdec.c| 15 tests/ref/fate/mxf-d10-user-comments| 2 +- tests/ref/fate/mxf-opatom-user-comments | 2 +- tests/ref/fate/mxf-probe-d10| 2 +- tests/ref/fate/mxf-probe-dnxhd | 4 +- tests/ref/fate/mxf-probe-dv25 | 2 +- tests/ref/fate/mxf-reel_name| 2 +- tests/ref/fate/mxf-user-comments| 2 +- 10 files changed, 75 insertions(+), 8 deletions(-) diff --git a/libavformat/mxf.c b/libavformat/mxf.c index 7d154ca9d3..e51fc48a84 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -86,6 +86,55 @@ const MXFCodecUL ff_mxf_codec_tag_uls[] = { { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, 0 }, }; +const MXFCodecUL ff_mxf_color_primaries_uls[] = { +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x01,0x00,0x00 }, 14, AVCOL_PRI_SMPTE170M }, /* SMPTE 170M */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x02,0x00,0x00 }, 14, AVCOL_PRI_BT470BG }, /* ITU-R BT.470 PAL */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x03,0x00,0x00 }, 14, AVCOL_PRI_BT709 }, /* ITU-R BT.709 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x04,0x00,0x00 }, 14, AVCOL_PRI_BT2020 }, /* ITU-R BT.2020 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x05,0x00,0x00 }, 14, AVCOL_PRI_SMPTE428 }, /* SMPTE-DC28 DCDM */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x06,0x00,0x00 }, 14, AVCOL_PRI_SMPTE432 }, /* P3D65 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x08,0x00,0x00 }, 14, AVCOL_PRI_SMPTE428 }, /* Cinema Mezzanine */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x0a,0x00,0x00 }, 14, AVCOL_PRI_SMPTE431 }, /* P3DCI */ +/* alternate mappings for encoding */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x01,0x00,0x00 }, 14, AVCOL_PRI_SMPTE240M }, /* = AVCOL_PRI_SMPTE170M */ + +{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AVCOL_PRI_UNSPECIFIED }, +}; + +const MXFCodecUL ff_mxf_color_trc_uls[] = { +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00 }, 14, AVCOL_TRC_GAMMA22 }, /* ITU-R BT.470 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x02,0x00,0x00 }, 14, AVCOL_TRC_BT709 }, /* ITU-R BT.709 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x03,0x00,0x00 }, 14, AVCOL_TRC_SMPTE240M }, /* SMPTE 240M */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x04,0x00,0x00 }, 14, AVCOL_TRC_BT709 }, /* SMPTE 274/296M (must appear after ITU-R BT.709) */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x05,0x00,0x00 }, 14, AVCOL_TRC_BT1361_ECG }, /* ITU-R BT.1361 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x06,0x00,0x00 }, 14, AVCOL_TRC_LINEAR }, /* Linear */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x08,0x04,0x01,0x01,0x01,0x01,0x07,0x00,0x00 }, 14, AVCOL_TRC_SMPTE428 }, /* SMPTE-DC28 DCDM */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x01,0x08,0x00,0x00 }, 14, AVCOL_TRC_IEC61966_2_4 }, /* IEC 61966-2-4 xvYCC */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0E,0x04,0x01,0x01,0x01,0x01,0x09,0x00,0x00 }, 14, AVCOL_TRC_BT2020_10 }, /* ITU-R BT.2020 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x01,0x0A,0x00,0x00 }, 14, AVCOL_TRC_SMPTE2084 }, /* SMPTE ST 2084 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x01,0x0B,0x00,0x00 }, 14, AVCOL_TRC_ARIB_STD_B67 }, /* Hybrid Log-Gamma OETF */ +/* alternate mappings for encoding */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00 }, 14, AVCOL_TRC_GAMMA28 }, /* = AVCOL_TRC_GAMMA22 */ +{ { 0x06,0x0E
[FFmpeg-devel] avformat/mxfdec: Read color metadata from MXF
Hello, Sorry I wasn't able to send this with git-send-email, I'm trying again with patch inline. The following patch adds reading colour metadata (transfer, primaries and colour space) from standard MXF files. I wrote it without seeing the other patch but it turned out very similar to this one that was never merged https://patchwork.ffmpeg.org/project/ffmpeg/patch/1474694344-31167-1-git-send-email-ste...@strobe.cc/ . Thanks. Harry From 3ff4c4187654e92a84ce165365e339995512c5be Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Mon, 27 Jul 2020 15:52:17 +0100 Subject: [PATCH 1/2] avformat/mxfdec: Read color metadata from MXF Reads color_primaries, color_trc and color_space from mxf headers. ULs are from https://registry.smpte-ra.org/ site. Signed-off-by: Harry Mallon --- libavformat/mxf.c| 49 libavformat/mxf.h| 3 +++ libavformat/mxfdec.c | 15 ++ 3 files changed, 67 insertions(+) diff --git a/libavformat/mxf.c b/libavformat/mxf.c index 7d154ca9d3..e51fc48a84 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -86,6 +86,55 @@ const MXFCodecUL ff_mxf_codec_tag_uls[] = { { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, 0 }, }; +const MXFCodecUL ff_mxf_color_primaries_uls[] = { +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x01,0x00,0x00 }, 14, AVCOL_PRI_SMPTE170M }, /* SMPTE 170M */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x02,0x00,0x00 }, 14, AVCOL_PRI_BT470BG }, /* ITU-R BT.470 PAL */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x03,0x00,0x00 }, 14, AVCOL_PRI_BT709 }, /* ITU-R BT.709 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x04,0x00,0x00 }, 14, AVCOL_PRI_BT2020 }, /* ITU-R BT.2020 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x05,0x00,0x00 }, 14, AVCOL_PRI_SMPTE428 }, /* SMPTE-DC28 DCDM */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x06,0x00,0x00 }, 14, AVCOL_PRI_SMPTE432 }, /* P3D65 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x08,0x00,0x00 }, 14, AVCOL_PRI_SMPTE428 }, /* Cinema Mezzanine */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x0a,0x00,0x00 }, 14, AVCOL_PRI_SMPTE431 }, /* P3DCI */ +/* alternate mappings for encoding */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x01,0x00,0x00 }, 14, AVCOL_PRI_SMPTE240M }, /* = AVCOL_PRI_SMPTE170M */ + +{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AVCOL_PRI_UNSPECIFIED }, +}; + +const MXFCodecUL ff_mxf_color_trc_uls[] = { +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00 }, 14, AVCOL_TRC_GAMMA22 }, /* ITU-R BT.470 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x02,0x00,0x00 }, 14, AVCOL_TRC_BT709 }, /* ITU-R BT.709 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x03,0x00,0x00 }, 14, AVCOL_TRC_SMPTE240M }, /* SMPTE 240M */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x04,0x00,0x00 }, 14, AVCOL_TRC_BT709 }, /* SMPTE 274/296M (must appear after ITU-R BT.709) */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x05,0x00,0x00 }, 14, AVCOL_TRC_BT1361_ECG }, /* ITU-R BT.1361 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x06,0x00,0x00 }, 14, AVCOL_TRC_LINEAR }, /* Linear */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x08,0x04,0x01,0x01,0x01,0x01,0x07,0x00,0x00 }, 14, AVCOL_TRC_SMPTE428 }, /* SMPTE-DC28 DCDM */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x01,0x08,0x00,0x00 }, 14, AVCOL_TRC_IEC61966_2_4 }, /* IEC 61966-2-4 xvYCC */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0E,0x04,0x01,0x01,0x01,0x01,0x09,0x00,0x00 }, 14, AVCOL_TRC_BT2020_10 }, /* ITU-R BT.2020 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x01,0x0A,0x00,0x00 }, 14, AVCOL_TRC_SMPTE2084 }, /* SMPTE ST 2084 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x01,0x0B,0x00,0x00 }, 14, AVCOL_TRC_ARIB_STD_B67 }, /* Hybrid Log-Gamma OETF */ +/* alternate mappings for encoding */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00 }, 14, AVCOL_TRC_GAMMA28 }, /* = AVCOL_TRC_GAMMA22 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x02,0x00,0x00 }, 14, AVCOL_TRC_SMPTE170M }, /* = AVCOL_TRC_BT709 */ +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0E,0x04,0x01,0x01,0x01,0x01,0x09,0x00,0x00 }, 14, AVCOL_TRC_BT2020_12 }, /* = AVCOL_TRC_BT2020_10 */ + +{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0
[FFmpeg-devel] avformat/mxfdec: Read color metadata from MXF
Hello, Sorry I wasn't able to send this with git-send-email. The following patch adds reading colour metadata (transfer, primaries and colour space) from standard MXF files. I wrote it without seeing the other patch but it turned out very similar to this one that was never merged https://patchwork.ffmpeg.org/project/ffmpeg/patch/1474694344-31167-1-git-send-email-ste...@strobe.cc/ Thanks. Harry 0001-avformat-mxfdec-Read-color-metadata-from-MXF.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".