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

Revert "Revert "Enable and test high bit depth input (#437)" (#442)" and fix reconstruction output #447

Merged
merged 18 commits into from Aug 13, 2018

Conversation

rzumer
Copy link
Collaborator

@rzumer rzumer commented Aug 11, 2018

After investigating the errors caused by the original PR, it seems that the tools used for comparison are interpolating samples from Y4M files labelled as using the C420jpeg color space, which the libaom decoder always uses, regardless of the chroma positioning indicated in the header.

In order to support outputting Y4M reconstructions at high bit depths, a change in rav1e.rs set the Y4M encoder's color space to be the same as that of the input file's. This means that rav1e was now outputting C420Mpeg2 reconstructions for input files using that color space, while the decoder output was always C420jpeg and therefore required interpolating chroma samples in order to be converted to a raw image. Of course, the result was that due to interpolation error, there was a difference in raw output between the reconstructed output and the AOM decoder output.

The change that causes this issue was reverted in order to maintain compatibility between the two output streams, and because it does not currently affect compatibility with high bit depth streams, as the y4m crate does we do not yet support encoding Y4M files at high bit depths. However, the real issue that prompted a reversal of the original PR stems from:

  • the reference decoder seemingly not handling chroma placement correctly
  • the decision to decode to raw images in order to detect errors rather than simply comparing Y4M output

I recommend testing encoder output by comparing the reconstructed and decoded Y4M files, excluding the header, in the future.

The changes to this PR compared to #437 are as follows:

  • the Y4M encoder used to output reconstruction is no longer initialized to a non-default color space
  • using the -r option at high bit depths will panic, as the y4m crate does not currently support high bit depth encoding
  • the Y4M encoder used to output reconstruction is now working at high bit depth

Relevant libaom issue: https://bugs.chromium.org/p/aomedia/issues/detail?id=2096

@rzumer
Copy link
Collaborator Author

rzumer commented Aug 11, 2018

The test failure in CI is due to CDEF changes introduced after #437. Setting enable_cdef = false in the sequence header solves it.

@Kagami
Copy link
Contributor

Kagami commented Aug 11, 2018

y4m crate does not currently support high bit depth encoding

What do you mean? Stream copy example works fine for me with nyan12.y4m, producing playable 12-bit file.

@rzumer
Copy link
Collaborator Author

rzumer commented Aug 12, 2018

@Kagami interesting, on my end encoding the reconstruction in rav1e panicks with "bad input" above 8-bit, which I thought was happening on y4m's end, but that may not be the case. I will look into it later this week. I edited the description in the meantime.

@rzumer
Copy link
Collaborator Author

rzumer commented Aug 13, 2018

Regarding the reconstruction output at high bit depths, here is the relevant issue in y4m: image-rs/y4m#13

We can perform our own conversion for now using from_raw_parts. I will look into this in the next couple of days.

src/lib.rs Outdated
fs.rec.planes[1].cfg.stride,
fs.rec.planes[2].cfg.stride);

for (y, line) in fs.rec.planes[0].data.chunks_mut(stride_y).enumerate() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rec does not mutate and you can use chunks_mut() on rec_y and friends.

for (line, line_out) in fs.rec.planes[0].data.chunks().zip(rec_y.chunks_mut(pitch_y))

Copy link
Collaborator Author

@rzumer rzumer Aug 13, 2018

Choose a reason for hiding this comment

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

Done, thank you.

@tdaede
Copy link
Collaborator

tdaede commented Aug 13, 2018

LGTM.

@tdaede tdaede merged commit f63f5e9 into xiph:master Aug 13, 2018
@rzumer rzumer changed the title Revert "Revert "Enable and test high bit depth input (#437)" (#442)" Revert "Revert "Enable and test high bit depth input (#437)" (#442)" and fix reconstruction output Sep 25, 2018
barrbrain pushed a commit to barrbrain/rav1e that referenced this pull request Oct 5, 2022
…h#442)" (xiph#447)

* Attempt to process 10-bit Y4M input

Currently compiles, encodes and decodes with desynchronization

* Use high bit depth quantization tables

* Move context::clamp() to util.rs

* Fix partition context initialization for high bit depth

* Enable and test 10-bit input

* Add 10- and 12-bit test clips to build.sh

Commented out by default, to enable as needed for local testing.

* Use the same bit depth as y4m_dec for y4m_enc

* Fix benchmark module compilation

* Fix high bit depth test encoding in 8-bit

* Fix header syntax for 12-bit 4:2:0 input

* Enable and test 12-bit input

* Reflect 12-bit support in README.md

* Keep the default C420jpeg color space in y4m_encoder

* Do not allow reconstruction output at high bit depths

* Fix reconstruction output at high bit depths

* Clean up reconstruction copy to frame buffers
barrbrain pushed a commit to barrbrain/rav1e that referenced this pull request Oct 5, 2022
…h#442)" (xiph#447)

* Attempt to process 10-bit Y4M input

Currently compiles, encodes and decodes with desynchronization

* Use high bit depth quantization tables

* Move context::clamp() to util.rs

* Fix partition context initialization for high bit depth

* Enable and test 10-bit input

* Add 10- and 12-bit test clips to build.sh

Commented out by default, to enable as needed for local testing.

* Use the same bit depth as y4m_dec for y4m_enc

* Fix benchmark module compilation

* Fix high bit depth test encoding in 8-bit

* Fix header syntax for 12-bit 4:2:0 input

* Enable and test 12-bit input

* Reflect 12-bit support in README.md

* Keep the default C420jpeg color space in y4m_encoder

* Do not allow reconstruction output at high bit depths

* Fix reconstruction output at high bit depths

* Clean up reconstruction copy to frame buffers
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.

None yet

4 participants