Browse code

add an enum for need_parsing

Originally committed as revision 8742 to svn://svn.ffmpeg.org/ffmpeg/trunk

Aurelien Jacobs authored on 2007/04/15 22:51:57
Showing 19 changed files
... ...
@@ -260,7 +260,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
260 260
                     st->codec->codec_id = CODEC_ID_NONE;
261 261
                     st->codec->codec_tag = 0;
262 262
                 }
263
-                st->need_parsing = 1;
263
+                st->need_parsing = AVSTREAM_PARSE_FULL;
264 264
                 /* We have to init the frame size at some point .... */
265 265
                 pos2 = url_ftell(pb);
266 266
                 if (gsize >= (pos2 + 8 - pos1 + 24)) {
... ...
@@ -337,7 +337,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
337 337
                 st->codec->codec_tag = tag1;
338 338
                 st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
339 339
                 if(tag1 == MKTAG('D', 'V', 'R', ' '))
340
-                    st->need_parsing = 1;
340
+                    st->need_parsing = AVSTREAM_PARSE_FULL;
341 341
             }
342 342
             pos2 = url_ftell(pb);
343 343
             url_fskip(pb, gsize - (pos2 - pos1 + 24));
... ...
@@ -253,6 +253,13 @@ typedef struct AVInputFormat {
253 253
     struct AVInputFormat *next;
254 254
 } AVInputFormat;
255 255
 
