mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Merge commit 'e767c9e8f2eaa116b61b8b6881b401b54bd320f5'
* commit 'e767c9e8f2eaa116b61b8b6881b401b54bd320f5': flv: Validate and reject unsupported codecs Conflicts: libavformat/flvenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
735ab7c5e0
@ -325,6 +325,17 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
|
|||||||
avio_wb32(pb, data_size + 11);
|
avio_wb32(pb, data_size + 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int unsupported_codec(AVFormatContext *s,
|
||||||
|
const char* type, int codec_id)
|
||||||
|
{
|
||||||
|
const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
|
||||||
|
av_log(s, AV_LOG_ERROR,
|
||||||
|
"%s codec %s not compatible with flv\n",
|
||||||
|
type,
|
||||||
|
desc ? desc->name : "unknown");
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
}
|
||||||
|
|
||||||
static int flv_write_header(AVFormatContext *s)
|
static int flv_write_header(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -347,11 +358,9 @@ static int flv_write_header(AVFormatContext *s)
|
|||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
flv->video_enc = enc;
|
flv->video_enc = enc;
|
||||||
if (enc->codec_tag == 0) {
|
if (!ff_codec_get_tag(flv_video_codec_ids, enc->codec_id))
|
||||||
av_log(s, AV_LOG_ERROR, "Video codec '%s' for stream %d is not compatible with FLV\n",
|
return unsupported_codec(s, "Video", enc->codec_id);
|
||||||
avcodec_get_name(enc->codec_id), i);
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
}
|
|
||||||
if (enc->codec_id == AV_CODEC_ID_MPEG4 ||
|
if (enc->codec_id == AV_CODEC_ID_MPEG4 ||
|
||||||
enc->codec_id == AV_CODEC_ID_H263) {
|
enc->codec_id == AV_CODEC_ID_H263) {
|
||||||
int error = s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL;
|
int error = s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL;
|
||||||
@ -376,17 +385,14 @@ static int flv_write_header(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
flv->audio_enc = enc;
|
flv->audio_enc = enc;
|
||||||
if (get_audio_flags(s, enc) < 0)
|
if (get_audio_flags(s, enc) < 0)
|
||||||
return AVERROR_INVALIDDATA;
|
return unsupported_codec(s, "Audio", enc->codec_id);
|
||||||
if (enc->codec_id == AV_CODEC_ID_PCM_S16BE)
|
if (enc->codec_id == AV_CODEC_ID_PCM_S16BE)
|
||||||
av_log(s, AV_LOG_WARNING,
|
av_log(s, AV_LOG_WARNING,
|
||||||
"16-bit big-endian audio in flv is valid but most likely unplayable (hardware dependent); use s16le\n");
|
"16-bit big-endian audio in flv is valid but most likely unplayable (hardware dependent); use s16le\n");
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_DATA:
|
case AVMEDIA_TYPE_DATA:
|
||||||
if (enc->codec_id != AV_CODEC_ID_TEXT && enc->codec_id != AV_CODEC_ID_NONE) {
|
if (enc->codec_id != AV_CODEC_ID_TEXT && enc->codec_id != AV_CODEC_ID_NONE)
|
||||||
av_log(s, AV_LOG_ERROR, "Data codec '%s' for stream %d is not compatible with FLV\n",
|
return unsupported_codec(s, "Data", enc->codec_id);
|
||||||
avcodec_get_name(enc->codec_id), i);
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
flv->data_enc = enc;
|
flv->data_enc = enc;
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_SUBTITLE:
|
case AVMEDIA_TYPE_SUBTITLE:
|
||||||
@ -536,13 +542,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
avio_w8(pb, FLV_TAG_TYPE_VIDEO);
|
avio_w8(pb, FLV_TAG_TYPE_VIDEO);
|
||||||
|
|
||||||
flags = enc->codec_tag;
|
flags = ff_codec_get_tag(flv_video_codec_ids, enc->codec_id);
|
||||||
if (flags <= 0 || flags > 15) {
|
|
||||||
av_log(s, AV_LOG_ERROR,
|
|
||||||
"Video codec '%s' is not compatible with FLV\n",
|
|
||||||
avcodec_get_name(enc->codec_id));
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
|
flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user