diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-22 00:04:31 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-28 01:56:32 +0200 |
commit | 3f11eac75741888c7b2b6f93c458766f2613bab5 (patch) | |
tree | b20563a7c223c5f6b4263ab68a0f2e35d1ed6bbc /libavcodec | |
parent | f09fd1c6c70505916a3d1b21530b3f71d8118688 (diff) | |
download | ffmpeg-3f11eac75741888c7b2b6f93c458766f2613bab5.tar.gz |
avcodec/encode: Set AV_PKT_FLAG_KEY based upon AV_CODEC_PROP_INTRA_ONLY
Currently, the AV_PKT_FLAG_KEY is automatically set for audio encoders;
yet this is wrong, as both MLP and TrueHD have non-keyframes. So set it
based upon AV_CODEC_PROP_INTRA_ONLY (from the corresponding
AVCodecDescriptor) instead. This also sets it for some video codecs,
which is intended.
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/encode.c | 7 | ||||
-rw-r--r-- | libavcodec/internal.h | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 98dfbfdff3..dd25cf999b 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -235,12 +235,9 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) } } if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { - /* NOTE: if we add any audio encoders which output non-keyframe packets, - * this needs to be moved to the encoders, but for now we can do it - * here to simplify things */ - avpkt->flags |= AV_PKT_FLAG_KEY; avpkt->dts = avpkt->pts; } + avpkt->flags |= avci->intra_only_flag; } if (avci->draining && !got_packet) @@ -553,6 +550,8 @@ int ff_encode_preinit(AVCodecContext *avctx) } avctx->sw_pix_fmt = frames_ctx->sw_format; } + if (avctx->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY) + avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY; return 0; } diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 2111f2b9ae..b6180f15a5 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -153,6 +153,13 @@ typedef struct AVCodecInternal { uint8_t *byte_buffer; unsigned int byte_buffer_size; + /** + * This is set to AV_PKT_FLAG_KEY for encoders that encode intra-only + * formats (i.e. whose codec descriptor has AV_CODEC_PROP_INTRA_ONLY set). + * This is used to set said flag generically for said encoders. + */ + int intra_only_flag; + void *frame_thread_encoder; EncodeSimpleContext es; |