256
+enum AVStreamParseType {
257
+    AVSTREAM_PARSE_NONE,
258
+    AVSTREAM_PARSE_FULL,       /**< full parsing and repack */
259
+    AVSTREAM_PARSE_HEADERS,    /**< only parse headers, don't repack */
260
+    AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on packet boundary */
261
+};
262
+
256 263
 typedef struct AVIndexEntry {
257 264
     int64_t pos;
258 265
     int64_t timestamp;
... ...
@@ -309,8 +316,7 @@ typedef struct AVStream {
309 309
     char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */
310 310
 
311 311
     /* av_read_frame() support */
312
-#define AVSTREAM_PARSE_TIMESTAMPS 3    /**< full parsing and interpolation of timestamps for frames not starting on packet boundary */
313
-    int need_parsing;                  ///< 1->full parsing needed, 2->only parse headers dont repack, 3->full parsing and interpolate timestamps
312
+    enum AVStreamParseType need_parsing;
314 313
     struct AVCodecParserContext *parser;
315 314
 
316 315
     int64_t cur_dts;
... ...
@@ -442,7 +442,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
442 442
                     st->codec->codec_type = CODEC_TYPE_VIDEO;
443 443
                     st->codec->codec_tag = tag1;
444 444
                     st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
445
-                    st->need_parsing = 2; //only parse headers dont do slower repacketization, this is needed to get the pict type which is needed for generating correct pts
445
+                    st->need_parsing = AVSTREAM_PARSE_HEADERS; // this is needed to get the pict type which is needed for generating correct pts
446 446
 //                    url_fskip(pb, size - 5 * 4);
447 447
                     break;
448 448
                 case CODEC_TYPE_AUDIO:
... ...
@@ -456,7 +456,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
456 456
                     st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
457 457
                     /* ADTS header is in extradata, AAC without header must be stored as exact frames, parser not needed and it will fail */
458 458
                     if (st->codec->codec_id == CODEC_ID_AAC && st->codec->extradata_size)
459
-                        st->need_parsing = 0;
459
+                        st->need_parsing = AVSTREAM_PARSE_NONE;
460 460
                     /* AVI files with Xan DPCM audio (wrongly) declare PCM
461 461
                      * audio in the header but have Axan as stream_code_tag. */
462 462
                     if (st->codec->stream_codec_tag == ff_get_fourcc("Axan")){
... ...
@@ -47,7 +47,7 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, int flv_c
47 47
         case FLV_CODECID_PCM_LE:
48 48
             acodec->codec_id = acodec->bits_per_sample == 8 ? CODEC_ID_PCM_S8 : CODEC_ID_PCM_S16LE; break;
49 49
         case FLV_CODECID_ADPCM: acodec->codec_id = CODEC_ID_ADPCM_SWF;                              break;
50
-        case FLV_CODECID_MP3  : acodec->codec_id = CODEC_ID_MP3      ; astream->need_parsing = 1  ; break;
50
+        case FLV_CODECID_MP3  : acodec->codec_id = CODEC_ID_MP3      ; astream->need_parsing = AVSTREAM_PARSE_FULL; break;
51 51
         case FLV_CODECID_NELLYMOSER_8HZ_MONO:
52 52
             acodec->sample_rate = 8000; //in case metadata does not otherwise declare samplerate
53 53
         case FLV_CODECID_NELLYMOSER:
... ...
@@ -128,13 +128,13 @@ static int get_sindex(AVFormatContext *s, int id, int format) {
128 128
         case 20:
129 129
             st->codec->codec_type = CODEC_TYPE_VIDEO;
130 130
             st->codec->codec_id = CODEC_ID_MPEG2VIDEO;
131
-            st->need_parsing = 2; // get keyframe flag etc.
131
+            st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
132 132
             break;
133 133
         case 22:
134 134
         case 23:
135 135
             st->codec->codec_type = CODEC_TYPE_VIDEO;
136 136
             st->codec->codec_id = CODEC_ID_MPEG1VIDEO;
137
-            st->need_parsing = 2; // get keyframe flag etc.
137
+            st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
138 138
             break;
139 139
         case 9:
140 140
             st->codec->codec_type = CODEC_TYPE_AUDIO;
... ...
@@ -190,7 +190,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
190 190
         s->is_pipe = 0;
191 191
     else{
192 192
         s->is_pipe = 1;
193
-        st->need_parsing= 1;
193
+        st->need_parsing = AVSTREAM_PARSE_FULL;
194 194
     }
195 195
 
196 196
     if (!ap->time_base.num) {
... ...
@@ -2354,7 +2354,7 @@ matroska_read_header (AVFormatContext    *s,
2354 2354
                           st->codec->height * videotrack->display_width,
2355 2355
                           st->codec-> width * videotrack->display_height,
2356 2356
                           255);
2357
-                st->need_parsing = 2;
2357
+                st->need_parsing = AVSTREAM_PARSE_HEADERS;
2358 2358
             } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
2359 2359
                 MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
2360 2360
 
... ...
@@ -927,7 +927,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
927 927
     case CODEC_ID_MP2:
928 928
     case CODEC_ID_MP3:
929 929
         st->codec->codec_type = CODEC_TYPE_AUDIO; /* force type after stsd for m1a hdlr */
930
-        st->need_parsing = 1;
930
+        st->need_parsing = AVSTREAM_PARSE_FULL;
931 931
         break;
932 932
     default:
933 933
         break;
... ...
@@ -292,7 +292,7 @@ static int mp3_read_header(AVFormatContext *s,
292 292
 
293 293
     st->codec->codec_type = CODEC_TYPE_AUDIO;
294 294
     st->codec->codec_id = CODEC_ID_MP3;
295
-    st->need_parsing = 1;
295
+    st->need_parsing = AVSTREAM_PARSE_FULL;
296 296
 
297 297
     /* try to get the TAG */
298 298
     if (!url_is_streamed(&s->pb)) {
... ...
@@ -1690,7 +1690,7 @@ static int mpegps_read_packet(AVFormatContext *s,
1690 1690
     st->codec->codec_type = type;
1691 1691
     st->codec->codec_id = codec_id;
1692 1692
     if (codec_id != CODEC_ID_PCM_S16BE)
1693
-        st->need_parsing = 1;
1693
+        st->need_parsing = AVSTREAM_PARSE_FULL;
1694 1694
  found:
1695 1695
     if(st->discard >= AVDISCARD_ALL)
1696 1696
         goto skip;
... ...
@@ -961,7 +961,7 @@ static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code)
961 961
         st->priv_data = pes;
962 962
         st->codec->codec_type = codec_type;
963 963
         st->codec->codec_id = codec_id;
964
-        st->need_parsing = 1;
964
+        st->need_parsing = AVSTREAM_PARSE_FULL;
965 965
         pes->st = st;
966 966
     }
967 967
     return st;
... ...
@@ -117,7 +117,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap)
117 117
     st->codec->codec_type      = CODEC_TYPE_AUDIO;
118 118
     st->codec->codec_id        = CODEC_ID_MP3;
119 119
     st->codec->bit_rate        = mtv->audio_br;
120
-    st->need_parsing=1;
120
+    st->need_parsing           = AVSTREAM_PARSE_FULL;
121 121
 
122 122
     /* Jump over header */
123 123
 
... ...
@@ -812,7 +812,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
812 812
             st->codec->width = descriptor->width;
813 813
             st->codec->height = descriptor->height;
814 814
             st->codec->bits_per_sample = descriptor->bits_per_sample; /* Uncompressed */
815
-            st->need_parsing = 2; /* only parse headers */
815
+            st->need_parsing = AVSTREAM_PARSE_HEADERS;
816 816
         } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
817 817
             container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
818 818
             if (st->codec->codec_id == CODEC_ID_NONE)
... ...
@@ -834,12 +834,12 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
834 834
                 if (descriptor->essence_container_ul[13] == 0x01) /* D-10 Mapping */
835 835
                     st->codec->channels = 8; /* force channels to 8 */
836 836
             } else if (st->codec->codec_id == CODEC_ID_MP2) {
837
-                st->need_parsing = 1;
837
+                st->need_parsing = AVSTREAM_PARSE_FULL;
838 838
             }
839 839
         }
840 840
         if (container_ul && container_ul->wrapping == Clip) {
841 841
             dprintf(mxf->fc, "stream %d: clip wrapped essence\n", st->index);
842
-            st->need_parsing = 1;
842
+            st->need_parsing = AVSTREAM_PARSE_FULL;
843 843
         }
844 844
     }
