diff options
Diffstat (limited to 'libavfilter/vf_pixdesctest.c')
-rw-r--r-- | libavfilter/vf_pixdesctest.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/libavfilter/vf_pixdesctest.c b/libavfilter/vf_pixdesctest.c index 0c5b7a1..790dd0d 100644 --- a/libavfilter/vf_pixdesctest.c +++ b/libavfilter/vf_pixdesctest.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2009 Stefano Sabatini * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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 */ @@ -47,7 +47,7 @@ static int config_props(AVFilterLink *inlink) priv->pix_desc = av_pix_fmt_desc_get(inlink->format); av_freep(&priv->line); - if (!(priv->line = av_malloc(sizeof(*priv->line) * inlink->w))) + if (!(priv->line = av_malloc_array(sizeof(*priv->line), inlink->w))) return AVERROR(ENOMEM); return 0; @@ -59,6 +59,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFilterLink *outlink = inlink->dst->outputs[0]; AVFrame *out; int i, c, w = inlink->w, h = inlink->h; + const int cw = FF_CEIL_RSHIFT(w, priv->pix_desc->log2_chroma_w); + const int ch = FF_CEIL_RSHIFT(h, priv->pix_desc->log2_chroma_h); out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) { @@ -69,27 +71,26 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) av_frame_copy_props(out, in); for (i = 0; i < 4; i++) { - int h = outlink->h; - h = i == 1 || i == 2 ? h>>priv->pix_desc->log2_chroma_h : h; + const int h1 = i == 1 || i == 2 ? ch : h; if (out->data[i]) { uint8_t *data = out->data[i] + - (out->linesize[i] > 0 ? 0 : out->linesize[i] * (h-1)); - memset(data, 0, FFABS(out->linesize[i]) * h); + (out->linesize[i] > 0 ? 0 : out->linesize[i] * (h1-1)); + memset(data, 0, FFABS(out->linesize[i]) * h1); } } /* copy palette */ if (priv->pix_desc->flags & AV_PIX_FMT_FLAG_PAL || priv->pix_desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) - memcpy(out->data[1], in->data[1], 256*4); + memcpy(out->data[1], in->data[1], AVPALETTE_SIZE); for (c = 0; c < priv->pix_desc->nb_components; c++) { - int w1 = c == 1 || c == 2 ? w>>priv->pix_desc->log2_chroma_w : w; - int h1 = c == 1 || c == 2 ? h>>priv->pix_desc->log2_chroma_h : h; + const int w1 = c == 1 || c == 2 ? cw : w; + const int h1 = c == 1 || c == 2 ? ch : h; for (i = 0; i < h1; i++) { av_read_image_line(priv->line, - in->data, + (void*)in->data, in->linesize, priv->pix_desc, 0, i, c, w1, 0); @@ -127,11 +128,8 @@ static const AVFilterPad avfilter_vf_pixdesctest_outputs[] = { AVFilter ff_vf_pixdesctest = { .name = "pixdesctest", .description = NULL_IF_CONFIG_SMALL("Test pixel format definitions."), - - .priv_size = sizeof(PixdescTestContext), - .uninit = uninit, - - .inputs = avfilter_vf_pixdesctest_inputs, - - .outputs = avfilter_vf_pixdesctest_outputs, + .priv_size = sizeof(PixdescTestContext), + .uninit = uninit, + .inputs = avfilter_vf_pixdesctest_inputs, + .outputs = avfilter_vf_pixdesctest_outputs, }; |