OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MEDIA_VIDEO_H264_POC_H_ | 5 #ifndef MEDIA_VIDEO_H264_POC_H_ |
6 #define MEDIA_VIDEO_H264_POC_H_ | 6 #define MEDIA_VIDEO_H264_POC_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 | 13 |
14 struct H264SPS; | 14 struct H264SPS; |
15 struct H264SliceHeader; | 15 struct H264SliceHeader; |
16 | 16 |
17 class MEDIA_EXPORT H264POC { | 17 class MEDIA_EXPORT H264POC { |
18 public: | 18 public: |
19 H264POC(); | 19 H264POC(); |
20 ~H264POC(); | 20 ~H264POC(); |
21 | 21 |
22 // Compute the picture order count for a slice, storing the result into | 22 // Returns the picture order count for a slice. |
23 // |*pic_order_cnt|. | 23 base::Optional<int32_t> ComputePicOrderCnt(const H264SPS* sps, |
24 // TODO(sandersd): Switch to a base::Optional<int32_t> return type. | 24 const H264SliceHeader& slice_hdr); |
25 bool ComputePicOrderCnt( | |
26 const H264SPS* sps, | |
27 const H264SliceHeader& slice_hdr, | |
28 int32_t* pic_order_cnt); | |
29 | 25 |
30 // As specified, the POC of a frame with MMCO5 changes (to zero) after | 26 // As specified, the POC of a frame with MMCO5 changes (to zero) after |
31 // decoding. We instead return 0 immediately, and flag that this has occurred | 27 // decoding. We instead return 0 immediately, and flag that this has occurred |
32 // by returning true here until ComputePicOrderCnt() is called again. | 28 // by returning true here until ComputePicOrderCnt() is called again. |
33 // | 29 // |
34 // Frames with MMCO5 do not reorder relative to frames earlier in decode | 30 // Frames with MMCO5 do not reorder relative to frames earlier in decode |
35 // order, but may reorder relative to frames later in decode order (just like | 31 // order, but may reorder relative to frames later in decode order (just like |
36 // IDRs). | 32 // IDRs). |
37 bool IsPendingMMCO5() { return pending_mmco5_; } | 33 bool IsPendingMMCO5() { return pending_mmco5_; } |
38 | 34 |
39 // Reset computation state. It's best (although not strictly required) to call | 35 // Reset computation state. It's best (although not strictly required) to call |
40 // this after a seek. | 36 // this after a seek. |
41 void Reset(); | 37 void Reset(); |
42 | 38 |
43 private: | 39 private: |
44 int32_t ref_pic_order_cnt_msb_; | 40 int32_t ref_pic_order_cnt_msb_; |
45 int32_t ref_pic_order_cnt_lsb_; | 41 int32_t ref_pic_order_cnt_lsb_; |
46 int32_t prev_frame_num_; | 42 int32_t prev_frame_num_; |
47 int32_t prev_frame_num_offset_; | 43 int32_t prev_frame_num_offset_; |
48 bool pending_mmco5_; | 44 bool pending_mmco5_; |
49 | 45 |
50 DISALLOW_COPY_AND_ASSIGN(H264POC); | 46 DISALLOW_COPY_AND_ASSIGN(H264POC); |
51 }; | 47 }; |
52 | 48 |
53 } // namespace media | 49 } // namespace media |
54 | 50 |
55 #endif // MEDIA_VIDEO_H264_POC_H_ | 51 #endif // MEDIA_VIDEO_H264_POC_H_ |
OLD | NEW |