Browse Source

avformat: Constify the API wrt AV(In|Out)putFormat

Also constify AVProbeData.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
Andreas Rheinhardt 4 years ago
parent
commit
56450a0ee4

+ 11 - 0
doc/APIchanges

@@ -14,6 +14,17 @@ libavutil:     2017-10-21
 
 
 API changes, most recent first:
+
+2021-04-27 - xxxxxxxxxx - lavf yyyyyyyyy - avformat.h
+  Constified the pointers to AVInputFormats and AVOutputFormats
+  in AVFormatContext, avformat_alloc_output_context2(),
+  av_find_input_format(), av_probe_input_format(),
+  av_probe_input_format2(), av_probe_input_format3(),
+  av_probe_input_buffer2(), av_probe_input_buffer(),
+  avformat_open_input(), av_guess_format() and av_guess_codec().
+  Furthermore, constified the AVProbeData in av_probe_input_format(),
+  av_probe_input_format2() and av_probe_input_format3().
+
 2021-04-19 - xxxxxxxxxx - lavu 56.74.100 - tx.h
   Add AV_TX_FULL_IMDCT and AV_TX_UNALIGNED.
 

+ 1 - 1
doc/examples/muxing.c

@@ -536,8 +536,8 @@ static void close_stream(AVFormatContext *oc, OutputStream *ost)
 int main(int argc, char **argv)
 {
     OutputStream video_st = { 0 }, audio_st = { 0 };
+    const AVOutputFormat *fmt;
     const char *filename;
-    AVOutputFormat *fmt;
     AVFormatContext *oc;
     AVCodec *audio_codec, *video_codec;
     int ret;

+ 1 - 1
doc/examples/remuxing.c

@@ -45,7 +45,7 @@ static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt, cons
 
 int main(int argc, char **argv)
 {
-    AVOutputFormat *ofmt = NULL;
+    const AVOutputFormat *ofmt = NULL;
     AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
     AVPacket pkt;
     const char *in_filename, *out_filename;

+ 7 - 5
fftools/ffmpeg_opt.c

@@ -1068,7 +1068,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
 {
     InputFile *f;
     AVFormatContext *ic;
-    AVInputFormat *file_iformat = NULL;
+    const AVInputFormat *file_iformat = NULL;
     int err, i, ret;
     int64_t timestamp;
     AVDictionary *unused_opts = NULL;
@@ -1117,20 +1117,22 @@ static int open_input_file(OptionsContext *o, const char *filename)
         av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i, 0);
     }
     if (o->nb_audio_channels) {
+        const AVClass *priv_class;
         /* because we set audio_channels based on both the "ac" and
          * "channel_layout" options, we need to check that the specified
          * demuxer actually has the "channels" option before setting it */
-        if (file_iformat && file_iformat->priv_class &&
-            av_opt_find(&file_iformat->priv_class, "channels", NULL, 0,
+        if (file_iformat && (priv_class = file_iformat->priv_class) &&
+            av_opt_find(&priv_class, "channels", NULL, 0,
                         AV_OPT_SEARCH_FAKE_OBJ)) {
             av_dict_set_int(&o->g->format_opts, "channels", o->audio_channels[o->nb_audio_channels - 1].u.i, 0);
         }
     }
     if (o->nb_frame_rates) {
+        const AVClass *priv_class;
         /* set the format-level framerate option;
          * this is important for video grabbers, e.g. x11 */
-        if (file_iformat && file_iformat->priv_class &&
-            av_opt_find(&file_iformat->priv_class, "framerate", NULL, 0,
+        if (file_iformat && (priv_class = file_iformat->priv_class) &&
+            av_opt_find(&priv_class, "framerate", NULL, 0,
                         AV_OPT_SEARCH_FAKE_OBJ)) {
             av_dict_set(&o->g->format_opts, "framerate",
                         o->frame_rates[o->nb_frame_rates - 1].u.str, 0);

+ 4 - 3
fftools/ffplay.c

@@ -203,7 +203,7 @@ typedef struct Decoder {
 
 typedef struct VideoState {
     SDL_Thread *read_tid;
-    AVInputFormat *iformat;
+    const AVInputFormat *iformat;
     int abort_request;
     int force_refresh;
     int paused;
@@ -308,7 +308,7 @@ typedef struct VideoState {
 } VideoState;
 
 /* options specified by the user */
-static AVInputFormat *file_iformat;
+static const AVInputFormat *file_iformat;
 static const char *input_filename;
 static const char *window_title;
 static int default_width  = 640;
@@ -3075,7 +3075,8 @@ static int read_thread(void *arg)
     return 0;
 }
 
-static VideoState *stream_open(const char *filename, AVInputFormat *iformat)
+static VideoState *stream_open(const char *filename,
+                               const AVInputFormat *iformat)
 {
     VideoState *is;
 

+ 1 - 1
fftools/ffprobe.c

@@ -257,7 +257,7 @@ static const OptionDef *options;
 /* FFprobe context */
 static const char *input_filename;
 static const char *print_input_filename;
-static AVInputFormat *iformat = NULL;
+static const AVInputFormat *iformat = NULL;
 
 static struct AVHashContext *hash;
 

+ 1 - 1
libavdevice/internal.h

@@ -22,7 +22,7 @@
 #include "libavformat/avformat.h"
 
 av_warn_unused_result
-int ff_alloc_input_device_context(struct AVFormatContext **avctx, struct AVInputFormat *iformat,
+int ff_alloc_input_device_context(struct AVFormatContext **avctx, const AVInputFormat *iformat,
                                   const char *format);
 
 #endif

+ 1 - 1
libavdevice/utils.c

@@ -20,7 +20,7 @@
 #include "libavutil/opt.h"
 #include "libavformat/avformat.h"
 
-int ff_alloc_input_device_context(AVFormatContext **avctx, AVInputFormat *iformat, const char *format)
+int ff_alloc_input_device_context(AVFormatContext **avctx, const AVInputFormat *iformat, const char *format)
 {
     AVFormatContext *s;
     int ret = 0;

+ 1 - 1
libavfilter/lavfutils.c

@@ -26,7 +26,7 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
                   int *w, int *h, enum AVPixelFormat *pix_fmt,
                   const char *filename, void *log_ctx)
 {
-    AVInputFormat *iformat = NULL;
+    const AVInputFormat *iformat = NULL;
     AVFormatContext *format_ctx = NULL;
     const AVCodec *codec;
     AVCodecContext *codec_ctx = NULL;

+ 1 - 1
libavfilter/src_movie.c

@@ -205,7 +205,7 @@ static int guess_channel_layout(MovieStream *st, int st_index, void *log_ctx)
 static av_cold int movie_common_init(AVFilterContext *ctx)
 {
     MovieContext *movie = ctx->priv;
-    AVInputFormat *iformat = NULL;
+    const AVInputFormat *iformat = NULL;
     int64_t timestamp;
     int nb_streams = 1, ret, i;
     char default_streams[16], *stream_specs, *spec, *cursor;

Some files were not shown because too many files changed in this diff