diff options
Diffstat (limited to 'libavfilter/audio.c')
-rw-r--r-- | libavfilter/audio.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/libavfilter/audio.c b/libavfilter/audio.c index 81a042b..a769c78 100644 --- a/libavfilter/audio.c +++ b/libavfilter/audio.c @@ -1,21 +1,25 @@ /* - * This file is part of Libav. + * Copyright (c) Stefano Sabatini | stefasab at gmail.com + * Copyright (c) S.N. Hemanth Meenakshisundaram | smeenaks at ucsd.edu * - * Libav is free software; you can redistribute it and/or + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/avassert.h" #include "libavutil/audioconvert.h" #include "audio.h" @@ -96,9 +100,9 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, samplesref->audio->nb_samples = nb_samples; samplesref->audio->channel_layout = channel_layout; - samplesref->audio->planar = av_sample_fmt_is_planar(sample_fmt); - planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1; + planes = av_sample_fmt_is_planar(sample_fmt) ? + av_get_channel_layout_nb_channels(channel_layout) : 1; /* make sure the buffer gets read permission or it's useless for output */ samplesref->perms = perms | AV_PERM_READ; @@ -176,6 +180,7 @@ void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) { void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *); AVFilterPad *dst = link->dstpad; + int64_t pts; FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1); @@ -185,7 +190,7 @@ void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) /* prepare to copy the samples if the buffer has insufficient permissions */ if ((dst->min_perms & samplesref->perms) != dst->min_perms || dst->rej_perms & samplesref->perms) { - int i, planar = av_sample_fmt_is_planar(samplesref->format); + int i, size, planar = av_sample_fmt_is_planar(samplesref->format); int planes = !planar ? 1: av_get_channel_layout_nb_channels(samplesref->audio->channel_layout); @@ -199,13 +204,19 @@ void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; /* Copy actual data into new samples buffer */ + /* src can be larger than dst if it was allocated larger than necessary. + dst can be slightly larger due to extra alignment padding. */ + size = FFMIN(samplesref->linesize[0], link->cur_buf->linesize[0]); + for (i = 0; samplesref->data[i] && i < 8; i++) + memcpy(link->cur_buf->data[i], samplesref->data[i], size); for (i = 0; i < planes; i++) - memcpy(link->cur_buf->extended_data[i], samplesref->extended_data[i], samplesref->linesize[0]); + memcpy(link->cur_buf->extended_data[i], samplesref->extended_data[i], size); avfilter_unref_buffer(samplesref); } else link->cur_buf = samplesref; + pts = link->cur_buf->pts; filter_samples(link, link->cur_buf); + ff_update_link_current_pts(link, pts); } - |