Commit bf798553 authored by cehoyos's avatar cehoyos

Validate AVCodecTag vs CodecID.

Patch by Francesco Lavra, francescolavra interfree it 


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@23159 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 4cd2401c
...@@ -2573,6 +2573,39 @@ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap) ...@@ -2573,6 +2573,39 @@ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
return 0; 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 av_write_header(AVFormatContext *s)
{ {
int ret, i; int ret, i;
...@@ -2615,11 +2648,12 @@ int av_write_header(AVFormatContext *s) ...@@ -2615,11 +2648,12 @@ int av_write_header(AVFormatContext *s)
if(s->oformat->codec_tag){ if(s->oformat->codec_tag){
if(st->codec->codec_tag){ if(st->codec->codec_tag){
//FIXME if (!validate_codec_tag(s, st)) {
//check that tag + id is in the table av_log(s, AV_LOG_ERROR,
//if neither is in the table -> OK "Tag 0x%08x incompatible with output codec\n",
//if tag is in the table with another id -> FAIL st->codec->codec_tag);
//if id is in the table with another tag -> FAIL unless strict < ? return AVERROR_INVALIDDATA;
}
}else }else
st->codec->codec_tag= av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id); st->codec->codec_tag= av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment