deshake.h
Go to the documentation of this file.
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 
34  EXHAUSTIVE, ///< Search all possible positions
35  SMART_EXHAUSTIVE, ///< Search most possible positions (faster)
37 };
38 
39 typedef struct {
40  int x; ///< Horizontal shift
41  int y; ///< Vertical shift
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
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;
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);
103 
104 #endif /* AVFILTER_DESHAKE_H */
This structure describes decoded (raw) audio or video data.
Definition: frame.h:76
int ry
Maximum vertical shift.
Definition: deshake.h:79
external API header
int y
Vertical shift.
Definition: deshake.h:41
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip in
Definition: git-howto.txt:5
double angle
Angle of rotation.
Definition: deshake.h:51
InterpolateMethod
Definition: transform.h:39
AVCodecContext * avctx
Definition: deshake.h:84
double zoom
Zoom percentage.
Definition: deshake.h:52
static void interpolate(float *out, float v1, float v2, int size)
Definition: twinvq.c:280
int blocksize
Size of blocks to compare.
Definition: deshake.h:81
FILE * fp
Definition: deshake.h:88
int refcount
Number of reference frames (defines averaging window)
Definition: deshake.h:87
int rx
Maximum horizontal shift.
Definition: deshake.h:78
char * filename
Motion search detailed log filename.
Definition: deshake.h:94
double x
Horizontal shift.
Definition: deshake.h:45
int contrast
Contrast threshold.
Definition: deshake.h:82
FillMethod
Definition: transform.h:51
int edge
Edge fill method.
Definition: deshake.h:80
int search
Motion search method.
Definition: deshake.h:83
DSPContext c
Context providing optimized SAD methods.
Definition: deshake.h:85
transform input video
double y
Vertical shift.
Definition: deshake.h:46
Search all possible positions.
Definition: deshake.h:34
static OpenclContext opencl_ctx
Definition: opencl.c:95
static int width
Definition: tests/utils.c:158
AVFrame * ref
Previous frame.
Definition: deshake.h:77
Transform avg
Definition: deshake.h:89
Search most possible positions (faster)
Definition: deshake.h:35
main external API structure.
spectrum bins to fill(1-based indexing) for m
BYTE int const BYTE int int int height
Definition: avisynth_c.h:713
Describe the class of an AVClass context structure.
Definition: log.h:50
int cw
Crop motion search to this box.
Definition: deshake.h:90
Transform last
Transform from last frame.
Definition: deshake.h:86
MotionVector vector
Motion vector.
Definition: deshake.h:50
SearchMethod
Definition: deshake.h:33
DSP utils.
int x
Horizontal shift.
Definition: deshake.h:40
An instance of a filter.
Definition: avfilter.h:524
OpenCL wrapper.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> out
DSPContext.
Definition: dsputil.h:127