FFmpeg
vf_zscale.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Paul B Mahol
3  * Copyright (c) 2022 Victoria Zhislina, Intel
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * zscale video filter using z.lib library
25  */
26 
27 #include <float.h>
28 #include <stdio.h>
29 #include <string.h>
30 
31 #include <zimg.h>
32 
33 #include "avfilter.h"
34 #include "formats.h"
35 #include "internal.h"
36 #include "video.h"
37 #include "libavutil/avstring.h"
38 #include "libavutil/eval.h"
39 #include "libavutil/internal.h"
40 #include "libavutil/intreadwrite.h"
41 #include "libavutil/mathematics.h"
42 #include "libavutil/opt.h"
43 #include "libavutil/parseutils.h"
44 #include "libavutil/pixdesc.h"
45 #include "libavutil/imgutils.h"
46 
47 #define ZIMG_ALIGNMENT 64
48 #define MIN_TILESIZE 64
49 #define MAX_THREADS 64
50 
51 static const char *const var_names[] = {
52  "in_w", "iw",
53  "in_h", "ih",
54  "out_w", "ow",
55  "out_h", "oh",
56  "a",
57  "sar",
58  "dar",
59  "hsub",
60  "vsub",
61  "ohsub",
62  "ovsub",
63  NULL
64 };
65 
66 enum var_name {
79 };
80 
81 typedef struct ZScaleContext {
82  const AVClass *class;
83 
84  /**
85  * New dimensions. Special values are:
86  * 0 = original width/height
87  * -1 = keep original aspect
88  * -N = try to keep aspect but make sure it is divisible by N
89  */
90  int w, h;
91  int dither;
92  int filter;
94  int trc;
95  int primaries;
96  int range;
97  int chromal;
99  int trc_in;
101  int range_in;
103  char *size_str;
106  double param_a;
107  double param_b;
108 
109  char *w_expr; ///< width expression string
110  char *h_expr; ///< height expression string
111 
116 
119 
120  void *tmp[MAX_THREADS]; //separate for each thread;
127 
128  zimg_image_format src_format, dst_format;
129  zimg_image_format alpha_src_format, alpha_dst_format;
130  zimg_image_format src_format_tmp, dst_format_tmp;
132  zimg_graph_builder_params alpha_params, params;
133  zimg_graph_builder_params alpha_params_tmp, params_tmp;
134  zimg_filter_graph *alpha_graph[MAX_THREADS], *graph[MAX_THREADS];
135 } ZScaleContext;
136 
137 typedef struct ThreadData {
139  AVFrame *in, *out;
140 } ThreadData;
141 
143 {
144  ZScaleContext *s = ctx->priv;
145  int ret;
146  zimg_image_format_default(&s->src_format, ZIMG_API_VERSION);
147  zimg_image_format_default(&s->dst_format, ZIMG_API_VERSION);
148  zimg_image_format_default(&s->src_format_tmp, ZIMG_API_VERSION);
149  zimg_image_format_default(&s->dst_format_tmp, ZIMG_API_VERSION);
150 
151  zimg_image_format_default(&s->alpha_src_format, ZIMG_API_VERSION);
152  zimg_image_format_default(&s->alpha_dst_format, ZIMG_API_VERSION);
153  zimg_image_format_default(&s->alpha_src_format_tmp, ZIMG_API_VERSION);
154  zimg_image_format_default(&s->alpha_dst_format_tmp, ZIMG_API_VERSION);
155 
156  zimg_graph_builder_params_default(&s->params, ZIMG_API_VERSION);
157  zimg_graph_builder_params_default(&s->params_tmp, ZIMG_API_VERSION);
158  zimg_graph_builder_params_default(&s->alpha_params, ZIMG_API_VERSION);
159  zimg_graph_builder_params_default(&s->alpha_params_tmp, ZIMG_API_VERSION);
160 
161  if (s->size_str && (s->w_expr || s->h_expr)) {
163  "Size and width/height expressions cannot be set at the same time.\n");
164  return AVERROR(EINVAL);
165  }
166 
167  if (s->w_expr && !s->h_expr)
168  FFSWAP(char *, s->w_expr, s->size_str);
169 
170  if (s->size_str) {
171  char buf[32];
172  if ((ret = av_parse_video_size(&s->w, &s->h, s->size_str)) < 0) {
174  "Invalid size '%s'\n", s->size_str);
175  return ret;
176  }
177  snprintf(buf, sizeof(buf)-1, "%d", s->w);
178  av_opt_set(s, "w", buf, 0);
179  snprintf(buf, sizeof(buf)-1, "%d", s->h);
180  av_opt_set(s, "h", buf, 0);
181  }
182  if (!s->w_expr)
183  av_opt_set(s, "w", "iw", 0);
184  if (!s->h_expr)
185  av_opt_set(s, "h", "ih", 0);
186 
187  return 0;
188 }
189 
190 static enum AVColorRange convert_range_from_zimg(enum zimg_pixel_range_e color_range);
191 
193 {
194  ZScaleContext *s = ctx->priv;
196  static const enum AVPixelFormat pixel_fmts[] = {
218  };
219  int ret;
220 
221  ret = ff_formats_ref(ff_make_format_list(pixel_fmts), &ctx->inputs[0]->outcfg.formats);
222  if (ret < 0)
223  return ret;
224  ret = ff_formats_ref(ff_make_format_list(pixel_fmts), &ctx->outputs[0]->incfg.formats);
225  if (ret < 0)
226  return ret;
227 
228  if ((ret = ff_formats_ref(ff_all_color_spaces(), &ctx->inputs[0]->outcfg.color_spaces)) < 0 ||
229  (ret = ff_formats_ref(ff_all_color_ranges(), &ctx->inputs[0]->outcfg.color_ranges)) < 0)
230  return ret;
231 
232  formats = s->colorspace != ZIMG_MATRIX_UNSPECIFIED && s->colorspace > 0
233  ? ff_make_formats_list_singleton(s->colorspace)
235  if ((ret = ff_formats_ref(formats, &ctx->outputs[0]->incfg.color_spaces)) < 0)
236  return ret;
237 
238  formats = s->range != -1
241  if ((ret = ff_formats_ref(formats, &ctx->outputs[0]->incfg.color_ranges)) < 0)
242  return ret;
243 
244  return 0;
245 }
246 
247 static void slice_params(ZScaleContext *s, int out_h, int in_h)
248 {
249  s->out_slice_start[0] = 0;
250  for (int i = 1; i < s->nb_threads; i++) {
251  int slice_end = out_h * i / s->nb_threads;
252  s->out_slice_end[i - 1] = s->out_slice_start[i] = FFALIGN(slice_end, 2);
253  }
254  s->out_slice_end[s->nb_threads - 1] = out_h;
255 
256  for (int i = 0; i < s->nb_threads; i++) {
257  s->in_slice_start[i] = s->out_slice_start[i] * in_h / (double)out_h;
258  s->in_slice_end[i] = s->out_slice_end[i] * in_h / (double)out_h;
259  }
260 }
261 
262 static int config_props(AVFilterLink *outlink)
263 {
264  AVFilterContext *ctx = outlink->src;
265  AVFilterLink *inlink = outlink->src->inputs[0];
266  ZScaleContext *s = ctx->priv;
268  const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(outlink->format);
269  int64_t w, h;
270  double var_values[VARS_NB], res;
271  char *expr;
272  int ret;
273  int factor_w, factor_h;
274 
275  var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w;
276  var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h;
277  var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN;
278  var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN;
279  var_values[VAR_A] = (double) inlink->w / inlink->h;
280  var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ?
281  (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
282  var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
283  var_values[VAR_HSUB] = 1 << desc->log2_chroma_w;
284  var_values[VAR_VSUB] = 1 << desc->log2_chroma_h;
285  var_values[VAR_OHSUB] = 1 << out_desc->log2_chroma_w;
286  var_values[VAR_OVSUB] = 1 << out_desc->log2_chroma_h;
287 
288  /* evaluate width and height */
289  av_expr_parse_and_eval(&res, (expr = s->w_expr),
290  var_names, var_values,
291  NULL, NULL, NULL, NULL, NULL, 0, ctx);
292  s->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res;
293  if ((ret = av_expr_parse_and_eval(&res, (expr = s->h_expr),
294  var_names, var_values,
295  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
296  goto fail;
297  s->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res;
298  /* evaluate again the width, as it may depend on the output height */
299  if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr),
300  var_names, var_values,
301  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
302  goto fail;
303  s->w = res;
304 
305  w = s->w;
306  h = s->h;
307 
308  /* Check if it is requested that the result has to be divisible by a some
309  * factor (w or h = -n with n being the factor). */
310  factor_w = 1;
311  factor_h = 1;
312  if (w < -1) {
313  factor_w = -w;
314  }
315  if (h < -1) {
316  factor_h = -h;
317  }
318 
319  if (w < 0 && h < 0)
320  s->w = s->h = 0;
321 
322  if (!(w = s->w))
323  w = inlink->w;
324  if (!(h = s->h))
325  h = inlink->h;
326 
327  /* Make sure that the result is divisible by the factor we determined
328  * earlier. If no factor was set, it is nothing will happen as the default
329  * factor is 1 */
330  if (w < 0)
331  w = av_rescale(h, inlink->w, inlink->h * factor_w) * factor_w;
332  if (h < 0)
333  h = av_rescale(w, inlink->h, inlink->w * factor_h) * factor_h;
334 
335  /* Note that force_original_aspect_ratio may overwrite the previous set
336  * dimensions so that it is not divisible by the set factors anymore. */
337  if (s->force_original_aspect_ratio) {
338  int tmp_w = av_rescale(h, inlink->w, inlink->h);
339  int tmp_h = av_rescale(w, inlink->h, inlink->w);
340 
341  if (s->force_original_aspect_ratio == 1) {
342  w = FFMIN(tmp_w, w);
343  h = FFMIN(tmp_h, h);
344  } else {
345  w = FFMAX(tmp_w, w);
346  h = FFMAX(tmp_h, h);
347  }
348  }
349 
350  if (w > INT_MAX || h > INT_MAX ||
351  (h * inlink->w) > INT_MAX ||
352  (w * inlink->h) > INT_MAX)
353  av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
354 
355  outlink->w = w;
356  outlink->h = h;
357 
358  s->first_time = 1;
359 
360  if (inlink->sample_aspect_ratio.num){
361  outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio);
362  } else
363  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
364 
365  av_log(ctx, AV_LOG_TRACE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d fmt:%s sar:%d/%d\n",
366  inlink ->w, inlink ->h, av_get_pix_fmt_name( inlink->format),
367  inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den,
368  outlink->w, outlink->h, av_get_pix_fmt_name(outlink->format),
369  outlink->sample_aspect_ratio.num, outlink->sample_aspect_ratio.den);
370  return 0;
371 
372 fail:
374  "Error when evaluating the expression '%s'.\n"
375  "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
376  expr, s->w_expr, s->h_expr);
377  return ret;
378 }
379 
381 {
382  char err_msg[1024];
383  int err_code = zimg_get_last_error(err_msg, sizeof(err_msg));
384 
385  av_log(ctx, AV_LOG_ERROR, "code %d: %s\n", err_code, err_msg);
386 
387  return AVERROR_EXTERNAL;
388 }
389 
390 static int convert_chroma_location(enum AVChromaLocation chroma_location)
391 {
392  switch (chroma_location) {
394  case AVCHROMA_LOC_LEFT:
395  return ZIMG_CHROMA_LEFT;
396  case AVCHROMA_LOC_CENTER:
397  return ZIMG_CHROMA_CENTER;
399  return ZIMG_CHROMA_TOP_LEFT;
400  case AVCHROMA_LOC_TOP:
401  return ZIMG_CHROMA_TOP;
403  return ZIMG_CHROMA_BOTTOM_LEFT;
404  case AVCHROMA_LOC_BOTTOM:
405  return ZIMG_CHROMA_BOTTOM;
406  }
407  return ZIMG_CHROMA_LEFT;
408 }
409 
410 static int convert_matrix(enum AVColorSpace colorspace)
411 {
412  switch (colorspace) {
413  case AVCOL_SPC_RGB:
414  return ZIMG_MATRIX_RGB;
415  case AVCOL_SPC_BT709:
416  return ZIMG_MATRIX_709;
418  return ZIMG_MATRIX_UNSPECIFIED;
419  case AVCOL_SPC_FCC:
420  return ZIMG_MATRIX_FCC;
421  case AVCOL_SPC_BT470BG:
422  return ZIMG_MATRIX_470BG;
423  case AVCOL_SPC_SMPTE170M:
424  return ZIMG_MATRIX_170M;
425  case AVCOL_SPC_SMPTE240M:
426  return ZIMG_MATRIX_240M;
427  case AVCOL_SPC_YCGCO:
428  return ZIMG_MATRIX_YCGCO;
430  return ZIMG_MATRIX_2020_NCL;
431  case AVCOL_SPC_BT2020_CL:
432  return ZIMG_MATRIX_2020_CL;
434  return ZIMG_MATRIX_CHROMATICITY_DERIVED_NCL;
436  return ZIMG_MATRIX_CHROMATICITY_DERIVED_CL;
437  case AVCOL_SPC_ICTCP:
438  return ZIMG_MATRIX_ICTCP;
439  }
440  return ZIMG_MATRIX_UNSPECIFIED;
441 }
442 
443 static int convert_trc(enum AVColorTransferCharacteristic color_trc)
444 {
445  switch (color_trc) {
447  return ZIMG_TRANSFER_UNSPECIFIED;
448  case AVCOL_TRC_BT709:
449  return ZIMG_TRANSFER_709;
450  case AVCOL_TRC_GAMMA22:
451  return ZIMG_TRANSFER_470_M;
452  case AVCOL_TRC_GAMMA28:
453  return ZIMG_TRANSFER_470_BG;
454  case AVCOL_TRC_SMPTE170M:
455  return ZIMG_TRANSFER_601;
456  case AVCOL_TRC_SMPTE240M:
457  return ZIMG_TRANSFER_240M;
458  case AVCOL_TRC_LINEAR:
459  return ZIMG_TRANSFER_LINEAR;
460  case AVCOL_TRC_LOG:
461  return ZIMG_TRANSFER_LOG_100;
462  case AVCOL_TRC_LOG_SQRT:
463  return ZIMG_TRANSFER_LOG_316;
465  return ZIMG_TRANSFER_IEC_61966_2_4;
466  case AVCOL_TRC_BT2020_10:
467  return ZIMG_TRANSFER_2020_10;
468  case AVCOL_TRC_BT2020_12:
469  return ZIMG_TRANSFER_2020_12;
470  case AVCOL_TRC_SMPTE2084:
471  return ZIMG_TRANSFER_ST2084;
473  return ZIMG_TRANSFER_ARIB_B67;
475  return ZIMG_TRANSFER_IEC_61966_2_1;
476  }
477  return ZIMG_TRANSFER_UNSPECIFIED;
478 }
479 
481 {
482  switch (color_primaries) {
484  return ZIMG_PRIMARIES_UNSPECIFIED;
485  case AVCOL_PRI_BT709:
486  return ZIMG_PRIMARIES_709;
487  case AVCOL_PRI_BT470M:
488  return ZIMG_PRIMARIES_470_M;
489  case AVCOL_PRI_BT470BG:
490  return ZIMG_PRIMARIES_470_BG;
491  case AVCOL_PRI_SMPTE170M:
492  return ZIMG_PRIMARIES_170M;
493  case AVCOL_PRI_SMPTE240M:
494  return ZIMG_PRIMARIES_240M;
495  case AVCOL_PRI_FILM:
496  return ZIMG_PRIMARIES_FILM;
497  case AVCOL_PRI_BT2020:
498  return ZIMG_PRIMARIES_2020;
499  case AVCOL_PRI_SMPTE428:
500  return ZIMG_PRIMARIES_ST428;
501  case AVCOL_PRI_SMPTE431:
502  return ZIMG_PRIMARIES_ST431_2;
503  case AVCOL_PRI_SMPTE432:
504  return ZIMG_PRIMARIES_ST432_1;
505  case AVCOL_PRI_JEDEC_P22:
506  return ZIMG_PRIMARIES_EBU3213_E;
507  }
508  return ZIMG_PRIMARIES_UNSPECIFIED;
509 }
510 
512 {
513  switch (color_range) {
515  case AVCOL_RANGE_MPEG:
516  return ZIMG_RANGE_LIMITED;
517  case AVCOL_RANGE_JPEG:
518  return ZIMG_RANGE_FULL;
519  }
520  return ZIMG_RANGE_LIMITED;
521 }
522 
523 static enum AVColorRange convert_range_from_zimg(enum zimg_pixel_range_e color_range)
524 {
525  switch (color_range) {
526  case ZIMG_RANGE_LIMITED:
527  return AVCOL_RANGE_MPEG;
528  case ZIMG_RANGE_FULL:
529  return AVCOL_RANGE_JPEG;
530  }
532 }
533 
534 /* returns 0 if image formats are the same and 1 otherwise */
535 static int compare_zimg_image_formats(zimg_image_format *img_fmt0, zimg_image_format *img_fmt1)
536 {
537  return ((img_fmt0->chroma_location != img_fmt1->chroma_location) ||
538 #if ZIMG_API_VERSION >= 0x204
539  (img_fmt0->alpha != img_fmt1->alpha) ||
540 #endif
541  (img_fmt0->color_family != img_fmt1->color_family) ||
542  (img_fmt0->color_primaries != img_fmt1->color_primaries) ||
543  (img_fmt0->depth != img_fmt1->depth) ||
544  (img_fmt0->field_parity != img_fmt1->field_parity) ||
545  (img_fmt0->height != img_fmt1->height) ||
546  (img_fmt0->matrix_coefficients != img_fmt1->matrix_coefficients) ||
547  (img_fmt0->pixel_range != img_fmt1->pixel_range) ||
548  (img_fmt0->pixel_type != img_fmt1->pixel_type) ||
549  (img_fmt0->subsample_h != img_fmt1->subsample_h) ||
550  (img_fmt0->subsample_w != img_fmt1->subsample_w) ||
551  (img_fmt0->transfer_characteristics != img_fmt1->transfer_characteristics) ||
552  (img_fmt0->width != img_fmt1->width));
553 }
554 
555 /* returns 0 if graph builder parameters are the same and 1 otherwise */
556 static int compare_zimg_graph_builder_params(zimg_graph_builder_params *parm0, zimg_graph_builder_params *parm1)
557 {
558  /* the parameters that could be changed inside a single ffmpeg zscale invocation are checked only
559  and NaN values that are default for some params are treated properly*/
560  int ret = (parm0->allow_approximate_gamma != parm1->allow_approximate_gamma) ||
561  (parm0->dither_type != parm1->dither_type) ||
562  (parm0->resample_filter != parm1->resample_filter) ||
563  (parm0->resample_filter_uv != parm1->resample_filter_uv);
564 
565  if ((isnan(parm0->nominal_peak_luminance) == 0) || (isnan(parm1->nominal_peak_luminance) == 0))
566  ret = ret || (parm0->nominal_peak_luminance != parm1->nominal_peak_luminance);
567  if ((isnan(parm0->filter_param_a) == 0) || (isnan(parm1->filter_param_a) == 0))
568  ret = ret || (parm0->filter_param_a != parm1->filter_param_a);
569  if ((isnan(parm0->filter_param_a_uv) == 0) || (isnan(parm1->filter_param_a_uv) == 0))
570  ret = ret || (parm0->filter_param_a_uv != parm1->filter_param_a_uv);
571  if ((isnan(parm0->filter_param_b) == 0) || (isnan(parm1->filter_param_b) == 0))
572  ret = ret || (parm0->filter_param_b != parm1->filter_param_b);
573  if ((isnan(parm0->filter_param_b_uv) == 0) || (isnan(parm1->filter_param_b_uv) == 0))
574  ret = ret || (parm0->filter_param_b_uv != parm1->filter_param_b_uv);
575 
576  return ret;
577 }
578 
579 static void format_init(zimg_image_format *format, AVFrame *frame, const AVPixFmtDescriptor *desc,
580  int colorspace, int primaries, int transfer, int range, int location)
581 {
582  format->width = frame->width;
584  format->subsample_w = desc->log2_chroma_w;
585  format->subsample_h = desc->log2_chroma_h;
586  format->depth = desc->comp[0].depth;
587  format->pixel_type = (desc->flags & AV_PIX_FMT_FLAG_FLOAT) ? ZIMG_PIXEL_FLOAT : desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
588  format->color_family = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_COLOR_RGB : ZIMG_COLOR_YUV;
589  format->matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_MATRIX_RGB : colorspace == -1 ? convert_matrix(frame->colorspace) : colorspace;
591  format->transfer_characteristics = transfer == -1 ? convert_trc(frame->color_trc) : transfer;
592  format->pixel_range = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_RANGE_FULL : range == -1 ? convert_range(frame->color_range) : range;
593  format->chroma_location = location == -1 ? convert_chroma_location(frame->chroma_location) : location;
594 }
595 
596 static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *desc, const AVPixFmtDescriptor *out_desc,
597  AVFilterContext *ctx, int job_nr, int n_jobs)
598 {
599  ZScaleContext *s = ctx->priv;
600  int ret;
601  size_t size;
602  zimg_image_format src_format;
603  zimg_image_format dst_format;
604  zimg_image_format alpha_src_format;
605  zimg_image_format alpha_dst_format;
606  const double in_slice_start = s->in_slice_start[job_nr];
607  const double in_slice_end = s->in_slice_end[job_nr];
608  const int out_slice_start = s->out_slice_start[job_nr];
609  const int out_slice_end = s->out_slice_end[job_nr];
610 
611  src_format = s->src_format;
612  dst_format = s->dst_format;
613  /* The input slice is specified through the active_region field,
614  unlike the output slice.
615  according to zimg requirements input and output slices should have even dimensions */
616  src_format.active_region.width = in->width;
617  src_format.active_region.height = in_slice_end - in_slice_start;
618  src_format.active_region.left = 0;
619  src_format.active_region.top = in_slice_start;
620  //dst now is the single tile only!!
621  dst_format.width = out->width;
622  dst_format.height = out_slice_end - out_slice_start;
623 
624  if (s->graph[job_nr]) {
625  zimg_filter_graph_free(s->graph[job_nr]);
626  }
627  s->graph[job_nr] = zimg_filter_graph_build(&src_format, &dst_format, &s->params);
628  if (!s->graph[job_nr])
629  return print_zimg_error(ctx);
630 
631  ret = zimg_filter_graph_get_tmp_size(s->graph[job_nr], &size);
632  if (ret)
633  return print_zimg_error(ctx);
634 
635  if (s->tmp[job_nr])
636  av_freep(&s->tmp[job_nr]);
637  s->tmp[job_nr] = av_calloc(size, 1);
638  if (!s->tmp[job_nr])
639  return AVERROR(ENOMEM);
640 
641  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && out_desc->flags & AV_PIX_FMT_FLAG_ALPHA) {
642  alpha_src_format = s->alpha_src_format;
643  alpha_dst_format = s->alpha_dst_format;
644  /* The input slice is specified through the active_region field, unlike the output slice.
645  according to zimg requirements input and output slices should have even dimentions */
646  alpha_src_format.active_region.width = in->width;
647  alpha_src_format.active_region.height = in_slice_end - in_slice_start;
648  alpha_src_format.active_region.left = 0;
649  alpha_src_format.active_region.top = in_slice_start;
650  //dst now is the single tile only!!
651  alpha_dst_format.width = out->width;
652  alpha_dst_format.height = out_slice_end - out_slice_start;
653 
654  if (s->alpha_graph[job_nr]) {
655  zimg_filter_graph_free(s->alpha_graph[job_nr]);
656  }
657  s->alpha_graph[job_nr] = zimg_filter_graph_build(&alpha_src_format, &alpha_dst_format, &s->alpha_params);
658  if (!s->alpha_graph[job_nr])
659  return print_zimg_error(ctx);
660  }
661  return 0;
662 }
663 
664 static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy)
665 {
666  AVFrame *aligned = NULL;
667  int ret = 0, plane, planes;
668 
669  /* Realign any unaligned input frame. */
670  planes = av_pix_fmt_count_planes(desc->nb_components);
671  for (plane = 0; plane < planes; plane++) {
672  int p = desc->comp[plane].plane;
673  if ((uintptr_t)(*frame)->data[p] % ZIMG_ALIGNMENT || (*frame)->linesize[p] % ZIMG_ALIGNMENT) {
674  if (!(aligned = av_frame_alloc())) {
675  ret = AVERROR(ENOMEM);
676  goto fail;
677  }
678 
679  aligned->format = (*frame)->format;
680  aligned->width = (*frame)->width;
681  aligned->height = (*frame)->height;
682 
684  goto fail;
685 
686  if (needs_copy && (ret = av_frame_copy(aligned, *frame)) < 0)
687  goto fail;
688 
689  if (needs_copy && (ret = av_frame_copy_props(aligned, *frame)) < 0)
690  goto fail;
691 
693  *frame = aligned;
694  return 0;
695  }
696  }
697 
698 fail:
700  return ret;
701 }
702 
704 {
705  if (s->primaries != -1)
706  frame->color_primaries = (int)s->dst_format.color_primaries;
707 
708  if (s->trc != -1)
709  frame->color_trc = (int)s->dst_format.transfer_characteristics;
710 
711  if (s->chromal != -1)
712  frame->chroma_location = (int)s->dst_format.chroma_location + 1;
713 }
714 
715 static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
716 {
717  ThreadData *td = data;
718  int ret = 0;
719  int p;
720  int need_gb;
721  ZScaleContext *s = ctx->priv;
722  zimg_image_buffer_const src_buf = { ZIMG_API_VERSION };
723  zimg_image_buffer dst_buf = { ZIMG_API_VERSION };
724  const int out_slice_start = s->out_slice_start[job_nr];
725 
726  /* create zimg filter graphs for each thread
727  only if not created earlier or there is some change in frame parameters */
728  need_gb = compare_zimg_image_formats(&s->src_format, &s->src_format_tmp) ||
729  compare_zimg_image_formats(&s->dst_format, &s->dst_format_tmp) ||
730  compare_zimg_graph_builder_params(&s->params, &s->params_tmp);
731  if(td->desc->flags & AV_PIX_FMT_FLAG_ALPHA && td->odesc->flags & AV_PIX_FMT_FLAG_ALPHA)
732  need_gb = need_gb || compare_zimg_image_formats(&s->alpha_src_format, &s->alpha_src_format_tmp) ||
733  compare_zimg_image_formats(&s->alpha_dst_format, &s->alpha_dst_format_tmp) ||
734  compare_zimg_graph_builder_params(&s->alpha_params, &s->alpha_params_tmp);
735 
736  if (need_gb){
737  ret = graphs_build(td->in, td->out, td->desc, td->odesc, ctx, job_nr, n_jobs);
738  if (ret < 0)
739  return print_zimg_error(ctx);
740  }
741  for (int i = 0; i < 3; i++) {
742  const int vsamp = i >= 1 ? td->odesc->log2_chroma_h : 0;
743 
744  p = td->desc->comp[i].plane;
745 
746  src_buf.plane[i].data = td->in->data[p];
747  src_buf.plane[i].stride = td->in->linesize[p];
748  src_buf.plane[i].mask = -1;
749 
750  p = td->odesc->comp[i].plane;
751  dst_buf.plane[i].data = td->out->data[p] + td->out->linesize[p] * (out_slice_start >> vsamp);
752  dst_buf.plane[i].stride = td->out->linesize[p];
753  dst_buf.plane[i].mask = -1;
754  }
755  if (!s->graph[job_nr])
756  return AVERROR(EINVAL);
757  ret = zimg_filter_graph_process(s->graph[job_nr], &src_buf, &dst_buf, s->tmp[job_nr], 0, 0, 0, 0);
758  if (ret)
759  return print_zimg_error(ctx);
760 
761  if (td->desc->flags & AV_PIX_FMT_FLAG_ALPHA && td->odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
762  src_buf.plane[0].data = td->in->data[3];
763  src_buf.plane[0].stride = td->in->linesize[3];
764  src_buf.plane[0].mask = -1;
765 
766  dst_buf.plane[0].data = td->out->data[3] + td->out->linesize[3] * out_slice_start;
767  dst_buf.plane[0].stride = td->out->linesize[3];
768  dst_buf.plane[0].mask = -1;
769 
770  if (!s->alpha_graph[job_nr])
771  return AVERROR(EINVAL);
772  ret = zimg_filter_graph_process(s->alpha_graph[job_nr], &src_buf, &dst_buf, s->tmp[job_nr], 0, 0, 0, 0);
773  if (ret)
774  return print_zimg_error(ctx);
775  }
776  return 0;
777 }
778 
780 {
781  AVFilterContext *ctx = link->dst;
782  ZScaleContext *s = ctx->priv;
783  AVFilterLink *outlink = ctx->outputs[0];
785  const AVPixFmtDescriptor *odesc = av_pix_fmt_desc_get(outlink->format);
786  char buf[32];
787  int ret = 0;
788  AVFrame *out = NULL;
789  ThreadData td;
790 
791  //we need to use this filter if something is different for an input and output only
792  //otherwise - just copy the input frame to the output
793  if ((link->format != outlink->format) ||
794  (link->w != outlink->w) ||
795  (link->h != outlink->h) ||
796  (link->colorspace != outlink->colorspace) ||
797  (link->color_range != outlink->color_range) ||
798  s->first_time ||
799  (s->src_format.chroma_location != s->dst_format.chroma_location) ||
800  (s->src_format.color_family !=s->dst_format.color_family) ||
801  (s->src_format.color_primaries !=s->dst_format.color_primaries) ||
802  (s->src_format.depth !=s->dst_format.depth) ||
803  (s->src_format.matrix_coefficients !=s->dst_format.matrix_coefficients) ||
804  (s->src_format.field_parity !=s->dst_format.field_parity) ||
805  (s->src_format.pixel_range !=s->dst_format.pixel_range) ||
806  (s->src_format.pixel_type !=s->dst_format.pixel_type) ||
807  (s->src_format.transfer_characteristics !=s->dst_format.transfer_characteristics)
808  ){
809  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
810  if (!out) {
811  ret = AVERROR(ENOMEM);
812  goto fail;
813  }
814 
815  if ((ret = realign_frame(odesc, &out, 0)) < 0)
816  goto fail;
817 
819  out->colorspace = outlink->colorspace;
820  out->color_range = outlink->color_range;
821 
822  if ((ret = realign_frame(desc, &in, 1)) < 0)
823  goto fail;
824 
825  snprintf(buf, sizeof(buf)-1, "%d", outlink->w);
826  av_opt_set(s, "w", buf, 0);
827  snprintf(buf, sizeof(buf)-1, "%d", outlink->h);
828  av_opt_set(s, "h", buf, 0);
829 
830  link->dst->inputs[0]->format = in->format;
831  link->dst->inputs[0]->w = in->width;
832  link->dst->inputs[0]->h = in->height;
833  link->dst->inputs[0]->colorspace = in->colorspace;
834  link->dst->inputs[0]->color_range = in->color_range;
835 
836  s->nb_threads = av_clip(FFMIN(ff_filter_get_nb_threads(ctx), FFMIN(link->h, outlink->h) / MIN_TILESIZE), 1, MAX_THREADS);
837  slice_params(s, out->height, in->height);
838 
839  zimg_image_format_default(&s->src_format, ZIMG_API_VERSION);
840  zimg_image_format_default(&s->dst_format, ZIMG_API_VERSION);
841  zimg_graph_builder_params_default(&s->params, ZIMG_API_VERSION);
842 
843  format_init(&s->src_format, in, desc, s->colorspace_in,
844  s->primaries_in, s->trc_in, s->range_in, s->chromal_in);
845  format_init(&s->dst_format, out, odesc, s->colorspace,
846  s->primaries, s->trc, s->range, s->chromal);
847  s->first_time = 0;
848 
849  s->params.dither_type = s->dither;
850  s->params.cpu_type = ZIMG_CPU_AUTO_64B;
851  s->params.resample_filter = s->filter;
852  s->params.resample_filter_uv = s->filter;
853  s->params.nominal_peak_luminance = s->nominal_peak_luminance;
854  s->params.allow_approximate_gamma = s->approximate_gamma;
855  s->params.filter_param_a = s->params.filter_param_a_uv = s->param_a;
856  s->params.filter_param_b = s->params.filter_param_b_uv = s->param_b;
857 
858  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
859  zimg_image_format_default(&s->alpha_src_format, ZIMG_API_VERSION);
860  zimg_image_format_default(&s->alpha_dst_format, ZIMG_API_VERSION);
861  zimg_graph_builder_params_default(&s->alpha_params, ZIMG_API_VERSION);
862 
863  s->alpha_params.dither_type = s->dither;
864  s->alpha_params.cpu_type = ZIMG_CPU_AUTO_64B;
865  s->alpha_params.resample_filter = s->filter;
866 
867  s->alpha_src_format.width = in->width;
868  s->alpha_src_format.height = in->height;
869  s->alpha_src_format.depth = desc->comp[0].depth;
870  s->alpha_src_format.pixel_type = (desc->flags & AV_PIX_FMT_FLAG_FLOAT) ? ZIMG_PIXEL_FLOAT : desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
871  s->alpha_src_format.color_family = ZIMG_COLOR_GREY;
872 
873  s->alpha_dst_format.depth = odesc->comp[0].depth;
874  s->alpha_dst_format.pixel_type = (odesc->flags & AV_PIX_FMT_FLAG_FLOAT) ? ZIMG_PIXEL_FLOAT : odesc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
875  s->alpha_dst_format.color_family = ZIMG_COLOR_GREY;
876  }
877 
879  av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
880  (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
881  (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
882  INT_MAX);
883 
884  td.in = in;
885  td.out = out;
886  td.desc = desc;
887  td.odesc = odesc;
888 
889  memset(s->jobs_ret, 0, s->nb_threads * sizeof(*s->jobs_ret));
890  ret = ff_filter_execute(ctx, filter_slice, &td, s->jobs_ret, s->nb_threads);
891  for (int i = 0; ret >= 0 && i < s->nb_threads; i++)
892  if (s->jobs_ret[i] < 0)
893  ret = s->jobs_ret[i];
894  if (ret < 0) {
895  av_frame_free(&in);
896  av_frame_free(&out);
897  return ret;
898  }
899 
900  s->src_format_tmp = s->src_format;
901  s->dst_format_tmp = s->dst_format;
902  s->params_tmp = s->params;
903  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
904  s->alpha_src_format_tmp = s->alpha_src_format;
905  s->alpha_dst_format_tmp = s->alpha_dst_format;
906  s->alpha_params_tmp = s->alpha_params;
907  }
908 
909  if ((!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) && (odesc->flags & AV_PIX_FMT_FLAG_ALPHA) ){
910  int x, y;
911  if (odesc->flags & AV_PIX_FMT_FLAG_FLOAT) {
912  for (y = 0; y < out->height; y++) {
913  const ptrdiff_t row = y * out->linesize[3];
914  for (x = 0; x < out->width; x++) {
915  AV_WN32(out->data[3] + x * odesc->comp[3].step + row,
916  av_float2int(1.0f));
917  }
918  }
919  } else if (s->dst_format.depth == 8) {
920  for (y = 0; y < outlink->h; y++)
921  memset(out->data[3] + y * out->linesize[3], 0xff, outlink->w);
922  } else {
923  const uint16_t max = (1 << s->dst_format.depth) - 1;
924  for (y = 0; y < outlink->h; y++) {
925  const ptrdiff_t row = y * out->linesize[3];
926  for (x = 0; x < out->width; x++)
927  AV_WN16(out->data[3] + x * odesc->comp[3].step + row, max);
928  }
929  }
930  }
931  } else {
932  /*no need for any filtering */
933  return ff_filter_frame(outlink, in);
934  }
935 fail:
936  av_frame_free(&in);
937  if (ret) {
938  av_frame_free(&out);
939  return ret;
940  }
941 
942  return ff_filter_frame(outlink, out);
943 }
944 
946 {
947  ZScaleContext *s = ctx->priv;
948 
949  for (int i = 0; i < s->nb_threads; i++) {
950  av_freep(&s->tmp[i]);
951  if (s->graph[i]) {
952  zimg_filter_graph_free(s->graph[i]);
953  s->graph[i] = NULL;
954  }
955  if (s->alpha_graph[i]) {
956  zimg_filter_graph_free(s->alpha_graph[i]);
957  s->alpha_graph[i] = NULL;
958  }
959  }
960 }
961 
962 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
963  char *res, int res_len, int flags)
964 {
965  ZScaleContext *s = ctx->priv;
966  int ret;
967 
968  if ( !strcmp(cmd, "width") || !strcmp(cmd, "w")
969  || !strcmp(cmd, "height") || !strcmp(cmd, "h")) {
970 
971  int old_w = s->w;
972  int old_h = s->h;
973  AVFilterLink *outlink = ctx->outputs[0];
974 
975  av_opt_set(s, cmd, args, 0);
976  if ((ret = config_props(outlink)) < 0) {
977  s->w = old_w;
978  s->h = old_h;
979  }
980  } else
981  ret = AVERROR(ENOSYS);
982 
983  return ret;
984 }
985 
986 #define OFFSET(x) offsetof(ZScaleContext, x)
987 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
988 #define TFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
989 
990 static const AVOption zscale_options[] = {
991  { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, .flags = TFLAGS },
992  { "width", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, .flags = TFLAGS },
993  { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, .flags = TFLAGS },
994  { "height", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, .flags = TFLAGS },
995  { "size", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
996  { "s", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
997  { "dither", "set dither type", OFFSET(dither), AV_OPT_TYPE_INT, {.i64 = 0}, 0, ZIMG_DITHER_ERROR_DIFFUSION, FLAGS, .unit = "dither" },
998  { "d", "set dither type", OFFSET(dither), AV_OPT_TYPE_INT, {.i64 = 0}, 0, ZIMG_DITHER_ERROR_DIFFUSION, FLAGS, .unit = "dither" },
999  { "none", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_NONE}, 0, 0, FLAGS, .unit = "dither" },
1000  { "ordered", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_ORDERED}, 0, 0, FLAGS, .unit = "dither" },
1001  { "random", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_RANDOM}, 0, 0, FLAGS, .unit = "dither" },
1002  { "error_diffusion", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_ERROR_DIFFUSION}, 0, 0, FLAGS, .unit = "dither" },
1003  { "filter", "set filter type", OFFSET(filter), AV_OPT_TYPE_INT, {.i64 = ZIMG_RESIZE_BILINEAR}, 0, ZIMG_RESIZE_LANCZOS, FLAGS, .unit = "filter" },
1004  { "f", "set filter type", OFFSET(filter), AV_OPT_TYPE_INT, {.i64 = ZIMG_RESIZE_BILINEAR}, 0, ZIMG_RESIZE_LANCZOS, FLAGS, .unit = "filter" },
1005  { "point", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_POINT}, 0, 0, FLAGS, .unit = "filter" },
1006  { "bilinear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_BILINEAR}, 0, 0, FLAGS, .unit = "filter" },
1007  { "bicubic", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_BICUBIC}, 0, 0, FLAGS, .unit = "filter" },
1008  { "spline16", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_SPLINE16}, 0, 0, FLAGS, .unit = "filter" },
1009  { "spline36", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_SPLINE36}, 0, 0, FLAGS, .unit = "filter" },
1010  { "lanczos", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_LANCZOS}, 0, 0, FLAGS, .unit = "filter" },
1011  { "out_range", "set color range", OFFSET(range), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
1012  { "range", "set color range", OFFSET(range), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
1013  { "r", "set color range", OFFSET(range), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
1014  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "range" },
1015  { "limited", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_LIMITED}, 0, 0, FLAGS, .unit = "range" },
1016  { "full", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_FULL}, 0, 0, FLAGS, .unit = "range" },
1017  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "range" },
1018  { "tv", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_LIMITED}, 0, 0, FLAGS, .unit = "range" },
1019  { "pc", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_FULL}, 0, 0, FLAGS, .unit = "range" },
1020  { "primaries", "set color primaries", OFFSET(primaries), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "primaries" },
1021  { "p", "set color primaries", OFFSET(primaries), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "primaries" },
1022  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "primaries" },
1023  { "709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_709}, 0, 0, FLAGS, .unit = "primaries" },
1024  { "unspecified", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_UNSPECIFIED}, 0, 0, FLAGS, .unit = "primaries" },
1025  { "170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_170M}, 0, 0, FLAGS, .unit = "primaries" },
1026  { "240m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_240M}, 0, 0, FLAGS, .unit = "primaries" },
1027  { "2020", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_2020}, 0, 0, FLAGS, .unit = "primaries" },
1028  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_UNSPECIFIED}, 0, 0, FLAGS, .unit = "primaries" },
1029  { "bt709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_709}, 0, 0, FLAGS, .unit = "primaries" },
1030  { "bt470m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_470_M}, 0, 0, FLAGS, .unit = "primaries" },
1031  { "bt470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_470_BG}, 0, 0, FLAGS, .unit = "primaries" },
1032  { "smpte170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_170M}, 0, 0, FLAGS, .unit = "primaries" },
1033  { "smpte240m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_240M}, 0, 0, FLAGS, .unit = "primaries" },
1034  { "film", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_FILM}, 0, 0, FLAGS, .unit = "primaries" },
1035  { "bt2020", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_2020}, 0, 0, FLAGS, .unit = "primaries" },
1036  { "smpte428", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_ST428}, 0, 0, FLAGS, .unit = "primaries" },
1037  { "smpte431", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_ST431_2}, 0, 0, FLAGS, .unit = "primaries" },
1038  { "smpte432", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_ST432_1}, 0, 0, FLAGS, .unit = "primaries" },
1039  { "jedec-p22", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_EBU3213_E}, 0, 0, FLAGS, .unit = "primaries" },
1040  { "ebu3213", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_EBU3213_E}, 0, 0, FLAGS, .unit = "primaries" },
1041  { "transfer", "set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "transfer" },
1042  { "t", "set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "transfer" },
1043  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "transfer" },
1044  { "709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_709}, 0, 0, FLAGS, .unit = "transfer" },
1045  { "unspecified", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_UNSPECIFIED}, 0, 0, FLAGS, .unit = "transfer" },
1046  { "601", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_601}, 0, 0, FLAGS, .unit = "transfer" },
1047  { "linear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LINEAR}, 0, 0, FLAGS, .unit = "transfer" },
1048  { "2020_10", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_10}, 0, 0, FLAGS, .unit = "transfer" },
1049  { "2020_12", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_12}, 0, 0, FLAGS, .unit = "transfer" },
1050  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_UNSPECIFIED}, 0, 0, FLAGS, .unit = "transfer" },
1051  { "bt470m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_470_M}, 0, 0, FLAGS, .unit = "transfer" },
1052  { "bt470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_470_BG}, 0, 0, FLAGS, .unit = "transfer" },
1053  { "smpte170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_601}, 0, 0, FLAGS, .unit = "transfer" },
1054  { "smpte240m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_240M}, 0, 0, FLAGS, .unit = "transfer" },
1055  { "bt709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_709}, 0, 0, FLAGS, .unit = "transfer" },
1056  { "linear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LINEAR}, 0, 0, FLAGS, .unit = "transfer" },
1057  { "log100", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LOG_100}, 0, 0, FLAGS, .unit = "transfer" },
1058  { "log316", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LOG_316}, 0, 0, FLAGS, .unit = "transfer" },
1059  { "bt2020-10", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_10}, 0, 0, FLAGS, .unit = "transfer" },
1060  { "bt2020-12", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_12}, 0, 0, FLAGS, .unit = "transfer" },
1061  { "smpte2084", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_ST2084}, 0, 0, FLAGS, .unit = "transfer" },
1062  { "iec61966-2-4", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_IEC_61966_2_4},0, 0, FLAGS, .unit = "transfer" },
1063  { "iec61966-2-1", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_IEC_61966_2_1},0, 0, FLAGS, .unit = "transfer" },
1064  { "arib-std-b67", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_ARIB_B67}, 0, 0, FLAGS, .unit = "transfer" },
1065  { "matrix", "set colorspace matrix", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "matrix" },
1066  { "m", "set colorspace matrix", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "matrix" },
1067  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "matrix" },
1068  { "709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_709}, 0, 0, FLAGS, .unit = "matrix" },
1069  { "unspecified", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_UNSPECIFIED}, 0, 0, FLAGS, .unit = "matrix" },
1070  { "470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_470BG}, 0, 0, FLAGS, .unit = "matrix" },
1071  { "170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_170M}, 0, 0, FLAGS, .unit = "matrix" },
1072  { "2020_ncl", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_NCL}, 0, 0, FLAGS, .unit = "matrix" },
1073  { "2020_cl", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_CL}, 0, 0, FLAGS, .unit = "matrix" },
1074  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_UNSPECIFIED}, 0, 0, FLAGS, .unit = "matrix" },
1075  { "gbr", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_RGB}, 0, 0, FLAGS, .unit = "matrix" },
1076  { "bt709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_709}, 0, 0, FLAGS, .unit = "matrix" },
1077  { "fcc", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_FCC}, 0, 0, FLAGS, .unit = "matrix" },
1078  { "bt470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_470BG}, 0, 0, FLAGS, .unit = "matrix" },
1079  { "smpte170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_170M}, 0, 0, FLAGS, .unit = "matrix" },
1080  { "smpte240m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_240M}, 0, 0, FLAGS, .unit = "matrix" },
1081  { "ycgco", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_YCGCO}, 0, 0, FLAGS, .unit = "matrix" },
1082  { "bt2020nc", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_NCL}, 0, 0, FLAGS, .unit = "matrix" },
1083  { "bt2020c", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_CL}, 0, 0, FLAGS, .unit = "matrix" },
1084  { "chroma-derived-nc",0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_CHROMATICITY_DERIVED_NCL}, 0, 0, FLAGS, .unit = "matrix" },
1085  { "chroma-derived-c", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_CHROMATICITY_DERIVED_CL}, 0, 0, FLAGS, .unit = "matrix" },
1086  { "ictcp", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_ICTCP}, 0, 0, FLAGS, .unit = "matrix" },
1087  { "in_range", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
1088  { "rangein", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
1089  { "rin", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
1090  { "primariesin", "set input color primaries", OFFSET(primaries_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "primaries" },
1091  { "pin", "set input color primaries", OFFSET(primaries_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "primaries" },
1092  { "transferin", "set input transfer characteristic", OFFSET(trc_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "transfer" },
1093  { "tin", "set input transfer characteristic", OFFSET(trc_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "transfer" },
1094  { "matrixin", "set input colorspace matrix", OFFSET(colorspace_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "matrix" },
1095  { "min", "set input colorspace matrix", OFFSET(colorspace_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "matrix" },
1096  { "chromal", "set output chroma location", OFFSET(chromal), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, .unit = "chroma" },
1097  { "c", "set output chroma location", OFFSET(chromal), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, .unit = "chroma" },
1098  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "chroma" },
1099  { "left", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_LEFT}, 0, 0, FLAGS, .unit = "chroma" },
1100  { "center", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_CENTER}, 0, 0, FLAGS, .unit = "chroma" },
1101  { "topleft", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_TOP_LEFT}, 0, 0, FLAGS, .unit = "chroma" },
1102  { "top", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_TOP}, 0, 0, FLAGS, .unit = "chroma" },
1103  { "bottomleft",0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_BOTTOM_LEFT}, 0, 0, FLAGS, .unit = "chroma" },
1104  { "bottom", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_BOTTOM}, 0, 0, FLAGS, .unit = "chroma" },
1105  { "chromalin", "set input chroma location", OFFSET(chromal_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, .unit = "chroma" },
1106  { "cin", "set input chroma location", OFFSET(chromal_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, .unit = "chroma" },
1107  { "npl", "set nominal peak luminance", OFFSET(nominal_peak_luminance), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, 0, DBL_MAX, FLAGS },
1108  { "agamma", "allow approximate gamma", OFFSET(approximate_gamma), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
1109  { "param_a", "parameter A, which is parameter \"b\" for bicubic, "
1110  "and the number of filter taps for lanczos", OFFSET(param_a), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, -DBL_MAX, DBL_MAX, FLAGS },
1111  { "param_b", "parameter B, which is parameter \"c\" for bicubic", OFFSET(param_b), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, -DBL_MAX, DBL_MAX, FLAGS },
1112  { NULL }
1113 };
1114 
1115 AVFILTER_DEFINE_CLASS(zscale);
1116 
1118  {
1119  .name = "default",
1120  .type = AVMEDIA_TYPE_VIDEO,
1121  .filter_frame = filter_frame,
1122  },
1123 };
1124 
1126  {
1127  .name = "default",
1128  .type = AVMEDIA_TYPE_VIDEO,
1129  .config_props = config_props,
1130  },
1131 };
1132 
1134  .name = "zscale",
1135  .description = NULL_IF_CONFIG_SMALL("Apply resizing, colorspace and bit depth conversion."),
1136  .init = init,
1137  .priv_size = sizeof(ZScaleContext),
1138  .priv_class = &zscale_class,
1139  .uninit = uninit,
1143  .process_command = process_command,
1144  .flags = AVFILTER_FLAG_SLICE_THREADS,
1145 };
formats
formats
Definition: signature.h:48
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:112
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:522
AVFrame::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: frame.h:627
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:501
AVFrame::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:623
td
#define td
Definition: regdef.h:70
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
av_clip
#define av_clip
Definition: common.h:98
ZScaleContext::jobs_ret
int jobs_ret[MAX_THREADS]
Definition: vf_zscale.c:122
ZScaleContext::range_in
int range_in
Definition: vf_zscale.c:101
AVERROR
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
opt.h
var_name
var_name
Definition: noise.c:46
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:435
ZScaleContext::colorspace_in
int colorspace_in
Definition: vf_zscale.c:98
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:580
convert_range_from_zimg
static enum AVColorRange convert_range_from_zimg(enum zimg_pixel_range_e color_range)
Definition: vf_zscale.c:523
ThreadData::odesc
const AVPixFmtDescriptor * odesc
Definition: vf_zscale.c:138
out
FILE * out
Definition: movenc.c:54
av_frame_get_buffer
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
Definition: frame.c:258
ZScaleContext::out_slice_end
int out_slice_end[MAX_THREADS]
Definition: vf_zscale.c:126
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_zscale.c:945
ZScaleContext::params_tmp
zimg_graph_builder_params params_tmp
Definition: vf_zscale.c:133
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2962
AVCOL_TRC_LINEAR
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition: pixfmt.h:589
AVCHROMA_LOC_BOTTOM
@ AVCHROMA_LOC_BOTTOM
Definition: pixfmt.h:709
ZScaleContext::h_expr
char * h_expr
height expression string
Definition: vf_zscale.c:110
ZScaleContext::filter
int filter
Definition: vf_zscale.c:92
ZIMG_ALIGNMENT
#define ZIMG_ALIGNMENT
Definition: vf_zscale.c:47
int64_t
long long int64_t
Definition: coverity.c:34
inlink
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
Definition: filter_design.txt:212
AV_PIX_FMT_FLAG_FLOAT
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:158
AVFrame::color_primaries
enum AVColorPrimaries color_primaries
Definition: frame.h:625
ZScaleContext::alpha_params_tmp
zimg_graph_builder_params alpha_params_tmp
Definition: vf_zscale.c:133
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:130
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:514
AVFrame::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:634
ZScaleContext::chromal
int chromal
Definition: vf_zscale.c:97
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
VAR_VSUB
@ VAR_VSUB
Definition: vf_zscale.c:75
pixdesc.h
TFLAGS
#define TFLAGS
Definition: vf_zscale.c:988
var_names
static const char *const var_names[]
Definition: vf_zscale.c:51
AVFrame::width
int width
Definition: frame.h:416
config_props
static int config_props(AVFilterLink *outlink)
Definition: vf_zscale.c:262
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:521
w
uint8_t w
Definition: llviddspenc.c:38
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:683
ZScaleContext::colorspace
int colorspace
Definition: vf_zscale.c:93
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:57
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:516
ZScaleContext::alpha_src_format
zimg_image_format alpha_src_format
Definition: vf_zscale.c:129
AVOption
AVOption.
Definition: opt.h:346
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:583
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
data
const char data[16]
Definition: mxf.c:148
AVComponentDescriptor::step
int step
Number of elements between 2 horizontally consecutive pixels.
Definition: pixdesc.h:40
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:478
AVCOL_PRI_JEDEC_P22
@ AVCOL_PRI_JEDEC_P22
Definition: pixfmt.h:572
format_init
static void format_init(zimg_image_format *format, AVFrame *frame, const AVPixFmtDescriptor *desc, int colorspace, int primaries, int transfer, int range, int location)
Definition: vf_zscale.c:579
ThreadData::desc
const AVPixFmtDescriptor * desc
Definition: vf_tonemap.c:175
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:610
float.h
AVCOL_TRC_BT2020_12
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
Definition: pixfmt.h:596
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_amplify.c:51
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
max
#define max(a, b)
Definition: cuda_runtime.h:33
mathematics.h
filter
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
Definition: filter_design.txt:228
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
zscale_options
static const AVOption zscale_options[]
Definition: vf_zscale.c:990
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:555
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
av_float2int
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
Definition: intfloat.h:50
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:526
video.h
ThreadData::in
AVFrame * in
Definition: af_adecorrelate.c:153
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:517
ZScaleContext::h
int h
Definition: vf_zscale.c:90
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:621
ff_make_formats_list_singleton
AVFilterFormats * ff_make_formats_list_singleton(int fmt)
Equivalent to ff_make_format_list({const int[]}{ fmt, -1 })
Definition: formats.c:529
ZScaleContext::primaries
int primaries
Definition: vf_zscale.c:95
ZScaleContext::nb_threads
int nb_threads
Definition: vf_zscale.c:121
ZScaleContext::in_h_chr_pos
int in_h_chr_pos
Definition: vf_zscale.c:114
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
ZScaleContext::param_b
double param_b
Definition: vf_zscale.c:107
VAR_OUT_W
@ VAR_OUT_W
Definition: vf_zscale.c:69
primaries
enum AVColorPrimaries primaries
Definition: mediacodec_wrapper.c:2575
AVFrame::chroma_location
enum AVChromaLocation chroma_location
Definition: frame.h:636
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3002
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:615
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:513
convert_primaries
static int convert_primaries(enum AVColorPrimaries color_primaries)
Definition: vf_zscale.c:480
ZScaleContext::out_slice_start
int out_slice_start[MAX_THREADS]
Definition: vf_zscale.c:125
ZScaleContext::dst_format
zimg_image_format dst_format
Definition: vf_zscale.c:128
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:496
AVCOL_TRC_IEC61966_2_1
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:594
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
ZScaleContext::src_format
zimg_image_format src_format
Definition: vf_zscale.c:128
fail
#define fail()
Definition: checkasm.h:179
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:494
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:523
ZScaleContext::range
int range
Definition: vf_zscale.c:96
VAR_OW
@ VAR_OW
Definition: vf_zscale.c:69
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:476
AVCOL_TRC_GAMMA28
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition: pixfmt.h:586
convert_matrix
static int convert_matrix(enum AVColorSpace colorspace)
Definition: vf_zscale.c:410
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_zscale.c:192
ZScaleContext::alpha_params
zimg_graph_builder_params alpha_params
Definition: vf_zscale.c:132
av_opt_set
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:738
AVCOL_TRC_LOG_SQRT
@ AVCOL_TRC_LOG_SQRT
"Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
Definition: pixfmt.h:591
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
AVRational::num
int num
Numerator.
Definition: rational.h:59
AVCOL_TRC_GAMMA22
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:585
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_zscale.c:962
VAR_SAR
@ VAR_SAR
Definition: vf_zscale.c:72
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:118
compare_zimg_graph_builder_params
static int compare_zimg_graph_builder_params(zimg_graph_builder_params *parm0, zimg_graph_builder_params *parm1)
Definition: vf_zscale.c:556
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:481
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:283
aligned
static int aligned(int val)
Definition: dashdec.c:170
ZScaleContext::tmp
void * tmp[MAX_THREADS]
Definition: vf_zscale.c:120
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:206
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:490
ZScaleContext::graph
zimg_filter_graph * graph[MAX_THREADS]
Definition: vf_zscale.c:134
ZScaleContext::alpha_dst_format_tmp
zimg_image_format alpha_dst_format_tmp
Definition: vf_zscale.c:131
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:86
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:498
ZScaleContext::param_a
double param_a
Definition: vf_zscale.c:106
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVCHROMA_LOC_TOP
@ AVCHROMA_LOC_TOP
Definition: pixfmt.h:707
AV_PIX_FMT_GBRAP14
#define AV_PIX_FMT_GBRAP14
Definition: pixfmt.h:500
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:499
ZScaleContext
Definition: vf_zscale.c:81
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
graphs_build
static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *desc, const AVPixFmtDescriptor *out_desc, AVFilterContext *ctx, int job_nr, int n_jobs)
Definition: vf_zscale.c:596
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:491
ZScaleContext::force_original_aspect_ratio
int force_original_aspect_ratio
Definition: vf_zscale.c:118
format
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 format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:616
approximate_gamma
static const double approximate_gamma[AVCOL_TRC_NB]
Definition: csp.c:135
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:237
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:678
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:1725
ZScaleContext::src_format_tmp
zimg_image_format src_format_tmp
Definition: vf_zscale.c:130
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:520
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:475
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:489
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AVCOL_PRI_SMPTE428
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
Definition: pixfmt.h:567
ZScaleContext::first_time
int first_time
Definition: vf_zscale.c:117
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
VAR_A
@ VAR_A
Definition: vf_zscale.c:71
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
ZScaleContext::dst_format_tmp
zimg_image_format dst_format_tmp
Definition: vf_zscale.c:130
AVCOL_PRI_SMPTE240M
@ AVCOL_PRI_SMPTE240M
identical to above, also called "SMPTE C" even though it uses D65
Definition: pixfmt.h:564
color_range
color_range
Definition: vf_selectivecolor.c:43
ZScaleContext::in_slice_start
double in_slice_start[MAX_THREADS]
Definition: vf_zscale.c:123
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:558
NAN
#define NAN
Definition: mathematics.h:115
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
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 link
Definition: filter_design.txt:23
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:87
AVCOL_SPC_CHROMA_DERIVED_CL
@ AVCOL_SPC_CHROMA_DERIVED_CL
Chromaticity-derived constant luminance system.
Definition: pixfmt.h:624
AVCOL_PRI_BT470BG
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:562
frame
static AVFrame * frame
Definition: demux_decode.c:54
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:563
if
if(ret)
Definition: filter_design.txt:179
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:497
ZScaleContext::params
zimg_graph_builder_params params
Definition: vf_zscale.c:132
print_zimg_error
static int print_zimg_error(AVFilterContext *ctx)
Definition: vf_zscale.c:380
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:679
realign_frame
static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy)
Definition: vf_zscale.c:664
FLAGS
#define FLAGS
Definition: vf_zscale.c:987
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:704
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVCHROMA_LOC_TOPLEFT
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition: pixfmt.h:706
AVCOL_TRC_IEC61966_2_4
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
Definition: pixfmt.h:592
isnan
#define isnan(x)
Definition: libm.h:340
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:85
compare_zimg_image_formats
static int compare_zimg_image_formats(zimg_image_format *img_fmt0, zimg_image_format *img_fmt1)
Definition: vf_zscale.c:535
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:415
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:557
parseutils.h
slice_params
static void slice_params(ZScaleContext *s, int out_h, int in_h)
Definition: vf_zscale.c:247
convert_range
static int convert_range(enum AVColorRange color_range)
Definition: vf_zscale.c:511
ZScaleContext::out_v_chr_pos
int out_v_chr_pos
Definition: vf_zscale.c:113
double
double
Definition: af_crystalizer.c:131
AVCOL_TRC_BT2020_10
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:595
AVCOL_SPC_YCGCO
@ AVCOL_SPC_YCGCO
used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
Definition: pixfmt.h:618
ZScaleContext::dither
int dither
Definition: vf_zscale.c:91
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:479
update_output_color_information
static void update_output_color_information(ZScaleContext *s, AVFrame *frame)
Definition: vf_zscale.c:703
ff_vf_zscale
const AVFilter ff_vf_zscale
Definition: vf_zscale.c:1133
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:493
ff_all_color_spaces
AVFilterFormats * ff_all_color_spaces(void)
Construct an AVFilterFormats representing all possible color spaces.
Definition: formats.c:630
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:649
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:566
color_primaries
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
Definition: csp.c:76
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:597
AVCOL_PRI_SMPTE431
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
Definition: pixfmt.h:569
ZScaleContext::in_v_chr_pos
int in_v_chr_pos
Definition: vf_zscale.c:115
eval.h
f
f
Definition: af_crystalizer.c:121
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
av_expr_parse_and_eval
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
Definition: eval.c:804
AVCOL_TRC_SMPTE240M
@ AVCOL_TRC_SMPTE240M
Definition: pixfmt.h:588
AVCOL_PRI_FILM
@ AVCOL_PRI_FILM
colour filters using Illuminant C
Definition: pixfmt.h:565
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:374
MAX_THREADS
#define MAX_THREADS
Definition: vf_zscale.c:49
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
av_frame_copy
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
Definition: frame.c:890
AVCOL_TRC_LOG
@ AVCOL_TRC_LOG
"Logarithmic transfer characteristic (100:1 range)"
Definition: pixfmt.h:590
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:508
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:483
size
int size
Definition: twinvq_data.h:10344
ZScaleContext::primaries_in
int primaries_in
Definition: vf_zscale.c:100
ZScaleContext::approximate_gamma
int approximate_gamma
Definition: vf_zscale.c:105
ZScaleContext::alpha_dst_format
zimg_image_format alpha_dst_format
Definition: vf_zscale.c:129
VAR_OHSUB
@ VAR_OHSUB
Definition: vf_zscale.c:76
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:485
filter_slice
static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
Definition: vf_zscale.c:715
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:703
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:431
range
enum AVColorRange range
Definition: mediacodec_wrapper.c:2557
VAR_IN_W
@ VAR_IN_W
Definition: vf_zscale.c:67
avfilter_vf_zscale_outputs
static const AVFilterPad avfilter_vf_zscale_outputs[]
Definition: vf_zscale.c:1125
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
ff_all_color_ranges
AVFilterFormats * ff_all_color_ranges(void)
Construct an AVFilterFormats representing all possible color ranges.
Definition: formats.c:646
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:518
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
av_parse_video_size
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
Parse str and put in width_ptr and height_ptr the detected values.
Definition: parseutils.c:150
VARS_NB
@ VARS_NB
Definition: vf_zscale.c:78
AVCOL_SPC_CHROMA_DERIVED_NCL
@ AVCOL_SPC_CHROMA_DERIVED_NCL
Chromaticity-derived non-constant luminance system.
Definition: pixfmt.h:623
VAR_HSUB
@ VAR_HSUB
Definition: vf_zscale.c:74
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:582
internal.h
AVChromaLocation
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:702
AVCOL_SPC_SMPTE240M
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
Definition: pixfmt.h:617
ZScaleContext::in_slice_end
double in_slice_end[MAX_THREADS]
Definition: vf_zscale.c:124
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:620
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_zscale.c:779
transfer
enum AVColorTransferCharacteristic transfer
Definition: mediacodec_wrapper.c:2585
internal.h
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:495
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:609
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:825
ThreadData
Used for passing data between threads.
Definition: dsddec.c:69
VAR_IW
@ VAR_IW
Definition: vf_zscale.c:67
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
ZScaleContext::w
int w
New dimensions.
Definition: vf_zscale.c:90
ZScaleContext::trc
int trc
Definition: vf_zscale.c:94
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:107
VAR_OH
@ VAR_OH
Definition: vf_zscale.c:70
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:612
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
ZScaleContext::chromal_in
int chromal_in
Definition: vf_zscale.c:102
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:666
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:477
AVFilter
Filter definition.
Definition: avfilter.h:166
VAR_IH
@ VAR_IH
Definition: vf_zscale.c:68
AVCOL_PRI_BT470M
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:560
ret
ret
Definition: filter_design.txt:187
ZScaleContext::trc_in
int trc_in
Definition: vf_zscale.c:99
ZScaleContext::size_str
char * size_str
Definition: vf_zscale.c:103
FFSWAP
#define FFSWAP(type, a, b)
Definition: macros.h:52
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:515
convert_chroma_location
static int convert_chroma_location(enum AVChromaLocation chroma_location)
Definition: vf_zscale.c:390
AVFrame::sample_aspect_ratio
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:451
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:482
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:487
AVFrame::height
int height
Definition: frame.h:416
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:601
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_zscale.c:142
AVCHROMA_LOC_CENTER
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
Definition: pixfmt.h:705
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AVCOL_SPC_FCC
@ AVCOL_SPC_FCC
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:614
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:519
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
avfilter.h
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:509
VAR_IN_H
@ VAR_IN_H
Definition: vf_zscale.c:68
VAR_OVSUB
@ VAR_OVSUB
Definition: vf_zscale.c:77
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
AVCOL_TRC_SMPTE170M
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
Definition: pixfmt.h:587
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
OFFSET
#define OFFSET(x)
Definition: vf_zscale.c:986
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
ZScaleContext::alpha_graph
zimg_filter_graph * alpha_graph[MAX_THREADS]
Definition: vf_zscale.c:134
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
desc
const char * desc
Definition: libsvtav1.c:75
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
MIN_TILESIZE
#define MIN_TILESIZE
Definition: vf_zscale.c:48
convert_trc
static int convert_trc(enum AVColorTransferCharacteristic color_trc)
Definition: vf_zscale.c:443
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
AVCOL_PRI_SMPTE432
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
Definition: pixfmt.h:570
planes
static const struct @386 planes[]
ZScaleContext::alpha_src_format_tmp
zimg_image_format alpha_src_format_tmp
Definition: vf_zscale.c:131
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
VAR_DAR
@ VAR_DAR
Definition: vf_zscale.c:73
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(zscale)
ZScaleContext::nominal_peak_luminance
double nominal_peak_luminance
Definition: vf_zscale.c:104
h
h
Definition: vp9dsp_template.c:2038
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:488
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:134
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:611
AVColorRange
AVColorRange
Visual content value range.
Definition: pixfmt.h:648
int
int
Definition: ffmpeg_filter.c:409
AVCOL_SPC_ICTCP
@ AVCOL_SPC_ICTCP
ITU-R BT.2100-0, ICtCp.
Definition: pixfmt.h:625
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
snprintf
#define snprintf
Definition: snprintf.h:34
VAR_OUT_H
@ VAR_OUT_H
Definition: vf_zscale.c:70
ZScaleContext::out_h_chr_pos
int out_h_chr_pos
Definition: vf_zscale.c:112
AVCHROMA_LOC_BOTTOMLEFT
@ AVCHROMA_LOC_BOTTOMLEFT
Definition: pixfmt.h:708
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:173
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:486
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2882
ZScaleContext::w_expr
char * w_expr
width expression string
Definition: vf_zscale.c:109
avfilter_vf_zscale_inputs
static const AVFilterPad avfilter_vf_zscale_inputs[]
Definition: vf_zscale.c:1117
AV_WN16
#define AV_WN16(p, v)
Definition: intreadwrite.h:370
dither
static const uint8_t dither[8][8]
Definition: vf_fspp.c:60