changeset 2023:a3e79d6e4e3c libavformat

add an enum for need_parsing
author aurel
date Sun, 15 Apr 2007 13:51:57 +0000
parents 4f62a7d9381a
children 8b400be65542
files asf.c avformat.h avidec.c flvdec.c gxf.c img2.c matroska.c mov.c mp3.c mpeg.c mpegts.c mtv.c mxf.c nsvdec.c raw.c rtp.c swf.c utils.c wav.c
diffstat 19 files changed, 40 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/asf.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/asf.c	Sun Apr 15 13:51:57 2007 +0000
@@ -260,7 +260,7 @@
                     st->codec->codec_id = CODEC_ID_NONE;
                     st->codec->codec_tag = 0;
                 }
-                st->need_parsing = 1;
+                st->need_parsing = AVSTREAM_PARSE_FULL;
                 /* We have to init the frame size at some point .... */
                 pos2 = url_ftell(pb);
                 if (gsize >= (pos2 + 8 - pos1 + 24)) {
@@ -337,7 +337,7 @@
                 st->codec->codec_tag = tag1;
                 st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
                 if(tag1 == MKTAG('D', 'V', 'R', ' '))
-                    st->need_parsing = 1;
+                    st->need_parsing = AVSTREAM_PARSE_FULL;
             }
             pos2 = url_ftell(pb);
             url_fskip(pb, gsize - (pos2 - pos1 + 24));
--- a/avformat.h	Sun Apr 15 12:35:44 2007 +0000
+++ b/avformat.h	Sun Apr 15 13:51:57 2007 +0000
@@ -253,6 +253,13 @@
     struct AVInputFormat *next;
 } AVInputFormat;
 
