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

Unified Diff: webrtc/modules/rtp_rtcp/source/h264/sps_parser_unittest.cc

Issue 1979443004: Add H264 bitstream rewriting to limit frame reordering marker in header (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed compiler warning on win Created 4 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/modules/rtp_rtcp/source/h264/sps_parser_unittest.cc
diff --git a/webrtc/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc b/webrtc/modules/rtp_rtcp/source/h264/sps_parser_unittest.cc
similarity index 81%
rename from webrtc/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc
rename to webrtc/modules/rtp_rtcp/source/h264/sps_parser_unittest.cc
index 7a7e3ed2937a139ac87c35666015b415cfa71ccf..da8f05a6d6593d41a145eab818843713ae79e3d9 100644
--- a/webrtc/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/h264/sps_parser_unittest.cc
@@ -8,12 +8,14 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/modules/rtp_rtcp/source/h264_sps_parser.h"
+#include "webrtc/modules/rtp_rtcp/source/h264/sps_parser.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/arraysize.h"
#include "webrtc/base/bitbuffer.h"
+#include "webrtc/base/buffer.h"
+#include "webrtc/modules/rtp_rtcp/source/h264/h264_common.h"
namespace webrtc {
@@ -116,58 +118,68 @@ void GenerateFakeSps(uint16_t width, uint16_t height, uint8_t buffer[]) {
}
}
-TEST(H264SpsParserTest, TestSampleSPSHdLandscape) {
+class H264SpsParserTest : public ::testing::Test {
+ public:
+ H264SpsParserTest() {}
+ virtual ~H264SpsParserTest() {}
+
+ protected:
+ bool ParseSps(const uint8_t* buffer, int length) {
+ sps_ = SpsParser::ParseSps(buffer, length);
+ return sps_ ? true : false;
stefan-webrtc 2016/05/22 23:11:50 I think you can return sps_(). Wouldn't it be sim
sprang_webrtc 2016/05/25 09:06:03 Nope, "type 'rtc::Optional<SpsParser::SpsState>' d
+ }
+
+ rtc::Optional<SpsParser::SpsState> sps_;
+};
+
+TEST_F(H264SpsParserTest, TestSampleSPSHdLandscape) {
// SPS for a 1280x720 camera capture from ffmpeg on osx. Contains
// emulation bytes but no cropping.
const uint8_t buffer[] = {0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05,
0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00,
0x00, 0x2A, 0xE0, 0xF1, 0x83, 0x19, 0x60};
- H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
- EXPECT_TRUE(parser.Parse());
- EXPECT_EQ(1280u, parser.width());
- EXPECT_EQ(720u, parser.height());
+
+ EXPECT_TRUE(ParseSps(buffer, arraysize(buffer)));
+ EXPECT_EQ(1280u, sps_->width);
+ EXPECT_EQ(720u, sps_->height);
}
-TEST(H264SpsParserTest, TestSampleSPSVgaLandscape) {
+TEST_F(H264SpsParserTest, TestSampleSPSVgaLandscape) {
// SPS for a 640x360 camera capture from ffmpeg on osx. Contains emulation
// bytes and cropping (360 isn't divisible by 16).
const uint8_t buffer[] = {0x7A, 0x00, 0x1E, 0xBC, 0xD9, 0x40, 0xA0, 0x2F,
0xF8, 0x98, 0x40, 0x00, 0x00, 0x03, 0x01, 0x80,
0x00, 0x00, 0x56, 0x83, 0xC5, 0x8B, 0x65, 0x80};
- H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
- EXPECT_TRUE(parser.Parse());
- EXPECT_EQ(640u, parser.width());
- EXPECT_EQ(360u, parser.height());
+ EXPECT_TRUE(ParseSps(buffer, arraysize(buffer)));
+ EXPECT_EQ(640u, sps_->width);
+ EXPECT_EQ(360u, sps_->height);
}
-TEST(H264SpsParserTest, TestSampleSPSWeirdResolution) {
+TEST_F(H264SpsParserTest, TestSampleSPSWeirdResolution) {
// SPS for a 200x400 camera capture from ffmpeg on osx. Horizontal and
// veritcal crop (neither dimension is divisible by 16).
const uint8_t buffer[] = {0x7A, 0x00, 0x0D, 0xBC, 0xD9, 0x43, 0x43, 0x3E,
0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00,
0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60};
- H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
- EXPECT_TRUE(parser.Parse());
- EXPECT_EQ(200u, parser.width());
- EXPECT_EQ(400u, parser.height());
+ EXPECT_TRUE(ParseSps(buffer, arraysize(buffer)));
+ EXPECT_EQ(200u, sps_->width);
+ EXPECT_EQ(400u, sps_->height);
}
-TEST(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) {
+TEST_F(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) {
uint8_t buffer[kSpsBufferMaxSize] = {0};
GenerateFakeSps(320u, 180u, buffer);
- H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
- EXPECT_TRUE(parser.Parse());
- EXPECT_EQ(320u, parser.width());
- EXPECT_EQ(180u, parser.height());
+ EXPECT_TRUE(ParseSps(buffer, arraysize(buffer)));
+ EXPECT_EQ(320u, sps_->width);
+ EXPECT_EQ(180u, sps_->height);
}
-TEST(H264SpsParserTest, TestSyntheticSPSWeirdResolution) {
+TEST_F(H264SpsParserTest, TestSyntheticSPSWeirdResolution) {
uint8_t buffer[kSpsBufferMaxSize] = {0};
GenerateFakeSps(156u, 122u, buffer);
- H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
- EXPECT_TRUE(parser.Parse());
- EXPECT_EQ(156u, parser.width());
- EXPECT_EQ(122u, parser.height());
+ EXPECT_TRUE(ParseSps(buffer, arraysize(buffer)));
+ EXPECT_EQ(156u, sps_->width);
+ EXPECT_EQ(122u, sps_->height);
}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698