[vlc-commits] tospdif: do filter even if the input is not correctly packetized

Thomas Guillem git at videolan.org
Fri Oct 14 12:59:27 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Oct 14 12:50:09 2016 +0200| [fe596ddf1cee4479368774f4860d43cbd7a3848a] | committer: Thomas Guillem

tospdif: do filter even if the input is not correctly packetized

This module doesn't depend of the demux/packetizer modules anymore. A52/DTS
packetizers helpers will be used if the input is not packetized

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

 modules/audio_filter/Makefile.am         |  3 ++-
 modules/audio_filter/converter/tospdif.c | 27 ++++++++++++++++++++++-----
 modules/codec/spdif.c                    |  2 --
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/modules/audio_filter/Makefile.am b/modules/audio_filter/Makefile.am
index 5839381..7ee0125 100644
--- a/modules/audio_filter/Makefile.am
+++ b/modules/audio_filter/Makefile.am
@@ -81,7 +81,8 @@ libaudio_format_plugin_la_CPPFLAGS = $(AM_CPPFLAGS)
 libaudio_format_plugin_la_LIBADD = $(LIBM)
 
 libtospdif_plugin_la_SOURCES = audio_filter/converter/tospdif.c \
-	packetizer/a52.h
+	packetizer/a52.h \
+	packetizer/dts_header.c packetizer/dts_header.h
 
 audio_filter_LTLIBRARIES += \
 	libtospdif_plugin.la \
diff --git a/modules/audio_filter/converter/tospdif.c b/modules/audio_filter/converter/tospdif.c
index f1e827d..9c07718 100644
--- a/modules/audio_filter/converter/tospdif.c
+++ b/modules/audio_filter/converter/tospdif.c
@@ -38,6 +38,7 @@
 #include <vlc_filter.h>
 
 #include "../packetizer/a52.h"
+#include "../packetizer/dts_header.h"
 
 static int  Open( vlc_object_t * );
 static void Close( vlc_object_t * );
@@ -202,7 +203,16 @@ static int write_buffer_ac3( filter_t *p_filter, block_t *p_in_buf )
     if( unlikely( p_in_buf->i_buffer < 6
      || p_in_buf->i_buffer > A52_FRAME_NB * 4
      || p_in_buf->i_nb_samples != A52_FRAME_NB ) )
-        return SPDIF_ERROR;
+    {
+        /* Input is not correctly packetizer. Try to parse the buffer in order
+         * to get the mandatory informations to play AC3 over S/PDIF */
+        vlc_a52_header_t a52;
+        if( vlc_a52_header_Parse( &a52, p_in_buf->p_buffer, p_in_buf->i_buffer )
+            != VLC_SUCCESS || a52.b_eac3 )
+            return SPDIF_ERROR;
+        p_in_buf->i_buffer = a52.i_size;
+        p_in_buf->i_nb_samples = a52.i_samples;
+    }
 
     if( write_init( p_filter, p_in_buf, A52_FRAME_NB * 4, A52_FRAME_NB ) )
         return SPDIF_ERROR;
@@ -340,6 +350,17 @@ static int write_buffer_truehd( filter_t *p_filter, block_t *p_in_buf )
 static int write_buffer_dts( filter_t *p_filter, block_t *p_in_buf )
 {
     uint16_t i_data_type;
+    if( p_in_buf->i_nb_samples == 0 )
+    {
+        /* Input is not correctly packetizer. Try to parse the buffer in order
+         * to get the mandatory informations to play DTS over S/PDIF */
+        vlc_dts_header_t header;
+        if( vlc_dts_header_Parse( &header, p_in_buf->p_buffer,
+                                  p_in_buf->i_buffer ) != VLC_SUCCESS )
+            return SPDIF_ERROR;
+        p_in_buf->i_nb_samples = header.i_frame_length;
+        p_in_buf->i_buffer = header.i_frame_size;
+    }
     switch( p_in_buf->i_nb_samples )
     {
     case  512:
@@ -426,10 +447,6 @@ static int Open( vlc_object_t *p_this )
     filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys;
 
-    if( p_filter->fmt_in.audio.i_frame_length == 0
-     || p_filter->fmt_in.audio.i_bytes_per_frame == 0 )
-        return VLC_EGENERIC;
-
     if( ( p_filter->fmt_in.audio.i_format != VLC_CODEC_DTS &&
           p_filter->fmt_in.audio.i_format != VLC_CODEC_A52 &&
           p_filter->fmt_in.audio.i_format != VLC_CODEC_EAC3 &&
diff --git a/modules/codec/spdif.c b/modules/codec/spdif.c
index 2c2ec0d..4fff770 100644
--- a/modules/codec/spdif.c
+++ b/modules/codec/spdif.c
@@ -85,8 +85,6 @@ OpenDecoder(vlc_object_t *p_this)
     p_dec->fmt_out.audio.i_format = p_dec->fmt_out.i_codec;
 
     if (p_dec->fmt_out.audio.i_channels == 0
-     || p_dec->fmt_out.audio.i_bytes_per_frame == 0
-     || p_dec->fmt_out.audio.i_frame_length == 0
      || decoder_UpdateAudioFormat(p_dec))
     {
         es_format_Init(&p_dec->fmt_out, UNKNOWN_ES, 0);



More information about the vlc-commits mailing list