diff mbox series

[FFmpeg-devel,9/9] avformat/avisynth: add read_frameprop_chroma_location option

Message ID 20220829000244.71123-10-qyot27@gmail.com
State New
Headers show
Series avisynth: add user options | expand

Commit Message

Stephen Hutchinson Aug. 29, 2022, 12:02 a.m. UTC
Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
---
 libavformat/avisynth.c | 50 +++++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 99173a8d51..4e7395c22b 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -109,6 +109,7 @@  typedef struct AviSynthContext {
     int frameprop_primaries;
     int frameprop_transfer;
     int frameprop_matrix;
+    int frameprop_chroma_location;
     int frameprop_sar;
 
     /* Linked list pointers. */
@@ -726,30 +727,32 @@  static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
             }
 
             /* Chroma Location */
-            if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ChromaLocation") == AVS_PROPTYPE_UNSET) {
-                st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
-            } else {
-                switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ChromaLocation", 0, &error)) {
-                case 0:
-                    st->codecpar->chroma_location = AVCHROMA_LOC_LEFT;
-                    break;
-                case 1:
-                    st->codecpar->chroma_location = AVCHROMA_LOC_CENTER;
-                    break;
-                case 2:
-                    st->codecpar->chroma_location = AVCHROMA_LOC_TOPLEFT;
-                    break;
-                case 3:
-                    st->codecpar->chroma_location = AVCHROMA_LOC_TOP;
-                    break;
-                case 4:
-                    st->codecpar->chroma_location = AVCHROMA_LOC_BOTTOMLEFT;
-                    break;
-                case 5:
-                    st->codecpar->chroma_location = AVCHROMA_LOC_BOTTOM;
-                    break;
-                default:
+            if(avs->frameprop_chroma_location) {
+                if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ChromaLocation") == AVS_PROPTYPE_UNSET) {
                     st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
+                } else {
+                    switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ChromaLocation", 0, &error)) {
+                    case 0:
+                        st->codecpar->chroma_location = AVCHROMA_LOC_LEFT;
+                        break;
+                    case 1:
+                        st->codecpar->chroma_location = AVCHROMA_LOC_CENTER;
+                        break;
+                    case 2:
+                        st->codecpar->chroma_location = AVCHROMA_LOC_TOPLEFT;
+                        break;
+                    case 3:
+                        st->codecpar->chroma_location = AVCHROMA_LOC_TOP;
+                        break;
+                    case 4:
+                        st->codecpar->chroma_location = AVCHROMA_LOC_BOTTOMLEFT;
+                        break;
+                    case 5:
+                        st->codecpar->chroma_location = AVCHROMA_LOC_BOTTOM;
+                        break;
+                    default:
+                        st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
+                    }
                 }
             }
 
@@ -1172,6 +1175,7 @@  static const AVOption avisynth_options[] = {
     { "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_chroma_location", "Read chroma location from script's frame properties (AviSynth+ v3.7.1+).", OFFSET(frameprop_chroma_location), 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 },
 };