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

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


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

demux: xiph: improve old ffmpeg xiph extradata test

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
(cherry picked from commit 1f073245f0c75096a075bc5c7075db660a8b1189)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

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

 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 8ef8f5aa31..06600484d5 100644
--- a/modules/demux/xiph.h
+++ b/modules/demux/xiph.h
@@ -26,9 +26,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)
@@ -59,9 +68,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 6fc5f4489c..3847cc54d6 100644
--- a/modules/mux/ogg.c
+++ b/modules/mux/ogg.c
@@ -842,7 +842,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