Go to the documentation of this file.
   37 static const uint8_t 
NNEDI_XDIM[] = { 8, 16, 32, 48, 8, 16, 32 };
 
   38 static const uint8_t 
NNEDI_YDIM[] = { 6, 6, 6, 6, 4, 4, 4 };
 
   39 static const uint16_t 
NNEDI_NNS[] = { 16, 32, 64, 128, 256 };
 
  106                  int src_stride, 
int dst_stride,
 
  109                   int src_stride, 
int dst_stride,
 
  112                          const void *
src, ptrdiff_t src_stride,
 
  117 #define OFFSET(x) offsetof(NNEDIContext, x) 
  118 #define RFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM 
  119 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 
  125         {
"interlaced", 
"only deinterlace frames marked as interlaced", 0, 
AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, 
RFLAGS, .unit = 
"deint" },
 
  127         {
"af", 
"use frame flags, both fields",  0, 
AV_OPT_TYPE_CONST, {.i64=-2}, 0, 0, 
RFLAGS, .unit = 
"field" },
 
  128         {
"a",  
"use frame flags, single field", 0, 
AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, 
RFLAGS, .unit = 
"field" },
 
  131         {
"tf", 
"use both fields, top first",    0, 
AV_OPT_TYPE_CONST, {.i64=2},  0, 0, 
RFLAGS, .unit = 
"field" },
 
  132         {
"bf", 
"use both fields, bottom first", 0, 
AV_OPT_TYPE_CONST, {.i64=3},  0, 0, 
RFLAGS, .unit = 
"field" },
 
  134     {
"nsize",  
"set size of local neighborhood around each pixel, used by the predictor neural network", 
OFFSET(nsize), 
AV_OPT_TYPE_INT, {.i64=6}, 0, 6, 
RFLAGS, .unit = 
"nsize" },
 
  142     {
"nns",    
"set number of neurons in predictor neural network", 
OFFSET(nnsparam), 
AV_OPT_TYPE_INT, {.i64=1}, 0, 4, 
RFLAGS, .unit = 
"nns" },
 
  151     {
"etype", 
"set which set of weights to use in the predictor", 
OFFSET(etype), 
AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
RFLAGS, .unit = 
"etype" },
 
  152         {
"a",  
"weights trained to minimize absolute error", 0, 
AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, 
RFLAGS, .unit = 
"etype" },
 
  153         {
"abs",
"weights trained to minimize absolute error", 0, 
AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, 
RFLAGS, .unit = 
"etype" },
 
  154         {
"s",  
"weights trained to minimize squared error",  0, 
AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, 
RFLAGS, .unit = 
"etype" },
 
  155         {
"mse",
"weights trained to minimize squared error",  0, 
AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, 
RFLAGS, .unit = 
"etype" },
 
  173     outlink->
w             = 
ctx->inputs[0]->w;
 
  174     outlink->
