add an enum for need_parsing

Originally committed as revision 8742 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Aurelien Jacobs 2007-04-15 13:51:57 +00:00
parent cefd4907e3
commit 57004ff1d7
19 changed files with 40 additions and 34 deletions

View File

@ -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));

View File

@ -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;

View File

@ -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")){

View File

@ -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:

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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)) {

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -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));
}

View File

@ -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 ...)*/

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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);