[FFmpeg-cvslog] avfilter/vf_zscale: make it possible to override input frame parameters
Paul B Mahol
git at videolan.org
Tue Jan 26 23:13:49 CET 2016
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Jan 26 23:07:07 2016 +0100| [df7b165e878ec07cfc31253bd8a6ad422a55089a] | committer: Paul B Mahol
avfilter/vf_zscale: make it possible to override input frame parameters
Mostly useful when there is no such parameters present at all.
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=df7b165e878ec07cfc31253bd8a6ad422a55089a
---
doc/filters.texi | 57 +++++++++++++++++++++++++++++++++++++++++++++++
libavfilter/vf_zscale.c | 20 +++++++++++++----
2 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 8545a2e..eaee284 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12784,6 +12784,63 @@ Possible value are:
@end table
Default is same as input.
+
+ at item rangein, rin
+Set the input color range.
+
+Possible values are:
+ at table @var
+ at item input
+ at item limited
+ at item full
+ at end table
+
+Default is same as input.
+
+ at item primariesin, pin
+Set the input color primaries.
+
+Possible values are:
+ at table @var
+ at item input
+ at item 709
+ at item unspecified
+ at item 170m
+ at item 240m
+ at item 2020
+ at end table
+
+Default is same as input.
+
+ at item transferin, tin
+Set the input transfer characteristics.
+
+Possible values are:
+ at table @var
+ at item input
+ at item 709
+ at item unspecified
+ at item 601
+ at item linear
+ at item 2020_10
+ at item 2020_12
+ at end table
+
+Default is same as input.
+
+ at item matrixin, min
+Set the input colorspace matrix.
+
+Possible value are:
+ at table @var
+ at item input
+ at item 709
+ at item unspecified
+ at item 470bg
+ at item 170m
+ at item 2020_ncl
+ at item 2020_cl
+ at end table
@end table
The values of the @option{w} and @option{h} options are expressions
diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 86e5f5f..939775a 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -88,6 +88,10 @@ typedef struct ZScaleContext {
int trc;
int primaries;
int range;
+ int colorspace_in;
+ int trc_in;
+ int primaries_in;
+ int range_in;
char *size_str;
char *w_expr; ///< width expression string
@@ -448,10 +452,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
s->src_format.depth = desc->comp[0].depth;
s->src_format.pixel_type = desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
s->src_format.color_family = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_COLOR_RGB : ZIMG_COLOR_YUV;
- s->src_format.matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_MATRIX_RGB : convert_matrix(in->colorspace);
- s->src_format.transfer_characteristics = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_TRANSFER_UNSPECIFIED : convert_trc(in->color_trc);
- s->src_format.color_primaries = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_PRIMARIES_UNSPECIFIED : convert_primaries(in->color_primaries);
- s->src_format.pixel_range = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_RANGE_FULL : convert_range(in->color_range);
+ 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;
+ s->src_format.transfer_characteristics = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_TRANSFER_UNSPECIFIED : s->trc_in == - 1 ? convert_trc(in->color_trc) : s->trc_in;
+ s->src_format.color_primaries = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_PRIMARIES_UNSPECIFIED : s->primaries_in == -1 ? convert_primaries(in->color_primaries) : s->primaries_in;
+ 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;
s->dst_format.width = out->width;
s->dst_format.height = out->height;
@@ -693,6 +697,14 @@ static const AVOption zscale_options[] = {
{ "ycgco", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_YCGCO}, 0, 0, FLAGS, "matrix" },
{ "2020_ncl", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_NCL}, 0, 0, FLAGS, "matrix" },
{ "2020_cl", 0, 0, AV_OPT_TYPE_CONST, {.i64 = ZIMG_MATRIX_2020_CL}, 0, 0, FLAGS, "matrix" },
+ { "rangein", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
+ { "rin", "set input color range", OFFSET(range_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
+ { "primariesin", "set input color primaries", OFFSET(primaries_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_PRIMARIES_2020, FLAGS, "primaries" },
+ { "pin", "set input color primaries", OFFSET(primaries_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_PRIMARIES_2020, FLAGS, "primaries" },
+ { "transferin", "set input transfer characteristic", OFFSET(trc_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_TRANSFER_2020_12, FLAGS, "transfer" },
+ { "tin", "set input transfer characteristic", OFFSET(trc_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_TRANSFER_2020_12, FLAGS, "transfer" },
+ { "matrixin", "set input colorspace matrix", OFFSET(colorspace_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_MATRIX_2020_CL, FLAGS, "matrix" },
+ { "min", "set input colorspace matrix", OFFSET(colorspace_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_MATRIX_2020_CL, FLAGS, "matrix" },
{ NULL }
};
More information about the ffmpeg-cvslog
mailing list