[FFmpeg-devel] [RFC 3/3] oggenc: add support for remuxing Daala video into OGG container
Rostislav Pehlivanov
atomnuker at gmail.com
Mon Dec 28 17:58:50 CET 2015
Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
---
libavformat/oggenc.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 4907512..87dcdde 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,19 +511,25 @@ 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;
}
- p = ogg_write_vorbiscomment(7, s->flags & AVFMT_FLAG_BITEXACT,
+ p = ogg_write_vorbiscomment(strlen(cstr), s->flags & AVFMT_FLAG_BITEXACT,
&oggstream->header_len[1], &st->metadata,
framing_bit);
oggstream->header[1] = p;
@@ -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