mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-23 11:39:49 +00:00
Merge commit '8c747d46f721cffa8ea51990805ad1d3a3a4fd0a'
* commit '8c747d46f721cffa8ea51990805ad1d3a3a4fd0a': vf_hqdn3d: switch to an AVOptions-based system. Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
f780a90355
@ -3620,7 +3620,6 @@ image noise producing smooth images and making still images really
|
||||
still. It should enhance compressibility.
|
||||
|
||||
It accepts the following optional parameters:
|
||||
@var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
|
||||
|
||||
@table @option
|
||||
@item luma_spatial
|
||||
|
@ -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") ||
|
||||
|
@ -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",
|
||||
¶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;
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user