[vlc-devel] [PATCH 04/11] modules:packetizers: no need to initialize the fmt_out anymore

Steve Lhomme robux4 at videolabs.io
Thu Jul 13 15:44:37 CEST 2017


If it's the same as the source. Less boilerplate code is good.
---
 modules/codec/aes3.c            |  2 --
 modules/codec/spudec/spudec.c   |  1 -
 modules/packetizer/a52.c        |  4 ----
 modules/packetizer/avparser.c   |  2 --
 modules/packetizer/copy.c       |  4 ----
 modules/packetizer/dirac.c      |  2 --
 modules/packetizer/dts.c        |  4 ----
 modules/packetizer/flac.c       |  5 -----
 modules/packetizer/h264.c       |  4 ----
 modules/packetizer/hevc.c       |  3 ---
 modules/packetizer/mlp.c        |  2 --
 modules/packetizer/mpeg4audio.c |  9 ---------
 modules/packetizer/mpeg4video.c | 18 +-----------------
 modules/packetizer/mpegvideo.c  |  4 ----
 modules/packetizer/vc1.c        |  1 -
 15 files changed, 1 insertion(+), 64 deletions(-)

diff --git a/modules/codec/aes3.c b/modules/codec/aes3.c
index 2df8363192..bc9bd60b11 100644
--- a/modules/codec/aes3.c
+++ b/modules/codec/aes3.c
@@ -287,8 +287,6 @@ static int Open( decoder_t *p_dec, bool b_packetizer )
     /* Set callback */
     if( b_packetizer )
     {
-        p_dec->fmt_out.i_codec = VLC_CODEC_302M;
-
         p_dec->pf_decode       = NULL;
         p_dec->pf_packetize    = Packetize;
     }
diff --git a/modules/codec/spudec/spudec.c b/modules/codec/spudec/spudec.c
index 09aeb376e8..d4eec7f32b 100644
--- a/modules/codec/spudec/spudec.c
+++ b/modules/codec/spudec/spudec.c
@@ -115,7 +115,6 @@ static int PacketizerOpen( vlc_object_t *p_this )
     }
     p_dec->pf_packetize  = Packetize;
     p_dec->p_sys->b_packetizer = true;
-    es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
     p_dec->fmt_out.i_codec = VLC_CODEC_SPU;
 
     return VLC_SUCCESS;
diff --git a/modules/packetizer/a52.c b/modules/packetizer/a52.c
index 41a4a9955c..6e9f832578 100644
--- a/modules/packetizer/a52.c
+++ b/modules/packetizer/a52.c
@@ -333,10 +333,6 @@ static int Open( vlc_object_t *p_this )
 
     block_BytestreamInit( &p_sys->bytestream );
 
-    /* Set output properties (Passthrough ONLY) */
-    p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;
-    p_dec->fmt_out.audio = p_dec->fmt_in.audio;
-
     /* Set callback */
     p_dec->pf_packetize = PacketizeBlock;
     p_dec->pf_flush     = PacketizeFlush;
diff --git a/modules/packetizer/avparser.c b/modules/packetizer/avparser.c
index 5271d6aa23..075870feb8 100644
--- a/modules/packetizer/avparser.c
+++ b/modules/packetizer/avparser.c
@@ -131,7 +131,6 @@ int OpenPacketizer( vlc_object_t *p_this )
     p_sys->p_parser_ctx = p_ctx;
     p_sys->p_codec_ctx = p_codec_ctx;
     p_sys->i_offset = 0;
-    es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
 
     return VLC_SUCCESS;
 }
@@ -148,7 +147,6 @@ void ClosePacketizer( vlc_object_t *p_this )
         av_parser_close( p_dec->p_sys->p_parser_ctx );
         free( p_dec->p_sys );
     }
-    es_format_Clean( &p_dec->fmt_out );
 }
 
 /*****************************************************************************
diff --git a/modules/packetizer/copy.c b/modules/packetizer/copy.c
index 5f74a426ce..c1768f3597 100644
--- a/modules/packetizer/copy.c
+++ b/modules/packetizer/copy.c
@@ -90,9 +90,6 @@ static int Open( vlc_object_t *p_this )
         p_dec->pf_packetize = Packetize;
     p_dec->pf_flush = Flush;
 
-    /* Create the output format */
-    es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
-
     p_dec->p_sys = p_sys = malloc( sizeof(*p_sys) );
     if (unlikely(p_sys == NULL))
         return VLC_ENOMEM;
