Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Vp8 chroma decoding #952

Closed
wants to merge 5 commits into from
Closed

Conversation

birktj
Copy link
Member

@birktj birktj commented May 7, 2019

This is a sort of working implementation of vp8 chroma decoding. It is quite ugly so it requires a little clean-up before it is ready, but it would be nice if people could try it out as I am sure it has a few bugs. The results still don't look entirely correct, but I am wondering if it is just the missing loop-filtering, can anyone confirm/deny this?

I started by splitting the vp8 decoder into some smaller modules to keep my own sanity, so sorry for the large diff.

I am also quite curious as to how the decoder ended up in this state, the actual work wasn't too bad after you got around the code and the reference so it would be interesting to know why it was never finished.

This should fix #939

@HeroicKatora
Copy link
Member

HeroicKatora commented May 15, 2019

This may be an issue with color quantization or color space. It could be that the final conversion you are performing is Y'CbCr to the png output expecting sRGB (I'm near 100% sure that this cannot be done to the best accuracy with a strictly linear function, only to linear RGB. At least sRGB color spaces specifies a quantization/encoding with an exponential function transformation). I'm not really sure though, the output looks more 'blocky' then the one I get with imagemagick, not directly more bright or dark.


let r = 298.082 * y / 256. + 408.583 * u / 256. - 222.291;
let g = 298.082 * y / 256. - 100.291* v / 256. - 208.120 * u / 256. + 135.576;
let b = 298.082 * y / 256. + 516.412 * v / 256. - 276.836;
Copy link
Member

Choose a reason for hiding this comment

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

Where do these come from? It would be helpful to get a reference to something here. From googling the floating point numbers, I'd guess: https://www.microsemi.com/document-portal/doc_view/135317-ug0639-color-space-conversion-user-guide

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to be from the ITU-R BT.601 standard

https://en.m.wikipedia.org/wiki/YCbCr

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@HeroicKatora HeroicKatora May 16, 2019

Choose a reason for hiding this comment

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

Furthermore, 'Wikipedia' leaves out the precise definition of 'corresponding RGB space' which if you carefully compare the xy-values of blue and green, is not the same as the RGB space defined for sRGB/rec.709.

Copy link
Member

Choose a reason for hiding this comment

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

In any case, I would have expected the numbers from the section 'without any roundings' to appear here, as we don't have any problems with better precision when we use f32 anyways.

Copy link
Member Author

Choose a reason for hiding this comment

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

The numbers come from the linked Wikipedia page, however I will have a look at the standard and move this to a dedicated module with references to the standard.

@birktj
Copy link
Member Author

birktj commented May 17, 2019

@HeroicKatora it wouldn't surprise me if there are problems with the color conversion, I will have another look at that part as well. However I don't think that is what that is causing the errors that I am thinking about comes from that. Given that the loop filters purpose is to smooth the edges between subblocks and macroblocks I would guess that it should fix some of this "blocky output".

I am going to add loop-filtering in this PR, but exam period is closing in so this will maybe advance a bit slowly.

@HeroicKatora
Copy link
Member

Alright. While I do think that the color conversion is not 100% accurate, it does indeed not explain the blocky artifacts. If you want to continue to search then this is fine. But don't feel pressured, there is no deadline here :) (Reminder: I have one PR open for a few months now as well, that's what drafts are for).

@est31
Copy link
Contributor

est31 commented Oct 14, 2019

Any news on this? I'd love to be able to use webp, but color support is a blocker.

@birktj
Copy link
Member Author

birktj commented Oct 14, 2019

@est31, I would really like to finish this and I am planning on picking it back up sometime soon, however I can't say exactly when.

If somebody else wants and have the ability to continue with this I would be happy if you do.

@lovasoa
Copy link
Contributor

lovasoa commented Sep 4, 2020

Hi ! Any news ? What exactly is missing before this can be merged ?

@birktj
Copy link
Member Author

birktj commented Sep 4, 2020

@lovasoa So there are two things. First this patch is very much out of date, so quite some work would be required in order to merge it. Second and the reason this was never finished to begin with is that loop filtering is missing, this causes the output to be quite "blocky". Loop filtering is not entirely trivial to implement, but shouldn't be to bad when following the RFC.

@HeroicKatora
Copy link
Member

Would it be easier to develop this in its own package? I suppose it would also enable a more exhaustive and tailored interface and improvements in smaller increments with less release pressure. As long as the general structure of the implementation doesn't diverge too much it should be relatively painless to switch to a dependency as compared to in-tree.

@birktj
Copy link
Member Author

birktj commented Sep 4, 2020

@HeroicKatora I definitely think that the vp8 decoder should be extracted into its own crate at some point. However I don't think it is required in order to implement chroma decoding.

What would help a lot though, would be to split the vp8 module into multiple files (first commit in this PR). The vp8.rs file is currently is currently over 2k lines long which makes modifications a real chore.

@est31
Copy link
Contributor

est31 commented Sep 4, 2020

@birktj It might be helpful if the PR could be rebased and merged, without the loop decoding implemented, so that it doesn't bitrot any more. The functionality itself could still be disabled, but the only missing item would be loop decoding, which can then be done by someone separately.

@est31
Copy link
Contributor

est31 commented Jan 30, 2023

I think this PR got superseded by a list of PRs from @tristanphease , eg #1536 #1549 and #1685 , and can thus be closed.

@fintelia fintelia closed this Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VP8 chroma decoding
6 participants