summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-04-10 21:13:27 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-04-10 21:14:30 +0200
commitf780a90355aa19256f37df9359a58140a9b4a6b3 (patch)
tree099d032ec50e0bfa8a86785da92d7315a35a81c3 /libavfilter
parent1ee9eacaa492a0f38ae426439516574f4bfae4d9 (diff)
parent8c747d46f721cffa8ea51990805ad1d3a3a4fd0a (diff)
downloadffmpeg-f780a90355aa19256f37df9359a58140a9b4a6b3.tar.gz
Merge commit '8c747d46f721cffa8ea51990805ad1d3a3a4fd0a'
* commit '8c747d46f721cffa8ea51990805ad1d3a3a4fd0a': vf_hqdn3d: switch to an AVOptions-based system. Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/avfilter.c1
-rw-r--r--libavfilter/vf_hqdn3d.c80
-rw-r--r--libavfilter/vf_hqdn3d.h8
3 files changed, 41 insertions, 48 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 5190ed7588..4f0afd5ca5 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -670,6 +670,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
!strcmp(filter->filter->name, "frei0r" ) ||
!strcmp(filter->filter->name, "frei0r_src") ||
!strcmp(filter->filter->name, "gradfun" ) ||
+ !strcmp(filter->filter->name, "hqdn3d" ) ||
!strcmp(filter->filter->name, "format") ||
!strcmp(filter->filter->name, "noformat") ||
!strcmp(filter->filter->name, "resample") ||
diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c
index 8169cc747e..f2117a8db7 100644
--- a/libavfilter/vf_hqdn3d.c
+++ b/libavfilter/vf_hqdn3d.c
@@ -26,10 +26,14 @@
* libmpcodecs/vf_hqdn3d.c.
*/
+#include <float.h>
+
#include "config.h"
#include "libavutil/common.h"
#include "libavutil/pixdesc.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
@@ -180,57 +184,19 @@ static int16_t *precalc_coefs(double dist25, int depth)
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",
- &param1, &param2, &param3, &param4)) {
- 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;
- }
- }
- hqdn3d->strength[0] = lum_spac;
- hqdn3d->strength[1] = lum_tmp;
- hqdn3d->strength[2] = chrom_spac;
- hqdn3d->strength[3] = chrom_tmp;
+ if (!hqdn3d->strength[LUMA_SPATIAL])
+ hqdn3d->strength[LUMA_SPATIAL] = PARAM1_DEFAULT;
+ if (!hqdn3d->strength[CHROMA_SPATIAL])
+ hqdn3d->strength[CHROMA_SPATIAL] = PARAM2_DEFAULT * hqdn3d->strength[LUMA_SPATIAL] / PARAM1_DEFAULT;
+ if (!hqdn3d->strength[LUMA_TMP])
+ hqdn3d->strength[LUMA_TMP] = PARAM3_DEFAULT * hqdn3d->strength[LUMA_SPATIAL] / PARAM1_DEFAULT;
+ if (!hqdn3d->strength[CHROMA_TMP])
+ hqdn3d->strength[CHROMA_TMP] = hqdn3d->strength[LUMA_TMP] * hqdn3d->strength[CHROMA_SPATIAL] / hqdn3d->strength[LUMA_SPATIAL];
av_log(ctx, AV_LOG_VERBOSE, "ls:%f cs:%f lt:%f ct:%f\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);
- }
+ hqdn3d->strength[LUMA_SPATIAL], hqdn3d->strength[CHROMA_SPATIAL],
+ hqdn3d->strength[LUMA_TMP], hqdn3d->strength[CHROMA_TMP]);
return 0;
}
@@ -342,6 +308,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return ff_filter_frame(outlink, out);
}
+#define OFFSET(x) offsetof(HQDN3DContext, x)
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
+static const AVOption options[] = {
+ { "luma_spatial", "spatial luma strength", OFFSET(strength[LUMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
+ { "chroma_spatial", "spatial chroma strength", OFFSET(strength[CHROMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
+ { "luma_tmp", "temporal luma strength", OFFSET(strength[LUMA_TMP]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
+ { "chroma_tmp", "temporal chroma strength", OFFSET(strength[CHROMA_TMP]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
+ { NULL },
+};
+
+static const AVClass hqdn3d_class = {
+ .class_name = "hqdn3d",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
static const AVFilterPad avfilter_vf_hqdn3d_inputs[] = {
{
.name = "default",
@@ -366,6 +349,7 @@ AVFilter avfilter_vf_hqdn3d = {
.description = NULL_IF_CONFIG_SMALL("Apply a High Quality 3D Denoiser."),
.priv_size = sizeof(HQDN3DContext),
+ .priv_class = &hqdn3d_class,
.init = init,
.uninit = uninit,
.query_formats = query_formats,
diff --git a/libavfilter/vf_hqdn3d.h b/libavfilter/vf_hqdn3d.h
index dfc69e140f..268ac9a259 100644
--- a/libavfilter/vf_hqdn3d.h
+++ b/libavfilter/vf_hqdn3d.h
@@ -26,7 +26,10 @@
#include <stddef.h>
#include <stdint.h>
+#include "libavutil/opt.h"
+
typedef struct {
+ const AVClass *class;
int16_t *coefs[4];
uint16_t *line;
uint16_t *frame_prev[3];
@@ -36,6 +39,11 @@ typedef struct {
void (*denoise_row[17])(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal);
} HQDN3DContext;
+#define LUMA_SPATIAL 0
+#define LUMA_TMP 1
+#define CHROMA_SPATIAL 2
+#define CHROMA_TMP 3
+
void ff_hqdn3d_init_x86(HQDN3DContext *hqdn3d);
#endif /* AVFILTER_VF_HQDN3D_H */