diff mbox series

[FFmpeg-devel,05/25] fftools/ffmpeg: move a miplaced assignment

Message ID 20230413141223.17245-5-anton@khirnov.net
State Accepted
Commit 4fc513b5e379dc4d45c8aa23af7d580708bbe4d9
Headers show
Series [FFmpeg-devel,01/25] fftools/ffmpeg_mux_init: move new_output_stream() lower in the file | 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

Anton Khirnov April 13, 2023, 2:12 p.m. UTC
Changing AVCodecContext.sample_aspect_ratio after the encoder was opened
is by itself questionable, but if anywhere it belongs in encoding rather
than filtering code.
---
 fftools/ffmpeg.c     | 3 ---
 fftools/ffmpeg_enc.c | 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index c1070485be..700fa5fbe1 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -711,9 +711,6 @@  static int reap_filters(int flush)
 
             switch (av_buffersink_get_type(filter)) {
             case AVMEDIA_TYPE_VIDEO:
-                if (!ost->frame_aspect_ratio.num)
-                    enc->sample_aspect_ratio = filtered_frame->sample_aspect_ratio;
-
                 enc_frame(ost, filtered_frame);
                 break;
             case AVMEDIA_TYPE_AUDIO:
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index a0779c45ae..0236e50e38 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -653,6 +653,9 @@  static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
                    av_ts2str(frame->pts), av_ts2timestr(frame->pts, &enc->time_base),
                    enc->time_base.num, enc->time_base.den);
         }
+
+        if (frame->sample_aspect_ratio.num && !ost->frame_aspect_ratio.num)
+            enc->sample_aspect_ratio = frame->sample_aspect_ratio;
     }
 
     update_benchmark(NULL);