[FFmpeg-devel] [PATCH] avfilter: align data frame when needed
Muhammad Faiz
mfcc64 at gmail.com
Sun May 7 10:15:56 EEST 2017
On Fri, May 5, 2017 at 1:01 PM, Muhammad Faiz <mfcc64 at gmail.com> wrote:
> This should fix Ticket6349.
> Since 383057f8e744efeaaa3648a59bc577b25b055835, framequeue may
> generate unaligned frame data.
>
> Signed-off-by: Muhammad Faiz <mfcc64 at gmail.com>
> ---
> libavfilter/avfilter.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index 08b86b0..504f5c6 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -1192,7 +1192,31 @@ static int take_samples(AVFilterLink *link, unsigned min, unsigned max,
> av_assert1(samples_ready(link, link->min_samples));
> frame0 = frame = ff_framequeue_peek(&link->fifo, 0);
> if (frame->nb_samples >= min && frame->nb_samples < max) {
> - *rframe = ff_framequeue_take(&link->fifo);
> + int align = 32;
> + if (!((align - 1) & (intptr_t)frame->data[0])) {
> + *rframe = ff_framequeue_take(&link->fifo);
> + return 0;
> + }
> +
> + buf = ff_get_audio_buffer(link, frame->nb_samples);
> + if (!buf)
> + return AVERROR(ENOMEM);
> +
> + ret = av_frame_copy_props(buf, frame);
> + if (ret < 0) {
> + av_frame_free(&buf);
> + return ret;
> + }
> +
> + ret = av_frame_copy(buf, frame);
> + if (ret < 0) {
> + av_frame_free(&buf);
> + return ret;
> + }
> +
> + frame = ff_framequeue_take(&link->fifo);
> + av_frame_free(&frame);
> + *rframe = buf;
> return 0;
> }
> nb_frames = 0;
> --
> 2.9.3
>
Is it ok to push this?
Thank's.
More information about the ffmpeg-devel
mailing list