diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-01-31 11:07:50 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-02-04 13:14:20 +0100 |
commit | d02340b9e3e72f401cddbeb3bcc3cb584902b886 (patch) | |
tree | 8110386a956be87c091e31a6e23bf773c2b3e5ac /libavcodec/decode.c | |
parent | 82da22066c0818b606812d479674929a229386e2 (diff) | |
download | ffmpeg-d02340b9e3e72f401cddbeb3bcc3cb584902b886.tar.gz |
lavc/decode: allow using AV_CODEC_FLAG_COPY_OPAQUE for decoding
Use it to propagate AVPacket.opaque[_ref] to corresponding AVFrame
fields. This is a more convenient alternative to reordered_opaque.
Diffstat (limited to 'libavcodec/decode.c')
-rw-r--r-- | libavcodec/decode.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 0abc88737b..17b398e933 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1291,7 +1291,8 @@ static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame) return av_packet_unpack_dictionary(side_metadata, size, frame_md); } -int ff_decode_frame_props_from_pkt(AVFrame *frame, const AVPacket *pkt) +int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx, + AVFrame *frame, const AVPacket *pkt) { static const struct { enum AVPacketSideDataType packet; @@ -1336,6 +1337,13 @@ int ff_decode_frame_props_from_pkt(AVFrame *frame, const AVPacket *pkt) frame->flags = (frame->flags & ~AV_FRAME_FLAG_DISCARD); } + if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + int ret = av_buffer_replace(&frame->opaque_ref, pkt->opaque_ref); + if (ret < 0) + return ret; + frame->opaque = pkt->opaque; + } + return 0; } @@ -1344,7 +1352,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) const AVPacket *pkt = avctx->internal->last_pkt_props; if (!(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { - int ret = ff_decode_frame_props_from_pkt(frame, pkt); + int ret = ff_decode_frame_props_from_pkt(avctx, frame, pkt); if (ret < 0) return ret; frame->pkt_size = (int)(intptr_t)pkt->opaque; |