mirror of https://git.ffmpeg.org/ffmpeg.git
lavf/movenc: Fail when codec tag is invalid for format
Fixes ticket #6897 Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
981178f3b0
commit
4cfb01d6ae
|
@ -1535,9 +1535,9 @@ static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track)
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track)
|
static unsigned int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track)
|
||||||
{
|
{
|
||||||
int tag = track->par->codec_tag;
|
unsigned int tag = track->par->codec_tag;
|
||||||
|
|
||||||
if (!tag || (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
|
if (!tag || (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
|
||||||
(track->par->codec_id == AV_CODEC_ID_DVVIDEO ||
|
(track->par->codec_id == AV_CODEC_ID_DVVIDEO ||
|
||||||
|
@ -1589,31 +1589,45 @@ static const AVCodecTag codec_cover_image_tags[] = {
|
||||||
{ AV_CODEC_ID_NONE, 0 },
|
{ AV_CODEC_ID_NONE, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
|
static unsigned int validate_codec_tag(const AVCodecTag *const *tags,
|
||||||
|
unsigned int tag, int codec_id)
|
||||||
{
|
{
|
||||||
int tag;
|
int i;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that tag + id is in the table
|
||||||
|
*/
|
||||||
|
for (i = 0; tags && tags[i]; i++) {
|
||||||
|
const AVCodecTag *codec_tags = tags[i];
|
||||||
|
while (codec_tags->id != AV_CODEC_ID_NONE) {
|
||||||
|
if (avpriv_toupper4(codec_tags->tag) == avpriv_toupper4(tag) &&
|
||||||
|
codec_tags->id == codec_id)
|
||||||
|
return codec_tags->tag;
|
||||||
|
codec_tags++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
|
||||||
|
{
|
||||||
|
unsigned int tag;
|
||||||
|
|
||||||
if (is_cover_image(track->st))
|
if (is_cover_image(track->st))
|
||||||
return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id);
|
return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id);
|
||||||
|
|
||||||
if (track->mode == MODE_MP4 || track->mode == MODE_PSP)
|
if (track->mode == MODE_IPOD)
|
||||||
tag = track->par->codec_tag;
|
|
||||||
else if (track->mode == MODE_ISM)
|
|
||||||
tag = track->par->codec_tag;
|
|
||||||
else if (track->mode == MODE_IPOD) {
|
|
||||||
if (!av_match_ext(s->url, "m4a") &&
|
if (!av_match_ext(s->url, "m4a") &&
|
||||||
!av_match_ext(s->url, "m4v") &&
|
!av_match_ext(s->url, "m4v") &&
|
||||||
!av_match_ext(s->url, "m4b"))
|
!av_match_ext(s->url, "m4b"))
|
||||||
av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
|
av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
|
||||||
"Quicktime/Ipod might not play the file\n");
|
"Quicktime/Ipod might not play the file\n");
|
||||||
tag = track->par->codec_tag;
|
|
||||||
} else if (track->mode & MODE_3GP)
|
|
||||||
tag = track->par->codec_tag;
|
|
||||||
else if (track->mode == MODE_F4V)
|
|
||||||
tag = track->par->codec_tag;
|
|
||||||
else
|
|
||||||
tag = mov_get_codec_tag(s, track);
|
|
||||||
|
|
||||||
|
if (track->mode == MODE_MOV)
|
||||||
|
tag = mov_get_codec_tag(s, track);
|
||||||
|
else
|
||||||
|
tag = validate_codec_tag(s->oformat->codec_tag, track->par->codec_tag,
|
||||||
|
track->par->codec_id);
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue