]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/utils.c
avformat: remove deprecated AVStream.codec
[ffmpeg] / libavformat / utils.c
index 13b1bc7c78527849d6f4953b8b116d1ba23ba58f..49bf19b2b04aee45620bf5c7af2e2225d26179db 100644 (file)
@@ -113,27 +113,6 @@ static int64_t wrap_timestamp(const AVStream *st, int64_t timestamp)
     return timestamp;
 }
 
-#if FF_API_FORMAT_GET_SET
-MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate)
-#if FF_API_LAVF_FFSERVER
-FF_DISABLE_DEPRECATION_WARNINGS
-MAKE_ACCESSORS(AVStream, stream, char *, recommended_encoder_configuration)
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec)
-MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, audio_codec)
-MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
-MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, data_codec)
-MAKE_ACCESSORS(AVFormatContext, format, int, metadata_header_padding)
-MAKE_ACCESSORS(AVFormatContext, format, void *, opaque)
-MAKE_ACCESSORS(AVFormatContext, format, av_format_control_message, control_message_cb)
-#if FF_API_OLD_OPEN_CALLBACKS
-FF_DISABLE_DEPRECATION_WARNINGS
-MAKE_ACCESSORS(AVFormatContext, format, AVOpenCallback, open_cb)
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-#endif
-
 int64_t av_stream_get_end_pts(const AVStream *st)
 {
     if (st->internal->priv_pts) {
@@ -179,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;
@@ -231,13 +203,6 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st,
     return codec;
 }
 
-#if FF_API_FORMAT_GET_SET
-int av_format_get_probe_score(const AVFormatContext *s)
-{
-    return s->probe_score;
-}
-#endif
-
 /* an arbitrarily chosen "sane" max packet size -- 50M */
 #define SANE_CHUNK_SIZE (50000000)
 
@@ -382,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;
             }
         }
@@ -398,27 +357,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 /************************************************************/
 /* input media file */
 
-#if FF_API_DEMUXER_OPEN
-int av_demuxer_open(AVFormatContext *ic) {
-    int err;
-
-    if (ic->format_whitelist && av_match_list(ic->iformat->name, ic->format_whitelist, ',') <= 0) {
-        av_log(ic, AV_LOG_ERROR, "Format not on whitelist \'%s\'\n", ic->format_whitelist);
-        return AVERROR(EINVAL);
-    }
-
-    if (ic->iformat->read_header) {
-        err = ic->iformat->read_header(ic);
-        if (err < 0)
-            return err;
-    }
-
-    if (ic->pb && !ic->internal->data_offset)
-        ic->internal->data_offset = avio_tell(ic->pb);
-
-    return 0;
-}
-#endif
 /* Open input file and probe the format if necessary. */
 static int init_input(AVFormatContext *s, const char *filename,
                       AVDictionary **options)
@@ -529,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;
@@ -545,7 +474,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 
 int avformat_open_input(AVFormatContext **ps, const char *filename,
-                        ff_const59 AVInputFormat *fmt, AVDictionary **options)
+                        const AVInputFormat *fmt, AVDictionary **options)
 {
     AVFormatContext *s = *ps;
     int i, ret = 0;
@@ -575,11 +504,6 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
         goto fail;
     }
 
-#if FF_API_FORMAT_FILENAME
-FF_DISABLE_DEPRECATION_WARNINGS
-    av_strlcpy(s->filename, filename ? filename : "", sizeof(s->filename));
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
     if ((ret = init_input(s, filename, &tmp)) < 0)
         goto fail;
     s->probe_score = ret;
@@ -636,11 +560,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
     if (s->pb)
         ff_id3v2_read_dict(s->pb, &s->internal->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
 
-#if FF_API_DEMUXER_OPEN
-    if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
-#else
     if (s->iformat->read_header)
-#endif
         if ((ret = s->iformat->read_header(s)) < 0)
             goto fail;
 
@@ -669,11 +589,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
     if ((ret = avformat_queue_attached_pictures(s)) < 0)
         goto close;
 
-#if FF_API_DEMUXER_OPEN
-    if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->internal->data_offset)
-#else
     if (s->pb && !s->internal->data_offset)
