[FFmpeg-cvslog] lavf/ogg: Support for end trimming Opus

Vignesh Venkatasubramanian git at videolan.org
Mon Sep 16 21:48:32 CEST 2013


ffmpeg | branch: master | Vignesh Venkatasubramanian <vigneshv at google.com> | Thu Sep 12 10:24:18 2013 -0700| [23637f98f4a90a7f0413db57ddb01a4d1a82ead7] | committer: Michael Niedermayer

lavf/ogg: Support for end trimming Opus

Adding support for end trimming Opus embedded in Ogg container.

Signed-Off By: Vignesh Venkatasubramanian <vigneshv at google.com>

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=23637f98f4a90a7f0413db57ddb01a4d1a82ead7
---

 libavformat/oggdec.c       |   13 +++++++++++++
 libavformat/oggdec.h       |    1 +
 libavformat/oggparseopus.c |    1 +
 3 files changed, 15 insertions(+)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 9c560a8..9f8d665 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -30,6 +30,7 @@
 
 #include <stdio.h>
 #include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
 #include "oggdec.h"
 #include "avformat.h"
 #include "internal.h"
@@ -773,6 +774,18 @@ retry:
     pkt->duration = os->pduration;
     pkt->pos      = fpos;
 
+    if (os->end_trimming) {
+        uint8_t *side_data = av_packet_new_side_data(pkt,
+                                                     AV_PKT_DATA_SKIP_SAMPLES,
+                                                     10);
+        if(side_data == NULL) {
+            av_free_packet(pkt);
+            av_free(pkt);
+            return AVERROR(ENOMEM);
+        }
+        AV_WL32(side_data + 4, os->end_trimming);
+    }
+
     return psize;
 }
 
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index e9a300d..c31859f 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -84,6 +84,7 @@ struct ogg_stream {
     int got_start;
     int got_data;   ///< 1 if the stream got some data (non-initial packets), 0 otherwise
     int nb_header; ///< set to the number of parsed headers
+    int end_trimming; ///< set the number of packets to drop from the end
     void *private;
 };
 
diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index 0e8f1ca..8e53860 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -118,6 +118,7 @@ static int opus_packet(AVFormatContext *avf, int idx)
         skip = FFMIN(skip, os->pduration);
         if (skip > 0) {
             os->pduration = skip < os->pduration ? os->pduration - skip : 1;
+            os->end_trimming = skip;
             av_log(avf, AV_LOG_WARNING,
                    "Last packet must be truncated to %d (unimplemented).\n",
                    os->pduration);



More information about the ffmpeg-cvslog mailing list