diff options
author | David Staessens <dstaessens@google.com> | 2020-12-01 14:43:17 +0900 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-04 11:50:08 +0000 |
commit | af53d9292e44c982b45d6acc9957dbb1028d6876 (patch) | |
tree | 97f8f31921537eacff6a274613bf60fe89e693d4 | |
parent | 22f808ff13e6f472c373382f45410f6dec300596 (diff) | |
download | crosvm-af53d9292e44c982b45d6acc9957dbb1028d6876.tar.gz |
crosvm: Propagate keyframe flag back to virtio encoder.
This CL makes changes so the VIRTIO_VIDEO_BUFFER_FLAG_IFRAME flag is
set and propagated back to the virtio encoder whenever the Chrome
encoder creates a keyframe.
BUG=b:173077927
TEST=tast run DUT arc.PowerCameraRecordingPerf.vm
Change-Id: I4029f3d7b745937e7960abba896c458182cf942e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2567307
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: David Staessens <dstaessens@chromium.org>
Commit-Queue: David Staessens <dstaessens@chromium.org>
-rw-r--r-- | devices/src/virtio/video/encoder/encoder.rs | 1 | ||||
-rw-r--r-- | devices/src/virtio/video/encoder/libvda_encoder.rs | 4 | ||||
-rw-r--r-- | devices/src/virtio/video/encoder/mod.rs | 10 |
3 files changed, 11 insertions, 4 deletions
diff --git a/devices/src/virtio/video/encoder/encoder.rs b/devices/src/virtio/video/encoder/encoder.rs index d22dd2165..d7226fd3c 100644 --- a/devices/src/virtio/video/encoder/encoder.rs +++ b/devices/src/virtio/video/encoder/encoder.rs @@ -54,6 +54,7 @@ pub enum EncoderEvent { ProcessedOutputBuffer { id: OutputBufferId, bytesused: u32, + keyframe: bool, timestamp: u64, }, FlushResponse { diff --git a/devices/src/virtio/video/encoder/libvda_encoder.rs b/devices/src/virtio/video/encoder/libvda_encoder.rs index 3f1793850..365daae9b 100644 --- a/devices/src/virtio/video/encoder/libvda_encoder.rs +++ b/devices/src/virtio/video/encoder/libvda_encoder.rs @@ -347,13 +347,13 @@ impl<'a> EncoderSession for LibvdaEncoderSession<'a> { ProcessedOutputBuffer { output_buffer_id, payload_size, + key_frame, timestamp, - // TODO(alexlau): Pass the `key_frame` field here when it's possible to - // propagate back to the client. .. } => EncoderEvent::ProcessedOutputBuffer { id: output_buffer_id as u32, bytesused: payload_size, + keyframe: key_frame, timestamp: timestamp as u64, }, FlushResponse { flush_done } => EncoderEvent::FlushResponse { flush_done }, diff --git a/devices/src/virtio/video/encoder/mod.rs b/devices/src/virtio/video/encoder/mod.rs index 04d82afbb..1ca14d8c0 100644 --- a/devices/src/virtio/video/encoder/mod.rs +++ b/devices/src/virtio/video/encoder/mod.rs @@ -337,6 +337,7 @@ impl<T: EncoderSession> Stream<T> { &mut self, output_buffer_id: OutputBufferId, bytesused: u32, + keyframe: bool, timestamp: u64, ) -> Option<Vec<VideoEvtResponseType>> { let resource_id = *match self.encoder_output_buffer_ids.get(&output_buffer_id) { @@ -382,7 +383,11 @@ impl<T: EncoderSession> Stream<T> { // At the moment, a buffer is saved in `eos_notification_buffer`, and // the EOS flag is populated and returned after a flush() command. // TODO(b/149725148): Populate flags once libvda supports it. - flags: 0, + flags: if keyframe { + protocol::VIRTIO_VIDEO_BUFFER_FLAG_IFRAME + } else { + 0 + }, size: bytesused, }; @@ -1292,8 +1297,9 @@ impl<T: Encoder> Device for EncoderDevice<T> { EncoderEvent::ProcessedOutputBuffer { id: output_buffer_id, bytesused, + keyframe, timestamp, - } => stream.processed_output_buffer(output_buffer_id, bytesused, timestamp), + } => stream.processed_output_buffer(output_buffer_id, bytesused, keyframe, timestamp), EncoderEvent::FlushResponse { flush_done } => stream.flush_response(flush_done), EncoderEvent::NotifyError { error } => stream.notify_error(error), } |