Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Unified Diff: webrtc/api/video/video_frame_buffer.h

Issue 2914463002: Add separate base classes for I420 and I444 buffers (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/api/video/video_frame_buffer.h
diff --git a/webrtc/api/video/video_frame_buffer.h b/webrtc/api/video/video_frame_buffer.h
index 6d0c99107cdced3adbedc87d5da8958dc909af95..13005afc8a57b5370e3fce5bd88717e51e970f66 100644
--- a/webrtc/api/video/video_frame_buffer.h
+++ b/webrtc/api/video/video_frame_buffer.h
@@ -18,7 +18,8 @@
namespace webrtc {
-class PlanarYuvBuffer;
+class I420BufferInterface;
+class I444BufferInterface;
// 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
@@ -58,12 +59,12 @@ class VideoFrameBuffer : public rtc::RefCountInterface {
// in another format, a conversion will take place. All implementations must
// provide a fallback to I420 for compatibility with e.g. the internal WebRTC
// software encoders.
- virtual rtc::scoped_refptr<PlanarYuvBuffer> ToI420();
+ virtual rtc::scoped_refptr<I420BufferInterface> ToI420();
// These functions should only be called if type() is of the correct type.
// Calling with a different type will result in a crash.
- rtc::scoped_refptr<PlanarYuvBuffer> GetI420();
- rtc::scoped_refptr<PlanarYuvBuffer> GetI444();
+ rtc::scoped_refptr<I420BufferInterface> GetI420();
nisse-webrtc 2017/05/29 14:20:05 I think it's nicer if we make these functions virt
magjed_webrtc 2017/05/29 17:40:07 What benefit do you see from making these function
nisse-webrtc 2017/05/30 07:05:32 I see two (weak) benefits: Consistency with the ot
kwiberg-webrtc 2017/05/30 07:32:07 Drive-by opinion: Don't be afraid of raw pointers
+ rtc::scoped_refptr<I444BufferInterface> GetI444();
// Deprecated - use ToI420() first instead.
// Returns pointer to the pixel data for a given plane. The memory is owned by
@@ -92,8 +93,8 @@ class VideoFrameBuffer : public rtc::RefCountInterface {
// This interface represents Type::kI420 and Type::kI444.
class PlanarYuvBuffer : public VideoFrameBuffer {
public:
- int ChromaWidth() const;
- int ChromaHeight() const;
+ 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.
@@ -106,12 +107,36 @@ class PlanarYuvBuffer : public VideoFrameBuffer {
int StrideU() const override = 0;
int StrideV() const override = 0;
- rtc::scoped_refptr<PlanarYuvBuffer> ToI420() override;
-
protected:
~PlanarYuvBuffer() override {}
};
+class I420BufferInterface : public PlanarYuvBuffer {
+ public:
+ Type type() const final;
+
+ int ChromaWidth() const final;
+ int ChromaHeight() const final;
+
+ rtc::scoped_refptr<I420BufferInterface> ToI420() final;
nisse-webrtc 2017/05/29 14:20:05 Here we could also put the GetI420() final {return
+
+ protected:
+ ~I420BufferInterface() override {}
+};
+
+class I444BufferInterface : public PlanarYuvBuffer {
+ public:
+ Type type() const final;
+
+ int ChromaWidth() const final;
+ int ChromaHeight() const final;
+
+ rtc::scoped_refptr<I420BufferInterface> ToI420() final;
+
+ protected:
+ ~I444BufferInterface() override {}
+};
+
} // namespace webrtc
#endif // WEBRTC_API_VIDEO_VIDEO_FRAME_BUFFER_H_

Powered by Google App Engine
This is Rietveld 408576698