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 "filters.h"
35 #include "formats.h"
36 #include "video.h"
37 #include "libavutil/eval.h"
38 #include "libavutil/internal.h"
39 #include "libavutil/intfloat.h"
40 #include "libavutil/intreadwrite.h"
41 #include "libavutil/mathematics.h"
42 #include "libavutil/mem.h"
43 #include "libavutil/opt.h"
44 #include "libavutil/parseutils.h"
45 #include "libavutil/pixdesc.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 
114 
115  void *tmp[MAX_THREADS]; //separate for each thread;
122 
123  zimg_image_format src_format, dst_format;
124  zimg_image_format src_format_tmp, dst_format_tmp;
125  zimg_graph_builder_params params;
126  zimg_graph_builder_params params_tmp;
127  zimg_filter_graph *graph[MAX_THREADS];
128 } ZScaleContext;
129 
130 typedef struct ThreadData {
132  AVFrame *in, *out;
133 } ThreadData;
134 
136 {
137  ZScaleContext *s = ctx->priv;
138  int ret;
139  zimg_image_format_default(&s->src_format, ZIMG_API_VERSION);
140  zimg_image_format_default(&s->dst_format, ZIMG_API_VERSION);
141  zimg_image_format_default(&s->src_format_tmp, ZIMG_API_VERSION);
142  zimg_image_format_default(&s->dst_format_tmp, ZIMG_API_VERSION);
143 
144  zimg_graph_builder_params_default(&s->params, ZIMG_API_VERSION);
145  zimg_graph_builder_params_default(&s->params_tmp, ZIMG_API_VERSION);
146 
147  if (s->size_str && (s->w_expr || s->h_expr)) {
149  "Size and width/height expressions cannot be set at the same time.\n");
150  return AVERROR(EINVAL);
151  }
152 
153  if (s->w_expr && !s->h_expr)
154  FFSWAP(char *, s->w_expr, s->size_str);
155 
156  if (s->size_str) {
157  char buf[32];
158  if ((ret = av_parse_video_size(&s->w, &s->h, s->size_str)) < 0) {
160  "Invalid size '%s'\n", s->size_str);
161  return ret;
162  }
163  snprintf(buf, sizeof(buf)-1, "%d", s->w);
164  av_opt_set(s, "w", buf, 0);
165  snprintf(buf, sizeof(buf)-1, "%d", s->h);
166  av_opt_set(s, "h", buf, 0);
167  }
168  if (!s->w_expr)
169  av_opt_set(s, "w", "iw", 0);
170  if (!s->h_expr)
171  av_opt_set(s, "h", "ih", 0);
172 
173  return 0;
174 }
175 
176 static enum AVColorRange convert_range_from_zimg(enum zimg_pixel_range_e color_range);
177 
179  AVFilterFormatsConfig **cfg_in,
180  AVFilterFormatsConfig **cfg_out)
181 {
182  const ZScaleContext *s = ctx->priv;
184  static const enum AVPixelFormat pixel_fmts[] = {
208  };
209  int ret;
210 
212  if (ret < 0)
213  return ret;
215  if (ret < 0)
216  return ret;
217 
218  if ((ret = ff_formats_ref(ff_all_color_spaces(), &cfg_in[0]->color_spaces)) < 0 ||
219  (ret = ff_formats_ref(ff_all_color_ranges(), &cfg_in[0]->color_ranges)) < 0)
220  return ret;
221 
222  formats = s->colorspace != ZIMG_MATRIX_UNSPECIFIED && s->colorspace > 0
223  ? ff_make_formats_list_singleton(s->colorspace)
225  if ((ret = ff_formats_ref(formats, &cfg_out[0]->color_spaces)) < 0)
226  return ret;
227 
228  formats = s->range != -1
231  if ((ret = ff_formats_ref(formats, &cfg_out[0]->color_ranges)) < 0)
232  return ret;
233 
234  if ((ret = ff_formats_ref(ff_all_alpha_modes(), &cfg_in[0]->alpha_modes)) < 0 ||
235  (ret = ff_formats_ref(ff_all_alpha_modes(), &cfg_out[0]->alpha_modes)) < 0)
236  return ret;
237 
238  return 0;
239 }
240 
241 static void slice_params(ZScaleContext *s, int out_h, int in_h)
242 {
243  s->out_slice_start[0] = 0;
244  for (int i = 1; i < s->nb_threads; i++) {
245  int slice_end = out_h * i / s->nb_threads;
246  s->out_slice_end[i - 1] = s->out_slice_start[i] = FFALIGN(slice_end, 2);
247  }
248  s->out_slice_end[s->nb_threads - 1] = out_h;
249 
250  for (int i = 0; i < s->nb_threads; i++) {
251  s->in_slice_start[i] = s->out_slice_start[i] * in_h / (double)out_h;
252  s->in_slice_end[i] = s->out_slice_end[i] * in_h / (double)out_h;
253  }
254 }
255 
256 static int config_props(AVFilterLink *outlink)
257 {
258  AVFilterContext *ctx = outlink->src;
259  AVFilterLink *inlink = outlink->src->inputs[0];
260  ZScaleContext *s = ctx->priv;
262  const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(outlink->format);
263  int64_t w, h;
264  double var_values[VARS_NB], res;
265  char *expr;
266  int ret;
267  int factor_w, factor_h;
268 
269  var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w;
270  var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h;
271  var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN;
272  var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN;
273  var_values[VAR_A] = (double) inlink->w / inlink->h;
274  var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ?
275  (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
276  var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
277  var_values[VAR_HSUB] = 1 << desc->log2_chroma_w;
278  var_values[VAR_VSUB] = 1 << desc->log2_chroma_h;
279  var_values[VAR_OHSUB] = 1 << out_desc->log2_chroma_w;
280  var_values[VAR_OVSUB] = 1 << out_desc->log2_chroma_h;
281 
282  /* evaluate width and height */
283  av_expr_parse_and_eval(&res, (expr = s->w_expr),
284  var_names, var_values,
285  NULL, NULL, NULL, NULL, NULL, 0, ctx);
286  s->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res;
287  if ((ret = av_expr_parse_and_eval(&res, (expr = s->h_expr),
288  var_names, var_values,
289  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
290  goto fail;
291  s->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res;
292  /* evaluate again the width, as it may depend on the output height */
293  if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr),
294  var_names, var_values,
295  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
296  goto fail;
297  s->w = res;
298 
299  w = s->w;
300  h = s->h;
301 
302  /* Check if it is requested that the result has to be divisible by a some
303  * factor (w or h = -n with n being the factor). */
304  factor_w = 1;
305  factor_h = 1;
306  if (w < -1) {
307  factor_w = -w;
308  }
309  if (h < -1) {
310  factor_h = -h;
311  }
312 
313  if (w < 0 && h < 0)
314  s->w = s->h = 0;
315 
316  if (!(w = s->w))
317  w = inlink->w;
318  if (!(h = s->h))
319  h = inlink->h;
320 
321  /* Make sure that the result is divisible by the factor we determined
322  * earlier. If no factor was set, it is nothing will happen as the default
323  * factor is 1 */
324  if (w < 0)
325  w = av_rescale(h, inlink->w, inlink->h * factor_w) * factor_w;
326  if (h < 0)
327  h = av_rescale(w, inlink->h, inlink->w * factor_h) * factor_h;
328 
329  /* Note that force_original_aspect_ratio may overwrite the previous set
330  * dimensions so that it is not divisible by the set factors anymore. */
331  if (s->force_original_aspect_ratio) {
332  int tmp_w = av_rescale(h, inlink->w, inlink->h);
333  int tmp_h = av_rescale(w, inlink->h, inlink->w);
334 
335  if (s->force_original_aspect_ratio == 1) {
336  w = FFMIN(tmp_w, w);
337  h = FFMIN(tmp_h, h);
338  } else {
339  w = FFMAX(tmp_w, w);
340  h = FFMAX(tmp_h, h);
341  }
342  }
343 
344  if (w > INT_MAX || h > INT_MAX ||
345  (h * inlink->w) > INT_MAX ||
346  (w * inlink->h) > INT_MAX)
347  av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
348 
349  outlink->w = w;
350  outlink->h = h;
351 
352  s->first_time = 1;
353 
354  if (inlink->sample_aspect_ratio.num){
355  outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio);
356  } else
357  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
358 
359  av_log(ctx, AV_LOG_DEBUG, "w:%d h:%d fmt:%s csp:%s range:%s sar:%d/%d -> w:%d h:%d fmt:%s csp:%s range:%s sar:%d/%d\n",
360  inlink ->w, inlink ->h, av_get_pix_fmt_name( inlink->format),
361  av_color_space_name(inlink->colorspace), av_color_range_name(inlink->color_range),
362  inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den,
363  outlink->w, outlink->h, av_get_pix_fmt_name(outlink->format),
365  outlink->sample_aspect_ratio.num, outlink->sample_aspect_ratio.den);
366  return 0;
367 
368 fail:
370  "Error when evaluating the expression '%s'.\n"
371  "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
372  expr, s->w_expr, s->h_expr);
373  return ret;
374 }
375 
377 {
378  char err_msg[1024];
379  int err_code = zimg_get_last_error(err_msg, sizeof(err_msg));
380 
381  av_log(ctx, AV_LOG_ERROR, "code %d: %s\n", err_code, err_msg);
382 
383  return AVERROR_EXTERNAL;
384 }
385 
386 static int convert_chroma_location(enum AVChromaLocation chroma_location)
387 {
388  switch (chroma_location) {
390  case AVCHROMA_LOC_LEFT:
391  return ZIMG_CHROMA_LEFT;
392  case AVCHROMA_LOC_CENTER:
393  return ZIMG_CHROMA_CENTER;
395  return ZIMG_CHROMA_TOP_LEFT;
396  case AVCHROMA_LOC_TOP:
397  return ZIMG_CHROMA_TOP;
399  return ZIMG_CHROMA_BOTTOM_LEFT;
400  case AVCHROMA_LOC_BOTTOM:
401  return ZIMG_CHROMA_BOTTOM;
402  }
403  return ZIMG_CHROMA_LEFT;
404 }
405 
406 static int convert_matrix(enum AVColorSpace colorspace)
407 {
408  switch (colorspace) {
409  case AVCOL_SPC_RGB:
410  return ZIMG_MATRIX_RGB;
411  case AVCOL_SPC_BT709:
412  return ZIMG_MATRIX_709;
414  return ZIMG_MATRIX_UNSPECIFIED;
415  case AVCOL_SPC_FCC:
416  return ZIMG_MATRIX_FCC;
417  case AVCOL_SPC_BT470BG:
418  return ZIMG_MATRIX_470BG;
419  case AVCOL_SPC_SMPTE170M:
420  return ZIMG_MATRIX_170M;
421  case AVCOL_SPC_SMPTE240M:
422  return ZIMG_MATRIX_240M;
423  case AVCOL_SPC_YCGCO:
424  return ZIMG_MATRIX_YCGCO;
426  return ZIMG_MATRIX_2020_NCL;
427  case AVCOL_SPC_BT2020_CL:
428  return ZIMG_MATRIX_2020_CL;
430  return ZIMG_MATRIX_CHROMATICITY_DERIVED_NCL;
432  return ZIMG_MATRIX_CHROMATICITY_DERIVED_CL;
433  case AVCOL_SPC_ICTCP:
434  return ZIMG_MATRIX_ICTCP;
435  }
436  return ZIMG_MATRIX_UNSPECIFIED;
437 }
438 
439 static int convert_trc(enum AVColorTransferCharacteristic color_trc)
440 {
441  switch (color_trc) {
443  return ZIMG_TRANSFER_UNSPECIFIED;
444  case AVCOL_TRC_BT709:
445  return ZIMG_TRANSFER_709;
446  case AVCOL_TRC_GAMMA22:
447  return ZIMG_TRANSFER_470_M;
448  case AVCOL_TRC_GAMMA28:
449  return ZIMG_TRANSFER_470_BG;
450  case AVCOL_TRC_SMPTE170M:
451  return ZIMG_TRANSFER_601;
452  case AVCOL_TRC_SMPTE240M:
453  return ZIMG_TRANSFER_240M;
454  case AVCOL_TRC_LINEAR:
455  return ZIMG_TRANSFER_LINEAR;
456  case AVCOL_TRC_LOG:
457  return ZIMG_TRANSFER_LOG_100;
458  case AVCOL_TRC_LOG_SQRT:
459  return ZIMG_TRANSFER_LOG_316;
461  return ZIMG_TRANSFER_IEC_61966_2_4;
462  case AVCOL_TRC_BT2020_10:
463  return ZIMG_TRANSFER_2020_10;
464  case AVCOL_TRC_BT2020_12:
465  return ZIMG_TRANSFER_2020_12;
466  case AVCOL_TRC_SMPTE2084:
467  return ZIMG_TRANSFER_ST2084;
469  return ZIMG_TRANSFER_ARIB_B67;
471  return ZIMG_TRANSFER_IEC_61966_2_1;
472  }
473  return ZIMG_TRANSFER_UNSPECIFIED;
474 }
475 
477 {
478  switch (color_primaries) {
480  return ZIMG_PRIMARIES_UNSPECIFIED;
481  case AVCOL_PRI_BT709:
482  return ZIMG_PRIMARIES_709;
483  case AVCOL_PRI_BT470M:
484  return ZIMG_PRIMARIES_470_M;
485  case AVCOL_PRI_BT470BG:
486  return ZIMG_PRIMARIES_470_BG;
487  case AVCOL_PRI_SMPTE170M:
488  return ZIMG_PRIMARIES_170M;
489  case AVCOL_PRI_SMPTE240M:
490  return ZIMG_PRIMARIES_240M;
491  case AVCOL_PRI_FILM:
492  return ZIMG_PRIMARIES_FILM;
493  case AVCOL_PRI_BT2020:
494  return ZIMG_PRIMARIES_2020;
495  case AVCOL_PRI_SMPTE428:
496  return ZIMG_PRIMARIES_ST428;
497  case AVCOL_PRI_SMPTE431:
498  return ZIMG_PRIMARIES_ST431_2;
499  case AVCOL_PRI_SMPTE432:
500  return ZIMG_PRIMARIES_ST432_1;
501  case AVCOL_PRI_JEDEC_P22:
502  return ZIMG_PRIMARIES_EBU3213_E;
503  }
504  return ZIMG_PRIMARIES_UNSPECIFIED;
505 }
506 
508 {
509  switch (color_range) {
511  case AVCOL_RANGE_MPEG:
512  return ZIMG_RANGE_LIMITED;
513  case AVCOL_RANGE_JPEG:
514  return ZIMG_RANGE_FULL;
515  }
516  return ZIMG_RANGE_LIMITED;
517 }
518 
519 static enum AVColorRange convert_range_from_zimg(enum zimg_pixel_range_e color_range)
520 {
521  switch (color_range) {
522  case ZIMG_RANGE_LIMITED:
523  return AVCOL_RANGE_MPEG;
524  case ZIMG_RANGE_FULL:
525  return AVCOL_RANGE_JPEG;
526  }
528 }
529 
530 /* returns 0 if image formats are the same and 1 otherwise */
531 static int compare_zimg_image_formats(zimg_image_format *img_fmt0, zimg_image_format *img_fmt1)
532 {
533  return ((img_fmt0->chroma_location != img_fmt1->chroma_location) ||
534 #if ZIMG_API_VERSION >= 0x204
535  (img_fmt0->alpha != img_fmt1->alpha) ||
536 #endif
537  (img_fmt0->color_family != img_fmt1->color_family) ||
538  (img_fmt0->color_primaries != img_fmt1->color_primaries) ||
539  (img_fmt0->depth != img_fmt1->depth) ||
540  (img_fmt0->field_parity != img_fmt1->field_parity) ||
541  (img_fmt0->height != img_fmt1->height) ||
542  (img_fmt0->matrix_coefficients != img_fmt1->matrix_coefficients) ||
543  (img_fmt0->pixel_range != img_fmt1->pixel_range) ||
544  (img_fmt0->pixel_type != img_fmt1->pixel_type) ||
545  (img_fmt0->subsample_h != img_fmt1->subsample_h) ||
546  (img_fmt0->subsample_w != img_fmt1->subsample_w) ||
547  (img_fmt0->transfer_characteristics != img_fmt1->transfer_characteristics) ||
548  (img_fmt0->width != img_fmt1->width));
549 }
550 
551 /* returns 0 if graph builder parameters are the same and 1 otherwise */
552 static int compare_zimg_graph_builder_params(zimg_graph_builder_params *parm0, zimg_graph_builder_params *parm1)
553 {
554  /* the parameters that could be changed inside a single ffmpeg zscale invocation are checked only
555  and NaN values that are default for some params are treated properly*/
556  int ret = (parm0->allow_approximate_gamma != parm1->allow_approximate_gamma) ||
557  (parm0->dither_type != parm1->dither_type) ||
558  (parm0->resample_filter != parm1->resample_filter) ||
559  (parm0->resample_filter_uv != parm1->resample_filter_uv);
560 
561  if ((isnan(parm0->nominal_peak_luminance) == 0) || (isnan(parm1->nominal_peak_luminance) == 0))
562  ret = ret || (parm0->nominal_peak_luminance != parm1->nominal_peak_luminance);
563  if ((isnan(parm0->filter_param_a) == 0) || (isnan(parm1->filter_param_a) == 0))
564  ret = ret || (parm0->filter_param_a != parm1->filter_param_a);
565  if ((isnan(parm0->filter_param_a_uv) == 0) || (isnan(parm1->filter_param_a_uv) == 0))
566  ret = ret || (parm0->filter_param_a_uv != parm1->filter_param_a_uv);
567  if ((isnan(parm0->filter_param_b) == 0) || (isnan(parm1->filter_param_b) == 0))
568  ret = ret || (parm0->filter_param_b != parm1->filter_param_b);
569  if ((isnan(parm0->filter_param_b_uv) == 0) || (isnan(parm1->filter_param_b_uv) == 0))
570  ret = ret || (parm0->filter_param_b_uv != parm1->filter_param_b_uv);
571 
572  return ret;
573 }
574 
575 static void format_init(zimg_image_format *format, AVFrame *frame, const AVPixFmtDescriptor *desc,
576  int colorspace, int primaries, int transfer, int range, int location)
577 {
578  format->width = frame->width;
579  format->height = frame->height;
580  format->subsample_w = desc->log2_chroma_w;
581  format->subsample_h = desc->log2_chroma_h;
582  format->depth = desc->comp[0].depth;
583  format->pixel_type = (desc->flags & AV_PIX_FMT_FLAG_FLOAT) ? (desc->comp[0].depth > 16 ? ZIMG_PIXEL_FLOAT : ZIMG_PIXEL_HALF)
584  : (desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE);
585  format->color_family = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_COLOR_RGB
586  : (desc->nb_components > 1 ? ZIMG_COLOR_YUV : ZIMG_COLOR_GREY);
587  format->matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_MATRIX_RGB : colorspace == -1 ? convert_matrix(frame->colorspace) : colorspace;
588  format->color_primaries = primaries == -1 ? convert_primaries(frame->color_primaries) : primaries;
589  format->transfer_characteristics = transfer == -1 ? convert_trc(frame->color_trc) : transfer;
590  format->pixel_range = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_RANGE_FULL : range == -1 ? convert_range(frame->color_range) : range;
591  format->chroma_location = location == -1 ? convert_chroma_location(frame->chroma_location) : location;
592  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA)
593  format->alpha = frame->alpha_mode == AVALPHA_MODE_PREMULTIPLIED ? ZIMG_ALPHA_PREMULTIPLIED : ZIMG_ALPHA_STRAIGHT;
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  const double in_slice_start = s->in_slice_start[job_nr];
605  const double in_slice_end = s->in_slice_end[job_nr];
606  const int out_slice_start = s->out_slice_start[job_nr];
607  const int out_slice_end = s->out_slice_end[job_nr];
608 
609  src_format = s->src_format;
610  dst_format = s->dst_format;
611  /* The input slice is specified through the active_region field,
612  unlike the output slice.
613  according to zimg requirements input and output slices should have even dimensions */
614  src_format.active_region.width = in->width;
615  src_format.active_region.height = in_slice_end - in_slice_start;
616  src_format.active_region.left = 0;
617  src_format.active_region.top = in_slice_start;
618  //dst now is the single tile only!!
619  dst_format.width = out->width;
620  dst_format.height = out_slice_end - out_slice_start;
621 
622  if (s->graph[job_nr]) {
623  zimg_filter_graph_free(s->graph[job_nr]);
624  }
625  s->graph[job_nr] = zimg_filter_graph_build(&src_format, &dst_format, &s->params);
626  if (!s->graph[job_nr])
627  return print_zimg_error(ctx);
628 
629  ret = zimg_filter_graph_get_tmp_size(s->graph[job_nr], &size);
630  if (ret)
631  return print_zimg_error(ctx);
632 
633  if (size > (SIZE_MAX - ZIMG_ALIGNMENT))
634  return AVERROR(ENOMEM);
635 
636  if (s->tmp[job_nr])
637  av_freep(&s->tmp[job_nr]);
638  s->tmp[job_nr] = av_mallocz(size + ZIMG_ALIGNMENT);
639  if (!s->tmp[job_nr])
640  return AVERROR(ENOMEM);
641 
642  return 0;
643 }
644 
646 {
647  AVFrame *aligned = NULL;
648  int ret = 0, plane, planes;
649 
650  /* Realign any unaligned input frame. */
651  planes = av_pix_fmt_count_planes((*frame)->format);
652  for (plane = 0; plane < planes; plane++) {
653  int p = desc->comp[plane].plane;
654  if ((uintptr_t)(*frame)->data[p] % ZIMG_ALIGNMENT || (*frame)->linesize[p] % ZIMG_ALIGNMENT) {
655  aligned = ff_default_get_video_buffer2(link, (*frame)->width, (*frame)->height, ZIMG_ALIGNMENT);
656  if (!aligned)
657  return AVERROR(ENOMEM);
658 
659  if ((ret = av_frame_copy(aligned, *frame)) < 0)
660  goto fail;
661 
662  if ((ret = av_frame_copy_props(aligned, *frame)) < 0)
663  goto fail;
664 
666  *frame = aligned;
667  return 0;
668  }
669  }
670 
671 fail:
673  return ret;
674 }
675 
677 {
678  if (s->primaries != -1)
679  frame->color_primaries = (int)s->dst_format.color_primaries;
680 
681  if (s->trc != -1)
682  frame->color_trc = (int)s->dst_format.transfer_characteristics;
683 
684  if (s->chromal != -1)
685  frame->chroma_location = (int)s->dst_format.chroma_location + 1;
686 }
687 
688 static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
689 {
690  ThreadData *td = data;
691  int ret = 0;
692  int p;
693  int need_gb;
694  ZScaleContext *s = ctx->priv;
695  zimg_image_buffer_const src_buf = { ZIMG_API_VERSION };
696  zimg_image_buffer dst_buf = { ZIMG_API_VERSION };
697  const int out_slice_start = s->out_slice_start[job_nr];
698 
699  /* create zimg filter graphs for each thread
700  only if not created earlier or there is some change in frame parameters */
701  need_gb = compare_zimg_image_formats(&s->src_format, &s->src_format_tmp) ||
702  compare_zimg_image_formats(&s->dst_format, &s->dst_format_tmp) ||
703  compare_zimg_graph_builder_params(&s->params, &s->params_tmp);
704 
705  if (need_gb){
706  ret = graphs_build(td->in, td->out, td->desc, td->odesc, ctx, job_nr, n_jobs);
707  if (ret < 0)
708  return print_zimg_error(ctx);
709  }
710  for (int i = 0; i < 4; i++) {
711  const int vsamp = i >= 1 ? td->odesc->log2_chroma_h : 0;
712 
713  p = td->desc->comp[i].plane;
714 
715  if (i < td->desc->nb_components) {
716  src_buf.plane[i].data = td->in->data[p];
717  src_buf.plane[i].stride = td->in->linesize[p];
718  src_buf.plane[i].mask = -1;
719  }
720 
721  p = td->odesc->comp[i].plane;
722  if (i < td->odesc->nb_components) {
723  dst_buf.plane[i].data = td->out->data[p] + td->out->linesize[p] * (out_slice_start >> vsamp);
724  dst_buf.plane[i].stride = td->out->linesize[p];
725  dst_buf.plane[i].mask = -1;
726  }
727  }
728  if (!s->graph[job_nr])
729  return AVERROR(EINVAL);
730  ret = zimg_filter_graph_process(s->graph[job_nr], &src_buf, &dst_buf,
731  (uint8_t *)FFALIGN((uintptr_t)s->tmp[job_nr], ZIMG_ALIGNMENT),
732  0, 0, 0, 0);
733  if (ret)
734  return print_zimg_error(ctx);
735 
736  return 0;
737 }
738 
740 {
741  AVFilterContext *ctx = link->dst;
742  ZScaleContext *s = ctx->priv;
743  AVFilterLink *outlink = ctx->outputs[0];
745  const AVPixFmtDescriptor *odesc = av_pix_fmt_desc_get(outlink->format);
746  char buf[32];
747  int ret = 0, changed = 0;
748  AVFrame *out = NULL;
749  ThreadData td;
750 
751  //we need to use this filter if something is different for an input and output only
752  //otherwise - just copy the input frame to the output
753  if ((link->format != outlink->format) ||
754  (link->w != outlink->w) ||
755  (link->h != outlink->h) ||
756  (link->colorspace != outlink->colorspace) ||
757  (link->color_range != outlink->color_range) ||
758  s->first_time ||
759  (s->src_format.chroma_location != s->dst_format.chroma_location) ||
760  (s->src_format.color_family !=s->dst_format.color_family) ||
761  (s->src_format.color_primaries !=s->dst_format.color_primaries) ||
762  (s->src_format.depth !=s->dst_format.depth) ||
763  (s->src_format.matrix_coefficients !=s->dst_format.matrix_coefficients) ||
764  (s->src_format.field_parity !=s->dst_format.field_parity) ||
765  (s->src_format.pixel_range !=s->dst_format.pixel_range) ||
766  (s->src_format.pixel_type !=s->dst_format.pixel_type) ||
767  (s->src_format.transfer_characteristics !=s->dst_format.transfer_characteristics)
768  ){
769  out = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, ZIMG_ALIGNMENT);
770  if (!out) {
771  ret = AVERROR(ENOMEM);
772  goto fail;
773  }
774 
776  out->colorspace = outlink->colorspace;
777  out->color_range = outlink->color_range;
778 
779  if ((ret = realign_frame(link, desc, &in)) < 0)
780  goto fail;
781 
782  snprintf(buf, sizeof(buf)-1, "%d", outlink->w);
783  av_opt_set(s, "w", buf, 0);
784  snprintf(buf, sizeof(buf)-1, "%d", outlink->h);
785  av_opt_set(s, "h", buf, 0);
786 
787  link->dst->inputs[0]->format = in->format;
788  link->dst->inputs[0]->w = in->width;
789  link->dst->inputs[0]->h = in->height;
790  link->dst->inputs[0]->colorspace = in->colorspace;
791  link->dst->inputs[0]->color_range = in->color_range;
792 
793  s->nb_threads = av_clip(FFMIN(ff_filter_get_nb_threads(ctx), FFMIN(link->h, outlink->h) / MIN_TILESIZE), 1, MAX_THREADS);
794  slice_params(s, out->height, in->height);
795 
796  zimg_image_format_default(&s->src_format, ZIMG_API_VERSION);
797  zimg_image_format_default(&s->dst_format, ZIMG_API_VERSION);
798  zimg_graph_builder_params_default(&s->params, ZIMG_API_VERSION);
799 
800  format_init(&s->src_format, in, desc, s->colorspace_in,
801  s->primaries_in, s->trc_in, s->range_in, s->chromal_in);
802  format_init(&s->dst_format, out, odesc, s->colorspace,
803  s->primaries, s->trc, s->range, s->chromal);
804  s->first_time = 0;
805 
806  s->params.dither_type = s->dither;
807  s->params.cpu_type = ZIMG_CPU_AUTO_64B;
808  s->params.resample_filter = s->filter;
809  s->params.resample_filter_uv = s->filter;
810  s->params.nominal_peak_luminance = s->nominal_peak_luminance;
811  s->params.allow_approximate_gamma = s->approximate_gamma;
812  s->params.filter_param_a = s->params.filter_param_a_uv = s->param_a;
813  s->params.filter_param_b = s->params.filter_param_b_uv = s->param_b;
814 
816  av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
817  (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
818  (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
819  INT_MAX);
820 
821  if (out->width != in->width || out->height != in->height)
823  if (out->color_trc != in->color_trc || out->color_primaries != in->color_primaries)
825  av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data, changed);
826 
827  td.in = in;
828  td.out = out;
829  td.desc = desc;
830  td.odesc = odesc;
831 
832  memset(s->jobs_ret, 0, s->nb_threads * sizeof(*s->jobs_ret));
833  ret = ff_filter_execute(ctx, filter_slice, &td, s->jobs_ret, s->nb_threads);
834  for (int i = 0; ret >= 0 && i < s->nb_threads; i++)
835  if (s->jobs_ret[i] < 0)
836  ret = s->jobs_ret[i];
837  if (ret < 0) {
838  av_frame_free(&in);
839  av_frame_free(&out);
840  return ret;
841  }
842 
843  s->src_format_tmp = s->src_format;
844  s->dst_format_tmp = s->dst_format;
845  s->params_tmp = s->params;
846 
847  if ((!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) && (odesc->flags & AV_PIX_FMT_FLAG_ALPHA) ){
848  int x, y;
849  if (odesc->flags & AV_PIX_FMT_FLAG_FLOAT) {
850  const uint16_t h_one = 0x3C00; // float2half(1.0f)
851  for (y = 0; y < out->height; y++) {
852  const ptrdiff_t row = y * out->linesize[3];
853  if (odesc->comp[0].depth == 16)
854  for (x = 0; x < out->width; x++) {
855  AV_WN16(out->data[3] + x * odesc->comp[3].step + row, h_one);
856  }
857  else
858  for (x = 0; x < out->width; x++) {
859  AV_WN32(out->data[3] + x * odesc->comp[3].step + row,
860  av_float2int(1.0f));
861  }
862  }
863  } else if (s->dst_format.depth == 8) {
864  for (y = 0; y < outlink->h; y++)
865  memset(out->data[3] + y * out->linesize[3], 0xff, outlink->w);
866  } else {
867  const uint16_t max = (1 << s->dst_format.depth) - 1;
868  for (y = 0; y < outlink->h; y++) {
869  const ptrdiff_t row = y * out->linesize[3];
870  for (x = 0; x < out->width; x++)
871  AV_WN16(out->data[3] + x * odesc->comp[3].step + row, max);
872  }
873  }
874  }
875  } else {
876  /*no need for any filtering */
877  return ff_filter_frame(outlink, in);
878  }
879 fail:
880  av_frame_free(&in);
881  if (ret) {
882  av_frame_free(&out);
883  return ret;
884  }
885 
886  return ff_filter_frame(outlink, out);
887 }
888 
890 {
891  ZScaleContext *s = ctx->priv;
892 
893  for (int i = 0; i < s->nb_threads; i++) {
894  av_freep(&s->tmp[i]);
895  if (s->graph[i]) {
896  zimg_filter_graph_free(s->graph[i]);
897  s->graph[i] = NULL;
898  }
899  }
900 }
901 
902 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
903  char *res, int res_len, int flags)
904 {
905  ZScaleContext *s = ctx->priv;
906  int ret;
907 
908  if ( !strcmp(cmd, "width") || !strcmp(cmd, "w")
909  || !strcmp(cmd, "height") || !strcmp(cmd, "h")) {
910 
911  int old_w = s->w;
912  int old_h = s->h;
913  AVFilterLink *outlink = ctx->outputs[0];
914 
915  av_opt_set(s, cmd, args, 0);
916  if ((ret = config_props(outlink)) < 0) {
917  s->w = old_w;
918  s->h = old_h;
919  }
920  } else
921  ret = AVERROR(ENOSYS);
922 
923  return ret;
924 }
925 
926 #define OFFSET(x) offsetof(ZScaleContext, x)
927 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
928 #define TFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
929 
930 static const AVOption zscale_options[] = {
931  { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, .flags = TFLAGS },
932  { "width", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, .flags = TFLAGS },
933  { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, .flags = TFLAGS },
934  { "height", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, .flags = TFLAGS },
935  { "size", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
936  { "s", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
937  { "dither", "set dither type", OFFSET(dither), AV_OPT_TYPE_INT, {.i64 = 0}, 0, ZIMG_DITHER_ERROR_DIFFUSION, FLAGS, .unit = "dither" },
938  { "d", "set dither type", OFFSET(dither), AV_OPT_TYPE_INT, {.i64 = 0}, 0, ZIMG_DITHER_ERROR_DIFFUSION, FLAGS, .unit = "dither" },
939  { "none", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_NONE}, 0, 0, FLAGS, .unit = "dither" },
940  { "ordered", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_ORDERED}, 0, 0, FLAGS, .unit = "dither" },
941  { "random", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_RANDOM}, 0, 0, FLAGS, .unit = "dither" },
942  { "error_diffusion", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_ERROR_DIFFUSION}, 0, 0, FLAGS, .unit = "dither" },
943  { "filter", "set filter type", OFFSET(filter), AV_OPT_TYPE_INT, {.i64 = ZIMG_RESIZE_BILINEAR}, 0, ZIMG_RESIZE_LANCZOS, FLAGS, .unit = "filter" },
944  { "f", "set filter type", OFFSET(filter), AV_OPT_TYPE_INT, {.i64 = ZIMG_RESIZE_BILINEAR}, 0, ZIMG_RESIZE_LANCZOS, FLAGS, .unit = "filter" },
945  { "point", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_POINT}, 0, 0, FLAGS, .unit = "filter" },
946  { "bilinear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_BILINEAR}, 0, 0, FLAGS, .unit = "filter" },
947  { "bicubic", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_BICUBIC}, 0, 0, FLAGS, .unit = "filter" },
948  { "spline16", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_SPLINE16}, 0, 0, FLAGS, .unit = "filter" },
949  { "spline36", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_SPLINE36}, 0, 0, FLAGS, .unit = "filter" },
950  { "lanczos", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_LANCZOS}, 0, 0, FLAGS, .unit = "filter" },
951  { "out_range", "set color range", OFFSET(range), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
952  { "range", "set color range", OFFSET(range), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
953  { "r", "set color range", OFFSET(range), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
954  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "range" },
955  { "limited", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_LIMITED}, 0, 0, FLAGS, .unit = "range" },
956  { "full", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_FULL}, 0, 0, FLAGS, .unit = "range" },
957  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "range" },
958  { "tv", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_LIMITED}, 0, 0, FLAGS, .unit = "range" },
959  { "pc", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_FULL}, 0, 0, FLAGS, .unit = "range" },
960  { "primaries", "set color primaries", OFFSET(primaries), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "primaries" },
961  { "p", "set color primaries", OFFSET(primaries), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "primaries" },
962  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "primaries" },
963  { "709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_709}, 0, 0, FLAGS, .unit = "primaries" },
964  { "unspecified", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_UNSPECIFIED}, 0, 0, FLAGS, .unit = "primaries" },
965  { "170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_170M}, 0, 0, FLAGS, .unit = "primaries" },
966  { "240m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_240M}, 0, 0, FLAGS, .unit = "primaries" },
967  { "2020", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_2020}, 0, 0, FLAGS, .unit = "primaries" },
968  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_UNSPECIFIED}, 0, 0, FLAGS, .unit = "primaries" },
969  { "bt709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_709}, 0, 0, FLAGS, .unit = "primaries" },
970  { "bt470m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_470_M}, 0, 0, FLAGS, .unit = "primaries" },
971  { "bt470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_470_BG}, 0, 0, FLAGS, .unit = "primaries" },
972  { "smpte170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_170M}, 0, 0, FLAGS, .unit = "primaries" },
973  { "smpte240m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_240M}, 0, 0, FLAGS, .unit = "primaries" },
974  { "film", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_FILM}, 0, 0, FLAGS, .unit = "primaries" },
975  { "bt2020", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_2020}, 0, 0, FLAGS, .unit = "primaries" },
976  { "smpte428", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_ST428}, 0, 0, FLAGS, .unit = "primaries" },
977  { "smpte431", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_ST431_2}, 0, 0, FLAGS, .unit = "primaries" },
978  { "smpte432", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_ST432_1}, 0, 0, FLAGS, .unit = "primaries" },
979  { "jedec-p22", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_EBU3213_E}, 0, 0, FLAGS, .unit = "primaries" },
980  { "ebu3213", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_EBU3213_E}, 0, 0, FLAGS, .unit = "primaries" },
981  { "transfer", "set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "transfer" },
982  { "t", "set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "transfer" },
983  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "transfer" },
984  { "709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_709}, 0, 0, FLAGS, .unit = "transfer" },
985  { "unspecified", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_UNSPECIFIED}, 0, 0, FLAGS, .unit = "transfer" },
986  { "601", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_601}, 0, 0, FLAGS, .unit = "transfer" },
987  { "linear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LINEAR}, 0, 0, FLAGS, .unit = "transfer" },
988  { "2020_10", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_10}, 0, 0, FLAGS, .unit = "transfer" },
989  { "2020_12", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_12}, 0, 0, FLAGS, .unit = "transfer" },
990  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_UNSPECIFIED}, 0, 0, FLAGS, .unit = "transfer" },
991  { "bt470m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_470_M}, 0, 0, FLAGS, .unit = "transfer" },
992  { "bt470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_470_BG}, 0, 0, FLAGS, .unit = "transfer" },
993  { "smpte170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_601}, 0, 0, FLAGS, .unit = "transfer" },
994  { "smpte240m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_240M}, 0, 0, FLAGS, .unit = "transfer" },
995  { "bt709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_709}, 0, 0, FLAGS, .unit = "transfer" },
996  { "linear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LINEAR}, 0, 0, FLAGS, .unit = "transfer" },
997  { "log100", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LOG_100}, 0, 0, FLAGS, .unit = "transfer" },
998  { "log316", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LOG_316}, 0, 0, FLAGS, .unit = "transfer" },
999  { "bt2020-10", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_10}, 0, 0, FLAGS, .unit = "transfer" },
1000  { "bt2020-12", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_12}, 0, 0, FLAGS, .unit = "transfer" },
1001  { "smpte2084", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_ST2084}, 0, 0, FLAGS, .unit = "transfer" },
1002  { "iec61966-2-4", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_IEC_61966_2_4},0, 0, FLAGS, .unit = "transfer" },
1003  { "iec61966-2-1", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_IEC_61966_2_1},0, 0, FLAGS, .unit = "transfer" },
1004  { "arib-std-b67", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_ARIB_B67}, 0, 0, FLAGS, .unit = "transfer" },
1005  { "matrix", "set colorspace matrix", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "matrix" },
1006  { "m", "set colorspace matrix", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "matrix" },
1007  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "matrix" },
1008  { "709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_709}, 0, 0, FLAGS, .unit = "matrix" },
1009  { "unspecified", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_UNSPECIFIED}, 0, 0, FLAGS, .unit = "matrix" },
1010  { "470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_470BG}, 0, 0, FLAGS, .unit = "matrix" },
1011  { "170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_170M}, 0, 0, FLAGS, .unit = "matrix" },
1012  { "2020_ncl", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_NCL}, 0, 0, FLAGS, .unit = "matrix" },
1013  { "2020_cl", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_CL}, 0, 0, FLAGS, .unit = "matrix" },
1014  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_UNSPECIFIED}, 0, 0, FLAGS, .unit = "matrix" },
1015  { "gbr", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_RGB}, 0, 0, FLAGS, .unit = "matrix" },
1016  { "bt709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_709}, 0, 0, FLAGS, .unit = "matrix" },
1017  { "fcc", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_FCC}, 0, 0, FLAGS, .unit = "matrix" },
1018  { "bt470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_470BG}, 0, 0, FLAGS, .unit = "matrix" },
1019  { "smpte170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_170M}, 0, 0, FLAGS, .unit = "matrix" },
1020  { "smpte240m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_240M}, 0, 0, FLAGS, .unit = "matrix" },
1021  { "ycgco", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_YCGCO}, 0, 0, FLAGS, .unit = "matrix" },
1022  { "bt2020nc", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_NCL}, 0, 0, FLAGS, .unit = "matrix" },
1023  { "bt2020c", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_CL}, 0, 0, FLAGS, .unit = "matrix" },
1024  { "chroma-derived-nc",0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_CHROMATICITY_DERIVED_NCL}, 0, 0, FLAGS, .unit = "matrix" },
1025  { "chroma-derived-c", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_CHROMATICITY_DERIVED_CL}, 0, 0, FLAGS, .unit = "matrix" },
1026  { "ictcp", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_ICTCP}, 0, 0, FLAGS, .unit = "matrix" },
1027  { "in_range", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
1028  { "rangein", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
1029  { "rin", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, .unit = "range" },
1030  { "primariesin", "set input color primaries", OFFSET(primaries_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "primaries" },
1031  { "pin", "set input color primaries", OFFSET(primaries_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "primaries" },
1032  { "transferin", "set input transfer characteristic", OFFSET(trc_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "transfer" },
1033  { "tin", "set input transfer characteristic", OFFSET(trc_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "transfer" },
1034  { "matrixin", "set input colorspace matrix", OFFSET(colorspace_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "matrix" },
1035  { "min", "set input colorspace matrix", OFFSET(colorspace_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, .unit = "matrix" },
1036  { "chromal", "set output chroma location", OFFSET(chromal), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, .unit = "chroma" },
1037  { "c", "set output chroma location", OFFSET(chromal), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, .unit = "chroma" },
1038  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "chroma" },
1039  { "left", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_LEFT}, 0, 0, FLAGS, .unit = "chroma" },
1040  { "center", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_CENTER}, 0, 0, FLAGS, .unit = "chroma" },
1041  { "topleft", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_TOP_LEFT}, 0, 0, FLAGS, .unit = "chroma" },
1042  { "top", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_TOP}, 0, 0, FLAGS, .unit = "chroma" },
1043  { "bottomleft",0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_BOTTOM_LEFT}, 0, 0, FLAGS, .unit = "chroma" },
1044  { "bottom", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_BOTTOM}, 0, 0, FLAGS, .unit = "chroma" },
1045  { "chromalin", "set input chroma location", OFFSET(chromal_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, .unit = "chroma" },
1046  { "cin", "set input chroma location", OFFSET(chromal_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, .unit = "chroma" },
1047  { "npl", "set nominal peak luminance", OFFSET(nominal_peak_luminance), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, 0, DBL_MAX, FLAGS },
1048  { "agamma", "allow approximate gamma", OFFSET(approximate_gamma), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
1049  { "param_a", "parameter A, which is parameter \"b\" for bicubic, "
1050  "and the number of filter taps for lanczos", OFFSET(param_a), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, -DBL_MAX, DBL_MAX, FLAGS },
1051  { "param_b", "parameter B, which is parameter \"c\" for bicubic", OFFSET(param_b), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, -DBL_MAX, DBL_MAX, FLAGS },
1052  { NULL }
1053 };
1054 
1055 AVFILTER_DEFINE_CLASS(zscale);
1056 
1058  {
1059  .name = "default",
1060  .type = AVMEDIA_TYPE_VIDEO,
1061  .filter_frame = filter_frame,
1062  },
1063 };
1064 
1066  {
1067  .name = "default",
1068  .type = AVMEDIA_TYPE_VIDEO,
1069  .config_props = config_props,
1070  },
1071 };
1072 
1074  .p.name = "zscale",
1075  .p.description = NULL_IF_CONFIG_SMALL("Apply resizing, colorspace and bit depth conversion."),
1076  .p.priv_class = &zscale_class,
1077  .p.flags = AVFILTER_FLAG_SLICE_THREADS,
1078  .init = init,
1079  .priv_size = sizeof(ZScaleContext),
1080  .uninit = uninit,
1084  .process_command = process_command,
1085 };
flags
const SwsFlags flags[]
Definition: swscale.c:61
formats
formats
Definition: signature.h:47
ff_default_get_video_buffer2
AVFrame * ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int align)
Definition: video.c:49
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:596
AVFrame::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: frame.h:682
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:565
AVFrame::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:678
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: vf_zscale.c:178
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
av_clip
#define av_clip
Definition: common.h:100
ZScaleContext::jobs_ret
int jobs_ret[MAX_THREADS]
Definition: vf_zscale.c:117
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:47
AVALPHA_MODE_PREMULTIPLIED
@ AVALPHA_MODE_PREMULTIPLIED
Alpha channel is multiplied into color values.
Definition: pixfmt.h:802
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:451
ZScaleContext::colorspace_in
int colorspace_in
Definition: vf_zscale.c:98
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:661
convert_range_from_zimg
static enum AVColorRange convert_range_from_zimg(enum zimg_pixel_range_e color_range)
Definition: vf_zscale.c:519
ThreadData::odesc
const AVPixFmtDescriptor * odesc
Definition: vf_zscale.c:131
out
FILE * out
Definition: movenc.c:55
ZScaleContext::out_slice_end
int out_slice_end[MAX_THREADS]
Definition: vf_zscale.c:121
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_zscale.c:889
ZScaleContext::params_tmp
zimg_graph_builder_params params_tmp
Definition: vf_zscale.c:126
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1067
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3447
AVCOL_TRC_LINEAR
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition: pixfmt.h:670
AVCHROMA_LOC_BOTTOM
@ AVCHROMA_LOC_BOTTOM
Definition: pixfmt.h:793
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:680
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:64
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:588
AVFrame::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:689
ZScaleContext::chromal
int chromal
Definition: vf_zscale.c:97
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:263
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
VAR_VSUB
@ VAR_VSUB
Definition: vf_zscale.c:75
pixdesc.h
TFLAGS
#define TFLAGS
Definition: vf_zscale.c:928
var_names
static const char *const var_names[]
Definition: vf_zscale.c:51
AVFrame::width
int width
Definition: frame.h:499
config_props
static int config_props(AVFilterLink *outlink)
Definition: vf_zscale.c:256
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:595
w
uint8_t w
Definition: llviddspenc.c:38
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:767
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:590
AVOption
AVOption.
Definition: opt.h:429
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:664
data
const char data[16]
Definition: mxf.c:149
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:539
AVCOL_PRI_JEDEC_P22
@ AVCOL_PRI_JEDEC_P22
Definition: pixfmt.h:653
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:575
ThreadData::desc
const AVPixFmtDescriptor * desc
Definition: vf_tonemap.c:176
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:691
float.h
AVCOL_TRC_BT2020_12
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
Definition: pixfmt.h:677
filter
void(* filter)(uint8_t *src, int stride, int qscale)
Definition: h263dsp.c:29
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_amplify.c:52
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
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
zscale_options
static const AVOption zscale_options[]
Definition: vf_zscale.c:930
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:636
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:220
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
intfloat.h
video.h
ThreadData::in
AVFrame * in
Definition: af_adecorrelate.c:155
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:591
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:702
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:545
ZScaleContext::primaries
int primaries
Definition: vf_zscale.c:95
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:518
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:448
ZScaleContext::nb_threads
int nb_threads
Definition: vf_zscale.c:116
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
realign_frame
static int realign_frame(AVFilterLink *link, const AVPixFmtDescriptor *desc, AVFrame **frame)
Definition: vf_zscale.c:645
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:2612
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3487
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:696
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:587
convert_primaries
static int convert_primaries(enum AVColorPrimaries color_primaries)
Definition: vf_zscale.c:476
ZScaleContext::out_slice_start
int out_slice_start[MAX_THREADS]
Definition: vf_zscale.c:120
ZScaleContext::dst_format
zimg_image_format dst_format
Definition: vf_zscale.c:123
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:560
AVCOL_TRC_IEC61966_2_1
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:675
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
Definition: mpeg12dec.c:1688
av_color_space_name
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:3823
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:123
fail
#define fail()
Definition: checkasm.h:200
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:558
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:597
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:537
AVCOL_TRC_GAMMA28
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition: pixfmt.h:667
convert_matrix
static int convert_matrix(enum AVColorSpace colorspace)
Definition: vf_zscale.c:406
AV_PIX_FMT_GRAYF16
#define AV_PIX_FMT_GRAYF16
Definition: pixfmt.h:581
av_opt_set
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:835
AVCOL_TRC_LOG_SQRT
@ AVCOL_TRC_LOG_SQRT
"Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
Definition: pixfmt.h:672
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
AV_SIDE_DATA_PROP_SIZE_DEPENDENT
@ AV_SIDE_DATA_PROP_SIZE_DEPENDENT
Side data depends on the video dimensions.
Definition: frame.h:309
AVCOL_TRC_GAMMA22
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:666
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:39
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:902
VAR_SAR
@ VAR_SAR
Definition: vf_zscale.c:72
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:552
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:542
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:171
ZScaleContext::tmp
void * tmp[MAX_THREADS]
Definition: vf_zscale.c:115
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:551
FFFilter
Definition: filters.h:266
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:562
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:791
AV_PIX_FMT_GBRAP14
#define AV_PIX_FMT_GBRAP14
Definition: pixfmt.h:564
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:563
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:552
ZScaleContext::force_original_aspect_ratio
int force_original_aspect_ratio
Definition: vf_zscale.c:113
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:697
approximate_gamma
static const double approximate_gamma[AVCOL_TRC_NB]
Definition: csp.c:135
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition: opt.h:267
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:705
ZScaleContext::src_format_tmp
zimg_image_format src_format_tmp
Definition: vf_zscale.c:124
filters.h
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:594
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:536
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:550
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:49
AVCOL_PRI_SMPTE428
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
Definition: pixfmt.h:648
ZScaleContext::first_time
int first_time
Definition: vf_zscale.c:112
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:124
AVCOL_PRI_SMPTE240M
@ AVCOL_PRI_SMPTE240M
identical to above, also called "SMPTE C" even though it uses D65
Definition: pixfmt.h:645
color_range
color_range
Definition: vf_selectivecolor.c:43
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:264
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:582
ZScaleContext::in_slice_start
double in_slice_start[MAX_THREADS]
Definition: vf_zscale.c:118
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:639
NAN
#define NAN
Definition: mathematics.h:115
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:705
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:643
ff_vf_zscale
const FFFilter ff_vf_zscale
Definition: vf_zscale.c:1073
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:644
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:519
if
if(ret)
Definition: filter_design.txt:179
av_color_range_name
const char * av_color_range_name(enum AVColorRange range)
Definition: pixdesc.c:3763
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:561
ZScaleContext::params
zimg_graph_builder_params params
Definition: vf_zscale.c:125
print_zimg_error
static int print_zimg_error(AVFilterContext *ctx)
Definition: vf_zscale.c:376
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
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:599
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
FLAGS
#define FLAGS
Definition: vf_zscale.c:927
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:788
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:790
AVCOL_TRC_IEC61966_2_4
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
Definition: pixfmt.h:673
isnan
#define isnan(x)
Definition: libm.h:342
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:531
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:282
AVComponentDescriptor::plane
int plane
Which of the 4 planes contains the component.
Definition: pixdesc.h:34
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:638
parseutils.h
slice_params
static void slice_params(ZScaleContext *s, int out_h, int in_h)
Definition: vf_zscale.c:241
convert_range
static int convert_range(enum AVColorRange color_range)
Definition: vf_zscale.c:507
double
double
Definition: af_crystalizer.c:132
AVCOL_TRC_BT2020_10
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:676
AVCOL_SPC_YCGCO
@ AVCOL_SPC_YCGCO
used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
Definition: pixfmt.h:699
ZScaleContext::dither
int dither
Definition: vf_zscale.c:91
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:540
update_output_color_information
static void update_output_color_information(ZScaleContext *s, AVFrame *frame)
Definition: vf_zscale.c:676
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:557
ff_all_color_spaces
AVFilterFormats * ff_all_color_spaces(void)
Construct an AVFilterFormats representing all possible color spaces.
Definition: formats.c:646
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
AV_PIX_FMT_GBRPF16
#define AV_PIX_FMT_GBRPF16
Definition: pixfmt.h:576
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:733
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:121
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:647
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:678
AVCOL_PRI_SMPTE431
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
Definition: pixfmt.h:650
eval.h
f
f
Definition: af_crystalizer.c:122
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:94
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:805
AVCOL_TRC_SMPTE240M
@ AVCOL_TRC_SMPTE240M
Definition: pixfmt.h:669
AVCOL_PRI_FILM
@ AVCOL_PRI_FILM
colour filters using Illuminant C
Definition: pixfmt.h:646
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:372
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:711
AVCOL_TRC_LOG
@ AVCOL_TRC_LOG
"Logarithmic transfer characteristic (100:1 range)"
Definition: pixfmt.h:671
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:578
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:544
size
int size
Definition: twinvq_data.h:10344
ZScaleContext::primaries_in
int primaries_in
Definition: vf_zscale.c:100
ZScaleContext::graph
zimg_filter_graph * graph[MAX_THREADS]
Definition: vf_zscale.c:127
ZScaleContext::approximate_gamma
int approximate_gamma
Definition: vf_zscale.c:105
planes
static const struct @522 planes[]
VAR_OHSUB
@ VAR_OHSUB
Definition: vf_zscale.c:76
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:546
filter_slice
static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
Definition: vf_zscale.c:688
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:787
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:514
range
enum AVColorRange range
Definition: mediacodec_wrapper.c:2594
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:1065
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:662
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:592
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
av_frame_side_data_remove_by_props
void av_frame_side_data_remove_by_props(AVFrameSideData ***sd, int *nb_sd, int props)
Remove and free all side data instances that match any of the given side data properties.
Definition: side_data.c:117
AVCOL_SPC_CHROMA_DERIVED_NCL
@ AVCOL_SPC_CHROMA_DERIVED_NCL
Chromaticity-derived non-constant luminance system.
Definition: pixfmt.h:704
VAR_HSUB
@ VAR_HSUB
Definition: vf_zscale.c:74
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:663
AVChromaLocation
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:786
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:698
ZScaleContext::in_slice_end
double in_slice_end[MAX_THREADS]
Definition: vf_zscale.c:119
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:701
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_zscale.c:739
transfer
enum AVColorTransferCharacteristic transfer
Definition: mediacodec_wrapper.c:2622
internal.h
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:559
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:690
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:845
ThreadData
Used for passing data between threads.
Definition: dsddec.c:71
VAR_IW
@ VAR_IW
Definition: vf_zscale.c:67
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:240
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
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:256
VAR_OH
@ VAR_OH
Definition: vf_zscale.c:70
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:45
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:693
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:750
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:538
AV_SIDE_DATA_PROP_COLOR_DEPENDENT
@ AV_SIDE_DATA_PROP_COLOR_DEPENDENT
Side data depends on the video color space.
Definition: frame.h:316
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:641
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
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:589
convert_chroma_location
static int convert_chroma_location(enum AVChromaLocation chroma_location)
Definition: vf_zscale.c:386
AVFrame::sample_aspect_ratio
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:524
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:543
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:548
AVFrame::height
int height
Definition: frame.h:499
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:682
ff_filter_execute
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: avfilter.c:1693
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_zscale.c:135
AVCHROMA_LOC_CENTER
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
Definition: pixfmt.h:789
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:695
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:593
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:579
VAR_IN_H
@ VAR_IN_H
Definition: vf_zscale.c:68
VAR_OVSUB
@ VAR_OVSUB
Definition: vf_zscale.c:77
AV_PIX_FMT_GBRAPF16
#define AV_PIX_FMT_GBRAPF16
Definition: pixfmt.h:577
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
ff_all_alpha_modes
AVFilterFormats * ff_all_alpha_modes(void)
Construct an AVFilterFormats representing all possible alpha modes.
Definition: formats.c:673
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:668
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:926
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
AVFilterContext
An instance of a filter.
Definition: avfilter.h:274
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:167
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FFFilter::p
AVFilter p
The public AVFilter.
Definition: filters.h:270
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
mem.h
convert_trc
static int convert_trc(enum AVColorTransferCharacteristic color_trc)
Definition: vf_zscale.c:439
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:651
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
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
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:472
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:2070
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:549
AV_OPT_TYPE_STRING
@ 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...
Definition: opt.h:276
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:692
AVColorRange
AVColorRange
Visual content value range.
Definition: pixfmt.h:732
AVCOL_SPC_ICTCP
@ AVCOL_SPC_ICTCP
ITU-R BT.2100-0, ICtCp.
Definition: pixfmt.h:706
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
snprintf
#define snprintf
Definition: snprintf.h:34
VAR_OUT_H
@ VAR_OUT_H
Definition: vf_zscale.c:70
AVCHROMA_LOC_BOTTOMLEFT
@ AVCHROMA_LOC_BOTTOMLEFT
Definition: pixfmt.h:792
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:547
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:3367
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:1057
AV_WN16
#define AV_WN16(p, v)
Definition: intreadwrite.h:368
dither
static const uint8_t dither[8][8]
Definition: vf_fspp.c:62