[vlc-commits] demux: flac: create es from streaminfo (refs #17933)

Francois Cartegnie git at videolan.org
Fri Feb 10 12:12:59 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Feb 10 12:11:46 2017 +0100| [bdc690e9c0e2516c00a6d3733a77a87a25d9b6e3] | committer: Francois Cartegnie

demux: flac: create es from streaminfo (refs #17933)

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

 modules/demux/flac.c      | 16 ++++++++++------
 modules/packetizer/flac.c |  1 +
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index 8a2df0f..69730d8 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -150,11 +150,19 @@ static int Open( vlc_object_t * p_this )
     p_sys->i_cover_score = 0;
 
     es_format_Init( &fmt, AUDIO_ES, VLC_CODEC_FLAC );
+    fmt.b_packetized = true;
 
     /* We need to read and store the STREAMINFO metadata into fmt extra */
     if( ParseHeaders( p_demux, &fmt ) )
         goto error;
 
+    p_sys->p_es = es_out_Add( p_demux->out, &fmt );
+    if( !p_sys->p_es )
+    {
+        es_format_Clean( &fmt );
+        goto error;
+    }
+
     /* Load the FLAC packetizer */
     p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, "flac" );
     if( !p_sys->p_packetizer )
@@ -243,12 +251,6 @@ static int Demux( demux_t *p_demux )
 
             p_block_out->p_next = NULL;
 
-            if( p_sys->p_es == NULL )
-            {
-                p_sys->p_packetizer->fmt_out.b_packetized = true;
-                p_sys->p_es = es_out_Add( p_demux->out, &p_sys->p_packetizer->fmt_out);
-            }
-
             /* set PCR */
             if( unlikely(p_sys->i_pts == VLC_TS_INVALID) )
                 es_out_Control( p_demux->out, ES_OUT_SET_PCR, __MAX(p_block_out->i_dts - 1, VLC_TS_0) );
@@ -611,6 +613,8 @@ static void ParseStreamInfo( es_format_t *p_fmt, uint64_t *pi_count )
 {
     uint8_t *p_data = p_fmt->p_extra;
     p_fmt->audio.i_rate = GetDWBE(&p_data[4+6]) >> 12;
+    p_fmt->audio.i_channels = (p_data[12] & 0x0F >> 1) + 1;
+    p_fmt->audio.i_bitspersample = ((p_data[12] & 0x01) << 4) | p_data[13] >> 4;
     *pi_count = GetQWBE(&p_data[4+6]) &  ((INT64_C(1)<<36)-1);
 }
 
diff --git a/modules/packetizer/flac.c b/modules/packetizer/flac.c
index e82d5b3..2a945a0 100644
--- a/modules/packetizer/flac.c
+++ b/modules/packetizer/flac.c
@@ -810,6 +810,7 @@ static int Open(vlc_object_t *p_this)
     es_format_Copy(&p_dec->fmt_out, &p_dec->fmt_in);
     p_dec->fmt_out.i_cat   = AUDIO_ES;
     p_dec->fmt_out.i_codec = VLC_CODEC_FLAC;
+    p_dec->fmt_out.b_packetized = true;
 
     /* */
     p_dec->pf_decode    = NULL;



More information about the vlc-commits mailing list