* Filter layer - default implementations
* Copyright (c) 2007 Bobby Bingham
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav 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.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav 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 FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/audioconvert.h"
-#include "libavcore/imgutils.h"
-#include "libavcore/samplefmt.h"
+#include "libavutil/audioconvert.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/samplefmt.h"
#include "avfilter.h"
#include "internal.h"
* alloc & free cycle currently implemented. */
AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
{
- char *buf = NULL;
- int linesize[4], i, tempsize;
+ int linesize[4];
uint8_t *data[4];
AVFilterBufferRef *picref = NULL;
- av_image_fill_linesizes(linesize, link->format, w);
- for (i = 0; i < 4; i++)
- linesize[i] = FFALIGN(linesize[i], 16);
- tempsize = av_image_fill_pointers(data, link->format, h, NULL, linesize);
- buf = av_malloc(tempsize + 16); // +2 is needed for swscaler, +16 to be
- // SIMD-friendly
- if (!buf)
+ // +2 is needed for swscaler, +16 to be SIMD-friendly
+ if (av_image_alloc(data, linesize, w, h, link->format, 16) < 0)
return NULL;
- av_image_fill_pointers(data, link->format, h, buf, linesize);
-
picref = avfilter_get_video_buffer_ref_from_arrays(data, linesize,
perms, w, h, link->format);
if (!picref) {
- av_free(buf);
+ av_free(data[0]);
return NULL;
}
samples->refcount = 1;
samples->free = ff_avfilter_default_free_buffer;
- sample_size = av_get_bits_per_sample_fmt(sample_fmt) >>3;
+ sample_size = av_get_bytes_per_sample(sample_fmt);
chans_nb = av_get_channel_layout_nb_channels(channel_layout);
per_channel_size = size/chans_nb;
- ref->audio->samples_nb = per_channel_size/sample_size;
+ ref->audio->nb_samples = per_channel_size/sample_size;
/* Set the number of bytes to traverse to reach next sample of a particular channel:
* For planar, this is simply the sample size.
return ref;
fail:
- av_free(buf);
- if (ref && ref->audio)
+ if (ref)
av_free(ref->audio);
av_free(ref);
av_free(samples);