-#endif
         s->internal->data_offset = avio_tell(s->pb);
 
     s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
@@ -982,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) {
@@ -1439,12 +1348,6 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
     /* update flags */
     if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA || ff_is_intra_only(st->codecpar->codec_id))
         pkt->flags |= AV_PKT_FLAG_KEY;
-#if FF_API_CONVERGENCE_DURATION
-FF_DISABLE_DEPRECATION_WARNINGS
-    if (pc)
-        pkt->convergence_duration = pc->convergence_duration;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
 }
 
 /**
@@ -1615,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;
         }
 
@@ -1748,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, "
@@ -2164,6 +2052,33 @@ int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, int flags)
                                      wanted_timestamp, flags);
 }
 
+int avformat_index_get_entries_count(const AVStream *st)
+{
+    return st->internal->nb_index_entries;
+}
+
+const AVIndexEntry *avformat_index_get_entry(const AVStream *st, int idx)
+{
+    if (idx < 0 || idx >= st->internal->nb_index_entries)
+        return NULL;
+
+    return &st->internal->index_entries[idx];
+}
+
+const AVIndexEntry *avformat_index_get_entry_from_timestamp(const AVStream *st,
+                                                            int64_t wanted_timestamp,
+                                                            int flags)
+{
+    int idx = ff_index_search_timestamp(st->internal->index_entries,
+                                        st->internal->nb_index_entries,
+                                        wanted_timestamp, flags);
+
+    if (idx < 0)
+        return NULL;
+
+    return &st->internal->index_entries[idx];
+}
+
 static int64_t ff_read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit,
                                  int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ))
 {
@@ -3673,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);
@@ -3720,16 +3626,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
         if (ic->codec_whitelist)
             av_dict_set(options ? &options[i] : &thread_opt, "codec_whitelist", ic->codec_whitelist, 0);
 
-        /* Ensure that subtitle_header is properly set. */
-        if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE
-            && codec && !avctx->codec) {
-            if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
-                av_log(ic, AV_LOG_WARNING,
-                       "Failed to open codec in %s\n",__FUNCTION__);
-        }
-
         // Try to just open decoders, in case this is enough to get parameters.
-        if (!has_codec_parameters(st, NULL) && st->internal->request_probe <= 0) {
+        // Also ensure that subtitle_header is properly set.
+        if (!has_codec_parameters(st, NULL) && st->internal->request_probe <= 0 ||
+            st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
             if (codec && !avctx->codec)
                 if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
                     av_log(ic, AV_LOG_WARNING,
@@ -4170,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;
     }
 
@@ -4247,7 +4111,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;
@@ -4307,7 +4171,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;
 }
 
@@ -4377,18 +4241,6 @@ int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src)
         }
     }
 
-#if FF_API_LAVF_FFSERVER
-FF_DISABLE_DEPRECATION_WARNINGS
-    av_freep(&dst->recommended_encoder_configuration);
-    if (src->recommended_encoder_configuration) {
-        const char *conf_str = src->recommended_encoder_configuration;
-        dst->recommended_encoder_configuration = av_strdup(conf_str);
-        if (!dst->recommended_encoder_configuration)
-            return AVERROR(ENOMEM);
-    }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
     return 0;
 }
 
@@ -4427,17 +4279,7 @@ 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);
-#if FF_API_LAVF_FFSERVER
-FF_DISABLE_DEPRECATION_WARNINGS
-    av_freep(&st->recommended_encoder_configuration);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
 
     av_freep(pst);
 }
@@ -4544,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;
@@ -4572,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
@@ -4653,11 +4478,7 @@ AVProgram *av_new_program(AVFormatContext *ac, int id)
     return program;
 }
 
-#if FF_API_CHAPTER_ID_INT
-AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base,
-#else
 AVChapter *avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_base,
-#endif
                               int64_t start, int64_t end, const char *title)
 {
     AVChapter *chapter = NULL;
@@ -4990,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;
 }
