[vlc-devel] [PATCH 3/4] decoder: remove b_need_packetized

Thomas Guillem thomas at gllm.fr
Mon Sep 7 16:53:17 CEST 2015


When needed (fmt->b_packetized == false), create a packetizer before creating a
decoder. The fmt_in of the decoder is copied either from the fmt_out of the
packetizer, or from the fmt of CreateDecoder.
---
 include/vlc_codec.h              |  3 ---
 modules/codec/avcodec/avcodec.c  |  2 --
 modules/codec/avcodec/video.c    |  3 ---
 modules/codec/crystalhd.c        |  1 -
 modules/codec/faad.c             |  3 ---
 modules/codec/flac.c             |  3 ---
 modules/codec/gstdecode.c        |  2 --
 modules/codec/mft.c              |  1 -
 modules/codec/omxil/mediacodec.c |  1 -
 modules/codec/omxil/omxil.c      |  2 --
 modules/codec/videotoolbox.m     |  2 --
 modules/codec/vpx.c              |  1 -
 modules/hw/mmal/codec.c          |  1 -
 src/input/decoder.c              | 10 ++++------
 14 files changed, 4 insertions(+), 31 deletions(-)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 0c43978..0028eff 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -62,9 +62,6 @@ struct decoder_t
     /* Output format of decoder/packetizer */
     es_format_t         fmt_out;
 
-    /* Some decoders only accept packetized data (ie. not truncated) */
-    bool                b_need_packetized;
-
     /* Tell the decoder if it is allowed to drop frames */
     bool                b_frame_drop_allowed;
 
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 2251cda..5402f69 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -326,8 +326,6 @@ static int OpenDecoder( vlc_object_t *p_this )
     if( avctx->level != FF_LEVEL_UNKNOWN)
         p_dec->fmt_in.i_level = avctx->level;
 
-    p_dec->b_need_packetized = true;
-
     return VLC_SUCCESS;
 }
 
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 7e05a5f..89b39ab 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -495,9 +495,6 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
 
     p_dec->pf_decode_video = DecodeVideo;
 
-    if ( p_dec->fmt_in.i_codec == VLC_CODEC_VP9 )
-        p_dec->b_need_packetized = true;
-
     return VLC_SUCCESS;
 }
 
diff --git a/modules/codec/crystalhd.c b/modules/codec/crystalhd.c
index d3b99ba..87c2134 100644
--- a/modules/codec/crystalhd.c
+++ b/modules/codec/crystalhd.c
@@ -348,7 +348,6 @@ static int OpenDecoder( vlc_object_t *p_this )
     p_dec->fmt_out.i_codec        = VLC_CODEC_YUYV;
     p_dec->fmt_out.video.i_width  = p_dec->fmt_in.video.i_width;
     p_dec->fmt_out.video.i_height = p_dec->fmt_in.video.i_height;
-    p_dec->b_need_packetized      = true;
 
     /* Set callbacks */
     p_dec->pf_decode_video = DecodeBlock;
diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 6185af9..ae8fed8 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -192,9 +192,6 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_buffer = p_sys->i_buffer_size = 0;
     p_sys->p_buffer = NULL;
 
-    /* Faad2 can't deal with truncated data (eg. from MPEG TS) */
-    p_dec->b_need_packetized = true;
-
     p_sys->b_sbr = p_sys->b_ps = false;
 
     p_dec->pf_decode_audio = DecodeBlock;
diff --git a/modules/codec/flac.c b/modules/codec/flac.c
index eaf8175..9fc69f8 100644
--- a/modules/codec/flac.c
+++ b/modules/codec/flac.c
@@ -359,9 +359,6 @@ static int OpenDecoder( vlc_object_t *p_this )
     /* Set callbacks */
     p_dec->pf_decode_audio = DecodeBlock;
 
-    /* */
-    p_dec->b_need_packetized = true;
-
     return VLC_SUCCESS;
 }
 
diff --git a/modules/codec/gstdecode.c b/modules/codec/gstdecode.c
index f623b9c..a2acf69 100644
--- a/modules/codec/gstdecode.c
+++ b/modules/codec/gstdecode.c
@@ -624,8 +624,6 @@ static int OpenDecoder( vlc_object_t *p_this )
             "set state failure", VLC_EGENERIC );
     p_sys->b_running = true;
 
-    /* Force packetized for now */
-    p_dec->b_need_packetized = true;
     /* Set callbacks */
     p_dec->pf_decode_video = DecodeBlock;
 
diff --git a/modules/codec/mft.c b/modules/codec/mft.c
index a61fa00..696319a 100644
--- a/modules/codec/mft.c
+++ b/modules/codec/mft.c
@@ -1155,7 +1155,6 @@ int Open(vlc_object_t *p_this)
     }
 
     p_dec->fmt_out.i_cat = p_dec->fmt_in.i_cat;
-    p_dec->b_need_packetized = true;
 
     return VLC_SUCCESS;
 
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 62987f6..b9ae3f7 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -561,7 +561,6 @@ static int OpenDecoder(vlc_object_t *p_this, pf_MediaCodecApi_init pf_init)
     p_dec->fmt_out.i_cat = p_dec->fmt_in.i_cat;
     p_dec->fmt_out.video = p_dec->fmt_in.video;
     p_dec->fmt_out.audio = p_dec->fmt_in.audio;
-    p_dec->b_need_packetized = true;
     p_sys->mime = mime;
     p_sys->b_new_block = true;
 
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 773d7b0..0700220 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -1249,8 +1249,6 @@ static int OpenGeneric( vlc_object_t *p_this, bool b_encode )
 
     if(p_sys->b_error) goto error;
 
-    p_dec->b_need_packetized = true;
-
     if (!p_sys->b_use_pts)
         msg_Dbg( p_dec, "using dts timestamp mode for %s", p_sys->psz_component);
 
diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index c9b15d2..0d2e3e9 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -660,8 +660,6 @@ static int OpenDecoder(vlc_object_t *p_this)
         p_dec->fmt_out.i_codec = VLC_CODEC_I420;
     }
 
-    p_dec->b_need_packetized = true;
-
     p_dec->pf_decode_video = DecodeBlock;
 
     msg_Info(p_dec, "Using Video Toolbox to decode '%4.4s'", (char *)&p_dec->fmt_in.i_codec);
diff --git a/modules/codec/vpx.c b/modules/codec/vpx.c
index 1707e72..f17444a 100644
--- a/modules/codec/vpx.c
+++ b/modules/codec/vpx.c
@@ -201,7 +201,6 @@ static int Open(vlc_object_t *p_this)
     dec->fmt_out.video.i_width = dec->fmt_in.video.i_width;
     dec->fmt_out.video.i_height = dec->fmt_in.video.i_height;
     dec->fmt_out.i_codec = VLC_CODEC_I420;
-    dec->b_need_packetized = true;
 
     return VLC_SUCCESS;
 }
diff --git a/modules/hw/mmal/codec.c b/modules/hw/mmal/codec.c
index 38fda50..dca8db5 100644
--- a/modules/hw/mmal/codec.c
+++ b/modules/hw/mmal/codec.c
@@ -116,7 +116,6 @@ static int OpenDecoder(decoder_t *dec)
         goto out;
     }
     dec->p_sys = sys;
-    dec->b_need_packetized = true;
 
     sys->opaque = var_InheritBool(dec, MMAL_OPAQUE_NAME);
     bcm_host_init();
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 39c6b10..b2b1440 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -142,7 +142,6 @@ static void LoadDecoder( decoder_t *p_dec, bool b_packetizer,
                          const es_format_t *p_fmt )
 {
     p_dec->b_frame_drop_allowed = true;
-    p_dec->b_need_packetized = false;
     p_dec->i_extra_picture_buffers = 0;
     p_dec->p_description = NULL;
 
@@ -1628,14 +1627,13 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
     p_dec->pf_get_display_date = DecoderGetDisplayDate;
     p_dec->pf_get_display_rate = DecoderGetDisplayRate;
 
+    /* Load a packetizer module if input is not already packetized */
+    if( !b_packetizer && !fmt->b_packetized )
+        fmt = LoadPacketizer( p_dec, fmt );
+
     /* Find a suitable decoder/packetizer module */
     LoadDecoder( p_dec, b_packetizer, fmt );
 
-    /* Check if decoder requires already packetized data */
-    if( !b_packetizer &&
-        p_dec->b_need_packetized && !p_dec->fmt_in.b_packetized )
-        LoadPacketizer( p_dec );
-
     /* Copy ourself the input replay gain */
     if( fmt->i_cat == AUDIO_ES )
     {
-- 
2.1.4



More information about the vlc-devel mailing list