Commit 043f3a84 authored by posciak@chromium.org's avatar posciak@chromium.org

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
parent 74c938f1
...@@ -1790,6 +1790,13 @@ bool VaapiH264Decoder::FinishPicture() { ...@@ -1790,6 +1790,13 @@ bool VaapiH264Decoder::FinishPicture() {
<< " Num available dec surfaces: " << " Num available dec surfaces: "
<< num_available_decode_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()) { if (dpb_.IsFull()) {
// DPB is full, we have to make space for the new picture. // DPB is full, we have to make space for the new picture.
// Get all pictures that haven't been outputted yet. // Get all pictures that haven't been outputted yet.
...@@ -1804,15 +1811,16 @@ bool VaapiH264Decoder::FinishPicture() { ...@@ -1804,15 +1811,16 @@ bool VaapiH264Decoder::FinishPicture() {
// is not a reference picture, thus making space for the current one. // is not a reference picture, thus making space for the current one.
while (dpb_.IsFull()) { while (dpb_.IsFull()) {
// Maybe outputted enough to output current picture. // Maybe outputted enough to output current picture.
if (!curr_pic_->ref && (output_candidate == not_outputted.end() || if (!pic->ref && (output_candidate == not_outputted.end() ||
curr_pic_->pic_order_cnt < (*output_candidate)->pic_order_cnt)) { pic->pic_order_cnt < (*output_candidate)->pic_order_cnt)) {
// curr_pic_ is not a reference picture and no preceding pictures are // pic is not a reference picture and no preceding pictures are
// waiting for output in DPB, so it can be outputted and discarded // waiting for output in DPB, so it can be outputted and discarded
// without storing in DPB. // without storing in DPB.
if (!OutputPic(curr_pic_.get())) if (!OutputPic(pic.get()))
return false; return false;
// Managed to output current picture, return without adding to DPB. // Managed to output current picture, return without adding to DPB.
// This will release current picture (stored in pic).
return true; return true;
} }
...@@ -1832,13 +1840,14 @@ bool VaapiH264Decoder::FinishPicture() { ...@@ -1832,13 +1840,14 @@ bool VaapiH264Decoder::FinishPicture() {
DVLOG(1) << "Could not free up space in DPB!"; DVLOG(1) << "Could not free up space in DPB!";
return false; return false;
} }
++output_candidate;
} }
++output_candidate;
} }
// Store current picture for later output and/or reference (ownership now // Store current picture for later output and/or reference (ownership now
// with the DPB). // with the DPB).
dpb_.StorePic(curr_pic_.release()); dpb_.StorePic(pic.release());
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment