diff mbox series

[FFmpeg-devel,1/3,v2] avformat/avisynth: read _SARNum/_SARDen from frame properties

Message ID 20220831002340.31886-2-qyot27@gmail.com
State New
Headers show
Series avisynth: add user-selectable flags | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Stephen Hutchinson Aug. 31, 2022, 12:23 a.m. UTC
Initialized to 1:1, but if the script sets these properties, it
will be set to those instead (0:0 disables it, apparently).

Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
---
 libavformat/avisynth.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Stephen Hutchinson Sept. 4, 2022, 7:08 p.m. UTC | #1
On 8/30/22 8:23 PM, Stephen Hutchinson wrote:
> Initialized to 1:1, but if the script sets these properties, it
> will be set to those instead (0:0 disables it, apparently).
> 
> Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
> ---
>   libavformat/avisynth.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
> index 3d9fa2be50..d978e6ec40 100644
> --- a/libavformat/avisynth.c
> +++ b/libavformat/avisynth.c
> @@ -251,6 +251,8 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
>       AVS_VideoFrame *frame;
>       int error;
>       int planar = 0; // 0: packed, 1: YUV, 2: Y8, 3: Planar RGB, 4: YUVA, 5: Planar RGBA
> +    int sar_num = 1;
> +    int sar_den = 1;
>   
>       st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>       st->codecpar->codec_id   = AV_CODEC_ID_RAWVIDEO;
> @@ -728,6 +730,12 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
>                   st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
>               }
>           }
> +
> +        /* Sample aspect ratio */
> +        sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error);
> +        sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error);
> +        st->sample_aspect_ratio = (AVRational){ sar_num, sar_den };
> +
>           avs_library.avs_release_video_frame(frame);
>       } else {
>           st->codecpar->field_order = AV_FIELD_UNKNOWN;

Pushed.
diff mbox series

Patch

diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 3d9fa2be50..d978e6ec40 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -251,6 +251,8 @@  static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
     AVS_VideoFrame *frame;
     int error;
     int planar = 0; // 0: packed, 1: YUV, 2: Y8, 3: Planar RGB, 4: YUVA, 5: Planar RGBA
+    int sar_num = 1;
+    int sar_den = 1;
 
     st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codecpar->codec_id   = AV_CODEC_ID_RAWVIDEO;
@@ -728,6 +730,12 @@  static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
                 st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
             }
         }
+
+        /* Sample aspect ratio */
+        sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error);
+        sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error);
+        st->sample_aspect_ratio = (AVRational){ sar_num, sar_den };
+
         avs_library.avs_release_video_frame(frame);
     } else {
         st->codecpar->field_order = AV_FIELD_UNKNOWN;