[vlc-commits] codec: avcodec: drop DVB spu frame header/trailer

Francois Cartegnie git at videolan.org
Mon Dec 18 22:12:13 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Dec 18 17:33:33 2017 +0100| [37fe8eabf10bc850036d787d8677a85046e737b7] | committer: Francois Cartegnie

codec: avcodec: drop DVB spu frame header/trailer

and set expected extradata.
maps to avcodec expected format

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=37fe8eabf10bc850036d787d8677a85046e737b7
---

 modules/codec/avcodec/subtitle.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c
index 5cac6339d6..b03dd648d0 100644
--- a/modules/codec/avcodec/subtitle.c
+++ b/modules/codec/avcodec/subtitle.c
@@ -90,6 +90,29 @@ int InitSubtitleDec(vlc_object_t *obj)
     context->extradata_size = 0;
     context->extradata = NULL;
 
+    if( codec->id == AV_CODEC_ID_DVB_SUBTITLE )
+    {
+        if( dec->fmt_in.i_extra > 3 )
+        {
+            context->extradata = malloc( dec->fmt_in.i_extra );
+            if( context->extradata )
+            {
+                context->extradata_size = dec->fmt_in.i_extra;
+                memcpy( context->extradata, dec->fmt_in.p_extra, dec->fmt_in.i_extra );
+            }
+        }
+        else
+        {
+            context->extradata = malloc( 4 );
+            if( context->extradata )
+            {
+                context->extradata_size = 4;
+                SetWBE( &context->extradata[0], dec->fmt_in.subs.dvb.i_id & 0xFFFF );
+                SetWBE( &context->extradata[2], dec->fmt_in.subs.dvb.i_id >> 16 );
+            }
+        }
+    }
+
 #if LIBAVFORMAT_VERSION_MICRO >= 100
     av_codec_set_pkt_timebase(context, AV_TIME_BASE_Q);
 #endif
@@ -182,6 +205,12 @@ static subpicture_t *DecodeBlock(decoder_t *dec, block_t **block_ptr)
     block->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE;
     memset(&block->p_buffer[block->i_buffer], 0, FF_INPUT_BUFFER_PADDING_SIZE);
 
+    if( sys->p_codec->id == AV_CODEC_ID_DVB_SUBTITLE && block->i_buffer > 3 )
+    {
+        block->p_buffer += 2; /* drop data identifier / stream id */
+        block->i_buffer -= 3; /* drop 0x3F/FF */
+    }
+
     /* */
     AVSubtitle subtitle;
     memset(&subtitle, 0, sizeof(subtitle));



More information about the vlc-commits mailing list