@@ -136,7 +133,6 @@ static void Close( vlc_object_t *p_this )
         block_ChainRelease( p_dec->p_sys->p_block );
     }
 
-    es_format_Clean( &p_dec->fmt_out );
     free( p_dec->p_sys );
 }
 
diff --git a/modules/packetizer/dirac.c b/modules/packetizer/dirac.c
index 359a046739..da94464b80 100644
--- a/modules/packetizer/dirac.c
+++ b/modules/packetizer/dirac.c
@@ -1375,8 +1375,6 @@ static int Open( vlc_object_t *p_this )
     p_dec->pf_packetize = Packetize;
     p_dec->pf_flush     = Flush;
 
-    /* Create the output format */
-    es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
     p_dec->p_sys = p_sys = calloc( 1, sizeof( decoder_sys_t ) );
 
     if( !p_sys )
diff --git a/modules/packetizer/dts.c b/modules/packetizer/dts.c
index 44239847b3..e62336efa5 100644
--- a/modules/packetizer/dts.c
+++ b/modules/packetizer/dts.c
@@ -354,10 +354,6 @@ static int Open( vlc_object_t *p_this )
     memset(&p_sys->dts, 0, sizeof(vlc_dts_header_t));
     block_BytestreamInit( &p_sys->bytestream );
 
-    /* Set output properties (passthrough only) */
-    p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;
-    p_dec->fmt_out.audio = p_dec->fmt_in.audio;
-
     /* Set callback */
     p_dec->pf_packetize = PacketizeBlock;
     p_dec->pf_flush     = PacketizeFlush;
diff --git a/modules/packetizer/flac.c b/modules/packetizer/flac.c
index 4e287bdba9..8c17c80dca 100644
--- a/modules/packetizer/flac.c
+++ b/modules/packetizer/flac.c
@@ -807,10 +807,6 @@ static int Open(vlc_object_t *p_this)
     block_BytestreamInit(&p_sys->bytestream);
 
     /* */
-    es_format_Copy(&p_dec->fmt_out, &p_dec->fmt_in);
-    p_dec->fmt_out.i_codec = VLC_CODEC_FLAC;
-
-    /* */
     p_dec->pf_decode    = NULL;
     p_dec->pf_packetize = Packetize;
     p_dec->pf_flush     = Flush;
@@ -823,7 +819,6 @@ static void Close(vlc_object_t *p_this)
     decoder_t *p_dec = (decoder_t *)p_this;
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    es_format_Clean(&p_dec->fmt_out);
     block_BytestreamRelease(&p_sys->bytestream);
     free(p_sys->p_buf);
     free(p_sys);
diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 1683c0318c..6756c8755b 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -347,10 +347,6 @@ static int Open( vlc_object_t *p_this )
     date_Init( &p_sys->dts, 30000 * 2, 1001 );
     date_Set( &p_sys->dts, VLC_TS_INVALID );
 
-    /* Setup properties */
-    es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
-    p_dec->fmt_out.i_codec = VLC_CODEC_H264;
-
     if( p_dec->fmt_in.video.i_frame_rate_base &&
         p_dec->fmt_in.video.i_frame_rate )
     {
diff --git a/modules/packetizer/hevc.c b/modules/packetizer/hevc.c
index 10eb42028b..5debaf69f1 100644
--- a/modules/packetizer/hevc.c
+++ b/modules/packetizer/hevc.c
@@ -184,9 +184,6 @@ static int Open(vlc_object_t *p_this)
                     p_hevc_startcode, 1, 5,
                     PacketizeReset, PacketizeParse, PacketizeValidate, p_dec);
 
