diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-07-12 18:42:00 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-07-12 18:42:00 +0000 |
commit | 0bef08e5169fb3bd45346ff1b3328ce6df5262ab (patch) | |
tree | 8a5b3527c3651598ccaa6ec76e282320f68e8c55 /libavformat/utils.c | |
parent | 3e86dba24b61527ecbd1780f3f7d3bd159c203d9 (diff) | |
download | ffmpeg-streaming-0bef08e5169fb3bd45346ff1b3328ce6df5262ab.zip ffmpeg-streaming-0bef08e5169fb3bd45346ff1b3328ce6df5262ab.tar.gz |
New codec probing system try #1.
Originally committed as revision 14184 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 329228d..4faef19 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -540,12 +540,30 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret; AVStream *st; + + for(;;){ + AVPacketList *pktl = s->raw_packet_buffer; + + if (pktl) { + *pkt = pktl->pkt; + if(s->streams[pkt->stream_index]->codec->codec_id != CODEC_ID_PROBE){ + s->raw_packet_buffer = pktl->next; + av_free(pktl); + return 0; + } + } + av_init_packet(pkt); ret= s->iformat->read_packet(s, pkt); if (ret < 0) return ret; st= s->streams[pkt->stream_index]; + if(!pktl && st->codec->codec_id!=CODEC_ID_PROBE) + return ret; + + add_to_pktbuf(&s->raw_packet_buffer, pkt); + switch(st->codec->codec_type){ case CODEC_TYPE_VIDEO: if(s->video_codec_id) st->codec->codec_id= s->video_codec_id; @@ -558,7 +576,21 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt) break; } - return ret; + if(st->codec->codec_id == CODEC_ID_PROBE){ + AVProbeData *pd = &st->probe_data; + + pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE); + memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size); + pd->buf_size += pkt->size; + memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE); + + set_codec_from_probe_data(st, pd, 1); + if(st->codec->codec_id != CODEC_ID_PROBE){ + pd->buf_size=0; + av_freep(&pd->buf); + } + } + } } /**********************************************************/ |