| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 FillVAPicture(&va_pics[i++], *rit); | 174 FillVAPicture(&va_pics[i++], *rit); |
| 175 } | 175 } |
| 176 | 176 |
| 177 return i; | 177 return i; |
| 178 } | 178 } |
| 179 | 179 |
| 180 VaapiH264Decoder::DecodeSurface* VaapiH264Decoder::DecodeSurfaceByPoC(int poc) { | 180 VaapiH264Decoder::DecodeSurface* VaapiH264Decoder::DecodeSurfaceByPoC(int poc) { |
| 181 DecSurfacesInUse::iterator iter = decode_surfaces_in_use_.find(poc); | 181 DecSurfacesInUse::iterator iter = decode_surfaces_in_use_.find(poc); |
| 182 if (iter == decode_surfaces_in_use_.end()) { | 182 if (iter == decode_surfaces_in_use_.end()) { |
| 183 DVLOG(1) << "Could not find surface assigned to POC: " << poc; | 183 DVLOG(1) << "Could not find surface assigned to POC: " << poc; |
| 184 return NULL; | 184 return nullptr; |
| 185 } | 185 } |
| 186 | 186 |
| 187 return iter->second.get(); | 187 return iter->second.get(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool VaapiH264Decoder::AssignSurfaceToPoC(int32 input_id, int poc) { | 190 bool VaapiH264Decoder::AssignSurfaceToPoC(int32 input_id, int poc) { |
| 191 if (available_va_surfaces_.empty()) { | 191 if (available_va_surfaces_.empty()) { |
| 192 DVLOG(1) << "No VA Surfaces available"; | 192 DVLOG(1) << "No VA Surfaces available"; |
| 193 return false; | 193 return false; |
| 194 } | 194 } |
| (...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 std::max<int>(parser_.GetSPS(curr_sps_id_)->max_num_ref_frames, | 1258 std::max<int>(parser_.GetSPS(curr_sps_id_)->max_num_ref_frames, |
| 1259 1)); | 1259 1)); |
| 1260 if (dpb_.CountRefPics() == | 1260 if (dpb_.CountRefPics() == |
| 1261 std::max<int>(parser_.GetSPS(curr_sps_id_)->max_num_ref_frames, | 1261 std::max<int>(parser_.GetSPS(curr_sps_id_)->max_num_ref_frames, |
| 1262 1)) { | 1262 1)) { |
| 1263 // Max number of reference pics reached, | 1263 // Max number of reference pics reached, |
| 1264 // need to remove one of the short term ones. | 1264 // need to remove one of the short term ones. |
| 1265 // Find smallest frame_num_wrap short reference picture and mark | 1265 // Find smallest frame_num_wrap short reference picture and mark |
| 1266 // it as unused. | 1266 // it as unused. |
| 1267 H264Picture* to_unmark = dpb_.GetLowestFrameNumWrapShortRefPic(); | 1267 H264Picture* to_unmark = dpb_.GetLowestFrameNumWrapShortRefPic(); |
| 1268 if (to_unmark == NULL) { | 1268 if (to_unmark == nullptr) { |
| 1269 DVLOG(1) << "Couldn't find a short ref picture to unmark"; | 1269 DVLOG(1) << "Couldn't find a short ref picture to unmark"; |
| 1270 return; | 1270 return; |
| 1271 } | 1271 } |
| 1272 to_unmark->ref = false; | 1272 to_unmark->ref = false; |
| 1273 } | 1273 } |
| 1274 } else { | 1274 } else { |
| 1275 // Shouldn't get here. | 1275 // Shouldn't get here. |
| 1276 DVLOG(1) << "Interlaced video not supported."; | 1276 DVLOG(1) << "Interlaced video not supported."; |
| 1277 report_error_to_uma_cb_.Run(INTERLACED_STREAM); | 1277 report_error_to_uma_cb_.Run(INTERLACED_STREAM); |
| 1278 } | 1278 } |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 const media::H264PPS* pps = parser_.GetPPS(pps_id); | 1511 const media::H264PPS* pps = parser_.GetPPS(pps_id); |
| 1512 DCHECK(pps); | 1512 DCHECK(pps); |
| 1513 | 1513 |
| 1514 curr_pps_id_ = pps->pic_parameter_set_id; | 1514 curr_pps_id_ = pps->pic_parameter_set_id; |
| 1515 | 1515 |
| 1516 return true; | 1516 return true; |
| 1517 } | 1517 } |
| 1518 | 1518 |
| 1519 bool VaapiH264Decoder::FinishPrevFrameIfPresent() { | 1519 bool VaapiH264Decoder::FinishPrevFrameIfPresent() { |
| 1520 // If we already have a frame waiting to be decoded, decode it and finish. | 1520 // If we already have a frame waiting to be decoded, decode it and finish. |
| 1521 if (curr_pic_ != NULL) { | 1521 if (curr_pic_ != nullptr) { |
| 1522 if (!DecodePicture()) | 1522 if (!DecodePicture()) |
| 1523 return false; | 1523 return false; |
| 1524 return FinishPicture(); | 1524 return FinishPicture(); |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 return true; | 1527 return true; |
| 1528 } | 1528 } |
| 1529 | 1529 |
| 1530 bool VaapiH264Decoder::ProcessSlice(media::H264SliceHeader* slice_hdr) { | 1530 bool VaapiH264Decoder::ProcessSlice(media::H264SliceHeader* slice_hdr) { |
| 1531 prev_frame_num_ = frame_num_; | 1531 prev_frame_num_ = frame_num_; |
| 1532 frame_num_ = slice_hdr->frame_num; | 1532 frame_num_ = slice_hdr->frame_num; |
| 1533 | 1533 |
| 1534 if (prev_frame_num_ > 0 && prev_frame_num_ < frame_num_ - 1) { | 1534 if (prev_frame_num_ > 0 && prev_frame_num_ < frame_num_ - 1) { |
| 1535 DVLOG(1) << "Gap in frame_num!"; | 1535 DVLOG(1) << "Gap in frame_num!"; |
| 1536 report_error_to_uma_cb_.Run(GAPS_IN_FRAME_NUM); | 1536 report_error_to_uma_cb_.Run(GAPS_IN_FRAME_NUM); |
| 1537 return false; | 1537 return false; |
| 1538 } | 1538 } |
| 1539 | 1539 |
| 1540 if (slice_hdr->field_pic_flag == 0) | 1540 if (slice_hdr->field_pic_flag == 0) |
| 1541 max_pic_num_ = max_frame_num_; | 1541 max_pic_num_ = max_frame_num_; |
| 1542 else | 1542 else |
| 1543 max_pic_num_ = 2 * max_frame_num_; | 1543 max_pic_num_ = 2 * max_frame_num_; |
| 1544 | 1544 |
| 1545 // TODO posciak: switch to new picture detection per 7.4.1.2.4. | 1545 // TODO posciak: switch to new picture detection per 7.4.1.2.4. |
| 1546 if (curr_pic_ != NULL && slice_hdr->first_mb_in_slice != 0) { | 1546 if (curr_pic_ != nullptr && slice_hdr->first_mb_in_slice != 0) { |
| 1547 // This is just some more slice data of the current picture, so | 1547 // This is just some more slice data of the current picture, so |
| 1548 // just queue it and return. | 1548 // just queue it and return. |
| 1549 QueueSlice(slice_hdr); | 1549 QueueSlice(slice_hdr); |
| 1550 return true; | 1550 return true; |
| 1551 } else { | 1551 } else { |
| 1552 // A new frame, so first finish the previous one before processing it... | 1552 // A new frame, so first finish the previous one before processing it... |
| 1553 if (!FinishPrevFrameIfPresent()) | 1553 if (!FinishPrevFrameIfPresent()) |
| 1554 return false; | 1554 return false; |
| 1555 | 1555 |
| 1556 // and then start a new one. | 1556 // and then start a new one. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 break; | 1681 break; |
| 1682 } | 1682 } |
| 1683 } | 1683 } |
| 1684 } | 1684 } |
| 1685 | 1685 |
| 1686 size_t VaapiH264Decoder::GetRequiredNumOfPictures() { | 1686 size_t VaapiH264Decoder::GetRequiredNumOfPictures() { |
| 1687 return dpb_.max_num_pics() + kPicsInPipeline; | 1687 return dpb_.max_num_pics() + kPicsInPipeline; |
| 1688 } | 1688 } |
| 1689 | 1689 |
| 1690 } // namespace content | 1690 } // namespace content |
| OLD | NEW |