[FFmpeg-cvslog] avformat: remove deprecated AVStream.codec

James Almer git at videolan.org
Wed Apr 28 00:16:59 EEST 2021


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sun Apr 18 10:59:35 2021 -0300| [3749eede66c3774799766b1f246afae8a6ffc9bb] | committer: James Almer

avformat: remove deprecated AVStream.codec

Signed-off-by: James Almer <jamrial at gmail.com>

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

 fftools/ffmpeg_opt.c      |  13 ----
 libavformat/avformat.h    |  16 ++---
 libavformat/dump.c        |  29 ++------
 libavformat/isom.c        |  12 +---
 libavformat/mov.c         |  17 -----
 libavformat/movenc.c      |  38 +----------
 libavformat/mux.c         |  27 --------
 libavformat/sdp.c         |  18 -----
 libavformat/segment.c     |   6 --
 libavformat/utils.c       | 164 +---------------------------------------------
 libavformat/version.h     |   3 -
 libavformat/yuv4mpegenc.c |   7 --
 12 files changed, 17 insertions(+), 333 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index e66141f3ab..c0b9f023bd 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2442,19 +2442,6 @@ loop_end:
         avio_closep(&pb);
     }
 
-#if FF_API_LAVF_AVCTX
-    for (i = nb_output_streams - oc->nb_streams; i < nb_output_streams; i++) { //for all streams of this output file
-        AVDictionaryEntry *e;
-        ost = output_streams[i];
-
-        if ((ost->stream_copy || ost->attachment_filename)
-            && (e = av_dict_get(o->g->codec_opts, "flags", NULL, AV_DICT_IGNORE_SUFFIX))
-            && (!e->key[5] || check_stream_specifier(oc, ost->st, e->key+6)))
-            if (av_opt_set(ost->st->codec, "flags", e->value, 0) < 0)
-                exit_program(1);
-    }
-#endif
-
     if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
         av_dump_format(oc, nb_output_files - 1, oc->url, 1);
         av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1);
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 28069d45dc..624d2dae2c 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -839,13 +839,7 @@ typedef struct AVStream {
      * encoding: set by the user, replaced by libavformat if left unset
      */
     int id;
-#if FF_API_LAVF_AVCTX
-    /**
-     * @deprecated use the codecpar struct instead
-     */
-    attribute_deprecated
-    AVCodecContext *codec;
-#endif
+
     void *priv_data;
 
     /**
@@ -1837,13 +1831,11 @@ const AVClass *avformat_get_class(void);
  *
  * When muxing, should be called by the user before avformat_write_header().
  *
- * User is required to call avcodec_close() and avformat_free_context() to
- * clean up the allocation by avformat_new_stream().
+ * User is required to call avformat_free_context() to clean up the allocation
+ * by avformat_new_stream().
  *
  * @param s media file handle
- * @param c If non-NULL, the AVCodecContext corresponding to the new stream
- * will be initialized to use this codec. This is needed for e.g. codec-specific
- * defaults to be set, so codec should be provided if it is known.
+ * @param c unused, does nothing
  *
  * @return newly created stream or NULL on error.
  */
diff --git a/libavformat/dump.c b/libavformat/dump.c
index f8ad01102a..9f54bc3e8d 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -37,6 +37,7 @@
 #include "libavutil/timecode.h"
 
 #include "avformat.h"
+#include "internal.h"
 
 #define HEXDUMP_PRINT(...)                                                    \
     do {                                                                      \
@@ -522,17 +523,13 @@ static void dump_stream_format(const AVFormatContext *ic, int i,
         return;
     }
 
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
     // Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext
-    avctx->properties = st->codec->properties;
-    avctx->codec      = st->codec->codec;
-    avctx->qmin       = st->codec->qmin;
-    avctx->qmax       = st->codec->qmax;
-    avctx->coded_width  = st->codec->coded_width;
-    avctx->coded_height = st->codec->coded_height;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
+    avctx->properties   = st->internal->avctx->properties;
+    avctx->codec        = st->internal->avctx->codec;
+    avctx->qmin         = st->internal->avctx->qmin;
+    avctx->qmax         = st->internal->avctx->qmax;
+    avctx->coded_width  = st->internal->avctx->coded_width;
+    avctx->coded_height = st->internal->avctx->coded_height;
 
     if (separator)
         av_opt_set(avctx, "dump_separator", separator, 0);
@@ -567,13 +564,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
         int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
         int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
         int tbn = st->time_base.den && st->time_base.num;
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-        int tbc = st->codec->time_base.den && st->codec->time_base.num;
-FF_ENABLE_DEPRECATION_WARNINGS
-#else
         int tbc = 0;
-#endif
 
         if (fps || tbr || tbn || tbc)
             av_log(NULL, AV_LOG_INFO, "%s", separator);
@@ -584,12 +575,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
             print_fps(av_q2d(st->r_frame_rate), tbn || tbc ? "tbr, " : "tbr");
         if (tbn)
             print_fps(1 / av_q2d(st->time_base), tbc ? "tbn, " : "tbn");
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-        if (tbc)
-            print_fps(1 / av_q2d(st->codec->time_base), "tbc");
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
     }
 
     if (st->disposition & AV_DISPOSITION_DEFAULT)
diff --git a/libavformat/isom.c b/libavformat/isom.c
index df98779149..35c5eb982e 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -329,22 +329,12 @@ static const AVCodecTag mp4_audio_types[] = {
 int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
 {
     enum AVCodecID codec_id;
-    unsigned v;
     int len, tag;
     int ret;
     int object_type_id = avio_r8(pb);
     avio_r8(pb); /* stream type */
     avio_rb24(pb); /* buffer size db */
-
-    v = avio_rb32(pb);
-
-    // TODO: fix this with codecpar
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-    if (v < INT32_MAX)
-        st->codec->rc_max_rate = v;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
+    avio_rb32(pb); /* rc_max_rate */
 
     st->codecpar->bit_rate = avio_rb32(pb); /* avg bitrate */
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 06034695e7..815106d924 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -804,12 +804,6 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     if (st->codecpar->channels > 1 && bsmod == 0x7)
         *ast = AV_AUDIO_SERVICE_TYPE_KARAOKE;
 
-#if FF_API_LAVF_AVCTX
-    FF_DISABLE_DEPRECATION_WARNINGS
-    st->codec->audio_service_type = *ast;
-    FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
     return 0;
 }
 
@@ -844,12 +838,6 @@ static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     if (st->codecpar->channels > 1 && bsmod == 0x7)
         *ast = AV_AUDIO_SERVICE_TYPE_KARAOKE;
 
-#if FF_API_LAVF_AVCTX
-    FF_DISABLE_DEPRECATION_WARNINGS
-    st->codec->audio_service_type = *ast;
-    FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
     return 0;
 }
 
@@ -2340,11 +2328,6 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
             tmcd_ctx->tmcd_flags = val;
             st->avg_frame_rate.num = AV_RB32(st->codecpar->extradata + 8); /* timescale */
             st->avg_frame_rate.den = AV_RB32(st->codecpar->extradata + 12); /* frameDuration */
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-            st->codec->time_base = av_inv_q(st->avg_frame_rate);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
             if (size > 30) {
                 uint32_t len = AV_RB32(st->codecpar->extradata + 18); /* name atom length */
                 uint32_t format = AV_RB32(st->codecpar->extradata + 22);
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index a315377ef6..b3d1fda435 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1459,27 +1459,9 @@ static int mov_get_dv_codec_tag(AVFormatContext *s, MOVTrack *track)
     return tag;
 }
 
-static AVRational find_fps(AVFormatContext *s, AVStream *st)
-{
-    AVRational rate = st->avg_frame_rate;
-
-#if FF_API_LAVF_AVCTX
-    FF_DISABLE_DEPRECATION_WARNINGS
-    rate = av_inv_q(st->codec->time_base);
-    if (av_timecode_check_frame_rate(rate) < 0) {
-        av_log(s, AV_LOG_DEBUG, "timecode: tbc=%d/%d invalid, fallback on %d/%d\n",
-               rate.num, rate.den, st->avg_frame_rate.num, st->avg_frame_rate.den);
-        rate = st->avg_frame_rate;
-    }
-    FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
-    return rate;
-}
-
 static int defined_frame_rate(AVFormatContext *s, AVStream *st)
 {
-    AVRational rational_framerate = find_fps(s, st);
+    AVRational rational_framerate = st->avg_frame_rate;
     int rate = 0;
     if (rational_framerate.den != 0)
         rate = av_q2d(rational_framerate);
@@ -2234,13 +2216,6 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
         track->par->codec_id != AV_CODEC_ID_DNXHD) {
         int field_order = track->par->field_order;
 
-#if FF_API_LAVF_AVCTX
-    FF_DISABLE_DEPRECATION_WARNINGS
-    if (field_order != track->st->codec->field_order && track->st->codec->field_order != AV_FIELD_UNKNOWN)
-        field_order = track->st->codec->field_order;
-    FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
         if (field_order != AV_FIELD_UNKNOWN)
             mov_write_fiel_tag(pb, track, field_order);
     }
@@ -2354,15 +2329,8 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track)
     AVDictionaryEntry *t = NULL;
 
     if (!track->st->avg_frame_rate.num || !track->st->avg_frame_rate.den) {
-#if FF_API_LAVF_AVCTX
-    FF_DISABLE_DEPRECATION_WARNINGS
-        frame_duration = av_rescale(track->timescale, track->st->codec->time_base.num, track->st->codec->time_base.den);
-        nb_frames      = ROUNDED_DIV(track->st->codec->time_base.den, track->st->codec->time_base.num);
-    FF_ENABLE_DEPRECATION_WARNINGS
-#else
         av_log(NULL, AV_LOG_ERROR, "avg_frame_rate not set for tmcd track.\n");
         return AVERROR(EINVAL);
-#endif
     } else {
         frame_duration = av_rescale(track->timescale, track->st->avg_frame_rate.den, track->st->avg_frame_rate.num);
         nb_frames      = ROUNDED_DIV(track->st->avg_frame_rate.num, track->st->avg_frame_rate.den);
@@ -6199,7 +6167,7 @@ static int mov_check_timecode_track(AVFormatContext *s, AVTimecode *tc, int src_
     int ret;
 
     /* compute the frame number */
-    ret = av_timecode_init_from_string(tc, find_fps(s,  s->streams[src_index]), tcstr, s);
+    ret = av_timecode_init_from_string(tc, s->streams[src_index]->avg_frame_rate, tcstr, s);
     return ret;
 }
 
@@ -6210,7 +6178,7 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde
     AVStream *src_st    = s->streams[src_index];
     uint8_t data[4];
     AVPacket *pkt = mov->pkt;
-    AVRational rate = find_fps(s, src_st);
+    AVRational rate = src_st->avg_frame_rate;
     int ret;
 
     /* tmcd track based on video stream */
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 1c08c74b90..eab58aa225 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -247,19 +247,6 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
         goto fail;
     }
 
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-    if (s->nb_streams && s->streams[0]->codec->flags & AV_CODEC_FLAG_BITEXACT) {
-        if (!(s->flags & AVFMT_FLAG_BITEXACT)) {
-            av_log(s, AV_LOG_WARNING,
-                   "The AVFormatContext is not in set to bitexact mode, only "
-                   "the AVCodecContext. If this is not intended, set "
-                   "AVFormatContext.flags |= AVFMT_FLAG_BITEXACT.\n");
-        }
-    }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
     // some sanity checks
     if (s->nb_streams == 0 && !(of->flags & AVFMT_NOSTREAMS)) {
         av_log(s, AV_LOG_ERROR, "No streams to mux were specified\n");
@@ -271,20 +258,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
         st  = s->streams[i];
         par = st->codecpar;
 
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-        if (st->codecpar->codec_type == AVMEDIA_TYPE_UNKNOWN &&
-            st->codec->codec_type    != AVMEDIA_TYPE_UNKNOWN) {
-            av_log(s, AV_LOG_WARNING, "Using AVStream.codec to pass codec "
-                   "parameters to muxers is deprecated, use AVStream.codecpar "
-                   "instead.\n");
-            ret = avcodec_parameters_from_context(st->codecpar, st->codec);
-            if (ret < 0)
-                goto fail;
-        }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
         if (!st->time_base.num) {
             /* fall back on the default timebase values */
             if (par->codec_type == AVMEDIA_TYPE_AUDIO && par->sample_rate)
diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index 95f3fbb876..1200e553f9 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -704,24 +704,6 @@ static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int
         case AV_CODEC_ID_SPEEX:
             av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n",
                                      payload_type, p->sample_rate);
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-            if (st->codec) {
-                const char *mode;
-                uint64_t vad_option;
-
-                if (st->codec->flags & AV_CODEC_FLAG_QSCALE)
-                      mode = "on";
-                else if (!av_opt_get_int(st->codec, "vad", AV_OPT_FLAG_ENCODING_PARAM, &vad_option) && vad_option)
-                      mode = "vad";
-                else
-                      mode = "off";
-
-                av_strlcatf(buff, size, "a=fmtp:%d vbr=%s\r\n",
-                                        payload_type, mode);
-            }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
             break;
         case AV_CODEC_ID_OPUS:
             /* The opus RTP draft says that all opus streams MUST be declared
diff --git a/libavformat/segment.c b/libavformat/segment.c
index faa8eb8f92..74106445e6 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -178,12 +178,6 @@ static int segment_mux_init(AVFormatContext *s)
         } else {
             opar->codec_tag = 0;
         }
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-        if (ipar->codec_tag == MKTAG('t','m','c','d'))
-            st->codec->time_base = ist->codec->time_base;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
     }
 
     return 0;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 2f66f539a6..49bf19b2b0 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -158,13 +158,6 @@ int ff_copy_whiteblacklists(AVFormatContext *dst, const AVFormatContext *src)
 
 static const AVCodec *find_decoder(AVFormatContext *s, const AVStream *st, enum AVCodecID codec_id)
 {
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-    if (st->codec->codec)
-        return st->codec->codec;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
     switch (st->codecpar->codec_type) {
     case AVMEDIA_TYPE_VIDEO:
         if (s->video_codec)    return s->video_codec;
@@ -354,12 +347,6 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st,
                 st->codecpar->codec_id   = fmt_id_type[i].id;
                 st->codecpar->codec_type = fmt_id_type[i].type;
                 st->internal->need_context_update = 1;
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-                st->codec->codec_type = st->codecpar->codec_type;
-                st->codec->codec_id   = st->codecpar->codec_id;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
                 return score;
             }
         }
@@ -480,15 +467,6 @@ static int update_stream_avctx(AVFormatContext *s)
         if (ret < 0)
             return ret;
 
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-        /* update deprecated public codec context */
-        ret = avcodec_parameters_to_context(st->codec, st->codecpar);
-        if (ret < 0)
-            return ret;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
         st->internal->need_context_update = 0;
     }
     return 0;
@@ -920,13 +898,6 @@ void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStrea
                                               av_mul_q(av_inv_q(st->internal->avctx->time_base), (AVRational){1, st->internal->avctx->ticks_per_frame});
     int frame_size, sample_rate;
 
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-    if ((!codec_framerate.den || !codec_framerate.num) && st->codec->time_base.den && st->codec->time_base.num)
-        codec_framerate = av_mul_q(av_inv_q(st->codec->time_base), (AVRational){1, st->codec->ticks_per_frame});
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
     *pnum = 0;
     *pden = 0;
     switch (st->codecpar->codec_type) {
@@ -1547,17 +1518,6 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
                 return ret;
             }
 
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-            /* update deprecated public codec context */
-            ret = avcodec_parameters_to_context(st->codec, st->codecpar);
-            if (ret < 0) {
-                av_packet_unref(pkt);
-                return ret;
-            }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
             st->internal->need_context_update = 0;
         }
 
@@ -1680,10 +1640,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
         av_opt_set_dict_val(s, "metadata", NULL, AV_OPT_SEARCH_CHILDREN);
     }
 
-#if FF_API_LAVF_AVCTX
-    update_stream_avctx(s);
-#endif
-
     if (s->debug & FF_FDEBUG_TS)
         av_log(s, AV_LOG_DEBUG,
                "read_frame_internal stream=%d, pts=%s, dts=%s, "
@@ -3632,15 +3588,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
         }
 
         /* check if the caller has overridden the codec id */
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-        if (st->codec->codec_id != st->internal->orig_codec_id) {
-            st->codecpar->codec_id   = st->codec->codec_id;
-            st->codecpar->codec_type = st->codec->codec_type;
-            st->internal->orig_codec_id = st->codec->codec_id;
-        }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
         // only for the split stuff
         if (!st->parser && !(ic->flags & AVFMT_FLAG_NOPARSE) && st->internal->request_probe <= 0) {
             st->parser = av_parser_init(st->codecpar->codec_id);
@@ -4123,42 +4070,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
                 goto find_stream_info_err;
         }
 
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-        ret = avcodec_parameters_to_context(st->codec, st->codecpar);
-        if (ret < 0)
-            goto find_stream_info_err;
-
-        // The old API (AVStream.codec) "requires" the resolution to be adjusted
-        // by the lowres factor.
-        if (st->internal->avctx->lowres && st->internal->avctx->width) {
-            st->codec->lowres = st->internal->avctx->lowres;
-            st->codec->width = st->internal->avctx->width;
-            st->codec->height = st->internal->avctx->height;
-        }
-
-        if (st->codec->codec_tag != MKTAG('t','m','c','d')) {
-            st->codec->time_base = st->internal->avctx->time_base;
-            st->codec->ticks_per_frame = st->internal->avctx->ticks_per_frame;
-        }
-        st->codec->framerate = st->avg_frame_rate;
-
-        if (st->internal->avctx->subtitle_header) {
-            st->codec->subtitle_header = av_malloc(st->internal->avctx->subtitle_header_size);
-            if (!st->codec->subtitle_header)
-                goto find_stream_info_err;
-            st->codec->subtitle_header_size = st->internal->avctx->subtitle_header_size;
-            memcpy(st->codec->subtitle_header, st->internal->avctx->subtitle_header,
-                   st->codec->subtitle_header_size);
-        }
-
-        // Fields unavailable in AVCodecParameters
-        st->codec->coded_width = st->internal->avctx->coded_width;
-        st->codec->coded_height = st->internal->avctx->coded_height;
-        st->codec->properties = st->internal->avctx->properties;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
         st->internal->avctx_inited = 0;
     }
 
