lavc: add a codec flag for propagating opaque from frames to packets

This is intended to be a more convenient replacement for
reordered_opaque.

Add support for it in the two encoders that offer
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE: libx264 and libx265. Other
encoders will be supported in future commits.
This commit is contained in:
Anton Khirnov
2022-07-12 11:25:09 +02:00
parent d0c8ca961d
commit 5c0348f3d6
7 changed files with 101 additions and 15 deletions

View File

@@ -636,6 +636,13 @@ int ff_encode_preinit(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE &&
!(avctx->codec->capabilities & AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE)) {
av_log(avctx, AV_LOG_ERROR, "The copy_opaque flag is set, but the "
"encoder does not support it.\n");
return AVERROR(EINVAL);
}
switch (avctx->codec_type) {
case AVMEDIA_TYPE_VIDEO: ret = encode_preinit_video(avctx); break;
case AVMEDIA_TYPE_AUDIO: ret = encode_preinit_audio(avctx); break;