Commit 205a239c authored by Jingning Han's avatar Jingning Han
Browse files

Make dynamic motion vector referencing support multiple bwd refs

This commit makes the dynamic motion vector referencing system
support multiple backward reference frames, hence making the
two experiments work properly.

Change-Id: I7b9812a29d9e634ca4817d5d1116cd093fa74e68
parent 2ee52605
......@@ -99,36 +99,10 @@ typedef struct {
#endif
} b_mode_info;
// Note that the rate-distortion optimization loop, bit-stream writer, and
// decoder implementation modules critically rely on the defined entry values
// specified herein. They should be refactored concurrently.
#define NONE -1
#define INTRA_FRAME 0
#define LAST_FRAME 1
#if CONFIG_EXT_REFS
#define LAST2_FRAME 2
#define LAST3_FRAME 3
#define GOLDEN_FRAME 4
#define BWDREF_FRAME 5
#define ALTREF_FRAME 6
#define MAX_REF_FRAMES 7
#define LAST_REF_FRAMES (LAST3_FRAME - LAST_FRAME + 1)
#else
#define GOLDEN_FRAME 2
#define ALTREF_FRAME 3
#define MAX_REF_FRAMES 4
#endif // CONFIG_EXT_REFS
typedef int8_t MV_REFERENCE_FRAME;
#if CONFIG_REF_MV
#define MODE_CTX_REF_FRAMES (MAX_REF_FRAMES + (ALTREF_FRAME - LAST_FRAME))
#define MODE_CTX_REF_FRAMES (MAX_REF_FRAMES + COMP_REFS)
#else
#define MODE_CTX_REF_FRAMES MAX_REF_FRAMES
#endif
......
......@@ -192,14 +192,38 @@ typedef enum {
#define COMP_INTER_CONTEXTS 5
#define REF_CONTEXTS 5
// Reference frame types
#define NONE -1
#define INTRA_FRAME 0
#define LAST_FRAME 1
#if CONFIG_EXT_REFS
#define FWD_REFS 4
#define BWD_REFS 2
#define SINGLE_REFS (FWD_REFS + BWD_REFS)
#define LAST2_FRAME 2
#define LAST3_FRAME 3
#define GOLDEN_FRAME 4
#define BWDREF_FRAME 5
#define ALTREF_FRAME 6
#define MAX_REF_FRAMES 7
#define LAST_REF_FRAMES (LAST3_FRAME - LAST_FRAME + 1)
#else
#define SINGLE_REFS 3
#define GOLDEN_FRAME 2
#define ALTREF_FRAME 3
#define MAX_REF_FRAMES 4
#endif // CONFIG_EXT_REFS
#define FWD_REFS (GOLDEN_FRAME - LAST_FRAME + 1)
#define FWD_RF_OFFSET(ref) (ref - LAST_FRAME)
#if CONFIG_EXT_REFS
#define BWD_REFS (ALTREF_FRAME - BWDREF_FRAME + 1)
#define BWD_RF_OFFSET(ref) (ref - BWDREF_FRAME)
#else
#define BWD_REFS 1
#define BWD_RF_OFFSET(ref) (ref - ALTREF_FRAME)
#endif
#define SINGLE_REFS (FWD_REFS + BWD_REFS)
#define COMP_REFS (FWD_REFS * BWD_REFS)
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -342,16 +342,31 @@ static INLINE int av1_nmv_ctx(const uint8_t ref_mv_count,
return 0;
}
static int8_t av1_ref_frame_type(const MV_REFERENCE_FRAME *const rf) {
if (rf[1] > INTRA_FRAME) return rf[0] + ALTREF_FRAME;
static INLINE int8_t av1_ref_frame_type(const MV_REFERENCE_FRAME *const rf) {
if (rf[1] > INTRA_FRAME) {
return MAX_REF_FRAMES + FWD_RF_OFFSET(rf[0]) +
BWD_RF_OFFSET(rf[1]) * FWD_REFS;
}
return rf[0];
}
static void av1_set_ref_frame(MV_REFERENCE_FRAME *rf, int8_t ref_frame_type) {
if (ref_frame_type > ALTREF_FRAME) {
rf[0] = ref_frame_type - ALTREF_FRAME;
rf[1] = ALTREF_FRAME;
static MV_REFERENCE_FRAME ref_frame_map[COMP_REFS][2] = {
#if CONFIG_EXT_REFS
{ LAST_FRAME, BWDREF_FRAME }, { LAST2_FRAME, BWDREF_FRAME },
{ LAST3_FRAME, BWDREF_FRAME }, { GOLDEN_FRAME, BWDREF_FRAME },
{ LAST_FRAME, ALTREF_FRAME }, { LAST2_FRAME, ALTREF_FRAME },
{ LAST3_FRAME, ALTREF_FRAME }, { GOLDEN_FRAME, ALTREF_FRAME }
#else
{ LAST_FRAME, ALTREF_FRAME }, { GOLDEN_FRAME, ALTREF_FRAME }
#endif
};
static INLINE void av1_set_ref_frame(MV_REFERENCE_FRAME *rf,
int8_t ref_frame_type) {
if (ref_frame_type >= MAX_REF_FRAMES) {
rf[0] = ref_frame_map[ref_frame_type - MAX_REF_FRAMES][0];
rf[1] = ref_frame_map[ref_frame_type - MAX_REF_FRAMES][1];
} else {
rf[0] = ref_frame_type;
rf[1] = NONE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment