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

Side by Side Diff: content/common/gpu/media/video_decode_accelerator_unittest.cc

Issue 11826064: Enforce non-negative BitstreamBuffer id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Documented the wrapping at 30 bits. Created 7 years, 11 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 // The bulk of this file is support code; sorry about that. Here's an overview 5 // The bulk of this file is support code; sorry about that. Here's an overview
6 // to hopefully help readers of this code: 6 // to hopefully help readers of this code:
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or
8 // Win/EGL. 8 // Win/EGL.
9 // - ClientState is an enum for the state of the decode client used by the test. 9 // - ClientState is an enum for the state of the decode client used by the test.
10 // - ClientStateNotification is a barrier abstraction that allows the test code 10 // - ClientStateNotification is a barrier abstraction that allows the test code
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 size_t next_fragment_size = next_fragment_bytes.size(); 596 size_t next_fragment_size = next_fragment_bytes.size();
597 597
598 // Populate the shared memory buffer w/ the fragments, duplicate its handle, 598 // Populate the shared memory buffer w/ the fragments, duplicate its handle,
599 // and hand it off to the decoder. 599 // and hand it off to the decoder.
600 base::SharedMemory shm; 600 base::SharedMemory shm;
601 CHECK(shm.CreateAndMapAnonymous(next_fragment_size)); 601 CHECK(shm.CreateAndMapAnonymous(next_fragment_size));
602 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size); 602 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size);
603 base::SharedMemoryHandle dup_handle; 603 base::SharedMemoryHandle dup_handle;
604 CHECK(shm.ShareToProcess(base::Process::Current().handle(), &dup_handle)); 604 CHECK(shm.ShareToProcess(base::Process::Current().handle(), &dup_handle));
605 media::BitstreamBuffer bitstream_buffer( 605 media::BitstreamBuffer bitstream_buffer(
606 next_bitstream_buffer_id_++, dup_handle, next_fragment_size); 606 next_bitstream_buffer_id_, dup_handle, next_fragment_size);
607 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer.
608 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF;
607 decoder_->Decode(bitstream_buffer); 609 decoder_->Decode(bitstream_buffer);
608 ++outstanding_decodes_; 610 ++outstanding_decodes_;
609 encoded_data_next_pos_to_decode_ = end_pos; 611 encoded_data_next_pos_to_decode_ = end_pos;
610 612
611 if (!remaining_play_throughs_ && 613 if (!remaining_play_throughs_ &&
612 -delete_decoder_state_ == next_bitstream_buffer_id_) { 614 -delete_decoder_state_ == next_bitstream_buffer_id_) {
613 DeleteDecoder(); 615 DeleteDecoder();
614 } 616 }
615 } 617 }
616 618
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 base::Unretained(&event))); 937 base::Unretained(&event)));
936 event.Wait(); 938 event.Wait();
937 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 939 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
938 content::OmxVideoDecodeAccelerator::PreSandboxInitialization(); 940 content::OmxVideoDecodeAccelerator::PreSandboxInitialization();
939 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 941 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
940 content::VaapiVideoDecodeAccelerator::PreSandboxInitialization(); 942 content::VaapiVideoDecodeAccelerator::PreSandboxInitialization();
941 #endif 943 #endif
942 944
943 return RUN_ALL_TESTS(); 945 return RUN_ALL_TESTS();
944 } 946 }
OLDNEW
« no previous file with comments | « content/common/gpu/media/gpu_video_decode_accelerator.cc ('k') | media/filters/gpu_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698