Skip to content

video: pick up VP6-with-alpha decoder fix#23743

Open
doctorpangloss wants to merge 1 commit into
ruffle-rs:masterfrom
doctorpangloss:fix/vp6-alpha-split
Open

video: pick up VP6-with-alpha decoder fix#23743
doctorpangloss wants to merge 1 commit into
ruffle-rs:masterfrom
doctorpangloss:fix/vp6-alpha-split

Conversation

@doctorpangloss
Copy link
Copy Markdown
Contributor

Bumps nihav-vp6 to ruffle-rs/nihav-vp6#3, which fixes a 3-byte off-by-one
in the VP6-alpha color sub-stream length. Adds a regression test that
decodes a real VP6-alpha keyframe end-to-end.

Fixes #23662.

@torokati44
Copy link
Copy Markdown
Member

Oh, were you able to access the content in the linked issue somehow?
Also, what do you think about #23665 ? Are both fixes necessary?

@torokati44 torokati44 added A-video T-fix Type: Bug fix (in something that's supposed to work already) labels May 18, 2026
@doctorpangloss
Copy link
Copy Markdown
Contributor Author

Oh, were you able to access the content in the linked issue somehow?

no, but the error message is just saying that swf contained vp6 with alpha, which is same as my content

sources: https://github.com/doctorpangloss/multics
compiled: https://static01.nyt.com/packages/flash/opinion/20110620-morris-emulator/Multics.swf

Also, what do you think about #23665 ? Are both fixes necessary?

afaik, they are solving different issues.

if you provide a guide for establishing baselines, i will fix all of TextLine too, because multics also needs that.

@torokati44
Copy link
Copy Markdown
Member

no, but the error message is just saying that swf contained vp6 with alpha, which is same as my content

sources: doctorpangloss/multics
compiled: static01.nyt.com/packages/flash/opinion/20110620-morris-emulator/Multics.swf

Ahh, so that's where the typewriter came from...

Also, what do you think about #23665 ? Are both fixes necessary?

afaik, they are solving different issues.

Indeed, and both are valid!

if you provide a guide for establishing baselines, i will fix all of TextLine too, because multics also needs that.

I can only point you at: https://github.com/ruffle-rs/ruffle/blob/master/CONTRIBUTING.md

And as also noted therein, under "Test Guidelines", I think the added test should be an SWF-based one too, like the one added in #23665.

BTW #23215 also touches TextLine, not sure if it's enough for this piece as well... (paging text experts @evilpie and @kjarosh)

Comment thread Cargo.lock
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you did a full cargo update. That will break a bunch of things - I suggest to just replace the git hashes in Cargo.toml, then a simple cargo check will update this file accordingly, without changing anything else.

Comment thread video/software/Cargo.toml
nihav_duck = { git = "https://github.com/ruffle-rs/nihav-vp6", rev = "e3fec79dda5120caa46a127eaafc18eb36b32408", optional = true }

[dev-dependencies]
flv-rs = { path = "../../flv" }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unnecessary.

use ruffle_video_software::decoder::VideoDecoder;
use swf::VideoCodec;

const FIXTURE: &[u8] = include_bytes!("fixtures/vp6_alpha_one_frame.flv");
Copy link
Copy Markdown
Member

@torokati44 torokati44 May 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make an SWF-based test instead of this? you can see tests/tests/swfs/visual/video/colorconversion/vp6 (IIRC) for an example.

Two interacting VP6-with-alpha (VP6A) fixes, rolled together:

- Pick up the nihav-vp6 decoder fix (bump the crate git ref): corrects
  VP6A decoding when the Y and alpha plane sizes differ.

- Premultiply the alpha in Bitmap::to_rgba for Yuva420p. VP6A carries
  straight alpha while the renderer and blend state expect premultiplied
  alpha; the previous min(c, a) clamp left every pixel with c <= a
  un-premultiplied, rendering semi-transparent video too bright. Use a
  real premultiply (c * a / 255).

Add a vp6_alpha decoder unit test, and re-baseline the
colorconversion/vp6a visual test to the corrected premultiplied render.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@torokati44
Copy link
Copy Markdown
Member

I think the two fixes would be nicer in separate commits.

@torokati44
Copy link
Copy Markdown
Member

torokati44 commented May 21, 2026

About premultiplied alpha:

The vp6a test looks exactly identical in FP and current Ruffle (without this PR) on my machine:

Maybe this is dependent on the platform or FP version? 😵

EDIT: What Flash Player, on what platform, did you use to get the new (less bright) expected image?

@torokati44
Copy link
Copy Markdown
Member

torokati44 commented May 21, 2026

Also, from the SWF spec (https://open-flash.github.io/mirrors/swf-spec-19.pdf)

EDIT: Not that these specs are infallible, or never lie...

@torokati44
Copy link
Copy Markdown
Member

torokati44 commented May 21, 2026

I hope it's not that this is done differently depending on whether the video is embedded in a SWF, or comes from an external FLV file... (I doubt that, but you can never know!)

EDIT: Well, but then the existing test wouldn't change, as that doesn't use a FLV file...

@torokati44
Copy link
Copy Markdown
Member

It also looks exactly as bright to me on Windows as on Linux in Flash Player:

@torokati44 torokati44 added the waiting-on-author Waiting on the PR author to make the requested changes label May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-video T-fix Type: Bug fix (in something that's supposed to work already) waiting-on-author Waiting on the PR author to make the requested changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error decoding flv encoded with VP6 codec

2 participants