845 845
     return 0;
... ...
@@ -474,7 +474,7 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
474 474
             st->codec->codec_tag = atag;
475 475
             st->codec->codec_id = codec_get_id(nsv_codec_audio_tags, atag);
476 476
 
477
-            st->need_parsing = 1; /* for PCM we will read a chunk later and put correct info */
477
+            st->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */
478 478
 
479 479
             /* set timebase to common denominator of ms and framerate */
480 480
             av_set_pts_info(st, 64, 1, framerate.num*1000);
... ...
@@ -626,7 +626,7 @@ null_chunk_retry:
626 626
             asize-=4;
627 627
             PRINT(("NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate));
628 628
             if (fill_header) {
629
-                st[NSV_ST_AUDIO]->need_parsing = 0; /* we know everything */
629
+                st[NSV_ST_AUDIO]->need_parsing = AVSTREAM_PARSE_NONE; /* we know everything */
630 630
                 if (bps != 16) {
631 631
                     PRINT(("NSV AUDIO bit/sample != 16 (%d)!!!\n", bps));
632 632
                 }
... ...
@@ -218,7 +218,7 @@ static int ac3_read_header(AVFormatContext *s,
218 218
 
219 219
     st->codec->codec_type = CODEC_TYPE_AUDIO;
220 220
     st->codec->codec_id = CODEC_ID_AC3;
221
-    st->need_parsing = 1;
221
+    st->need_parsing = AVSTREAM_PARSE_FULL;
222 222
     /* the parameters will be extracted from the compressed bitstream */
223 223
     return 0;
224 224
 }
... ...
@@ -233,7 +233,7 @@ static int shorten_read_header(AVFormatContext *s,
233 233
         return AVERROR_NOMEM;
234 234
     st->codec->codec_type = CODEC_TYPE_AUDIO;
235 235
     st->codec->codec_id = CODEC_ID_SHORTEN;
236
-    st->need_parsing = 1;
236
+    st->need_parsing = AVSTREAM_PARSE_FULL;
237 237
     /* the parameters will be extracted from the compressed bitstream */
238 238
     return 0;
239 239
 }
... ...
@@ -249,7 +249,7 @@ static int flac_read_header(AVFormatContext *s,
249 249
         return AVERROR_NOMEM;
250 250
     st->codec->codec_type = CODEC_TYPE_AUDIO;
251 251
     st->codec->codec_id = CODEC_ID_FLAC;
252
-    st->need_parsing = 1;
252
+    st->need_parsing = AVSTREAM_PARSE_FULL;
253 253
     /* the parameters will be extracted from the compressed bitstream */
254 254
     return 0;
255 255
 }
... ...
@@ -266,7 +266,7 @@ static int dts_read_header(AVFormatContext *s,
266 266
 
267 267
     st->codec->codec_type = CODEC_TYPE_AUDIO;
268 268
     st->codec->codec_id = CODEC_ID_DTS;
269
-    st->need_parsing = 1;
269
+    st->need_parsing = AVSTREAM_PARSE_FULL;
270 270
     /* the parameters will be extracted from the compressed bitstream */
271 271
     return 0;
272 272
 }
... ...
@@ -283,7 +283,7 @@ static int aac_read_header(AVFormatContext *s,
283 283
 
284 284
     st->codec->codec_type = CODEC_TYPE_AUDIO;
285 285
     st->codec->codec_id = CODEC_ID_AAC;
286
-    st->need_parsing = 1;
286
+    st->need_parsing = AVSTREAM_PARSE_FULL;
287 287
     /* the parameters will be extracted from the compressed bitstream */
288 288
     return 0;
289 289
 }
... ...
@@ -300,7 +300,7 @@ static int video_read_header(AVFormatContext *s,
300 300
 
301 301
     st->codec->codec_type = CODEC_TYPE_VIDEO;
302 302
     st->codec->codec_id = s->iformat->value;
303
-    st->need_parsing = 1;
303
+    st->need_parsing = AVSTREAM_PARSE_FULL;
304 304
 
305 305
     /* for mjpeg, specify frame rate */
306 306
     /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/
... ...
@@ -469,7 +469,7 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *r
469 469
         case CODEC_ID_MP3:
470 470
         case CODEC_ID_MPEG4:
471 471
         case CODEC_ID_H264:
472
-            st->need_parsing = 1;
472
+            st->need_parsing = AVSTREAM_PARSE_FULL;
473 473
             break;
474 474
         default:
475 475
             break;
... ...
@@ -681,7 +681,7 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
681 681
             ast->codec->channels = 1 + (v&1);
682 682
             ast->codec->codec_type = CODEC_TYPE_AUDIO;
683 683
             ast->codec->codec_id = codec_get_id(swf_audio_codec_tags, (v>>4) & 15);
684
-            ast->need_parsing = 1;
684
+            ast->need_parsing = AVSTREAM_PARSE_FULL;
685 685
             sample_rate_code= (v>>2) & 3;
686 686
             if (!sample_rate_code)
687 687
                 return AVERROR_IO;
... ...
@@ -782,8 +782,8 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
782 782
                 st->parser = av_parser_init(st->codec->codec_id);
783 783
                 if (!st->parser) {
784 784
                     /* no parser available : just output the raw packets */
785
-                    st->need_parsing = 0;
786
-                }else if(st->need_parsing == 2){
785
+                    st->need_parsing = AVSTREAM_PARSE_NONE;
786
+                }else if(st->need_parsing == AVSTREAM_PARSE_HEADERS){
787 787
                     st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
788 788
                 }
789 789
                 if(st->parser && (s->iformat->flags & AVFMT_GENERIC_INDEX)){
... ...
@@ -1704,7 +1704,7 @@ int av_find_stream_info(AVFormatContext *ic)
1704 1704
         //only for the split stuff
1705 1705
         if (!st->parser) {
1706 1706
             st->parser = av_parser_init(st->codec->codec_id);
1707
-            if(st->need_parsing == 2 && st->parser){
1707
+            if(st->need_parsing == AVSTREAM_PARSE_HEADERS && st->parser){
1708 1708
                 st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
1709 1709
             }
1710 1710
         }
... ...
@@ -1907,7 +1907,7 @@ int av_find_stream_info(AVFormatContext *ic)
1907 1907
             if (st->codec->codec_id == CODEC_ID_NONE) {
1908 1908
                 codec_identified[st->index] = set_codec_from_probe_data(st, &(probe_data[st->index]), 0);
1909 1909
                 if (codec_identified[st->index]) {
1910
-                    st->need_parsing = 1;
1910
+                    st->need_parsing = AVSTREAM_PARSE_FULL;
1911 1911
                 }
1912 1912
             }
1913 1913
             if(!st->codec->bits_per_sample)
... ...
@@ -179,7 +179,7 @@ static int wav_read_header(AVFormatContext *s,
179 179
         return AVERROR_NOMEM;
180 180
 
181 181
     get_wav_header(pb, st->codec, size);
182
-    st->need_parsing = 1;
182
+    st->need_parsing = AVSTREAM_PARSE_FULL;
183 183
 
184 184
     av_set_pts_info(st, 64, 1, st->codec->sample_rate);
185 185