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

Side by Side Diff: webrtc/api/video/video_frame_buffer.h

Issue 2924263002: Revert of Add support for multiple pixel formats in VideoFrameBuffer (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « webrtc/api/video/i420_buffer.cc ('k') | webrtc/api/video/video_frame_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_API_VIDEO_VIDEO_FRAME_BUFFER_H_ 11 #ifndef WEBRTC_API_VIDEO_VIDEO_FRAME_BUFFER_H_
12 #define WEBRTC_API_VIDEO_VIDEO_FRAME_BUFFER_H_ 12 #define WEBRTC_API_VIDEO_VIDEO_FRAME_BUFFER_H_
13 13
14 #include <stdint.h> 14 #include <stdint.h>
15 15
16 #include "webrtc/base/refcount.h" 16 #include "webrtc/base/refcount.h"
17 #include "webrtc/base/scoped_ref_ptr.h" 17 #include "webrtc/base/scoped_ref_ptr.h"
18 18
19 namespace webrtc { 19 namespace webrtc {
20 20
21 class PlanarYuvBuffer; 21 // Interface of a simple frame buffer containing pixel data. This interface does
22 22 // not contain any frame metadata such as rotation, timestamp, pixel_width, etc.
23 // Base class for frame buffers of different types of pixel format and storage.
24 // The tag in type() indicates how the data is represented, and each type is
25 // implemented as a subclass. To access the pixel data, call the appropriate
26 // GetXXX() function, where XXX represents the type. There is also a function
27 // ToI420() that returns a frame buffer in I420 format, converting from the
28 // underlying representation if necessary. I420 is the most widely accepted
29 // format and serves as a fallback for video sinks that can only handle I420,
30 // e.g. the internal WebRTC software encoders. A special enum value 'kNative' is
31 // provided for external clients to implement their own frame buffer
32 // representations, e.g. as textures. The external client can produce such
33 // native frame buffers from custom video sources, and then cast it back to the
34 // correct subclass in custom video sinks. The purpose of this is to improve
35 // performance by providing an optimized path without intermediate conversions.
36 // Frame metadata such as rotation and timestamp are stored in
37 // webrtc::VideoFrame, and not here.
38 class VideoFrameBuffer : public rtc::RefCountInterface { 23 class VideoFrameBuffer : public rtc::RefCountInterface {
39 public: 24 public:
40 // New frame buffer types will be added conservatively when there is an
41 // opportunity to optimize the path between some pair of video source and
42 // video sink.
43 enum class Type {
44 kNative,
45 kI420,
46 kI444,
47 };
48
49 // This function specifies in what pixel format the data is stored in.
50 virtual Type type() const;
51
52 // The resolution of the frame in pixels. For formats where some planes are 25 // The resolution of the frame in pixels. For formats where some planes are
53 // subsampled, this is the highest-resolution plane. 26 // subsampled, this is the highest-resolution plane.
54 virtual int width() const = 0; 27 virtual int width() const = 0;
55 virtual int height() const = 0; 28 virtual int height() const = 0;
56 29
57 // Returns a memory-backed frame buffer in I420 format. If the pixel data is
58 // in another format, a conversion will take place. All implementations must
59 // provide a fallback to I420 for compatibility with e.g. the internal WebRTC
60 // software encoders.
61 virtual rtc::scoped_refptr<PlanarYuvBuffer> ToI420();
62
63 // These functions should only be called if type() is of the correct type.
64 // Calling with a different type will result in a crash.
65 rtc::scoped_refptr<PlanarYuvBuffer> GetI420();
66 rtc::scoped_refptr<PlanarYuvBuffer> GetI444();
67
68 // Deprecated - use ToI420() first instead.
69 // Returns pointer to the pixel data for a given plane. The memory is owned by 30 // Returns pointer to the pixel data for a given plane. The memory is owned by
70 // the VideoFrameBuffer object and must not be freed by the caller. 31 // the VideoFrameBuffer object and must not be freed by the caller.
71 virtual const uint8_t* DataY() const; 32 virtual const uint8_t* DataY() const = 0;
72 virtual const uint8_t* DataU() const; 33 virtual const uint8_t* DataU() const = 0;
73 virtual const uint8_t* DataV() const; 34 virtual const uint8_t* DataV() const = 0;
35
74 // Returns the number of bytes between successive rows for a given plane. 36 // Returns the number of bytes between successive rows for a given plane.
75 virtual int StrideY() const; 37 virtual int StrideY() const = 0;
76 virtual int StrideU() const; 38 virtual int StrideU() const = 0;
77 virtual int StrideV() const; 39 virtual int StrideV() const = 0;
78 40
79 // Deprecated - use type() to determine if the stored data is kNative, and
80 // then cast into the appropriate type.
81 // Return the handle of the underlying video frame. This is used when the 41 // Return the handle of the underlying video frame. This is used when the
82 // frame is backed by a texture. 42 // frame is backed by a texture.
83 virtual void* native_handle() const; 43 virtual void* native_handle() const = 0;
84 44
85 // Deprecated - use ToI420() instead. 45 // Returns a new memory-backed frame buffer converted from this buffer's
86 virtual rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer(); 46 // native handle.
47 virtual rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() = 0;
87 48
88 protected: 49 protected:
89 ~VideoFrameBuffer() override {} 50 ~VideoFrameBuffer() override {}
90 }; 51 };
91 52
92 // This interface represents Type::kI420 and Type::kI444.
93 class PlanarYuvBuffer : public VideoFrameBuffer {
94 public:
95 int ChromaWidth() const;
96 int ChromaHeight() const;
97
98 // Returns pointer to the pixel data for a given plane. The memory is owned by
99 // the VideoFrameBuffer object and must not be freed by the caller.
100 const uint8_t* DataY() const override = 0;
101 const uint8_t* DataU() const override = 0;
102 const uint8_t* DataV() const override = 0;
103
104 // Returns the number of bytes between successive rows for a given plane.
105 int StrideY() const override = 0;
106 int StrideU() const override = 0;
107 int StrideV() const override = 0;
108
109 rtc::scoped_refptr<PlanarYuvBuffer> ToI420() override;
110
111 protected:
112 ~PlanarYuvBuffer() override {}
113 };
114
115 } // namespace webrtc 53 } // namespace webrtc
116 54
117 #endif // WEBRTC_API_VIDEO_VIDEO_FRAME_BUFFER_H_ 55 #endif // WEBRTC_API_VIDEO_VIDEO_FRAME_BUFFER_H_
OLDNEW
« no previous file with comments | « webrtc/api/video/i420_buffer.cc ('k') | webrtc/api/video/video_frame_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698