Skip to content

Commit 3749eed

Browse files
committed
avformat: remove deprecated AVStream.codec
Signed-off-by: James Almer <jamrial@gmail.com>
1 parent e5af920 commit 3749eed

File tree

12 files changed

+17
-333
lines changed

12 files changed

+17
-333
lines changed

fftools/ffmpeg_opt.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,19 +2442,6 @@ static int open_output_file(OptionsContext *o, const char *filename)
24422442
avio_closep(&pb);
24432443
}
24442444

2445-
#if FF_API_LAVF_AVCTX
2446-
for (i = nb_output_streams - oc->nb_streams; i < nb_output_streams; i++) { //for all streams of this output file
2447-
AVDictionaryEntry *e;
2448-
ost = output_streams[i];
2449-
2450-
if ((ost->stream_copy || ost->attachment_filename)
2451-
&& (e = av_dict_get(o->g->codec_opts, "flags", NULL, AV_DICT_IGNORE_SUFFIX))
2452-
&& (!e->key[5] || check_stream_specifier(oc, ost->st, e->key+6)))
2453-
if (av_opt_set(ost->st->codec, "flags", e->value, 0) < 0)
2454-
exit_program(1);
2455-
}
2456-
#endif
2457-
24582445
if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
24592446
av_dump_format(oc, nb_output_files - 1, oc->url, 1);
24602447
av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1);

