[vlc-commits] demux: xiph: improve old ffmpeg xiph extradata test

Francois Cartegnie git at videolan.org
Wed Aug 14 18:13:25 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul 29 14:03:46 2019 +0200| [1f073245f0c75096a075bc5c7075db660a8b1189] | committer: Hugo Beauzée-Luyssen

demux: xiph: improve old ffmpeg xiph extradata test

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

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

 modules/codec/opus_header.c |  1 +
 modules/demux/xiph.h        | 18 ++++++++++++++----
 modules/mux/ogg.c           |  3 ++-
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/modules/codec/opus_header.c b/modules/codec/opus_header.c
index 08dd5dbef5..a19d9c73f7 100644
--- a/modules/codec/opus_header.c
+++ b/modules/codec/opus_header.c
@@ -35,6 +35,7 @@
 #include <stdlib.h>
 
 #include <vlc_common.h>
+#include <vlc_codec.h>
 #include "../demux/xiph.h"
 
 /* Header contents:
diff --git a/modules/demux/xiph.h b/modules/demux/xiph.h
index 34917ab637..c0b2ec8330 100644
--- a/modules/demux/xiph.h
+++ b/modules/demux/xiph.h
@@ -25,9 +25,18 @@
 #define XIPH_MAX_HEADER_COUNT (256)
 
 /* Temp ffmpeg vorbis format */
-static inline bool xiph_IsLavcFormat(const void *extra, unsigned i_extra)
+static inline bool xiph_IsLavcFormat(const void *extra, unsigned i_extra,
+                                     vlc_fourcc_t i_codec)
 {
-    return (i_extra >= 6 && GetWBE(extra) == 30);
+    switch(i_codec)
+    {
+        case VLC_CODEC_VORBIS:
+            return i_extra >= 6 && GetWBE(extra) == 30;
+        case VLC_CODEC_THEORA:
+            return i_extra >= 6 && GetWBE(extra) == 42;
+        default:
+            return false;
+    }
 }
 
 static inline unsigned xiph_CountLavcHeaders(const void *p_extra, unsigned i_extra)
@@ -58,9 +67,10 @@ static inline unsigned xiph_CountHeaders(const void *p_extra, unsigned i_extra)
     return *p + 1;
 }
 
-static inline unsigned xiph_CountUnknownHeaders(const void *p_extra, unsigned i_extra)
+static inline unsigned xiph_CountUnknownHeaders(const void *p_extra, unsigned i_extra,
+                                                vlc_fourcc_t i_codec)
 {
-    if (xiph_IsLavcFormat(p_extra, i_extra))
+    if (xiph_IsLavcFormat(p_extra, i_extra, i_codec))
         return xiph_CountLavcHeaders(p_extra, i_extra);
     else
         return xiph_CountHeaders(p_extra, i_extra);
diff --git a/modules/mux/ogg.c b/modules/mux/ogg.c
index 41e2507a1f..82e5e90aa2 100644
--- a/modules/mux/ogg.c
+++ b/modules/mux/ogg.c
@@ -840,7 +840,8 @@ static void OggGetSkeletonFisbone( uint8_t **pp_buffer, long *pi_size,
     if ( p_input->p_fmt->p_extra )
         SetDWLE( &(*pp_buffer)[44],
                 xiph_CountUnknownHeaders( p_input->p_fmt->p_extra,
-                                          p_input->p_fmt->i_extra ) );
+                                          p_input->p_fmt->i_extra,
+                                          p_input->p_fmt->i_codec ) );
 
     if ( headers.i_size > 0 )
     {



More information about the vlc-commits mailing list