[FFmpeg-devel] [RFC v3 2/2] oggenc: add support for remuxing of files with the Daala video codec

Rostislav Pehlivanov atomnuker at gmail.com
Fri Jan 1 17:22:30 CET 2016


Requires the parser from the decoder (previous commit).

Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
---
 libavformat/oggenc.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 4907512..7f0cfc1 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -452,7 +452,8 @@ static int ogg_write_header(AVFormatContext *s)
             st->codec->codec_id != AV_CODEC_ID_THEORA &&
             st->codec->codec_id != AV_CODEC_ID_SPEEX  &&
             st->codec->codec_id != AV_CODEC_ID_FLAC   &&
-            st->codec->codec_id != AV_CODEC_ID_OPUS) {
+            st->codec->codec_id != AV_CODEC_ID_OPUS   &&
+            st->codec->codec_id != AV_CODEC_ID_DAALA) {
             av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i);
             return AVERROR(EINVAL);
         }
@@ -510,13 +511,19 @@ static int ogg_write_header(AVFormatContext *s)
             }
         } else {
             uint8_t *p;
-            const char *cstr = st->codec->codec_id == AV_CODEC_ID_VORBIS ? "vorbis" : "theora";
-            int header_type = st->codec->codec_id == AV_CODEC_ID_VORBIS ? 3 : 0x81;
-            int framing_bit = st->codec->codec_id == AV_CODEC_ID_VORBIS ? 1 : 0;
-
-            if (avpriv_split_xiph_headers(st->codec->extradata, st->codec->extradata_size,
-                                      st->codec->codec_id == AV_CODEC_ID_VORBIS ? 30 : 42,
-                                      (const uint8_t**)oggstream->header, oggstream->header_len) < 0) {
+            enum AVCodecID cid = st->codec->codec_id;
+            const char *cstr = cid == AV_CODEC_ID_VORBIS ? "vorbis" :
+                               cid == AV_CODEC_ID_DAALA  ? "daala" : "theora";
+            int f_hdr_size =   cid == AV_CODEC_ID_VORBIS ? 30 :
+                               cid == AV_CODEC_ID_DAALA  ? 47 : 42;
+            int header_type =  cid == AV_CODEC_ID_VORBIS ? 3 : 0x81;
+            int framing_bit =  cid == AV_CODEC_ID_VORBIS ? 1 : 0;
+
+            if (avpriv_split_xiph_headers(st->codec->extradata,
+                                          st->codec->extradata_size,
+                                          f_hdr_size,
+                                          (const uint8_t**)oggstream->header,
+                                          oggstream->header_len) < 0) {
                 av_log(s, AV_LOG_ERROR, "Extradata corrupted\n");
                 av_freep(&st->priv_data);
                 return AVERROR_INVALIDDATA;
@@ -530,7 +537,7 @@ static int ogg_write_header(AVFormatContext *s)
                 return AVERROR(ENOMEM);
 
             bytestream_put_byte(&p, header_type);
-            bytestream_put_buffer(&p, cstr, 6);
+            bytestream_put_buffer(&p, cstr, strlen(cstr));
 
             if (st->codec->codec_id == AV_CODEC_ID_THEORA) {
                 /** KFGSHIFT is the width of the less significant section of the granule position
-- 
2.6.4



More information about the ffmpeg-devel mailing list