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

Side by Side Diff: media/filters/h264_to_annex_b_bitstream_converter_unittest.cc

Issue 1904213003: Convert //media/filters from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/filters/h264_to_annex_b_bitstream_converter.h"
6
5 #include <stdint.h> 7 #include <stdint.h>
6 8
9 #include <memory>
10
7 #include "base/macros.h" 11 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "media/filters/h264_to_annex_b_bitstream_converter.h"
10 #include "media/formats/mp4/box_definitions.h" 12 #include "media/formats/mp4/box_definitions.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 14
13 namespace media { 15 namespace media {
14 16
15 class H264ToAnnexBBitstreamConverterTest : public testing::Test { 17 class H264ToAnnexBBitstreamConverterTest : public testing::Test {
16 protected: 18 protected:
17 H264ToAnnexBBitstreamConverterTest() {} 19 H264ToAnnexBBitstreamConverterTest() {}
18 20
19 ~H264ToAnnexBBitstreamConverterTest() override {} 21 ~H264ToAnnexBBitstreamConverterTest() override {}
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 0x01, 0xC9, 0xB0, 0xB6, 0xB9, 0x92, 0xED, 0x1D, 0x08, 0xB0, 0x80, 0x06, 284 0x01, 0xC9, 0xB0, 0xB6, 0xB9, 0x92, 0xED, 0x1D, 0x08, 0xB0, 0x80, 0x06,
283 0x20, 0xEA, 0xEE, 0xF9, 0x1D, 0xA4, 0x57, 0x73, 0x2E, 0x1B, 0xA5, 0xAF, 285 0x20, 0xEA, 0xEE, 0xF9, 0x1D, 0xA4, 0x57, 0x73, 0x2E, 0x1B, 0xA5, 0xAF,
284 0xF6, 0xAF, 0xAE, 0x04, 0x7C, 0x4C, 0x7E, 0xC8, 0xDB, 0xC0, 0xFB, 0x37, 286 0xF6, 0xAF, 0xAE, 0x04, 0x7C, 0x4C, 0x7E, 0xC8, 0xDB, 0xC0, 0xFB, 0x37,
285 0xC8, 0x7E, 0xFE, 0x47, 0x0A, 0x3C, 0xFA, 0x61, 0xE7, 0xEB, 0x1B, 0xF3, 287 0xC8, 0x7E, 0xFE, 0x47, 0x0A, 0x3C, 0xFA, 0x61, 0xE7, 0xEB, 0x1B, 0xF3,
286 0x7C, 0x32, 0xE3, 0x7C, 0x37, 0x66, 0x7C, 0x53, 0x07, 0xC2, 0x37, 0xA3, 288 0x7C, 0x32, 0xE3, 0x7C, 0x37, 0x66, 0x7C, 0x53, 0x07, 0xC2, 0x37, 0xA3,
287 0xBD, 0xF7, 0xFA, 0xE3, 0x8A, 0x76, 0xCB, 0x6C, 0xC8, 0x13, 0xC4, 0x53, 289 0xBD, 0xF7, 0xFA, 0xE3, 0x8A, 0x76, 0xCB, 0x6C, 0xC8, 0x13, 0xC4, 0x53,
288 0x53, 0xDB, 0xAD, 0x37, 0x1A, 0xEB, 0xE0}; 290 0x53, 0xDB, 0xAD, 0x37, 0x1A, 0xEB, 0xE0};
289 291
290 TEST_F(H264ToAnnexBBitstreamConverterTest, Success) { 292 TEST_F(H264ToAnnexBBitstreamConverterTest, Success) {
291 // Initialize converter. 293 // Initialize converter.
292 scoped_ptr<uint8_t[]> output; 294 std::unique_ptr<uint8_t[]> output;
293 H264ToAnnexBBitstreamConverter converter; 295 H264ToAnnexBBitstreamConverter converter;
294 296
295 // Parse the headers. 297 // Parse the headers.
296 EXPECT_TRUE(converter.ParseConfiguration( 298 EXPECT_TRUE(converter.ParseConfiguration(
297 kHeaderDataOkWithFieldLen4, 299 kHeaderDataOkWithFieldLen4,
298 sizeof(kHeaderDataOkWithFieldLen4), 300 sizeof(kHeaderDataOkWithFieldLen4),
299 &avc_config_)); 301 &avc_config_));
300 uint32_t config_size = converter.GetConfigSize(avc_config_); 302 uint32_t config_size = converter.GetConfigSize(avc_config_);
301 EXPECT_GT(config_size, 0U); 303 EXPECT_GT(config_size, 0U);
302 304
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 342
341 // Parse the headers 343 // Parse the headers
342 EXPECT_FALSE(converter.ParseConfiguration( 344 EXPECT_FALSE(converter.ParseConfiguration(
343 corrupted_header, 345 corrupted_header,
344 sizeof(corrupted_header), 346 sizeof(corrupted_header),
345 &avc_config_)); 347 &avc_config_));
346 } 348 }
347 349
348 TEST_F(H264ToAnnexBBitstreamConverterTest, FailureNalUnitBreakage) { 350 TEST_F(H264ToAnnexBBitstreamConverterTest, FailureNalUnitBreakage) {
349 // Initialize converter. 351 // Initialize converter.
350 scoped_ptr<uint8_t[]> output; 352 std::unique_ptr<uint8_t[]> output;
351 H264ToAnnexBBitstreamConverter converter; 353 H264ToAnnexBBitstreamConverter converter;
352 354
353 // Parse the headers. 355 // Parse the headers.
354 EXPECT_TRUE(converter.ParseConfiguration( 356 EXPECT_TRUE(converter.ParseConfiguration(
355 kHeaderDataOkWithFieldLen4, 357 kHeaderDataOkWithFieldLen4,
356 sizeof(kHeaderDataOkWithFieldLen4), 358 sizeof(kHeaderDataOkWithFieldLen4),
357 &avc_config_)); 359 &avc_config_));
358 uint32_t config_size = converter.GetConfigSize(avc_config_); 360 uint32_t config_size = converter.GetConfigSize(avc_config_);
359 EXPECT_GT(config_size, 0U); 361 EXPECT_GT(config_size, 0U);
360 362
(...skipping 27 matching lines...) Expand all
388 corrupted_nal_unit, 390 corrupted_nal_unit,
389 sizeof(corrupted_nal_unit), 391 sizeof(corrupted_nal_unit),
390 &avc_config_, 392 &avc_config_,
391 output.get(), 393 output.get(),
392 &output_size_left_for_nal_unit)); 394 &output_size_left_for_nal_unit));
393 EXPECT_EQ(output_size_left_for_nal_unit, 0U); 395 EXPECT_EQ(output_size_left_for_nal_unit, 0U);
394 } 396 }
395 397
396 TEST_F(H264ToAnnexBBitstreamConverterTest, FailureTooSmallOutputBuffer) { 398 TEST_F(H264ToAnnexBBitstreamConverterTest, FailureTooSmallOutputBuffer) {
397 // Initialize converter. 399 // Initialize converter.
398 scoped_ptr<uint8_t[]> output; 400 std::unique_ptr<uint8_t[]> output;
399 H264ToAnnexBBitstreamConverter converter; 401 H264ToAnnexBBitstreamConverter converter;
400 402
401 // Parse the headers. 403 // Parse the headers.
402 EXPECT_TRUE(converter.ParseConfiguration( 404 EXPECT_TRUE(converter.ParseConfiguration(
403 kHeaderDataOkWithFieldLen4, 405 kHeaderDataOkWithFieldLen4,
404 sizeof(kHeaderDataOkWithFieldLen4), 406 sizeof(kHeaderDataOkWithFieldLen4),
405 &avc_config_)); 407 &avc_config_));
406 uint32_t config_size = converter.GetConfigSize(avc_config_); 408 uint32_t config_size = converter.GetConfigSize(avc_config_);
407 EXPECT_GT(config_size, 0U); 409 EXPECT_GT(config_size, 0U);
408 uint32_t real_config_size = config_size; 410 uint32_t real_config_size = config_size;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 0x00, 0x3e, 0x90, 0x00, 0x0e, 0xa6, 0x00, 0xf1, 0x62, 0xd3, 466 0x00, 0x3e, 0x90, 0x00, 0x0e, 0xa6, 0x00, 0xf1, 0x62, 0xd3,
465 0x80, 0x01, 0x00, 0x06, 0x68, 0xea, 0xc0, 0xbc, 0xb2, 0x2c}; 467 0x80, 0x01, 0x00, 0x06, 0x68, 0xea, 0xc0, 0xbc, 0xb2, 0x2c};
466 468
467 static const uint8_t kCorruptedPacketData[] = { 469 static const uint8_t kCorruptedPacketData[] = {
468 0x00, 0x00, 0x00, 0x15, 0x01, 0x9f, 0x6e, 0xbc, 0x85, 0x3f, 470 0x00, 0x00, 0x00, 0x15, 0x01, 0x9f, 0x6e, 0xbc, 0x85, 0x3f,
469 0x0f, 0x87, 0x47, 0xa8, 0xd7, 0x5b, 0xfc, 0xb8, 0xfd, 0x3f, 471 0x0f, 0x87, 0x47, 0xa8, 0xd7, 0x5b, 0xfc, 0xb8, 0xfd, 0x3f,
470 0x57, 0x0e, 0xac, 0xf5, 0x4c, 0x01, 0x2e, 0x57}; 472 0x57, 0x0e, 0xac, 0xf5, 0x4c, 0x01, 0x2e, 0x57};
471 473
472 TEST_F(H264ToAnnexBBitstreamConverterTest, CorruptedPacket) { 474 TEST_F(H264ToAnnexBBitstreamConverterTest, CorruptedPacket) {
473 // Initialize converter. 475 // Initialize converter.
474 scoped_ptr<uint8_t[]> output; 476 std::unique_ptr<uint8_t[]> output;
475 H264ToAnnexBBitstreamConverter converter; 477 H264ToAnnexBBitstreamConverter converter;
476 478
477 // Parse the headers. 479 // Parse the headers.
478 EXPECT_TRUE(converter.ParseConfiguration( 480 EXPECT_TRUE(converter.ParseConfiguration(
479 kCorruptedPacketConfiguration, 481 kCorruptedPacketConfiguration,
480 sizeof(kCorruptedPacketConfiguration), 482 sizeof(kCorruptedPacketConfiguration),
481 &avc_config_)); 483 &avc_config_));
482 uint32_t config_size = converter.GetConfigSize(avc_config_); 484 uint32_t config_size = converter.GetConfigSize(avc_config_);
483 EXPECT_GT(config_size, 0U); 485 EXPECT_GT(config_size, 0U);
484 486
485 // Go on with converting the headers. 487 // Go on with converting the headers.
486 output.reset(new uint8_t[config_size]); 488 output.reset(new uint8_t[config_size]);
487 EXPECT_TRUE(converter.ConvertAVCDecoderConfigToByteStream( 489 EXPECT_TRUE(converter.ConvertAVCDecoderConfigToByteStream(
488 avc_config_, 490 avc_config_,
489 output.get(), 491 output.get(),
490 &config_size)); 492 &config_size));
491 493
492 // Expect an error here. 494 // Expect an error here.
493 uint32_t output_size = converter.CalculateNeededOutputBufferSize( 495 uint32_t output_size = converter.CalculateNeededOutputBufferSize(
494 kCorruptedPacketData, sizeof(kCorruptedPacketData), &avc_config_); 496 kCorruptedPacketData, sizeof(kCorruptedPacketData), &avc_config_);
495 EXPECT_EQ(output_size, 0U); 497 EXPECT_EQ(output_size, 0U);
496 } 498 }
497 499
498 } // namespace media 500 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698