History

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.

Anton Khirnov committed 15 years ago

Commit 84ad31f1 parent 3b3bbdd35 files · +83 −57Browse files

Unified · Split

35 files
  1. avconv.c +4 −1
  2. libavformat/4xm.c +2 −1
  3. libavformat/applehttp.c +2 −1
  4. libavformat/avidec.c +2 −1
  5. libavformat/avisynth.c +4 −2
  6. libavformat/avs.c +2 −2
  7. libavformat/bink.c +1 −1
  8. libavformat/c93.c +1 −1
  9. libavformat/flic.c +1 −1
  10. libavformat/flvdec.c +2 −1
  11. libavformat/gxf.c +2 −1
  12. libavformat/idroqdec.c +1 −1
  13. libavformat/jvdec.c +1 −1
  14. libavformat/libnut.c +1 −1
  15. libavformat/lmlm4.c +1 −1
  16. libavformat/lxfdec.c +1 −1
  17. libavformat/mov.c +2 −1
  18. libavformat/mpeg.c +2 −1
  19. libavformat/mpegts.c +12 −6
  20. libavformat/mtv.c +4 −6
  21. libavformat/mxfdec.c +2 −1
  22. libavformat/mxg.c +4 −6
  23. libavformat/nsvdec.c +4 −2
  24. libavformat/nutdec.c +1 −1
  25. libavformat/nuv.c +2 −2
  26. libavformat/oggdec.c +2 −1
  27. libavformat/pva.c +1 −1
  28. libavformat/r3d.c +1 −1
  29. libavformat/rdt.c +2 −1
  30. libavformat/rtsp.c +2 −1
  31. libavformat/sapdec.c +4 −2
  32. libavformat/swfdec.c +6 −3
  33. libavformat/wtv.c +2 −1
  34. libavformat/xmv.c +1 −1
  35. libavformat/yop.c +1 −1
