You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
lavc/avcodec: simplify codec id/type validity checking
On entry to avcodec_open2(), the AVCodecContext type and id either have to be UNKNOWN/NONE or have to match the codec to be used.
This commit is contained in:
@@ -158,16 +158,14 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
|||||||
codec = avctx->codec;
|
codec = avctx->codec;
|
||||||
codec2 = ffcodec(codec);
|
codec2 = ffcodec(codec);
|
||||||
|
|
||||||
if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
|
if ((avctx->codec_type != AVMEDIA_TYPE_UNKNOWN && avctx->codec_type != codec->type) ||
|
||||||
avctx->codec_id == AV_CODEC_ID_NONE) {
|
(avctx->codec_id != AV_CODEC_ID_NONE && avctx->codec_id != codec->id)) {
|
||||||
avctx->codec_type = codec->type;
|
|
||||||
avctx->codec_id = codec->id;
|
|
||||||
}
|
|
||||||
if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type &&
|
|
||||||
avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
|
av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avctx->codec_type = codec->type;
|
||||||
|
avctx->codec_id = codec->id;
|
||||||
avctx->codec = codec;
|
avctx->codec = codec;
|
||||||
|
|
||||||
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
|
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
|
||||||
|
Reference in New Issue
Block a user