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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 prev_ref_field_ = curr_pic_->field; 1781 prev_ref_field_ = curr_pic_->field;
1782 } 1782 }
1783 1783
1784 // Remove unused (for reference or later output) pictures from DPB. 1784 // Remove unused (for reference or later output) pictures from DPB.
1785 dpb_.RemoveUnused(); 1785 dpb_.RemoveUnused();
1786 1786
1787 DVLOG(4) << "Finishing picture, DPB entries: " << dpb_.size() 1787 DVLOG(4) << "Finishing picture, DPB entries: " << dpb_.size()
1788 << " Num available dec surfaces: " 1788 << " Num available dec surfaces: "
1789 << num_available_decode_surfaces_; 1789 << num_available_decode_surfaces_;
1790 1790
1791 // Whatever happens below, curr_pic_ will stop managing the pointer to the
1792 // picture after this function returns. The ownership will either be
1793 // transferred to DPB, if the image is still needed (for output and/or
1794 // reference), or the memory will be released if we manage to output it here
1795 // without having to store it for future reference.
1796 scoped_ptr<H264Picture> pic(curr_pic_.release());
1797
1791 if (dpb_.IsFull()) { 1798 if (dpb_.IsFull()) {
1792 // DPB is full, we have to make space for the new picture. 1799 // DPB is full, we have to make space for the new picture.
1793 // Get all pictures that haven't been outputted yet. 1800 // Get all pictures that haven't been outputted yet.
1794 H264Picture::PtrVector not_outputted; 1801 H264Picture::PtrVector not_outputted;
1795 dpb_.GetNotOutputtedPicsAppending(not_outputted); 1802 dpb_.GetNotOutputtedPicsAppending(not_outputted);
1796 std::sort(not_outputted.begin(), not_outputted.end(), POCAscCompare()); 1803 std::sort(not_outputted.begin(), not_outputted.end(), POCAscCompare());
1797 H264Picture::PtrVector::iterator output_candidate = not_outputted.begin(); 1804 H264Picture::PtrVector::iterator output_candidate = not_outputted.begin();
1798 1805
1799 // Keep outputting pictures until we can either output the picture being 1806 // Keep outputting pictures until we can either output the picture being
1800 // finished and discard it (if it is not a reference picture), or until 1807 // finished and discard it (if it is not a reference picture), or until
1801 // we can discard an older picture that was just waiting for output and 1808 // we can discard an older picture that was just waiting for output and
1802 // is not a reference picture, thus making space for the current one. 1809 // is not a reference picture, thus making space for the current one.
1803 while (dpb_.IsFull()) { 1810 while (dpb_.IsFull()) {
1804 // Maybe outputted enough to output current picture. 1811 // Maybe outputted enough to output current picture.
1805 if (!curr_pic_->ref && (output_candidate == not_outputted.end() || 1812 if (!pic->ref && (output_candidate == not_outputted.end() ||
1806 curr_pic_->pic_order_cnt < (*output_candidate)->pic_order_cnt)) { 1813 pic->pic_order_cnt < (*output_candidate)->pic_order_cnt)) {
1807 // curr_pic_ is not a reference picture and no preceding pictures are 1814 // pic is not a reference picture and no preceding pictures are
1808 // waiting for output in DPB, so it can be outputted and discarded 1815 // waiting for output in DPB, so it can be outputted and discarded
1809 // without storing in DPB. 1816 // without storing in DPB.
1810 if (!OutputPic(curr_pic_.get())) 1817 if (!OutputPic(pic.get()))
1811 return false; 1818 return false;
1812 1819
1813 // Managed to output current picture, return without adding to DPB. 1820 // Managed to output current picture, return without adding to DPB.
1821 // This will release current picture (stored in pic).
1814 return true; 1822 return true;
1815 } 1823 }
1816 1824
1817 // Couldn't output current picture, so try to output the lowest PoC 1825 // Couldn't output current picture, so try to output the lowest PoC
1818 // from DPB. 1826 // from DPB.
1819 if (output_candidate != not_outputted.end()) { 1827 if (output_candidate != not_outputted.end()) {
1820 if (!OutputPic(*output_candidate)) 1828 if (!OutputPic(*output_candidate))
1821 return false; 1829 return false;
1822 1830
1823 // If outputted picture wasn't a reference picture, it can be removed. 1831 // If outputted picture wasn't a reference picture, it can be removed.
1824 if (!(*output_candidate)->ref) 1832 if (!(*output_candidate)->ref)
1825 dpb_.RemoveByPOC((*output_candidate)->pic_order_cnt); 1833 dpb_.RemoveByPOC((*output_candidate)->pic_order_cnt);
1826 } else { 1834 } else {
1827 // Couldn't output current pic and couldn't do anything 1835 // Couldn't output current pic and couldn't do anything
1828 // with existing pictures in DPB, so we can't make space. 1836 // with existing pictures in DPB, so we can't make space.
1829 // This should not happen. 1837 // This should not happen.
1830 DVLOG(1) << "Could not free up space in DPB!"; 1838 DVLOG(1) << "Could not free up space in DPB!";
1831 return false; 1839 return false;
1832 } 1840 }
1841
1842 ++output_candidate;
1833 } 1843 }
1834 ++output_candidate;
1835 } 1844 }
1836 1845
1837 // Store current picture for later output and/or reference (ownership now 1846 // Store current picture for later output and/or reference (ownership now
1838 // with the DPB). 1847 // with the DPB).
1839 dpb_.StorePic(curr_pic_.release()); 1848 dpb_.StorePic(pic.release());
1840 1849
1841 return true; 1850 return true;
1842 } 1851 }
1843 1852
1844 bool VaapiH264Decoder::ProcessSPS(int sps_id) { 1853 bool VaapiH264Decoder::ProcessSPS(int sps_id) {
1845 const H264SPS* sps = parser_.GetSPS(sps_id); 1854 const H264SPS* sps = parser_.GetSPS(sps_id);
1846 DCHECK(sps); 1855 DCHECK(sps);
1847 1856
1848 if (sps->frame_mbs_only_flag == 0) { 1857 if (sps->frame_mbs_only_flag == 0) {
1849 // Fields/interlaced video not supported. 1858 // Fields/interlaced video not supported.
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 VAAPI_SyncSurface && 2171 VAAPI_SyncSurface &&
2163 VAAPI_BeginPicture && 2172 VAAPI_BeginPicture &&
2164 VAAPI_RenderPicture && 2173 VAAPI_RenderPicture &&
2165 VAAPI_EndPicture && 2174 VAAPI_EndPicture &&
2166 VAAPI_CreateBuffer && 2175 VAAPI_CreateBuffer &&
2167 VAAPI_DestroyBuffer && 2176 VAAPI_DestroyBuffer &&
2168 VAAPI_ErrorStr; 2177 VAAPI_ErrorStr;
2169 } 2178 }
2170 2179
2171 } // namespace content 2180 } // namespace content
OLDNEW
« 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