yading@10: /* yading@10: * Copyright (C) 2013 Wei Gao yading@10: * yading@10: * This file is part of FFmpeg. yading@10: * yading@10: * FFmpeg is free software; you can redistribute it and/or yading@10: * modify it under the terms of the GNU Lesser General Public yading@10: * License as published by the Free Software Foundation; either yading@10: * version 2.1 of the License, or (at your option) any later version. yading@10: * yading@10: * FFmpeg is distributed in the hope that it will be useful, yading@10: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@10: * Lesser General Public License for more details. yading@10: * yading@10: * You should have received a copy of the GNU Lesser General Public yading@10: * License along with FFmpeg; if not, write to the Free Software yading@10: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@10: */ yading@10: yading@10: #ifndef AVFILTER_DESHAKE_H yading@10: #define AVFILTER_DESHAKE_H yading@10: yading@10: #include "config.h" yading@10: #include "avfilter.h" yading@10: #include "libavcodec/dsputil.h" yading@10: #include "transform.h" yading@10: #if CONFIG_OPENCL yading@10: #include "libavutil/opencl.h" yading@10: #endif yading@10: yading@10: yading@10: enum SearchMethod { yading@10: EXHAUSTIVE, ///< Search all possible positions yading@10: SMART_EXHAUSTIVE, ///< Search most possible positions (faster) yading@10: SEARCH_COUNT yading@10: }; yading@10: yading@10: typedef struct { yading@10: int x; ///< Horizontal shift yading@10: int y; ///< Vertical shift yading@10: } IntMotionVector; yading@10: yading@10: typedef struct { yading@10: double x; ///< Horizontal shift yading@10: double y; ///< Vertical shift yading@10: } MotionVector; yading@10: yading@10: typedef struct { yading@10: MotionVector vector; ///< Motion vector yading@10: double angle; ///< Angle of rotation yading@10: double zoom; ///< Zoom percentage yading@10: } Transform; yading@10: yading@10: #if CONFIG_OPENCL yading@10: yading@10: typedef struct { yading@10: size_t matrix_size; yading@10: float matrix_y[9]; yading@10: float matrix_uv[9]; yading@10: cl_mem cl_matrix_y; yading@10: cl_mem cl_matrix_uv; yading@10: int in_plane_size[8]; yading@10: int out_plane_size[8]; yading@10: int plane_num; yading@10: cl_mem cl_inbuf; yading@10: size_t cl_inbuf_size; yading@10: cl_mem cl_outbuf; yading@10: size_t cl_outbuf_size; yading@10: AVOpenCLKernelEnv kernel_env; yading@10: } DeshakeOpenclContext; yading@10: yading@10: #endif yading@10: yading@10: typedef struct { yading@10: const AVClass *class; yading@10: AVFrame *ref; ///< Previous frame yading@10: int rx; ///< Maximum horizontal shift yading@10: int ry; ///< Maximum vertical shift yading@10: int edge; ///< Edge fill method yading@10: int blocksize; ///< Size of blocks to compare yading@10: int contrast; ///< Contrast threshold yading@10: int search; ///< Motion search method yading@10: AVCodecContext *avctx; yading@10: DSPContext c; ///< Context providing optimized SAD methods yading@10: Transform last; ///< Transform from last frame yading@10: int refcount; ///< Number of reference frames (defines averaging window) yading@10: FILE *fp; yading@10: Transform avg; yading@10: int cw; ///< Crop motion search to this box yading@10: int ch; yading@10: int cx; yading@10: int cy; yading@10: char *filename; ///< Motion search detailed log filename yading@10: int opencl; yading@10: #if CONFIG_OPENCL yading@10: DeshakeOpenclContext opencl_ctx; yading@10: #endif yading@10: int (* transform)(AVFilterContext *ctx, int width, int height, int cw, int ch, yading@10: const float *matrix_y, const float *matrix_uv, enum InterpolateMethod interpolate, yading@10: enum FillMethod fill, AVFrame *in, AVFrame *out); yading@10: } DeshakeContext; yading@10: yading@10: #endif /* AVFILTER_DESHAKE_H */