lavf/matroska: Adding the new SeekPreRoll element
authorVignesh Venkatasubramanian <vigneshv@google.com>
Fri, 16 Aug 2013 18:08:06 +0000 (11:08 -0700)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 17 Aug 2013 22:04:08 +0000 (00:04 +0200)
In order to encapsuate Opus in Matroska, there is a new element
that has been added to the Matroska Spec, SeekPreRoll. It has the
duration in nanoseconds that has to be decoded before every seek.
Spec: http://matroska.org/technical/specs/index.html#SeekPreRoll
Proposal for encapsulateing Opus in Matroska:
http://wiki.xiph.org/MatroskaOpus

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/matroska.h
libavformat/matroskaenc.c

index 2eb2fe6..9c8071a 100644 (file)
@@ -91,6 +91,7 @@
 #define MATROSKA_ID_CODECINFOURL 0x3B4040
 #define MATROSKA_ID_CODECDOWNLOADURL 0x26B240
 #define MATROSKA_ID_CODECDECODEALL 0xAA
+#define MATROSKA_ID_SEEKPREROLL 0x56BB
 #define MATROSKA_ID_TRACKNAME  0x536E
 #define MATROSKA_ID_TRACKLANGUAGE 0x22B59C
 #define MATROSKA_ID_TRACKFLAGENABLED 0xB9
index c201d5e..18e96c3 100644 (file)
@@ -121,6 +121,9 @@ typedef struct MatroskaMuxContext {
 /** per-cuepoint - 2 1-byte EBML IDs, 2 1-byte EBML sizes, 8-byte uint max */
 #define MAX_CUEPOINT_SIZE(num_tracks) 12 + MAX_CUETRACKPOS_SIZE*num_tracks
 
+/** Seek preroll value for opus */
+#define OPUS_SEEK_PREROLL 80000000
+
 
 static int ebml_id_size(unsigned int id)
 {
@@ -642,6 +645,10 @@ static int mkv_write_tracks(AVFormatContext *s)
             }
         }
 
+        if (codec->codec_id == AV_CODEC_ID_OPUS) {
+            put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL);
+        }
+
         if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 ||
                                         codec->codec_id == AV_CODEC_ID_VP9 ||
                                       ((codec->codec_id == AV_CODEC_ID_OPUS)&&(codec->strict_std_compliance <= FF_COMPLIANCE_EXPERIMENTAL)) ||