static av_cold int init(AVFilterContext *ctx) { int ret; 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->blocksize /= 2; deshake->blocksize = av_clip(deshake->blocksize, 4, 128); if (deshake->rx % 16) { av_log(ctx, AV_LOG_ERROR, "rx must be a multiple of 16\n"); return AVERROR_PATCHWELCOME; } if (deshake->filename) deshake->fp = fopen(deshake->filename, "w"); if (deshake->fp) 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); // Quadword align left edge of box for MMX code, adjust width if necessary // to keep right margin if (deshake->cx > 0) { deshake->cw += deshake->cx - (deshake->cx & ~15); deshake->cx &= ~15; } deshake->transform = deshake_transform_c; deshake->find_motion = deshake_findmotion_c; if (!CONFIG_OPENCL && deshake->opencl) { av_log(ctx, AV_LOG_ERROR, "OpenCL support was not enabled in this build, cannot be selected\n"); return AVERROR(EINVAL); } if (CONFIG_OPENCL && deshake->opencl) { deshake->transform = ff_opencl_transform; #ifdef OCL_FINDMOTION deshake->find_motion = ff_opencl_findmotion; #endif ret = ff_opencl_deshake_init(ctx); if (ret < 0) return ret; } 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", deshake->cx, deshake->cy, deshake->cw, deshake->ch, deshake->rx, deshake->ry, deshake->edge, deshake->blocksize * 2, deshake->contrast, deshake->search); return 0; }
static int config_input(AVFilterLink *inlink) { SelectContext *select = inlink->dst->priv; select->var_values[VAR_N] = 0.0; select->var_values[VAR_SELECTED_N] = 0.0; select->var_values[VAR_TB] = av_q2d(inlink->time_base); select->var_values[VAR_PREV_PTS] = NAN; select->var_values[VAR_PREV_SELECTED_PTS] = NAN; select->var_values[VAR_PREV_SELECTED_T] = NAN; select->var_values[VAR_PREV_T] = NAN; select->var_values[VAR_START_PTS] = NAN; select->var_values[VAR_START_T] = NAN; select->var_values[VAR_I] = AV_PICTURE_TYPE_I; select->var_values[VAR_P] = AV_PICTURE_TYPE_P; select->var_values[VAR_B] = AV_PICTURE_TYPE_B; select->var_values[VAR_SI] = AV_PICTURE_TYPE_SI; select->var_values[VAR_SP] = AV_PICTURE_TYPE_SP; select->var_values[VAR_BI] = AV_PICTURE_TYPE_BI; select->var_values[VAR_PICT_TYPE_I] = AV_PICTURE_TYPE_I; select->var_values[VAR_PICT_TYPE_P] = AV_PICTURE_TYPE_P; select->var_values[VAR_PICT_TYPE_B] = AV_PICTURE_TYPE_B; select->var_values[VAR_PICT_TYPE_SI] = AV_PICTURE_TYPE_SI; select->var_values[VAR_PICT_TYPE_SP] = AV_PICTURE_TYPE_SP; select->var_values[VAR_PICT_TYPE_BI] = AV_PICTURE_TYPE_BI; select->var_values[VAR_INTERLACE_TYPE_P] = INTERLACE_TYPE_P; select->var_values[VAR_INTERLACE_TYPE_T] = INTERLACE_TYPE_T; select->var_values[VAR_INTERLACE_TYPE_B] = INTERLACE_TYPE_B; select->var_values[VAR_PICT_TYPE] = NAN; select->var_values[VAR_INTERLACE_TYPE] = NAN; select->var_values[VAR_SCENE] = NAN; select->var_values[VAR_CONSUMED_SAMPLES_N] = NAN; select->var_values[VAR_SAMPLES_N] = NAN; select->var_values[VAR_SAMPLE_RATE] = inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN; if (select->do_scene_detect) { select->sad = av_pixelutils_get_sad_fn(3, 3, 2, select); // 8x8 both sources aligned if (!select->sad) return AVERROR(EINVAL); } return 0; }
static int run_single_test(const char *test, const uint8_t *block1, ptrdiff_t stride1, const uint8_t *block2, ptrdiff_t stride2, int align, int n) { int out, ref; av_pixelutils_sad_fn f_ref = sad_c[n - 1]; av_pixelutils_sad_fn f_out = av_pixelutils_get_sad_fn(n, n, align, NULL); switch (align) { case 0: block1++; block2++; break; case 1: block2++; break; case 2: break; } out = f_out(block1, stride1, block2, stride2); ref = f_ref(block1, stride1, block2, stride2); printf("[%s] [%c%c] SAD [%s] %dx%d=%d ref=%d\n", out == ref ? "OK" : "FAIL", align ? 'A' : 'U', align == 2 ? 'A' : 'U', test, 1<<n, 1<<n, out, ref); return out != ref; }