@@ -5222,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) == ':') {
@@ -5298,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:
@@ -5336,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);
         }
@@ -5530,7 +5315,7 @@ int ff_generate_avci_extradata(AVStream *st)
 }
 
 uint8_t *av_stream_get_side_data(const AVStream *st,
-                                 enum AVPacketSideDataType type, buffer_size_t *size)
+                                 enum AVPacketSideDataType type, size_t *size)
 {
     int i;
 
@@ -5583,7 +5368,7 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
 }
 
 uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
-                                 buffer_size_t size)
+                                 size_t size)
 {
     int ret;
     uint8_t *data = av_malloc(size);
@@ -5648,64 +5433,6 @@ int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *a
     return 1;
 }
 
-#if FF_API_OLD_BSF
-FF_DISABLE_DEPRECATION_WARNINGS
-int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt,
-                               AVBitStreamFilterContext *bsfc)
-{
-    int ret = 0;
-    while (bsfc) {
-        AVPacket new_pkt = *pkt;
-        int a = av_bitstream_filter_filter(bsfc, codec, NULL,
-                                           &new_pkt.data, &new_pkt.size,
-                                           pkt->data, pkt->size,
-                                           pkt->flags & AV_PKT_FLAG_KEY);
-        if (a == 0 && new_pkt.size == 0 && new_pkt.side_data_elems == 0) {
-            av_packet_unref(pkt);
-            memset(pkt, 0, sizeof(*pkt));
-            return 0;
-        }
-        if(a == 0 && new_pkt.data != pkt->data) {
-            uint8_t *t = av_malloc(new_pkt.size + AV_INPUT_BUFFER_PADDING_SIZE); //the new should be a subset of the old so cannot overflow
-            if (t) {
-                memcpy(t, new_pkt.data, new_pkt.size);
-                memset(t + new_pkt.size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
-                new_pkt.data = t;
-                new_pkt.buf = NULL;
-                a = 1;
-            } else {
-                a = AVERROR(ENOMEM);
-            }
-        }
-        if (a > 0) {
-            new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
-                                           av_buffer_default_free, NULL, 0);
-            if (new_pkt.buf) {
-                pkt->side_data = NULL;
-                pkt->side_data_elems = 0;
-                av_packet_unref(pkt);
-            } else {
-                av_freep(&new_pkt.data);
-                a = AVERROR(ENOMEM);
-            }
-        }
-        if (a < 0) {
-            av_log(codec, AV_LOG_ERROR,
-                   "Failed to open bitstream filter %s for stream %d with codec %s",
-                   bsfc->filter->name, pkt->stream_index,
-                   codec->codec ? codec->codec->name : "copy");
-            ret = a;
-            break;
-        }
-        *pkt = new_pkt;
-
-        bsfc = bsfc->next;
-    }
-    return ret;
-}
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
 int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **options)
 {
     if (!s->oformat)
@@ -5757,7 +5484,7 @@ int ff_standardize_creation_time(AVFormatContext *s)
 int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette)
 {
     uint8_t *side_data;
-    buffer_size_t size;
+    size_t size;
 
     side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size);
     if (side_data) {
@@ -5810,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;
     /*
@@ -5865,9 +5585,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
         enc_ctx->time_base = dec_ctx->time_base;
     }
 
-    if (ost->avg_frame_rate.num)
-        enc_ctx->time_base = av_inv_q(ost->avg_frame_rate);
-
     av_reduce(&enc_ctx->time_base.num, &enc_ctx->time_base.den,
               enc_ctx->time_base.num, enc_ctx->time_base.den, INT_MAX);
 
@@ -5877,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)
@@ -5891,9 +5602,4 @@ void ff_format_set_url(AVFormatContext *s, char *url)
     av_assert0(url);
     av_freep(&s->url);
     s->url = url;
-#if FF_API_FORMAT_FILENAME
-FF_DISABLE_DEPRECATION_WARNINGS
-    av_strlcpy(s->filename, url, sizeof(s->filename));
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
 }