...
|
...
|
@@ -421,6 +421,23 @@ static int convert_range(enum AVColorRange color_range)
|
421
|
421
|
return ZIMG_RANGE_LIMITED;
|
422
|
422
|
}
|
423
|
423
|
|
|
424
|
+static void format_init(zimg_image_format *format, AVFrame *frame, const AVPixFmtDescriptor *desc,
|
|
425
|
+ int colorspace, int primaries, int transfer, int range, int location)
|
|
426
|
+{
|
|
427
|
+ format->width = frame->width;
|
|
428
|
+ format->height = frame->height;
|
|
429
|
+ format->subsample_w = desc->log2_chroma_w;
|
|
430
|
+ format->subsample_h = desc->log2_chroma_h;
|
|
431
|
+ format->depth = desc->comp[0].depth;
|
|
432
|
+ format->pixel_type = desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
|
|
433
|
+ format->color_family = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_COLOR_RGB : ZIMG_COLOR_YUV;
|
|
434
|
+ format->matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_MATRIX_RGB : colorspace == -1 ? convert_matrix(frame->colorspace) : colorspace;
|
|
435
|
+ format->color_primaries = primaries == -1 ? convert_primaries(frame->color_primaries) : primaries;
|
|
436
|
+ format->transfer_characteristics = transfer == - 1 ? convert_trc(frame->color_trc) : transfer;
|
|
437
|
+ format->pixel_range = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_RANGE_FULL : range == -1 ? convert_range(frame->color_range) : range;
|
|
438
|
+ format->chroma_location = location == -1 ? convert_chroma_location(frame->chroma_location) : location;
|
|
439
|
+}
|
|
440
|
+
|
424
|
441
|
static int filter_frame(AVFilterLink *link, AVFrame *in)
|
425
|
442
|
{
|
426
|
443
|
ZScaleContext *s = link->dst->priv;
|
...
|
...
|
@@ -483,31 +500,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
|
483
|
483
|
s->params.nominal_peak_luminance = s->nominal_peak_luminance;
|
484
|
484
|
s->params.allow_approximate_gamma = s->approximate_gamma;
|
485
|
485
|
|
486
|
|
- s->src_format.width = in->width;
|
487
|
|
- s->src_format.height = in->height;
|
488
|
|
- s->src_format.subsample_w = desc->log2_chroma_w;
|
489
|
|
- s->src_format.subsample_h = desc->log2_chroma_h;
|
490
|
|
- s->src_format.depth = desc->comp[0].depth;
|
491
|
|
- s->src_format.pixel_type = desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
|
492
|
|
- s->src_format.color_family = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_COLOR_RGB : ZIMG_COLOR_YUV;
|
493
|
|
- s->src_format.matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_MATRIX_RGB : s->colorspace_in == -1 ? convert_matrix(in->colorspace) : s->colorspace_in;
|
494
|
|
- s->src_format.transfer_characteristics = s->trc_in == - 1 ? convert_trc(in->color_trc) : s->trc_in;
|
495
|
|
- s->src_format.color_primaries = s->primaries_in == -1 ? convert_primaries(in->color_primaries) : s->primaries_in;
|
496
|
|
- s->src_format.pixel_range = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_RANGE_FULL : s->range_in == -1 ? convert_range(in->color_range) : s->range_in;
|
497
|
|
- s->src_format.chroma_location = s->chromal_in == -1 ? convert_chroma_location(in->chroma_location) : s->chromal_in;
|
498
|
|
-
|
499
|
|
- s->dst_format.width = out->width;
|
500
|
|
- s->dst_format.height = out->height;
|
501
|
|
- s->dst_format.subsample_w = odesc->log2_chroma_w;
|
502
|
|
- s->dst_format.subsample_h = odesc->log2_chroma_h;
|
503
|
|
- s->dst_format.depth = odesc->comp[0].depth;
|
504
|
|
- s->dst_format.pixel_type = odesc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
|
505
|
|
- s->dst_format.color_family = (odesc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_COLOR_RGB : ZIMG_COLOR_YUV;
|
506
|
|
- s->dst_format.matrix_coefficients = (odesc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_MATRIX_RGB : s->colorspace == -1 ? convert_matrix(out->colorspace) : s->colorspace;
|
507
|
|
- s->dst_format.transfer_characteristics = s->trc == -1 ? convert_trc(out->color_trc) : s->trc;
|
508
|
|
- s->dst_format.color_primaries = s->primaries == -1 ? convert_primaries(out->color_primaries) : s->primaries;
|
509
|
|
- s->dst_format.pixel_range = (odesc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_RANGE_FULL : s->range == -1 ? convert_range(out->color_range) : s->range;
|
510
|
|
- s->dst_format.chroma_location = s->chromal == -1 ? convert_chroma_location(out->chroma_location) : s->chromal;
|
|
486
|
+ format_init(&s->src_format, in, desc, s->colorspace_in,
|
|
487
|
+ s->primaries_in, s->trc_in, s->range_in, s->chromal_in);
|
|
488
|
+ format_init(&s->dst_format, out, odesc, s->colorspace,
|
|
489
|
+ s->primaries, s->trc, s->range, s->chromal);
|
511
|
490
|
|
512
|
491
|
if (s->colorspace != -1)
|
513
|
492
|
out->colorspace = (int)s->dst_format.matrix_coefficients;
|