[vlc-commits] opus_header: remove dependency on libopus

Rafaël Carré git at videolan.org
Fri Jun 6 03:56:32 CEST 2014


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Tue Jun  3 07:55:30 2014 +0200| [4b1794ff0e0ff5f496fb034f38cadc7b15f5a775] | committer: Rafaël Carré

opus_header: remove dependency on libopus

We might need to generate Opus headers without actually encoding anything

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

 modules/codec/opus.c        |    2 +-
 modules/codec/opus_header.c |   14 +++++++-------
 modules/codec/opus_header.h |    2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/modules/codec/opus.c b/modules/codec/opus.c
index 9f9858a..c05e27e 100644
--- a/modules/codec/opus.c
+++ b/modules/codec/opus.c
@@ -641,7 +641,7 @@ static int OpenEncoder(vlc_object_t *p_this)
 
     /* 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, &header, opus_get_version_string()))
     {
         msg_Err(enc, "Failed to write header.");
         status = VLC_ENOMEM;
diff --git a/modules/codec/opus_header.c b/modules/codec/opus_header.c
index 513c7c2..101a33d 100644
--- a/modules/codec/opus_header.c
+++ b/modules/codec/opus_header.c
@@ -30,7 +30,6 @@
 #endif
 
 #include "opus_header.h"
-#include <opus.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -236,11 +235,12 @@ The comment header is decoded as follows:
   7) done.
 */
 
-static char *comment_init(size_t *length)
+static char *comment_init(size_t *length, const char *vendor)
 {
     /*The 'vendor' field should be the actual encoding library used.*/
-    const char *vendor_string = opus_get_version_string();
-    int vendor_length = strlen(vendor_string);
+    if (!vendor)
+        vendor = "unknown";
+    int vendor_length = strlen(vendor);
 
     int user_comment_list_length = 0;
     int len = 8 + 4 + vendor_length + 4;
@@ -250,7 +250,7 @@ static char *comment_init(size_t *length)
 
     memcpy(p, "OpusTags", 8);
     SetDWLE(p + 8, vendor_length);
-    memcpy(p + 12, vendor_string, vendor_length);
+    memcpy(p + 12, vendor, vendor_length);
     SetDWLE(p + 12 + vendor_length, user_comment_list_length);
 
     *length = len;
@@ -367,7 +367,7 @@ static int opus_header_to_packet(const OpusHeader *h, unsigned char *packet, int
     return p.pos;
 }
 
-int opus_write_header(uint8_t **p_extra, int *i_extra, OpusHeader *header)
+int opus_write_header(uint8_t **p_extra, int *i_extra, OpusHeader *header, const char *vendor)
 {
     unsigned char header_data[100];
     const int packet_size = opus_header_to_packet(header, header_data,
@@ -380,7 +380,7 @@ int opus_write_header(uint8_t **p_extra, int *i_extra, OpusHeader *header)
     size[0] = packet_size;
 
     size_t comments_length;
-    char *comments = comment_init(&comments_length);
+    char *comments = comment_init(&comments_length, vendor);
     if (!comments)
         return 1;
     if (comment_add(&comments, &comments_length, "ENCODER=",
diff --git a/modules/codec/opus_header.h b/modules/codec/opus_header.h
index 71c7884..a4c1f16 100644
--- a/modules/codec/opus_header.h
+++ b/modules/codec/opus_header.h
@@ -45,6 +45,6 @@ typedef struct {
 
 int opus_header_parse(const unsigned char *header, int len, OpusHeader *h);
 int opus_prepare_header(unsigned channels, unsigned rate, OpusHeader *header);
-int opus_write_header(uint8_t **p_extra, int *i_extra, OpusHeader *header);
+int opus_write_header(uint8_t **p_extra, int *i_extra, OpusHeader *header, const char *vendor);
 
 #endif



More information about the vlc-commits mailing list