diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2010-10-06 20:21:07 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2010-10-06 20:21:07 +0000 |
commit | 6612d8cf3170a5bf1b3460c22f8c725c02542533 (patch) | |
tree | 887a00c4d753247b8cdc7639d6a0d21fe8468767 /libavformat/utils.c | |
parent | 1136850dd59f52d92d8ba3a70a42fafcdf37c05d (diff) | |
download | ffmpeg-6612d8cf3170a5bf1b3460c22f8c725c02542533.tar.gz |
Move handling of ID3v2 to common utils.c code, reducing code duplication
and supporting it for more formats, fixing issue 2258.
Originally committed as revision 25378 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index a545a5d9f4..a51a5faf59 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -23,6 +23,7 @@ #include "libavcodec/internal.h" #include "libavutil/opt.h" #include "metadata.h" +#include "id3v2.h" #include "libavutil/avstring.h" #include "riff.h" #include "audiointerleave.h" @@ -343,18 +344,27 @@ int av_filename_number_test(const char *filename) AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max) { + AVProbeData lpd = *pd; AVInputFormat *fmt1, *fmt; int score; + if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) { + int id3len = ff_id3v2_tag_len(lpd.buf); + if (lpd.buf_size > id3len + 16) { + lpd.buf += id3len; + lpd.buf_size -= id3len; + } + } + fmt = NULL; for(fmt1 = first_iformat; fmt1 != NULL; fmt1 = fmt1->next) { if (!is_opened == !(fmt1->flags & AVFMT_NOFILE)) continue; score = 0; if (fmt1->read_probe) { - score = fmt1->read_probe(pd); + score = fmt1->read_probe(&lpd); } else if (fmt1->extensions) { - if (av_match_ext(pd->filename, fmt1->extensions)) { + if (av_match_ext(lpd.filename, fmt1->extensions)) { score = 50; } } @@ -448,6 +458,10 @@ int av_open_input_stream(AVFormatContext **ic_ptr, ic->priv_data = NULL; } + // e.g. AVFMT_NOFILE formats will not have a ByteIOContext + if (ic->pb) + ff_id3v2_read(ic, ID3v2_DEFAULT_MAGIC); + if (ic->iformat->read_header) { err = ic->iformat->read_header(ic, ap); if (err < 0) |