diff mbox series

[FFmpeg-devel,1/6] lavc/decode: stop mangling last_pkt_props->opaque

Message ID 20230310115635.13639-1-anton@khirnov.net
State Accepted
Commit a3bf63c26e6197a9b6e490538667368530a9dcd3
Headers show
Series [FFmpeg-devel,1/6] lavc/decode: stop mangling last_pkt_props->opaque | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov March 10, 2023, 11:56 a.m. UTC
It is currently abused to store packet size, which breaks
AV_CODEC_FLAG_COPY_OPAQUE.

Use stream_index instead, which is unused in libavcodec and has the
same type as size.
---
 libavcodec/decode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Anton Khirnov March 10, 2023, 12:11 p.m. UTC | #1
This will go into the 6.0 branch as well.
Martin Storsjö March 10, 2023, 12:39 p.m. UTC | #2
On Fri, 10 Mar 2023, Anton Khirnov wrote:

> It is currently abused to store packet size, which breaks
> AV_CODEC_FLAG_COPY_OPAQUE.
>
> Use stream_index instead, which is unused in libavcodec and has the
> same type as size.
> ---
> libavcodec/decode.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)

LGTM, thanks! (I didn't look at the rest of the patches.)

// Martin
Anton Khirnov March 11, 2023, 10:51 a.m. UTC | #3
pushed to master and 6.0
diff mbox series

Patch

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index be2be81089..d1ba7f167f 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -140,7 +140,7 @@  static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt)
     if (pkt) {
         ret = av_packet_copy_props(avci->last_pkt_props, pkt);
         if (!ret)
-            avci->last_pkt_props->opaque = (void *)(intptr_t)pkt->size; // Needed for ff_decode_frame_props().
+            avci->last_pkt_props->stream_index = pkt->size; // Needed for ff_decode_frame_props().
     }
     return ret;
 }
@@ -461,7 +461,7 @@  FF_ENABLE_DEPRECATION_WARNINGS
         pkt->dts                  = AV_NOPTS_VALUE;
         if (!(codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) {
             // See extract_packet_props() comment.
-            avci->last_pkt_props->opaque = (void *)((intptr_t)avci->last_pkt_props->opaque - consumed);
+            avci->last_pkt_props->stream_index = avci->last_pkt_props->stream_index - consumed;
             avci->last_pkt_props->pts = AV_NOPTS_VALUE;
             avci->last_pkt_props->dts = AV_NOPTS_VALUE;
         }
@@ -1355,7 +1355,7 @@  int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
         int ret = ff_decode_frame_props_from_pkt(avctx, frame, pkt);
         if (ret < 0)
             return ret;
-        frame->pkt_size     = (int)(intptr_t)pkt->opaque;
+        frame->pkt_size = pkt->stream_index;
     }
 #if FF_API_REORDERED_OPAQUE
 FF_DISABLE_DEPRECATION_WARNINGS