2013-04-02 14:54:22 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Wei Gao <weigao@multicorewareinc.com>
|
2013-12-14 12:11:00 +01:00
|
|
|
* Copyright (C) 2013 Lenny Wang
|
2013-04-02 14:54:22 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AVFILTER_DESHAKE_H
|
|
|
|
#define AVFILTER_DESHAKE_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "avfilter.h"
|
|
|
|
#include "transform.h"
|
2014-08-02 18:57:32 +02:00
|
|
|
#include "libavutil/pixelutils.h"
|
2013-04-02 14:54:22 +02:00
|
|
|
#if CONFIG_OPENCL
|
|
|
|
#include "libavutil/opencl.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
enum SearchMethod {
|
|
|
|
EXHAUSTIVE, ///< Search all possible positions
|
|
|
|
SMART_EXHAUSTIVE, ///< Search most possible positions (faster)
|
|
|
|
SEARCH_COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int x; ///< Horizontal shift
|
|
|
|
int y; ///< Vertical shift
|
|
|
|
} IntMotionVector;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double x; ///< Horizontal shift
|
|
|
|
double y; ///< Vertical shift
|
|
|
|
} MotionVector;
|
|
|
|
|
|
|
|
typedef struct {
|
2014-09-18 00:08:05 +02:00
|
|
|
MotionVector vec; ///< Motion vector
|
2013-04-02 14:54:22 +02:00
|
|
|
double angle; ///< Angle of rotation
|
|
|
|
double zoom; ///< Zoom percentage
|
|
|
|
} Transform;
|
|
|
|
|
|
|
|
#if CONFIG_OPENCL
|
|
|
|
|
|
|
|
typedef struct {
|
2013-11-04 04:58:09 +01:00
|
|
|
cl_command_queue command_queue;
|
|
|
|
cl_program program;
|
2013-12-14 12:11:00 +01:00
|
|
|
cl_kernel kernel_luma;
|
|
|
|
cl_kernel kernel_chroma;
|
2013-04-02 14:54:22 +02:00
|
|
|
int in_plane_size[8];
|
|
|
|
int out_plane_size[8];
|
|
|
|
int plane_num;
|
|
|
|
cl_mem cl_inbuf;
|
|
|
|
size_t cl_inbuf_size;
|
|
|
|
cl_mem cl_outbuf;
|
|
|
|
size_t cl_outbuf_size;
|
|
|
|
} DeshakeOpenclContext;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2014-09-01 23:36:29 +02:00
|
|
|
#define MAX_R 64
|
|
|
|
|
2013-04-02 14:54:22 +02:00
|
|
|
typedef struct {
|
|
|
|
const AVClass *class;
|
2014-09-01 23:36:29 +02:00
|
|
|
int counts[2*MAX_R+1][2*MAX_R+1]; /// < Scratch buffer for motion search
|
2014-09-01 23:47:12 +02:00
|
|
|
double *angles; ///< Scratch buffer for block angles
|
|
|
|
unsigned angles_size;
|
2013-04-02 14:54:22 +02:00
|
|
|
AVFrame *ref; ///< Previous frame
|
|
|
|
int rx; ///< Maximum horizontal shift
|
|
|
|
int ry; ///< Maximum vertical shift
|
|
|
|
int edge; ///< Edge fill method
|
|
|
|
int blocksize; ///< Size of blocks to compare
|
|
|
|
int contrast; ///< Contrast threshold
|
|
|
|
int search; ///< Motion search method
|
2014-08-02 18:57:32 +02:00
|
|
|
av_pixelutils_sad_fn sad; ///< Sum of the absolute difference function
|
2013-04-02 14:54:22 +02:00
|
|
|
Transform last; ///< Transform from last frame
|
|
|
|
int refcount; ///< Number of reference frames (defines averaging window)
|
|
|
|
FILE *fp;
|
|
|
|
Transform avg;
|
|
|
|
int cw; ///< Crop motion search to this box
|
|
|
|
int ch;
|
|
|
|
int cx;
|
|
|
|
int cy;
|
|
|
|
char *filename; ///< Motion search detailed log filename
|
|
|
|
int opencl;
|
|
|
|
#if CONFIG_OPENCL
|
|
|
|
DeshakeOpenclContext opencl_ctx;
|
|
|
|
#endif
|
|
|
|
int (* transform)(AVFilterContext *ctx, int width, int height, int cw, int ch,
|
|
|
|
const float *matrix_y, const float *matrix_uv, enum InterpolateMethod interpolate,
|
|
|
|
enum FillMethod fill, AVFrame *in, AVFrame *out);
|
|
|
|
} DeshakeContext;
|
|
|
|
|
|
|
|
#endif /* AVFILTER_DESHAKE_H */
|