vf_deshake.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /*
  2. * Copyright (C) 2010 Georg Martius <georg.martius@web.de>
  3. * Copyright (C) 2010 Daniel G. Taylor <dan@programmer-art.org>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * fast deshake / depan video filter
  24. *
  25. * SAD block-matching motion compensation to fix small changes in
  26. * horizontal and/or vertical shift. This filter helps remove camera shake
  27. * from hand-holding a camera, bumping a tripod, moving on a vehicle, etc.
  28. *
  29. * Algorithm:
  30. * - For each frame with one previous reference frame
  31. * - For each block in the frame
  32. * - If contrast > threshold then find likely motion vector
  33. * - For all found motion vectors
  34. * - Find most common, store as global motion vector
  35. * - Find most likely rotation angle
  36. * - Transform image along global motion
  37. *
  38. * TODO:
  39. * - Fill frame edges based on previous/next reference frames
  40. * - Fill frame edges by stretching image near the edges?
  41. * - Can this be done quickly and look decent?
  42. *
  43. * Dark Shikari links to http://wiki.videolan.org/SoC_x264_2010#GPU_Motion_Estimation_2
  44. * for an algorithm similar to what could be used here to get the gmv
  45. * It requires only a couple diamond searches + fast downscaling
  46. *
  47. * Special thanks to Jason Kotenko for his help with the algorithm and my
  48. * inability to see simple errors in C code.
  49. */
  50. #include "avfilter.h"
  51. #include "formats.h"
  52. #include "internal.h"
  53. #include "video.h"
  54. #include "libavutil/common.h"
  55. #include "libavutil/mem.h"
  56. #include "libavutil/pixdesc.h"
  57. #include "libavcodec/dsputil.h"
  58. #include "transform.h"
  59. #define CHROMA_WIDTH(link) -((-link->w) >> av_pix_fmt_desc_get(link->format)->log2_chroma_w)
  60. #define CHROMA_HEIGHT(link) -((-link->h) >> av_pix_fmt_desc_get(link->format)->log2_chroma_h)
  61. enum SearchMethod {
  62. EXHAUSTIVE, ///< Search all possible positions
  63. SMART_EXHAUSTIVE, ///< Search most possible positions (faster)
  64. SEARCH_COUNT
  65. };
  66. typedef struct {
  67. int x; ///< Horizontal shift
  68. int y; ///< Vertical shift
  69. } IntMotionVector;
  70. typedef struct {
  71. double x; ///< Horizontal shift
  72. double y; ///< Vertical shift
  73. } MotionVector;
  74. typedef struct {
  75. MotionVector vector; ///< Motion vector
  76. double angle; ///< Angle of rotation
  77. double zoom; ///< Zoom percentage
  78. } Transform;
  79. typedef struct {
  80. AVClass av_class;
  81. AVFilterBufferRef *ref; ///< Previous frame
  82. int rx; ///< Maximum horizontal shift
  83. int ry; ///< Maximum vertical shift
  84. int edge; ///< Edge fill method
  85. int blocksize; ///< Size of blocks to compare
  86. int contrast; ///< Contrast threshold
  87. int search; ///< Motion search method
  88. AVCodecContext *avctx;
  89. DSPContext c; ///< Context providing optimized SAD methods
  90. Transform last; ///< Transform from last frame
  91. int refcount; ///< Number of reference frames (defines averaging window)
  92. FILE *fp;
  93. Transform avg;
  94. int cw; ///< Crop motion search to this box
  95. int ch;
  96. int cx;
  97. int cy;
  98. } DeshakeContext;
  99. static int cmp(const double *a, const double *b)
  100. {
  101. return *a < *b ? -1 : ( *a > *b ? 1 : 0 );
  102. }
  103. /**
  104. * Cleaned mean (cuts off 20% of values to remove outliers and then averages)
  105. */
  106. static double clean_mean(double *values, int count)
  107. {
  108. double mean = 0;
  109. int cut = count / 5;
  110. int x;
  111. qsort(values, count, sizeof(double), (void*)cmp);
  112. for (x = cut; x < count - cut; x++) {
  113. mean += values[x];
  114. }
  115. return mean / (count - cut * 2);
  116. }
  117. /**
  118. * Find the most likely shift in motion between two frames for a given
  119. * macroblock. Test each block against several shifts given by the rx
  120. * and ry attributes. Searches using a simple matrix of those shifts and
  121. * chooses the most likely shift by the smallest difference in blocks.
  122. */
  123. static void find_block_motion(DeshakeContext *deshake, uint8_t *src1,
  124. uint8_t *src2, int cx, int cy, int stride,
  125. IntMotionVector *mv)
  126. {
  127. int x, y;
  128. int diff;
  129. int smallest = INT_MAX;
  130. int tmp, tmp2;
  131. #define CMP(i, j) deshake->c.sad[0](deshake, src1 + cy * stride + cx, \
  132. src2 + (j) * stride + (i), stride, \
  133. deshake->blocksize)
  134. if (deshake->search == EXHAUSTIVE) {
  135. // Compare every possible position - this is sloooow!
  136. for (y = -deshake->ry; y <= deshake->ry; y++) {
  137. for (x = -deshake->rx; x <= deshake->rx; x++) {
  138. diff = CMP(cx - x, cy - y);
  139. if (diff < smallest) {
  140. smallest = diff;
  141. mv->x = x;
  142. mv->y = y;
  143. }
  144. }
  145. }
  146. } else if (deshake->search == SMART_EXHAUSTIVE) {
  147. // Compare every other possible position and find the best match
  148. for (y = -deshake->ry + 1; y < deshake->ry - 2; y += 2) {
  149. for (x = -deshake->rx + 1; x < deshake->rx - 2; x += 2) {
  150. diff = CMP(cx - x, cy - y);
  151. if (diff < smallest) {
  152. smallest = diff;
  153. mv->x = x;
  154. mv->y = y;
  155. }
  156. }
  157. }
  158. // Hone in on the specific best match around the match we found above
  159. tmp = mv->x;
  160. tmp2 = mv->y;
  161. for (y = tmp2 - 1; y <= tmp2 + 1; y++) {
  162. for (x = tmp - 1; x <= tmp + 1; x++) {
  163. if (x == tmp && y == tmp2)
  164. continue;
  165. diff = CMP(cx - x, cy - y);
  166. if (diff < smallest) {
  167. smallest = diff;
  168. mv->x = x;
  169. mv->y = y;
  170. }
  171. }
  172. }
  173. }
  174. if (smallest > 512) {
  175. mv->x = -1;
  176. mv->y = -1;
  177. }
  178. emms_c();
  179. //av_log(NULL, AV_LOG_ERROR, "%d\n", smallest);
  180. //av_log(NULL, AV_LOG_ERROR, "Final: (%d, %d) = %d x %d\n", cx, cy, mv->x, mv->y);
  181. }
  182. /**
  183. * Find the contrast of a given block. When searching for global motion we
  184. * really only care about the high contrast blocks, so using this method we
  185. * can actually skip blocks we don't care much about.
  186. */
  187. static int block_contrast(uint8_t *src, int x, int y, int stride, int blocksize)
  188. {
  189. int highest = 0;
  190. int lowest = 0;
  191. int i, j, pos;
  192. for (i = 0; i <= blocksize * 2; i++) {
  193. // We use a width of 16 here to match the libavcodec sad functions
  194. for (j = 0; i <= 15; i++) {
  195. pos = (y - i) * stride + (x - j);
  196. if (src[pos] < lowest)
  197. lowest = src[pos];
  198. else if (src[pos] > highest) {
  199. highest = src[pos];
  200. }
  201. }
  202. }
  203. return highest - lowest;
  204. }
  205. /**
  206. * Find the rotation for a given block.
  207. */
  208. static double block_angle(int x, int y, int cx, int cy, IntMotionVector *shift)
  209. {
  210. double a1, a2, diff;
  211. a1 = atan2(y - cy, x - cx);
  212. a2 = atan2(y - cy + shift->y, x - cx + shift->x);
  213. diff = a2 - a1;
  214. return (diff > M_PI) ? diff - 2 * M_PI :
  215. (diff < -M_PI) ? diff + 2 * M_PI :
  216. diff;
  217. }
  218. /**
  219. * Find the estimated global motion for a scene given the most likely shift
  220. * for each block in the frame. The global motion is estimated to be the
  221. * same as the motion from most blocks in the frame, so if most blocks
  222. * move one pixel to the right and two pixels down, this would yield a
  223. * motion vector (1, -2).
  224. */
  225. static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
  226. int width, int height, int stride, Transform *t)
  227. {
  228. int x, y;
  229. IntMotionVector mv = {0, 0};
  230. int counts[128][128];
  231. int count_max_value = 0;
  232. int contrast;
  233. int pos;
  234. double *angles = av_malloc(sizeof(*angles) * width * height / (16 * deshake->blocksize));
  235. int center_x = 0, center_y = 0;
  236. double p_x, p_y;
  237. // Reset counts to zero
  238. for (x = 0; x < deshake->rx * 2 + 1; x++) {
  239. for (y = 0; y < deshake->ry * 2 + 1; y++) {
  240. counts[x][y] = 0;
  241. }
  242. }
  243. pos = 0;
  244. // Find motion for every block and store the motion vector in the counts
  245. for (y = deshake->ry; y < height - deshake->ry - (deshake->blocksize * 2); y += deshake->blocksize * 2) {
  246. // We use a width of 16 here to match the libavcodec sad functions
  247. for (x = deshake->rx; x < width - deshake->rx - 16; x += 16) {
  248. // If the contrast is too low, just skip this block as it probably
  249. // won't be very useful to us.
  250. contrast = block_contrast(src2, x, y, stride, deshake->blocksize);
  251. if (contrast > deshake->contrast) {
  252. //av_log(NULL, AV_LOG_ERROR, "%d\n", contrast);
  253. find_block_motion(deshake, src1, src2, x, y, stride, &mv);
  254. if (mv.x != -1 && mv.y != -1) {
  255. counts[mv.x + deshake->rx][mv.y + deshake->ry] += 1;
  256. if (x > deshake->rx && y > deshake->ry)
  257. angles[pos++] = block_angle(x, y, 0, 0, &mv);
  258. center_x += mv.x;
  259. center_y += mv.y;
  260. }
  261. }
  262. }
  263. }
  264. if (pos) {
  265. center_x /= pos;
  266. center_y /= pos;
  267. t->angle = clean_mean(angles, pos);
  268. if (t->angle < 0.001)
  269. t->angle = 0;
  270. } else {
  271. t->angle = 0;
  272. }
  273. // Find the most common motion vector in the frame and use it as the gmv
  274. for (y = deshake->ry * 2; y >= 0; y--) {
  275. for (x = 0; x < deshake->rx * 2 + 1; x++) {
  276. //av_log(NULL, AV_LOG_ERROR, "%5d ", counts[x][y]);
  277. if (counts[x][y] > count_max_value) {
  278. t->vector.x = x - deshake->rx;
  279. t->vector.y = y - deshake->ry;
  280. count_max_value = counts[x][y];
  281. }
  282. }
  283. //av_log(NULL, AV_LOG_ERROR, "\n");
  284. }
  285. p_x = (center_x - width / 2.0);
  286. p_y = (center_y - height / 2.0);
  287. t->vector.x += (cos(t->angle)-1)*p_x - sin(t->angle)*p_y;
  288. t->vector.y += sin(t->angle)*p_x + (cos(t->angle)-1)*p_y;
  289. // Clamp max shift & rotation?
  290. t->vector.x = av_clipf(t->vector.x, -deshake->rx * 2, deshake->rx * 2);
  291. t->vector.y = av_clipf(t->vector.y, -deshake->ry * 2, deshake->ry * 2);
  292. t->angle = av_clipf(t->angle, -0.1, 0.1);
  293. //av_log(NULL, AV_LOG_ERROR, "%d x %d\n", avg->x, avg->y);
  294. av_free(angles);
  295. }
  296. static av_cold int init(AVFilterContext *ctx, const char *args)
  297. {
  298. DeshakeContext *deshake = ctx->priv;
  299. char filename[256] = {0};
  300. deshake->rx = 16;
  301. deshake->ry = 16;
  302. deshake->edge = FILL_MIRROR;
  303. deshake->blocksize = 8;
  304. deshake->contrast = 125;
  305. deshake->search = EXHAUSTIVE;
  306. deshake->refcount = 20;
  307. deshake->cw = -1;
  308. deshake->ch = -1;
  309. deshake->cx = -1;
  310. deshake->cy = -1;
  311. if (args) {
  312. sscanf(args, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%255s",
  313. &deshake->cx, &deshake->cy, &deshake->cw, &deshake->ch,
  314. &deshake->rx, &deshake->ry, &deshake->edge,
  315. &deshake->blocksize, &deshake->contrast, &deshake->search, filename);
  316. deshake->blocksize /= 2;
  317. deshake->rx = av_clip(deshake->rx, 0, 64);
  318. deshake->ry = av_clip(deshake->ry, 0, 64);
  319. deshake->edge = av_clip(deshake->edge, FILL_BLANK, FILL_COUNT - 1);
  320. deshake->blocksize = av_clip(deshake->blocksize, 4, 128);
  321. deshake->contrast = av_clip(deshake->contrast, 1, 255);
  322. deshake->search = av_clip(deshake->search, EXHAUSTIVE, SEARCH_COUNT - 1);
  323. }
  324. if (*filename)
  325. deshake->fp = fopen(filename, "w");
  326. if (deshake->fp)
  327. fwrite("Ori x, Avg x, Fin x, Ori y, Avg y, Fin y, Ori angle, Avg angle, Fin angle, Ori zoom, Avg zoom, Fin zoom\n", sizeof(char), 104, deshake->fp);
  328. // Quadword align left edge of box for MMX code, adjust width if necessary
  329. // to keep right margin
  330. if (deshake->cx > 0) {
  331. deshake->cw += deshake->cx - (deshake->cx & ~15);
  332. deshake->cx &= ~15;
  333. }
  334. av_log(ctx, AV_LOG_VERBOSE, "cx: %d, cy: %d, cw: %d, ch: %d, rx: %d, ry: %d, edge: %d blocksize: %d contrast: %d search: %d\n",
  335. deshake->cx, deshake->cy, deshake->cw, deshake->ch,
  336. deshake->rx, deshake->ry, deshake->edge, deshake->blocksize * 2, deshake->contrast, deshake->search);
  337. return 0;
  338. }
  339. static int query_formats(AVFilterContext *ctx)
  340. {
  341. static const enum AVPixelFormat pix_fmts[] = {
  342. AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV410P,
  343. AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
  344. AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_NONE
  345. };
  346. ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
  347. return 0;
  348. }
  349. static int config_props(AVFilterLink *link)
  350. {
  351. DeshakeContext *deshake = link->dst->priv;
  352. deshake->ref = NULL;
  353. deshake->last.vector.x = 0;
  354. deshake->last.vector.y = 0;
  355. deshake->last.angle = 0;
  356. deshake->last.zoom = 0;
  357. deshake->avctx = avcodec_alloc_context3(NULL);
  358. dsputil_init(&deshake->c, deshake->avctx);
  359. return 0;
  360. }
  361. static av_cold void uninit(AVFilterContext *ctx)
  362. {
  363. DeshakeContext *deshake = ctx->priv;
  364. avfilter_unref_buffer(deshake->ref);
  365. if (deshake->fp)
  366. fclose(deshake->fp);
  367. if (deshake->avctx)
  368. avcodec_close(deshake->avctx);
  369. av_freep(&deshake->avctx);
  370. }
  371. static int filter_frame(AVFilterLink *link, AVFilterBufferRef *in)
  372. {
  373. DeshakeContext *deshake = link->dst->priv;
  374. AVFilterLink *outlink = link->dst->outputs[0];
  375. AVFilterBufferRef *out;
  376. Transform t = {{0},0}, orig = {{0},0};
  377. float matrix[9];
  378. float alpha = 2.0 / deshake->refcount;
  379. char tmp[256];
  380. out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
  381. if (!out) {
  382. avfilter_unref_bufferp(&in);
  383. return AVERROR(ENOMEM);
  384. }
  385. avfilter_copy_buffer_ref_props(out, in);
  386. if (deshake->cx < 0 || deshake->cy < 0 || deshake->cw < 0 || deshake->ch < 0) {
  387. // Find the most likely global motion for the current frame
  388. find_motion(deshake, (deshake->ref == NULL) ? in->data[0] : deshake->ref->data[0], in->data[0], link->w, link->h, in->linesize[0], &t);
  389. } else {
  390. uint8_t *src1 = (deshake->ref == NULL) ? in->data[0] : deshake->ref->data[0];
  391. uint8_t *src2 = in->data[0];
  392. deshake->cx = FFMIN(deshake->cx, link->w);
  393. deshake->cy = FFMIN(deshake->cy, link->h);
  394. if ((unsigned)deshake->cx + (unsigned)deshake->cw > link->w) deshake->cw = link->w - deshake->cx;
  395. if ((unsigned)deshake->cy + (unsigned)deshake->ch > link->h) deshake->ch = link->h - deshake->cy;
  396. // Quadword align right margin
  397. deshake->cw &= ~15;
  398. src1 += deshake->cy * in->linesize[0] + deshake->cx;
  399. src2 += deshake->cy * in->linesize[0] + deshake->cx;
  400. find_motion(deshake, src1, src2, deshake->cw, deshake->ch, in->linesize[0], &t);
  401. }
  402. // Copy transform so we can output it later to compare to the smoothed value
  403. orig.vector.x = t.vector.x;
  404. orig.vector.y = t.vector.y;
  405. orig.angle = t.angle;
  406. orig.zoom = t.zoom;
  407. // Generate a one-sided moving exponential average
  408. deshake->avg.vector.x = alpha * t.vector.x + (1.0 - alpha) * deshake->avg.vector.x;
  409. deshake->avg.vector.y = alpha * t.vector.y + (1.0 - alpha) * deshake->avg.vector.y;
  410. deshake->avg.angle = alpha * t.angle + (1.0 - alpha) * deshake->avg.angle;
  411. deshake->avg.zoom = alpha * t.zoom + (1.0 - alpha) * deshake->avg.zoom;
  412. // Remove the average from the current motion to detect the motion that
  413. // is not on purpose, just as jitter from bumping the camera
  414. t.vector.x -= deshake->avg.vector.x;
  415. t.vector.y -= deshake->avg.vector.y;
  416. t.angle -= deshake->avg.angle;
  417. t.zoom -= deshake->avg.zoom;
  418. // Invert the motion to undo it
  419. t.vector.x *= -1;
  420. t.vector.y *= -1;
  421. t.angle *= -1;
  422. // Write statistics to file
  423. if (deshake->fp) {
  424. snprintf(tmp, 256, "%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n", orig.vector.x, deshake->avg.vector.x, t.vector.x, orig.vector.y, deshake->avg.vector.y, t.vector.y, orig.angle, deshake->avg.angle, t.angle, orig.zoom, deshake->avg.zoom, t.zoom);
  425. fwrite(tmp, sizeof(char), strlen(tmp), deshake->fp);
  426. }
  427. // Turn relative current frame motion into absolute by adding it to the
  428. // last absolute motion
  429. t.vector.x += deshake->last.vector.x;
  430. t.vector.y += deshake->last.vector.y;
  431. t.angle += deshake->last.angle;
  432. t.zoom += deshake->last.zoom;
  433. // Shrink motion by 10% to keep things centered in the camera frame
  434. t.vector.x *= 0.9;
  435. t.vector.y *= 0.9;
  436. t.angle *= 0.9;
  437. // Store the last absolute motion information
  438. deshake->last.vector.x = t.vector.x;
  439. deshake->last.vector.y = t.vector.y;
  440. deshake->last.angle = t.angle;
  441. deshake->last.zoom = t.zoom;
  442. // Generate a luma transformation matrix
  443. avfilter_get_matrix(t.vector.x, t.vector.y, t.angle, 1.0 + t.zoom / 100.0, matrix);
  444. // Transform the luma plane
  445. avfilter_transform(in->data[0], out->data[0], in->linesize[0], out->linesize[0], link->w, link->h, matrix, INTERPOLATE_BILINEAR, deshake->edge);
  446. // Generate a chroma transformation matrix
  447. avfilter_get_matrix(t.vector.x / (link->w / CHROMA_WIDTH(link)), t.vector.y / (link->h / CHROMA_HEIGHT(link)), t.angle, 1.0 + t.zoom / 100.0, matrix);
  448. // Transform the chroma planes
  449. avfilter_transform(in->data[1], out->data[1], in->linesize[1], out->linesize[1], CHROMA_WIDTH(link), CHROMA_HEIGHT(link), matrix, INTERPOLATE_BILINEAR, deshake->edge);
  450. avfilter_transform(in->data[2], out->data[2], in->linesize[2], out->linesize[2], CHROMA_WIDTH(link), CHROMA_HEIGHT(link), matrix, INTERPOLATE_BILINEAR, deshake->edge);
  451. // Cleanup the old reference frame
  452. avfilter_unref_buffer(deshake->ref);
  453. // Store the current frame as the reference frame for calculating the
  454. // motion of the next frame
  455. deshake->ref = in;
  456. return ff_filter_frame(outlink, out);
  457. }
  458. static const AVFilterPad deshake_inputs[] = {
  459. {
  460. .name = "default",
  461. .type = AVMEDIA_TYPE_VIDEO,
  462. .filter_frame = filter_frame,
  463. .config_props = config_props,
  464. .min_perms = AV_PERM_READ | AV_PERM_PRESERVE,
  465. },
  466. { NULL }
  467. };
  468. static const AVFilterPad deshake_outputs[] = {
  469. {
  470. .name = "default",
  471. .type = AVMEDIA_TYPE_VIDEO,
  472. },
  473. { NULL }
  474. };
  475. AVFilter avfilter_vf_deshake = {
  476. .name = "deshake",
  477. .description = NULL_IF_CONFIG_SMALL("Stabilize shaky video."),
  478. .priv_size = sizeof(DeshakeContext),
  479. .init = init,
  480. .uninit = uninit,
  481. .query_formats = query_formats,
  482. .inputs = deshake_inputs,
  483. .outputs = deshake_outputs,
  484. };