libavformat/avformat.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -839,13 +839,7 @@ typedef struct AVStream {
839839
* encoding: set by the user, replaced by libavformat if left unset
840840
*/
841841
int id;
842-
#if FF_API_LAVF_AVCTX
843-
/**
844-
* @deprecated use the codecpar struct instead
845-
*/
846-
attribute_deprecated
847-
AVCodecContext *codec;
848-
#endif
842+
849843
void *priv_data;
850844

851845
/**
@@ -1837,13 +1831,11 @@ const AVClass *avformat_get_class(void);
18371831
*
18381832
* When muxing, should be called by the user before avformat_write_header().
18391833
*
1840-
* User is required to call avcodec_close() and avformat_free_context() to
1841-
* clean up the allocation by avformat_new_stream().
1834+
* User is required to call avformat_free_context() to clean up the allocation
1835+
* by avformat_new_stream().
18421836
*
18431837
* @param s media file handle
1844-
* @param c If non-NULL, the AVCodecContext corresponding to the new stream
1845-
* will be initialized to use this codec. This is needed for e.g. codec-specific
1846-
* defaults to be set, so codec should be provided if it is known.
1838+
* @param c unused, does nothing
18471839
*
18481840
* @return newly created stream or NULL on error.
18491841
*/

libavformat/dump.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "libavutil/timecode.h"
3838

3939
#include "avformat.h"
40+
#include "internal.h"
4041

4142
#define HEXDUMP_PRINT(...) \
4243
do { \
@@ -522,17 +523,13 @@ static void dump_stream_format(const AVFormatContext *ic, int i,
522523
return;
523524
}
524525

525-
#if FF_API_LAVF_AVCTX
526-
FF_DISABLE_DEPRECATION_WARNINGS
527526
// Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext
528-
avctx->properties = st->codec->properties;
529-
avctx->codec = st->codec->codec;
530-
avctx->qmin = st->codec->qmin;
531-
avctx->qmax = st->codec->qmax;
532-
avctx->coded_width = st->codec->coded_width;
533-
avctx->coded_height = st->codec->coded_height;
534-
FF_ENABLE_DEPRECATION_WARNINGS
535-
#endif
527+
avctx->properties = st->internal->avctx->properties;
528+
avctx->codec = st->internal->avctx->codec;
529+
avctx->qmin = st->internal->avctx->qmin;
530+
avctx->qmax = st->internal->avctx->qmax;
531+
avctx->coded_width = st->internal->avctx->coded_width;
532+
avctx->coded_height = st->internal->avctx->coded_height;
536533

537534
if (separator)
538535
av_opt_set(avctx, "dump_separator", separator, 0);
@@ -567,13 +564,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
567564
int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
568565
int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
569566
int tbn = st->time_base.den && st->time_base.num;
570-
#if FF_API_LAVF_AVCTX
571-
FF_DISABLE_DEPRECATION_WARNINGS
572-
int tbc = st->codec->time_base.den && st->codec->time_base.num;
573-
FF_ENABLE_DEPRECATION_WARNINGS
574-
#else
575567
int tbc = 0;
576-
#endif
577568

578569
if (fps || tbr || tbn || tbc)
579570
av_log(NULL, AV_LOG_INFO, "%s", separator);
@@ -584,12 +575,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
584575
print_fps(av_q2d(st->r_frame_rate), tbn || tbc ? "tbr, " : "tbr");
585576
if (tbn)
586577
print_fps(1 / av_q2d(st->time_base), tbc ? "tbn, " : "tbn");
587-
#if FF_API_LAVF_AVCTX
588-
FF_DISABLE_DEPRECATION_WARNINGS
589-
if (tbc)
590-
print_fps(1 / av_q2d(st->codec->time_base), "tbc");
591-
FF_ENABLE_DEPRECATION_WARNINGS
592-
#endif
593578
}
594579

595580
if (st->disposition & AV_DISPOSITION_DEFAULT)

libavformat/isom.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,22 +329,12 @@ static const AVCodecTag mp4_audio_types[] = {
329329
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
330330
{
331331
enum AVCodecID codec_id;
332-
unsigned v;
333332
int len, tag;
334333
int ret;
335334
int object_type_id = avio_r8(pb);
336335
avio_r8(pb); /* stream type */
337336
avio_rb24(pb); /* buffer size db */
338-
339-
v = avio_rb32(pb);
340-
341-
// TODO: fix this with codecpar
342-
#if FF_API_LAVF_AVCTX
343-
FF_DISABLE_DEPRECATION_WARNINGS
344-
if (v < INT32_MAX)
345-
st->codec->rc_max_rate = v;
346-
FF_ENABLE_DEPRECATION_WARNINGS
347-
#endif
337+
avio_rb32(pb); /* rc_max_rate */
348338

349339
st->codecpar->bit_rate = avio_rb32(pb); /* avg bitrate */
350340

libavformat/mov.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -804,12 +804,6 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
804804
if (st->codecpar->channels > 1 && bsmod == 0x7)
805805
*ast = AV_AUDIO_SERVICE_TYPE_KARAOKE;
806806

807-
#if FF_API_LAVF_AVCTX
808-
FF_DISABLE_DEPRECATION_WARNINGS
809-
st->codec->audio_service_type = *ast;
810-
FF_ENABLE_DEPRECATION_WARNINGS
811-
#endif
812-
813807
return 0;
814808
}
815809

@@ -844,12 +838,6 @@ static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
844838
if (st->codecpar->channels > 1 && bsmod == 0x7)
845839
*ast = AV_AUDIO_SERVICE_TYPE_KARAOKE;
846840

847-
#if FF_API_LAVF_AVCTX
848-
FF_DISABLE_DEPRECATION_WARNINGS
849-
st->codec->audio_service_type = *ast;
850-
FF_ENABLE_DEPRECATION_WARNINGS
851-
#endif
852-
853841
return 0;
854842
}
855843

@@ -2340,11 +2328,6 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
23402328
tmcd_ctx->tmcd_flags = val;
23412329
st->avg_frame_rate.num = AV_RB32(st->codecpar->extradata + 8); /* timescale */
23422330
st->avg_frame_rate.den = AV_RB32(st->codecpar->extradata + 12); /* frameDuration */
2343-
#if FF_API_LAVF_AVCTX
2344-
FF_DISABLE_DEPRECATION_WARNINGS
2345-
st->codec->time_base = av_inv_q(st->avg_frame_rate);
2346-
FF_ENABLE_DEPRECATION_WARNINGS
2347-
#endif
23482331
if (size > 30) {
23492332
uint32_t len = AV_RB32(st->codecpar->extradata + 18); /* name atom length */
23502333
uint32_t format = AV_RB32(st->codecpar->extradata + 22);

libavformat/movenc.c

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,27 +1459,9 @@ static int mov_get_dv_codec_tag(AVFormatContext *s, MOVTrack *track)
14591459
return tag;
14601460
}
14611461

1462-
static AVRational find_fps(AVFormatContext *s, AVStream *st)
1463-
{
1464-
AVRational rate = st->avg_frame_rate;
1465-
1466-
#if FF_API_LAVF_AVCTX
1467-
FF_DISABLE_DEPRECATION_WARNINGS
1468-
rate = av_inv_q(st->codec->time_base);
1469-
if (av_timecode_check_frame_rate(rate) < 0) {
1470-
av_log(s, AV_LOG_DEBUG, "timecode: tbc=%d/%d invalid, fallback on %d/%d\n",
1471-
rate.num, rate.den, st->avg_frame_rate.num, st->avg_frame_rate.den);
1472-
rate = st->avg_frame_rate;
1473-
}
1474-
FF_ENABLE_DEPRECATION_WARNINGS
1475-
#endif
1476-
1477-
return rate;
1478-
}
1479-
14801462
static int defined_frame_rate(AVFormatContext *s, AVStream *st)
14811463
{
1482-
AVRational rational_framerate = find_fps(s, st);
1464+
AVRational rational_framerate = st->avg_frame_rate;
14831465
int rate = 0;
14841466
if (rational_framerate.den != 0)
14851467
rate = av_q2d(rational_framerate);
@@ -2234,13 +2216,6 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
22342216
track->par->codec_id != AV_CODEC_ID_DNXHD) {
22352217
int field_order = track->par->field_order;
22362218

2237-
#if FF_API_LAVF_AVCTX
2238-
FF_DISABLE_DEPRECATION_WARNINGS
2239-
if (field_order != track->st->codec->field_order && track->st->codec->field_order != AV_FIELD_UNKNOWN)
2240-
field_order = track->st->codec->field_order;
2241-
FF_ENABLE_DEPRECATION_WARNINGS
2242-
#endif
2243-
22442219
if (field_order != AV_FIELD_UNKNOWN)
22452220
mov_write_fiel_tag(pb, track, field_order);
22462221
}
@@ -2354,15 +2329,8 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track)
23542329
AVDictionaryEntry *t = NULL;
23552330

23562331
if (!track->st->avg_frame_rate.num || !track->st->avg_frame_rate.den) {
2357-
#if FF_API_LAVF_AVCTX
2358-
FF_DISABLE_DEPRECATION_WARNINGS
2359-
frame_duration = av_rescale(track->timescale, track->st->codec->time_base.num, track->st->codec->time_base.den);
2360-
nb_frames = ROUNDED_DIV(track->st->codec->time_base.den, track->st->codec->time_base.num);
2361-
FF_ENABLE_DEPRECATION_WARNINGS
2362-
#else
23632332
av_log(NULL, AV_LOG_ERROR, "avg_frame_rate not set for tmcd track.\n");
23642333
return AVERROR(EINVAL);
2365-
#endif
23662334
} else {
23672335
frame_duration = av_rescale(track->timescale, track->st->avg_frame_rate.den, track->st->avg_frame_rate.num);
23682336
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_
61996167
int ret;
62006168

62016169
/* compute the frame number */
6202-
ret = av_timecode_init_from_string(tc, find_fps(s, s->streams[src_index]), tcstr, s);
6170+
ret = av_timecode_init_from_string(tc, s->streams[src_index]->avg_frame_rate, tcstr, s);
62036171
return ret;
62046172
}
62056173

@@ -6210,7 +6178,7 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde
62106178
AVStream *src_st = s->streams[src_index];
62116179
uint8_t data[4];
62126180
AVPacket *pkt = mov->pkt;
6213-
AVRational rate = find_fps(s, src_st);
6181+
AVRational rate = src_st->avg_frame_rate;
62146182
int ret;
62156183

