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

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

Issue 10823246: VAVDA: Fix a crash if we fail parsing SPS/DecodeInitial. (Closed) Base URL: https://git.chromium.org/git/chromium/src@master
Patch Set: Created 8 years, 4 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 | « content/common/gpu/media/vaapi_h264_decoder.h ('k') | 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 (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 <dlfcn.h> 5 #include <dlfcn.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 curr_sps_id_ = -1; 316 curr_sps_id_ = -1;
317 curr_pps_id_ = -1; 317 curr_pps_id_ = -1;
318 pic_width_ = -1; 318 pic_width_ = -1;
319 pic_height_ = -1; 319 pic_height_ = -1;
320 max_frame_num_ = 0; 320 max_frame_num_ = 0;
321 max_pic_num_ = 0; 321 max_pic_num_ = 0;
322 max_long_term_frame_idx_ = 0; 322 max_long_term_frame_idx_ = 0;
323 max_pic_order_cnt_lsb_ = 0; 323 max_pic_order_cnt_lsb_ = 0;
324 state_ = kUninitialized; 324 state_ = kUninitialized;
325 num_available_decode_surfaces_ = 0; 325 num_available_decode_surfaces_ = 0;
326 va_context_created_ = false;
326 } 327 }
327 328
328 VaapiH264Decoder::~VaapiH264Decoder() { 329 VaapiH264Decoder::~VaapiH264Decoder() {
329 Destroy(); 330 Destroy();
330 } 331 }
331 332
332 // This puts the decoder in state where it keeps stream data and is ready 333 // This puts the decoder in state where it keeps stream data and is ready
333 // to resume playback from a random location in the stream, but drops all 334 // to resume playback from a random location in the stream, but drops all
334 // inputs and outputs and makes all surfaces available for use. 335 // inputs and outputs and makes all surfaces available for use.
335 void VaapiH264Decoder::Reset() { 336 void VaapiH264Decoder::Reset() {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 va_surface_ids_, GetRequiredNumOfPictures(), 578 va_surface_ids_, GetRequiredNumOfPictures(),
578 &va_context_id_); 579 &va_context_id_);
579 580
580 if (va_res != VA_STATUS_SUCCESS) { 581 if (va_res != VA_STATUS_SUCCESS) {
581 DVLOG(1) << "Error creating a decoding surface (binding to texture?)"; 582 DVLOG(1) << "Error creating a decoding surface (binding to texture?)";
582 VAAPI_DestroySurfaces(va_display_, va_surface_ids_, 583 VAAPI_DestroySurfaces(va_display_, va_surface_ids_,
583 GetRequiredNumOfPictures()); 584 GetRequiredNumOfPictures());
584 return false; 585 return false;
585 } 586 }
586 587
588 va_context_created_ = true;
589
587 return true; 590 return true;
588 } 591 }
589 592
590 void VaapiH264Decoder::DestroyVASurfaces() { 593 void VaapiH264Decoder::DestroyVASurfaces() {
591 DCHECK(state_ == kDecoding || state_ == kError || state_ == kAfterReset); 594 DCHECK(state_ == kDecoding || state_ == kError || state_ == kAfterReset);
592 decode_surfaces_.clear(); 595 decode_surfaces_.clear();
593 596
597 // This can happen if we fail during DecodeInitial.
598 if (!va_context_created_)
599 return;
600
594 VAStatus va_res = VAAPI_DestroyContext(va_display_, va_context_id_); 601 VAStatus va_res = VAAPI_DestroyContext(va_display_, va_context_id_);
595 VA_LOG_ON_ERROR(va_res, "vaDestroyContext failed"); 602 VA_LOG_ON_ERROR(va_res, "vaDestroyContext failed");
596 603
597 va_res = VAAPI_DestroySurfaces(va_display_, va_surface_ids_, 604 va_res = VAAPI_DestroySurfaces(va_display_, va_surface_ids_,
598 GetRequiredNumOfPictures()); 605 GetRequiredNumOfPictures());
599 VA_LOG_ON_ERROR(va_res, "vaDestroySurfaces failed"); 606 VA_LOG_ON_ERROR(va_res, "vaDestroySurfaces failed");
607
608 va_context_created_ = false;
600 } 609 }
601 610
602 void VaapiH264Decoder::DestroyPendingBuffers() { 611 void VaapiH264Decoder::DestroyPendingBuffers() {
603 while (!pending_slice_bufs_.empty()) { 612 while (!pending_slice_bufs_.empty()) {
604 VABufferID buffer = pending_slice_bufs_.front(); 613 VABufferID buffer = pending_slice_bufs_.front();
605 VAStatus va_res = VAAPI_DestroyBuffer(va_display_, buffer); 614 VAStatus va_res = VAAPI_DestroyBuffer(va_display_, buffer);
606 VA_LOG_ON_ERROR(va_res, "vaDestroyBuffer failed"); 615 VA_LOG_ON_ERROR(va_res, "vaDestroyBuffer failed");
607 pending_slice_bufs_.pop(); 616 pending_slice_bufs_.pop();
608 } 617 }
609 while (!pending_va_bufs_.empty()) { 618 while (!pending_va_bufs_.empty()) {
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2153 VAAPI_SyncSurface && 2162 VAAPI_SyncSurface &&
2154 VAAPI_BeginPicture && 2163 VAAPI_BeginPicture &&
2155 VAAPI_RenderPicture && 2164 VAAPI_RenderPicture &&
2156 VAAPI_EndPicture && 2165 VAAPI_EndPicture &&
2157 VAAPI_CreateBuffer && 2166 VAAPI_CreateBuffer &&
2158 VAAPI_DestroyBuffer && 2167 VAAPI_DestroyBuffer &&
2159 VAAPI_ErrorStr; 2168 VAAPI_ErrorStr;
2160 } 2169 }
2161 2170
2162 } // namespace content 2171 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/vaapi_h264_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698