OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 // This file contains codec dependent definitions that are needed in |
| 12 // order to compile the WebRTC codebase, even if this codec is not used. |
| 13 |
| 14 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_INCLUDE_VP9_GLOBALS_H_ |
| 15 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_INCLUDE_VP9_GLOBALS_H_ |
| 16 |
| 17 #include "webrtc/modules/video_coding/codecs/interface/common_constants.h" |
| 18 |
| 19 namespace webrtc { |
| 20 |
| 21 const int16_t kMaxOneBytePictureId = 0x7F; // 7 bits |
| 22 const int16_t kMaxTwoBytePictureId = 0x7FFF; // 15 bits |
| 23 const uint8_t kNoSpatialIdx = 0xFF; |
| 24 const uint8_t kNoGofIdx = 0xFF; |
| 25 const uint8_t kNumVp9Buffers = 8; |
| 26 const size_t kMaxVp9RefPics = 3; |
| 27 const size_t kMaxVp9FramesInGof = 0xFF; // 8 bits |
| 28 const size_t kMaxVp9NumberOfSpatialLayers = 8; |
| 29 |
| 30 enum TemporalStructureMode { |
| 31 kTemporalStructureMode1, // 1 temporal layer structure - i.e., IPPP... |
| 32 kTemporalStructureMode2, // 2 temporal layers 01... |
| 33 kTemporalStructureMode3, // 3 temporal layers 0212... |
| 34 kTemporalStructureMode4 // 3 temporal layers 02120212... |
| 35 }; |
| 36 |
| 37 struct GofInfoVP9 { |
| 38 void SetGofInfoVP9(TemporalStructureMode tm) { |
| 39 switch (tm) { |
| 40 case kTemporalStructureMode1: |
| 41 num_frames_in_gof = 1; |
| 42 temporal_idx[0] = 0; |
| 43 temporal_up_switch[0] = false; |
| 44 num_ref_pics[0] = 1; |
| 45 pid_diff[0][0] = 1; |
| 46 break; |
| 47 case kTemporalStructureMode2: |
| 48 num_frames_in_gof = 2; |
| 49 temporal_idx[0] = 0; |
| 50 temporal_up_switch[0] = false; |
| 51 num_ref_pics[0] = 1; |
| 52 pid_diff[0][0] = 2; |
| 53 |
| 54 temporal_idx[1] = 1; |
| 55 temporal_up_switch[1] = true; |
| 56 num_ref_pics[1] = 1; |
| 57 pid_diff[1][0] = 1; |
| 58 break; |
| 59 case kTemporalStructureMode3: |
| 60 num_frames_in_gof = 4; |
| 61 temporal_idx[0] = 0; |
| 62 temporal_up_switch[0] = false; |
| 63 num_ref_pics[0] = 1; |
| 64 pid_diff[0][0] = 4; |
| 65 |
| 66 temporal_idx[1] = 2; |
| 67 temporal_up_switch[1] = true; |
| 68 num_ref_pics[1] = 1; |
| 69 pid_diff[1][0] = 1; |
| 70 |
| 71 temporal_idx[2] = 1; |
| 72 temporal_up_switch[2] = true; |
| 73 num_ref_pics[2] = 1; |
| 74 pid_diff[2][0] = 2; |
| 75 |
| 76 temporal_idx[3] = 2; |
| 77 temporal_up_switch[3] = false; |
| 78 num_ref_pics[3] = 2; |
| 79 pid_diff[3][0] = 1; |
| 80 pid_diff[3][1] = 2; |
| 81 break; |
| 82 case kTemporalStructureMode4: |
| 83 num_frames_in_gof = 8; |
| 84 temporal_idx[0] = 0; |
| 85 temporal_up_switch[0] = false; |
| 86 num_ref_pics[0] = 1; |
| 87 pid_diff[0][0] = 4; |
| 88 |
| 89 temporal_idx[1] = 2; |
| 90 temporal_up_switch[1] = true; |
| 91 num_ref_pics[1] = 1; |
| 92 pid_diff[1][0] = 1; |
| 93 |
| 94 temporal_idx[2] = 1; |
| 95 temporal_up_switch[2] = true; |
| 96 num_ref_pics[2] = 1; |
| 97 pid_diff[2][0] = 2; |
| 98 |
| 99 temporal_idx[3] = 2; |
| 100 temporal_up_switch[3] = false; |
| 101 num_ref_pics[3] = 2; |
| 102 pid_diff[3][0] = 1; |
| 103 pid_diff[3][1] = 2; |
| 104 |
| 105 temporal_idx[4] = 0; |
| 106 temporal_up_switch[0] = false; |
| 107 num_ref_pics[4] = 1; |
| 108 pid_diff[4][0] = 4; |
| 109 |
| 110 temporal_idx[5] = 2; |
| 111 temporal_up_switch[1] = false; |
| 112 num_ref_pics[5] = 2; |
| 113 pid_diff[5][0] = 1; |
| 114 pid_diff[5][1] = 2; |
| 115 |
| 116 temporal_idx[6] = 1; |
| 117 temporal_up_switch[2] = false; |
| 118 num_ref_pics[6] = 2; |
| 119 pid_diff[6][0] = 2; |
| 120 pid_diff[6][1] = 4; |
| 121 |
| 122 temporal_idx[7] = 2; |
| 123 temporal_up_switch[3] = false; |
| 124 num_ref_pics[7] = 2; |
| 125 pid_diff[7][0] = 1; |
| 126 pid_diff[7][1] = 2; |
| 127 break; |
| 128 default: |
| 129 assert(false); |
| 130 } |
| 131 } |
| 132 |
| 133 void CopyGofInfoVP9(const GofInfoVP9& src) { |
| 134 num_frames_in_gof = src.num_frames_in_gof; |
| 135 for (size_t i = 0; i < num_frames_in_gof; ++i) { |
| 136 temporal_idx[i] = src.temporal_idx[i]; |
| 137 temporal_up_switch[i] = src.temporal_up_switch[i]; |
| 138 num_ref_pics[i] = src.num_ref_pics[i]; |
| 139 for (uint8_t r = 0; r < num_ref_pics[i]; ++r) { |
| 140 pid_diff[i][r] = src.pid_diff[i][r]; |
| 141 } |
| 142 } |
| 143 } |
| 144 |
| 145 size_t num_frames_in_gof; |
| 146 uint8_t temporal_idx[kMaxVp9FramesInGof]; |
| 147 bool temporal_up_switch[kMaxVp9FramesInGof]; |
| 148 uint8_t num_ref_pics[kMaxVp9FramesInGof]; |
| 149 uint8_t pid_diff[kMaxVp9FramesInGof][kMaxVp9RefPics]; |
| 150 uint16_t pid_start; |
| 151 }; |
| 152 |
| 153 struct RTPVideoHeaderVP9 { |
| 154 void InitRTPVideoHeaderVP9() { |
| 155 inter_pic_predicted = false; |
| 156 flexible_mode = false; |
| 157 beginning_of_frame = false; |
| 158 end_of_frame = false; |
| 159 ss_data_available = false; |
| 160 picture_id = kNoPictureId; |
| 161 max_picture_id = kMaxTwoBytePictureId; |
| 162 tl0_pic_idx = kNoTl0PicIdx; |
| 163 temporal_idx = kNoTemporalIdx; |
| 164 spatial_idx = kNoSpatialIdx; |
| 165 temporal_up_switch = false; |
| 166 inter_layer_predicted = false; |
| 167 gof_idx = kNoGofIdx; |
| 168 num_ref_pics = 0; |
| 169 num_spatial_layers = 1; |
| 170 } |
| 171 |
| 172 bool inter_pic_predicted; // This layer frame is dependent on previously |
| 173 // coded frame(s). |
| 174 bool flexible_mode; // This frame is in flexible mode. |
| 175 bool beginning_of_frame; // True if this packet is the first in a VP9 layer |
| 176 // frame. |
| 177 bool end_of_frame; // True if this packet is the last in a VP9 layer frame. |
| 178 bool ss_data_available; // True if SS data is available in this payload |
| 179 // descriptor. |
| 180 int16_t picture_id; // PictureID index, 15 bits; |
| 181 // kNoPictureId if PictureID does not exist. |
| 182 int16_t max_picture_id; // Maximum picture ID index; either 0x7F or 0x7FFF; |
| 183 int16_t tl0_pic_idx; // TL0PIC_IDX, 8 bits; |
| 184 // kNoTl0PicIdx means no value provided. |
| 185 uint8_t temporal_idx; // Temporal layer index, or kNoTemporalIdx. |
| 186 uint8_t spatial_idx; // Spatial layer index, or kNoSpatialIdx. |
| 187 bool temporal_up_switch; // True if upswitch to higher frame rate is possible |
| 188 // starting from this frame. |
| 189 bool inter_layer_predicted; // Frame is dependent on directly lower spatial |
| 190 // layer frame. |
| 191 |
| 192 uint8_t gof_idx; // Index to predefined temporal frame info in SS data. |
| 193 |
| 194 uint8_t num_ref_pics; // Number of reference pictures used by this layer |
| 195 // frame. |
| 196 uint8_t pid_diff[kMaxVp9RefPics]; // P_DIFF signaled to derive the PictureID |
| 197 // of the reference pictures. |
| 198 int16_t ref_picture_id[kMaxVp9RefPics]; // PictureID of reference pictures. |
| 199 |
| 200 // SS data. |
| 201 size_t num_spatial_layers; // Always populated. |
| 202 bool spatial_layer_resolution_present; |
| 203 uint16_t width[kMaxVp9NumberOfSpatialLayers]; |
| 204 uint16_t height[kMaxVp9NumberOfSpatialLayers]; |
| 205 GofInfoVP9 gof; |
| 206 }; |
| 207 |
| 208 } // namespace webrtc |
| 209 |
| 210 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_INCLUDE_VP9_GLOBALS_H_ |
OLD | NEW |