Skip to content

Truly independent web browser

LibMediaCodecs: Carry CICP through the Vulkan decode queue

Zaggy102496fded040159
diff --git a/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.cpp b/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.cpp
index 587d9297cc2..6e1b87d9215 100644
--- a/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.cpp
+++ b/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.cpp
@@ -712,6 +712,7 @@ DecoderErrorOr<void> FFmpegVulkanVideoDecoder::receive_decoded_frames(EndOfStrea
DecodingFrame decoding_frame;
decoding_frame.frame = frame;
decoding_frame.timing = *timing;
+ decoding_frame.cicp = coding_independent_code_points_of(m_functions, *m_codec_context, {});
decoding_frame.generation = m_generation;
auto decoded = semaphore_value_of(*frame);
decoding_frame.semaphore = decoded.semaphore;
@@ -807,7 +808,7 @@ DecoderErrorOr<FFmpegVulkanVideoDecoder::DecodedOutput> FFmpegVulkanVideoDecoder
Gfx::Size<u32> size { static_cast<u32>(frame.width), static_cast<u32>(frame.height) };
auto bit_depth = bit_depth_of(frames_context);
auto contents = DECODER_TRY_ALLOC(try_make_ref_counted<VulkanFrameContents>(m_functions, exchange(decoding_frame.frame, nullptr)));
- return DecodedOutput { move(surface), move(contents), decoding_frame.timing, size, bit_depth };
+ return DecodedOutput { move(surface), move(contents), decoding_frame.timing, size, bit_depth, decoding_frame.cicp };
}
DecoderErrorOr<void> FFmpegVulkanVideoDecoder::prepare_to_copy_frames_from(AVFrame const& frame)
@@ -1107,7 +1108,8 @@ DecoderErrorOr<NonnullRefPtr<VideoFrame>> FFmpegVulkanVideoDecoder::take_next_ou
if (!storage)
return DecoderError::with_description(DecoderErrorCategory::TryAgain, "Every video surface the decoder may hand out is held elsewhere"sv);
- auto cicp = coding_independent_code_points_of(m_functions, *m_codec_context, container_cicp);
+ auto cicp = container_cicp;
+ cicp.adopt_specified_values(output.cicp);
auto frame = DECODER_TRY_ALLOC(try_make_ref_counted<VideoFrame>(output.timing.timestamp, output.timing.duration, output.size, output.bit_depth, Subsampling::yuv420(), cicp, storage.release_nonnull()));
m_outputs.take_first();
return frame;
diff --git a/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.h b/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.h
index 0b14574d50e..a351d9b8c2a 100644
--- a/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.h
+++ b/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.h
@@ -62,6 +62,8 @@ private:
// None marks the end of the stream, after the last frame.
AVFrame* frame { nullptr };
VideoFramesAwaitingOutput::Frame timing;
+ // The codec context that decoded the frame can be replaced before the frame goes out.
+ CodingIndependentCodePoints cicp;
u64 generation { 0 };
// Later decodes that reference the frame advance its semaphore further, so the value its own decode signals
// is taken as soon as FFmpeg hands the frame out.
@@ -76,6 +78,7 @@ private:
VideoFramesAwaitingOutput::Frame timing;
Gfx::Size<u32> size;
u8 bit_depth { 0 };
+ CodingIndependentCodePoints cicp;
};
enum class EndOfStreamIsFinal : u8 {