-    /* Copy properties */
-    es_format_Copy(&p_dec->fmt_out, &p_dec->fmt_in);
-
     /* Init timings */
     if( p_dec->fmt_in.video.i_frame_rate_base > 0 )
         date_Init( &p_sys->dts, p_dec->fmt_in.video.i_frame_rate * 2,
diff --git a/modules/packetizer/mlp.c b/modules/packetizer/mlp.c
index 389fefe687..6a05e0f06b 100644
--- a/modules/packetizer/mlp.c
+++ b/modules/packetizer/mlp.c
@@ -487,8 +487,6 @@ static int Open( vlc_object_t *p_this )
     p_sys->b_mlp = false;
     p_sys->b_discontinuity = false;
 
-    /* Set output properties (Passthrough only) */
-    p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;
     p_dec->fmt_out.audio.i_rate = 0;
 
     /* Set callback */
diff --git a/modules/packetizer/mpeg4audio.c b/modules/packetizer/mpeg4audio.c
index 45ff7e2af7..929eccea9d 100644
--- a/modules/packetizer/mpeg4audio.c
+++ b/modules/packetizer/mpeg4audio.c
@@ -219,9 +219,6 @@ static int OpenPacketizer(vlc_object_t *p_this)
     p_sys->b_latm_cfg = false;
     p_sys->i_warnings = 0;
 
-    /* Set output properties */
-    p_dec->fmt_out.i_codec = VLC_CODEC_MP4A;
-
     msg_Dbg(p_dec, "running MPEG4 audio packetizer");
 
     /*
@@ -257,12 +254,6 @@ static int OpenPacketizer(vlc_object_t *p_this)
             break;
     }
 
-    /* Some mux (avi) do send RAW AAC without extradata,
-       and LATM can be sent with out-of-band audioconfig,
-       (avformat sets m4a extradata in both cases)
-       so we can't rely on extradata to guess multiplexing */
-    p_dec->fmt_out.audio.i_rate = p_dec->fmt_in.audio.i_rate;
-
     if(p_dec->fmt_in.i_extra)
     {
         mpeg4_asc_t asc;
diff --git a/modules/packetizer/mpeg4video.c b/modules/packetizer/mpeg4video.c
index 6932660c30..acb209fa18 100644
--- a/modules/packetizer/mpeg4video.c
+++ b/modules/packetizer/mpeg4video.c
@@ -154,29 +154,13 @@ static int Open( vlc_object_t *p_this )
     p_sys->pp_last = &p_sys->p_frame;
 
     /* Setup properties */
-    es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
-    p_dec->fmt_out.i_codec = VLC_CODEC_MP4V;
-
-    free(p_dec->fmt_out.p_extra);
-
-    if( p_dec->fmt_in.i_extra )
+    if( p_dec->fmt_out.i_extra )
     {
         /* We have a vol */
-        p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
-        p_dec->fmt_out.p_extra = xmalloc( p_dec->fmt_in.i_extra );
-        memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra,
-                p_dec->fmt_in.i_extra );
-
         msg_Dbg( p_dec, "opening with vol size: %d", p_dec->fmt_in.i_extra );
         ParseVOL( p_dec, &p_dec->fmt_out,
                   p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
     }
-    else
-    {
-        /* No vol, we'll have to look for one later on */
-        p_dec->fmt_out.i_extra = 0;
-        p_dec->fmt_out.p_extra = 0;
-    }
 
     /* Set callback */
     p_dec->pf_packetize = Packetize;
diff --git a/modules/packetizer/mpegvideo.c b/modules/packetizer/mpegvideo.c
index a538582322..5366a00d06 100644
--- a/modules/packetizer/mpegvideo.c
+++ b/modules/packetizer/mpegvideo.c
@@ -166,10 +166,6 @@ static int Open( vlc_object_t *p_this )
     if( p_dec->fmt_in.i_codec != VLC_CODEC_MPGV )
         return VLC_EGENERIC;
 
-    es_format_Init( &p_dec->fmt_out, VIDEO_ES, VLC_CODEC_MPGV );
-    p_dec->fmt_out.i_original_fourcc = p_dec->fmt_in.i_original_fourcc;
-
-
     p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
     if( !p_dec->p_sys )
         return VLC_ENOMEM;
diff --git a/modules/packetizer/vc1.c b/modules/packetizer/vc1.c
index 56bb19d094..fae2f7b698 100644
--- a/modules/packetizer/vc1.c
+++ b/modules/packetizer/vc1.c
@@ -151,7 +151,6 @@ static int Open( vlc_object_t *p_this )
     p_dec->pf_get_cc = GetCc;
 
     /* Create the output format */
-    es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
     p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
     if( unlikely( !p_sys ) )
         return VLC_ENOMEM;
-- 
2.12.1



More information about the vlc-devel mailing list