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

Unified Diff: content/common/gpu/media/vaapi_h264_decoder.cc

Issue 10824341: VAVDA: Clarify curr_pic_ ownership in FinishPicture(). (Closed) Base URL: https://git.chromium.org/git/chromium/src@git-svn
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/vaapi_h264_decoder.cc
diff --git a/content/common/gpu/media/vaapi_h264_decoder.cc b/content/common/gpu/media/vaapi_h264_decoder.cc
index 0d8643e9de2f8612911de9c725489efa1da86308..64eb6e1b88906ee13ed521aae89fdb378da37568 100644
--- a/content/common/gpu/media/vaapi_h264_decoder.cc
+++ b/content/common/gpu/media/vaapi_h264_decoder.cc
@@ -1788,6 +1788,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.
@@ -1802,15 +1809,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;
}
@@ -1830,13 +1838,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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698