diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2007-04-15 13:51:57 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2007-04-15 13:51:57 +0000 |
commit | 57004ff1d71d8a592cf8d3a268526c4e10ebe976 (patch) | |
tree | 9f8cabeb4f34375206dfdc8973a321e3b0e716f7 | |
parent | cefd4907e37112bc1f7ec5e0f0f2f7247ecf8150 (diff) | |
download | ffmpeg-57004ff1d71d8a592cf8d3a268526c4e10ebe976.tar.gz |
add an enum for need_parsing
Originally committed as revision 8742 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/asf.c | 4 | ||||
-rw-r--r-- | libavformat/avformat.h | 10 | ||||
-rw-r--r-- | libavformat/avidec.c | 4 | ||||
-rw-r--r-- | libavformat/flvdec.c | 2 | ||||
-rw-r--r-- | libavformat/gxf.c | 4 | ||||
-rw-r--r-- | libavformat/img2.c | 2 | ||||
-rw-r--r-- | libavformat/matroska.c | 2 | ||||
-rw-r--r-- | libavformat/mov.c | 2 | ||||
-rw-r--r-- | libavformat/mp3.c | 2 | ||||
-rw-r--r-- | libavformat/mpeg.c | 2 | ||||
-rw-r--r-- | libavformat/mpegts.c | 2 | ||||
-rw-r--r-- | libavformat/mtv.c | 2 | ||||
-rw-r--r-- | libavformat/mxf.c | 6 | ||||
-rw-r--r-- | libavformat/nsvdec.c | 4 | ||||
-rw-r--r-- | libavformat/raw.c | 12 | ||||
-rw-r--r-- | libavformat/rtp.c | 2 | ||||
-rw-r--r-- | libavformat/swf.c | 2 | ||||
-rw-r--r-- | libavformat/utils.c | 8 | ||||
-rw-r--r-- | libavformat/wav.c | 2 |
19 files changed, 40 insertions, 34 deletions
diff --git a/libavformat/asf.c b/libavformat/asf.c index 9dce1d751a..009dd7a94c 100644 --- a/libavformat/asf.c +++ b/libavformat/asf.c @@ -260,7 +260,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) 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 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) 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)); diff --git a/libavformat/avformat.h b/libavformat/avformat.h index d6525954bb..76ccb51848 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -253,6 +253,13 @@ typedef struct AVInputFormat { 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 @@ typedef struct AVStream { 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; diff --git a/libavformat/avidec.c b/libavformat/avidec.c index d434c57181..53621c5018 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -442,7 +442,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) 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 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) 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")){ diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 3278cdcff8..1f8035d859 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -47,7 +47,7 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, int flv_c 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: diff --git a/libavformat/gxf.c b/libavformat/gxf.c index a4a933c184..e6ee74c493 100644 --- a/libavformat/gxf.c +++ b/libavformat/gxf.c @@ -128,13 +128,13 @@ static int get_sindex(AVFormatContext *s, int id, int format) { 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; diff --git a/libavformat/img2.c b/libavformat/img2.c index ec39677377..d668d8ac30 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -190,7 +190,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) s->is_pipe = 0; else{ s->is_pipe = 1; - st->need_parsing= 1; + st->need_parsing = AVSTREAM_PARSE_FULL; } if (!ap->time_base.num) { diff --git a/libavformat/matroska.c b/libavformat/matroska.c index 0b03403de8..eaf4ceb953 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -2354,7 +2354,7 @@ matroska_read_header (AVFormatContext *s, 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; diff --git a/libavformat/mov.c b/libavformat/mov.c index aff43c2e54..edee417843 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -927,7 +927,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) 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; diff --git a/libavformat/mp3.c b/libavformat/mp3.c index 60066a7797..ff736118ae 100644 --- a/libavformat/mp3.c +++ b/libavformat/mp3.c @@ -292,7 +292,7 @@ static int mp3_read_header(AVFormatContext *s, 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)) { diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 40a7a259f2..07763c7c2d 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -1690,7 +1690,7 @@ static int mpegps_read_packet(AVFormatContext *s, 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; diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index c466710eee..35da0f036d 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -961,7 +961,7 @@ static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code) 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; diff --git a/libavformat/mtv.c b/libavformat/mtv.c index 88a077ccd8..fca8f76580 100644 --- a/libavformat/mtv.c +++ b/libavformat/mtv.c @@ -117,7 +117,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap) 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 */ diff --git a/libavformat/mxf.c b/libavformat/mxf.c index 55c73a5979..a13f6735c5 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -812,7 +812,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) 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 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) 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; diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index a8fbca180d..85bb69a676 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -474,7 +474,7 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) 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 @@ null_chunk_retry: 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)); } diff --git a/libavformat/raw.c b/libavformat/raw.c index f61d87b65e..2d111b88b9 100644 --- a/libavformat/raw.c +++ b/libavformat/raw.c @@ -218,7 +218,7 @@ static int ac3_read_header(AVFormatContext *s, 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 @@ static int shorten_read_header(AVFormatContext *s, 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 @@ static int flac_read_header(AVFormatContext *s, 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 @@ static int dts_read_header(AVFormatContext *s, 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 @@ static int aac_read_header(AVFormatContext *s, 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 @@ static int video_read_header(AVFormatContext *s, 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 ...)*/ diff --git a/libavformat/rtp.c b/libavformat/rtp.c index 439fd6d3f8..67ab41da0f 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -469,7 +469,7 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *r 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; diff --git a/libavformat/swf.c b/libavformat/swf.c index f8f21462a3..eaf2e8d754 100644 --- a/libavformat/swf.c +++ b/libavformat/swf.c @@ -681,7 +681,7 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) 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; diff --git a/libavformat/utils.c b/libavformat/utils.c index b748b546ca..6267b9a729 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -782,8 +782,8 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt) 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 @@ int av_find_stream_info(AVFormatContext *ic) //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 @@ int av_find_stream_info(AVFormatContext *ic) 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) diff --git a/libavformat/wav.c b/libavformat/wav.c index 0699bec70f..a6db698aa5 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -179,7 +179,7 @@ static int wav_read_header(AVFormatContext *s, 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); |