Marshal codec_specific_data flag through to parsers
Codec2 can pass codec specific data that does not produce a
frame. Each parser can then determine what to do with it.
The vp9 parser can not determine what to do with the
codec specific data without the data being explicitly marked
as such. In the end the parser does not need this data at all,
it can be thrown out.
Bug: 410904398
Test: atest android.video.cts.CodecDecoderPerformanceTest#testPerformanceOfHardwareVideoDecoders[108_c2.cros-codecs.vp9.decoder_1_2.5_ORDINARY]
Change-Id: I0e61d9f83a128f36346933b732b9fb6582db7d7f
diff --git a/src/c2_wrapper.rs b/src/c2_wrapper.rs
index 99ca906..29bcdf5 100644
--- a/src/c2_wrapper.rs
+++ b/src/c2_wrapper.rs
@@ -63,6 +63,7 @@
// C2DecoderWorker based on parsing, so we don't actually need to populate this at the HAL
// level.
pub contains_visible_frame: bool,
+ pub codec_specific_data: bool,
// TODO: Add output delay and color aspect support as needed.
}
@@ -89,6 +90,7 @@
timestamp: 0,
contains_visible_frame: false,
drain: DrainMode::NoDrain,
+ codec_specific_data: false,
}
}
}
diff --git a/src/c2_wrapper/c2_decoder.rs b/src/c2_wrapper/c2_decoder.rs
index b511317..f4bdade 100644
--- a/src/c2_wrapper/c2_decoder.rs
+++ b/src/c2_wrapper/c2_decoder.rs
@@ -355,10 +355,14 @@
C2Decoder::ImportingDecoder(decoder) => decoder.decode(
job.timestamp,
bitstream,
+ job.codec_specific_data,
&mut *self.alloc_cb.lock().unwrap(),
),
- C2Decoder::ConvertingDecoder(decoder) => {
- decoder.decode(job.timestamp, bitstream, &mut || {
+ C2Decoder::ConvertingDecoder(decoder) => decoder.decode(
+ job.timestamp,
+ bitstream,
+ job.codec_specific_data,
+ &mut || {
let external = (*self.alloc_cb.lock().unwrap())()?;
let internal =
self.auxiliary_frame_pool.as_mut().unwrap().alloc()?;
@@ -366,8 +370,8 @@
internal: internal,
external: Mutex::new(Some(external)),
})
- })
- }
+ },
+ ),
}
} else {
// The drain signals are artificial jobs constructed by the C2Wrapper itself,
diff --git a/src/decoder/stateless.rs b/src/decoder/stateless.rs
index f70b2cc..7560d56 100644
--- a/src/decoder/stateless.rs
+++ b/src/decoder/stateless.rs
@@ -183,6 +183,7 @@
&mut self,
timestamp: u64,
bitstream: &[u8],
+ codec_specific_data: bool,
alloc_cb: &mut dyn FnMut() -> Option<<Self::Handle as DecodedHandle>::Frame>,
) -> Result<(usize, bool), DecodeError>;
@@ -259,9 +260,10 @@
&mut self,
timestamp: u64,
bitstream: &[u8],
+ codec_specific_data: bool,
alloc_cb: &mut dyn FnMut() -> Option<<Self::Handle as DecodedHandle>::Frame>,
) -> Result<(usize, bool), DecodeError> {
- self.0.decode(timestamp, bitstream, alloc_cb)
+ self.0.decode(timestamp, bitstream, codec_specific_data, alloc_cb)
}
fn queue_empty_frame(&mut self, timestamp: u64) {
diff --git a/src/decoder/stateless/av1.rs b/src/decoder/stateless/av1.rs
index f1133e2..c18e10f 100644
--- a/src/decoder/stateless/av1.rs
+++ b/src/decoder/stateless/av1.rs
@@ -322,6 +322,7 @@
&mut self,
timestamp: u64,
bitstream: &[u8],
+ _codec_specific_data: bool,
alloc_cb: &mut dyn FnMut() -> Option<
<<B as StatelessDecoderBackend>::Handle as DecodedHandle>::Frame,
>,
diff --git a/src/decoder/stateless/h264.rs b/src/decoder/stateless/h264.rs
index d7c6fb5..bf0ed44 100644
--- a/src/decoder/stateless/h264.rs
+++ b/src/decoder/stateless/h264.rs
@@ -1254,6 +1254,7 @@
&mut self,
timestamp: u64,
bitstream: &[u8],
+ _codec_specific_data: bool,
alloc_cb: &mut dyn FnMut() -> Option<
<<B as StatelessDecoderBackend>::Handle as DecodedHandle>::Frame,
>,
diff --git a/src/decoder/stateless/h265.rs b/src/decoder/stateless/h265.rs
index cc50d9d..803a03c 100644
--- a/src/decoder/stateless/h265.rs
+++ b/src/decoder/stateless/h265.rs
@@ -1146,6 +1146,7 @@
&mut self,
timestamp: u64,
bitstream: &[u8],
+ _codec_specific_data: bool,
alloc_cb: &mut dyn FnMut() -> Option<
<<B as StatelessDecoderBackend>::Handle as DecodedHandle>::Frame,
>,
diff --git a/src/decoder/stateless/vp8.rs b/src/decoder/stateless/vp8.rs
index 27159bd..c75d5f7 100644
--- a/src/decoder/stateless/vp8.rs
+++ b/src/decoder/stateless/vp8.rs
@@ -12,6 +12,8 @@
use std::os::fd::AsFd;
use std::os::fd::BorrowedFd;
+use log::debug;
+
use crate::codec::vp8::parser::Frame;
use crate::codec::vp8::parser::Header;
use crate::codec::vp8::parser::MbLfAdjustments;
@@ -240,10 +242,16 @@
&mut self,
timestamp: u64,
bitstream: &[u8],
+ codec_specific_data: bool,
alloc_cb: &mut dyn FnMut() -> Option<
<<B as StatelessDecoderBackend>::Handle as DecodedHandle>::Frame,
>,
) -> Result<(usize, bool), DecodeError> {
+ if codec_specific_data {
+ debug!("discarding {} bytes of codec specific data", bitstream.len());
+ return Ok((bitstream.len(), false));
+ }
+
let frame = self
.codec
.parser
diff --git a/src/decoder/stateless/vp9.rs b/src/decoder/stateless/vp9.rs
index 20f466d..a11aa2f 100644
--- a/src/decoder/stateless/vp9.rs
+++ b/src/decoder/stateless/vp9.rs
@@ -243,12 +243,18 @@
&mut self,
timestamp: u64,
bitstream: &[u8],
+ codec_specific_data: bool,
alloc_cb: &mut dyn FnMut() -> Option<
<<B as StatelessDecoderBackend>::Handle as DecodedHandle>::Frame,
>,
) -> Result<(usize, bool), DecodeError> {
let mut processed_visible_frame = false;
+ if codec_specific_data {
+ debug!("discarding {} bytes of codec specific data", bitstream.len());
+ return Ok((bitstream.len(), processed_visible_frame));
+ }
+
let frames = self
.codec
.parser