From 40b0bb09144209391270620b33e37fddbbea76dc Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Fri, 4 Nov 2022 18:00:09 -0500 Subject: [PATCH] LibVideo: Change all Span to ReadonlyBytes --- Userland/Libraries/LibVideo/MatroskaDemuxer.cpp | 2 +- Userland/Libraries/LibVideo/MatroskaDemuxer.h | 2 +- Userland/Libraries/LibVideo/VP9/Decoder.cpp | 4 ++-- Userland/Libraries/LibVideo/VP9/Decoder.h | 4 ++-- Userland/Libraries/LibVideo/VP9/Parser.cpp | 4 ++-- Userland/Libraries/LibVideo/VP9/Parser.h | 4 ++-- Userland/Libraries/LibVideo/VideoDecoder.h | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Userland/Libraries/LibVideo/MatroskaDemuxer.cpp b/Userland/Libraries/LibVideo/MatroskaDemuxer.cpp index e9a5cfa34f..892c68dd36 100644 --- a/Userland/Libraries/LibVideo/MatroskaDemuxer.cpp +++ b/Userland/Libraries/LibVideo/MatroskaDemuxer.cpp @@ -18,7 +18,7 @@ DecoderErrorOr> MatroskaDemuxer::from_file(String return make(document); } -DecoderErrorOr> MatroskaDemuxer::from_data(Span data) +DecoderErrorOr> MatroskaDemuxer::from_data(ReadonlyBytes data) { // FIXME: MatroskaReader should return errors. auto nullable_document = MatroskaReader::parse_matroska_from_data(data.data(), data.size()); diff --git a/Userland/Libraries/LibVideo/MatroskaDemuxer.h b/Userland/Libraries/LibVideo/MatroskaDemuxer.h index aa3987091a..17b73f18de 100644 --- a/Userland/Libraries/LibVideo/MatroskaDemuxer.h +++ b/Userland/Libraries/LibVideo/MatroskaDemuxer.h @@ -18,7 +18,7 @@ public: // FIXME: We should instead accept some abstract data streaming type so that the demuxer // can work with non-contiguous data. static DecoderErrorOr> from_file(StringView filename); - static DecoderErrorOr> from_data(Span data); + static DecoderErrorOr> from_data(ReadonlyBytes data); MatroskaDemuxer(NonnullOwnPtr& document) : m_document(move(document)) diff --git a/Userland/Libraries/LibVideo/VP9/Decoder.cpp b/Userland/Libraries/LibVideo/VP9/Decoder.cpp index 90f8160e04..318216c963 100644 --- a/Userland/Libraries/LibVideo/VP9/Decoder.cpp +++ b/Userland/Libraries/LibVideo/VP9/Decoder.cpp @@ -19,7 +19,7 @@ Decoder::Decoder() { } -DecoderErrorOr Decoder::receive_sample(Span chunk_data) +DecoderErrorOr Decoder::receive_sample(ReadonlyBytes chunk_data) { auto superframe_sizes = m_parser->parse_superframe_sizes(chunk_data); @@ -52,7 +52,7 @@ inline size_t index_from_row_and_column(u32 row, u32 column, u32 stride) return row * stride + column; } -DecoderErrorOr Decoder::decode_frame(Span frame_data) +DecoderErrorOr Decoder::decode_frame(ReadonlyBytes frame_data) { // 1. The syntax elements for the coded frame are extracted as specified in sections 6 and 7. The syntax // tables include function calls indicating when the block decode processes should be triggered. diff --git a/Userland/Libraries/LibVideo/VP9/Decoder.h b/Userland/Libraries/LibVideo/VP9/Decoder.h index 41a9123f04..119f524cfd 100644 --- a/Userland/Libraries/LibVideo/VP9/Decoder.h +++ b/Userland/Libraries/LibVideo/VP9/Decoder.h @@ -28,7 +28,7 @@ public: Decoder(); ~Decoder() override { } /* (8.1) General */ - DecoderErrorOr receive_sample(Span) override; + DecoderErrorOr receive_sample(ReadonlyBytes) override; void dump_frame_info(); DecoderErrorOr> get_decoded_frame() override; @@ -36,7 +36,7 @@ public: private: typedef i32 Intermediate; - DecoderErrorOr decode_frame(Span); + DecoderErrorOr decode_frame(ReadonlyBytes); DecoderErrorOr create_video_frame(); DecoderErrorOr allocate_buffers(); diff --git a/Userland/Libraries/LibVideo/VP9/Parser.cpp b/Userland/Libraries/LibVideo/VP9/Parser.cpp index d776379a50..300c3bca36 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.cpp +++ b/Userland/Libraries/LibVideo/VP9/Parser.cpp @@ -28,7 +28,7 @@ Parser::~Parser() { } -Vector Parser::parse_superframe_sizes(Span frame_data) +Vector Parser::parse_superframe_sizes(ReadonlyBytes frame_data) { if (frame_data.size() < 1) return {}; @@ -76,7 +76,7 @@ Vector Parser::parse_superframe_sizes(Span frame_data) } /* (6.1) */ -DecoderErrorOr Parser::parse_frame(Span frame_data) +DecoderErrorOr Parser::parse_frame(ReadonlyBytes frame_data) { m_bit_stream = make(frame_data.data(), frame_data.size()); m_syntax_element_counter = make(); diff --git a/Userland/Libraries/LibVideo/VP9/Parser.h b/Userland/Libraries/LibVideo/VP9/Parser.h index c65606eebf..154a85a4ca 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.h +++ b/Userland/Libraries/LibVideo/VP9/Parser.h @@ -33,13 +33,13 @@ class Parser { public: explicit Parser(Decoder&); ~Parser(); - DecoderErrorOr parse_frame(Span); + DecoderErrorOr parse_frame(ReadonlyBytes); void dump_info(); private: /* Annex B: Superframes are a method of storing multiple coded frames into a single chunk * See also section 5.26. */ - Vector parse_superframe_sizes(Span); + Vector parse_superframe_sizes(ReadonlyBytes); DecoderErrorOr read_frame_type(); DecoderErrorOr read_color_range(); diff --git a/Userland/Libraries/LibVideo/VideoDecoder.h b/Userland/Libraries/LibVideo/VideoDecoder.h index bcafc73fd5..a4b239c4c4 100644 --- a/Userland/Libraries/LibVideo/VideoDecoder.h +++ b/Userland/Libraries/LibVideo/VideoDecoder.h @@ -18,7 +18,7 @@ class VideoDecoder { public: virtual ~VideoDecoder() {}; - virtual DecoderErrorOr receive_sample(Span sample) = 0; + virtual DecoderErrorOr receive_sample(ReadonlyBytes sample) = 0; DecoderErrorOr receive_sample(ByteBuffer const& sample) { return receive_sample(sample.span()); } virtual DecoderErrorOr> get_decoded_frame() = 0; };