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

Side by Side Diff: media/filters/gpu_video_decoder.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
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | ppapi/api/dev/pp_video_dev.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gpu_video_decoder.h" 5 #include "media/filters/gpu_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/cpu.h" 9 #include "base/cpu.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return; 277 return;
278 } 278 }
279 279
280 if (!pending_reset_cb_.is_null()) 280 if (!pending_reset_cb_.is_null())
281 return; 281 return;
282 282
283 size_t size = buffer->GetDataSize(); 283 size_t size = buffer->GetDataSize();
284 SHMBuffer* shm_buffer = GetSHM(size); 284 SHMBuffer* shm_buffer = GetSHM(size);
285 memcpy(shm_buffer->shm->memory(), buffer->GetData(), size); 285 memcpy(shm_buffer->shm->memory(), buffer->GetData(), size);
286 BitstreamBuffer bitstream_buffer( 286 BitstreamBuffer bitstream_buffer(
287 next_bitstream_buffer_id_++, shm_buffer->shm->handle(), size); 287 next_bitstream_buffer_id_, shm_buffer->shm->handle(), size);
288 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer.
289 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF;
288 bool inserted = bitstream_buffers_in_decoder_.insert(std::make_pair( 290 bool inserted = bitstream_buffers_in_decoder_.insert(std::make_pair(
289 bitstream_buffer.id(), BufferPair(shm_buffer, buffer))).second; 291 bitstream_buffer.id(), BufferPair(shm_buffer, buffer))).second;
290 DCHECK(inserted); 292 DCHECK(inserted);
291 RecordBufferData(bitstream_buffer, *buffer); 293 RecordBufferData(bitstream_buffer, *buffer);
292 294
293 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( 295 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind(
294 &VideoDecodeAccelerator::Decode, weak_vda_, bitstream_buffer)); 296 &VideoDecodeAccelerator::Decode, weak_vda_, bitstream_buffer));
295 297
296 if (CanMoreDecodeWorkBeDone()) 298 if (CanMoreDecodeWorkBeDone())
297 EnsureDemuxOrDecode(); 299 EnsureDemuxOrDecode();
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 583
582 error_occured_ = true; 584 error_occured_ = true;
583 585
584 if (!pending_read_cb_.is_null()) { 586 if (!pending_read_cb_.is_null()) {
585 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); 587 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL);
586 return; 588 return;
587 } 589 }
588 } 590 }
589 591
590 } // namespace media 592 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | ppapi/api/dev/pp_video_dev.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698