Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 6cfbb2d26fd131d8fa4d69ea0d9a0c628be48bd5 Mon Sep 17 00:00:00 2001
- From: Paul B Mahol <[email protected]>
- Date: Wed, 22 Jan 2025 20:17:45 +0000
- Subject: [PATCH] avfilter: add pf2pf video filter
- ---
- libavfilter/Makefile | 1 +
- libavfilter/allfilters.c | 1 +
- libavfilter/pf2pf_dst_depth_template.c | 49 +++++
- libavfilter/pf2pf_dst_endian_template.c | 30 +++
- libavfilter/pf2pf_src_depth_template.c | 39 ++++
- libavfilter/pf2pf_src_endian_template.c | 30 +++
- libavfilter/pf2pf_template.c | 113 +++++++++++
- libavfilter/vf_pf2pf.c | 251 ++++++++++++++++++++++++
- libavutil/imgutils.c | 3 +-
- 9 files changed, 515 insertions(+), 2 deletions(-)
- create mode 100644 libavfilter/pf2pf_dst_depth_template.c
- create mode 100644 libavfilter/pf2pf_dst_endian_template.c
- create mode 100644 libavfilter/pf2pf_src_depth_template.c
- create mode 100644 libavfilter/pf2pf_src_endian_template.c
- create mode 100644 libavfilter/pf2pf_template.c
- create mode 100644 libavfilter/vf_pf2pf.c
- diff --git a/libavfilter/Makefile b/libavfilter/Makefile
- index b9089195f9..4d7bfeef41 100644
- --- a/libavfilter/Makefile
- +++ b/libavfilter/Makefile
- @@ -457,6 +457,7 @@ OBJS-$(CONFIG_PALETTEGEN_FILTER) += vf_palettegen.o palette.o
- OBJS-$(CONFIG_PALETTEUSE_FILTER) += vf_paletteuse.o framesync.o palette.o
- OBJS-$(CONFIG_PERMS_FILTER) += f_perms.o
- OBJS-$(CONFIG_PERSPECTIVE_FILTER) += vf_perspective.o
- +OBJS-$(CONFIG_PF2PF_FILTER) += vf_pf2pf.o
- OBJS-$(CONFIG_PHASE_FILTER) += vf_phase.o
- OBJS-$(CONFIG_PHOTOSENSITIVITY_FILTER) += vf_photosensitivity.o
- OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o
- diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
- index 3d435bc7a4..3bc6d62396 100644
- --- a/libavfilter/allfilters.c
- +++ b/libavfilter/allfilters.c
- @@ -430,6 +430,7 @@ extern const FFFilter ff_vf_palettegen;
- extern const FFFilter ff_vf_paletteuse;
- extern const FFFilter ff_vf_perms;
- extern const FFFilter ff_vf_perspective;
- +extern const FFFilter ff_vf_pf2pf;
- extern const FFFilter ff_vf_phase;
- extern const FFFilter ff_vf_photosensitivity;
- extern const FFFilter ff_vf_pixdesctest;
- diff --git a/libavfilter/pf2pf_dst_depth_template.c b/libavfilter/pf2pf_dst_depth_template.c
- new file mode 100644
- index 0000000000..d632acdd58
- --- /dev/null
- +++ b/libavfilter/pf2pf_dst_depth_template.c
- @@ -0,0 +1,49 @@
- +/*
- + * 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.
- + *
- + * 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 FFmpeg; if not, write to the Free Software
- + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- + */
- +
- +#include "avfilter.h"
- +#include "video.h"
- +
- +#undef dtype
- +#undef DST_F
- +#undef DWP
- +#undef DRP
- +#if DST_DEPTH == 8
- +#define dtype uint8_t
- +#define DST_F u8
- +#define DWP(x, y) ((x)[0] = (y))
- +#define DRP(x) ((x)[0])
- +#elif DST_DEPTH == 16
- +#define dtype uint16_t
- +#define DST_F u16
- +#if DST_E == 0
- +#define DWP(x, y) AV_WL16((x), (y))
- +#define DRP(x) AV_RL16(x)
- +#elif DST_E == 1
- +#define DWP(x, y) AV_WB16((x), (y))
- +#define DRP(x) AV_RB16(x)
- +#endif
- +#endif
- +
- +#undef SRC_DEPTH
- +#define SRC_DEPTH 8
- +#include "pf2pf_src_depth_template.c"
- +
- +#undef SRC_DEPTH
- +#define SRC_DEPTH 16
- +#include "pf2pf_src_depth_template.c"
- diff --git a/libavfilter/pf2pf_dst_endian_template.c b/libavfilter/pf2pf_dst_endian_template.c
- new file mode 100644
- index 0000000000..1007ce6a80
- --- /dev/null
- +++ b/libavfilter/pf2pf_dst_endian_template.c
- @@ -0,0 +1,30 @@
- +/*
- + * 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.
- + *
- + * 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 FFmpeg; if not, write to the Free Software
- + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- + */
- +
- +#include "avfilter.h"
- +#include "video.h"
- +
- +#undef DST_E
- +#define DST_E 0
- +#include "pf2pf_src_endian_template.c"
- +
- +#if DST_DEPTH == 16
- +#undef DST_E
- +#define DST_E 1
- +#include "pf2pf_src_endian_template.c"
- +#endif
- diff --git a/libavfilter/pf2pf_src_depth_template.c b/libavfilter/pf2pf_src_depth_template.c
- new file mode 100644
- index 0000000000..cf5cf4cb1e
- --- /dev/null
- +++ b/libavfilter/pf2pf_src_depth_template.c
- @@ -0,0 +1,39 @@
- +/*
- + * 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.
- + *
- + * 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 FFmpeg; if not, write to the Free Software
- + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- + */
- +
- +#include "avfilter.h"
- +#include "video.h"
- +
- +#undef stype
- +#undef SRC_F
- +#undef SRP
- +#if SRC_DEPTH == 8
- +#define stype uint8_t
- +#define SRC_F u8
- +#define SRP(x) ((x)[0])
- +#elif SRC_DEPTH == 16
- +#define stype uint16_t
- +#define SRC_F u16
- +#if SRC_E == 0
- +#define SRP(x) AV_RL16((x))
- +#elif SRC_E == 1
- +#define SRP(x) AV_RB16((x))
- +#endif
- +#endif
- +
- +#include "pf2pf_template.c"
- diff --git a/libavfilter/pf2pf_src_endian_template.c b/libavfilter/pf2pf_src_endian_template.c
- new file mode 100644
- index 0000000000..6c3d0d30f5
- --- /dev/null
- +++ b/libavfilter/pf2pf_src_endian_template.c
- @@ -0,0 +1,30 @@
- +/*
- + * 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.
- + *
- + * 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 FFmpeg; if not, write to the Free Software
- + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- + */
- +
- +#include "avfilter.h"
- +#include "video.h"
- +
- +#undef SRC_E
- +#define SRC_E 0
- +#include "pf2pf_dst_depth_template.c"
- +
- +#if SRC_DEPTH == 16
- +#undef SRC_E
- +#define SRC_E 1
- +#include "pf2pf_dst_depth_template.c"
- +#endif
- diff --git a/libavfilter/pf2pf_template.c b/libavfilter/pf2pf_template.c
- new file mode 100644
- index 0000000000..e9760bf938
- --- /dev/null
- +++ b/libavfilter/pf2pf_template.c
- @@ -0,0 +1,113 @@
- +/*
- + * 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.
- + *
- + * 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 FFmpeg; if not, write to the Free Software
- + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- + */
- +
- +#include "avfilter.h"
- +#include "video.h"
- +
- +#if SRC_DEPTH > 8 || SRC_E == 0
- +#define fn3(a,b,c,d,e) a##_##b##_##c##_to_##d##_##e
- +#define fn2(a,b,c,d,e) fn3(a,b,c,d,e)
- +#define fn(a) fn2(a, SRC_F, SRC_E, DST_F, DST_E)
- +
- +static void fn(pf2pf_loop)(uint8_t **dstp,
- + const uint8_t **srcp,
- + const int *dst_linesizep,
- + const int *src_linesizep,
- + const int w, const int h,
- + const int dst_plane,
- + const int dst_step, const int dst_shift,
- + const int dst_offset, const int dst_depth,
- + const int src_plane,
- + const int src_step, const int src_shift,
- + const int src_offset, const int src_depth)
- +{
- + const ptrdiff_t dst_linesize = dst_linesizep[dst_plane];
- + const ptrdiff_t src_linesize = src_linesizep[src_plane];
- + const unsigned dst_mask = (1U << dst_depth) - 1;
- + const unsigned src_mask = (1U << src_depth) - 1;
- + const unsigned dst_rshift = FFMAX(src_depth - dst_depth, 0);
- + const unsigned dst_lshift = dst_shift + FFMAX(dst_depth-src_depth, 0);
- + const uint8_t *src = srcp[src_plane];
- + uint8_t *dst = dstp[dst_plane];
- +
- + for (int y = 0; y < h; y++) {
- + for (int x = 0, i = 0, j = 0; x < w; x++) {
- + unsigned odst = DRP(dst + i + dst_offset);
- + DWP(dst + i + dst_offset, odst | (((((SRP(src + j + src_offset) >> src_shift) & src_mask) >> dst_rshift) & dst_mask) << dst_lshift));
- + i += dst_step;
- + j += src_step;
- + }
- +
- + dst += dst_linesize;
- + src += src_linesize;
- + }
- +}
- +
- +static int fn(pf2pf)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
- +{
- + PF2PFContext *s = ctx->priv;
- + const int nb_components = s->dst_desc->nb_components;
- + const int *linesize = s->linesize;
- + ThreadData *td = arg;
- + AVFrame *restrict out = td->out;
- + AVFrame *restrict in = td->in;
- + const int w = in->width;
- + const int h = in->height;
- + const int start = (h * jobnr) / nb_jobs;
- + const int end = (h * (jobnr+1)) / nb_jobs;
- +
- + for (int comp = 0; comp < nb_components; comp++) {
- + if (out->data[comp]) {
- + uint8_t *dst_data = out->data[comp] + start * out->linesize[comp];
- +
- + for (int y = start; y < end; y++) {
- + memset(dst_data, 0, linesize[comp]);
- + dst_data += out->linesize[comp];
- + }
- + }
- + }
- +
- + for (int comp = 0; comp < nb_components; comp++) {
- + const int dst_plane = s->dst_desc->comp[comp].plane;
- + const int dst_step = s->dst_desc->comp[comp].step;
- + const int dst_shift = s->dst_desc->comp[comp].shift;
- + const int dst_offset= s->dst_desc->comp[comp].offset;
- + const int dst_depth = s->dst_desc->comp[comp].depth;
- + const int src_plane = s->src_desc->comp[comp].plane;
- + const int src_step = s->src_desc->comp[comp].step;
- + const int src_shift = s->src_desc->comp[comp].shift;
- + const int src_offset= s->src_desc->comp[comp].offset;
- + const int src_depth = s->src_desc->comp[comp].depth;
- + uint8_t *dst_data[4] = {NULL}, *src_data[4] = {NULL};
- +
- + for (int i = 0; i < 4; i++) {
- + if (out->data[i])
- + dst_data[i] = out->data[i] + start * out->linesize[i];
- + if (in->data[i])
- + src_data[i] = in->data[i] + start * in->linesize[i];
- + }
- +
- + fn(pf2pf_loop)((uint8_t **)dst_data, (const uint8_t **)src_data, out->linesize, in->linesize,
- + w, end - start,
- + dst_plane, dst_step, dst_shift, dst_offset, dst_depth,
- + src_plane, src_step, src_shift, src_offset, src_depth);
- + }
- +
- + return 0;
- +}
- +#endif
- diff --git a/libavfilter/vf_pf2pf.c b/libavfilter/vf_pf2pf.c
- new file mode 100644
- index 0000000000..f0a8c51b0b
- --- /dev/null
- +++ b/libavfilter/vf_pf2pf.c
- @@ -0,0 +1,251 @@
- +/*
- + * 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.
- + *
- + * 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 FFmpeg; if not, write to the Free Software
- + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- + */
- +
- +#include "libavutil/imgutils.h"
- +#include "libavutil/intreadwrite.h"
- +#include "libavutil/opt.h"
- +#include "libavutil/pixdesc.h"
- +#include "libavutil/pixfmt.h"
- +#include "avfilter.h"
- +#include "video.h"
- +#include "filters.h"
- +#include "formats.h"
- +
- +typedef struct PF2PFContext {
- + const AVClass *class;
- +
- + const AVPixFmtDescriptor *dst_desc, *src_desc;
- +
- + int linesize[4];
- + int format;
- + int pass;
- +
- + int (*do_pf2pf)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
- +} PF2PFContext;
- +
- +#define OFFSET(x) offsetof(PF2PFContext, x)
- +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
- +
- +static const AVOption pf2pf_options[] = {
- + { "format", "set the pixel format", OFFSET(format), AV_OPT_TYPE_PIXEL_FMT, {.i64=AV_PIX_FMT_NONE}, AV_PIX_FMT_NONE, AV_PIX_FMT_NB-1, FLAGS },
- + {NULL}
- +};
- +
- +AVFILTER_DEFINE_CLASS(pf2pf);
- +
- +static int query_formats(const AVFilterContext *ctx,
- + AVFilterFormatsConfig **cfg_in,
- + AVFilterFormatsConfig **cfg_out)
- +{
- + const PF2PFContext *s = ctx->priv;
- + AVFilterFormats *formats;
- + int ret;
- +
- + formats = ff_all_formats(AVMEDIA_TYPE_VIDEO);
- + if (!formats)
- + return AVERROR(ENOMEM);
- +
- + if ((ret = ff_formats_ref(formats, &cfg_in[0]->formats)) < 0)
- + return ret;
- +
- + if (s->format != AV_PIX_FMT_NONE) {
- + formats = NULL;
- +
- + ret = ff_add_format(&formats, s->format);
- + if (ret)
- + return ret;
- +
- + return ff_formats_ref(formats, &cfg_out[0]->formats);
- + }
- +
- + formats = ff_all_formats(AVMEDIA_TYPE_VIDEO);
- + if (!formats)
- + return AVERROR(ENOMEM);
- +
- + return ff_formats_ref(formats, &cfg_out[0]->formats);
- +}
- +
- +typedef struct ThreadData {
- + AVFrame *in, *out;
- +} ThreadData;
- +
- +#define DST_DEPTH 8
- +#include "pf2pf_dst_endian_template.c"
- +
- +#undef DST_DEPTH
- +#define DST_DEPTH 16
- +#include "pf2pf_dst_endian_template.c"
- +
- +static int config_output(AVFilterLink *outlink)
- +{
- + AVFilterContext *ctx = outlink->src;
- + AVFilterLink *inlink = ctx->inputs[0];
- + PF2PFContext *s = ctx->priv;
- + int ret;
- +
- + if (outlink->format == inlink->format) {
- + s->pass = 1;
- + return 0;
- + }
- +
- + s->dst_desc = av_pix_fmt_desc_get(outlink->format);
- + s->src_desc = av_pix_fmt_desc_get(inlink->format);
- +
- + if ((ret = av_image_fill_linesizes(s->linesize, outlink->format, inlink->w)) < 0)
- + return ret;
- +
- + if (s->dst_desc->comp[0].depth > 8) {
- + if (s->src_desc->comp[0].depth > 8) {
- + if (s->dst_desc->flags & AV_PIX_FMT_FLAG_BE) {
- + if (s->src_desc->flags & AV_PIX_FMT_FLAG_BE) {
- + s->do_pf2pf = pf2pf_u16_1_to_u16_1;
- + } else {
- + s->do_pf2pf = pf2pf_u16_0_to_u16_1;
- + }
- + } else {
- + if (s->src_desc->flags & AV_PIX_FMT_FLAG_BE) {
- + s->do_pf2pf = pf2pf_u16_1_to_u16_0;
- + } else {
- + s->do_pf2pf = pf2pf_u16_0_to_u16_0;
- + }
- + }
- + } else {
- + if (s->dst_desc->flags & AV_PIX_FMT_FLAG_BE) {
- + s->do_pf2pf = pf2pf_u8_0_to_u16_1;
- + } else {
- + s->do_pf2pf = pf2pf_u8_0_to_u16_0;
- + }
- + }
- + } else {
- + if (s->src_desc->comp[0].depth > 8) {
- + if (s->src_desc->flags & AV_PIX_FMT_FLAG_BE) {
- + s->do_pf2pf = pf2pf_u16_1_to_u8_0;
- + } else {
- + s->do_pf2pf = pf2pf_u16_0_to_u8_0;
- + }
- + } else {
- + s->do_pf2pf = pf2pf_u8_0_to_u8_0;
- + }
- + }
- +
- + return 0;
- +}
- +
- +static int filter_frame(AVFilterLink *inlink, AVFrame *in)
- +{
- + AVFilterContext *ctx = inlink->dst;
- + AVFilterLink *outlink = ctx->outputs[0];
- + PF2PFContext *s = ctx->priv;
- + AVFrame *out;
- +
- + if (s->pass) {
- + out = in;
- + } else {
- + ThreadData td;
- + int nb_jobs;
- +
- + out = ff_get_video_buffer(outlink, in->width, in->height);
- + if (!out) {
- + av_frame_free(&in);
- + return AVERROR(ENOMEM);
- + }
- +
- + td.in = in;
- + td.out = out;
- +
- + nb_jobs = in->height;
- +
- + ff_filter_execute(ctx, s->do_pf2pf, &td, NULL,
- + FFMIN(nb_jobs, ff_filter_get_nb_threads(ctx)));
- +
- + av_frame_copy_props(out, in);
- + av_frame_free(&in);
- + }
- +
- + return ff_filter_frame(outlink, out);
- +}
- +
- +static int activate(AVFilterContext *ctx)
- +{
- + AVFilterLink *inlink = ctx->inputs[0];
- + AVFilterLink *outlink = ctx->outputs[0];
- + AVFrame *in;
- + int ret;
- +
- + FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
- +
- + ret = ff_inlink_consume_frame(inlink, &in);
- + if (ret < 0)
- + return ret;
- + if (ret > 0)
- + return filter_frame(inlink, in);
- +
- + FF_FILTER_FORWARD_STATUS(inlink, outlink);
- + FF_FILTER_FORWARD_WANTED(outlink, inlink);
- +
- + return FFERROR_NOT_READY;
- +}
- +
- +static AVFrame *get_in_video_buffer(AVFilterLink *inlink, int w, int h)
- +{
- + AVFilterContext *ctx = inlink->dst;
- + PF2PFContext *s = ctx->priv;
- +
- + return s->pass ?
- + ff_null_get_video_buffer (inlink, w, h) :
- + ff_default_get_video_buffer(inlink, w, h);
- +}
- +
- +static AVFrame *get_out_video_buffer(AVFilterLink *outlink, int w, int h)
- +{
- + AVFilterContext *ctx = outlink->src;
- + PF2PFContext *s = ctx->priv;
- +
- + return s->pass ?
- + ff_null_get_video_buffer (outlink, w, h) :
- + ff_default_get_video_buffer(outlink, w, h);
- +}
- +
- +static const AVFilterPad inputs[] = {
- + {
- + .name = "default",
- + .type = AVMEDIA_TYPE_VIDEO,
- + .get_buffer.video = get_in_video_buffer,
- + },
- +};
- +
- +static const AVFilterPad outputs[] = {
- + {
- + .name = "default",
- + .type = AVMEDIA_TYPE_VIDEO,
- + .config_props = config_output,
- + .get_buffer.video = get_out_video_buffer,
- + },
- +};
- +
- +const FFFilter ff_vf_pf2pf = {
- + .p.name = "pf2pf",
- + .p.description = NULL_IF_CONFIG_SMALL("Switch video pixel format."),
- + .p.priv_class = &pf2pf_class,
- + .priv_size = sizeof(PF2PFContext),
- + .activate = activate,
- + FILTER_QUERY_FUNC2(query_formats),
- + FILTER_INPUTS(inputs),
- + FILTER_OUTPUTS(outputs),
- + .p.flags = AVFILTER_FLAG_SLICE_THREADS,
- +};
- diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
- index 119372e418..2b1dc10215 100644
- --- a/libavutil/imgutils.c
- +++ b/libavutil/imgutils.c
- @@ -35,12 +35,11 @@
- void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
- const AVPixFmtDescriptor *pixdesc)
- {
- - int i;
- memset(max_pixsteps, 0, 4*sizeof(max_pixsteps[0]));
- if (max_pixstep_comps)
- memset(max_pixstep_comps, 0, 4*sizeof(max_pixstep_comps[0]));
- - for (i = 0; i < 4; i++) {
- + for (int i = 0; i < pixdesc->nb_components; i++) {
- const AVComponentDescriptor *comp = &(pixdesc->comp[i]);
- if (comp->step > max_pixsteps[comp->plane]) {
- max_pixsteps[comp->plane] = comp->step;
- --
- 2.47.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement