From c66bd78e3dbbc9b6e709f74745179bdd13d2160f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Wed, 30 Nov 2011 00:06:25 +0100 Subject: [PATCH] vf_scale: support PAL8 output by producing BGR8. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While quality is bad, PAL8 support is needed to allow testing some encoders that only support PAL8 input. Signed-off-by: Reimar Döffinger --- libavfilter/vf_scale.c | 10 ++++++---- tests/ref/lavfi/pixfmts_copy | 1 + tests/ref/lavfi/pixfmts_crop | 1 + tests/ref/lavfi/pixfmts_hflip | 1 + tests/ref/lavfi/pixfmts_null | 1 + tests/ref/lavfi/pixfmts_scale | 1 + tests/ref/lavfi/pixfmts_vflip | 1 + 7 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 8483536404..e411406d8a 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -128,7 +128,7 @@ static int query_formats(AVFilterContext *ctx) if (ctx->outputs[0]) { formats = NULL; for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) - if ( sws_isSupportedOutput(pix_fmt) + if ( (sws_isSupportedOutput(pix_fmt) || pix_fmt == PIX_FMT_PAL8) && (ret = avfilter_add_format(&formats, pix_fmt)) < 0) { avfilter_formats_unref(&formats); return ret; @@ -143,6 +143,7 @@ static int config_props(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; AVFilterLink *inlink = outlink->src->inputs[0]; + enum PixelFormat outfmt = outlink->format; ScaleContext *scale = ctx->priv; int64_t w, h; double var_values[VARS_NB], res; @@ -212,21 +213,22 @@ static int config_props(AVFilterLink *outlink) scale->flags); scale->input_is_pal = av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL; + if (outfmt == PIX_FMT_PAL8) outfmt = PIX_FMT_BGR8; if (scale->sws) sws_freeContext(scale->sws); scale->sws = sws_getContext(inlink ->w, inlink ->h, inlink ->format, - outlink->w, outlink->h, outlink->format, + outlink->w, outlink->h, outfmt, scale->flags, NULL, NULL, NULL); if (scale->isws[0]) sws_freeContext(scale->isws[0]); scale->isws[0] = sws_getContext(inlink ->w, inlink ->h/2, inlink ->format, - outlink->w, outlink->h/2, outlink->format, + outlink->w, outlink->h/2, outfmt, scale->flags, NULL, NULL, NULL); if (scale->isws[1]) sws_freeContext(scale->isws[1]); scale->isws[1] = sws_getContext(inlink ->w, inlink ->h/2, inlink ->format, - outlink->w, outlink->h/2, outlink->format, + outlink->w, outlink->h/2, outfmt, scale->flags, NULL, NULL, NULL); if (!scale->sws || !scale->isws[0] || !scale->isws[1]) return AVERROR(EINVAL); diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index 5abb346c4e..3a638c33c2 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -20,6 +20,7 @@ monob 668ebe8b8103b9046b251b2fa8a1d88f monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f +pal8 dec8ed2258ec89b8a796f21cad4df867 rgb0 ff1a9f355d43f9d25f07a191b5aa906c rgb24 b41eba9651e1b5fe386289b506188105 rgb48be cc139ec1dd9451f0e049c0cb3a0c8aa2 diff --git a/tests/ref/lavfi/pixfmts_crop b/tests/ref/lavfi/pixfmts_crop index ac79ac6ba7..b84e1b8191 100644 --- a/tests/ref/lavfi/pixfmts_crop +++ b/tests/ref/lavfi/pixfmts_crop @@ -13,6 +13,7 @@ bgra 395c9f706fccda721471acaa5c96c16c gray 8c4850e66562a587a292dc728a65ea4a gray16be 257b4339925b0e672f552d8c9511f2c3 gray16le 67cf7b26cda55356cc25e0f4e42cc136 +pal8 d6c1b598244f41e2f005e42407d234d2 rgb24 3b90ed64b687d3dc186c6ef521dc71a8 rgb48be e6fd353c0eb9bea889423954414bea35 rgb48le 68a1723da11ce08b502d42e204376503 diff --git a/tests/ref/lavfi/pixfmts_hflip b/tests/ref/lavfi/pixfmts_hflip index dfedba816f..ba012ea76a 100644 --- a/tests/ref/lavfi/pixfmts_hflip +++ b/tests/ref/lavfi/pixfmts_hflip @@ -13,6 +13,7 @@ bgra 01ca21e7e6a8d1281b4553bde8e8a404 gray 03efcb4ab52a24c0af0e03cfd26c9377 gray16be 632535b46edec78a6534ef18d37f2b71 gray16le 5c24e6f847bf9a41a40760c0d15df161 +pal8 6c1545bb295e9289add1760851a3d9c9 rgb24 754f1722fc738590cc407ac65749bfe8 rgb48be d690412ca5fada031b5da47b87096248 rgb48le c901feb564232f5d0bc0eabd66dae3e7 diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index 5abb346c4e..3a638c33c2 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -20,6 +20,7 @@ monob 668ebe8b8103b9046b251b2fa8a1d88f monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f +pal8 dec8ed2258ec89b8a796f21cad4df867 rgb0 ff1a9f355d43f9d25f07a191b5aa906c rgb24 b41eba9651e1b5fe386289b506188105 rgb48be cc139ec1dd9451f0e049c0cb3a0c8aa2 diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index 9239198520..53ea7db703 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -20,6 +20,7 @@ monob cb62f31b701c6e987b574974d1b31e32 monow fd5d417ab7728acddffc06870661df61 nv12 4676d59db43d657dc12841f6bc3ab452 nv21 69c699510ff1fb777b118ebee1002f14 +pal8 6324fa058e1bc157ed7132bfe4022317 rgb0 1bd6f54ad067503ac9783a70062c8f87 rgb24 13ff53ebeab74dc05492836f1cfbd2c1 rgb48be 8fac63787a711886030f8e056872b488 diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index 193e1538e6..ce613debe5 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -20,6 +20,7 @@ monob d0cf8732677a5360b6160133043590d8 monow ff9869d067ecb94eb9d90c9750c31fea nv12 046f00f598ce14d9854a3534a5c99114 nv21 01ea369dd2d0d3ed7451dc5c8d61497f +pal8 47ed19a7e128b0e33c25d2a463b0611a rgb0 330bd6168e46c0d5eb4acbdbb50afa2e rgb24 eaefabc168d0b14576bab45bc1e56e1e rgb48be 62dd185862ed142283bd300eb6dbd216