[FFmpeg-cvslog] avformat/avformat, utils: Make av_find_best_stream const-correct

Andreas Rheinhardt git at videolan.org
Wed Apr 28 00:16:43 EEST 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Thu Feb 25 01:53:40 2021 +0100| [46dac8cf3d250184ab4247809bc03f60e14f4c0c] | committer: James Almer

avformat/avformat, utils: Make av_find_best_stream const-correct

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=46dac8cf3d250184ab4247809bc03f60e14f4c0c
---

 doc/APIchanges                 | 4 ++++
 doc/examples/extract_mvs.c     | 2 +-
 doc/examples/filtering_audio.c | 2 +-
 doc/examples/filtering_video.c | 2 +-
 doc/examples/hw_decode.c       | 2 +-
 doc/examples/vaapi_transcode.c | 2 +-
 libavformat/avformat.h         | 2 +-
 libavformat/utils.c            | 4 ++--
 8 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 9b7a2d4b99..9a5cfa7dc0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,10 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2021-04-27 - xxxxxxxxxx - lavf yyyyyyyyy - avformat.h
+  av_find_best_stream now uses a const AVCodec ** parameter
+  for the returned decoder.
+
 2021-04-27 - xxxxxxxxxx - lavc yyyyyyyyy - codec.h
   avcodec_find_encoder_by_name(), avcodec_find_encoder(),
   avcodec_find_decoder_by_name() and avcodec_find_decoder()
diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c
index de31ccd2b9..42e1844150 100644
--- a/doc/examples/extract_mvs.c
+++ b/doc/examples/extract_mvs.c
@@ -78,7 +78,7 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type)
     int ret;
     AVStream *st;
     AVCodecContext *dec_ctx = NULL;
-    AVCodec *dec = NULL;
+    const AVCodec *dec = NULL;
     AVDictionary *opts = NULL;
 
     ret = av_find_best_stream(fmt_ctx, type, -1, -1, &dec, 0);
diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c
index 834b137cd9..508c19c60b 100644
--- a/doc/examples/filtering_audio.c
+++ b/doc/examples/filtering_audio.c
@@ -48,8 +48,8 @@ static int audio_stream_index = -1;
 
 static int open_input_file(const char *filename)
 {
+    const AVCodec *dec;
     int ret;
-    AVCodec *dec;
 
     if ((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)) < 0) {
         av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c
index 105a200d93..88394530ab 100644
--- a/doc/examples/filtering_video.c
+++ b/doc/examples/filtering_video.c
@@ -53,8 +53,8 @@ static int64_t last_pts = AV_NOPTS_VALUE;
 
 static int open_input_file(const char *filename)
 {
+    const AVCodec *dec;
     int ret;
-    AVCodec *dec;
 
     if ((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)) < 0) {
         av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
diff --git a/doc/examples/hw_decode.c b/doc/examples/hw_decode.c
index 71be6e6709..096a229c0d 100644
--- a/doc/examples/hw_decode.c
+++ b/doc/examples/hw_decode.c
@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
     int video_stream, ret;
     AVStream *video = NULL;
     AVCodecContext *decoder_ctx = NULL;
-    AVCodec *decoder = NULL;
+    const AVCodec *decoder = NULL;
     AVPacket packet;
     enum AVHWDeviceType type;
     int i;
diff --git a/doc/examples/vaapi_transcode.c b/doc/examples/vaapi_transcode.c
index e9b33eede0..a174bb643a 100644
--- a/doc/examples/vaapi_transcode.c
+++ b/doc/examples/vaapi_transcode.c
@@ -62,7 +62,7 @@ static enum AVPixelFormat get_vaapi_format(AVCodecContext *ctx,
 static int open_input_file(const char *filename)
 {
     int ret;
-    AVCodec *decoder = NULL;
+    const AVCodec *decoder = NULL;
     AVStream *video = NULL;
 
     if ((ret = avformat_open_input(&ifmt_ctx, filename, NULL, NULL)) < 0) {
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 23bdaa207b..28069d45dc 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2070,7 +2070,7 @@ int av_find_best_stream(AVFormatContext *ic,
                         enum AVMediaType type,
                         int wanted_stream_nb,
                         int related_stream,
-                        AVCodec **decoder_ret,
+                        const AVCodec **decoder_ret,
                         int flags);
 
 /**
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7078891dc0..2f66f539a6 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4200,7 +4200,7 @@ AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int
 
 int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
                         int wanted_stream_nb, int related_stream,
-                        AVCodec **decoder_ret, int flags)
+                        const AVCodec **decoder_ret, int flags)
 {
     int i, nb_streams = ic->nb_streams;
     int ret = AVERROR_STREAM_NOT_FOUND;
@@ -4260,7 +4260,7 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
         }
     }
     if (decoder_ret)
-        *decoder_ret = (AVCodec*)best_decoder;
+        *decoder_ret = best_decoder;
     return ret;
 }
 



More information about the ffmpeg-cvslog mailing list