84static const char *
const var_names[] = {
"X",
"Y",
"W",
"H",
"N",
"WS",
"HS",
NULL };
89#define OFFSET(x) offsetof(FFTFILTContext, x)
90#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
107static inline double lum(
void *priv,
double x,
double y,
int plane)
110 return s->rdft_vdata_out[plane][(int)x *
s->rdft_vstride[plane] + (
int)y];
113static double weight_Y(
void *priv,
double x,
double y) {
return lum(priv, x, y,
Y); }
114static double weight_U(
void *priv,
double x,
double y) {
return lum(priv, x, y,
U); }
115static double weight_V(
void *priv,
double x,
double y) {
return lum(priv, x, y,
V); }
121 for (
i =
w;
i <
w + (w2-
w)/2;
i++)
122 dest[
i] = dest[2*
w -
i - 1];
125 dest[
i] = dest[w2 -
i];
133 for (
int plane = 0; plane <
s->nb_planes; plane++) {
134 const int w =
s->planewidth[plane];
135 const int h =
s->planeheight[plane];
141 float *hdata_in =
s->rdft_hdata_in[plane] +
i *
s->rdft_hstride[plane];
143 for (
int j = 0; j <
w; j++)
144 hdata_in[j] =
src[j];
146 copy_rev(
s->rdft_hdata_in[plane] +
i *
s->rdft_hstride[plane],
w,
s->rdft_hlen[plane]);
150 s->htx_fn(
s->hrdft[jobnr][plane],
151 s->rdft_hdata_out[plane] +
i *
s->rdft_hstride[plane],
152 s->rdft_hdata_in[plane] +
i *
s->rdft_hstride[plane],
164 for (
int plane = 0; plane <
s->nb_planes; plane++) {
165 const int w =
s->planewidth[plane];
166 const int h =
s->planeheight[plane];
171 const uint16_t *
src = (
const uint16_t *)(in->
data[plane] +
i * in->
linesize[plane]);
172 float *hdata_in =
s->rdft_hdata_in[plane] +
i *
s->rdft_hstride[plane];
174 for (
int j = 0; j <
w; j++)
175 hdata_in[j] =
src[j];
177 copy_rev(
s->rdft_hdata_in[plane] +
i *
s->rdft_hstride[plane],
w,
s->rdft_hlen[plane]);
181 s->htx_fn(
s->hrdft[jobnr][plane],
182 s->rdft_hdata_out[plane] +
i *
s->rdft_hstride[plane],
183 s->rdft_hdata_in[plane] +
i *
s->rdft_hstride[plane],
195 for (
int plane = 0; plane <
s->nb_planes; plane++) {
196 const int w =
s->planewidth[plane];
197 const int h =
s->planeheight[plane];
202 s->ihtx_fn(
s->ihrdft[jobnr][plane],
203 s->rdft_hdata_out[plane] +
i *
s->rdft_hstride[plane],
204 s->rdft_hdata_in[plane] +
i *
s->rdft_hstride[plane],
208 const float scale = 1.f / (
s->rdft_hlen[plane] *
s->rdft_vlen[plane]);
209 const float *
src =
s->rdft_hdata_out[plane] +
i *
s->rdft_hstride[plane];
210 uint8_t *
dst =
out->data[plane] +
i *
out->linesize[plane];
212 for (
int j = 0; j <
w; j++)
225 for (
int plane = 0; plane <
s->nb_planes; plane++) {
226 int max = (1 <<
s->depth) - 1;
227 const int w =
s->planewidth[plane];
228 const int h =
s->planeheight[plane];
233 s->ihtx_fn(
s->ihrdft[jobnr][plane],
234 s->rdft_hdata_out[plane] +
i *
s->rdft_hstride[plane],
235 s->rdft_hdata_in[plane] +
i *
s->rdft_hstride[plane],
239 const float scale = 1.f / (
s->rdft_hlen[plane] *
s->rdft_vlen[plane]);
240 const float *
src =
s->rdft_hdata_out[plane] +
i *
s->rdft_hstride[plane];
241 uint16_t *
dst = (uint16_t *)(
out->data[plane] +
i *
out->linesize[plane]);
243 for (
int j = 0; j <
w; j++)
256 if (!
s->dc[
U] && !
s->dc[
V]) {
260 if (!
s->dc[
U])
s->dc[
U] =
s->dc[
V];
261 if (!
s->dc[
V])
s->dc[
V] =
s->dc[
U];
264 if (!
s->weight_str[
U] && !
s->weight_str[
V]) {
272 for (plane = 0; plane < 3; plane++) {
274 const char *
const func2_names[] = {
"weight_Y",
"weight_U",
"weight_V",
NULL };
292 values[
VAR_W] =
s->planewidth[plane];
293 values[
VAR_H] =
s->planeheight[plane];
294 values[
VAR_WS] =
s->rdft_hlen[plane];
295 values[
VAR_HS] =
s->rdft_vlen[plane];
297 for (
i = 0;
i <
s->rdft_hlen[plane];
i++) {
299 for (j = 0; j <
s->rdft_vlen[plane]; j++) {
301 s->weight[plane][
i *
s->rdft_vlen[plane] + j] =
314 s->depth =
desc->comp[0].depth;
316 s->planewidth[0] =
s->planewidth[3] = inlink->
w;
318 s->planeheight[0] =
s->planeheight[3] = inlink->
h;
323 for (
i = 0;
i <
desc->nb_components;
i++) {
324 int w =
s->planewidth[
i];
325 int h =
s->planeheight[
i];
331 if (!(
s->rdft_hdata_in[
i] =
av_calloc(
h,
s->rdft_hstride[
i] *
sizeof(
float))))
334 if (!(
s->rdft_hdata_out[
i] =
av_calloc(
h,
s->rdft_hstride[
i] *
sizeof(
float))))
337 for (
int j = 0; j <
s->nb_threads; j++) {
338 float scale = 1.f, iscale = 1.f;
341 0, 1 <<
s->rdft_hbits[
i], &
scale, 0);
345 1, 1 <<
s->rdft_hbits[
i], &iscale, 0);
354 if (!(
s->rdft_vdata_in[
i] =
av_calloc(
s->rdft_hstride[
i],
s->rdft_vstride[
i] *
sizeof(
float))))
357 if (!(
s->rdft_vdata_out[
i] =
av_calloc(
s->rdft_hstride[
i],
s->rdft_vstride[
i] *
sizeof(
float))))
360 for (
int j = 0; j <
s->nb_threads; j++) {
361 float scale = 1.f, iscale = 1.f;
364 0, 1 <<
s->rdft_vbits[
i], &
scale, 0);
368 1, 1 <<
s->rdft_vbits[
i], &iscale, 0);
375 for (plane = 0; plane < 3; plane++) {
376 if(!(
s->weight[plane] =
av_calloc(
s->rdft_hlen[plane],
s->rdft_vlen[plane] *
sizeof(
double))))
397 for (
int plane = 0; plane <
s->nb_planes; plane++) {
398 const int height =
s->rdft_hlen[plane];
403 const double *
weight =
s->weight[plane] +
i *
s->rdft_vlen[plane];
404 float *vdata =
s->rdft_vdata_out[plane] +
i *
s->rdft_vstride[plane];
406 for (
int j = 0; j <
s->rdft_vlen[plane]; j++)
418 for (
int plane = 0; plane <
s->nb_planes; plane++) {
419 const int hlen =
s->rdft_hlen[plane];
420 const int vlen =
s->rdft_vlen[plane];
421 const int hstride =
s->rdft_hstride[plane];
422 const int vstride =
s->rdft_vstride[plane];
425 const int h =
s->planeheight[plane];
426 float *hdata =
s->rdft_hdata_out[plane];
427 float *vdata =
s->rdft_vdata_in[plane];
430 for (
int j = 0; j <
h; j++)
431 vdata[
i * vstride + j] = hdata[j * hstride +
i];
443 for (
int plane = 0; plane <
s->nb_planes; plane++) {
444 const int height =
s->rdft_hlen[plane];
449 s->vtx_fn(
s->vrdft[jobnr][plane],
450 s->rdft_vdata_out[plane] +
i *
s->rdft_vstride[plane],
451 s->rdft_vdata_in[plane] +
i *
s->rdft_vstride[plane],
462 for (
int plane = 0; plane <
s->nb_planes; plane++) {
463 const int height =
s->rdft_hlen[plane];
468 s->ivtx_fn(
s->ivrdft[jobnr][plane],
469 s->rdft_vdata_in[plane] +
i *
s->rdft_vstride[plane],
470 s->rdft_vdata_out[plane] +
i *
s->rdft_vstride[plane],
481 for (
int plane = 0; plane <
s->nb_planes; plane++) {
482 const int hlen =
s->rdft_hlen[plane];
483 const int hstride =
s->rdft_hstride[plane];
484 const int vstride =
s->rdft_vstride[plane];
487 const int h =
s->planeheight[plane];
488 float *hdata =
s->rdft_hdata_in[plane];
489 float *vdata =
s->rdft_vdata_in[plane];
492 for (
int j = 0; j <
h; j++)
493 hdata[j * hstride +
i] = vdata[
i * vstride + j];
515 FFMIN(
s->planeheight[1],
s->nb_threads));
518 FFMIN(
s->planeheight[1],
s->nb_threads));
521 FFMIN(
s->planeheight[1],
s->nb_threads));
523 for (
int plane = 0; plane <
s->nb_planes; plane++) {
529 FFMIN(
s->planeheight[1],
s->nb_threads));
531 for (
int plane = 0; plane <
s->nb_planes; plane++)
532 s->rdft_vdata_out[plane][0] +=
s->rdft_hlen[plane] *
s->rdft_vlen[plane] *
s->dc[plane] * (1 << (
s->depth - 8));
535 FFMIN(
s->planeheight[1],
s->nb_threads));
538 FFMIN(
s->planeheight[1],
s->nb_threads));
541 FFMIN(
s->planeheight[1],
s->nb_threads));
558 for (
int j = 0; j <
s->nb_threads; j++) {
597 .p.description =
NULL_IF_CONFIG_SMALL(
"Apply arbitrary expressions to pixels in frequency domain."),
598 .p.priv_class = &fftfilt_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double(*const func2[])(void *, double, double)
static const char *const func2_names[]
const FFFilter ff_vf_fftfilt
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
#define i(width, name, range_min, range_max)
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
simple arithmetic expression evaluator
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
#define FILTER_PIXFMTS_ARRAY(array)
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
static int initialize(AVFilterContext *ctx)
size_t av_cpu_max_align(void)
Get the maximum data alignment that may be required by FFmpeg.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
static const char *const var_names[]
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P14
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
const h264_weight_func weight
static int config_props(AVBitStreamFilterLink *link)
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int(* irdft_horizontal)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int planewidth[MAX_PLANES]
int planeheight[MAX_PLANES]
int rdft_vbits[MAX_PLANES]
char * weight_str[MAX_PLANES]
float * rdft_hdata_in[MAX_PLANES]
float * rdft_vdata_out[MAX_PLANES]
AVTXContext * ivrdft[MAX_THREADS][MAX_PLANES]
size_t rdft_hstride[MAX_PLANES]
size_t rdft_vstride[MAX_PLANES]
size_t rdft_hlen[MAX_PLANES]
AVTXContext * hrdft[MAX_THREADS][MAX_PLANES]
float * rdft_hdata_out[MAX_PLANES]
size_t rdft_vlen[MAX_PLANES]
float * rdft_vdata_in[MAX_PLANES]
double * weight[MAX_PLANES]
AVTXContext * vrdft[MAX_THREADS][MAX_PLANES]
AVExpr * weight_expr[MAX_PLANES]
AVTXContext * ihrdft[MAX_THREADS][MAX_PLANES]
int rdft_hbits[MAX_PLANES]
int(* rdft_horizontal)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Link properties exposed to filter code, but not external callers.
static AVFormatContext * ctx
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
@ AV_TX_FLOAT_RDFT
Real to complex and complex to real DFTs.
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
static enum AVPixelFormat pixel_fmts_fftfilt[]
static int irdft_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static void copy_rev(float *dest, int w, int w2)
static int rdft_horizontal8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int irdft_horizontal8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int irdft_horizontal16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static void do_eval(FFTFILTContext *s, AVFilterLink *inlink, int plane)
static av_cold int initialize(AVFilterContext *ctx)
static double weight_Y(void *priv, double x, double y)
static int copy_horizontal(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int rdft_horizontal16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const AVFilterPad fftfilt_inputs[]
static int multiply_data(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int copy_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static double weight_U(void *priv, double x, double y)
static int rdft_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static double weight_V(void *priv, double x, double y)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int config_props(AVFilterLink *inlink)
static const AVOption fftfilt_options[]
static av_cold void uninit(AVFilterContext *ctx)
static double lum(void *priv, double x, double y, int plane)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)