325f6e0a97
* qatar/master: lavfi: do not export the filters from shared objects Conflicts: libavfilter/af_amix.c libavfilter/af_anull.c libavfilter/asrc_anullsrc.c libavfilter/f_select.c libavfilter/f_settb.c libavfilter/split.c libavfilter/src_movie.c libavfilter/vf_aspect.c libavfilter/vf_blackframe.c libavfilter/vf_colorbalance.c libavfilter/vf_copy.c libavfilter/vf_crop.c libavfilter/vf_cropdetect.c libavfilter/vf_drawbox.c libavfilter/vf_format.c libavfilter/vf_framestep.c libavfilter/vf_frei0r.c libavfilter/vf_hflip.c libavfilter/vf_libopencv.c libavfilter/vf_lut.c libavfilter/vf_null.c libavfilter/vf_overlay.c libavfilter/vf_scale.c libavfilter/vf_transpose.c libavfilter/vf_unsharp.c libavfilter/vf_vflip.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
112 lines
3.0 KiB
C
112 lines
3.0 KiB
C
/*
|
|
* Copyright (c) 2007 Bobby Bingham
|
|
*
|
|
* 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
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* video vertical flip filter
|
|
*/
|
|
|
|
#include "libavutil/internal.h"
|
|
#include "libavutil/pixdesc.h"
|
|
#include "avfilter.h"
|
|
#include "internal.h"
|
|
#include "video.h"
|
|
|
|
typedef struct {
|
|
int vsub; ///< vertical chroma subsampling
|
|
} FlipContext;
|
|
|
|
static int config_input(AVFilterLink *link)
|
|
{
|
|
FlipContext *flip = link->dst->priv;
|
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
|
|
|
|
flip->vsub = desc->log2_chroma_h;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static AVFrame *get_video_buffer(AVFilterLink *link, int w, int h)
|
|
{
|
|
FlipContext *flip = link->dst->priv;
|
|
AVFrame *frame;
|
|
int i;
|
|
|
|
frame = ff_get_video_buffer(link->dst->outputs[0], w, h);
|
|
if (!frame)
|
|
return NULL;
|
|
|
|
for (i = 0; i < 4; i ++) {
|
|
int vsub = i == 1 || i == 2 ? flip->vsub : 0;
|
|
int height = FF_CEIL_RSHIFT(h, vsub);
|
|
|
|
if (frame->data[i]) {
|
|
frame->data[i] += (height - 1) * frame->linesize[i];
|
|
frame->linesize[i] = -frame->linesize[i];
|
|
}
|
|
}
|
|
|
|
return frame;
|
|
}
|
|
|
|
static int filter_frame(AVFilterLink *link, AVFrame *frame)
|
|
{
|
|
FlipContext *flip = link->dst->priv;
|
|
int i;
|
|
|
|
for (i = 0; i < 4; i ++) {
|
|
int vsub = i == 1 || i == 2 ? flip->vsub : 0;
|
|
int height = FF_CEIL_RSHIFT(link->h, vsub);
|
|
|
|
if (frame->data[i]) {
|
|
frame->data[i] += (height - 1) * frame->linesize[i];
|
|
frame->linesize[i] = -frame->linesize[i];
|
|
}
|
|
}
|
|
|
|
return ff_filter_frame(link->dst->outputs[0], frame);
|
|
}
|
|
static const AVFilterPad avfilter_vf_vflip_inputs[] = {
|
|
{
|
|
.name = "default",
|
|
.type = AVMEDIA_TYPE_VIDEO,
|
|
.get_video_buffer = get_video_buffer,
|
|
.filter_frame = filter_frame,
|
|
.config_props = config_input,
|
|
},
|
|
{ NULL }
|
|
};
|
|
|
|
static const AVFilterPad avfilter_vf_vflip_outputs[] = {
|
|
{
|
|
.name = "default",
|
|
.type = AVMEDIA_TYPE_VIDEO,
|
|
},
|
|
{ NULL }
|
|
};
|
|
|
|
AVFilter ff_vf_vflip = {
|
|
.name = "vflip",
|
|
.description = NULL_IF_CONFIG_SMALL("Flip the input video vertically."),
|
|
.priv_size = sizeof(FlipContext),
|
|
.inputs = avfilter_vf_vflip_inputs,
|
|
.outputs = avfilter_vf_vflip_outputs,
|
|
};
|