FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_zscale.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Paul B Mahol
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * zscale video filter using z.lib library
24  */
25 
26 #include <float.h>
27 #include <stdio.h>
28 #include <string.h>
29 
30 #include <zimg.h>
31 
32 #include "avfilter.h"
33 #include "formats.h"
34 #include "internal.h"
35 #include "video.h"
36 #include "libavutil/avstring.h"
37 #include "libavutil/eval.h"
38 #include "libavutil/internal.h"
39 #include "libavutil/intreadwrite.h"
40 #include "libavutil/mathematics.h"
41 #include "libavutil/opt.h"
42 #include "libavutil/parseutils.h"
43 #include "libavutil/pixdesc.h"
44 #include "libavutil/imgutils.h"
45 #include "libavutil/avassert.h"
46 
47 static const char *const var_names[] = {
48  "in_w", "iw",
49  "in_h", "ih",
50  "out_w", "ow",
51  "out_h", "oh",
52  "a",
53  "sar",
54  "dar",
55  "hsub",
56  "vsub",
57  "ohsub",
58  "ovsub",
59  NULL
60 };
61 
62 enum var_name {
75 };
76 
77 typedef struct ZScaleContext {
78  const AVClass *class;
79 
80  /**
81  * New dimensions. Special values are:
82  * 0 = original width/height
83  * -1 = keep original aspect
84  * -N = try to keep aspect but make sure it is divisible by N
85  */
86  int w, h;
87  int dither;
88  int filter;
90  int trc;
91  int primaries;
92  int range;
93  int chromal;
95  int trc_in;
97  int range_in;
99  char *size_str;
102 
103  char *w_expr; ///< width expression string
104  char *h_expr; ///< height expression string
105 
110 
112 
113  void *tmp;
114  size_t tmp_size;
115 
116  zimg_image_format src_format, dst_format;
117  zimg_image_format alpha_src_format, alpha_dst_format;
118  zimg_graph_builder_params alpha_params, params;
119  zimg_filter_graph *alpha_graph, *graph;
120 
121  enum AVColorSpace in_colorspace, out_colorspace;
123  enum AVColorPrimaries in_primaries, out_primaries;
124  enum AVColorRange in_range, out_range;
125  enum AVChromaLocation in_chromal, out_chromal;
126 } ZScaleContext;
127 
129 {
130  ZScaleContext *s = ctx->priv;
131  int ret;
132 
133  if (s->size_str && (s->w_expr || s->h_expr)) {
134  av_log(ctx, AV_LOG_ERROR,
135  "Size and width/height expressions cannot be set at the same time.\n");
136  return AVERROR(EINVAL);
137  }
138 
139  if (s->w_expr && !s->h_expr)
140  FFSWAP(char *, s->w_expr, s->size_str);
141 
142  if (s->size_str) {
143  char buf[32];
144  if ((ret = av_parse_video_size(&s->w, &s->h, s->size_str)) < 0) {
145  av_log(ctx, AV_LOG_ERROR,
146  "Invalid size '%s'\n", s->size_str);
147  return ret;
148  }
149  snprintf(buf, sizeof(buf)-1, "%d", s->w);
150  av_opt_set(s, "w", buf, 0);
151  snprintf(buf, sizeof(buf)-1, "%d", s->h);
152  av_opt_set(s, "h", buf, 0);
153  }
154  if (!s->w_expr)
155  av_opt_set(s, "w", "iw", 0);
156  if (!s->h_expr)
157  av_opt_set(s, "h", "ih", 0);
158 
159  return 0;
160 }
161 
163 {
164  static const enum AVPixelFormat pixel_fmts[] = {
185  };
186  int ret;
187 
188  ret = ff_formats_ref(ff_make_format_list(pixel_fmts), &ctx->inputs[0]->out_formats);
189  if (ret < 0)
190  return ret;
191  return ff_formats_ref(ff_make_format_list(pixel_fmts), &ctx->outputs[0]->in_formats);
192 }
193 
194 static int config_props(AVFilterLink *outlink)
195 {
196  AVFilterContext *ctx = outlink->src;
197  AVFilterLink *inlink = outlink->src->inputs[0];
198  ZScaleContext *s = ctx->priv;
200  const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(outlink->format);
201  int64_t w, h;
202  double var_values[VARS_NB], res;
203  char *expr;
204  int ret;
205  int factor_w, factor_h;
206 
207  var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w;
208  var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h;
209  var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN;
210  var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN;
211  var_values[VAR_A] = (double) inlink->w / inlink->h;
212  var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ?
213  (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
214  var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
215  var_values[VAR_HSUB] = 1 << desc->log2_chroma_w;
216  var_values[VAR_VSUB] = 1 << desc->log2_chroma_h;
217  var_values[VAR_OHSUB] = 1 << out_desc->log2_chroma_w;
218  var_values[VAR_OVSUB] = 1 << out_desc->log2_chroma_h;
219 
220  /* evaluate width and height */
221  av_expr_parse_and_eval(&res, (expr = s->w_expr),
222  var_names, var_values,
223  NULL, NULL, NULL, NULL, NULL, 0, ctx);
224  s->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res;
225  if ((ret = av_expr_parse_and_eval(&res, (expr = s->h_expr),
226  var_names, var_values,
227  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
228  goto fail;
229  s->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res;
230  /* evaluate again the width, as it may depend on the output height */
231  if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr),
232  var_names, var_values,
233  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
234  goto fail;
235  s->w = res;
236 
237  w = s->w;
238  h = s->h;
239 
240  /* Check if it is requested that the result has to be divisible by a some
241  * factor (w or h = -n with n being the factor). */
242  factor_w = 1;
243  factor_h = 1;
244  if (w < -1) {
245  factor_w = -w;
246  }
247  if (h < -1) {
248  factor_h = -h;
249  }
250 
251  if (w < 0 && h < 0)
252  s->w = s->h = 0;
253 
254  if (!(w = s->w))
255  w = inlink->w;
256  if (!(h = s->h))
257  h = inlink->h;
258 
259  /* Make sure that the result is divisible by the factor we determined
260  * earlier. If no factor was set, it is nothing will happen as the default
261  * factor is 1 */
262  if (w < 0)
263  w = av_rescale(h, inlink->w, inlink->h * factor_w) * factor_w;
264  if (h < 0)
265  h = av_rescale(w, inlink->h, inlink->w * factor_h) * factor_h;
266 
267  /* Note that force_original_aspect_ratio may overwrite the previous set
268  * dimensions so that it is not divisible by the set factors anymore. */
270  int tmp_w = av_rescale(h, inlink->w, inlink->h);
271  int tmp_h = av_rescale(w, inlink->h, inlink->w);
272 
273  if (s->force_original_aspect_ratio == 1) {
274  w = FFMIN(tmp_w, w);
275  h = FFMIN(tmp_h, h);
276  } else {
277  w = FFMAX(tmp_w, w);
278  h = FFMAX(tmp_h, h);
279  }
280  }
281 
282  if (w > INT_MAX || h > INT_MAX ||
283  (h * inlink->w) > INT_MAX ||
284  (w * inlink->h) > INT_MAX)
285  av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
286 
287  outlink->w = w;
288  outlink->h = h;
289 
290  if (inlink->w == outlink->w &&
291  inlink->h == outlink->h &&
292  inlink->format == outlink->format)
293  ;
294  else {
295  }
296 
297  if (inlink->sample_aspect_ratio.num){
298  outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio);
299  } else
300  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
301 
302  av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d fmt:%s sar:%d/%d\n",
303  inlink ->w, inlink ->h, av_get_pix_fmt_name( inlink->format),
305  outlink->w, outlink->h, av_get_pix_fmt_name(outlink->format),
306  outlink->sample_aspect_ratio.num, outlink->sample_aspect_ratio.den);
307  return 0;
308 
309 fail:
310  av_log(ctx, AV_LOG_ERROR,
311  "Error when evaluating the expression '%s'.\n"
312  "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
313  expr, s->w_expr, s->h_expr);
314  return ret;
315 }
316 
318 {
319  char err_msg[1024];
320  int err_code = zimg_get_last_error(err_msg, sizeof(err_msg));
321 
322  av_log(ctx, AV_LOG_ERROR, "code %d: %s\n", err_code, err_msg);
323 
324  return AVERROR_EXTERNAL;
325 }
326 
327 static int convert_chroma_location(enum AVChromaLocation chroma_location)
328 {
329  switch (chroma_location) {
331  case AVCHROMA_LOC_LEFT:
332  return ZIMG_CHROMA_LEFT;
333  case AVCHROMA_LOC_CENTER:
334  return ZIMG_CHROMA_CENTER;
336  return ZIMG_CHROMA_TOP_LEFT;
337  case AVCHROMA_LOC_TOP:
338  return ZIMG_CHROMA_TOP;
340  return ZIMG_CHROMA_BOTTOM_LEFT;
341  case AVCHROMA_LOC_BOTTOM:
342  return ZIMG_CHROMA_BOTTOM;
343  }
344  return ZIMG_CHROMA_LEFT;
345 }
346 
347 static int convert_matrix(enum AVColorSpace colorspace)
348 {
349  switch (colorspace) {
350  case AVCOL_SPC_RGB:
351  return ZIMG_MATRIX_RGB;
352  case AVCOL_SPC_BT709:
353  return ZIMG_MATRIX_709;
355  return ZIMG_MATRIX_UNSPECIFIED;
356  case AVCOL_SPC_FCC:
357  return ZIMG_MATRIX_FCC;
358  case AVCOL_SPC_BT470BG:
359  return ZIMG_MATRIX_470BG;
360  case AVCOL_SPC_SMPTE170M:
361  return ZIMG_MATRIX_170M;
362  case AVCOL_SPC_SMPTE240M:
363  return ZIMG_MATRIX_240M;
364  case AVCOL_SPC_YCGCO:
365  return ZIMG_MATRIX_YCGCO;
367  return ZIMG_MATRIX_2020_NCL;
368  case AVCOL_SPC_BT2020_CL:
369  return ZIMG_MATRIX_2020_CL;
371  return ZIMG_MATRIX_CHROMATICITY_DERIVED_NCL;
373  return ZIMG_MATRIX_CHROMATICITY_DERIVED_CL;
374  case AVCOL_SPC_ICTCP:
375  return ZIMG_MATRIX_ICTCP;
376  }
377  return ZIMG_MATRIX_UNSPECIFIED;
378 }
379 
380 static int convert_trc(enum AVColorTransferCharacteristic color_trc)
381 {
382  switch (color_trc) {
384  return ZIMG_TRANSFER_UNSPECIFIED;
385  case AVCOL_TRC_BT709:
386  return ZIMG_TRANSFER_709;
387  case AVCOL_TRC_GAMMA22:
388  return ZIMG_TRANSFER_470_M;
389  case AVCOL_TRC_GAMMA28:
390  return ZIMG_TRANSFER_470_BG;
391  case AVCOL_TRC_SMPTE170M:
392  return ZIMG_TRANSFER_601;
393  case AVCOL_TRC_SMPTE240M:
394  return ZIMG_TRANSFER_240M;
395  case AVCOL_TRC_LINEAR:
396  return ZIMG_TRANSFER_LINEAR;
397  case AVCOL_TRC_LOG:
398  return ZIMG_TRANSFER_LOG_100;
399  case AVCOL_TRC_LOG_SQRT:
400  return ZIMG_TRANSFER_LOG_316;
402  return ZIMG_TRANSFER_IEC_61966_2_4;
403  case AVCOL_TRC_BT2020_10:
404  return ZIMG_TRANSFER_2020_10;
405  case AVCOL_TRC_BT2020_12:
406  return ZIMG_TRANSFER_2020_12;
407  case AVCOL_TRC_SMPTE2084:
408  return ZIMG_TRANSFER_ST2084;
410  return ZIMG_TRANSFER_ARIB_B67;
412  return ZIMG_TRANSFER_IEC_61966_2_1;
413  }
414  return ZIMG_TRANSFER_UNSPECIFIED;
415 }
416 
418 {
419  switch (color_primaries) {
421  return ZIMG_PRIMARIES_UNSPECIFIED;
422  case AVCOL_PRI_BT709:
423  return ZIMG_PRIMARIES_709;
424  case AVCOL_PRI_BT470M:
425  return ZIMG_PRIMARIES_470_M;
426  case AVCOL_PRI_BT470BG:
427  return ZIMG_PRIMARIES_470_BG;
428  case AVCOL_PRI_SMPTE170M:
429  return ZIMG_PRIMARIES_170M;
430  case AVCOL_PRI_SMPTE240M:
431  return ZIMG_PRIMARIES_240M;
432  case AVCOL_PRI_FILM:
433  return ZIMG_PRIMARIES_FILM;
434  case AVCOL_PRI_BT2020:
435  return ZIMG_PRIMARIES_2020;
436  case AVCOL_PRI_SMPTE428:
437  return ZIMG_PRIMARIES_ST428;
438  case AVCOL_PRI_SMPTE431:
439  return ZIMG_PRIMARIES_ST431_2;
440  case AVCOL_PRI_SMPTE432:
441  return ZIMG_PRIMARIES_ST432_1;
442  case AVCOL_PRI_JEDEC_P22:
443  return ZIMG_PRIMARIES_EBU3213_E;
444  }
445  return ZIMG_PRIMARIES_UNSPECIFIED;
446 }
447 
449 {
450  switch (color_range) {
452  case AVCOL_RANGE_MPEG:
453  return ZIMG_RANGE_LIMITED;
454  case AVCOL_RANGE_JPEG:
455  return ZIMG_RANGE_FULL;
456  }
457  return ZIMG_RANGE_LIMITED;
458 }
459 
460 static void format_init(zimg_image_format *format, AVFrame *frame, const AVPixFmtDescriptor *desc,
461  int colorspace, int primaries, int transfer, int range, int location)
462 {
463  format->width = frame->width;
464  format->height = frame->height;
465  format->subsample_w = desc->log2_chroma_w;
466  format->subsample_h = desc->log2_chroma_h;
467  format->depth = desc->comp[0].depth;
468  format->pixel_type = (desc->flags & AV_PIX_FMT_FLAG_FLOAT) ? ZIMG_PIXEL_FLOAT : desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
469  format->color_family = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_COLOR_RGB : ZIMG_COLOR_YUV;
470  format->matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_MATRIX_RGB : colorspace == -1 ? convert_matrix(frame->colorspace) : colorspace;
471  format->color_primaries = primaries == -1 ? convert_primaries(frame->color_primaries) : primaries;
472  format->transfer_characteristics = transfer == - 1 ? convert_trc(frame->color_trc) : transfer;
473  format->pixel_range = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_RANGE_FULL : range == -1 ? convert_range(frame->color_range) : range;
474  format->chroma_location = location == -1 ? convert_chroma_location(frame->chroma_location) : location;
475 }
476 
477 static int graph_build(zimg_filter_graph **graph, zimg_graph_builder_params *params,
478  zimg_image_format *src_format, zimg_image_format *dst_format,
479  void **tmp, size_t *tmp_size)
480 {
481  int ret;
482  size_t size;
483 
484  zimg_filter_graph_free(*graph);
485  *graph = zimg_filter_graph_build(src_format, dst_format, params);
486  if (!*graph)
487  return print_zimg_error(NULL);
488 
489  ret = zimg_filter_graph_get_tmp_size(*graph, &size);
490  if (ret)
491  return print_zimg_error(NULL);
492 
493  if (size > *tmp_size) {
494  av_freep(tmp);
495  *tmp = av_malloc(size);
496  if (!*tmp)
497  return AVERROR(ENOMEM);
498 
499  *tmp_size = size;
500  }
501 
502  return 0;
503 }
504 
505 static int filter_frame(AVFilterLink *link, AVFrame *in)
506 {
507  ZScaleContext *s = link->dst->priv;
508  AVFilterLink *outlink = link->dst->outputs[0];
510  const AVPixFmtDescriptor *odesc = av_pix_fmt_desc_get(outlink->format);
511  zimg_image_buffer_const src_buf = { ZIMG_API_VERSION };
512  zimg_image_buffer dst_buf = { ZIMG_API_VERSION };
513  char buf[32];
514  int ret = 0, plane;
515  AVFrame *out;
516 
517  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
518  if (!out) {
519  av_frame_free(&in);
520  return AVERROR(ENOMEM);
521  }
522 
523  av_frame_copy_props(out, in);
524  out->width = outlink->w;
525  out->height = outlink->h;
526 
527  if( in->width != link->w
528  || in->height != link->h
529  || in->format != link->format
530  || s->in_colorspace != in->colorspace
531  || s->in_trc != in->color_trc
532  || s->in_primaries != in->color_primaries
533  || s->in_range != in->color_range
534  || s->out_colorspace != out->colorspace
535  || s->out_trc != out->color_trc
536  || s->out_primaries != out->color_primaries
537  || s->out_range != out->color_range
538  || s->in_chromal != in->chroma_location
539  || s->out_chromal != out->chroma_location) {
540  snprintf(buf, sizeof(buf)-1, "%d", outlink->w);
541  av_opt_set(s, "w", buf, 0);
542  snprintf(buf, sizeof(buf)-1, "%d", outlink->h);
543  av_opt_set(s, "h", buf, 0);
544 
545  link->dst->inputs[0]->format = in->format;
546  link->dst->inputs[0]->w = in->width;
547  link->dst->inputs[0]->h = in->height;
548 
549  if ((ret = config_props(outlink)) < 0) {
550  av_frame_free(&in);
551  av_frame_free(&out);
552  return ret;
553  }
554 
555  zimg_image_format_default(&s->src_format, ZIMG_API_VERSION);
556  zimg_image_format_default(&s->dst_format, ZIMG_API_VERSION);
557  zimg_graph_builder_params_default(&s->params, ZIMG_API_VERSION);
558 
559  s->params.dither_type = s->dither;
560  s->params.cpu_type = ZIMG_CPU_AUTO;
561  s->params.resample_filter = s->filter;
562  s->params.resample_filter_uv = s->filter;
563  s->params.nominal_peak_luminance = s->nominal_peak_luminance;
564  s->params.allow_approximate_gamma = s->approximate_gamma;
565 
566  format_init(&s->src_format, in, desc, s->colorspace_in,
567  s->primaries_in, s->trc_in, s->range_in, s->chromal_in);
568  format_init(&s->dst_format, out, odesc, s->colorspace,
569  s->primaries, s->trc, s->range, s->chromal);
570 
571  if (s->colorspace != -1)
572  out->colorspace = (int)s->dst_format.matrix_coefficients;
573 
574  if (s->primaries != -1)
575  out->color_primaries = (int)s->dst_format.color_primaries;
576 
577  if (s->range != -1)
578  out->color_range = (int)s->dst_format.pixel_range + 1;
579 
580  if (s->trc != -1)
581  out->color_trc = (int)s->dst_format.transfer_characteristics;
582 
583  if (s->chromal != -1)
584  out->chroma_location = (int)s->dst_format.chroma_location - 1;
585 
586  ret = graph_build(&s->graph, &s->params, &s->src_format, &s->dst_format,
587  &s->tmp, &s->tmp_size);
588  if (ret < 0)
589  goto fail;
590 
591  s->in_colorspace = in->colorspace;
592  s->in_trc = in->color_trc;
593  s->in_primaries = in->color_primaries;
594  s->in_range = in->color_range;
595  s->out_colorspace = out->colorspace;
596  s->out_trc = out->color_trc;
597  s->out_primaries = out->color_primaries;
598  s->out_range = out->color_range;
599 
600  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
601  zimg_image_format_default(&s->alpha_src_format, ZIMG_API_VERSION);
602  zimg_image_format_default(&s->alpha_dst_format, ZIMG_API_VERSION);
603  zimg_graph_builder_params_default(&s->alpha_params, ZIMG_API_VERSION);
604 
605  s->alpha_params.dither_type = s->dither;
606  s->alpha_params.cpu_type = ZIMG_CPU_AUTO;
607  s->alpha_params.resample_filter = s->filter;
608 
609  s->alpha_src_format.width = in->width;
610  s->alpha_src_format.height = in->height;
611  s->alpha_src_format.depth = desc->comp[0].depth;
612  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;
613  s->alpha_src_format.color_family = ZIMG_COLOR_GREY;
614 
615  s->alpha_dst_format.width = out->width;
616  s->alpha_dst_format.height = out->height;
617  s->alpha_dst_format.depth = odesc->comp[0].depth;
618  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;
619  s->alpha_dst_format.color_family = ZIMG_COLOR_GREY;
620 
621  zimg_filter_graph_free(s->alpha_graph);
622  s->alpha_graph = zimg_filter_graph_build(&s->alpha_src_format, &s->alpha_dst_format, &s->alpha_params);
623  if (!s->alpha_graph) {
624  ret = print_zimg_error(link->dst);
625  goto fail;
626  }
627  }
628  }
629 
630  if (s->colorspace != -1)
631  out->colorspace = (int)s->dst_format.matrix_coefficients;
632 
633  if (s->primaries != -1)
634  out->color_primaries = (int)s->dst_format.color_primaries;
635 
636  if (s->range != -1)
637  out->color_range = (int)s->dst_format.pixel_range;
638 
639  if (s->trc != -1)
640  out->color_trc = (int)s->dst_format.transfer_characteristics;
641 
643  (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
644  (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
645  INT_MAX);
646 
647  for (plane = 0; plane < 3; plane++) {
648  int p = desc->comp[plane].plane;
649  src_buf.plane[plane].data = in->data[p];
650  src_buf.plane[plane].stride = in->linesize[p];
651  src_buf.plane[plane].mask = -1;
652 
653  p = odesc->comp[plane].plane;
654  dst_buf.plane[plane].data = out->data[p];
655  dst_buf.plane[plane].stride = out->linesize[p];
656  dst_buf.plane[plane].mask = -1;
657  }
658 
659  ret = zimg_filter_graph_process(s->graph, &src_buf, &dst_buf, s->tmp, 0, 0, 0, 0);
660  if (ret) {
661  ret = print_zimg_error(link->dst);
662  goto fail;
663  }
664 
665  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
666  src_buf.plane[0].data = in->data[3];
667  src_buf.plane[0].stride = in->linesize[3];
668  src_buf.plane[0].mask = -1;
669 
670  dst_buf.plane[0].data = out->data[3];
671  dst_buf.plane[0].stride = out->linesize[3];
672  dst_buf.plane[0].mask = -1;
673 
674  ret = zimg_filter_graph_process(s->alpha_graph, &src_buf, &dst_buf, s->tmp, 0, 0, 0, 0);
675  if (ret) {
676  ret = print_zimg_error(link->dst);
677  goto fail;
678  }
679  } else if (odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
680  int x, y;
681 
682  if (odesc->flags & AV_PIX_FMT_FLAG_FLOAT) {
683  for (y = 0; y < out->height; y++) {
684  for (x = 0; x < out->width; x++) {
685  AV_WN32(out->data[3] + x * odesc->comp[3].step + y * out->linesize[3],
686  av_float2int(1.0f));
687  }
688  }
689  } else {
690  for (y = 0; y < outlink->h; y++)
691  memset(out->data[3] + y * out->linesize[3], 0xff, outlink->w);
692  }
693  }
694 
695 fail:
696  av_frame_free(&in);
697  if (ret) {
698  av_frame_free(&out);
699  return ret;
700  }
701 
702  return ff_filter_frame(outlink, out);
703 }
704 
706 {
707  ZScaleContext *s = ctx->priv;
708 
709  zimg_filter_graph_free(s->graph);
710  zimg_filter_graph_free(s->alpha_graph);
711  av_freep(&s->tmp);
712  s->tmp_size = 0;
713 }
714 
715 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
716  char *res, int res_len, int flags)
717 {
718  ZScaleContext *s = ctx->priv;
719  int ret;
720 
721  if ( !strcmp(cmd, "width") || !strcmp(cmd, "w")
722  || !strcmp(cmd, "height") || !strcmp(cmd, "h")) {
723 
724  int old_w = s->w;
725  int old_h = s->h;
726  AVFilterLink *outlink = ctx->outputs[0];
727 
728  av_opt_set(s, cmd, args, 0);
729  if ((ret = config_props(outlink)) < 0) {
730  s->w = old_w;
731  s->h = old_h;
732  }
733  } else
734  ret = AVERROR(ENOSYS);
735 
736  return ret;
737 }
738 
739 #define OFFSET(x) offsetof(ZScaleContext, x)
740 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
741 
742 static const AVOption zscale_options[] = {
743  { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, .flags = FLAGS },
744  { "width", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, .flags = FLAGS },
745  { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, .flags = FLAGS },
746  { "height", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, .flags = FLAGS },
747  { "size", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
748  { "s", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
749  { "dither", "set dither type", OFFSET(dither), AV_OPT_TYPE_INT, {.i64 = 0}, 0, ZIMG_DITHER_ERROR_DIFFUSION, FLAGS, "dither" },
750  { "d", "set dither type", OFFSET(dither), AV_OPT_TYPE_INT, {.i64 = 0}, 0, ZIMG_DITHER_ERROR_DIFFUSION, FLAGS, "dither" },
751  { "none", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_NONE}, 0, 0, FLAGS, "dither" },
752  { "ordered", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_ORDERED}, 0, 0, FLAGS, "dither" },
753  { "random", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_RANDOM}, 0, 0, FLAGS, "dither" },
754  { "error_diffusion", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_DITHER_ERROR_DIFFUSION}, 0, 0, FLAGS, "dither" },
755  { "filter", "set filter type", OFFSET(filter), AV_OPT_TYPE_INT, {.i64 = ZIMG_RESIZE_BILINEAR}, 0, ZIMG_RESIZE_LANCZOS, FLAGS, "filter" },
756  { "f", "set filter type", OFFSET(filter), AV_OPT_TYPE_INT, {.i64 = ZIMG_RESIZE_BILINEAR}, 0, ZIMG_RESIZE_LANCZOS, FLAGS, "filter" },
757  { "point", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_POINT}, 0, 0, FLAGS, "filter" },
758  { "bilinear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_BILINEAR}, 0, 0, FLAGS, "filter" },
759  { "bicubic", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_BICUBIC}, 0, 0, FLAGS, "filter" },
760  { "spline16", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_SPLINE16}, 0, 0, FLAGS, "filter" },
761  { "spline36", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_SPLINE36}, 0, 0, FLAGS, "filter" },
762  { "lanczos", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RESIZE_LANCZOS}, 0, 0, FLAGS, "filter" },
763  { "out_range", "set color range", OFFSET(range), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
764  { "range", "set color range", OFFSET(range), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
765  { "r", "set color range", OFFSET(range), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
766  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, "range" },
767  { "limited", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_LIMITED}, 0, 0, FLAGS, "range" },
768  { "full", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_FULL}, 0, 0, FLAGS, "range" },
769  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, "range" },
770  { "tv", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_LIMITED}, 0, 0, FLAGS, "range" },
771  { "pc", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_RANGE_FULL}, 0, 0, FLAGS, "range" },
772  { "primaries", "set color primaries", OFFSET(primaries), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "primaries" },
773  { "p", "set color primaries", OFFSET(primaries), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "primaries" },
774  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, "primaries" },
775  { "709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_709}, 0, 0, FLAGS, "primaries" },
776  { "unspecified", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_UNSPECIFIED}, 0, 0, FLAGS, "primaries" },
777  { "170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_170M}, 0, 0, FLAGS, "primaries" },
778  { "240m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_240M}, 0, 0, FLAGS, "primaries" },
779  { "2020", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_2020}, 0, 0, FLAGS, "primaries" },
780  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_UNSPECIFIED}, 0, 0, FLAGS, "primaries" },
781  { "bt709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_709}, 0, 0, FLAGS, "primaries" },
782  { "bt470m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_470_M}, 0, 0, FLAGS, "primaries" },
783  { "bt470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_470_BG}, 0, 0, FLAGS, "primaries" },
784  { "smpte170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_170M}, 0, 0, FLAGS, "primaries" },
785  { "smpte240m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_240M}, 0, 0, FLAGS, "primaries" },
786  { "film", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_FILM}, 0, 0, FLAGS, "primaries" },
787  { "bt2020", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_2020}, 0, 0, FLAGS, "primaries" },
788  { "smpte428", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_ST428}, 0, 0, FLAGS, "primaries" },
789  { "smpte431", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_ST431_2}, 0, 0, FLAGS, "primaries" },
790  { "smpte432", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_ST432_1}, 0, 0, FLAGS, "primaries" },
791  { "jedec-p22", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_PRIMARIES_EBU3213_E}, 0, 0, FLAGS, "primaries" },
792  { "transfer", "set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
793  { "t", "set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
794  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, "transfer" },
795  { "709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_709}, 0, 0, FLAGS, "transfer" },
796  { "unspecified", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_UNSPECIFIED}, 0, 0, FLAGS, "transfer" },
797  { "601", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_601}, 0, 0, FLAGS, "transfer" },
798  { "linear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LINEAR}, 0, 0, FLAGS, "transfer" },
799  { "2020_10", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_10}, 0, 0, FLAGS, "transfer" },
800  { "2020_12", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_12}, 0, 0, FLAGS, "transfer" },
801  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_UNSPECIFIED}, 0, 0, FLAGS, "transfer" },
802  { "bt470m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_470_M}, 0, 0, FLAGS, "transfer" },
803  { "bt470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_470_BG}, 0, 0, FLAGS, "transfer" },
804  { "smpte170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_601}, 0, 0, FLAGS, "transfer" },
805  { "bt709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_709}, 0, 0, FLAGS, "transfer" },
806  { "linear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LINEAR}, 0, 0, FLAGS, "transfer" },
807  { "log100", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LOG_100}, 0, 0, FLAGS, "transfer" },
808  { "log316", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_LOG_316}, 0, 0, FLAGS, "transfer" },
809  { "bt2020-10", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_10}, 0, 0, FLAGS, "transfer" },
810  { "bt2020-12", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_2020_12}, 0, 0, FLAGS, "transfer" },
811  { "smpte2084", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_ST2084}, 0, 0, FLAGS, "transfer" },
812  { "iec61966-2-4", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_IEC_61966_2_4},0, 0, FLAGS, "transfer" },
813  { "iec61966-2-1", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_IEC_61966_2_1},0, 0, FLAGS, "transfer" },
814  { "arib-std-b67", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_TRANSFER_ARIB_B67}, 0, 0, FLAGS, "transfer" },
815  { "matrix", "set colorspace matrix", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "matrix" },
816  { "m", "set colorspace matrix", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "matrix" },
817  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, "matrix" },
818  { "709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_709}, 0, 0, FLAGS, "matrix" },
819  { "unspecified", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_UNSPECIFIED}, 0, 0, FLAGS, "matrix" },
820  { "470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_470BG}, 0, 0, FLAGS, "matrix" },
821  { "170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_170M}, 0, 0, FLAGS, "matrix" },
822  { "2020_ncl", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_NCL}, 0, 0, FLAGS, "matrix" },
823  { "2020_cl", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_CL}, 0, 0, FLAGS, "matrix" },
824  { "unknown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_UNSPECIFIED}, 0, 0, FLAGS, "matrix" },
825  { "gbr", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_RGB}, 0, 0, FLAGS, "matrix" },
826  { "bt709", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_709}, 0, 0, FLAGS, "matrix" },
827  { "fcc", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_FCC}, 0, 0, FLAGS, "matrix" },
828  { "bt470bg", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_470BG}, 0, 0, FLAGS, "matrix" },
829  { "smpte170m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_170M}, 0, 0, FLAGS, "matrix" },
830  { "smpte2400m", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_240M}, 0, 0, FLAGS, "matrix" },
831  { "ycgco", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_YCGCO}, 0, 0, FLAGS, "matrix" },
832  { "bt2020nc", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_NCL}, 0, 0, FLAGS, "matrix" },
833  { "bt2020c", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_CL}, 0, 0, FLAGS, "matrix" },
834  { "chroma-derived-nc",0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_CHROMATICITY_DERIVED_NCL}, 0, 0, FLAGS, "matrix" },
835  { "chroma-derived-c", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_CHROMATICITY_DERIVED_CL}, 0, 0, FLAGS, "matrix" },
836  { "ictcp", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_ICTCP}, 0, 0, FLAGS, "matrix" },
837  { "in_range", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
838  { "rangein", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
839  { "rin", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
840  { "primariesin", "set input color primaries", OFFSET(primaries_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "primaries" },
841  { "pin", "set input color primaries", OFFSET(primaries_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "primaries" },
842  { "transferin", "set input transfer characteristic", OFFSET(trc_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
843  { "tin", "set input transfer characteristic", OFFSET(trc_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
844  { "matrixin", "set input colorspace matrix", OFFSET(colorspace_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "matrix" },
845  { "min", "set input colorspace matrix", OFFSET(colorspace_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "matrix" },
846  { "chromal", "set output chroma location", OFFSET(chromal), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, "chroma" },
847  { "c", "set output chroma location", OFFSET(chromal), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, "chroma" },
848  { "input", 0, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, "chroma" },
849  { "left", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_LEFT}, 0, 0, FLAGS, "chroma" },
850  { "center", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_CENTER}, 0, 0, FLAGS, "chroma" },
851  { "topleft", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_TOP_LEFT}, 0, 0, FLAGS, "chroma" },
852  { "top", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_TOP}, 0, 0, FLAGS, "chroma" },
853  { "bottomleft",0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_BOTTOM_LEFT}, 0, 0, FLAGS, "chroma" },
854  { "bottom", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_CHROMA_BOTTOM}, 0, 0, FLAGS, "chroma" },
855  { "chromalin", "set input chroma location", OFFSET(chromal_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, "chroma" },
856  { "cin", "set input chroma location", OFFSET(chromal_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, "chroma" },
857  { "npl", "set nominal peak luminance", OFFSET(nominal_peak_luminance), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, 0, DBL_MAX, FLAGS },
858  { "agamma", "allow approximate gamma", OFFSET(approximate_gamma), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
859  { NULL }
860 };
861 
862 static const AVClass zscale_class = {
863  .class_name = "zscale",
864  .item_name = av_default_item_name,
865  .option = zscale_options,
866  .version = LIBAVUTIL_VERSION_INT,
867  .category = AV_CLASS_CATEGORY_FILTER,
868 };
869 
871  {
872  .name = "default",
873  .type = AVMEDIA_TYPE_VIDEO,
874  .filter_frame = filter_frame,
875  },
876  { NULL }
877 };
878 
880  {
881  .name = "default",
882  .type = AVMEDIA_TYPE_VIDEO,
883  .config_props = config_props,
884  },
885  { NULL }
886 };
887 
889  .name = "zscale",
890  .description = NULL_IF_CONFIG_SMALL("Apply resizing, colorspace and bit depth conversion."),
891  .init_dict = init_dict,
892  .query_formats = query_formats,
893  .priv_size = sizeof(ZScaleContext),
894  .priv_class = &zscale_class,
895  .uninit = uninit,
896  .inputs = avfilter_vf_zscale_inputs,
897  .outputs = avfilter_vf_zscale_outputs,
899 };
ITU-R BT2020 for 12-bit system.
Definition: pixfmt.h:460
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
Definition: pixfmt.h:475
int plane
Definition: avisynth_c.h:422
static const AVFilterPad avfilter_vf_zscale_outputs[]
Definition: vf_zscale.c:879
int plane
Which of the 4 planes contains the component.
Definition: pixdesc.h:35
#define NULL
Definition: coverity.c:32
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:407
const char * s
Definition: avisynth_c.h:768
static const char * format[]
Definition: af_aiir.c:311
IEC 61966-2-4.
Definition: pixfmt.h:456
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:401
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2363
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:520
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
int out_v_chr_pos
Definition: vf_zscale.c:107
AVOption.
Definition: opt.h:246
"Linear transfer characteristics"
Definition: pixfmt.h:453
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:403
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:148
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:378
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:404
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
misc image utilities
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
Main libavfilter public API header.
JEDEC P22 phosphors.
Definition: pixfmt.h:436
const char * desc
Definition: nvenc.c:65
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
Definition: pixfmt.h:479
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
Definition: pixfmt.h:435
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:164
int num
Numerator.
Definition: rational.h:59
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:384
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:480
zimg_image_format dst_format
Definition: vf_zscale.c:116
SMPTE ST 431-2 (2011) / DCI P3.
Definition: pixfmt.h:434
color_range
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:372
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:99
int approximate_gamma
Definition: vf_zscale.c:101
zimg_graph_builder_params alpha_params
Definition: vf_zscale.c:118
enum AVColorSpace in_colorspace out_colorspace
Definition: vf_zscale.c:121
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
Definition: pixfmt.h:474
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:444
char * w_expr
width expression string
Definition: vf_zscale.c:103
functionally identical to above
Definition: pixfmt.h:481
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
const char * name
Pad name.
Definition: internal.h:60
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
zimg_filter_graph * alpha_graph
Definition: vf_zscale.c:119
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
static int print_zimg_error(AVFilterContext *ctx)
Definition: vf_zscale.c:317
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, int clip)
Definition: cfhd.c:114
enum AVColorPrimaries in_primaries out_primaries
Definition: vf_zscale.c:123
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:97
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
zimg_image_format alpha_dst_format
Definition: vf_zscale.c:117
#define av_cold
Definition: attributes.h:82
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:181
#define av_malloc(s)
AVOptions.
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:473
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:192
Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16.
Definition: pixfmt.h:482
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:449
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:400
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:383
static AVFrame * frame
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:96
static int flags
Definition: log.c:55
int in_h_chr_pos
Definition: vf_zscale.c:108
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:75
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
static const AVFilterPad avfilter_vf_zscale_inputs[]
Definition: vf_zscale.c:870
static int convert_range(enum AVColorRange color_range)
Definition: vf_zscale.c:448
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:381
AVColorRange
MPEG vs JPEG YUV range.
Definition: pixfmt.h:496
ptrdiff_t size
Definition: opengl_enc.c:101
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
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:373
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:406
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:420
#define av_log(a,...)
static int convert_matrix(enum AVColorSpace colorspace)
Definition: vf_zscale.c:347
static int query_formats(AVFilterContext *ctx)
Definition: vf_zscale.c:162
A filter pad used for either input or output.
Definition: internal.h:54
enum AVColorRange in_range out_range
Definition: vf_zscale.c:124
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:460
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:425
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:744
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:172
int width
Definition: frame.h:276
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts)
Definition: vf_zscale.c:128
#define AVERROR(e)
Definition: error.h:43
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:148
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_zscale.c:505
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
void * tmp
Definition: vf_zscale.c:113
static const uint8_t dither[8][8]
Definition: vf_fspp.c:57
void * priv
private data for use by the filter
Definition: avfilter.h:353
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:463
#define OFFSET(x)
Definition: vf_zscale.c:739
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:408
GLenum GLint * params
Definition: opengl_enc.c:114
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:474
zimg_image_format alpha_src_format
Definition: vf_zscale.c:117
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
Definition: pixfmt.h:422
simple assert() macros that are a bit more flexible than ISO C assert().
SMPTE ST 428-1 (CIE 1931 XYZ)
Definition: pixfmt.h:432
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:371
#define FFMAX(a, b)
Definition: common.h:94
#define fail()
Definition: checkasm.h:116
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:390
int w
New dimensions.
Definition: vf_zscale.c:86
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
var_name
Definition: aeval.c:46
common internal API header
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:366
AVDictionary * opts
Definition: movenc.c:50
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:461
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:387
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
#define NAN
Definition: mathematics.h:64
#define FFMIN(a, b)
Definition: common.h:96
char * size_str
Definition: vf_zscale.c:99
zimg_filter_graph * graph
Definition: vf_zscale.c:119
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:74
static int graph_build(zimg_filter_graph **graph, zimg_graph_builder_params *params, zimg_image_format *src_format, zimg_image_format *dst_format, void **tmp, size_t *tmp_size)
Definition: vf_zscale.c:477
colour filters using Illuminant C
Definition: pixfmt.h:430
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:440
uint8_t w
Definition: llviddspenc.c:38
static void uninit(AVFilterContext *ctx)
Definition: vf_zscale.c:705
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:484
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition: pixfmt.h:522
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:427
static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
AVFormatContext * ctx
Definition: movenc.c:48
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:405
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:367
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:386
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:478
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:499
int colorspace_in
Definition: vf_zscale.c:94
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:379
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:291
also ITU-R BT1361
Definition: pixfmt.h:446
ITU-R BT.2100-0, ICtCp.
Definition: pixfmt.h:489
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
Definition: pixfmt.h:451
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:376
zimg_graph_builder_params params
Definition: vf_zscale.c:118
double nominal_peak_luminance
Definition: vf_zscale.c:100
int chromal_in
Definition: vf_zscale.c:98
functionally identical to above
Definition: pixfmt.h:429
enum AVChromaLocation in_chromal out_chromal
Definition: vf_zscale.c:125
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:249
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:173
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
Chromaticity-derived constant luminance system.
Definition: pixfmt.h:488
static int convert_trc(enum AVColorTransferCharacteristic color_trc)
Definition: vf_zscale.c:380
static const char *const var_names[]
Definition: vf_zscale.c:47
char * h_expr
height expression string
Definition: vf_zscale.c:104
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:306
zimg_image_format src_format
Definition: vf_zscale.c:116
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
int out_h_chr_pos
Definition: vf_zscale.c:106
void * buf
Definition: avisynth_c.h:690
int primaries_in
Definition: vf_zscale.c:96
Chromaticity-derived non-constant luminance system.
Definition: pixfmt.h:487
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:368
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_zscale.c:715
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
int colorspace
Definition: vf_zscale.c:89
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
static int convert_primaries(enum AVColorPrimaries color_primaries)
Definition: vf_zscale.c:417
Rational number (pair of numerator and denominator).
Definition: rational.h:58
"Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
Definition: pixfmt.h:455
const char * name
Filter name.
Definition: avfilter.h:148
static int convert_chroma_location(enum AVChromaLocation chroma_location)
Definition: vf_zscale.c:327
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:365
enum AVChromaLocation chroma_location
Definition: frame.h:476
#define snprintf
Definition: snprintf.h:34
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
Definition: intfloat.h:50
misc parsing utilities
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static const AVClass zscale_class
Definition: vf_zscale.c:862
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:377
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:385
size_t tmp_size
Definition: vf_zscale.c:114
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:369
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:375
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:232
the normal 219*2^(n-8) "MPEG" YUV ranges
Definition: pixfmt.h:498
static int config_props(AVFilterLink *outlink)
Definition: vf_zscale.c:194
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:485
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:397
int
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:398
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:458
if(ret< 0)
Definition: vf_mcdeint.c:279
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:211
#define AV_WN32(p, v)
Definition: intreadwrite.h:376
AVFilter ff_vf_zscale
Definition: vf_zscale.c:888
also ITU-R BT470BG
Definition: pixfmt.h:450
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:402
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:76
static const AVOption zscale_options[]
Definition: vf_zscale.c:742
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
int den
Denominator.
Definition: rational.h:60
int force_original_aspect_ratio
Definition: vf_zscale.c:111
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:465
#define FLAGS
Definition: vf_zscale.c:740
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:254
int in_v_chr_pos
Definition: vf_zscale.c:109
enum AVColorPrimaries color_primaries
Definition: frame.h:465
An instance of a filter.
Definition: avfilter.h:338
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:459
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:428
ITU-R BT2020.
Definition: pixfmt.h:431
int height
Definition: frame.h:276
FILE * out
Definition: movenc.c:54
#define av_freep(p)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:95
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:518
enum AVColorTransferCharacteristic color_trc
Definition: frame.h:467
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
Definition: pixfmt.h:521
#define FFSWAP(type, a, b)
Definition: common.h:99
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:2279
internal API functions
int depth
Number of bits in the component.
Definition: pixdesc.h:58
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:57
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:449
enum AVColorTransferCharacteristic in_trc out_trc
Definition: vf_zscale.c:122
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:380
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:652
int step
Number of elements between 2 horizontally consecutive pixels.
Definition: pixdesc.h:41
simple arithmetic expression evaluator
"Logarithmic transfer characteristic (100:1 range)"
Definition: pixfmt.h:454
static uint8_t tmp[11]
Definition: aes_ctr.c:26