62166184
/* tmcd track based on video stream */

libavformat/mux.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,6 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
247247
goto fail;
248248
}
249249

250-
#if FF_API_LAVF_AVCTX
251-
FF_DISABLE_DEPRECATION_WARNINGS
252-
if (s->nb_streams && s->streams[0]->codec->flags & AV_CODEC_FLAG_BITEXACT) {
253-
if (!(s->flags & AVFMT_FLAG_BITEXACT)) {
254-
av_log(s, AV_LOG_WARNING,
255-
"The AVFormatContext is not in set to bitexact mode, only "
256-
"the AVCodecContext. If this is not intended, set "
257-
"AVFormatContext.flags |= AVFMT_FLAG_BITEXACT.\n");
258-
}
259-
}
260-
FF_ENABLE_DEPRECATION_WARNINGS
261-
#endif
262-
263250
// some sanity checks
264251
if (s->nb_streams == 0 && !(of->flags & AVFMT_NOSTREAMS)) {
265252
av_log(s, AV_LOG_ERROR, "No streams to mux were specified\n");
@@ -271,20 +258,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
271258
st = s->streams[i];
272259
par = st->codecpar;
273260

274-
#if FF_API_LAVF_AVCTX
275-
FF_DISABLE_DEPRECATION_WARNINGS
276-
if (st->codecpar->codec_type == AVMEDIA_TYPE_UNKNOWN &&
277-
st->codec->codec_type != AVMEDIA_TYPE_UNKNOWN) {
278-
av_log(s, AV_LOG_WARNING, "Using AVStream.codec to pass codec "
279-
"parameters to muxers is deprecated, use AVStream.codecpar "
280-
"instead.\n");
281-
ret = avcodec_parameters_from_context(st->codecpar, st->codec);
282-
if (ret < 0)
283-
goto fail;
284-
}
285-
FF_ENABLE_DEPRECATION_WARNINGS
286-
#endif
287-
288261
if (!st->time_base.num) {
289262
/* fall back on the default timebase values */
290263
if (par->codec_type == AVMEDIA_TYPE_AUDIO && par->sample_rate)

libavformat/sdp.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -704,24 +704,6 @@ static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int
704704
case AV_CODEC_ID_SPEEX:
705705
av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n",
706706
payload_type, p->sample_rate);
707-
#if FF_API_LAVF_AVCTX
708-
FF_DISABLE_DEPRECATION_WARNINGS
709-
if (st->codec) {
710-
const char *mode;
711-
uint64_t vad_option;
712-
713-
if (st->codec->flags & AV_CODEC_FLAG_QSCALE)
714-
mode = "on";
715-
else if (!av_opt_get_int(st->codec, "vad", AV_OPT_FLAG_ENCODING_PARAM, &vad_option) && vad_option)
716-
mode = "vad";
717-
else
718-
mode = "off";
719-
720-
av_strlcatf(buff, size, "a=fmtp:%d vbr=%s\r\n",
721-
payload_type, mode);
722-
}
723-
FF_ENABLE_DEPRECATION_WARNINGS
724-
#endif
725707
break;
726708
case AV_CODEC_ID_OPUS:
727709
/* The opus RTP draft says that all opus streams MUST be declared

libavformat/segment.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,6 @@ static int segment_mux_init(AVFormatContext *s)
178178
} else {
179179
opar->codec_tag = 0;
180180
}
181-
#if FF_API_LAVF_AVCTX
182-
FF_DISABLE_DEPRECATION_WARNINGS
183-
if (ipar->codec_tag == MKTAG('t','m','c','d'))
184-
st->codec->time_base = ist->codec->time_base;
185-
FF_ENABLE_DEPRECATION_WARNINGS
186-
#endif
187181
}
188182

189183
return 0;

0 commit comments

Comments
 (0)