Add bit depth information to PlanarYuvBuffer
For HDR codecs, we expect to receive input that has 10-bit color depth. But
currently, WebRTC assumes only 8-bit input and output. This CL adds k010
format that represent this input.
Bug: webrtc:9376
Change-Id: Ie7df64b0eddb0752b493e0457a49083a1e87ba51
Reviewed-on: https://webrtc-review.googlesource.com/81920
Commit-Queue: Emircan Uysaler <emircan@webrtc.org>
Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23749}diff --git a/api/video/video_frame_buffer.h b/api/video/video_frame_buffer.h
index 2be7e0b..1e8169a 100644
--- a/api/video/video_frame_buffer.h
+++ b/api/video/video_frame_buffer.h
@@ -21,6 +21,7 @@
class I420BufferInterface;
class I420ABufferInterface;
class I444BufferInterface;
+class I010BufferInterface;
// Base class for frame buffers of different types of pixel format and storage.
// The tag in type() indicates how the data is represented, and each type is
@@ -47,6 +48,7 @@
kI420,
kI420A,
kI444,
+ kI010,
};
// This function specifies in what pixel format the data is stored in.
@@ -73,24 +75,21 @@
const I420ABufferInterface* GetI420A() const;
I444BufferInterface* GetI444();
const I444BufferInterface* GetI444() const;
+ I010BufferInterface* GetI010();
+ const I010BufferInterface* GetI010() const;
protected:
~VideoFrameBuffer() override {}
};
-// This interface represents Type::kI420 and Type::kI444.
+// This interface represents planar formats.
class PlanarYuvBuffer : public VideoFrameBuffer {
public:
virtual int ChromaWidth() const = 0;
virtual int ChromaHeight() const = 0;
- // Returns pointer to the pixel data for a given plane. The memory is owned by
- // the VideoFrameBuffer object and must not be freed by the caller.
- virtual const uint8_t* DataY() const = 0;
- virtual const uint8_t* DataU() const = 0;
- virtual const uint8_t* DataV() const = 0;
-
- // Returns the number of bytes between successive rows for a given plane.
+ // Returns the number of steps(in terms of Data*() return type) between
+ // successive rows for a given plane.
virtual int StrideY() const = 0;
virtual int StrideU() const = 0;
virtual int StrideV() const = 0;
@@ -99,7 +98,21 @@
~PlanarYuvBuffer() override {}
};
-class I420BufferInterface : public PlanarYuvBuffer {
+// This interface represents 8-bit color depth formats: Type::kI420,
+// Type::kI420A and Type::kI444.
+class PlanarYuv8Buffer : public PlanarYuvBuffer {
+ public:
+ // Returns pointer to the pixel data for a given plane. The memory is owned by
+ // the VideoFrameBuffer object and must not be freed by the caller.
+ virtual const uint8_t* DataY() const = 0;
+ virtual const uint8_t* DataU() const = 0;
+ virtual const uint8_t* DataV() const = 0;
+
+ protected:
+ ~PlanarYuv8Buffer() override {}
+};
+
+class I420BufferInterface : public PlanarYuv8Buffer {
public:
Type type() const override;
@@ -122,7 +135,7 @@
~I420ABufferInterface() override {}
};
-class I444BufferInterface : public PlanarYuvBuffer {
+class I444BufferInterface : public PlanarYuv8Buffer {
public:
Type type() const final;
@@ -133,6 +146,32 @@
~I444BufferInterface() override {}
};
+// This interface represents 8-bit to 16-bit color depth formats: Type::kI010.
+class PlanarYuv16BBuffer : public PlanarYuvBuffer {
+ public:
+ // Returns pointer to the pixel data for a given plane. The memory is owned by
+ // the VideoFrameBuffer object and must not be freed by the caller.
+ virtual const uint16_t* DataY() const = 0;
+ virtual const uint16_t* DataU() const = 0;
+ virtual const uint16_t* DataV() const = 0;
+
+ protected:
+ ~PlanarYuv16BBuffer() override {}
+};
+
+// Represents Type::kI010, allocates 16 bits per pixel and fills 10 least
+// significant bits with color information.
+class I010BufferInterface : public PlanarYuv16BBuffer {
+ public:
+ Type type() const override;
+
+ int ChromaWidth() const final;
+ int ChromaHeight() const final;
+
+ protected:
+ ~I010BufferInterface() override {}
+};
+
} // namespace webrtc
#endif // API_VIDEO_VIDEO_FRAME_BUFFER_H_