mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 20:48:55 +00:00
virtio: video: decoder: fix NV12 plane format
A NV12 frame is made of one Y plane at full resolution, and one plane include one U and one V component for each four pixels. Thus the size of the second plane should be half of that of the first one. This is important to get right as ffmpeg conversion functions wil rely on this information and will fail if the computed size is bigger than the target buffer. BUG=b:161774071 BUG=b:169295147 TEST=Android Youtube plays properly on Hatch. Change-Id: I4196983389def3a4914c076d68067874041fab55 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3023743 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Alexandre Courbot <acourbot@chromium.org> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This commit is contained in:
parent
12a694e45e
commit
de86c8253d
1 changed files with 12 additions and 4 deletions
|
@ -339,11 +339,19 @@ impl<S: DecoderSession> Context<S> {
|
|||
let rect_width: u32 = (visible_rect.right - visible_rect.left) as u32;
|
||||
let rect_height: u32 = (visible_rect.bottom - visible_rect.top) as u32;
|
||||
|
||||
let plane_size = rect_width * rect_height;
|
||||
let stride = rect_width;
|
||||
let plane_formats = vec![
|
||||
PlaneFormat { plane_size, stride },
|
||||
PlaneFormat { plane_size, stride },
|
||||
// Y plane, 1 sample per pixel.
|
||||
PlaneFormat {
|
||||
plane_size: rect_width * rect_height,
|
||||
stride: rect_width,
|
||||
},
|
||||
// UV plane, 1 sample per group of 4 pixels for U and V.
|
||||
PlaneFormat {
|
||||
// Add one vertical line so odd resolutions result in an extra UV line to cover all the
|
||||
// Y samples.
|
||||
plane_size: rect_width * ((rect_height + 1) / 2),
|
||||
stride: rect_width,
|
||||
},
|
||||
];
|
||||
|
||||
self.out_params = Params {
|
||||
|
|
Loading…
Reference in a new issue