Signed-off-by: Paul B Mahol <one...@gmail.com> --- The fate test should be redone.
--- libavfilter/vf_lut.c | 57 ++++++++++++++++++++++++++++++++------- tests/ref/fate/filter-pixfmts-lut | 4 +++ 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index 93b18a8..d8f9d11 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -59,7 +59,7 @@ enum var_name { typedef struct LutContext { const AVClass *class; - uint8_t lut[4][256]; ///< lookup table for each component + uint16_t lut[4][256 * 4]; ///< lookup table for each component char *comp_expr_str[4]; AVExpr *comp_expr[4]; int hsub, vsub; @@ -112,7 +112,9 @@ static av_cold void uninit(AVFilterContext *ctx) AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV440P, \ AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P, \ AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, \ - AV_PIX_FMT_YUVJ440P + AV_PIX_FMT_YUVJ440P, \ + AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV420P10,\ + AV_PIX_FMT_YUV440P10 #define RGB_FORMATS \ AV_PIX_FMT_ARGB, AV_PIX_FMT_RGBA, \ @@ -216,10 +218,18 @@ static int config_props(AVFilterLink *inlink) case AV_PIX_FMT_YUVA420P: case AV_PIX_FMT_YUVA422P: case AV_PIX_FMT_YUVA444P: - min[Y] = min[U] = min[V] = 16; - max[Y] = 235; - max[U] = max[V] = 240; - min[A] = 0; max[A] = 255; + case AV_PIX_FMT_YUV420P10: + case AV_PIX_FMT_YUV422P10: + case AV_PIX_FMT_YUV440P10: + case AV_PIX_FMT_YUV444P10: + min[Y] = 16 * (1 << (desc->comp[0].depth_minus1 - 7)); + min[U] = 16 * (1 << (desc->comp[1].depth_minus1 - 7)); + min[V] = 16 * (1 << (desc->comp[2].depth_minus1 - 7)); + min[A] = 0; + max[Y] = 235 * (1 << (desc->comp[0].depth_minus1 - 7)); + max[U] = 240 * (1 << (desc->comp[1].depth_minus1 - 7)); + max[V] = 240 * (1 << (desc->comp[2].depth_minus1 - 7)); + max[A] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1; break; default: min[0] = min[1] = min[2] = min[3] = 0; @@ -255,7 +265,7 @@ static int config_props(AVFilterLink *inlink) s->var_values[VAR_MAXVAL] = max[color]; s->var_values[VAR_MINVAL] = min[color]; - for (val = 0; val < 256; val++) { + for (val = 0; val < 256 * 4; val++) { s->var_values[VAR_VAL] = val; s->var_values[VAR_CLIPVAL] = av_clip(val, min[color], max[color]); s->var_values[VAR_NEGVAL] = @@ -283,7 +293,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) LutContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out; - uint8_t *inrow, *outrow, *inrow0, *outrow0; int i, j, plane, direct = 0; if (av_frame_is_writable(in)) { @@ -300,9 +309,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (s->is_rgb) { /* packed */ + uint8_t *inrow, *outrow, *inrow0, *outrow0; const int w = inlink->w; const int h = in->height; - const uint8_t (*tab)[256] = (const uint8_t (*)[256])s->lut; + const uint16_t (*tab)[256*4] = (const uint16_t (*)[256*4])s->lut; const int in_linesize = in->linesize[0]; const int out_linesize = out->linesize[0]; const int step = s->step; @@ -326,14 +336,41 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) inrow0 += in_linesize; outrow0 += out_linesize; } + } else if (outlink->format == AV_PIX_FMT_YUV444P10 || + outlink->format == AV_PIX_FMT_YUV440P10 || + outlink->format == AV_PIX_FMT_YUV422P10 || + outlink->format == AV_PIX_FMT_YUV420P10) { + uint16_t *inrow, *outrow; + + for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++) { + int vsub = plane == 1 || plane == 2 ? s->vsub : 0; + int hsub = plane == 1 || plane == 2 ? s->hsub : 0; + int h = FF_CEIL_RSHIFT(inlink->h, vsub); + int w = FF_CEIL_RSHIFT(inlink->w, hsub); + const uint16_t *tab = s->lut[plane]; + const int in_linesize = in->linesize[plane]; + const int out_linesize = out->linesize[plane]; + + inrow = (uint16_t *)in ->data[plane]; + outrow = (uint16_t *)out->data[plane]; + + for (i = 0; i < h; i++) { + for (j = 0; j < w; j++) + outrow[j] = tab[inrow[j]]; + inrow += in_linesize; + outrow += out_linesize; + } + } } else { /* planar */ + uint8_t *inrow, *outrow; + for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++) { int vsub = plane == 1 || plane == 2 ? s->vsub : 0; int hsub = plane == 1 || plane == 2 ? s->hsub : 0; int h = FF_CEIL_RSHIFT(inlink->h, vsub); int w = FF_CEIL_RSHIFT(inlink->w, hsub); - const uint8_t *tab = s->lut[plane]; + const uint16_t *tab = s->lut[plane]; const int in_linesize = in->linesize[plane]; const int out_linesize = out->linesize[plane]; diff --git a/tests/ref/fate/filter-pixfmts-lut b/tests/ref/fate/filter-pixfmts-lut index 1deac4c..7c9811d 100644 --- a/tests/ref/fate/filter-pixfmts-lut +++ b/tests/ref/fate/filter-pixfmts-lut @@ -7,9 +7,13 @@ rgba 7bc854c2698b78af3e9159a19c2d9d21 yuv410p 51b39a0e33f108e652457a26667319ea yuv411p 9204c5af92aef4922a05f58c1f6c095e yuv420p 7c43bb0cae8dee633375c89295598508 +yuv420p10le 77583cf09556489ce6c79c48e730c93a yuv422p 67df35da0c35e54882492b2365438254 +yuv422p10le ef08cb8c149d2eb2cd2255f4c54d0272 yuv440p 5e41adcfc27be4369afd217b61b2ffe3 +yuv440p10le ed1f155a8c2b6bdf040c4b7df4b68420 yuv444p a2b58590aef88db2c1f14a1a3a3b0359 +yuv444p10le b9d9fe575277c7938a84dfa89b17cc2a yuva420p 518a380bf1af60ef2ecf4754eec088e9 yuva422p 7110ac2e37377b05b6fc5ad967dfabb5 yuva444p 642f3958f141dece9e99407945e2ef43 -- 1.7.11.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel