Go to the documentation of this file.
46 #define MAX_NB_THREADS 32
122 const uint8_t *
src,
int src_stride,
125 int plane,
int nb_jobs);
127 const uint8_t *
src,
int src_linesize,
128 const uint8_t *
ref,
int ref_linesize,
129 int y,
int x,
int plane,
int jobnr);
132 #define OFFSET(x) offsetof(BM3DContext, x)
133 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
136 {
"sigma",
"set denoising strength",
138 {
"block",
"set size of local patch",
140 {
"bstep",
"set sliding step for processing blocks",
142 {
"group",
"set maximal number of similar blocks",
144 {
"range",
"set block matching range",
146 {
"mstep",
"set step for block matching",
148 {
"thmse",
"set threshold of mean square error for block matching",
150 {
"hdthr",
"set hard threshold for 3D transfer domain",
152 {
"estim",
"set filtering estimation mode",
154 {
"basic",
"basic estimate",
156 {
"final",
"final estimate",
158 {
"ref",
"have reference stream",
160 {
"planes",
"set planes to filter",
197 search_range = search_range / search_step * search_step;
199 if (
pos == plane_boundary) {
201 }
else if (
pos > plane_boundary) {
218 static int search_boundary(
int plane_boundary,
int search_range,
int search_step,
int vertical,
int y,
int x)
220 return do_search_boundary(vertical ? y : x, plane_boundary, search_range, search_step);
232 const uint8_t *srcp =
src +
pos->y * src_stride +
pos->x;
233 const uint8_t *refp =
src + r_y * src_stride + r_x;
234 const int block_size =
s->block_size;
238 for (
y = 0;
y < block_size;
y++) {
239 for (
x = 0;
x < block_size;
x++) {
240 double temp = refp[
x] - srcp[
x];
253 const uint16_t *srcp = (uint16_t *)
src +
pos->y * src_stride / 2 +
pos->x;
254 const uint16_t *refp = (uint16_t *)
src + r_y * src_stride / 2 + r_x;
255 const int block_size =
s->block_size;
259 for (
y = 0;
y < block_size;
y++) {
260 for (
x = 0;
x < block_size;
x++) {
261 double temp = refp[
x] - srcp[
x];
265 srcp += src_stride / 2;
266 refp += src_stride / 2;
273 const PosCode *search_pos,
int search_size,
float th_mse,
274 int r_y,
int r_x,
int plane,
int jobnr)
277 double MSE2SSE =
s->group_size *
s->block_size *
s->block_size * src_range * src_range / (
s->max *
s->max);
278 double distMul = 1. / MSE2SSE;
279 double th_sse = th_mse * MSE2SSE;
282 for (
int i = 0;
i < search_size;
i++) {
286 dist =
s->do_block_ssd(
s, &
pos,
src, src_stride, r_y, r_x);
289 if (dist <= th_sse && dist != 0) {
290 const double score = dist * distMul;
296 if (
index >=
s->group_size)
297 index =
s->group_size - 1;
311 int exclude_cur_pos,
int plane,
int jobnr)
314 const int width =
s->planewidth[plane];
315 const int height =
s->planeheight[plane];
316 const int block_size =
s->block_size;
317 const int step =
s->bm_step;
318 const int range =
s->bm_range /
step *
step;
325 for (
int j = t; j <=
b; j +=
step) {
326 for (
int i = l;
i <=
r;
i +=
step) {
329 if (exclude_cur_pos > 0 && j ==
y &&
i ==
x) {
339 if (exclude_cur_pos == 1) {
351 int j,
int i,
int plane,
int jobnr)
355 if (
s->group_size == 1 ||
s->th_mse <= 0.f) {
368 int y,
int x,
int block_size,
float *dst)
370 const uint8_t *
src = srcp +
y * src_linesize +
x;
372 for (
int j = 0; j < block_size; j++)
377 int y,
int x,
int block_size,
float *dst)
379 const uint16_t *
src = (uint16_t *)srcp +
y * src_linesize / 2 +
x;
381 for (
int j = 0; j < block_size; j++)
386 const uint8_t *
ref,
int ref_linesize,
387 int y,
int x,
int plane,
int jobnr)
390 const int pblock_size =
s->pblock_size;
391 const int buffer_linesize =
s->pblock_size *
s->pblock_size;
393 const int block_size =
s->block_size;
394 const int width =
s->planewidth[plane];
395 const int pgroup_size =
s->pgroup_size;
396 const int group_size =
s->group_size;
403 float den_weight, num_weight;
406 for (
int k = 0; k < nb_match_blocks; k++) {
410 for (
int i = 0;
i < block_size;
i++) {
411 s->get_block_row(
src, src_linesize,
y +
i,
x, block_size, bufferh + pblock_size *
i);
412 sc->
tx_fn(sc->
dctf, buffert, bufferh + pblock_size *
i,
sizeof(
float));
413 for (
int j = 0; j < block_size; j++)
414 bufferv[j * pblock_size +
i] = buffert[j];
417 for (
int i = 0;
i < block_size;
i++) {
418 sc->
tx_fn(sc->
dctf, buffert, bufferv +
i * pblock_size,
sizeof(
float));
419 memcpy(
buffer + k * buffer_linesize +
i * pblock_size,
420 buffert, block_size *
sizeof(
float));
424 for (
int i = 0;
i < block_size;
i++) {
425 for (
int j = 0; j < block_size; j++) {
426 for (
int k = 0; k < nb_match_blocks; k++)
427 bufferz[k] =
buffer[buffer_linesize * k +
i * pblock_size + j];
429 sc->
tx_fn_g(sc->
gdctf, bufferz, bufferz,
sizeof(
float));
430 bufferz += pgroup_size;
434 threshold[0] =
s->hard_threshold *
s->sigma *
M_SQRT2 * 4.f * block_size * block_size * (1 << (
s->depth - 8)) / 255.f;
435 threshold[1] = threshold[0] *
sqrtf(2.
f);
436 threshold[2] = threshold[0] * 2.f;
437 threshold[3] = threshold[0] *
sqrtf(8.
f);
440 for (
int i = 0;
i < block_size;
i++) {
441 for (
int j = 0; j < block_size; j++) {
442 for (
int k = 0; k < nb_match_blocks; k++) {
443 const float thresh = threshold[(j == 0) + (
i == 0) + (k == 0)];
445 if (bufferz[k] > thresh || bufferz[k] < -thresh) {
451 bufferz += pgroup_size;
457 for (
int i = 0;
i < block_size;
i++) {
458 for (
int j = 0; j < block_size; j++) {
461 for (
int k = 0; k < nb_match_blocks; k++)
462 buffer[buffer_linesize * k +
i * pblock_size + j] = bufferz[k];
463 bufferz += pgroup_size;
467 den_weight = retained < 1 ? 1.f : 1.f / retained;
468 num_weight = den_weight;
471 for (
int k = 0; k < nb_match_blocks; k++) {
475 for (
int i = 0;
i < block_size;
i++) {
476 memcpy(bufferv +
i * pblock_size,
477 buffer + k * buffer_linesize +
i * pblock_size,
478 block_size *
sizeof(
float));
481 for (
int i = 0;
i < block_size;
i++) {
482 sc->
itx_fn(sc->
dcti, buffert, bufferv +
i * pblock_size,
sizeof(
float));
483 for (
int j = 0; j < block_size; j++)
484 bufferh[j * pblock_size +
i] = buffert[j];
487 for (
int i = 0;
i < block_size;
i++) {
488 sc->
itx_fn(sc->
dcti, buffert, bufferh + pblock_size *
i,
sizeof(
float));
489 for (
int j = 0; j < block_size; j++) {
490 num[j] += buffert[j] * num_weight;
491 den[j] += den_weight;
500 const uint8_t *
ref,
int ref_linesize,
501 int y,
int x,
int plane,
int jobnr)
504 const int pblock_size =
s->pblock_size;
505 const int buffer_linesize =
s->pblock_size *
s->pblock_size;
507 const int block_size =
s->block_size;
508 const int width =
s->planewidth[plane];
509 const int pgroup_size =
s->pgroup_size;
510 const int group_size =
s->group_size;
511 const float sigma_sqr =
s->sigma *
s->sigma;
520 float den_weight, num_weight;
523 for (
int k = 0; k < nb_match_blocks; k++) {
527 for (
int i = 0;
i < block_size;
i++) {
528 s->get_block_row(
src, src_linesize,
y +
i,
x, block_size, bufferh + pblock_size *
i);
529 s->get_block_row(
ref, ref_linesize,
y +
i,
x, block_size, rbufferh + pblock_size *
i);
530 sc->
tx_fn(sc->
dctf, bufferh + pblock_size *
i, bufferh + pblock_size *
i,
sizeof(
float));
531 sc->
tx_fn(sc->
dctf, rbufferh + pblock_size *
i, rbufferh + pblock_size *
i,
sizeof(
float));
534 for (
int i = 0;
i < block_size;
i++) {
535 for (
int j = 0; j < block_size; j++) {
536 bufferv[
i * pblock_size + j] = bufferh[j * pblock_size +
i];
537 rbufferv[
i * pblock_size + j] = rbufferh[j * pblock_size +
i];
539 sc->
tx_fn(sc->
dctf, bufferv +
i * pblock_size, bufferv +
i * pblock_size,
sizeof(
float));
540 sc->
tx_fn(sc->
dctf, rbufferv +
i * pblock_size, rbufferv +
i * pblock_size,
sizeof(
float));
543 for (
int i = 0;
i < block_size;
i++) {
544 memcpy(
buffer + k * buffer_linesize +
i * pblock_size,
545 bufferv +
i * pblock_size, block_size *
sizeof(
float));
546 memcpy(rbuffer + k * buffer_linesize +
i * pblock_size,
547 rbufferv +
i * pblock_size, block_size *
sizeof(
float));
551 for (
int i = 0;
i < block_size;
i++) {
552 for (
int j = 0; j < block_size; j++) {
553 for (
int k = 0; k < nb_match_blocks; k++) {
554 bufferz[k] =
buffer[buffer_linesize * k +
i * pblock_size + j];
555 rbufferz[k] = rbuffer[buffer_linesize * k +
i * pblock_size + j];
557 if (group_size > 1) {
558 sc->
tx_fn_g(sc->
gdctf, bufferz, bufferz,
sizeof(
float));
559 sc->
tx_fn_g(sc->
gdctf, rbufferz, rbufferz,
sizeof(
float));
561 bufferz += pgroup_size;
562 rbufferz += pgroup_size;
569 for (
int i = 0;
i < block_size;
i++) {
570 for (
int j = 0; j < block_size; j++) {
571 for (
int k = 0; k < nb_match_blocks; k++) {
572 const float ref_sqr = rbufferz[k] * rbufferz[k];
573 float wiener_coef = ref_sqr / (ref_sqr + sigma_sqr);
575 if (
isnan(wiener_coef))
577 bufferz[k] *= wiener_coef;
578 l2_wiener += wiener_coef * wiener_coef;
580 bufferz += pgroup_size;
581 rbufferz += pgroup_size;
587 for (
int i = 0;
i < block_size;
i++) {
588 for (
int j = 0; j < block_size; j++) {
591 for (
int k = 0; k < nb_match_blocks; k++) {
592 buffer[buffer_linesize * k +
i * pblock_size + j] = bufferz[k];
594 bufferz += pgroup_size;
598 l2_wiener =
FFMAX(l2_wiener, 1e-15
f);
599 den_weight = 1.f / l2_wiener;
600 num_weight = den_weight;
602 for (
int k = 0; k < nb_match_blocks; k++) {
606 for (
int i = 0;
i < block_size;
i++) {
607 memcpy(bufferv +
i * pblock_size,
608 buffer + k * buffer_linesize +
i * pblock_size,
609 block_size *
sizeof(
float));
612 for (
int i = 0;
i < block_size;
i++) {
613 sc->
itx_fn(sc->
dcti, bufferv + pblock_size *
i, bufferv + pblock_size *
i,
sizeof(
float));
614 for (
int j = 0; j < block_size; j++) {
615 bufferh[j * pblock_size +
i] = bufferv[
i * pblock_size + j];
619 for (
int i = 0;
i < block_size;
i++) {
620 sc->
itx_fn(sc->
dcti, bufferh + pblock_size *
i, bufferh + pblock_size *
i,
sizeof(
float));
621 for (
int j = 0; j < block_size; j++) {
622 num[j] += bufferh[
i * pblock_size + j] * num_weight;
623 den[j] += den_weight;
632 int plane,
int nb_jobs)
634 const int height =
s->planeheight[plane];
635 const int width =
s->planewidth[plane];
638 for (
int j = 0; j <
width; j++) {
639 uint8_t *dstp = dst +
i * dst_linesize;
643 for (
int k = 0; k < nb_jobs; k++) {
658 int plane,
int nb_jobs)
660 const int height =
s->planeheight[plane];
661 const int width =
s->planewidth[plane];
662 const int depth =
s->depth;
665 for (
int j = 0; j <
width; j++) {
666 uint16_t *dstp = (uint16_t *)dst +
i * dst_linesize / 2;
670 for (
int k = 0; k < nb_jobs; k++) {
688 const int block_step =
s->block_step;
690 const uint8_t *
src =
td->src;
691 const uint8_t *
ref =
td->ref;
692 const int src_linesize =
td->src_linesize;
693 const int ref_linesize =
td->ref_linesize;
694 const int plane =
td->plane;
695 const int width =
s->planewidth[plane];
696 const int height =
s->planeheight[plane];
697 const int block_pos_bottom =
FFMAX(0,
height -
s->block_size);
698 const int block_pos_right =
FFMAX(0,
width -
s->block_size);
699 const int slice_start = (((
height + block_step - 1) / block_step) * jobnr / nb_jobs) * block_step;
700 const int slice_end = (jobnr == nb_jobs - 1) ? block_pos_bottom + block_step :
701 (((
height + block_step - 1) / block_step) * (jobnr + 1) / nb_jobs) * block_step;
706 for (
int j = slice_start; j <
slice_end; j += block_step) {
707 if (j > block_pos_bottom) {
708 j = block_pos_bottom;
711 for (
int i = 0;
i < block_pos_right + block_step;
i += block_step) {
712 if (
i > block_pos_right) {
718 s->block_filtering(
s,
src, src_linesize,
719 ref, ref_linesize, j,
i, plane, jobnr);
737 for (p = 0; p <
s->nb_planes; p++) {
738 const int nb_jobs =
FFMAX(1,
FFMIN(
s->nb_threads,
s->planeheight[p] /
s->block_size));
741 if (!((1 << p) &
s->planes) ||
ctx->is_disabled) {
744 s->planewidth[p] * (1 + (
s->depth > 8)),
s->planeheight[p]);
750 td.ref =
ref->data[p];
751 td.ref_linesize =
ref->linesize[p];
755 s->do_output(
s, (*out)->data[p], (*out)->linesize[p], p, nb_jobs);
761 #define SQR(x) ((x) * (x))
771 s->depth =
desc->comp[0].depth;
772 s->max = (1 <<
s->depth) - 1;
774 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
776 s->planewidth[0] =
s->planewidth[3] =
inlink->w;
780 for (
int i = 0;
i <
s->nb_threads;
i++) {
782 float iscale = 0.5f /
s->block_size;
799 if (
s->group_size > 1) {
800 float iscale = 0.5f /
s->group_size;
907 if (
s->th_mse == 0.f)
908 s->th_mse = 400.f +
s->sigma * 80.f;
910 }
else if (
s->mode ==
FINAL) {
915 if (
s->th_mse == 0.f)
916 s->th_mse = 200.f +
s->sigma * 10.f;
923 if (
s->block_step >
s->block_size) {
925 s->block_step,
s->block_size);
926 s->block_step =
s->block_size;
929 if (
s->bm_step >
s->bm_range) {
931 s->bm_step,
s->bm_range);
932 s->bm_step =
s->bm_range;
944 pad.
name =
"reference";
969 "(size %dx%d) do not match the corresponding "
970 "second input link %s parameters (%dx%d) ",
972 ctx->input_pads[1].name,
ref->w,
ref->h);
1011 for (
int i = 0;
i <
s->nb_threads;
i++) {
1054 .priv_class = &bm3d_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_GBRAP16
AVRational time_base
Time base for the incoming frames.
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
#define AV_LOG_WARNING
Something somehow does not look correct.
SliceContext slices[MAX_NB_THREADS]
AVPixelFormat
Pixel format.
static const struct @346 planes[]
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
#define FILTER_PIXFMTS_ARRAY(array)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
double(* do_block_ssd)(struct BM3DContext *s, PosCode *pos, const uint8_t *src, int src_stride, int r_y, int r_x)
#define AV_PIX_FMT_YUVA422P9
This structure describes decoded (raw) audio or video data.
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
Clip a signed integer to an unsigned power of two range.
static const AVOption bm3d_options[]
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
static void block_matching(BM3DContext *s, const uint8_t *ref, int ref_linesize, int j, int i, int plane, int jobnr)
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
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...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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.
static double do_block_ssd(BM3DContext *s, PosCode *pos, const uint8_t *src, int src_stride, int r_y, int r_x)
AVFILTER_DEFINE_CLASS(bm3d)
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUVA420P9
@ EXT_STOP
Completely stop all streams with this one.
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_GBRP14
int ff_append_inpad(AVFilterContext *f, AVFilterPad *p)
Append a new input/output pad to the filter's list of such pads.
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUV422P9
static av_always_inline float scale(float x, float s)
#define AV_PIX_FMT_GRAY16
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events.
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
A filter pad used for either input or output.
#define FFDIFFSIGN(x, y)
Comparator.
#define AV_PIX_FMT_YUV444P10
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PIX_FMT_YUV422P16
PosPairCode match_blocks[256]
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
void(* do_output)(struct BM3DContext *s, uint8_t *dst, int dst_linesize, int plane, int nb_jobs)
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AV_PIX_FMT_GBRAP10
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
#define AV_PIX_FMT_GBRAP12
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static int search_boundary(int plane_boundary, int search_range, int search_step, int vertical, int y, int x)
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
static void final_block_filtering(BM3DContext *s, const uint8_t *src, int src_linesize, const uint8_t *ref, int ref_linesize, int y, int x, int plane, int jobnr)
#define AV_PIX_FMT_GRAY14
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GBRP16
Describe the class of an AVClass context structure.
static int process_frame(FFFrameSync *fs)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define fs(width, name, subs,...)
static void basic_block_filtering(BM3DContext *s, const uint8_t *src, int src_linesize, const uint8_t *ref, int ref_linesize, int y, int x, int plane, int jobnr)
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static void do_output(BM3DContext *s, uint8_t *dst, int dst_linesize, int plane, int nb_jobs)
#define AV_PIX_FMT_YUV440P10
static __device__ float sqrtf(float a)
size_t av_cpu_max_align(void)
Get the maximum data alignment that may be required by FFmpeg.
#define AV_PIX_FMT_YUV422P10
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
static av_cold void uninit(AVFilterContext *ctx)
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int(* config_props)(AVFilterLink *link)
Link configuration callback.
static int cmp_scores(const void *a, const void *b)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_YUV422P12
static const AVFilterPad bm3d_outputs[]
#define AV_PIX_FMT_YUV444P12
AVFilterContext * src
source filter
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUVA444P10
PosCode * search_positions
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
#define i(width, name, range_min, range_max)
void(* get_block_row)(const uint8_t *srcp, int src_linesize, int y, int x, int block_size, float *dst)
int w
agreed upon image width
#define AV_PIX_FMT_GBRP12
static void do_output16(BM3DContext *s, uint8_t *dst, int dst_linesize, int plane, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Used for passing data between threads.
static int do_search_boundary(int pos, int plane_boundary, int search_range, int search_step)
static int config_input(AVFilterLink *inlink)
static void block_matching_multi(BM3DContext *s, const uint8_t *ref, int ref_linesize, int y, int x, int exclude_cur_pos, int plane, int jobnr)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
const char * name
Pad name.
void * av_calloc(size_t nmemb, size_t size)
#define AV_PIX_FMT_YUV444P9
static int filter_frame(AVFilterContext *ctx, AVFrame **out, AVFrame *in, AVFrame *ref)
static void do_block_matching_multi(BM3DContext *s, const uint8_t *src, int src_stride, int src_range, const PosCode *search_pos, int search_size, float th_mse, int r_y, int r_x, int plane, int jobnr)
enum AVMediaType type
AVFilterPad type.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define AV_PIX_FMT_YUVA444P9
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
static av_cold int init(AVFilterContext *ctx)
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
int h
agreed upon image height
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
static void get_block_row(const uint8_t *srcp, int src_linesize, int y, int x, int block_size, float *dst)
#define AV_PIX_FMT_YUVA422P12
static int config_output(AVFilterLink *outlink)
static int ref[MAX_W *MAX_W]
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static double do_block_ssd16(BM3DContext *s, PosCode *pos, const uint8_t *src, int src_stride, int r_y, int r_x)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
@ AV_TX_FLOAT_DCT
Real to real (DCT) transforms.
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
#define AV_PIX_FMT_YUV440P12
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
#define AV_PIX_FMT_YUV444P14
void(* block_filtering)(struct BM3DContext *s, const uint8_t *src, int src_linesize, const uint8_t *ref, int ref_linesize, int y, int x, int plane, int jobnr)
static void get_block_row16(const uint8_t *srcp, int src_linesize, int y, int x, int block_size, float *dst)
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
#define AV_PIX_FMT_GRAY12
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
const AVFilter ff_vf_bm3d
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14
static int activate(AVFilterContext *ctx)