Commit def03d34 authored by Clément Bœsch's avatar Clément Bœsch

avfilter/deshake: remove avcodec dependency

parent f50ec597
...@@ -2533,8 +2533,7 @@ cropdetect_filter_deps="gpl" ...@@ -2533,8 +2533,7 @@ cropdetect_filter_deps="gpl"
dctdnoiz_filter_deps="avcodec" dctdnoiz_filter_deps="avcodec"
dctdnoiz_filter_select="dct" dctdnoiz_filter_select="dct"
delogo_filter_deps="gpl" delogo_filter_deps="gpl"
deshake_filter_deps="avcodec" deshake_filter_select="pixelutils"
deshake_filter_select="me_cmp"
drawtext_filter_deps="libfreetype" drawtext_filter_deps="libfreetype"
ebur128_filter_deps="gpl" ebur128_filter_deps="gpl"
flite_filter_deps="libflite" flite_filter_deps="libflite"
...@@ -5253,7 +5252,6 @@ enabled amovie_filter && prepend avfilter_deps "avformat avcodec" ...@@ -5253,7 +5252,6 @@ enabled amovie_filter && prepend avfilter_deps "avformat avcodec"
enabled aresample_filter && prepend avfilter_deps "swresample" enabled aresample_filter && prepend avfilter_deps "swresample"
enabled asyncts_filter && prepend avfilter_deps "avresample" enabled asyncts_filter && prepend avfilter_deps "avresample"
enabled atempo_filter && prepend avfilter_deps "avcodec" enabled atempo_filter && prepend avfilter_deps "avcodec"
enabled deshake_filter && prepend avfilter_deps "avcodec"
enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample" enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample"
enabled elbg_filter && prepend avfilter_deps "avcodec" enabled elbg_filter && prepend avfilter_deps "avcodec"
enabled mcdeint_filter && prepend avfilter_deps "avcodec" enabled mcdeint_filter && prepend avfilter_deps "avcodec"
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include "config.h" #include "config.h"
#include "avfilter.h" #include "avfilter.h"
#include "libavcodec/dsputil.h"
#include "transform.h" #include "transform.h"
#include "libavutil/pixelutils.h"
#if CONFIG_OPENCL #if CONFIG_OPENCL
#include "libavutil/opencl.h" #include "libavutil/opencl.h"
#endif #endif
...@@ -80,8 +80,7 @@ typedef struct { ...@@ -80,8 +80,7 @@ typedef struct {
int blocksize; ///< Size of blocks to compare int blocksize; ///< Size of blocks to compare
int contrast; ///< Contrast threshold int contrast; ///< Contrast threshold
int search; ///< Motion search method int search; ///< Motion search method
AVCodecContext *avctx; av_pixelutils_sad_fn sad; ///< Sum of the absolute difference function
DSPContext c; ///< Context providing optimized SAD methods
Transform last; ///< Transform from last frame Transform last; ///< Transform from last frame
int refcount; ///< Number of reference frames (defines averaging window) int refcount; ///< Number of reference frames (defines averaging window)
FILE *fp; FILE *fp;
......
...@@ -57,7 +57,6 @@ ...@@ -57,7 +57,6 @@
#include "libavutil/mem.h" #include "libavutil/mem.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "libavutil/pixdesc.h" #include "libavutil/pixdesc.h"
#include "libavcodec/dsputil.h"
#include "deshake.h" #include "deshake.h"
#include "deshake_opencl.h" #include "deshake_opencl.h"
...@@ -132,9 +131,8 @@ static void find_block_motion(DeshakeContext *deshake, uint8_t *src1, ...@@ -132,9 +131,8 @@ static void find_block_motion(DeshakeContext *deshake, uint8_t *src1,
int smallest = INT_MAX; int smallest = INT_MAX;
int tmp, tmp2; int tmp, tmp2;
#define CMP(i, j) deshake->c.sad[0](NULL, src1 + cy * stride + cx, \ #define CMP(i, j) deshake->sad(src1 + cy * stride + cx, stride,\
src2 + (j) * stride + (i), stride, \ src2 + (j) * stride + (i), stride)
deshake->blocksize)
if (deshake->search == EXHAUSTIVE) { if (deshake->search == EXHAUSTIVE) {
// Compare every possible position - this is sloooow! // Compare every possible position - this is sloooow!
...@@ -201,7 +199,7 @@ static int block_contrast(uint8_t *src, int x, int y, int stride, int blocksize) ...@@ -201,7 +199,7 @@ static int block_contrast(uint8_t *src, int x, int y, int stride, int blocksize)
int i, j, pos; int i, j, pos;
for (i = 0; i <= blocksize * 2; i++) { for (i = 0; i <= blocksize * 2; i++) {
// We use a width of 16 here to match the libavcodec sad functions // We use a width of 16 here to match the sad function
for (j = 0; j <= 15; j++) { for (j = 0; j <= 15; j++) {
pos = (y - i) * stride + (x - j); pos = (y - i) * stride + (x - j);
if (src[pos] < lowest) if (src[pos] < lowest)
...@@ -263,7 +261,7 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2, ...@@ -263,7 +261,7 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
pos = 0; pos = 0;
// Find motion for every block and store the motion vector in the counts // Find motion for every block and store the motion vector in the counts
for (y = deshake->ry; y < height - deshake->ry - (deshake->blocksize * 2); y += deshake->blocksize * 2) { for (y = deshake->ry; y < height - deshake->ry - (deshake->blocksize * 2); y += deshake->blocksize * 2) {
// We use a width of 16 here to match the libavcodec sad functions // We use a width of 16 here to match the sad function
for (x = deshake->rx; x < width - deshake->rx - 16; x += 16) { for (x = deshake->rx; x < width - deshake->rx - 16; x += 16) {
// If the contrast is too low, just skip this block as it probably // If the contrast is too low, just skip this block as it probably
// won't be very useful to us. // won't be very useful to us.
...@@ -351,6 +349,10 @@ static av_cold int init(AVFilterContext *ctx) ...@@ -351,6 +349,10 @@ static av_cold int init(AVFilterContext *ctx)
int ret; int ret;
DeshakeContext *deshake = ctx->priv; DeshakeContext *deshake = ctx->priv;
deshake->sad = av_pixelutils_get_sad_fn(4, 4, 1, deshake); // 16x16, 2nd source unaligned
if (!deshake->sad)
return AVERROR(EINVAL);
deshake->refcount = 20; // XXX: add to options? deshake->refcount = 20; // XXX: add to options?
deshake->blocksize /= 2; deshake->blocksize /= 2;
deshake->blocksize = av_clip(deshake->blocksize, 4, 128); deshake->blocksize = av_clip(deshake->blocksize, 4, 128);
...@@ -413,9 +415,6 @@ static int config_props(AVFilterLink *link) ...@@ -413,9 +415,6 @@ static int config_props(AVFilterLink *link)
deshake->last.angle = 0; deshake->last.angle = 0;
deshake->last.zoom = 0; deshake->last.zoom = 0;
deshake->avctx = avcodec_alloc_context3(NULL);
avpriv_dsputil_init(&deshake->c, deshake->avctx);
return 0; return 0;
} }
...@@ -428,9 +427,6 @@ static av_cold void uninit(AVFilterContext *ctx) ...@@ -428,9 +427,6 @@ static av_cold void uninit(AVFilterContext *ctx)
av_frame_free(&deshake->ref); av_frame_free(&deshake->ref);
if (deshake->fp) if (deshake->fp)
fclose(deshake->fp); fclose(deshake->fp);
if (deshake->avctx)
avcodec_close(deshake->avctx);
av_freep(&deshake->avctx);
} }
static int filter_frame(AVFilterLink *link, AVFrame *in) static int filter_frame(AVFilterLink *link, AVFrame *in)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment