summaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorFrancesco Lavra <francescolavra@interfree.it>2010-05-18 19:23:29 +0000
committerCarl Eugen Hoyos <cehoyos@rainbow.studorg.tuwien.ac.at>2010-05-18 19:23:29 +0000
commit698f4cc7f0af0ba9ef54b01cfffd1f02d7aa5d05 (patch)
treece4a887be66f96f40e0b14d1b5ce77312d935d09 /libavformat
parent603a5f04b2da0622faab796307d7208ecde80603 (diff)
downloadffmpeg-streaming-698f4cc7f0af0ba9ef54b01cfffd1f02d7aa5d05.zip
ffmpeg-streaming-698f4cc7f0af0ba9ef54b01cfffd1f02d7aa5d05.tar.gz
Validate AVCodecTag vs CodecID.
Patch by Francesco Lavra, francescolavra interfree it Originally committed as revision 23159 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/utils.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 73cecc9..9b5ae5d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2573,6 +2573,39 @@ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
return 0;
}
+static int validate_codec_tag(AVFormatContext *s, AVStream *st)
+{
+ const AVCodecTag *avctag;
+ int n;
+ enum CodecID id = CODEC_ID_NONE;
+ unsigned int tag = 0;
+
+ /**
+ * Check that tag + id is in the table
+ * If neither is in the table -> OK
+ * If tag is in the table with another id -> FAIL
+ * If id is in the table with another tag -> FAIL unless strict < normal
+ */
+ for (n = 0; s->oformat->codec_tag[n]; n++) {
+ avctag = s->oformat->codec_tag[n];
+ while (avctag->id != CODEC_ID_NONE) {
+ if (ff_toupper4(avctag->tag) == ff_toupper4(st->codec->codec_tag)) {
+ id = avctag->id;
+ if (id == st->codec->codec_id)
+ return 1;
+ }
+ if (avctag->id == st->codec->codec_id)
+ tag = avctag->tag;
+ avctag++;
+ }
+ }
+ if (id != CODEC_ID_NONE)
+ return 0;
+ if (tag && (st->codec->strict_std_compliance >= FF_COMPLIANCE_NORMAL))
+ return 0;
+ return 1;
+}
+
int av_write_header(AVFormatContext *s)
{
int ret, i;
@@ -2615,11 +2648,12 @@ int av_write_header(AVFormatContext *s)
if(s->oformat->codec_tag){
if(st->codec->codec_tag){
- //FIXME
- //check that tag + id is in the table
- //if neither is in the table -> OK
- //if tag is in the table with another id -> FAIL
- //if id is in the table with another tag -> FAIL unless strict < ?
+ if (!validate_codec_tag(s, st)) {
+ av_log(s, AV_LOG_ERROR,
+ "Tag 0x%08x incompatible with output codec\n",
+ st->codec->codec_tag);
+ return AVERROR_INVALIDDATA;
+ }
}else
st->codec->codec_tag= av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id);
}
OpenPOWER on IntegriCloud