} VP9_COMMON;
+static int get_free_fb(VP9_COMMON *cm) {
+ int i;
+ for (i = 0; i < NUM_YV12_BUFFERS; i++)
+ if (cm->fb_idx_ref_cnt[i] == 0)
+ break;
+
+ assert(i < NUM_YV12_BUFFERS);
+ cm->fb_idx_ref_cnt[i] = 1;
+ return i;
+}
+
+static void ref_cnt_fb(int *buf, int *idx, int new_idx) {
+ if (buf[*idx] > 0)
+ buf[*idx]--;
+
+ *idx = new_idx;
+
+ buf[new_idx]++;
+}
+
#endif // VP9_COMMON_VP9_ONYXC_INT_H_
#include "vp9/decoder/vp9_detokenize.h"
#include "./vpx_scale_rtcd.h"
-static int get_free_fb(VP9_COMMON *cm);
-static void ref_cnt_fb(int *buf, int *idx, int new_idx);
-
#define WRITE_RECON_BUFFER 0
#if WRITE_RECON_BUFFER == 1
static void recon_write_yuv_frame(char *name, YV12_BUFFER_CONFIG *s) {
}
-static int get_free_fb(VP9_COMMON *cm) {
- int i;
- for (i = 0; i < NUM_YV12_BUFFERS; i++)
- if (cm->fb_idx_ref_cnt[i] == 0)
- break;
-
- assert(i < NUM_YV12_BUFFERS);
- cm->fb_idx_ref_cnt[i] = 1;
- return i;
-}
-
-static void ref_cnt_fb(int *buf, int *idx, int new_idx) {
- if (buf[*idx] > 0)
- buf[*idx]--;
-
- *idx = new_idx;
-
- buf[new_idx]++;
-}
-
/* If any buffer copy / swapping is signalled it should be done here. */
static int swap_frame_buffers(VP9_COMMON *cm) {
int err = 0;
}
static void update_reference_frames(VP9_COMMON *cm) {
- YV12_BUFFER_CONFIG *yv12_fb = cm->yv12_fb;
-
// At this point the new frame has been encoded.
// If any buffer copy / swapping is signaled it should be done here.
if (cm->frame_type == KEY_FRAME) {
- yv12_fb[cm->new_fb_idx].flags |= VP9_GOLD_FLAG | VP9_ALT_FLAG;
-
- yv12_fb[cm->gld_fb_idx].flags &= ~VP9_GOLD_FLAG;
- yv12_fb[cm->alt_fb_idx].flags &= ~VP9_ALT_FLAG;
-
- cm->alt_fb_idx = cm->gld_fb_idx = cm->new_fb_idx;
+ ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, cm->new_fb_idx);
+ ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->alt_fb_idx, cm->new_fb_idx);
} else { /* For non key frames */
if (cm->refresh_alt_ref_frame) {
- cm->yv12_fb[cm->new_fb_idx].flags |= VP9_ALT_FLAG;
- cm->yv12_fb[cm->alt_fb_idx].flags &= ~VP9_ALT_FLAG;
- cm->alt_fb_idx = cm->new_fb_idx;
+ ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->alt_fb_idx, cm->new_fb_idx);
}
if (cm->refresh_golden_frame) {
- cm->yv12_fb[cm->new_fb_idx].flags |= VP9_GOLD_FLAG;
- cm->yv12_fb[cm->gld_fb_idx].flags &= ~VP9_GOLD_FLAG;
- cm->gld_fb_idx = cm->new_fb_idx;
+ ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, cm->new_fb_idx);
}
}
if (cm->refresh_last_frame) {
- cm->yv12_fb[cm->new_fb_idx].flags |= VP9_LAST_FLAG;
- cm->yv12_fb[cm->lst_fb_idx].flags &= ~VP9_LAST_FLAG;
- cm->lst_fb_idx = cm->new_fb_idx;
+ ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->lst_fb_idx, cm->new_fb_idx);
}
}
}
#endif
- /* find a free buffer for the new frame */
- {
- int i = 0;
- for (; i < NUM_YV12_BUFFERS; i++) {
- if (!cm->yv12_fb[i].flags) {
- cm->new_fb_idx = i;
- break;
- }
- }
- assert(i < NUM_YV12_BUFFERS);
- }
+ /* find a free buffer for the new frame, releasing the reference previously
+ * held.
+ */
+ cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
+ cm->new_fb_idx = get_free_fb(cm);
+
if (cpi->pass == 1) {
Pass1Encode(cpi, size, dest, frame_flags);
} else if (cpi->pass == 2) {