[FFmpeg-cvslog] avcodec/utils: split side-data in new decode API too

wm4 git at videolan.org
Fri Apr 29 10:35:46 CEST 2016


ffmpeg | branch: master | wm4 <nfxjfg at googlemail.com> | Thu Apr 28 15:34:15 2016 +0200| [66dd21d50be14a355e296b769d9d99090c0207f7] | committer: wm4

avcodec/utils: split side-data in new decode API too

The deprecated avcodec_decode_video2() and avcodec_decode_audio4()
functions called av_packet_split_side_data() on the input packets. This
is required for packets produced by libavformat with the
AVFMT_FLAG_KEEP_SIDE_DATA flag unset (which is unfortunately the
default).

The new API didn't do this yet, although it didn't matter as no decoder
supports the new API yet. The emulation layer for the old API calls the
old API functions, which took care of the splitting. Add this code to
the new API codec entrypoints too, because we shouldn't send essentially
corrupted data to decoders.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=66dd21d50be14a355e296b769d9d99090c0207f7
---

 libavcodec/utils.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 21ad3cf..ffbabb1 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2784,11 +2784,17 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke
 
     if (avctx->codec->send_packet) {
         if (avpkt) {
-            ret = apply_param_change(avctx, (AVPacket *)avpkt);
-            if (ret < 0)
-                return ret;
+            AVPacket tmp = *avpkt;
+            int did_split = av_packet_split_side_data(&tmp);
+            ret = apply_param_change(avctx, &tmp);
+            if (ret >= 0)
+                ret = avctx->codec->send_packet(avctx, &tmp);
+            if (did_split)
+                av_packet_free_side_data(&tmp);
+            return ret;
+        } else {
+            return avctx->codec->send_packet(avctx, NULL);
         }
-        return avctx->codec->send_packet(avctx, avpkt);
     }
 
     // Emulation via old API. Assume avpkt is likely not refcounted, while



More information about the ffmpeg-cvslog mailing list