devices/video/decoder: use decoder pixel format type in DecoderDevice

Use the decoder's own pixel format type to avoid using the libvda one in
the DecoderDevice interface.

BUG=b:169295147
BUG=b:161774071
TEST=Youtube video playback works on kukui-arc-r.
TEST=Youtube video playback works on hatch-arc-r.

Change-Id: I85589c25d337a517e4d98c55e8fb4e968c0c3e46
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2477405
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alex Lau <alexlau@chromium.org>
This commit is contained in:
Alexandre Courbot 2020-10-11 18:04:09 +09:00 committed by Commit Bot
parent 828150b5d4
commit 2b9bf44f78
3 changed files with 23 additions and 6 deletions

View file

@ -65,7 +65,7 @@ pub trait DecoderSession {
fn use_output_buffer(
&self,
picture_buffer_id: i32,
format: libvda::PixelFormat,
format: Format,
output_buffer: RawFd,
planes: &[libvda::FramePlane],
) -> VideoResult<()>;

View file

@ -28,6 +28,20 @@ impl TryFrom<Format> for libvda::Profile {
}
}
impl TryFrom<Format> for libvda::PixelFormat {
type Error = VideoError;
fn try_from(format: Format) -> Result<Self, Self::Error> {
Ok(match format {
Format::NV12 => libvda::PixelFormat::NV12,
_ => {
error!("specified format {} is not supported by VDA", format);
return Err(VideoError::InvalidParameter);
}
})
}
}
pub struct LibvdaSession<'a> {
session: libvda::decode::Session<'a>,
}
@ -62,13 +76,16 @@ impl<'a> DecoderSession for LibvdaSession<'a> {
fn use_output_buffer(
&self,
picture_buffer_id: i32,
format: libvda::PixelFormat,
format: Format,
output_buffer: RawFd,
planes: &[libvda::FramePlane],
) -> VideoResult<()> {
Ok(self
.session
.use_output_buffer(picture_buffer_id, format, output_buffer, planes)?)
Ok(self.session.use_output_buffer(
picture_buffer_id,
libvda::PixelFormat::try_from(format)?,
output_buffer,
planes,
)?)
}
fn reuse_output_buffer(&self, picture_buffer_id: i32) -> VideoResult<()> {

View file

@ -615,7 +615,7 @@ impl<'a, D: DecoderBackend> Decoder<D> {
// Take ownership of this file by `into_raw_fd()` as this
// file will be closed by libvda.
let fd = resource_info.file.into_raw_fd();
session.use_output_buffer(buffer_id as i32, libvda::PixelFormat::NV12, fd, &planes)
session.use_output_buffer(buffer_id as i32, Format::NV12, fd, &planes)
}
}
}