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

Side by Side Diff: media/base/android/sdk_media_codec_bridge_unittest.cc

Issue 1601863002: Remove non-batching assumptions from SdkMediaCodecBridgeTest.DoNormal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed clang build by using constants Created 4 years, 10 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 0x6c, 0x73, 0xa0, 0x92, 0xad, 0x27, 0x1c, 0x20, 0x0f, 0xc1, 0xca, 0x44, 83 0x6c, 0x73, 0xa0, 0x92, 0xad, 0x27, 0x1c, 0x20, 0x0f, 0xc1, 0xca, 0x44,
84 0x87, 0x47, 0xc5, 0x43, 0x23, 0x01, 0xda, 0x23, 0xe2, 0x89, 0x38, 0x9f, 84 0x87, 0x47, 0xc5, 0x43, 0x23, 0x01, 0xda, 0x23, 0xe2, 0x89, 0x38, 0x9f,
85 0x1f, 0x8d, 0x8c, 0xc6, 0x95, 0xa3, 0x34, 0x21, 0x21, 0x2d, 0x49, 0xea, 85 0x1f, 0x8d, 0x8c, 0xc6, 0x95, 0xa3, 0x34, 0x21, 0x21, 0x2d, 0x49, 0xea,
86 0x4b, 0x05, 0x85, 0xf5, 0x58, 0x25, 0x13, 0xcd, 0x51, 0x19, 0x1a, 0x88, 86 0x4b, 0x05, 0x85, 0xf5, 0x58, 0x25, 0x13, 0xcd, 0x51, 0x19, 0x1a, 0x88,
87 0xa6, 0x83, 0xd6, 0xd0, 0xbc, 0x25, 0x19, 0x1c, 0x92, 0x12, 0x44, 0x5d, 87 0xa6, 0x83, 0xd6, 0xd0, 0xbc, 0x25, 0x19, 0x1c, 0x92, 0x12, 0x44, 0x5d,
88 0x1c, 0x04, 0xf1, 0x99, 0xdf, 0x92, 0x8e, 0x09, 0x85, 0xf3, 0x88, 0x82, 88 0x1c, 0x04, 0xf1, 0x99, 0xdf, 0x92, 0x8e, 0x09, 0x85, 0xf3, 0x88, 0x82,
89 0x4c, 0x22, 0x17, 0xc5, 0x25, 0x23, 0xed, 0x78, 0xf5, 0x41, 0xd1, 0xe9, 89 0x4c, 0x22, 0x17, 0xc5, 0x25, 0x23, 0xed, 0x78, 0xf5, 0x41, 0xd1, 0xe9,
90 0x8a, 0xb3, 0x52, 0xd1, 0x3d, 0x79, 0x81, 0x4d, 0x31, 0x24, 0xf9, 0x38, 90 0x8a, 0xb3, 0x52, 0xd1, 0x3d, 0x79, 0x81, 0x4d, 0x31, 0x24, 0xf9, 0x38,
91 0x96, 0xbc, 0xf4, 0x8c, 0x25, 0xe9, 0xf2, 0x73, 0x94, 0x85, 0xc2, 0x61, 91 0x96, 0xbc, 0xf4, 0x8c, 0x25, 0xe9, 0xf2, 0x73, 0x94, 0x85, 0xc2, 0x61,
92 0x6a, 0x34, 0x68, 0x65, 0x78, 0x87, 0xa6, 0x4f}; 92 0x6a, 0x34, 0x68, 0x65, 0x78, 0x87, 0xa6, 0x4f};
93 static const size_t kDecodedAudioLengthInBytes = 9216u;
93 94
94 } // namespace 95 } // namespace
95 96
96 namespace media { 97 namespace media {
97 98
98 // Helper macro to skip the test if MediaCodecBridge isn't available. 99 // Helper macro to skip the test if MediaCodecBridge isn't available.
99 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ 100 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \
100 do { \ 101 do { \
101 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \ 102 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \
102 VLOG(0) << "Could not run test - not supported on device."; \ 103 VLOG(0) << "Could not run test - not supported on device."; \
103 return; \ 104 return; \
104 } \ 105 } \
105 } while (0) 106 } while (0)
106 107
107 static const int kPresentationTimeBase = 100; 108 static const int kPresentationTimeBase = 100;
109 static const int kMaxInputPts = kPresentationTimeBase + 2;
108 110
109 static inline const base::TimeDelta InfiniteTimeOut() { 111 static inline const base::TimeDelta InfiniteTimeOut() {
110 return base::TimeDelta::FromMicroseconds(-1); 112 return base::TimeDelta::FromMicroseconds(-1);
111 } 113 }
112 114
113 void DecodeMediaFrame(VideoCodecBridge* media_codec, 115 void DecodeMediaFrame(VideoCodecBridge* media_codec,
114 const uint8_t* data, 116 const uint8_t* data,
115 size_t data_size, 117 size_t data_size,
116 const base::TimeDelta input_presentation_timestamp, 118 const base::TimeDelta input_presentation_timestamp,
117 const base::TimeDelta initial_timestamp_lower_bound) { 119 const base::TimeDelta initial_timestamp_lower_bound) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 176
175 status = media_codec->DequeueInputBuffer(InfiniteTimeOut(), &input_buf_index); 177 status = media_codec->DequeueInputBuffer(InfiniteTimeOut(), &input_buf_index);
176 media_codec->QueueInputBuffer(input_buf_index, test_mp3, sizeof(test_mp3), 178 media_codec->QueueInputBuffer(input_buf_index, test_mp3, sizeof(test_mp3),
177 base::TimeDelta::FromMicroseconds(++input_pts)); 179 base::TimeDelta::FromMicroseconds(++input_pts));
178 180
179 status = media_codec->DequeueInputBuffer(InfiniteTimeOut(), &input_buf_index); 181 status = media_codec->DequeueInputBuffer(InfiniteTimeOut(), &input_buf_index);
180 media_codec->QueueEOS(input_buf_index); 182 media_codec->QueueEOS(input_buf_index);
181 183
182 input_pts = kPresentationTimeBase; 184 input_pts = kPresentationTimeBase;
183 bool eos = false; 185 bool eos = false;
186 size_t total_size = 0;
184 while (!eos) { 187 while (!eos) {
185 size_t unused_offset = 0; 188 size_t unused_offset = 0;
186 size_t size = 0; 189 size_t size = 0;
187 base::TimeDelta timestamp; 190 base::TimeDelta timestamp;
188 int output_buf_index = -1; 191 int output_buf_index = -1;
189 status = media_codec->DequeueOutputBuffer(InfiniteTimeOut(), 192 status = media_codec->DequeueOutputBuffer(InfiniteTimeOut(),
190 &output_buf_index, &unused_offset, 193 &output_buf_index, &unused_offset,
191 &size, &timestamp, &eos, nullptr); 194 &size, &timestamp, &eos, nullptr);
192 switch (status) { 195 switch (status) {
193 case MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER: 196 case MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER:
194 FAIL(); 197 FAIL();
195 return; 198 return;
196 199
197 case MEDIA_CODEC_OUTPUT_FORMAT_CHANGED: 200 case MEDIA_CODEC_OUTPUT_FORMAT_CHANGED:
198 continue; 201 continue;
199 202
200 case MEDIA_CODEC_OUTPUT_BUFFERS_CHANGED: 203 case MEDIA_CODEC_OUTPUT_BUFFERS_CHANGED:
201 continue; 204 continue;
202 205
203 default: 206 default:
204 break; 207 break;
205 } 208 }
206 ASSERT_GE(output_buf_index, 0); 209 ASSERT_GE(output_buf_index, 0);
207 EXPECT_LE(1u, size); 210 EXPECT_LE(1u, size);
208 if (!eos) 211 total_size += size;
209 EXPECT_EQ(++input_pts, timestamp.InMicroseconds());
210 ASSERT_LE(input_pts, kPresentationTimeBase + 2);
211 } 212 }
212 ASSERT_EQ(input_pts, kPresentationTimeBase + 2); 213 EXPECT_EQ(kDecodedAudioLengthInBytes, total_size);
214 ASSERT_LE(input_pts, kMaxInputPts);
213 } 215 }
214 216
215 TEST(SdkMediaCodecBridgeTest, InvalidVorbisHeader) { 217 TEST(SdkMediaCodecBridgeTest, InvalidVorbisHeader) {
216 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 218 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
217 219
218 scoped_ptr<media::AudioCodecBridge> media_codec; 220 scoped_ptr<media::AudioCodecBridge> media_codec;
219 media_codec.reset(AudioCodecBridge::Create(kCodecVorbis)); 221 media_codec.reset(AudioCodecBridge::Create(kCodecVorbis));
220 222
221 // The first byte of the header is not 0x02. 223 // The first byte of the header is not 0x02.
222 uint8_t invalid_first_byte[] = {0x00, 0xff, 0xff, 0xff, 0xff}; 224 uint8_t invalid_first_byte[] = {0x00, 0xff, 0xff, 0xff, 0xff};
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 295 }
294 296
295 TEST(SdkMediaCodecBridgeTest, CreateUnsupportedCodec) { 297 TEST(SdkMediaCodecBridgeTest, CreateUnsupportedCodec) {
296 EXPECT_EQ(nullptr, AudioCodecBridge::Create(kUnknownAudioCodec)); 298 EXPECT_EQ(nullptr, AudioCodecBridge::Create(kUnknownAudioCodec));
297 EXPECT_EQ(nullptr, VideoCodecBridge::CreateDecoder(kUnknownVideoCodec, false, 299 EXPECT_EQ(nullptr, VideoCodecBridge::CreateDecoder(kUnknownVideoCodec, false,
298 gfx::Size(320, 240), 300 gfx::Size(320, 240),
299 nullptr, nullptr)); 301 nullptr, nullptr));
300 } 302 }
301 303
302 } // namespace media 304 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698