Index: trunk/src/content/common/gpu/media/video_encode_accelerator_unittest.cc |
=================================================================== |
--- trunk/src/content/common/gpu/media/video_encode_accelerator_unittest.cc (revision 279732) |
+++ trunk/src/content/common/gpu/media/video_encode_accelerator_unittest.cc (working copy) |
@@ -13,6 +13,7 @@ |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_split.h" |
#include "base/time/time.h" |
+#include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
#include "content/common/gpu/media/video_accelerator_unittest_helpers.h" |
#include "media/base/bind_to_current_loop.h" |
#include "media/base/bitstream_buffer.h" |
@@ -21,18 +22,6 @@ |
#include "media/video/video_encode_accelerator.h" |
#include "testing/gtest/include/gtest/gtest.h" |
-#if defined(USE_X11) |
-#include "ui/gfx/x/x11_types.h" |
-#endif |
- |
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
-#include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
-#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
-#include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
-#else |
-#error The VideoEncodeAcceleratorUnittest is not supported on this platform. |
-#endif |
- |
using media::VideoEncodeAccelerator; |
namespace content { |
@@ -255,29 +244,28 @@ |
seen_pps_(false), |
seen_idr_(false) {} |
- virtual void ProcessStreamBuffer(const uint8* stream, size_t size) OVERRIDE; |
+ void ProcessStreamBuffer(const uint8* stream, size_t size) OVERRIDE; |
private: |
// Set to true when encoder provides us with the corresponding NALU type. |
bool seen_sps_; |
bool seen_pps_; |
bool seen_idr_; |
- |
- media::H264Parser h264_parser_; |
}; |
void H264Validator::ProcessStreamBuffer(const uint8* stream, size_t size) { |
- h264_parser_.SetStream(stream, size); |
+ media::H264Parser h264_parser; |
+ h264_parser.SetStream(stream, size); |
while (1) { |
media::H264NALU nalu; |
media::H264Parser::Result result; |
- result = h264_parser_.AdvanceToNextNALU(&nalu); |
+ result = h264_parser.AdvanceToNextNALU(&nalu); |
if (result == media::H264Parser::kEOStream) |
break; |
- ASSERT_EQ(media::H264Parser::kOk, result); |
+ ASSERT_EQ(result, media::H264Parser::kOk); |
bool keyframe = false; |
@@ -285,35 +273,22 @@ |
case media::H264NALU::kIDRSlice: |
ASSERT_TRUE(seen_sps_); |
ASSERT_TRUE(seen_pps_); |
- seen_idr_ = true; |
+ seen_idr_ = keyframe = true; |
// fallthrough |
- case media::H264NALU::kNonIDRSlice: { |
+ case media::H264NALU::kNonIDRSlice: |
ASSERT_TRUE(seen_idr_); |
- |
- media::H264SliceHeader shdr; |
- ASSERT_EQ(media::H264Parser::kOk, |
- h264_parser_.ParseSliceHeader(nalu, &shdr)); |
- keyframe = shdr.IsISlice() || shdr.IsSISlice(); |
- |
if (!frame_cb_.Run(keyframe)) |
return; |
break; |
- } |
- case media::H264NALU::kSPS: { |
- int sps_id; |
- ASSERT_EQ(media::H264Parser::kOk, h264_parser_.ParseSPS(&sps_id)); |
+ case media::H264NALU::kSPS: |
seen_sps_ = true; |
break; |
- } |
- case media::H264NALU::kPPS: { |
+ case media::H264NALU::kPPS: |
ASSERT_TRUE(seen_sps_); |
- int pps_id; |
- ASSERT_EQ(media::H264Parser::kOk, h264_parser_.ParsePPS(&pps_id)); |
seen_pps_ = true; |
break; |
- } |
default: |
break; |
@@ -327,7 +302,7 @@ |
: StreamValidator(frame_cb), |
seen_keyframe_(false) {} |
- virtual void ProcessStreamBuffer(const uint8* stream, size_t size) OVERRIDE; |
+ void ProcessStreamBuffer(const uint8* stream, size_t size) OVERRIDE; |
private: |
// Have we already got a keyframe in the stream? |
@@ -382,13 +357,13 @@ |
double frames_per_second(); |
// VideoDecodeAccelerator::Client implementation. |
- virtual void RequireBitstreamBuffers(unsigned int input_count, |
- const gfx::Size& input_coded_size, |
- size_t output_buffer_size) OVERRIDE; |
- virtual void BitstreamBufferReady(int32 bitstream_buffer_id, |
- size_t payload_size, |
- bool key_frame) OVERRIDE; |
- virtual void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE; |
+ void RequireBitstreamBuffers(unsigned int input_count, |
+ const gfx::Size& input_coded_size, |
+ size_t output_buffer_size) OVERRIDE; |
+ void BitstreamBufferReady(int32 bitstream_buffer_id, |
+ size_t payload_size, |
+ bool key_frame) OVERRIDE; |
+ void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE; |
private: |
bool has_encoder() { return encoder_.get(); } |
@@ -584,13 +559,8 @@ |
DCHECK(thread_checker_.CalledOnValidThread()); |
CHECK(!has_encoder()); |
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); |
encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); |
-#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
- encoder_.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay())); |
-#endif |
- |
SetState(CS_ENCODER_SET); |
DVLOG(1) << "Profile: " << test_stream_.requested_profile |