66 #define OFFSET(x) offsetof(VagueDenoiserContext, x) 
   67 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM 
   85     0.037828455506995f, -0.023849465019380f, -0.110624404418423f, 0.377402855612654f,
 
   86     0.852698679009403f, 0.377402855612654f, -0.110624404418423f, -0.023849465019380f, 0.037828455506995f
 
   90     -0.064538882628938f, 0.040689417609558f, 0.418092273222212f, -0.788485616405664f,
 
   91     0.418092273222212f, 0.040689417609558f, -0.064538882628938f
 
   95     -0.064538882628938f, -0.040689417609558f, 0.418092273222212f, 0.788485616405664f,
 
   96     0.418092273222212f, -0.040689417609558f, -0.064538882628938f
 
  100     -0.037828455506995f, -0.023849465019380f, 0.110624404418423f, 0.377402855612654f,
 
  101     -0.852698679009403f, 0.377402855612654f, 0.110624404418423f, -0.023849465019380f, -0.037828455506995f
 
  136     int p, i, nsteps_width, nsteps_height, nsteps_max;
 
  161     for (nsteps_max = 1; nsteps_max < 15; nsteps_max++) {
 
  162         if (pow(2, nsteps_max) >= nsteps_width || pow(2, nsteps_max) >= nsteps_height)
 
  168     for (p = 0; p < 4; p++) {
 
  174         for (i = 1; i < s->
nsteps; i++) {
 
  185 static inline void copy(
const float *p1, 
float *p2, 
const int length)
 
  187     memcpy(p2, p1, length * 
sizeof(
float));
 
  190 static inline void copyv(
const float *p1, 
const int stride1, 
float *p2, 
const int length)
 
  194     for (i = 0; i < 
length; i++) {
 
  200 static inline void copyh(
const float *p1, 
float *p2, 
const int stride2, 
const int length)
 
  204     for (i = 0; i < 
length; i++) {
 
  220     const int originalLast = last;
 
  224         output[--first] = output[
NPAD];
 
  226         output[++last] = output[originalLast];
 
  230     for (i = 0; i < nextend; i++)
 
  231         output[--first] = output[
NPAD + 1 + i];
 
  236     nextend = idx - last;
 
  237     for (i = 0; i < nextend; i++)
 
  238         output[++last] = output[originalLast - 1 - i];
 
  247     for (i = 
NPAD; i < 
NPAD + low_size; i++) {
 
  249         const float b = input[2 * i - 13] * analysis_low[1];
 
  250         const float c = input[2 * i - 12] * analysis_low[2];
 
  251         const float d = input[2 * i - 11] * analysis_low[3];
 
  252         const float e = input[2 * i - 10] * analysis_low[4];
 
  253         const float f = input[2 * i -  9] * analysis_low[3];
 
  254         const float g = input[2 * i -  8] * analysis_low[2];
 
  255         const float h = input[2 * i -  7] * analysis_low[1];
 
  256         const float k = input[2 * i -  6] * analysis_low[0];
 
  258         output[i] = a + b + c + d + e + f + g + h + k;
 
  261     for (i = 
NPAD; i < 
NPAD + low_size; i++) {
 
  263         const float b = input[2 * i - 11] * analysis_high[1];
 
  264         const float c = input[2 * i - 10] * analysis_high[2];
 
  265         const float d = input[2 * i -  9] * analysis_high[3];
 
  266         const float e = input[2 * i -  8] * analysis_high[2];
 
  267         const float f = input[2 * i -  7] * analysis_high[1];
 
  268         const float g = input[2 * i -  6] * analysis_high[0];
 
  270         output[i + low_size] = a + b + c + d + e + f + 
g;
 
  276     const int low_size = (size + 1) >> 1;
 
  277     const int high_size = size >> 1;
 
  278     int left_ext = 1, right_ext, i;
 
  281     memcpy(temp + 
NPAD, input + 
NPAD, low_size * 
sizeof(
float));
 
  283     right_ext = (size % 2 == 0) ? 2 : 1;
 
  286     memset(output, 0, (
NPAD + 
NPAD + size) * 
sizeof(
float));
 
  287     findex = (size + 2) >> 1;
 
  289     for (i = 9; i < findex + 11; i++) {
 
  291         const float b = temp[i] * synthesis_low[1];
 
  292         const float c = temp[i] * synthesis_low[2];
 
  293         const float d = temp[i] * synthesis_low[3];
 
  295         output[2 * i - 13] += 
a;
 
  296         output[2 * i - 12] += 
b;
 
  297         output[2 * i - 11] += 
c;
 
  298         output[2 * i - 10] += d;
 
  299         output[2 * i -  9] += 
c;
 
  300         output[2 * i -  8] += 
b;
 
  301         output[2 * i -  7] += 
a;
 
  304     memcpy(temp + 
NPAD, input + 
NPAD + low_size, high_size * 
sizeof(
float));
 
  307     right_ext = (size % 2 == 0) ? 1 : 2;
 
  310     for (i = 8; i < findex + 11; i++) {
 
  312         const float b = temp[i] * synthesis_high[1];
 
  313         const float c = temp[i] * synthesis_high[2];
 
  314         const float d = temp[i] * synthesis_high[3];
 
  315         const float e = temp[i] * synthesis_high[4];
 
  317         output[2 * i - 13] += 
a;
 
  318         output[2 * i - 12] += 
b;
 
  319         output[2 * i - 11] += 
c;
 
  320         output[2 * i - 10] += d;
 
  321         output[2 * i -  9] += e;
 
  322         output[2 * i -  8] += d;
 
  323         output[2 * i -  7] += 
c;
 
  324         output[2 * i -  6] += 
b;
 
  325         output[2 * i -  5] += 
a;
 
  330                               const int stride, 
const float threshold,
 
  331                               const float percent, 
const int unused)
 
  333     const float frac = 1.f - percent * 0.01f;
 
  336     for (y = 0; y < 
height; y++) {
 
  337         for (x = 0; x < 
width; x++) {
 
  338             if (
FFABS(block[x]) <= threshold)
 
  346                               const float threshold, 
const float percent, 
const int nsteps)
 
  348     const float frac = 1.f - percent * 0.01f;
 
  349     const float shift = threshold * 0.01f * percent;
 
  354     for (l = 0; l < nsteps; l++) {
 
  359     for (y = 0; y < 
height; y++) {
 
  360         const int x0 = (y < 
h) ? w : 0;
 
  361         for (x = x0; x < 
width; x++) {
 
  363             if (temp <= threshold)
 
  366                 block[x] = (block[x] < 0.f ? -1.f : (block[x] > 0.f ? 1.f : 0.f)) * (temp - 
shift);
 
  373                               const int stride, 
const float threshold,
 
  374                               const float percent, 
const int unused)
 
  376     const float percent01 = percent * 0.01f;
 
  377     const float tr2 = threshold * threshold * percent01;
 
  378     const float frac = 1.f - percent01;
 
  381     for (y = 0; y < 
height; y++) {
 
  382         for (x = 0; x < 
width; x++) {
 
  384             if (temp <= threshold) {
 
  387                 const float tp2 = temp * 
temp;
 
  388                 block[x] *= (tp2 - tr2) / tp2;
 
  403         const uint16_t *srcp16 = (
const uint16_t *)in->
data[p];
 
  405         uint16_t *dstp16 = (uint16_t *)out->
data[p];
 
  406         float *output = s->
block;
 
  407         int h_low_size0 = 
width;
 
  409         int nsteps_transform = s->
nsteps;
 
  410         int nsteps_invert = s->
nsteps;
 
  411         const float *input = s->
block;
 
  413         if (!((1 << p) & s->
planes)) {
 
  420             for (y = 0; y < 
height; y++) {
 
  421                 for (x = 0; x < 
width; x++)
 
  422                     output[x] = srcp8[x];
 
  427             for (y = 0; y < 
height; y++) {
 
  428                 for (x = 0; x < 
width; x++)
 
  429                     output[x] = srcp16[x];
 
  435         while (nsteps_transform--) {
 
  436             int low_size = (h_low_size0 + 1) >> 1;
 
  437             float *input = s->
block;
 
  438             for (j = 0; j < v_low_size0; j++) {
 
  445             low_size = (v_low_size0 + 1) >> 1;
 
  447             for (j = 0; j < h_low_size0; j++) {
 
  454             h_low_size0 = (h_low_size0 + 1) >> 1;
 
  455             v_low_size0 = (v_low_size0 + 1) >> 1;
 
  460         while (nsteps_invert--) {
 
  463             float * idx3 = s->
block;
 
  464             for (i = 0; i < idx2; i++) {
 
  472             for (i = 0; i < idx; i++) {
 
  481             for (y = 0; y < 
height; y++) {
 
  482                 for (x = 0; x < 
width; x++)
 
  483                     dstp8[x] = av_clip_uint8(input[x] + 0.5f);
 
  488             for (y = 0; y < 
height; y++) {
 
  489                 for (x = 0; x < 
width; x++)
 
  490                     dstp16[x] = av_clip(input[x] + 0.5f, 0, s->
peak);
 
  575     .
name          = 
"vaguedenoiser",
 
  578     .priv_class    = &vaguedenoiser_class,
 
  582     .
inputs        = vaguedenoiser_inputs,
 
  583     .
outputs       = vaguedenoiser_outputs,
 
static av_cold int init(AVFilterContext *ctx)
 
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
static int shift(int a, int b)
 
#define AV_PIX_FMT_YUV440P10
 
static void qian_thresholding(float *block, const int width, const int height, const int stride, const float threshold, const float percent, const int unused)
 
static void copy(const float *p1, float *p2, const int length)
 
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
 
This structure describes decoded (raw) audio or video data. 
 
#define AV_PIX_FMT_YUV444P14
 
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) 
 
Main libavfilter public API header. 
 
int h
agreed upon image height 
 
static void hard_thresholding(float *block, const int width, const int height, const int stride, const float threshold, const float percent, const int unused)
 
#define AV_PIX_FMT_GBRP10
 
#define AV_PIX_FMT_YUV420P12
 
AVFilter ff_vf_vaguedenoiser
 
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions. 
 
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width. 
 
Macro definitions for various function/variable attributes. 
 
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
 
const char * name
Pad name. 
 
AVFILTER_DEFINE_CLASS(vaguedenoiser)
 
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter. 
 
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed. 
 
static void copyv(const float *p1, const int stride1, float *p2, const int length)
 
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
 
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
 
#define AV_PIX_FMT_YUV444P16
 
#define AV_PIX_FMT_YUV422P12
 
A filter pad used for either input or output. 
 
static const float synthesis_low[7]
 
A link between two filters. 
 
static void symmetric_extension(float *output, const int size, const int left_ext, const int right_ext)
 
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height. 
 
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g. 
 
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
 
void * priv
private data for use by the filter 
 
#define AV_PIX_FMT_YUV444P10
 
static void invert_step(const float *input, float *output, float *temp, const int size, VagueDenoiserContext *s)
 
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) 
 
static const AVOption vaguedenoiser_options[]
 
int w
agreed upon image width 
 
#define AV_PIX_FMT_YUV422P9
 
uint8_t nb_components
The number of components each pixel has, (1-4) 
 
#define AV_PIX_FMT_GBRP16
 
#define AV_PIX_FMT_GRAY16
 
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
 
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
 
static const AVFilterPad vaguedenoiser_outputs[]
 
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
 
static const AVFilterPad inputs[]
 
static const AVFilterPad vaguedenoiser_inputs[]
 
#define AV_PIX_FMT_YUV444P9
 
#define AV_PIX_FMT_GBRP14
 
static const AVFilterPad outputs[]
 
int format
agreed upon media format 
 
static int query_formats(AVFilterContext *ctx)
 
#define AV_PIX_FMT_YUV420P16
 
static void transform_step(float *input, float *output, const int size, const int low_size, VagueDenoiserContext *s)
 
#define AV_PIX_FMT_YUV420P14
 
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable. 
 
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line. 
 
void(* thresholding)(float *block, const int width, const int height, const int stride, const float threshold, const float percent, const int nsteps)
 
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
 
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
 
#define AV_PIX_FMT_YUV420P10
 
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) 
 
Describe the class of an AVClass context structure. 
 
const char * name
Filter name. 
 
#define AV_PIX_FMT_YUV440P12
 
#define AV_PIX_FMT_YUV420P9
 
AVFilterLink ** outputs
array of pointers to output links 
 
static enum AVPixelFormat pix_fmts[]
 
#define AV_PIX_FMT_YUV422P14
 
#define AV_PIX_FMT_GBRP12
 
#define AV_PIX_FMT_YUV422P10
 
static av_cold void uninit(AVFilterContext *ctx)
 
#define AV_PIX_FMT_YUV444P12
 
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes. 
 
GLint GLenum GLboolean GLsizei stride
 
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) 
 
common internal and external API header 
 
static const float synthesis_high[9]
 
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
 
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) 
 
static const struct @272 planes[]
 
static int config_input(AVFilterLink *inlink)
 
static void filter(VagueDenoiserContext *s, AVFrame *in, AVFrame *out)
 
AVFilterContext * dst
dest filter 
 
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
 
static const float analysis_high[7]
 
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) 
 
#define av_malloc_array(a, b)
 
static void soft_thresholding(float *block, const int width, const int height, const int stride, const float threshold, const float percent, const int nsteps)
 
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst. 
 
int depth
Number of bits in the component. 
 
static void copyh(const float *p1, float *p2, const int stride2, const int length)
 
AVPixelFormat
Pixel format. 
 
#define AV_PIX_FMT_YUV422P16
 
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst. 
 
static const float analysis_low[9]
 
#define AV_CEIL_RSHIFT(a, b)