diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-06-18 11:43:24 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2011-10-19 17:02:11 +0200 |
commit | 84ad31ff180fa089cd6bfd93c246336a16036455 (patch) | |
tree | 13dfd7e1445d6eafda50c6e3dd98030f464579af | |
parent | 3b3bbdd3e63a3a1eaf69b861f72cf74f1669afe1 (diff) | |
download | ffmpeg-84ad31ff180fa089cd6bfd93c246336a16036455.tar.gz |
lavf: replace av_new_stream->avformat_new_stream part II.
Manual replacements are done in this commit.
In many cases, the id is some constant made up number (e.g. 0 for video
and 1 for audio), which is then not used in the demuxer for anything.
Those ids are removed.
35 files changed, 83 insertions, 57 deletions
@@ -3016,7 +3016,7 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type) { OutputStream *ost; - AVStream *st = av_new_stream(oc, oc->nb_streams < o->nb_streamid_map ? o->streamid_map[oc->nb_streams] : 0); + AVStream *st = avformat_new_stream(oc, NULL); int idx = oc->nb_streams - 1, ret = 0; int64_t max_frames = INT64_MAX; char *bsf = NULL, *next, *codec_tag = NULL; @@ -3030,6 +3030,9 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e exit_program(1); } + if (oc->nb_streams - 1 < o->nb_streamid_map) + st->id = o->streamid_map[oc->nb_streams - 1]; + output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams, nb_output_streams + 1); ost = &output_streams[nb_output_streams - 1]; diff --git a/libavformat/4xm.c b/libavformat/4xm.c index 21771348a9..ba4eda351d 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -198,12 +198,13 @@ static int fourxm_read_header(AVFormatContext *s, i += 8 + size; /* allocate a new AVStream */ - st = av_new_stream(s, current_track); + st = avformat_new_stream(s, NULL); if (!st){ ret= AVERROR(ENOMEM); goto fail; } + st->id = current_track; av_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate); fourxm->tracks[current_track].stream_index = st->index; diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index 567baeb8ee..eadb230045 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -505,11 +505,12 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) snprintf(bitrate_str, sizeof(bitrate_str), "%d", v->bandwidth); /* Create new AVStreams for each stream in this variant */ for (j = 0; j < v->ctx->nb_streams; j++) { - AVStream *st = av_new_stream(s, i); + AVStream *st = avformat_new_stream(s, NULL); if (!st) { ret = AVERROR(ENOMEM); goto fail; } + st->id = i; avcodec_copy_context(st->codec, v->ctx->streams[j]->codec); if (v->bandwidth) av_dict_set(&st->metadata, "variant_bitrate", bitrate_str, diff --git a/libavformat/avidec.c b/libavformat/avidec.c index da92353b00..71aa0365d3 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -426,10 +426,11 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) break; }else{ stream_index++; - st = av_new_stream(s, stream_index); + st = avformat_new_stream(s, NULL); if (!st) goto fail; + st->id = stream_index; ast = av_mallocz(sizeof(AVIStream)); if (!ast) goto fail; diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index b615796116..78eb5e6025 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -84,7 +84,8 @@ static int avisynth_read_header(AVFormatContext *s, AVFormatParameters *ap) if (AVIStreamReadFormat(stream->handle, 0, &wvfmt, &struct_size) != S_OK) continue; - st = av_new_stream(s, id); + st = avformat_new_stream(s, NULL); + st->id = id; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->block_align = wvfmt.nBlockAlign; @@ -110,7 +111,8 @@ static int avisynth_read_header(AVFormatContext *s, AVFormatParameters *ap) if (AVIStreamReadFormat(stream->handle, 0, &imgfmt, &struct_size) != S_OK) continue; - st = av_new_stream(s, id); + st = avformat_new_stream(s, NULL); + st->id = id; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->r_frame_rate.num = stream->info.dwRate; st->r_frame_rate.den = stream->info.dwScale; diff --git a/libavformat/avs.c b/libavformat/avs.c index cc0e849bc2..c6ccbb2cd2 100644 --- a/libavformat/avs.c +++ b/libavformat/avs.c @@ -179,7 +179,7 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt) case AVS_VIDEO: if (!avs->st_video) { - avs->st_video = av_new_stream(s, AVS_VIDEO); + avs->st_video = avformat_new_stream(s, NULL); if (avs->st_video == NULL) return AVERROR(ENOMEM); avs->st_video->codec->codec_type = AVMEDIA_TYPE_VIDEO; @@ -196,7 +196,7 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt) case AVS_AUDIO: if (!avs->st_audio) { - avs->st_audio = av_new_stream(s, AVS_AUDIO); + avs->st_audio = avformat_new_stream(s, NULL); if (avs->st_audio == NULL) return AVERROR(ENOMEM); avs->st_audio->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff --git a/libavformat/bink.c b/libavformat/bink.c index 19c4571e00..ea04afdf92 100644 --- a/libavformat/bink.c +++ b/libavformat/bink.c @@ -130,7 +130,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) avio_skip(pb, 4 * bink->num_audio_tracks); for (i = 0; i < bink->num_audio_tracks; i++) { - ast = av_new_stream(s, 1); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff --git a/libavformat/c93.c b/libavformat/c93.c index 9a0eb52234..a47c301a36 100644 --- a/libavformat/c93.c +++ b/libavformat/c93.c @@ -117,7 +117,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) datasize = avio_rl16(pb); if (datasize > 42) { if (!c93->audio) { - c93->audio = av_new_stream(s, 1); + c93->audio = avformat_new_stream(s, NULL); if (!c93->audio) return AVERROR(ENOMEM); c93->audio->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff --git a/libavformat/flic.c b/libavformat/flic.c index c231777963..39c7444964 100644 --- a/libavformat/flic.c +++ b/libavformat/flic.c @@ -145,7 +145,7 @@ static int flic_read_header(AVFormatContext *s, */ if (AV_RL16(&preamble[4]) == FLIC_TFTD_CHUNK_AUDIO) { /* TFTD videos have an extra 22050 Hz 8-bit mono audio stream */ - ast = av_new_stream(s, 1); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index d2f3f51d28..5e354b11be 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -354,9 +354,10 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) { } static AVStream *create_stream(AVFormatContext *s, int is_audio){ - AVStream *st = av_new_stream(s, is_audio); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return NULL; + st->id = is_audio; st->codec->codec_type = is_audio ? AVMEDIA_TYPE_AUDIO : AVMEDIA_TYPE_VIDEO; av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ return st; diff --git a/libavformat/gxf.c b/libavformat/gxf.c index 8077d809b3..283e3a6246 100644 --- a/libavformat/gxf.c +++ b/libavformat/gxf.c @@ -81,9 +81,10 @@ static int get_sindex(AVFormatContext *s, int id, int format) { i = ff_find_stream_index(s, id); if (i >= 0) return i; - st = av_new_stream(s, id); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); + st->id = id; switch (format) { case 3: case 4: diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c index 88770345ae..f1c1acca8b 100644 --- a/libavformat/idroqdec.c +++ b/libavformat/idroqdec.c @@ -166,7 +166,7 @@ static int roq_read_packet(AVFormatContext *s, case RoQ_SOUND_MONO: case RoQ_SOUND_STEREO: if (roq->audio_stream_index == -1) { - AVStream *st = av_new_stream(s, 1); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE); diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c index 908a9261d9..42a4dbf4cc 100644 --- a/libavformat/jvdec.c +++ b/libavformat/jvdec.c @@ -70,7 +70,7 @@ static int read_header(AVFormatContext *s, avio_skip(pb, 80); ast = avformat_new_stream(s, NULL); - vst = av_new_stream(s, 1); + vst = avformat_new_stream(s, NULL); if (!ast || !vst) return AVERROR(ENOMEM); diff --git a/libavformat/libnut.c b/libavformat/libnut.c index a618c53903..fbf9f2ac67 100644 --- a/libavformat/libnut.c +++ b/libavformat/libnut.c @@ -213,7 +213,7 @@ static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) { priv->s = s; for (i = 0; s[i].type != -1 && i < 2; i++) { - AVStream * st = av_new_stream(avf, i); + AVStream * st = avformat_new_stream(avf, NULL); int j; for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[i].fourcc[j]<<(j*8); diff --git a/libavformat/lmlm4.c b/libavformat/lmlm4.c index 7945cb1a4c..db3bf2875f 100644 --- a/libavformat/lmlm4.c +++ b/libavformat/lmlm4.c @@ -67,7 +67,7 @@ static int lmlm4_read_header(AVFormatContext *s, AVFormatParameters *ap) { st->need_parsing = AVSTREAM_PARSE_HEADERS; av_set_pts_info(st, 64, 1001, 30000); - if (!(st = av_new_stream(s, 1))) + if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_MP2; diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c index 1ab345e79f..cfa4f970ad 100644 --- a/libavformat/lxfdec.c +++ b/libavformat/lxfdec.c @@ -243,7 +243,7 @@ static int lxf_read_header(AVFormatContext *s, AVFormatParameters *ap) av_log(s, AV_LOG_WARNING, "VBI data not yet supported\n"); if ((lxf->channels = (disk_params >> 2) & 0xF)) { - if (!(st = av_new_stream(s, 1))) + if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff --git a/libavformat/mov.c b/libavformat/mov.c index 144fdb9a15..d93969ce2a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1793,8 +1793,9 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) MOVStreamContext *sc; int ret; - st = av_new_stream(c->fc, c->fc->nb_streams); + st = avformat_new_stream(c->fc, NULL); if (!st) return AVERROR(ENOMEM); + st->id = c->fc->nb_streams; sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 52bf40faa5..982903829f 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -532,9 +532,10 @@ static int mpegps_read_packet(AVFormatContext *s, goto redo; } /* no stream found: add a new stream */ - st = av_new_stream(s, startcode); + st = avformat_new_stream(s, NULL); if (!st) goto skip; + st->id = startcode; st->codec->codec_type = type; st->codec->codec_id = codec_id; if (codec_id != CODEC_ID_PCM_S16BE) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 5d1b296ca5..b7814e59c9 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -598,12 +598,13 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, return AVERROR(ENOMEM); memcpy(sub_pes, pes, sizeof(*sub_pes)); - sub_st = av_new_stream(pes->stream, pes->pid); + sub_st = avformat_new_stream(pes->stream, NULL); if (!sub_st) { av_free(sub_pes); return AVERROR(ENOMEM); } + sub_st->id = pes->pid; av_set_pts_info(sub_st, 33, 1, 90000); sub_st->priv_data = sub_pes; sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO; @@ -700,9 +701,10 @@ static int mpegts_push_data(MpegTSFilter *filter, /* stream not present in PMT */ if (!pes->st) { - pes->st = av_new_stream(ts->stream, pes->pid); + pes->st = avformat_new_stream(ts->stream, NULL); if (!pes->st) return AVERROR(ENOMEM); + pes->st->id = pes->pid; mpegts_set_stream_info(pes->st, pes, 0, 0); } @@ -1090,14 +1092,18 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len /* now create ffmpeg stream */ if (ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES) { pes = ts->pids[pid]->u.pes_filter.opaque; - if (!pes->st) - pes->st = av_new_stream(pes->stream, pes->pid); + if (!pes->st) { + pes->st = avformat_new_stream(pes->stream, NULL); + st->id = pes->pid; + } st = pes->st; } else { if (ts->pids[pid]) mpegts_close_filter(ts, ts->pids[pid]); //wrongly added sdt filter probably pes = add_pes_stream(ts, pid, pcr_pid); - if (pes) - st = av_new_stream(pes->stream, pes->pid); + if (pes) { + st = avformat_new_stream(pes->stream, NULL); + st->id = pes->pid; + } } if (!st) diff --git a/libavformat/mtv.c b/libavformat/mtv.c index 59f13fe704..16e4c90eeb 100644 --- a/libavformat/mtv.c +++ b/libavformat/mtv.c @@ -32,8 +32,6 @@ #define MTV_HEADER_SIZE 512 #define MTV_AUDIO_PADDING_SIZE 12 #define AUDIO_SAMPLING_RATE 44100 -#define VIDEO_SID 0 -#define AUDIO_SID 1 typedef struct MTVDemuxContext { @@ -118,7 +116,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap) // video - raw rgb565 - st = av_new_stream(s, VIDEO_SID); + st = avformat_new_stream(s, NULL); if(!st) return AVERROR(ENOMEM); @@ -134,7 +132,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap) // audio - mp3 - st = av_new_stream(s, AUDIO_SID); + st = avformat_new_stream(s, NULL); if(!st) return AVERROR(ENOMEM); @@ -171,7 +169,7 @@ static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt) return ret; pkt->pos -= MTV_AUDIO_PADDING_SIZE; - pkt->stream_index = AUDIO_SID; + pkt->stream_index = 1; }else { @@ -190,7 +188,7 @@ static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt) for(i=0;i<mtv->img_segment_size/2;i++) *((uint16_t *)pkt->data+i) = av_bswap16(*((uint16_t *)pkt->data+i)); #endif - pkt->stream_index = VIDEO_SID; + pkt->stream_index = 0; } return ret; diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index d0a8a3afe2..76a8329766 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -746,11 +746,12 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) if (!source_track) continue; - st = av_new_stream(mxf->fc, source_track->track_id); + st = avformat_new_stream(mxf->fc, NULL); if (!st) { av_log(mxf->fc, AV_LOG_ERROR, "could not allocate stream\n"); return -1; } + st->id = source_track->track_id; st->priv_data = source_track; st->duration = component->duration; if (st->duration == -1) diff --git a/libavformat/mxg.c b/libavformat/mxg.c index 5caa68a667..2b69f7204f 100644 --- a/libavformat/mxg.c +++ b/libavformat/mxg.c @@ -24,8 +24,6 @@ #include "avformat.h" #include "avio.h" -#define VIDEO_STREAM_INDEX 0 -#define AUDIO_STREAM_INDEX 1 #define DEFAULT_PACKET_SIZE 1024 #define OVERREAD_SIZE 3 @@ -44,14 +42,14 @@ static int mxg_read_header(AVFormatContext *s, AVFormatParameters *ap) MXGContext *mxg = s->priv_data; /* video parameters will be extracted from the compressed bitstream */ - video_st = av_new_stream(s, VIDEO_STREAM_INDEX); + video_st = avformat_new_stream(s, NULL); if (!video_st) return AVERROR(ENOMEM); video_st->codec->codec_type = AVMEDIA_TYPE_VIDEO; video_st->codec->codec_id = CODEC_ID_MXPEG; av_set_pts_info(video_st, 64, 1, 1000000); - audio_st = av_new_stream(s, AUDIO_STREAM_INDEX); + audio_st = avformat_new_stream(s, NULL); if (!audio_st) return AVERROR(ENOMEM); audio_st->codec->codec_type = AVMEDIA_TYPE_AUDIO; @@ -166,7 +164,7 @@ static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt) } pkt->pts = pkt->dts = mxg->dts; - pkt->stream_index = VIDEO_STREAM_INDEX; + pkt->stream_index = 0; pkt->destruct = NULL; pkt->size = mxg->buffer_ptr - mxg->soi_ptr; pkt->data = mxg->soi_ptr; @@ -204,7 +202,7 @@ static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt) if (marker == APP13 && size >= 16) { /* audio data */ /* time (GMT) of first sample in usec since 1970, little-endian */ pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8); - pkt->stream_index = AUDIO_STREAM_INDEX; + pkt->stream_index = 1; pkt->destruct = NULL; pkt->size = size - 14; pkt->data = startmarker_ptr + 16; diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index 08c4b10362..84957c6a7a 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -437,10 +437,11 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) nsv->vheight = vwidth; if (vtag != T_NONE) { int i; - st = av_new_stream(s, NSV_ST_VIDEO); + st = avformat_new_stream(s, NULL); if (!st) goto fail; + st->id = NSV_ST_VIDEO; nst = av_mallocz(sizeof(NSVStream)); if (!nst) goto fail; @@ -468,10 +469,11 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) } if (atag != T_NONE) { #ifndef DISABLE_AUDIO - st = av_new_stream(s, NSV_ST_AUDIO); + st = avformat_new_stream(s, NULL); if (!st) goto fail; + st->id = NSV_ST_AUDIO; nst = av_mallocz(sizeof(NSVStream)); if (!nst) goto fail; diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 493ca7efc0..730d6884cf 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -288,7 +288,7 @@ static int decode_main_header(NUTContext *nut){ nut->stream = av_mallocz(sizeof(StreamContext)*stream_count); for(i=0; i<stream_count; i++){ - av_new_stream(s, i); + avformat_new_stream(s, NULL); } return 0; diff --git a/libavformat/nuv.c b/libavformat/nuv.c index 36ec8fa093..f9ab6b7045 100644 --- a/libavformat/nuv.c +++ b/libavformat/nuv.c @@ -153,7 +153,7 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) { if (v_packs) { ctx->v_id = stream_nr++; - vst = av_new_stream(s, ctx->v_id); + vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; @@ -169,7 +169,7 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) { if (a_packs) { ctx->a_id = stream_nr++; - ast = av_new_stream(s, ctx->a_id); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 1fa8b09d13..7fd50a5590 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -172,10 +172,11 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream) os->header = -1; if (new_avstream) { - st = av_new_stream(s, idx); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); + st->id = idx; av_set_pts_info(st, 64, 1, 1000000); } diff --git a/libavformat/pva.c b/libavformat/pva.c index d045c29c4d..55883d7e9d 100644 --- a/libavformat/pva.c +++ b/libavformat/pva.c @@ -51,7 +51,7 @@ static int pva_read_header(AVFormatContext *s, AVFormatParameters *ap) { av_set_pts_info(st, 32, 1, 90000); av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME); - if (!(st = av_new_stream(s, 1))) + if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_MP2; diff --git a/libavformat/r3d.c b/libavformat/r3d.c index 8e632c99f1..11d450544a 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -89,7 +89,7 @@ static int r3d_read_red1(AVFormatContext *s) tmp = avio_r8(s->pb); // audio channels av_dlog(s, "audio channels %d\n", tmp); if (tmp > 0) { - AVStream *ast = av_new_stream(s, 1); + AVStream *ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff --git a/libavformat/rdt.c b/libavformat/rdt.c index 9155cfc480..3f161f618c 100644 --- a/libavformat/rdt.c +++ b/libavformat/rdt.c @@ -459,8 +459,9 @@ add_dstream(AVFormatContext *s, AVStream *orig_st) { AVStream *st; - if (!(st = av_new_stream(s, orig_st->id))) + if (!(st = avformat_new_stream(s, NULL))) return NULL; + st->id = orig_st->id; st->codec->codec_type = orig_st->codec->codec_type; st->first_dts = orig_st->first_dts; diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 678594714f..5aadc4430a 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -357,9 +357,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), "MP2T")) { /* no corresponding stream */ } else { - st = av_new_stream(s, rt->nb_rtsp_streams - 1); + st = avformat_new_stream(s, NULL); if (!st) return; + st->id = rt->nb_rtsp_streams - 1; rtsp_st->stream_index = st->index; st->codec->codec_type = codec_type; if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) { diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index c317821772..84a9eb17b3 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -163,11 +163,12 @@ static int sap_read_header(AVFormatContext *s, if (sap->sdp_ctx->ctx_flags & AVFMTCTX_NOHEADER) s->ctx_flags |= AVFMTCTX_NOHEADER; for (i = 0; i < sap->sdp_ctx->nb_streams; i++) { - AVStream *st = av_new_stream(s, i); + AVStream *st = avformat_new_stream(s, NULL); if (!st) { ret = AVERROR(ENOMEM); goto fail; } + st->id = i; avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec); st->time_base = sap->sdp_ctx->streams[i]->time_base; } @@ -211,11 +212,12 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt) if (s->ctx_flags & AVFMTCTX_NOHEADER) { while (sap->sdp_ctx->nb_streams > s->nb_streams) { int i = s->nb_streams; - AVStream *st = av_new_stream(s, i); + AVStream *st = avformat_new_stream(s, NULL); if (!st) { av_free_packet(pkt); return AVERROR(ENOMEM); } + st->id = i; avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec); st->time_base = sap->sdp_ctx->streams[i]->time_base; } diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index 502647f9a2..ac3d86c51c 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -106,9 +106,10 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) avio_rl16(pb); avio_r8(pb); /* Check for FLV1 */ - vst = av_new_stream(s, ch_id); + vst = avformat_new_stream(s, NULL); if (!vst) return -1; + vst->id = ch_id; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, avio_r8(pb)); av_set_pts_info(vst, 16, 256, swf->frame_rate); @@ -127,9 +128,10 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) avio_r8(pb); v = avio_r8(pb); swf->samples_per_frame = avio_rl16(pb); - ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */ + ast = avformat_new_stream(s, NULL); if (!ast) return -1; + ast->id = -1; /* -1 to avoid clash with video stream ch_id */ ast->codec->channels = 1 + (v&1); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id = ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15); @@ -177,9 +179,10 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) break; } if (i == s->nb_streams) { - vst = av_new_stream(s, -2); /* -2 to avoid clash with video stream and audio stream */ + vst = avformat_new_stream(s, NULL); if (!vst) return -1; + vst->id = -2; /* -2 to avoid clash with video stream and audio stream */ vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_MJPEG; av_set_pts_info(vst, 64, 256, swf->frame_rate); diff --git a/libavformat/wtv.c b/libavformat/wtv.c index c3cd5ebcda..4defc14e3c 100644 --- a/libavformat/wtv.c +++ b/libavformat/wtv.c @@ -626,9 +626,10 @@ static AVStream * new_stream(AVFormatContext *s, AVStream *st, int sid, int code WtvStream *wst = av_mallocz(sizeof(WtvStream)); if (!wst) return NULL; - st = av_new_stream(s, sid); + st = avformat_new_stream(s, NULL); if (!st) return NULL; + st->id = sid; st->priv_data = wst; } st->codec->codec_type = codec_type; diff --git a/libavformat/xmv.c b/libavformat/xmv.c index 9c47193beb..30e3b5ade9 100644 --- a/libavformat/xmv.c +++ b/libavformat/xmv.c @@ -211,7 +211,7 @@ static int xmv_read_header(AVFormatContext *s, av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream " "(0x%04X)\n", track->flags); - ast = av_new_stream(s, audio_track); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); diff --git a/libavformat/yop.c b/libavformat/yop.c index 72004bf8fe..c9bf9f8c4a 100644 --- a/libavformat/yop.c +++ b/libavformat/yop.c @@ -57,7 +57,7 @@ static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap) int frame_rate, ret; audio_stream = avformat_new_stream(s, NULL); - video_stream = av_new_stream(s, 1); + video_stream = avformat_new_stream(s, NULL); // Extra data that will be passed to the decoder video_stream->codec->extradata_size = 8; |