+enum AVStreamParseType {
+    AVSTREAM_PARSE_NONE,
+    AVSTREAM_PARSE_FULL,       /**< full parsing and repack */
+    AVSTREAM_PARSE_HEADERS,    /**< only parse headers, don't repack */
+    AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on packet boundary */
+};
+
 typedef struct AVIndexEntry {
     int64_t pos;
     int64_t timestamp;
@@ -309,8 +316,7 @@
     char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */
 
     /* av_read_frame() support */
-#define AVSTREAM_PARSE_TIMESTAMPS 3    /**< full parsing and interpolation of timestamps for frames not starting on packet boundary */
-    int need_parsing;                  ///< 1->full parsing needed, 2->only parse headers dont repack, 3->full parsing and interpolate timestamps
+    enum AVStreamParseType need_parsing;
     struct AVCodecParserContext *parser;
 
     int64_t cur_dts;
--- a/avidec.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/avidec.c	Sun Apr 15 13:51:57 2007 +0000
@@ -442,7 +442,7 @@
                     st->codec->codec_type = CODEC_TYPE_VIDEO;
                     st->codec->codec_tag = tag1;
                     st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
-                    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
+                    st->need_parsing = AVSTREAM_PARSE_HEADERS; // this is needed to get the pict type which is needed for generating correct pts
 //                    url_fskip(pb, size - 5 * 4);
                     break;
                 case CODEC_TYPE_AUDIO:
@@ -456,7 +456,7 @@
                     st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
                     /* ADTS header is in extradata, AAC without header must be stored as exact frames, parser not needed and it will fail */
                     if (st->codec->codec_id == CODEC_ID_AAC && st->codec->extradata_size)
-                        st->need_parsing = 0;
+                        st->need_parsing = AVSTREAM_PARSE_NONE;
                     /* AVI files with Xan DPCM audio (wrongly) declare PCM
                      * audio in the header but have Axan as stream_code_tag. */
                     if (st->codec->stream_codec_tag == ff_get_fourcc("Axan")){
--- a/flvdec.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/flvdec.c	Sun Apr 15 13:51:57 2007 +0000
@@ -47,7 +47,7 @@
         case FLV_CODECID_PCM_LE:
             acodec->codec_id = acodec->bits_per_sample == 8 ? CODEC_ID_PCM_S8 : CODEC_ID_PCM_S16LE; break;
         case FLV_CODECID_ADPCM: acodec->codec_id = CODEC_ID_ADPCM_SWF;                              break;
-        case FLV_CODECID_MP3  : acodec->codec_id = CODEC_ID_MP3      ; astream->need_parsing = 1  ; break;
+        case FLV_CODECID_MP3  : acodec->codec_id = CODEC_ID_MP3      ; astream->need_parsing = AVSTREAM_PARSE_FULL; break;
         case FLV_CODECID_NELLYMOSER_8HZ_MONO:
             acodec->sample_rate = 8000; //in case metadata does not otherwise declare samplerate
         case FLV_CODECID_NELLYMOSER:
--- a/gxf.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/gxf.c	Sun Apr 15 13:51:57 2007 +0000
@@ -128,13 +128,13 @@
         case 20:
             st->codec->codec_type = CODEC_TYPE_VIDEO;
             st->codec->codec_id = CODEC_ID_MPEG2VIDEO;
-            st->need_parsing = 2; // get keyframe flag etc.
+            st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
             break;
         case 22:
         case 23:
             st->codec->codec_type = CODEC_TYPE_VIDEO;
             st->codec->codec_id = CODEC_ID_MPEG1VIDEO;
-            st->need_parsing = 2; // get keyframe flag etc.
+            st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
             break;
         case 9:
             st->codec->codec_type = CODEC_TYPE_AUDIO;
--- a/img2.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/img2.c	Sun Apr 15 13:51:57 2007 +0000
@@ -190,7 +190,7 @@
         s->is_pipe = 0;
     else{
         s->is_pipe = 1;
-        st->need_parsing= 1;
+        st->need_parsing = AVSTREAM_PARSE_FULL;
     }
 
     if (!ap->time_base.num) {
--- a/matroska.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/matroska.c	Sun Apr 15 13:51:57 2007 +0000
@@ -2354,7 +2354,7 @@
                           st->codec->height * videotrack->display_width,
                           st->codec-> width * videotrack->display_height,
                           255);
-                st->need_parsing = 2;
+                st->need_parsing = AVSTREAM_PARSE_HEADERS;
             } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
                 MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
 
--- a/mov.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/mov.c	Sun Apr 15 13:51:57 2007 +0000
@@ -927,7 +927,7 @@
     case CODEC_ID_MP2:
     case CODEC_ID_MP3:
         st->codec->codec_type = CODEC_TYPE_AUDIO; /* force type after stsd for m1a hdlr */
-        st->need_parsing = 1;
+        st->need_parsing = AVSTREAM_PARSE_FULL;
         break;
     default:
         break;
--- a/mp3.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/mp3.c	Sun Apr 15 13:51:57 2007 +0000
@@ -292,7 +292,7 @@
 
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_MP3;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
 
     /* try to get the TAG */
     if (!url_is_streamed(&s->pb)) {
--- a/mpeg.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/mpeg.c	Sun Apr 15 13:51:57 2007 +0000
@@ -1690,7 +1690,7 @@
     st->codec->codec_type = type;
     st->codec->codec_id = codec_id;
     if (codec_id != CODEC_ID_PCM_S16BE)
-        st->need_parsing = 1;
+        st->need_parsing = AVSTREAM_PARSE_FULL;
  found:
     if(st->discard >= AVDISCARD_ALL)
         goto skip;
--- a/mpegts.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/mpegts.c	Sun Apr 15 13:51:57 2007 +0000
@@ -961,7 +961,7 @@
         st->priv_data = pes;
         st->codec->codec_type = codec_type;
         st->codec->codec_id = codec_id;
-        st->need_parsing = 1;
+        st->need_parsing = AVSTREAM_PARSE_FULL;
         pes->st = st;
     }
     return st;
--- a/mtv.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/mtv.c	Sun Apr 15 13:51:57 2007 +0000
@@ -117,7 +117,7 @@
     st->codec->codec_type      = CODEC_TYPE_AUDIO;
     st->codec->codec_id        = CODEC_ID_MP3;
     st->codec->bit_rate        = mtv->audio_br;
-    st->need_parsing=1;
+    st->need_parsing           = AVSTREAM_PARSE_FULL;
 
     /* Jump over header */
 
--- a/mxf.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/mxf.c	Sun Apr 15 13:51:57 2007 +0000
@@ -812,7 +812,7 @@
             st->codec->width = descriptor->width;
             st->codec->height = descriptor->height;
             st->codec->bits_per_sample = descriptor->bits_per_sample; /* Uncompressed */
-            st->need_parsing = 2; /* only parse headers */
+            st->need_parsing = AVSTREAM_PARSE_HEADERS;
         } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
             container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
             if (st->codec->codec_id == CODEC_ID_NONE)
@@ -834,12 +834,12 @@
                 if (descriptor->essence_container_ul[13] == 0x01) /* D-10 Mapping */
                     st->codec->channels = 8; /* force channels to 8 */
             } else if (st->codec->codec_id == CODEC_ID_MP2) {
-                st->need_parsing = 1;
+                st->need_parsing = AVSTREAM_PARSE_FULL;
             }
         }
         if (container_ul && container_ul->wrapping == Clip) {
             dprintf(mxf->fc, "stream %d: clip wrapped essence\n", st->index);
-            st->need_parsing = 1;
+            st->need_parsing = AVSTREAM_PARSE_FULL;
         }
     }
     return 0;
--- a/nsvdec.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/nsvdec.c	Sun Apr 15 13:51:57 2007 +0000
@@ -474,7 +474,7 @@
             st->codec->codec_tag = atag;
             st->codec->codec_id = codec_get_id(nsv_codec_audio_tags, atag);
 
-            st->need_parsing = 1; /* for PCM we will read a chunk later and put correct info */
+            st->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */
 
             /* set timebase to common denominator of ms and framerate */
             av_set_pts_info(st, 64, 1, framerate.num*1000);
@@ -626,7 +626,7 @@
             asize-=4;
             PRINT(("NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate));
             if (fill_header) {
-                st[NSV_ST_AUDIO]->need_parsing = 0; /* we know everything */
+                st[NSV_ST_AUDIO]->need_parsing = AVSTREAM_PARSE_NONE; /* we know everything */
                 if (bps != 16) {
                     PRINT(("NSV AUDIO bit/sample != 16 (%d)!!!\n", bps));
                 }
--- a/raw.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/raw.c	Sun Apr 15 13:51:57 2007 +0000
@@ -218,7 +218,7 @@
 
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_AC3;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
 }
@@ -233,7 +233,7 @@
         return AVERROR_NOMEM;
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_SHORTEN;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
 }
@@ -249,7 +249,7 @@
         return AVERROR_NOMEM;
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_FLAC;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
 }
@@ -266,7 +266,7 @@
 
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_DTS;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
 }
@@ -283,7 +283,7 @@
 
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_AAC;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
 }
@@ -300,7 +300,7 @@
 
     st->codec->codec_type = CODEC_TYPE_VIDEO;
     st->codec->codec_id = s->iformat->value;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
 
     /* for mjpeg, specify frame rate */
     /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/
--- a/rtp.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/rtp.c	Sun Apr 15 13:51:57 2007 +0000
@@ -469,7 +469,7 @@
         case CODEC_ID_MP3:
         case CODEC_ID_MPEG4:
         case CODEC_ID_H264:
-            st->need_parsing = 1;
+            st->need_parsing = AVSTREAM_PARSE_FULL;
             break;
         default:
             break;
--- a/swf.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/swf.c	Sun Apr 15 13:51:57 2007 +0000
@@ -681,7 +681,7 @@
             ast->codec->channels = 1 + (v&1);
             ast->codec->codec_type = CODEC_TYPE_AUDIO;
             ast->codec->codec_id = codec_get_id(swf_audio_codec_tags, (v>>4) & 15);
-            ast->need_parsing = 1;
+            ast->need_parsing = AVSTREAM_PARSE_FULL;
             sample_rate_code= (v>>2) & 3;
             if (!sample_rate_code)
                 return AVERROR_IO;
--- a/utils.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/utils.c	Sun Apr 15 13:51:57 2007 +0000
@@ -782,8 +782,8 @@
                 st->parser = av_parser_init(st->codec->codec_id);
                 if (!st->parser) {
                     /* no parser available : just output the raw packets */
-                    st->need_parsing = 0;
-                }else if(st->need_parsing == 2){
+                    st->need_parsing = AVSTREAM_PARSE_NONE;
+                }else if(st->need_parsing == AVSTREAM_PARSE_HEADERS){
                     st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
                 }
                 if(st->parser && (s->iformat->flags & AVFMT_GENERIC_INDEX)){
@@ -1704,7 +1704,7 @@
         //only for the split stuff
         if (!st->parser) {
             st->parser = av_parser_init(st->codec->codec_id);
-            if(st->need_parsing == 2 && st->parser){
+            if(st->need_parsing == AVSTREAM_PARSE_HEADERS && st->parser){
                 st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
             }
         }
@@ -1907,7 +1907,7 @@
             if (st->codec->codec_id == CODEC_ID_NONE) {
                 codec_identified[st->index] = set_codec_from_probe_data(st, &(probe_data[st->index]), 0);
                 if (codec_identified[st->index]) {
-                    st->need_parsing = 1;
+                    st->need_parsing = AVSTREAM_PARSE_FULL;
                 }
             }
             if(!st->codec->bits_per_sample)
--- a/wav.c	Sun Apr 15 12:35:44 2007 +0000
+++ b/wav.c	Sun Apr 15 13:51:57 2007 +0000
@@ -179,7 +179,7 @@
         return AVERROR_NOMEM;
 
     get_wav_header(pb, st->codec, size);
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
 
     av_set_pts_info(st, 64, 1, st->codec->sample_rate);