[FFmpeg-cvslog] lavc/utils: make sub decode consistent with A/V.

Clément Bœsch git at videolan.org
Thu Oct 25 00:04:14 CEST 2012


ffmpeg | branch: master | Clément Bœsch <ubitux at gmail.com> | Sun Oct 21 00:16:11 2012 +0200| [60d9ee1b75b37e9d188cf7321d0d74d8714da696] | committer: Clément Bœsch

lavc/utils: make sub decode consistent with A/V.

This allows side data to be transmitted properly with subtitles.

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

 libavcodec/utils.c |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index d7c3ecb..2029b53 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1852,22 +1852,39 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
                              int *got_sub_ptr,
                              AVPacket *avpkt)
 {
-    int ret;
+    int ret = 0;
 
     if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) {
         av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n");
         return AVERROR(EINVAL);
     }
 
-    avctx->pkt = avpkt;
     *got_sub_ptr = 0;
     avcodec_get_subtitle_defaults(sub);
+
+    if (avpkt->size) {
+        AVPacket tmp = *avpkt;
+        int did_split = av_packet_split_side_data(&tmp);
+        //apply_param_change(avctx, &tmp);
+
+        avctx->pkt = &tmp;
+
     if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE)
         sub->pts = av_rescale_q(avpkt->pts,
                                 avctx->pkt_timebase, AV_TIME_BASE_Q);
-    ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt);
+        ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &tmp);
+
+        avctx->pkt = NULL;
+        if (did_split) {
+            ff_packet_free_side_data(&tmp);
+            if(ret == tmp.size)
+                ret = avpkt->size;
+        }
+
     if (*got_sub_ptr)
         avctx->frame_number++;
+    }
+
     return ret;
 }
 



More information about the ffmpeg-cvslog mailing list