We will init and update current_video_frame and current_frame_coding_index in the functions. So it's easier to keep track of when the frame indexes are updated.
Unified · Split
| @@ -226,7 +226,16 @@ typedef struct VP9Common { · 225 unmodified lines | |||
| 226 | unsigned int frame_context_idx; /* Context to use/update */ | 226 | unsigned int frame_context_idx; /* Context to use/update */ |
| 227 | FRAME_COUNTS counts; | 227 | FRAME_COUNTS counts; |
| 228 | 228 | ||
| 229 | // TODO(angiebird): current_video_frame/current_frame_coding_index into a | ||
| 230 | // structure | ||
| 229 | unsigned int current_video_frame; | 231 | unsigned int current_video_frame; |
| 232 | #if CONFIG_RATE_CTRL | ||
| 233 | // Each show or no show frame is assigned with a coding index based on its | ||
| 234 | // coding order (starting from zero). | ||
| 235 | |||
| 236 | // Current frame's coding index. | ||
| 237 | int current_frame_coding_index; | ||
| 238 | #endif | ||
| 230 | BITSTREAM_PROFILE profile; | 239 | BITSTREAM_PROFILE profile; |
| 231 | 240 | ||
| 232 | // VPX_BITS_8 in profile 0 or 1, VPX_BITS_10 or VPX_BITS_12 in profile 2 or 3. | 241 | // VPX_BITS_8 in profile 0 or 1, VPX_BITS_10 or VPX_BITS_12 in profile 2 or 3. |
| @@ -254,6 +263,22 @@ typedef struct VP9Common { · 21 unmodified lines | |||
| 254 | int lf_row; | 263 | int lf_row; |
| 255 | } VP9_COMMON; | 264 | } VP9_COMMON; |
| 256 | 265 | ||
| 266 | static INLINE void init_frame_indexes(VP9_COMMON *cm) { | ||
| 267 | cm->current_video_frame = 0; | ||
| 268 | #if CONFIG_RATE_CTRL | ||
| 269 | cm->current_frame_coding_index = 0; | ||
| 270 | #endif // CONFIG_RATE_CTRL | ||
| 271 | } | ||
| 272 | |||
| 273 | static INLINE void update_frame_indexes(VP9_COMMON *cm, int show_frame) { | ||
| 274 | if (show_frame) { | ||
| 275 | ++cm->current_video_frame; | ||
| 276 | } | ||
| 277 | #if CONFIG_RATE_CTRL | ||
| 278 | ++cm->current_frame_coding_index; | ||
| 279 | #endif // CONFIG_RATE_CTRL | ||
| 280 | } | ||
| 281 | |||
| 257 | typedef struct { | 282 | typedef struct { |
| 258 | int frame_width; | 283 | int frame_width; |
| 259 | int frame_height; | 284 | int frame_height; |
| @@ -188,7 +188,7 @@ VP9Decoder *vp9_decoder_create(BufferPool *const pool) { · 187 unmodified lines | |||
| 188 | memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map)); | 188 | memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map)); |
| 189 | memset(&cm->next_ref_frame_map, -1, sizeof(cm->next_ref_frame_map)); | 189 | memset(&cm->next_ref_frame_map, -1, sizeof(cm->next_ref_frame_map)); |
| 190 | 190 | ||
| 191 | cm->current_video_frame = 0; | 191 | init_frame_indexes(cm); |
| 192 | pbi->ready_for_new_data = 1; | 192 | pbi->ready_for_new_data = 1; |
| 193 | pbi->common.buffer_pool = pool; | 193 | pbi->common.buffer_pool = pool; |
| 194 | 194 | ||
| @@ -2311,7 +2311,7 @@ VP9_COMP *vp9_create_compressor(const VP9EncoderConfig *oxcf, · 2310 unmodified lines | |||
| 2311 | 2311 | ||
| 2312 | vp9_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc); | 2312 | vp9_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc); |
| 2313 | 2313 | ||
| 2314 | cm->current_video_frame = 0; | 2314 | init_frame_indexes(cm); |
| 2315 | cpi->partition_search_skippable_frame = 0; | 2315 | cpi->partition_search_skippable_frame = 0; |
| 2316 | cpi->tile_data = NULL; | 2316 | cpi->tile_data = NULL; |
| 2317 | 2317 | ||
| @@ -5342,7 +5342,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size, · 3024 unmodified lines | |||
| 5342 | vp9_swap_mi_and_prev_mi(cm); | 5342 | vp9_swap_mi_and_prev_mi(cm); |
| 5343 | // Don't increment frame counters if this was an altref buffer | 5343 | // Don't increment frame counters if this was an altref buffer |
| 5344 | // update not a real frame | 5344 | // update not a real frame |
| 5345 | ++cm->current_video_frame; | 5345 | update_frame_indexes(cm, cm->show_frame); |
| 5346 | if (cpi->use_svc) vp9_inc_frame_in_layer(cpi); | 5346 | if (cpi->use_svc) vp9_inc_frame_in_layer(cpi); |
| 5347 | } | 5347 | } |
| 5348 | 5348 | ||
| @@ -1478,7 +1478,8 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { · 1477 unmodified lines | |||
| 1478 | fclose(recon_file); | 1478 | fclose(recon_file); |
| 1479 | } | 1479 | } |
| 1480 | 1480 | ||
| 1481 | ++cm->current_video_frame; | 1481 | // In the first pass, every frame is considered as a show frame. |
| 1482 | update_frame_indexes(cm, /*show_frame=*/1); | ||
| 1482 | if (cpi->use_svc) vp9_inc_frame_in_layer(cpi); | 1483 | if (cpi->use_svc) vp9_inc_frame_in_layer(cpi); |
| 1483 | } | 1484 | } |
| 1484 | 1485 | ||