History

Add init/update_frame_indexes()

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.

angiebird committed 6 years ago

Commit 93834fa1 parent a1c0c954 files · +30 −4Browse files

Unified · Split

4 files
  1. vp9/common/vp9_onyxc_int.h +25 −0
  2. vp9/decoder/vp9_decoder.c +1 −1
  3. vp9/encoder/vp9_encoder.c +2 −2
  4. vp9/encoder/vp9_firstpass.c +2 −1
vp9/common/vp9_onyxc_int.h+25−0
@@ -226,7 +226,16 @@ typedef struct VP9Common { · 225 unmodified lines
226226 unsigned int frame_context_idx; /* Context to use/update */
227227 FRAME_COUNTS counts;
228228
229+ // TODO(angiebird): current_video_frame/current_frame_coding_index into a
230+ // structure
229231 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
230239 BITSTREAM_PROFILE profile;
231240
232241 // 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
254263 int lf_row;
255264 } VP9_COMMON;
256265
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+
257282 typedef struct {
258283 int frame_width;
259284 int frame_height;
vp9/decoder/vp9_decoder.c+1−1
@@ -188,7 +188,7 @@ VP9Decoder *vp9_decoder_create(BufferPool *const pool) { · 187 unmodified lines
188188 memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
189189 memset(&cm->next_ref_frame_map, -1, sizeof(cm->next_ref_frame_map));
190190
191− cm->current_video_frame = 0;
191+ init_frame_indexes(cm);
192192 pbi->ready_for_new_data = 1;
193193 pbi->common.buffer_pool = pool;
194194
vp9/encoder/vp9_encoder.c+2−2
@@ -2311,7 +2311,7 @@ VP9_COMP *vp9_create_compressor(const VP9EncoderConfig *oxcf, · 2310 unmodified lines
23112311
23122312 vp9_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc);
23132313
2314− cm->current_video_frame = 0;
2314+ init_frame_indexes(cm);
23152315 cpi->partition_search_skippable_frame = 0;
23162316 cpi->tile_data = NULL;
23172317
@@ -5342,7 +5342,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size, · 3024 unmodified lines
53425342 vp9_swap_mi_and_prev_mi(cm);
53435343 // Don't increment frame counters if this was an altref buffer
53445344 // update not a real frame
5345− ++cm->current_video_frame;
5345+ update_frame_indexes(cm, cm->show_frame);
53465346 if (cpi->use_svc) vp9_inc_frame_in_layer(cpi);
53475347 }
53485348
vp9/encoder/vp9_firstpass.c+2−1
@@ -1478,7 +1478,8 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { · 1477 unmodified lines
14781478 fclose(recon_file);
14791479 }
14801480
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);
14821483 if (cpi->use_svc) vp9_inc_frame_in_layer(cpi);
14831484 }
14841485

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t