Skip to content

decoder: h264: Use Cow instead of slice#66

Open
bgrzesik wants to merge 2 commits intochromeos:mainfrom
bgrzesik:dec-h26x-cow
Open

decoder: h264: Use Cow instead of slice#66
bgrzesik wants to merge 2 commits intochromeos:mainfrom
bgrzesik:dec-h26x-cow

Conversation

@bgrzesik
Copy link
Contributor

@bgrzesik bgrzesik commented Mar 5, 2024

Fixes #44
Partially address #49
Relies on chromeos/cros-libva#10

@bgrzesik
Copy link
Contributor Author

bgrzesik commented Mar 6, 2024

I tested the changes using fluster and there seems to be no effect on the test results

@bgrzesik bgrzesik marked this pull request as ready for review March 6, 2024 09:12
Copy link
Contributor

@Gnurou Gnurou left a comment

Choose a reason for hiding this comment

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

Looking good, a few comments inline. Having CL descriptions shortly explain what happens in the CL would also make reviews easier imho.

offset: nalu_offset,
sc_offset: start_code_offset,
offset: nalu_offset - start_code_offset,
sc_offset: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks unrelated to the switch to Cow. Actually, this looks more like it should be part of the next commit that removes sc_offset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, It it was related to the comment below. But I've moved to the next commit.

src/utils.rs Outdated
let end = n.offset + n.size;
&n.data[start..end]
})
.ok()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, this should be unrelated to using Cow IIUC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it is

error[E0515]: cannot return value referencing local data `n.data`
   --> src/utils.rs:175:17
    |
175 |                 &n.data[start..end]
    |                 ^------^^^^^^^^^^^^
    |                 ||
    |                 |`n.data` is borrowed here
    |                 returns a value referencing data owned by the current function

I've moved slicing the bitstream to a separate commit, however before that commit this slicing had to be handled separately for Cow::Owned , like it is now.

src/utils.rs Outdated
let start = n.sc_offset;
let end = n.offset + n.size;
&n.data[start..end]
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

@Gnurou Gnurou assigned bgrzesik and Gnurou and unassigned bgrzesik Mar 8, 2024
@bgrzesik bgrzesik force-pushed the dec-h26x-cow branch 2 times, most recently from 39c9a51 to 3039f54 Compare March 8, 2024 14:50
Copy link
Contributor Author

@bgrzesik bgrzesik left a comment

Choose a reason for hiding this comment

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

Thank you @Gnurou for the review! Hopefully it's better now 😁

src/utils.rs Outdated
let end = n.offset + n.size;
&n.data[start..end]
})
.ok()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it is

error[E0515]: cannot return value referencing local data `n.data`
   --> src/utils.rs:175:17
    |
175 |                 &n.data[start..end]
    |                 ^------^^^^^^^^^^^^
    |                 ||
    |                 |`n.data` is borrowed here
    |                 returns a value referencing data owned by the current function

I've moved slicing the bitstream to a separate commit, however before that commit this slicing had to be handled separately for Cow::Owned , like it is now.

offset: nalu_offset,
sc_offset: start_code_offset,
offset: nalu_offset - start_code_offset,
sc_offset: 0,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, It it was related to the comment below. But I've moved to the next commit.

@Gnurou
Copy link
Contributor

Gnurou commented Mar 13, 2024

So unfortunately I am getting test failures on AMD when decoder: h264: vaapi: Use slice arrays instead multiple buffers is applied...

---- decoder::stateless::h264::vaapi::tests::test_25fps_nonblock stdout ----
thread 'decoder::stateless::h264::vaapi::tests::test_25fps_nonblock' panicked at src/decoder/stateless.rs:399:21:
assertion `left == right` failed: at frame 0
  left: "f3fd3133"
 right: "3eae0fa4"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- decoder::stateless::h264::vaapi::tests::test_25fps_block stdout ----
thread 'decoder::stateless::h264::vaapi::tests::test_25fps_block' panicked at src/decoder/stateless.rs:399:21:
assertion `left == right` failed: at frame 0
  left: "f3fd3133"
 right: "3eae0fa4"

Possibly AMD doesn't like slice arrays? That would be quite an issue...

@Gnurou
Copy link
Contributor

Gnurou commented Mar 13, 2024

Pushed the first 3 commits (and an update to cros-libva so build passes on the PR) - let's see if we can figure out the AMD issue...

This changes is necessary for the next change, that will require picture
to contain copies of slices.
With this commit the chromeos#44 is fixed. It is achieved by submitting multiple
slices of one picture using a single slice data buffer and all slice
parameters using a single buffer with multiple elements.
@bgrzesik
Copy link
Contributor Author

Possibly AMD doesn't like slice arrays? That would be quite an issue...

Yeah, I can confirm the AMD does not like slice arrays (source). Assert fails on debug mesa.

@Gnurou
Copy link
Contributor

Gnurou commented Mar 22, 2024

I'm wondering the reason for this limitation - tried to look at related issues on Gitlab, but could not find a matching one. Maybe we should open a bug?

@bgrzesik
Copy link
Contributor Author

I'm wondering the reason for this limitation - tried to look at related issues on Gitlab, but could not find a matching one.

When I briefly looked at the code it seemed if I understand it correctly, the slice data is submitted to the hw on vaRenderBuffer, so I think it's just a design choice.

I wonder how other users approaches this issue and if it is an Intel driver issue. I tried running ToT ccdec with video generated using gst-launch-1.0 videotestsrc num-buffers=1000 ! 'video/x-raw,width=320,height=240,format=NV12' ! x264enc option-string="slices=100" ! filesink location=a.h264 and checked the md5 with ffmpeg and checksums were the same.

Maybe we should open a bug?

Nevertheless I think it could be worth it

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.

decoder::stateless::h264::vaapi::tests::test_25fps_block regression on Intel

2 participants