static int init(AVFilterContext *ctx, const char *args) { HQDN3DContext *hqdn3d = ctx->priv; double lum_spac, lum_tmp, chrom_spac, chrom_tmp; double param1, param2, param3, param4; lum_spac = PARAM1_DEFAULT; chrom_spac = PARAM2_DEFAULT; lum_tmp = PARAM3_DEFAULT; chrom_tmp = lum_tmp * chrom_spac / lum_spac; if (args) { switch (sscanf(args, "%lf:%lf:%lf:%lf", ¶m1, ¶m2, ¶m3, ¶m4)) { case 1: lum_spac = param1; chrom_spac = PARAM2_DEFAULT * param1 / PARAM1_DEFAULT; lum_tmp = PARAM3_DEFAULT * param1 / PARAM1_DEFAULT; chrom_tmp = lum_tmp * chrom_spac / lum_spac; break; case 2: lum_spac = param1; chrom_spac = param2; lum_tmp = PARAM3_DEFAULT * param1 / PARAM1_DEFAULT; chrom_tmp = lum_tmp * chrom_spac / lum_spac; break; case 3: lum_spac = param1; chrom_spac = param2; lum_tmp = param3; chrom_tmp = lum_tmp * chrom_spac / lum_spac; break; case 4: lum_spac = param1; chrom_spac = param2; lum_tmp = param3; chrom_tmp = param4; break; } } av_log(ctx, AV_LOG_VERBOSE, "ls:%lf cs:%lf lt:%lf ct:%lf\n", lum_spac, chrom_spac, lum_tmp, chrom_tmp); if (lum_spac < 0 || chrom_spac < 0 || isnan(chrom_tmp)) { av_log(ctx, AV_LOG_ERROR, "Invalid negative value for luma or chroma spatial strength, " "or resulting value for chroma temporal strength is nan.\n"); return AVERROR(EINVAL); } precalc_coefs(hqdn3d->coefs[0], lum_spac); precalc_coefs(hqdn3d->coefs[1], lum_tmp); precalc_coefs(hqdn3d->coefs[2], chrom_spac); precalc_coefs(hqdn3d->coefs[3], chrom_tmp); return 0; }
static int config_input(AVFilterLink *inlink) { HQDN3DContext *hqdn3d = inlink->dst->priv; int i; hqdn3d->hsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_w; hqdn3d->vsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_h; hqdn3d->depth = av_pix_fmt_descriptors[inlink->format].comp[0].depth_minus1+1; hqdn3d->line = av_malloc(inlink->w * sizeof(*hqdn3d->line)); if (!hqdn3d->line) return AVERROR(ENOMEM); for (i = 0; i < 4; i++) { hqdn3d->coefs[i] = precalc_coefs(hqdn3d->strength[i], hqdn3d->depth); if (!hqdn3d->coefs[i]) return AVERROR(ENOMEM); } #if HAVE_YASM hqdn3d->denoise_row[ 8] = ff_hqdn3d_row_8_x86; hqdn3d->denoise_row[ 9] = ff_hqdn3d_row_9_x86; hqdn3d->denoise_row[10] = ff_hqdn3d_row_10_x86; hqdn3d->denoise_row[16] = ff_hqdn3d_row_16_x86; #endif return 0; }
static int config_input(AVFilterLink *inlink) { HQDN3DContext *hqdn3d = inlink->dst->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); int i; hqdn3d->hsub = desc->log2_chroma_w; hqdn3d->vsub = desc->log2_chroma_h; hqdn3d->depth = desc->comp[0].depth_minus1+1; hqdn3d->line = av_malloc(inlink->w * sizeof(*hqdn3d->line)); if (!hqdn3d->line) return AVERROR(ENOMEM); for (i = 0; i < 4; i++) { hqdn3d->coefs[i] = precalc_coefs(hqdn3d->strength[i], hqdn3d->depth); if (!hqdn3d->coefs[i]) return AVERROR(ENOMEM); } if (ARCH_X86) ff_hqdn3d_init_x86(hqdn3d); return 0; }
static int config_input(AVFilterLink *inlink) { HQDN3DContext *s = inlink->dst->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); int i; uninit(inlink->dst); s->hsub = desc->log2_chroma_w; s->vsub = desc->log2_chroma_h; s->depth = desc->comp[0].depth; s->line = av_malloc_array(inlink->w, sizeof(*s->line)); if (!s->line) return AVERROR(ENOMEM); for (i = 0; i < 4; i++) { s->coefs[i] = precalc_coefs(s->strength[i], s->depth); if (!s->coefs[i]) return AVERROR(ENOMEM); } if (ARCH_X86) ff_hqdn3d_init_x86(s); return 0; }