@@ -4368,11 +4279,6 @@ static void free_stream(AVStream **pst)
 
     av_dict_free(&st->metadata);
     avcodec_parameters_free(&st->codecpar);
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-    avcodec_free_context(&st->codec);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
     av_freep(&st->priv_data);
 
     av_freep(pst);
@@ -4480,16 +4386,6 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
     if (!st)
         return NULL;
 
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-    st->codec = avcodec_alloc_context3(c);
-    if (!st->codec) {
-        av_free(st);
-        return NULL;
-    }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
     st->internal = av_mallocz(sizeof(*st->internal));
     if (!st->internal)
         goto fail;
@@ -4508,13 +4404,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
         goto fail;
 
     if (s->iformat) {
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-        /* no default bitrate if decoding */
-        st->codec->bit_rate = 0;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
         /* default pts setting is MPEG-like */
         avpriv_set_pts_info(st, 33, 1, 90000);
         /* we set the current DTS to 0 so that formats without any timestamps
@@ -4922,11 +4811,6 @@ void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits,
         return;
     }
     s->time_base     = new_tb;
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-    s->codec->pkt_timebase = new_tb;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
     s->internal->avctx->pkt_timebase = new_tb;
     s->pts_wrap_bits = pts_wrap_bits;
 }
@@ -5154,16 +5038,8 @@ static int match_stream_specifier(AVFormatContext *s, AVStream *st,
             if (*spec && *spec++ != ':')         /* If we are not at the end, then another specifier must follow. */
                 return AVERROR(EINVAL);
 
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-            if (type != st->codecpar->codec_type
-               && (st->codecpar->codec_type != AVMEDIA_TYPE_UNKNOWN || st->codec->codec_type != type))
-                match = 0;
-    FF_ENABLE_DEPRECATION_WARNINGS
-#else
             if (type != st->codecpar->codec_type)
                 match = 0;
-#endif
             if (nopic && (st->disposition & AV_DISPOSITION_ATTACHED_PIC))
                 match = 0;
         } else if (*spec == 'p' && *(spec + 1) == ':') {
@@ -5230,35 +5106,16 @@ FF_DISABLE_DEPRECATION_WARNINGS
             return match && ret;
         } else if (*spec == 'u' && *(spec + 1) == '\0') {
             AVCodecParameters *par = st->codecpar;
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-            AVCodecContext *codec = st->codec;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
             int val;
             switch (par->codec_type) {
             case AVMEDIA_TYPE_AUDIO:
                 val = par->sample_rate && par->channels;
-#if FF_API_LAVF_AVCTX
-                val = val || (codec->sample_rate && codec->channels);
-#endif
-                if (par->format == AV_SAMPLE_FMT_NONE
-#if FF_API_LAVF_AVCTX
-                    && codec->sample_fmt == AV_SAMPLE_FMT_NONE
-#endif
-                    )
+                if (par->format == AV_SAMPLE_FMT_NONE)
                     return 0;
                 break;
             case AVMEDIA_TYPE_VIDEO:
                 val = par->width && par->height;
-#if FF_API_LAVF_AVCTX
-                val = val || (codec->width && codec->height);
-#endif
-                if (par->format == AV_PIX_FMT_NONE
-#if FF_API_LAVF_AVCTX
-                    && codec->pix_fmt == AV_PIX_FMT_NONE
-#endif
-                    )
+                if (par->format == AV_PIX_FMT_NONE)
                     return 0;
                 break;
             case AVMEDIA_TYPE_UNKNOWN:
@@ -5268,11 +5125,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
                 val = 1;
                 break;
             }
-#if FF_API_LAVF_AVCTX
-            return match && ((par->codec_id != AV_CODEC_ID_NONE || codec->codec_id != AV_CODEC_ID_NONE) && val != 0);
-#else
             return match && (par->codec_id != AV_CODEC_ID_NONE && val != 0);
-#endif
         } else {
             return AVERROR(EINVAL);
         }
@@ -5684,15 +5537,8 @@ int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
     const AVCodecContext *dec_ctx;
     AVCodecContext       *enc_ctx;
 
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-    dec_ctx = ist->codec;
-    enc_ctx = ost->codec;
-FF_ENABLE_DEPRECATION_WARNINGS
-#else
     dec_ctx = ist->internal->avctx;
     enc_ctx = ost->internal->avctx;
-#endif
 
     enc_ctx->time_base = ist->time_base;
     /*
@@ -5748,13 +5594,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 AVRational av_stream_get_codec_timebase(const AVStream *st)
 {
     // See avformat_transfer_internal_stream_timing_info() TODO.
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-    return st->codec->time_base;
-FF_ENABLE_DEPRECATION_WARNINGS
-#else
     return st->internal->avctx->time_base;
-#endif
 }
 
 void ff_format_set_url(AVFormatContext *s, char *url)
diff --git a/libavformat/version.h b/libavformat/version.h
index 195c3eaa5a..4a2a62016b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -55,9 +55,6 @@
  * at once through the bump. This improves the git bisect-ability of the change.
  *
  */
-#ifndef FF_API_LAVF_AVCTX
-#define FF_API_LAVF_AVCTX               (LIBAVFORMAT_VERSION_MAJOR < 59)
-#endif
 #ifndef FF_API_LAVF_PRIV_OPT
 #define FF_API_LAVF_PRIV_OPT            (LIBAVFORMAT_VERSION_MAJOR < 60)
 #endif
diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
index 6b53780ba0..f21f2dce92 100644
--- a/libavformat/yuv4mpegenc.c
+++ b/libavformat/yuv4mpegenc.c
@@ -50,13 +50,6 @@ static int yuv4_write_header(AVFormatContext *s)
     if (aspectn == 0 && aspectd == 1)
         aspectd = 0;  // 0:0 means unknown
 
-#if FF_API_LAVF_AVCTX
-    FF_DISABLE_DEPRECATION_WARNINGS
-    if (field_order != st->codec->field_order && st->codec->field_order != AV_FIELD_UNKNOWN)
-        field_order = st->codec->field_order;
-    FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
     switch(st->codecpar->color_range) {
     case AVCOL_RANGE_MPEG:
         colorrange = " XCOLORRANGE=LIMITED";



More information about the ffmpeg-cvslog mailing list