[vlc-devel] [PATCH] opus encoder: do not write a full blown ogg header in extra data

Rafaël Carré funman at videolan.org
Fri Jan 17 16:19:10 CET 2014


we only need the OpusHeader
Fix muxing into matroska
---
 modules/codec/opus.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/codec/opus.c b/modules/codec/opus.c
index 8aa8adb..9a1116d 100644
--- a/modules/codec/opus.c
+++ b/modules/codec/opus.c
@@ -637,14 +637,21 @@ static int OpenEncoder(vlc_object_t *p_this)
     header.preskip = sys->i_samples_delay;
 
     /* Now that we have preskip, we can write the header to extradata */
-    if (opus_write_header((uint8_t **) &enc->fmt_out.p_extra,
-                          &enc->fmt_out.i_extra, &header))
+    enc->fmt_out.i_extra = 19;
+    enc->fmt_out.p_extra = malloc(enc->fmt_out.i_extra);
+    if (!enc->fmt_out.p_extra)
     {
-        msg_Err(enc, "Failed to write header.");
         status = VLC_ENOMEM;
         goto error;
     }
 
+    if (opus_header_to_packet(&header, enc->fmt_out.p_extra, enc->fmt_out.i_extra) != 19)
+    {
+        msg_Err(enc, "Failed to write header.");
+        status = VLC_EGENERIC;
+        goto error;
+    }
+
     if (sys->i_samples_delay > 0)
     {
         const unsigned padding_samples = sys->i_samples_delay *
-- 
1.8.5.3




More information about the vlc-devel mailing list