aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-04 22:03:13 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-14 03:49:11 +0200
commit2fe186409bf3249669271502298bdc8844ce4e0b (patch)
tree022d6207d1427834763e3d5cb10b18c5e2338e68 /libavcodec/utils.c
parent0f03563d7ec757e10767303794e15c6dd15a8fc6 (diff)
downloadffmpeg-2fe186409bf3249669271502298bdc8844ce4e0b.tar.gz
lavc: skip initial silence when requested
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index abb5674e7f..3ef52728ff 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1627,6 +1627,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
}
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
+ uint8_t *side;
+ int side_size;
// copy to ensure we do not change avpkt
AVPacket tmp = *avpkt;
int did_split = av_packet_split_side_data(&tmp);
@@ -1645,6 +1647,22 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
frame->sample_rate = avctx->sample_rate;
}
+ side= av_packet_get_side_data(avctx->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
+ if(side && side_size>=10) {
+ avctx->internal->skip_samples = AV_RL32(side);
+ }
+ if (avctx->internal->skip_samples) {
+ if(frame->nb_samples <= avctx->internal->skip_samples){
+ *got_frame_ptr = 0;
+ avctx->internal->skip_samples -= frame->nb_samples;
+ } else {
+ av_samples_copy(frame->extended_data, frame->extended_data, 0, avctx->internal->skip_samples,
+ frame->nb_samples - avctx->internal->skip_samples, avctx->channels, frame->format);
+ frame->nb_samples -= avctx->internal->skip_samples;
+ avctx->internal->skip_samples = 0;
+ }
+ }
+
avctx->pkt = NULL;
if (did_split) {
ff_packet_free_side_data(&tmp);