diff mbox series

[FFmpeg-devel,09/49] fftools/ffmpeg: store output format separately from the muxer context

Message ID 20220404113037.13070-10-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/49] fftools/ffmpeg: drop an obsolete hack | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov April 4, 2022, 11:29 a.m. UTC
Allows accessing it without going through the muxer context. This will
be useful in the following commits, where the muxer context will be
hidden.
---
 fftools/ffmpeg.c     | 18 ++++++++++--------
 fftools/ffmpeg.h     |  2 ++
 fftools/ffmpeg_opt.c |  1 +
 3 files changed, 13 insertions(+), 8 deletions(-)

Comments

James Almer April 6, 2022, noon UTC | #1
On 4/4/2022 8:29 AM, Anton Khirnov wrote:
> Allows accessing it without going through the muxer context. This will
> be useful in the following commits, where the muxer context will be
> hidden.
> ---
>   fftools/ffmpeg.c     | 18 ++++++++++--------
>   fftools/ffmpeg.h     |  2 ++
>   fftools/ffmpeg_opt.c |  1 +
>   3 files changed, 13 insertions(+), 8 deletions(-)

Patches 4 to 9 look ok.
Anton Khirnov April 13, 2022, 10:18 a.m. UTC | #2
Quoting James Almer (2022-04-06 14:00:21)
> On 4/4/2022 8:29 AM, Anton Khirnov wrote:
> > Allows accessing it without going through the muxer context. This will
> > be useful in the following commits, where the muxer context will be
> > hidden.
> > ---
> >   fftools/ffmpeg.c     | 18 ++++++++++--------
> >   fftools/ffmpeg.h     |  2 ++
> >   fftools/ffmpeg_opt.c |  1 +
> >   3 files changed, 13 insertions(+), 8 deletions(-)
> 
> Patches 4 to 9 look ok.

Thank you, pushed patches up to 9
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 69d1949103..a85ed18b08 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2789,9 +2789,9 @@  static int init_output_stream_streamcopy(OutputStream *ost)
 
     if (!codec_tag) {
         unsigned int codec_tag_tmp;
-        if (!of->ctx->oformat->codec_tag ||
-            av_codec_get_id (of->ctx->oformat->codec_tag, par_src->codec_tag) == par_src->codec_id ||
-            !av_codec_get_tag2(of->ctx->oformat->codec_tag, par_src->codec_id, &codec_tag_tmp))
+        if (!of->format->codec_tag ||
+            av_codec_get_id (of->format->codec_tag, par_src->codec_tag) == par_src->codec_id ||
+            !av_codec_get_tag2(of->format->codec_tag, par_src->codec_id, &codec_tag_tmp))
             codec_tag = par_src->codec_tag;
     }
 
@@ -2809,7 +2809,7 @@  static int init_output_stream_streamcopy(OutputStream *ost)
     else
         ost->st->avg_frame_rate = ist->st->avg_frame_rate;
 
-    ret = avformat_transfer_internal_stream_timing_info(of->ctx->oformat, ost->st, ist->st, copy_tb);
+    ret = avformat_transfer_internal_stream_timing_info(of->format, ost->st, ist->st, copy_tb);
     if (ret < 0)
         return ret;
 
@@ -3011,7 +3011,8 @@  static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
     InputStream *ist = get_input_stream(ost);
     AVCodecContext *enc_ctx = ost->enc_ctx;
     AVCodecContext *dec_ctx = NULL;
-    AVFormatContext *oc = output_files[ost->file_index]->ctx;
+    OutputFile      *of = output_files[ost->file_index];
+    AVFormatContext *oc = of->ctx;
     int ret;
 
     set_encoder_id(output_files[ost->file_index], ost);
@@ -3072,7 +3073,8 @@  static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
         if (!(enc_ctx->time_base.num && enc_ctx->time_base.den))
             enc_ctx->time_base = av_buffersink_get_time_base(ost->filter->filter);
         if (   av_q2d(enc_ctx->time_base) < 0.001 && video_sync_method != VSYNC_PASSTHROUGH
-           && (video_sync_method == VSYNC_CFR || video_sync_method == VSYNC_VSCFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & AVFMT_VARIABLE_FPS)))){
+           && (video_sync_method == VSYNC_CFR || video_sync_method == VSYNC_VSCFR ||
+               (video_sync_method == VSYNC_AUTO && !(of->format->flags & AVFMT_VARIABLE_FPS)))){
             av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not efficiently supporting it.\n"
                                        "Please consider specifying a lower framerate, a different muxer or -vsync 2\n");
         }
@@ -3405,7 +3407,7 @@  static int transcode_init(void)
     /* write headers for files with no streams */
     for (i = 0; i < nb_output_files; i++) {
         oc = output_files[i]->ctx;
-        if (oc->oformat->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) {
+        if (output_files[i]->format->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) {
             ret = of_check_init(output_files[i]);
             if (ret < 0)
                 goto dump_format;
@@ -4615,7 +4617,7 @@  int main(int argc, char **argv)
     }
 
     for (i = 0; i < nb_output_files; i++) {
-        if (strcmp(output_files[i]->ctx->oformat->name, "rtp"))
+        if (strcmp(output_files[i]->format->name, "rtp"))
             want_sdp = 0;
     }
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index ff8ebbfab5..9f0c093e34 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -579,6 +579,8 @@  typedef struct OutputStream {
 typedef struct OutputFile {
     int index;
 
+    const AVOutputFormat *format;
+
     AVFormatContext *ctx;
     AVDictionary *opts;
     int ost_index;       /* index of the first stream in output_streams */
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index daecba9e57..47e8b9b7bd 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2332,6 +2332,7 @@  static int open_output_file(OptionsContext *o, const char *filename)
     }
 
     of->ctx = oc;
+    of->format = oc->oformat;
     if (o->recording_time != INT64_MAX)
         oc->duration = o->recording_time;