swscale/graph: set up palette using current input image

Using the original input image here is completely wrong - the format/palette
could have been set to anything else in the meantime. At best, we would want to
use the original input to add_legacy_sws_pass(), but it's impossible for this
to differ from the per-pass input. The only time legacy subpasses are added
is when using cascaded contexts, but in this case, the only context actually
reading from the palette format would be the first one.

I'm not entirely sure why this code was originally written this way, but
I'm reasonably confident that it's not at all necessary. Tested extensively
on both FATE, the self-test, and real-world files.

Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-02-10 18:18:09 +01:00
committed by Niklas Haas
parent 0b446cdccd
commit b98751b13c

View File

@@ -219,8 +219,6 @@ static void free_legacy_swscale(void *priv)
static void setup_legacy_swscale(const SwsImg *out, const SwsImg *in,
const SwsPass *pass)
{
const SwsGraph *graph = pass->graph;
const SwsImg *in_orig = graph->exec.input;
SwsContext *sws = pass->priv;
SwsInternal *c = sws_internal(sws);
if (sws->flags & SWS_BITEXACT && sws->dither == SWS_DITHER_ED && c->dither_error[0]) {
@@ -229,7 +227,7 @@ static void setup_legacy_swscale(const SwsImg *out, const SwsImg *in,
}
if (usePal(sws->src_format))
ff_update_palette(c, (const uint32_t *) in_orig->data[1]);
ff_update_palette(c, (const uint32_t *) in->data[1]);
}
static inline SwsContext *slice_ctx(const SwsPass *pass, int y)