Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (C) 2013 Wei Gao <weigao@multicorewareinc.com>
  3.  *
  4.  * This file is part of FFmpeg.
  5.  *
  6.  * FFmpeg is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2.1 of the License, or (at your option) any later version.
  10.  *
  11.  * FFmpeg is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with FFmpeg; if not, write to the Free Software
  18.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19.  */
  20.  
  21. #ifndef AVFILTER_DESHAKE_H
  22. #define AVFILTER_DESHAKE_H
  23.  
  24. #include "config.h"
  25. #include "avfilter.h"
  26. #include "libavcodec/dsputil.h"
  27. #include "transform.h"
  28. #if CONFIG_OPENCL
  29. #include "libavutil/opencl.h"
  30. #endif
  31.  
  32.  
  33. enum SearchMethod {
  34.     EXHAUSTIVE,        ///< Search all possible positions
  35.     SMART_EXHAUSTIVE,  ///< Search most possible positions (faster)
  36.     SEARCH_COUNT
  37. };
  38.  
  39. typedef struct {
  40.     int x;             ///< Horizontal shift
  41.     int y;             ///< Vertical shift
  42. } IntMotionVector;
  43.  
  44. typedef struct {
  45.     double x;             ///< Horizontal shift
  46.     double y;             ///< Vertical shift
  47. } MotionVector;
  48.  
  49. typedef struct {
  50.     MotionVector vector;  ///< Motion vector
  51.     double angle;         ///< Angle of rotation
  52.     double zoom;          ///< Zoom percentage
  53. } Transform;
  54.  
  55. #if CONFIG_OPENCL
  56.  
  57. typedef struct {
  58.     size_t matrix_size;
  59.     float matrix_y[9];
  60.     float matrix_uv[9];
  61.     cl_mem cl_matrix_y;
  62.     cl_mem cl_matrix_uv;
  63.     int in_plane_size[8];
  64.     int out_plane_size[8];
  65.     int plane_num;
  66.     cl_mem cl_inbuf;
  67.     size_t cl_inbuf_size;
  68.     cl_mem cl_outbuf;
  69.     size_t cl_outbuf_size;
  70.     AVOpenCLKernelEnv kernel_env;
  71. } DeshakeOpenclContext;
  72.  
  73. #endif
  74.  
  75. typedef struct {
  76.     const AVClass *class;
  77.     AVFrame *ref;              ///< Previous frame
  78.     int rx;                    ///< Maximum horizontal shift
  79.     int ry;                    ///< Maximum vertical shift
  80.     int edge;                  ///< Edge fill method
  81.     int blocksize;             ///< Size of blocks to compare
  82.     int contrast;              ///< Contrast threshold
  83.     int search;                ///< Motion search method
  84.     AVCodecContext *avctx;
  85.     DSPContext c;              ///< Context providing optimized SAD methods
  86.     Transform last;            ///< Transform from last frame
  87.     int refcount;              ///< Number of reference frames (defines averaging window)
  88.     FILE *fp;
  89.     Transform avg;
  90.     int cw;                    ///< Crop motion search to this box
  91.     int ch;
  92.     int cx;
  93.     int cy;
  94.     char *filename;            ///< Motion search detailed log filename
  95.     int opencl;
  96. #if CONFIG_OPENCL
  97.     DeshakeOpenclContext opencl_ctx;
  98. #endif
  99.     int (* transform)(AVFilterContext *ctx, int width, int height, int cw, int ch,
  100.                       const float *matrix_y, const float *matrix_uv, enum InterpolateMethod interpolate,
  101.                       enum FillMethod fill, AVFrame *in, AVFrame *out);
  102. } DeshakeContext;
  103.  
  104. #endif /* AVFILTER_DESHAKE_H */
  105.