summaryrefslogtreecommitdiffstats
path: root/demux/packet.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-03 20:00:34 +0100
committerwm4 <wm4@nowhere>2014-11-03 20:20:28 +0100
commit4e87ac823108a670a1a0c5f67ab9bcd6980bac33 (patch)
tree4e71fa69834ce2e7886f3870abc3b8766d1605c3 /demux/packet.c
parent93e1db0bff5fc48dffeb2dc94801436bdb459cd3 (diff)
downloadmpv-4e87ac823108a670a1a0c5f67ab9bcd6980bac33.tar.bz2
mpv-4e87ac823108a670a1a0c5f67ab9bcd6980bac33.tar.xz
demux_mkv: implement audio skipping/trimming
This mechanism was introduced for Opus, and allows correct skipping of "preroll" data, as well as discarding trailing audio if the file's length isn't a multiple of the audio frame size. Not sure how to handle seeking. I don't understand the purpose of the SeekPreRoll element. This was tested with correctness_trimming_nobeeps.opus, remuxed to mka with mkvmerge v7.2.0. It seems to be correct, although the reported file duration is incorrect (maybe a mkvmerge issue).
Diffstat (limited to 'demux/packet.c')
-rw-r--r--demux/packet.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/demux/packet.c b/demux/packet.c
index 959c707732..968427dee5 100644
--- a/demux/packet.c
+++ b/demux/packet.c
@@ -20,6 +20,7 @@
#include <assert.h>
#include <libavcodec/avcodec.h>
+#include <libavutil/intreadwrite.h>
#include "common/av_common.h"
#include "common/common.h"
@@ -113,3 +114,18 @@ struct demux_packet *demux_copy_packet(struct demux_packet *dp)
new->duration = dp->duration;
return new;
}
+
+int demux_packet_set_padding(struct demux_packet *dp, int start, int end)
+{
+ if (!start && !end)
+ return 0;
+ if (!dp->avpacket)
+ return -1;
+ uint8_t *p = av_packet_new_side_data(dp->avpacket, AV_PKT_DATA_SKIP_SAMPLES, 10);
+ if (!p)
+ return -1;
+
+ AV_WL32(p + 0, start);
+ AV_WL32(p + 4, end);
+ return 0;
+}