h             = 
ctx->inputs[0]->h;
 
  176     if (
s->field == -2 || 
s->field > 1) {
 
  216     sum = 
s->fdsp->scalarproduct_float(kernel, 
input, n);
 
  225     return x / (1.0f + 
fabsf(x));
 
  235                         const void *
src, ptrdiff_t src_stride,
 
  236                         uint8_t *prescreen, 
int N,
 
  240     const float *src_p = 
src;
 
  243     const float *
window = src_p - 2 * src_stride - 5;
 
  245     for (
int j = 0; j < 
N; j++) {
 
  249         for (
int i = 0; 
i < 4; 
i++)
 
  250             memcpy(
input + 
i * 12, 
window + 
i * src_stride + j, 12 * 
sizeof(
float));
 
  253         for (
int n = 0; n < 4; n++)
 
  258         for (
int n = 0; n < 4; n++)
 
  263         for (
int n = 0; n < 4; n++)
 
  271                         const void *
src, ptrdiff_t src_stride,
 
  272                         uint8_t *prescreen, 
int N,
 
  276     const float *src_p = 
src;
 
  279     const float *
window = src_p - 2 * src_stride - 6;
 
  281     for (
int j = 0; j < 
N; j += 4) {
 
  285         for (
int i = 0; 
i < 4; 
i++)
 
  286             memcpy(
input + 
i * 16, 
window + 
i * src_stride + j, 16 * 
sizeof(
float));
 
  288         for (
int n = 0; n < 4; n++)
 
  292         for (
int n = 0; n < 4; n++)
 
  295         for (
int n = 0; n < 4; n++)
 
  296             prescreen[j + n] = 
state[n + 4] > 0.
f;
 
  302     return nn * model->
nsize;
 
  330                          float *buf, 
float mstd[4],
 
  338     for (
int i = 0; 
i < model->
ydim; 
i++) {
 
  339         memcpy(buf, 
src, model->
xdim * 
sizeof(
float));
 
  341         for (
int j = 0; j < model->
xdim; j++) {
 
  352     mstd[0] = sum * 
scale;
 
  355     tmp = sum_sq * 
scale - mstd[0] * mstd[0];
 
  356     if (
tmp < FLT_EPSILON) {
 
  361         mstd[2] = 1.0f / mstd[1];
 
  376 static void wae5(
const float *softmax, 
const float *el,
 
  377                  int n, 
float mstd[4])
 
  379     float vsum = 0.0f, wsum = 0.0f;
 
  381     for (
int i = 0; 
i < n; 
i++) {
 
  387         mstd[3] += (5.0f * vsum) / wsum * mstd[1] + mstd[0];
 
  393                       const void *
src, ptrdiff_t src_stride, 
void *
dst,
 
  394                       const uint8_t *prescreen, 
int N,
 
  398     const float *src_p = 
src;
 
  402     const float *
window = src_p - (model->
ydim / 2) * src_stride - (model->
xdim / 2 - 1);
 
  403     const int filter_size = model->
nsize;
 
  404     const int nns = model->
nns;
 
  406     for (
int i = 0; 
i < 
N; 
i++) {
 
  408         float activation[256 * 2];
 
  418         for (
int nn = 0; nn < nns; nn++)
 
  421         for (
int nn = 0; nn < nns; nn++)
 
  425         wae5(activation, activation + nns, nns, mstd);
 
  428             for (
int nn = 0; nn < nns; nn++)
 
  431             for (
int nn = 0; nn < nns; nn++)
 
  435             wae5(activation, activation + nns, nns, mstd);
 
  438         dst_p[
i] = mstd[3] * (use_q2 ? 0.5f : 1.f);
 
  443                        int src_stride, 
int dst_stride,
 
  446     for (
int y = 0; y < 
height; y++) {
 
  447         for (
int x = 0; x < 32; x++)
 
  450         for (
int x = 0; x < 
width; x++)
 
  453         for (
int x = 0; x < 32; x++)
 
  462                        int src_stride, 
int dst_stride,
 
  465     const uint16_t *
src = (
const uint16_t *)srcp;
 
  469     for (
int y = 0; y < 
height; y++) {
 
  470         for (
int x = 0; x < 32; x++)
 
  473         for (
int x = 0; x < 
width; x++)
 
  476         for (
int x = 0; x < 32; x++)
 
  485                         int src_stride, 
int dst_stride,
 
  489     for (
int y = 0; y < 
height; y++) {
 
  490         for (
int x = 0; x < 
width; x++)
 
  499                         int src_stride, 
int dst_stride,
 
  503     uint16_t *
dst = (uint16_t *)dstp;
 
  507     for (
int y = 0; y < 
height; y++) {
 
  508         for (
int x = 0; x < 
width; x++)
 
  517                           void *
dst, 
const uint8_t *prescreen, 
int n)
 
  519     const float *src_p = 
src;
 
  521     const float *
window = src_p - 2 * src_stride;
 
  523     for (
int i = 0; 
i < n; 
i++) {
 
  529         accum += (-3.0f / 32.0f) * 
window[0 * src_stride + 
i];
 
  530         accum += (19.0f / 32.0f) * 
window[1 * src_stride + 
i];
 
  531         accum += (19.0f / 32.0f) * 
window[2 * src_stride + 
i];
 
  532         accum += (-3.0f / 32.0f) * 
window[3 * src_stride + 
i];
 
  543     const float in_scale = 
s->in_scale;
 
  544     const float out_scale = 
s->out_scale;
 
  545     const int depth = 
s->depth;
 
  551     for (
int p = 0; p < 
s->nb_planes; p++) {
 
  552         const int height = 
s->planeheight[p];
 
  553         const int width = 
s->planewidth[p];
 
  556         const uint8_t *src_data = in->
data[p];
 
  557         uint8_t *dst_data = 
out->data[p];
 
  559         const int src_linesize = in->
linesize[p];
 
  560         const int dst_linesize = 
out->linesize[p];
 
  561         uint8_t *prescreen_buf = 
s->prescreen_buf[jobnr];
 
  562         float *srcbuf = 
s->input_buf[jobnr];
 
  563         const int srcbuf_stride = 
width + 64;
 
  564         float *dstbuf = 
s->output_buf[jobnr];
 
  565         const int dstbuf_stride = 
width;
 
  568         const uint8_t *in_line;
 
  572         if (!(
s->process_plane & (1 << p))) {
 
  581         in_line  = src_data + (y_out * src_linesize);
 
  582         out_line = dst_data + (y_out * dst_linesize);
 
  585             memcpy(out_line, in_line, 
s->linesize[p]);
 
  587             in_line  += src_linesize * 2;
 
  588             out_line += dst_linesize * 2;
 
  593         s->read(src_data + 
FFMAX(y_out - 5, tff) * src_linesize,
 
  595                 src_linesize * 2, srcbuf_stride,
 
  597         srcbuf += srcbuf_stride;
 
  599         s->read(src_data + 
FFMAX(y_out - 3, tff) * src_linesize,
 
  601                 src_linesize * 2, srcbuf_stride,
 
  603         srcbuf += srcbuf_stride;
 
  605         s->read(src_data + 
FFMAX(y_out - 1, tff) * src_linesize,
 
  607                 src_linesize * 2, srcbuf_stride,
 
  609         srcbuf += srcbuf_stride;
 
  611         in_line  = src_data + 
FFMIN(y_out + 1, 
height - 1 - !tff) * src_linesize;
 
  612         out_line = dst_data + (y_out * dst_linesize);
 
  614         s->read(in_line, srcbuf + 32, src_linesize * 2, srcbuf_stride,
 
  615                 width, slice_height - last_slice, in_scale);
 
  617         y_out += (slice_height - last_slice) * 2;
 
  619         s->read(src_data + 
FFMIN(y_out + 1, 
height - 1 - !tff) * src_linesize,
 
  620                 srcbuf + 32 + srcbuf_stride * (slice_height - last_slice),
 
  621                 src_linesize * 2, srcbuf_stride,
 
  624         s->read(src_data + 
FFMIN(y_out + 3, 
height - 1 - !tff) * src_linesize,
 
  625                 srcbuf + 32 + srcbuf_stride * (slice_height + 1 - last_slice),
 
  626                 src_linesize * 2, srcbuf_stride,
 
  629         s->read(src_data + 
FFMIN(y_out + 5, 
height - 1 - !tff) * src_linesize,
 
  630                 srcbuf + 32 + srcbuf_stride * (slice_height + 2 - last_slice),
 
  631                 src_linesize * 2, srcbuf_stride,
 
  636                 s->prescreen[
s->pscrn > 1](
ctx, srcbuf + (y / 2) * srcbuf_stride + 32,
 
  637                              srcbuf_stride, prescreen_buf, 
width,
 
  638                              &
s->prescreener[
s->pscrn - 1]);
 
  641                       srcbuf + (y / 2) * srcbuf_stride + 32,
 
  643                       dstbuf + (y / 2) * dstbuf_stride,
 
  644                       prescreen_buf, 
width,
 
  645                       &
s->coeffs[
s->etype][
s->nnsparam][
s->nsize], 
s->qual == 2);
 
  650                               dstbuf + (y / 2) * dstbuf_stride,
 
  651                               prescreen_buf, 
width);
 
  654         s->write(dstbuf, out_line, dstbuf_stride, dst_linesize * 2,
 
  655                  width, slice_height, depth, out_scale);
 
  675                       FFMIN(
s->planeheight[1] / 2, 
s->nb_threads));
 
  677     if (
s->field == -2 || 
s->field > 1)
 
  678         s->field_n = !
s->field_n;
 
  701     s->pts = 
s->prev->pts * 2;
 
  703     if (
ret < 0 || (
s->field > -2 && 
s->field < 2)) {
 
  709     s->pts = 
s->prev->pts + in->
pts;
 
  735                                                 ctx->outputs[0]->time_base);
 
  739     } 
else if (
ret < 0) {
 
  748     memcpy(
dst, *
data, n * 
sizeof(
float));
 
  763     int filter_size = nns * xdim * ydim;
 
  767     data = 
av_calloc(filter_size + bias_size, 4 * 
sizeof(
float));
 
  774     coeffs->
nsize = xdim * ydim;
 
  795     copy_weights(&
s->prescreener[0].kernel_l0[0][0], 4 * 48, &bdata);
 
  798     copy_weights(&
s->prescreener[0].kernel_l1[0][0], 4 * 4, &bdata);
 
  801     copy_weights(&
s->prescreener[0].kernel_l2[0][0], 4 * 8, &bdata);
 
  804     for (
int i = 0; 
i < 3; 
i++) {
 
  806         float kernel_l0_shuffled[4 * 64];
 
  807         float kernel_l1_shuffled[4 * 4];
 
  815         for (
int n = 0; n < 4; n++) {
 
  816             for (
int k = 0; k < 64; k++)
 
  817                 data->kernel_l0[n][k] = kernel_l0_shuffled[(k / 8) * 32 + n * 8 + k % 8];
 
  818             for (
int k = 0; k < 4; k++)
 
  819                 data->kernel_l1[n][k] = kernel_l1_shuffled[k * 4 + n];
 
  823     for (
int m = 0; m < 2; m++) {
 
  825         for (
int i = 0; 
i < 5; 
i++) {
 
  829             for (
int j = 0; j < 7; j++) {
 
  833                 const int filter_size = xdim * ydim;
 
  879     for (
int n = 0; n < 4; n++) {
 
  888     for (
int n = 0; n < 4; n++) {
 
  897     const int filter_size = model->
nsize;
 
  898     const int nns = model->
nns;
 
  899     const float scale = 1.f / nns;
 
  901     double softmax_means[256]; 
 
  902     double elliott_means[256]; 
 
  903     double mean_filter[48 * 6] = { 0 }; 
 
  907     for (
int nn = 0; nn < nns; nn++) {
 
  908         softmax_means[nn] = 
mean(model->
softmax_q1 + nn * filter_size, filter_size);
 
  909         elliott_means[nn] = 
mean(model->
elliott_q1 + nn * filter_size, filter_size);
 
  911         for (
int k = 0; k < filter_size; k++)
 
  912             mean_filter[k] += model->
softmax_q1[nn * filter_size + k] - softmax_means[nn];
 
  915     for (
int k = 0; k < filter_size; k++)
 
  916         mean_filter[k] *= 
scale;
 
  920     for (
int nn = 0; nn < nns; nn++) {
 
  921         for (
int k = 0; k < filter_size; k++) {
 
  922             model->
softmax_q1[nn * filter_size + k] -= softmax_means[nn] + mean_filter[k];
 
  923             model->
elliott_q1[nn * filter_size + k] -= elliott_means[nn];
 
  929     memset(mean_filter, 0, 
sizeof(mean_filter));
 
  931     for (
int nn = 0; nn < nns; nn++) {
 
  932         softmax_means[nn] = 
mean(model->
softmax_q2 + nn * filter_size, filter_size);
 
  933         elliott_means[nn] = 
mean(model->
elliott_q2 + nn * filter_size, filter_size);
 
  935         for (
int k = 0; k < filter_size; k++) {
 
  936             mean_filter[k] += model->
softmax_q2[nn * filter_size + k] - softmax_means[nn];
 
  940     for (
int k = 0; k < filter_size; k++)
 
  941         mean_filter[k] *= 
scale;
 
  945     for (
int nn = 0; nn < nns; nn++) {
 
  946         for (
int k = 0; k < filter_size; k++) {
 
  947             model->
softmax_q2[nn * filter_size + k] -= softmax_means[nn] + mean_filter[k];
 
  948             model->
elliott_q2[nn * filter_size + k] -= elliott_means[nn];
 
  958     FILE *weights_file = 
NULL;
 
  970     if (fseek(weights_file, 0, SEEK_END)) {
 
  972         fclose(weights_file);
 
  976     weights_size = ftell(weights_file);
 
  978     if (weights_size == -1) {
 
  979         fclose(weights_file);
 
  983         fclose(weights_file);
 
  988     if (fseek(weights_file, 0, SEEK_SET)) {
 
  989         fclose(weights_file);
 
  996         fclose(weights_file);
 
 1002         fclose(weights_file);
 
 1008     fclose(weights_file);
 
 1032     s->depth = 
desc->comp[0].depth;
 
 1039     s->planewidth[0] = 
s->planewidth[3] = 
inlink->w;
 
 1041     s->planeheight[0] = 
s->planeheight[3] = 
inlink->h;
 
 1043     s->half = ((1 << 8) - 1) / 2.f;
 
 1044     s->out_scale = 1 << (
s->depth - 8);
 
 1045     s->in_scale = 1.f / 
s->out_scale;
 
 1066     for (
int i = 0; 
i < 2; 
i++) {
 
 1067         for (
int j = 0; j < 5; j++) {
 
 1068             for (
int k = 0; k < 7; k++)
 
 1073     s->input_size = (
s->planewidth[0] + 64) * (
s->planeheight[0] + 6);
 
 1074     s->input_buf = 
av_calloc(
s->nb_threads, 
sizeof(*
s->input_buf));
 
 1078     for (
int i = 0; 
i < 
s->nb_threads; 
i++) {
 
 1079         s->input_buf[
i] = 
av_calloc(
s->input_size, 
sizeof(**
s->input_buf));
 
 1080         if (!
s->input_buf[
i])
 
 1084     s->output_buf = 
av_calloc(
s->nb_threads, 
sizeof(*
s->output_buf));
 
 1088     for (
int i = 0; 
i < 
s->nb_threads; 
i++) {
 
 1089         s->output_buf[
i] = 
av_calloc(
s->input_size, 
sizeof(**
s->output_buf));
 
 1090         if (!
s->output_buf[
i])
 
 1094     s->prescreen_buf = 
av_calloc(
s->nb_threads, 
sizeof(*
s->prescreen_buf));
 
 1095     if (!
s->prescreen_buf)
 
 1098     for (
int i = 0; 
i < 
s->nb_threads; 
i++) {
 
 1099         s->prescreen_buf[
i] = 
av_calloc(
s->planewidth[0], 
sizeof(**
s->prescreen_buf));
 
 1100         if (!
s->prescreen_buf[
i])
 
 1111     for (
int i = 0; 
i < 
s->nb_threads && 
s->prescreen_buf; 
i++)
 
 1116     for (
int i = 0; 
i < 
s->nb_threads && 
s->input_buf; 
i++)
 
 1121     for (
int i = 0; 
i < 
s->nb_threads && 
s->output_buf; 
i++)
 
 1127     for (
int i = 0; 
i < 2; 
i++) {
 
 1128         for (
int j = 0; j < 5; j++) {
 
 1129             for (
int k = 0; k < 7; k++) {
 
 1158     .p.description = 
NULL_IF_CONFIG_SMALL(
"Apply neural network edge directed interpolation intra-only deinterlacer."),
 
 1159     .p.priv_class  = &nnedi_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
static float dot_dsp(const NNEDIContext *const s, const float *kernel, const float *input, int n, float scale, float bias)
AVPixelFormat
Pixel format.
const FFFilter ff_vf_nnedi
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
static int get_frame(AVFilterContext *ctx, int is_second)
static void subtract_mean_predictor(PredictorCoefficients *model)
#define FILTER_PIXFMTS_ARRAY(array)
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)
#define AVERROR_EOF
End of file.
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
static const float * softmax_q2_filter(int nn, const PredictorCoefficients *const model)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_PIX_FMT_YUVA422P9
#define FILTER_INPUTS(array)
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.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
static void read_bytes(const uint8_t *src, float *dst, int src_stride, int dst_stride, int width, int height, float scale)
static uint8_t half(int a, int b)
#define AV_PIX_FMT_YUV420P10
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
static void process_old(AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, uint8_t *prescreen, int N, const PrescreenerCoefficients *const m_data)
void(* prescreen[2])(AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, uint8_t *prescreen, int N, const PrescreenerCoefficients *const coeffs)
AVFILTER_DEFINE_CLASS(nnedi)
static av_cold void uninit(AVFilterContext *ctx)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
const char * name
Filter name.
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
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.
Link properties exposed to filter code, but not external callers.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
static float elliott(float x)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUVA420P9
static SDL_Window * window
static const float * elliott_q2_filter(int nn, const PredictorCoefficients *const model)
#define AV_PIX_FMT_GBRP14
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
@ 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 double val(void *priv, double ch)
static const uint8_t NNEDI_XDIM[]
#define AV_PIX_FMT_GRAY16
static __device__ float fabsf(float a)
A filter pad used for either input or output.
static void write_words(const float *src, uint8_t *dstp, int src_stride, int dst_stride, int width, int height, int depth, float scale)
static float softmax_exp(float x)
#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 ...
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const AVFilterPad inputs[]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PIX_FMT_YUV422P16
static float * allocate(float **ptr, int size)
@ 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 const uint16_t NNEDI_NNS[]
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
#define AV_PIX_FMT_GBRAP12
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
float kernel_l0[4][16 *4]
static int request_frame(AVFilterLink *link)
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_GRAY14
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this field
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_OUTPUTS(array)
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 link
@ 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 const float * softmax_q1_filter(int nn, const PredictorCoefficients *const model)
static void interpolation(const void *src, ptrdiff_t src_stride, void *dst, const uint8_t *prescreen, int n)
#define LOCAL_ALIGNED_32(t, v,...)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
PredictorCoefficients coeffs[2][5][7]
static int bias(int x, int c)
static void subtract_mean_old(PrescreenerCoefficients *coeffs, float half)
Rational number (pair of numerator and denominator).
@ 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 transform_elliott(float *input, int size)
#define AV_PIX_FMT_YUV440P10
void(* write)(const float *src, uint8_t *dst, int src_stride, int dst_stride, int width, int height, int depth, float scale)
static const uint8_t NNEDI_YDIM[]
static __device__ float sqrtf(float a)
static const AVOption nnedi_options[]
#define AV_PIX_FMT_YUV422P10
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
static FilterLink * ff_filter_link(AVFilterLink *link)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define DECLARE_ALIGNED(n, t, v)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define AV_PIX_FMT_YUV422P12
static void wae5(const float *softmax, const float *el, int n, float mstd[4])
#define AV_PIX_FMT_YUV444P12
static const float * elliott_q1_filter(int nn, const PredictorCoefficients *const model)
AVFilterContext * src
source filter
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
static void predictor(AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, void *dst, const uint8_t *prescreen, int N, const PredictorCoefficients *const model, int use_q2)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUVA444P10
static void transform_softmax_exp(float *input, int size)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
static const AVFilterPad outputs[]
static av_cold int init(AVFilterContext *ctx)
static int filter_offset(int nn, const PredictorCoefficients *const model)
#define i(width, name, range_min, range_max)
int w
agreed upon image width
#define AV_PIX_FMT_GBRP12
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
static enum AVPixelFormat pix_fmts[]
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
const char * name
Pad name.
FILE * avpriv_fopen_utf8(const char *path, const char *mode)
Open a file using a UTF-8 filename.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
static void write_bytes(const float *src, uint8_t *dst, int src_stride, int dst_stride, int width, int height, int depth, float scale)
void * av_calloc(size_t nmemb, size_t size)
void(* read)(const uint8_t *src, float *dst, int src_stride, int dst_stride, int width, int height, float scale)
#define AV_PIX_FMT_YUV444P9
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
static void subtract_mean_new(PrescreenerCoefficients *coeffs, float half)
#define AV_PIX_FMT_YUVA444P9
static void gather_input(const float *src, ptrdiff_t src_stride, float *buf, float mstd[4], const PredictorCoefficients *const model)
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
static int allocate_model(PredictorCoefficients *coeffs, int xdim, int ydim, int nns)
int h
agreed upon image height
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static const size_t NNEDI_WEIGHTS_SIZE
#define AV_PIX_FMT_YUVA422P12
@ AV_OPT_TYPE_INT
Underlying C type is int.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void process_new(AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, uint8_t *prescreen, int N, const PrescreenerCoefficients *const m_data)
static float mean(const float *input, int size)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static void read_words(const uint8_t *srcp, float *dst, int src_stride, int dst_stride, int width, int height, float scale)
static void transform(float *input, int size, float mean, float half)
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
@ 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...
AVFilter p
The public AVFilter.
@ 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...
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static int read_weights(AVFilterContext *ctx, const float *bdata)
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static int config_input(AVFilterLink *inlink)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
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)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void copy_weights(float *dst, int n, const float **data)
#define AV_PIX_FMT_YUV440P12
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
#define AV_PIX_FMT_YUV444P14
@ 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 AV_PIX_FMT_GRAY12
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14
PrescreenerCoefficients prescreener[4]
static int config_output(AVFilterLink *outlink)