summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorposciak@chromium.org <posciak@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-20 22:22:53 +0000
committerposciak@chromium.org <posciak@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-20 22:22:53 +0000
commit043f3a84a5111ec9e64a958cdb7ee1300889cdfe (patch)
tree9c858fc349ed562c9af4b5b594125f1e991e2844 /content
parent74c938f1836a5eeb3a4a2485da45fc2c3ad070fb (diff)
downloadchromium_src-043f3a84a5111ec9e64a958cdb7ee1300889cdfe.zip
chromium_src-043f3a84a5111ec9e64a958cdb7ee1300889cdfe.tar.gz
chromium_src-043f3a84a5111ec9e64a958cdb7ee1300889cdfe.tar.bz2
VAVDA: Clarify curr_pic_ ownership in FinishPicture().
This ensures that curr_pic_ is properly freed after FinishPicture() returns. BUG=143739 TEST=by hand Review URL: https://chromiumcodereview.appspot.com/10824341 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/common/gpu/media/vaapi_h264_decoder.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/content/common/gpu/media/vaapi_h264_decoder.cc b/content/common/gpu/media/vaapi_h264_decoder.cc
index b459ebb..02ad4e2 100644
--- a/content/common/gpu/media/vaapi_h264_decoder.cc
+++ b/content/common/gpu/media/vaapi_h264_decoder.cc
@@ -1790,6 +1790,13 @@ bool VaapiH264Decoder::FinishPicture() {
<< " Num available dec surfaces: "
<< num_available_decode_surfaces_;
+ // Whatever happens below, curr_pic_ will stop managing the pointer to the
+ // picture after this function returns. The ownership will either be
+ // transferred to DPB, if the image is still needed (for output and/or
+ // reference), or the memory will be released if we manage to output it here
+ // without having to store it for future reference.
+ scoped_ptr<H264Picture> pic(curr_pic_.release());
+
if (dpb_.IsFull()) {
// DPB is full, we have to make space for the new picture.
// Get all pictures that haven't been outputted yet.
@@ -1804,15 +1811,16 @@ bool VaapiH264Decoder::FinishPicture() {
// is not a reference picture, thus making space for the current one.
while (dpb_.IsFull()) {
// Maybe outputted enough to output current picture.
- if (!curr_pic_->ref && (output_candidate == not_outputted.end() ||
- curr_pic_->pic_order_cnt < (*output_candidate)->pic_order_cnt)) {
- // curr_pic_ is not a reference picture and no preceding pictures are
+ if (!pic->ref && (output_candidate == not_outputted.end() ||
+ pic->pic_order_cnt < (*output_candidate)->pic_order_cnt)) {
+ // pic is not a reference picture and no preceding pictures are
// waiting for output in DPB, so it can be outputted and discarded
// without storing in DPB.
- if (!OutputPic(curr_pic_.get()))
+ if (!OutputPic(pic.get()))
return false;
// Managed to output current picture, return without adding to DPB.
+ // This will release current picture (stored in pic).
return true;
}
@@ -1832,13 +1840,14 @@ bool VaapiH264Decoder::FinishPicture() {
DVLOG(1) << "Could not free up space in DPB!";
return false;
}
+
+ ++output_candidate;
}
- ++output_candidate;
}
// Store current picture for later output and/or reference (ownership now
// with the DPB).
- dpb_.StorePic(curr_pic_.release());
+ dpb_.StorePic(pic.release());
return true;
}