avconv.c+4−1
@@ -3016,7 +3016,7 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV · 3015 unmodified lines
3016static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)3016static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
3017{3017{
3018 OutputStream *ost;3018 OutputStream *ost;
3019 AVStream *st = av_new_stream(oc, oc->nb_streams < o->nb_streamid_map ? o->streamid_map[oc->nb_streams] : 0);3019 AVStream *st = avformat_new_stream(oc, NULL);
3020 int idx = oc->nb_streams - 1, ret = 0;3020 int idx = oc->nb_streams - 1, ret = 0;
3021 int64_t max_frames = INT64_MAX;3021 int64_t max_frames = INT64_MAX;
3022 char *bsf = NULL, *next, *codec_tag = NULL;3022 char *bsf = NULL, *next, *codec_tag = NULL;
@@ -3030,6 +3030,9 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e · 7 unmodified lines
3030 exit_program(1);3030 exit_program(1);
3031 }3031 }
3032 3032
3033 if (oc->nb_streams - 1 < o->nb_streamid_map)
3034 st->id = o->streamid_map[oc->nb_streams - 1];
3035
3033 output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams,3036 output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams,
3034 nb_output_streams + 1);3037 nb_output_streams + 1);
3035 ost = &output_streams[nb_output_streams - 1];3038 ost = &output_streams[nb_output_streams - 1];
libavformat/4xm.c+2−1
@@ -198,12 +198,13 @@ static int fourxm_read_header(AVFormatContext *s, · 197 unmodified lines
198 i += 8 + size;198 i += 8 + size;
199 199
200 /* allocate a new AVStream */200 /* allocate a new AVStream */
201 st = av_new_stream(s, current_track);201 st = avformat_new_stream(s, NULL);
202 if (!st){202 if (!st){
203 ret= AVERROR(ENOMEM);203 ret= AVERROR(ENOMEM);
204 goto fail;204 goto fail;
205 }205 }
206 206
207 st->id = current_track;
207 av_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate);208 av_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate);
208 209
209 fourxm->tracks[current_track].stream_index = st->index;210 fourxm->tracks[current_track].stream_index = st->index;
libavformat/applehttp.c+2−1
@@ -505,11 +505,12 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) · 504 unmodified lines
505 snprintf(bitrate_str, sizeof(bitrate_str), "%d", v->bandwidth);505 snprintf(bitrate_str, sizeof(bitrate_str), "%d", v->bandwidth);
506 /* Create new AVStreams for each stream in this variant */506 /* Create new AVStreams for each stream in this variant */
507 for (j = 0; j < v->ctx->nb_streams; j++) {507 for (j = 0; j < v->ctx->nb_streams; j++) {
508 AVStream *st = av_new_stream(s, i);508 AVStream *st = avformat_new_stream(s, NULL);
509 if (!st) {509 if (!st) {
510 ret = AVERROR(ENOMEM);510 ret = AVERROR(ENOMEM);
511 goto fail;511 goto fail;
512 }512 }
513 st->id = i;
513 avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);514 avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);
514 if (v->bandwidth)515 if (v->bandwidth)
515 av_dict_set(&st->metadata, "variant_bitrate", bitrate_str,516 av_dict_set(&st->metadata, "variant_bitrate", bitrate_str,
libavformat/avidec.c+2−1
@@ -426,10 +426,11 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) · 425 unmodified lines
426 break;426 break;
427 }else{427 }else{
428 stream_index++;428 stream_index++;
429 st = av_new_stream(s, stream_index);429 st = avformat_new_stream(s, NULL);
430 if (!st)430 if (!st)
431 goto fail;431 goto fail;
432 432
433 st->id = stream_index;
433 ast = av_mallocz(sizeof(AVIStream));434 ast = av_mallocz(sizeof(AVIStream));
434 if (!ast)435 if (!ast)
435 goto fail;436 goto fail;
libavformat/avisynth.c+4−2
@@ -84,7 +84,8 @@ static int avisynth_read_header(AVFormatContext *s, AVFormatParameters *ap) · 83 unmodified lines
84 if (AVIStreamReadFormat(stream->handle, 0, &wvfmt, &struct_size) != S_OK)84 if (AVIStreamReadFormat(stream->handle, 0, &wvfmt, &struct_size) != S_OK)
85 continue;85 continue;
86 86
87 st = av_new_stream(s, id);87 st = avformat_new_stream(s, NULL);
88 st->id = id;
88 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;89 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
89 90
90 st->codec->block_align = wvfmt.nBlockAlign;91 st->codec->block_align = wvfmt.nBlockAlign;
@@ -110,7 +111,8 @@ static int avisynth_read_header(AVFormatContext *s, AVFormatParameters *ap) · 19 unmodified lines
110 if (AVIStreamReadFormat(stream->handle, 0, &imgfmt, &struct_size) != S_OK)111 if (AVIStreamReadFormat(stream->handle, 0, &imgfmt, &struct_size) != S_OK)
111 continue;112 continue;
112 113
113 st = av_new_stream(s, id);114 st = avformat_new_stream(s, NULL);
115 st->id = id;
114 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;116 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
115 st->r_frame_rate.num = stream->info.dwRate;117 st->r_frame_rate.num = stream->info.dwRate;
116 st->r_frame_rate.den = stream->info.dwScale;118 st->r_frame_rate.den = stream->info.dwScale;
libavformat/avs.c+2−2
@@ -179,7 +179,7 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt) · 178 unmodified lines
179 179
180 case AVS_VIDEO:180 case AVS_VIDEO:
181 if (!avs->st_video) {181 if (!avs->st_video) {
182 avs->st_video = av_new_stream(s, AVS_VIDEO);182 avs->st_video = avformat_new_stream(s, NULL);
183 if (avs->st_video == NULL)183 if (avs->st_video == NULL)
184 return AVERROR(ENOMEM);184 return AVERROR(ENOMEM);
185 avs->st_video->codec->codec_type = AVMEDIA_TYPE_VIDEO;185 avs->st_video->codec->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -196,7 +196,7 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt) · 10 unmodified lines
196 196
197 case AVS_AUDIO:197 case AVS_AUDIO:
198 if (!avs->st_audio) {198 if (!avs->st_audio) {
199 avs->st_audio = av_new_stream(s, AVS_AUDIO);199 avs->st_audio = avformat_new_stream(s, NULL);
200 if (avs->st_audio == NULL)200 if (avs->st_audio == NULL)
201 return AVERROR(ENOMEM);201 return AVERROR(ENOMEM);
202 avs->st_audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;202 avs->st_audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
libavformat/bink.c+1−1
@@ -130,7 +130,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) · 129 unmodified lines
130 avio_skip(pb, 4 * bink->num_audio_tracks);130 avio_skip(pb, 4 * bink->num_audio_tracks);
131 131
132 for (i = 0; i < bink->num_audio_tracks; i++) {132 for (i = 0; i < bink->num_audio_tracks; i++) {
133 ast = av_new_stream(s, 1);133 ast = avformat_new_stream(s, NULL);
134 if (!ast)134 if (!ast)
135 return AVERROR(ENOMEM);135 return AVERROR(ENOMEM);
136 ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;136 ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
libavformat/c93.c+1−1
@@ -117,7 +117,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 116 unmodified lines
117 datasize = avio_rl16(pb);117 datasize = avio_rl16(pb);
118 if (datasize > 42) {118 if (datasize > 42) {
119 if (!c93->audio) {119 if (!c93->audio) {
120 c93->audio = av_new_stream(s, 1);120 c93->audio = avformat_new_stream(s, NULL);
121 if (!c93->audio)121 if (!c93->audio)
122 return AVERROR(ENOMEM);122 return AVERROR(ENOMEM);
123 c93->audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;123 c93->audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
libavformat/flic.c+1−1
@@ -145,7 +145,7 @@ static int flic_read_header(AVFormatContext *s, · 144 unmodified lines
145 */145 */
146 if (AV_RL16(&preamble[4]) == FLIC_TFTD_CHUNK_AUDIO) {146 if (AV_RL16(&preamble[4]) == FLIC_TFTD_CHUNK_AUDIO) {
147 /* TFTD videos have an extra 22050 Hz 8-bit mono audio stream */147 /* TFTD videos have an extra 22050 Hz 8-bit mono audio stream */
148 ast = av_new_stream(s, 1);148 ast = avformat_new_stream(s, NULL);
149 if (!ast)149 if (!ast)
150 return AVERROR(ENOMEM);150 return AVERROR(ENOMEM);
151 151
libavformat/flvdec.c+2−1
@@ -354,9 +354,10 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) { · 353 unmodified lines
354}354}
355 355
356static AVStream *create_stream(AVFormatContext *s, int is_audio){356static AVStream *create_stream(AVFormatContext *s, int is_audio){
357 AVStream *st = av_new_stream(s, is_audio);357 AVStream *st = avformat_new_stream(s, NULL);
358 if (!st)358 if (!st)
359 return NULL;359 return NULL;
360 st->id = is_audio;
360 st->codec->codec_type = is_audio ? AVMEDIA_TYPE_AUDIO : AVMEDIA_TYPE_VIDEO;361 st->codec->codec_type = is_audio ? AVMEDIA_TYPE_AUDIO : AVMEDIA_TYPE_VIDEO;
361 av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */362 av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
362 return st;363 return st;
libavformat/gxf.c+2−1
@@ -81,9 +81,10 @@ static int get_sindex(AVFormatContext *s, int id, int format) { · 80 unmodified lines
81 i = ff_find_stream_index(s, id);81 i = ff_find_stream_index(s, id);
82 if (i >= 0)82 if (i >= 0)
83 return i;83 return i;
84 st = av_new_stream(s, id);84 st = avformat_new_stream(s, NULL);
85 if (!st)85 if (!st)
86 return AVERROR(ENOMEM);86 return AVERROR(ENOMEM);
87 st->id = id;
87 switch (format) {88 switch (format) {
88 case 3:89 case 3:
89 case 4:90 case 4:
libavformat/idroqdec.c+1−1
@@ -166,7 +166,7 @@ static int roq_read_packet(AVFormatContext *s, · 165 unmodified lines
166 case RoQ_SOUND_MONO:166 case RoQ_SOUND_MONO:
167 case RoQ_SOUND_STEREO:167 case RoQ_SOUND_STEREO:
168 if (roq->audio_stream_index == -1) {168 if (roq->audio_stream_index == -1) {
169 AVStream *st = av_new_stream(s, 1);169 AVStream *st = avformat_new_stream(s, NULL);
170 if (!st)170 if (!st)
171 return AVERROR(ENOMEM);171 return AVERROR(ENOMEM);
172 av_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE);172 av_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE);
libavformat/jvdec.c+1−1
@@ -70,7 +70,7 @@ static int read_header(AVFormatContext *s, · 69 unmodified lines
70 avio_skip(pb, 80);70 avio_skip(pb, 80);
71 71
72 ast = avformat_new_stream(s, NULL);72 ast = avformat_new_stream(s, NULL);
73 vst = av_new_stream(s, 1);73 vst = avformat_new_stream(s, NULL);
74 if (!ast || !vst)74 if (!ast || !vst)
75 return AVERROR(ENOMEM);75 return AVERROR(ENOMEM);
76 76
libavformat/libnut.c+1−1
@@ -213,7 +213,7 @@ static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) { · 212 unmodified lines
213 priv->s = s;213 priv->s = s;
214 214
215 for (i = 0; s[i].type != -1 && i < 2; i++) {215 for (i = 0; s[i].type != -1 && i < 2; i++) {
216 AVStream * st = av_new_stream(avf, i);216 AVStream * st = avformat_new_stream(avf, NULL);
217 int j;217 int j;
218 218
219 for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[i].fourcc[j]<<(j*8);219 for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[i].fourcc[j]<<(j*8);
libavformat/lmlm4.c+1−1
@@ -67,7 +67,7 @@ static int lmlm4_read_header(AVFormatContext *s, AVFormatParameters *ap) { · 66 unmodified lines
67 st->need_parsing = AVSTREAM_PARSE_HEADERS;67 st->need_parsing = AVSTREAM_PARSE_HEADERS;
68 av_set_pts_info(st, 64, 1001, 30000);68 av_set_pts_info(st, 64, 1001, 30000);
69 69
70 if (!(st = av_new_stream(s, 1)))70 if (!(st = avformat_new_stream(s, NULL)))
71 return AVERROR(ENOMEM);71 return AVERROR(ENOMEM);
72 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;72 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
73 st->codec->codec_id = CODEC_ID_MP2;73 st->codec->codec_id = CODEC_ID_MP2;
libavformat/lxfdec.c+1−1
@@ -243,7 +243,7 @@ static int lxf_read_header(AVFormatContext *s, AVFormatParameters *ap) · 242 unmodified lines
243 av_log(s, AV_LOG_WARNING, "VBI data not yet supported\n");243 av_log(s, AV_LOG_WARNING, "VBI data not yet supported\n");
244 244
245 if ((lxf->channels = (disk_params >> 2) & 0xF)) {245 if ((lxf->channels = (disk_params >> 2) & 0xF)) {
246 if (!(st = av_new_stream(s, 1)))246 if (!(st = avformat_new_stream(s, NULL)))
247 return AVERROR(ENOMEM);247 return AVERROR(ENOMEM);
248 248
249 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;249 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
libavformat/mov.c+2−1
@@ -1793,8 +1793,9 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 1792 unmodified lines
1793 MOVStreamContext *sc;1793 MOVStreamContext *sc;
1794 int ret;1794 int ret;
1795 1795
1796 st = av_new_stream(c->fc, c->fc->nb_streams);1796 st = avformat_new_stream(c->fc, NULL);
1797 if (!st) return AVERROR(ENOMEM);1797 if (!st) return AVERROR(ENOMEM);
1798 st->id = c->fc->nb_streams;
1798 sc = av_mallocz(sizeof(MOVStreamContext));1799 sc = av_mallocz(sizeof(MOVStreamContext));
1799 if (!sc) return AVERROR(ENOMEM);1800 if (!sc) return AVERROR(ENOMEM);
1800 1801
libavformat/mpeg.c+2−1
@@ -532,9 +532,10 @@ static int mpegps_read_packet(AVFormatContext *s, · 531 unmodified lines
532 goto redo;532 goto redo;
533 }533 }
534 /* no stream found: add a new stream */534 /* no stream found: add a new stream */
535 st = av_new_stream(s, startcode);535 st = avformat_new_stream(s, NULL);
536 if (!st)536 if (!st)
537 goto skip;537 goto skip;
538 st->id = startcode;
538 st->codec->codec_type = type;539 st->codec->codec_type = type;
539 st->codec->codec_id = codec_id;540 st->codec->codec_id = codec_id;
540 if (codec_id != CODEC_ID_PCM_S16BE)541 if (codec_id != CODEC_ID_PCM_S16BE)
libavformat/mpegts.c+12−6
@@ -598,12 +598,13 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, · 597 unmodified lines
598 return AVERROR(ENOMEM);598 return AVERROR(ENOMEM);
599 memcpy(sub_pes, pes, sizeof(*sub_pes));599 memcpy(sub_pes, pes, sizeof(*sub_pes));
600 600
601 sub_st = av_new_stream(pes->stream, pes->pid);601 sub_st = avformat_new_stream(pes->stream, NULL);
602 if (!sub_st) {602 if (!sub_st) {
603 av_free(sub_pes);603 av_free(sub_pes);
604 return AVERROR(ENOMEM);604 return AVERROR(ENOMEM);
605 }605 }
606 606
607 sub_st->id = pes->pid;
607 av_set_pts_info(sub_st, 33, 1, 90000);608 av_set_pts_info(sub_st, 33, 1, 90000);
608 sub_st->priv_data = sub_pes;609 sub_st->priv_data = sub_pes;
609 sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;610 sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -700,9 +701,10 @@ static int mpegts_push_data(MpegTSFilter *filter, · 90 unmodified lines
700 701
701 /* stream not present in PMT */702 /* stream not present in PMT */
702 if (!pes->st) {703 if (!pes->st) {
703 pes->st = av_new_stream(ts->stream, pes->pid);704 pes->st = avformat_new_stream(ts->stream, NULL);
704 if (!pes->st)705 if (!pes->st)
705 return AVERROR(ENOMEM);706 return AVERROR(ENOMEM);
707 pes->st->id = pes->pid;
706 mpegts_set_stream_info(pes->st, pes, 0, 0);708 mpegts_set_stream_info(pes->st, pes, 0, 0);
707 }709 }
708 710
@@ -1090,14 +1092,18 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len · 381 unmodified lines
1090 /* now create ffmpeg stream */1092 /* now create ffmpeg stream */
1091 if (ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES) {1093 if (ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES) {
1092 pes = ts->pids[pid]->u.pes_filter.opaque;1094 pes = ts->pids[pid]->u.pes_filter.opaque;
1093 if (!pes->st)1095 if (!pes->st) {
1094 pes->st = av_new_stream(pes->stream, pes->pid);1096 pes->st = avformat_new_stream(pes->stream, NULL);
1097 st->id = pes->pid;
1098 }
1095 st = pes->st;1099 st = pes->st;
1096 } else {1100 } else {
1097 if (ts->pids[pid]) mpegts_close_filter(ts, ts->pids[pid]); //wrongly added sdt filter probably1101 if (ts->pids[pid]) mpegts_close_filter(ts, ts->pids[pid]); //wrongly added sdt filter probably
1098 pes = add_pes_stream(ts, pid, pcr_pid);1102 pes = add_pes_stream(ts, pid, pcr_pid);
1099 if (pes)1103 if (pes) {
1100 st = av_new_stream(pes->stream, pes->pid);1104 st = avformat_new_stream(pes->stream, NULL);
1105 st->id = pes->pid;
1106 }
1101 }1107 }
1102 1108
1103 if (!st)1109 if (!st)
libavformat/mtv.c+4−6
@@ -32,8 +32,6 @@ · 31 unmodified lines
32#define MTV_HEADER_SIZE 51232#define MTV_HEADER_SIZE 512
33#define MTV_AUDIO_PADDING_SIZE 1233#define MTV_AUDIO_PADDING_SIZE 12
34#define AUDIO_SAMPLING_RATE 4410034#define AUDIO_SAMPLING_RATE 44100
35#define VIDEO_SID 0
36#define AUDIO_SID 1
37 35
38typedef struct MTVDemuxContext {36typedef struct MTVDemuxContext {
39 37
@@ -118,7 +116,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap) · 78 unmodified lines
118 116
119 // video - raw rgb565117 // video - raw rgb565
120 118
121 st = av_new_stream(s, VIDEO_SID);119 st = avformat_new_stream(s, NULL);
122 if(!st)120 if(!st)
123 return AVERROR(ENOMEM);121 return AVERROR(ENOMEM);
124 122
@@ -134,7 +132,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap) · 9 unmodified lines
134 132
135 // audio - mp3133 // audio - mp3
136 134
137 st = av_new_stream(s, AUDIO_SID);135 st = avformat_new_stream(s, NULL);
138 if(!st)136 if(!st)
139 return AVERROR(ENOMEM);137 return AVERROR(ENOMEM);
140 138
@@ -171,7 +169,7 @@ static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt) · 30 unmodified lines
171 return ret;169 return ret;
172 170
173 pkt->pos -= MTV_AUDIO_PADDING_SIZE;171 pkt->pos -= MTV_AUDIO_PADDING_SIZE;
174 pkt->stream_index = AUDIO_SID;172 pkt->stream_index = 1;
175 173
176 }else174 }else
177 {175 {
@@ -190,7 +188,7 @@ static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt) · 12 unmodified lines
190 for(i=0;i<mtv->img_segment_size/2;i++)188 for(i=0;i<mtv->img_segment_size/2;i++)
191 *((uint16_t *)pkt->data+i) = av_bswap16(*((uint16_t *)pkt->data+i));189 *((uint16_t *)pkt->data+i) = av_bswap16(*((uint16_t *)pkt->data+i));
192#endif190#endif
193 pkt->stream_index = VIDEO_SID;191 pkt->stream_index = 0;
194 }192 }
195 193
196 return ret;194 return ret;
libavformat/mxfdec.c+2−1
@@ -746,11 +746,12 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) · 745 unmodified lines
746 if (!source_track)746 if (!source_track)
747 continue;747 continue;
748 748
749 st = av_new_stream(mxf->fc, source_track->track_id);749 st = avformat_new_stream(mxf->fc, NULL);
750 if (!st) {750 if (!st) {
751 av_log(mxf->fc, AV_LOG_ERROR, "could not allocate stream\n");751 av_log(mxf->fc, AV_LOG_ERROR, "could not allocate stream\n");
752 return -1;752 return -1;
753 }753 }
754 st->id = source_track->track_id;
754 st->priv_data = source_track;755 st->priv_data = source_track;
755 st->duration = component->duration;756 st->duration = component->duration;
756 if (st->duration == -1)757 if (st->duration == -1)
libavformat/mxg.c+4−6
@@ -24,8 +24,6 @@ · 23 unmodified lines
24#include "avformat.h"24#include "avformat.h"
25#include "avio.h"25#include "avio.h"
26 26
27#define VIDEO_STREAM_INDEX 0
28#define AUDIO_STREAM_INDEX 1
29#define DEFAULT_PACKET_SIZE 102427#define DEFAULT_PACKET_SIZE 1024
30#define OVERREAD_SIZE 328#define OVERREAD_SIZE 3
31 29
@@ -44,14 +42,14 @@ static int mxg_read_header(AVFormatContext *s, AVFormatParameters *ap) · 12 unmodified lines
44 MXGContext *mxg = s->priv_data;42 MXGContext *mxg = s->priv_data;
45 43
46 /* video parameters will be extracted from the compressed bitstream */44 /* video parameters will be extracted from the compressed bitstream */
47 video_st = av_new_stream(s, VIDEO_STREAM_INDEX);45 video_st = avformat_new_stream(s, NULL);
48 if (!video_st)46 if (!video_st)
49 return AVERROR(ENOMEM);47 return AVERROR(ENOMEM);
50 video_st->codec->codec_type = AVMEDIA_TYPE_VIDEO;48 video_st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
51 video_st->codec->codec_id = CODEC_ID_MXPEG;49 video_st->codec->codec_id = CODEC_ID_MXPEG;
52 av_set_pts_info(video_st, 64, 1, 1000000);50 av_set_pts_info(video_st, 64, 1, 1000000);
53 51
54 audio_st = av_new_stream(s, AUDIO_STREAM_INDEX);52 audio_st = avformat_new_stream(s, NULL);
55 if (!audio_st)53 if (!audio_st)
56 return AVERROR(ENOMEM);54 return AVERROR(ENOMEM);
57 audio_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;55 audio_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -166,7 +164,7 @@ static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt) · 108 unmodified lines
166 }164 }
167 165
168 pkt->pts = pkt->dts = mxg->dts;166 pkt->pts = pkt->dts = mxg->dts;
169 pkt->stream_index = VIDEO_STREAM_INDEX;167 pkt->stream_index = 0;
170 pkt->destruct = NULL;168 pkt->destruct = NULL;
171 pkt->size = mxg->buffer_ptr - mxg->soi_ptr;169 pkt->size = mxg->buffer_ptr - mxg->soi_ptr;
172 pkt->data = mxg->soi_ptr;170 pkt->data = mxg->soi_ptr;
@@ -204,7 +202,7 @@ static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt) · 31 unmodified lines
204 if (marker == APP13 && size >= 16) { /* audio data */202 if (marker == APP13 && size >= 16) { /* audio data */
205 /* time (GMT) of first sample in usec since 1970, little-endian */203 /* time (GMT) of first sample in usec since 1970, little-endian */
206 pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8);204 pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8);
207 pkt->stream_index = AUDIO_STREAM_INDEX;205 pkt->stream_index = 1;
208 pkt->destruct = NULL;206 pkt->destruct = NULL;
209 pkt->size = size - 14;207 pkt->size = size - 14;
210 pkt->data = startmarker_ptr + 16;208 pkt->data = startmarker_ptr + 16;
libavformat/nsvdec.c+4−2
@@ -437,10 +437,11 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) · 436 unmodified lines
437 nsv->vheight = vwidth;437 nsv->vheight = vwidth;
438 if (vtag != T_NONE) {438 if (vtag != T_NONE) {
439 int i;439 int i;
440 st = av_new_stream(s, NSV_ST_VIDEO);440 st = avformat_new_stream(s, NULL);
441 if (!st)441 if (!st)
442 goto fail;442 goto fail;
443 443
444 st->id = NSV_ST_VIDEO;
444 nst = av_mallocz(sizeof(NSVStream));445 nst = av_mallocz(sizeof(NSVStream));
445 if (!nst)446 if (!nst)
446 goto fail;447 goto fail;
@@ -468,10 +469,11 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) · 21 unmodified lines
468 }469 }
469 if (atag != T_NONE) {470 if (atag != T_NONE) {
470#ifndef DISABLE_AUDIO471#ifndef DISABLE_AUDIO
471 st = av_new_stream(s, NSV_ST_AUDIO);472 st = avformat_new_stream(s, NULL);
472 if (!st)473 if (!st)
473 goto fail;474 goto fail;
474 475
476 st->id = NSV_ST_AUDIO;
475 nst = av_mallocz(sizeof(NSVStream));477 nst = av_mallocz(sizeof(NSVStream));
476 if (!nst)478 if (!nst)
477 goto fail;479 goto fail;
libavformat/nutdec.c+1−1
@@ -288,7 +288,7 @@ static int decode_main_header(NUTContext *nut){ · 287 unmodified lines
288 288
289 nut->stream = av_mallocz(sizeof(StreamContext)*stream_count);289 nut->stream = av_mallocz(sizeof(StreamContext)*stream_count);
290 for(i=0; i<stream_count; i++){290 for(i=0; i<stream_count; i++){
291 av_new_stream(s, i);291 avformat_new_stream(s, NULL);
292 }292 }
293 293
294 return 0;294 return 0;
libavformat/nuv.c+2−2
@@ -153,7 +153,7 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) { · 152 unmodified lines
153 153
154 if (v_packs) {154 if (v_packs) {
155 ctx->v_id = stream_nr++;155 ctx->v_id = stream_nr++;
156 vst = av_new_stream(s, ctx->v_id);156 vst = avformat_new_stream(s, NULL);
157 if (!vst)157 if (!vst)
158 return AVERROR(ENOMEM);158 return AVERROR(ENOMEM);
159 vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;159 vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -169,7 +169,7 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) { · 9 unmodified lines
169 169
170 if (a_packs) {170 if (a_packs) {
171 ctx->a_id = stream_nr++;171 ctx->a_id = stream_nr++;
172 ast = av_new_stream(s, ctx->a_id);172 ast = avformat_new_stream(s, NULL);
173 if (!ast)173 if (!ast)
174 return AVERROR(ENOMEM);174 return AVERROR(ENOMEM);
175 ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;175 ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
libavformat/oggdec.c+2−1
@@ -172,10 +172,11 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream) · 171 unmodified lines
172 os->header = -1;172 os->header = -1;
173 173
174 if (new_avstream) {174 if (new_avstream) {
175 st = av_new_stream(s, idx);175 st = avformat_new_stream(s, NULL);
176 if (!st)176 if (!st)
177 return AVERROR(ENOMEM);177 return AVERROR(ENOMEM);
178 178
179 st->id = idx;
179 av_set_pts_info(st, 64, 1, 1000000);180 av_set_pts_info(st, 64, 1, 1000000);
180 }181 }
181 182
libavformat/pva.c+1−1
@@ -51,7 +51,7 @@ static int pva_read_header(AVFormatContext *s, AVFormatParameters *ap) { · 50 unmodified lines
51 av_set_pts_info(st, 32, 1, 90000);51 av_set_pts_info(st, 32, 1, 90000);
52 av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME);52 av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME);
53 53
54 if (!(st = av_new_stream(s, 1)))54 if (!(st = avformat_new_stream(s, NULL)))
55 return AVERROR(ENOMEM);55 return AVERROR(ENOMEM);
56 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;56 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
57 st->codec->codec_id = CODEC_ID_MP2;57 st->codec->codec_id = CODEC_ID_MP2;
libavformat/r3d.c+1−1
@@ -89,7 +89,7 @@ static int r3d_read_red1(AVFormatContext *s) · 88 unmodified lines
89 tmp = avio_r8(s->pb); // audio channels89 tmp = avio_r8(s->pb); // audio channels
90 av_dlog(s, "audio channels %d\n", tmp);90 av_dlog(s, "audio channels %d\n", tmp);
91 if (tmp > 0) {91 if (tmp > 0) {
92 AVStream *ast = av_new_stream(s, 1);92 AVStream *ast = avformat_new_stream(s, NULL);
93 if (!ast)93 if (!ast)
94 return AVERROR(ENOMEM);94 return AVERROR(ENOMEM);
95 ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;95 ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
libavformat/rdt.c+2−1
@@ -459,8 +459,9 @@ add_dstream(AVFormatContext *s, AVStream *orig_st) · 458 unmodified lines
459{459{
460 AVStream *st;460 AVStream *st;
461 461
462 if (!(st = av_new_stream(s, orig_st->id)))462 if (!(st = avformat_new_stream(s, NULL)))
463 return NULL;463 return NULL;
464 st->id = orig_st->id;
464 st->codec->codec_type = orig_st->codec->codec_type;465 st->codec->codec_type = orig_st->codec->codec_type;
465 st->first_dts = orig_st->first_dts;466 st->first_dts = orig_st->first_dts;
466 467
libavformat/rtsp.c+2−1
@@ -357,9 +357,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, · 356 unmodified lines
357 if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), "MP2T")) {357 if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), "MP2T")) {
358 /* no corresponding stream */358 /* no corresponding stream */
359 } else {359 } else {
360 st = av_new_stream(s, rt->nb_rtsp_streams - 1);360 st = avformat_new_stream(s, NULL);
361 if (!st)361 if (!st)
362 return;362 return;
363 st->id = rt->nb_rtsp_streams - 1;
363 rtsp_st->stream_index = st->index;364 rtsp_st->stream_index = st->index;
364 st->codec->codec_type = codec_type;365 st->codec->codec_type = codec_type;
365 if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) {366 if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) {
libavformat/sapdec.c+4−2
@@ -163,11 +163,12 @@ static int sap_read_header(AVFormatContext *s, · 162 unmodified lines
163 if (sap->sdp_ctx->ctx_flags & AVFMTCTX_NOHEADER)163 if (sap->sdp_ctx->ctx_flags & AVFMTCTX_NOHEADER)
164 s->ctx_flags |= AVFMTCTX_NOHEADER;164 s->ctx_flags |= AVFMTCTX_NOHEADER;
165 for (i = 0; i < sap->sdp_ctx->nb_streams; i++) {165 for (i = 0; i < sap->sdp_ctx->nb_streams; i++) {
166 AVStream *st = av_new_stream(s, i);166 AVStream *st = avformat_new_stream(s, NULL);
167 if (!st) {167 if (!st) {
168 ret = AVERROR(ENOMEM);168 ret = AVERROR(ENOMEM);
169 goto fail;169 goto fail;
170 }170 }
171 st->id = i;
171 avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec);172 avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec);
172 st->time_base = sap->sdp_ctx->streams[i]->time_base;173 st->time_base = sap->sdp_ctx->streams[i]->time_base;
173 }174 }
@@ -211,11 +212,12 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt) · 37 unmodified lines
211 if (s->ctx_flags & AVFMTCTX_NOHEADER) {212 if (s->ctx_flags & AVFMTCTX_NOHEADER) {
212 while (sap->sdp_ctx->nb_streams > s->nb_streams) {213 while (sap->sdp_ctx->nb_streams > s->nb_streams) {
213 int i = s->nb_streams;214 int i = s->nb_streams;
214 AVStream *st = av_new_stream(s, i);215 AVStream *st = avformat_new_stream(s, NULL);
215 if (!st) {216 if (!st) {
216 av_free_packet(pkt);217 av_free_packet(pkt);
217 return AVERROR(ENOMEM);218 return AVERROR(ENOMEM);
218 }219 }
220 st->id = i;
219 avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec);221 avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec);
220 st->time_base = sap->sdp_ctx->streams[i]->time_base;222 st->time_base = sap->sdp_ctx->streams[i]->time_base;
221 }223 }
libavformat/swfdec.c+6−3
@@ -106,9 +106,10 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) · 105 unmodified lines
106 avio_rl16(pb);106 avio_rl16(pb);
107 avio_r8(pb);107 avio_r8(pb);
108 /* Check for FLV1 */108 /* Check for FLV1 */
109 vst = av_new_stream(s, ch_id);109 vst = avformat_new_stream(s, NULL);
110 if (!vst)110 if (!vst)
111 return -1;111 return -1;
112 vst->id = ch_id;
112 vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;113 vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
113 vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, avio_r8(pb));114 vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, avio_r8(pb));
114 av_set_pts_info(vst, 16, 256, swf->frame_rate);115 av_set_pts_info(vst, 16, 256, swf->frame_rate);
@@ -127,9 +128,10 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) · 12 unmodified lines
127 avio_r8(pb);128 avio_r8(pb);
128 v = avio_r8(pb);129 v = avio_r8(pb);
129 swf->samples_per_frame = avio_rl16(pb);130 swf->samples_per_frame = avio_rl16(pb);
130 ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */131 ast = avformat_new_stream(s, NULL);
131 if (!ast)132 if (!ast)
132 return -1;133 return -1;
134 ast->id = -1; /* -1 to avoid clash with video stream ch_id */
133 ast->codec->channels = 1 + (v&1);135 ast->codec->channels = 1 + (v&1);
134 ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;136 ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
135 ast->codec->codec_id = ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15);137 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) · 41 unmodified lines
177 break;179 break;
178 }180 }
179 if (i == s->nb_streams) {181 if (i == s->nb_streams) {
180 vst = av_new_stream(s, -2); /* -2 to avoid clash with video stream and audio stream */182 vst = avformat_new_stream(s, NULL);
181 if (!vst)183 if (!vst)
182 return -1;184 return -1;
185 vst->id = -2; /* -2 to avoid clash with video stream and audio stream */
183 vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;186 vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
184 vst->codec->codec_id = CODEC_ID_MJPEG;187 vst->codec->codec_id = CODEC_ID_MJPEG;
185 av_set_pts_info(vst, 64, 256, swf->frame_rate);188 av_set_pts_info(vst, 64, 256, swf->frame_rate);
libavformat/wtv.c+2−1
@@ -626,9 +626,10 @@ static AVStream * new_stream(AVFormatContext *s, AVStream *st, int sid, int code · 625 unmodified lines
626 WtvStream *wst = av_mallocz(sizeof(WtvStream));626 WtvStream *wst = av_mallocz(sizeof(WtvStream));
627 if (!wst)627 if (!wst)
628 return NULL;628 return NULL;
629 st = av_new_stream(s, sid);629 st = avformat_new_stream(s, NULL);
630 if (!st)630 if (!st)
631 return NULL;631 return NULL;
632 st->id = sid;
632 st->priv_data = wst;633 st->priv_data = wst;
633 }634 }
634 st->codec->codec_type = codec_type;635 st->codec->codec_type = codec_type;
libavformat/xmv.c+1−1
@@ -211,7 +211,7 @@ static int xmv_read_header(AVFormatContext *s, · 210 unmodified lines
211 av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream "211 av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream "
212 "(0x%04X)\n", track->flags);212 "(0x%04X)\n", track->flags);
213 213
214 ast = av_new_stream(s, audio_track);214 ast = avformat_new_stream(s, NULL);
215 if (!ast)215 if (!ast)
216 return AVERROR(ENOMEM);216 return AVERROR(ENOMEM);
217 217
libavformat/yop.c+1−1
@@ -57,7 +57,7 @@ static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap) · 56 unmodified lines
57 int frame_rate, ret;57 int frame_rate, ret;
58 58
59 audio_stream = avformat_new_stream(s, NULL);59 audio_stream = avformat_new_stream(s, NULL);
60 video_stream = av_new_stream(s, 1);60 video_stream = avformat_new_stream(s, NULL);
61 61
62 // Extra data that will be passed to the decoder62 // Extra data that will be passed to the decoder
63 video_stream->codec->extradata_size = 8;63 video_stream->codec->extradata_size = 8;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t