summaryrefslogtreecommitdiff
path: root/media/base/yuvframegenerator.h
diff options
context:
space:
mode:
authormallinath@webrtc.org <mallinath@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-02-03 16:57:16 +0000
committermallinath@webrtc.org <mallinath@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-02-03 16:57:16 +0000
commitb881d27f23e9a8f52dc6a60fc66ebd75f9c2f15c (patch)
tree7e476a94dc6bd821fb3452e8021da5a49c3325df /media/base/yuvframegenerator.h
parentd51e05ddea8c27cfc8f1e33fd4ef068534280bd5 (diff)
downloadtalk-b881d27f23e9a8f52dc6a60fc66ebd75f9c2f15c.tar.gz
Update talk to 60923971
Review URL: https://webrtc-codereview.appspot.com/7909004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@5475 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'media/base/yuvframegenerator.h')
-rw-r--r--media/base/yuvframegenerator.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/media/base/yuvframegenerator.h b/media/base/yuvframegenerator.h
new file mode 100644
index 0000000..4adf971
--- /dev/null
+++ b/media/base/yuvframegenerator.h
@@ -0,0 +1,78 @@
+// Generates YUV420 frames with a "landscape with striped crosshair" in the
+// Y-plane, plus a horizontal gradient in the U-plane and a vertical one in the
+// V-plane. This makes for a nice mix of colours that is suited for both
+// catching visual errors and making sure e.g. YUV->RGB/BGR conversion looks
+// the same on different platforms.
+// There is also a solid box bouncing around in the Y-plane, and two differently
+// coloured lines bouncing horizontally and vertically in the U and V plane.
+// This helps illustrating how the frame boundary goes, and can aid as a quite
+// handy visual help for noticing e.g. packet loss if the frames are encoded
+// and sent over the network.
+
+#ifndef TALK_MEDIA_BASE_YUVFRAMEGENERATOR_H_
+#define TALK_MEDIA_BASE_YUVFRAMEGENERATOR_H_
+
+#include "talk/base/basictypes.h"
+
+namespace cricket {
+
+class YuvFrameGenerator {
+ public:
+ // Constructs a frame-generator that produces frames of size |width|x|height|.
+ // If |enable_barcode| is specified, barcodes can be included in the frames
+ // when calling |GenerateNextFrame(uint8*, uint32)|. If |enable_barcode| is
+ // |true| then |width|x|height| should be at least 160x100; otherwise this
+ // constructor will abort.
+ YuvFrameGenerator(int width, int height, bool enable_barcode);
+ ~YuvFrameGenerator();
+
+ int GetFrameSize() { return frame_data_size_; }
+
+ // Generate the next frame and return it in the provided |frame_buffer|. If
+ // barcode_value is not |nullptr| the value referred by it will be encoded
+ // into a barcode in the frame. The value should in the range:
+ // [0..9,999,999]. If the value exceeds this range or barcodes were not
+ // requested in the constructor, this function will abort.
+ void GenerateNextFrame(uint8* frame_buffer, int32 barcode_value);
+
+ int GetHeight() { return height_; }
+ int GetWidth() { return width_; }
+
+ // Fetch the bounds of the barcode from the generator. The barcode will
+ // always be at this location. This function will abort if barcodes were not
+ // requested in the constructor.
+ void GetBarcodeBounds(int* top, int* left, int* width, int* height);
+
+ private:
+ void DrawLandscape(uint8 *p, int w, int h);
+ void DrawGradientX(uint8 *p, int w, int h);
+ void DrawGradientY(uint8 *p, int w, int h);
+ void DrawMovingLineX(uint8 *p, int w, int h, int n);
+ void DrawMovingLineY(uint8 *p, int w, int h, int n);
+ void DrawBouncingCube(uint8 *p, int w, int h, int n);
+
+ void DrawBarcode(uint32 value);
+ int DrawSideGuardBars(int x, int y, int height);
+ int DrawMiddleGuardBars(int x, int y, int height);
+ int DrawEanEncodedDigit(int digit, int x, int y, int height, bool r_code);
+ void DrawBlockRectangle(uint8* p, int x_start, int y_start,
+ int width, int height, int pitch, uint8 value);
+
+ private:
+ int width_;
+ int height_;
+ int frame_index_;
+ int frame_data_size_;
+ uint8* y_data_;
+ uint8* u_data_;
+ uint8* v_data_;
+
+ int barcode_start_x_;
+ int barcode_start_y_;
+
+ DISALLOW_COPY_AND_ASSIGN(YuvFrameGenerator);
+};
+
+} // namespace cricket
+
+#endif // TALK_MEDIA_BASE_YUVFRAMEGENERATOR_H_