[FFmpeg-devel] [PATCH 8/9] avformat/avisynth: add read_frameprop_matrix option
Stephen Hutchinson
qyot27 at gmail.com
Mon Aug 29 03:02:43 EEST 2022
Signed-off-by: Stephen Hutchinson <qyot27 at gmail.com>
---
libavformat/avisynth.c | 98 ++++++++++++++++++++++--------------------
1 file changed, 51 insertions(+), 47 deletions(-)
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index ff4435758e..99173a8d51 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -108,6 +108,7 @@ typedef struct AviSynthContext {
int frameprop_range;
int frameprop_primaries;
int frameprop_transfer;
+ int frameprop_matrix;
int frameprop_sar;
/* Linked list pointers. */
@@ -671,54 +672,56 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
}
/* Matrix coefficients */
- if(avs_library.avs_prop_get_type(avs->env, avsmap, "_Matrix") == AVS_PROPTYPE_UNSET) {
- st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED;
- } else {
- switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Matrix", 0, &error)) {
- case 0:
- st->codecpar->color_space = AVCOL_SPC_RGB;
- break;
- case 1:
- st->codecpar->color_space = AVCOL_SPC_BT709;
- break;
- case 2:
- st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED;
- break;
- case 4:
- st->codecpar->color_space = AVCOL_SPC_FCC;
- break;
- case 5:
- st->codecpar->color_space = AVCOL_SPC_BT470BG;
- break;
- case 6:
- st->codecpar->color_space = AVCOL_SPC_SMPTE170M;
- break;
- case 7:
- st->codecpar->color_space = AVCOL_SPC_SMPTE240M;
- break;
- case 8:
- st->codecpar->color_space = AVCOL_SPC_YCGCO;
- break;
- case 9:
- st->codecpar->color_space = AVCOL_SPC_BT2020_NCL;
- break;
- case 10:
- st->codecpar->color_space = AVCOL_SPC_BT2020_CL;
- break;
- case 11:
- st->codecpar->color_space = AVCOL_SPC_SMPTE2085;
- break;
- case 12:
- st->codecpar->color_space = AVCOL_SPC_CHROMA_DERIVED_NCL;
- break;
- case 13:
- st->codecpar->color_space = AVCOL_SPC_CHROMA_DERIVED_CL;
- break;
- case 14:
- st->codecpar->color_space = AVCOL_SPC_ICTCP;
- break;
- default:
+ if(avs->frameprop_matrix) {
+ if(avs_library.avs_prop_get_type(avs->env, avsmap, "_Matrix") == AVS_PROPTYPE_UNSET) {
st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED;
+ } else {
+ switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Matrix", 0, &error)) {
+ case 0:
+ st->codecpar->color_space = AVCOL_SPC_RGB;
+ break;
+ case 1:
+ st->codecpar->color_space = AVCOL_SPC_BT709;
+ break;
+ case 2:
+ st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED;
+ break;
+ case 4:
+ st->codecpar->color_space = AVCOL_SPC_FCC;
+ break;
+ case 5:
+ st->codecpar->color_space = AVCOL_SPC_BT470BG;
+ break;
+ case 6:
+ st->codecpar->color_space = AVCOL_SPC_SMPTE170M;
+ break;
+ case 7:
+ st->codecpar->color_space = AVCOL_SPC_SMPTE240M;
+ break;
+ case 8:
+ st->codecpar->color_space = AVCOL_SPC_YCGCO;
+ break;
+ case 9:
+ st->codecpar->color_space = AVCOL_SPC_BT2020_NCL;
+ break;
+ case 10:
+ st->codecpar->color_space = AVCOL_SPC_BT2020_CL;
+ break;
+ case 11:
+ st->codecpar->color_space = AVCOL_SPC_SMPTE2085;
+ break;
+ case 12:
+ st->codecpar->color_space = AVCOL_SPC_CHROMA_DERIVED_NCL;
+ break;
+ case 13:
+ st->codecpar->color_space = AVCOL_SPC_CHROMA_DERIVED_CL;
+ break;
+ case 14:
+ st->codecpar->color_space = AVCOL_SPC_ICTCP;
+ break;
+ default:
+ st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED;
+ }
}
}
@@ -1168,6 +1171,7 @@ static const AVOption avisynth_options[] = {
{ "read_frameprop_range", "Read color range from script's frame properties (AviSynth+ v3.7.1+).", OFFSET(frameprop_range), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
{ "read_frameprop_primaries", "Read color primaries from script's frame properties (AviSynth+ v3.7.1+).", OFFSET(frameprop_primaries), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
{ "read_frameprop_transfer", "Read color transfer characteristics from script's frame properties (AviSynth+ v3.7.1+).", OFFSET(frameprop_transfer), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
+ { "read_frameprop_matrix", "Read matrix coefficients from script's frame properties (AviSynth+ v3.7.1+).", OFFSET(frameprop_matrix), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
{ "read_frameprop_sar", "Read SAR from script's frame properties (AviSynth+ v3.7.1+).", OFFSET(frameprop_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
{ NULL },
};
--
2.34.1
More information about the ffmpeg-devel
mailing list