Commit c2195c5b authored by Jingning Han's avatar Jingning Han
Browse files

Make drl support bi-directional reference frames

This commit refactors the reference frame structure used in the
dynamic motion vector referencing system, and makes it support
the bi-directional reference frames. This resolves unit test
failure (enc/dec mismatch) when both are turned on.

The compression performance (ref-mv + ext-refs) is improved by
0.2% for lowres.

Change-Id: I233624d8fccc1f69e82295f94de984ff056365dc
parent 7f929d29
......@@ -113,13 +113,22 @@ typedef struct {
#define GOLDEN_FRAME 2
#define ALTREF_FRAME 3
#define MAX_REF_FRAMES 4
#endif // CONFIG_EXT_REFS
typedef int8_t MV_REFERENCE_FRAME;
#define FWD_REF_FRAMES (GOLDEN_FRAME - LAST_FRAME + 1)
#define FWD_RF_OFFSET(ref) (ref - LAST_FRAME)
#if CONFIG_EXT_REFS
#define BWD_REF_FRAMES (ALTREF_FRAME - BWDREF_FRAME + 1)
#define BWD_RF_OFFSET(ref) (ref - BWDREF_FRAME)
#else
#define BWD_REF_FRAMES 1
#define BWD_RF_OFFSET(ref) (ref - ALTREF_FRAME)
#endif
#if CONFIG_REF_MV
#define MODE_CTX_REF_FRAMES (MAX_REF_FRAMES + (ALTREF_FRAME - LAST_FRAME))
#define MODE_CTX_REF_FRAMES (MAX_REF_FRAMES + FWD_REF_FRAMES * BWD_REF_FRAMES)
#else
#define MODE_CTX_REF_FRAMES MAX_REF_FRAMES
#endif
......
......@@ -261,17 +261,36 @@ static INLINE int vp10_nmv_ctx(const uint8_t ref_mv_count,
}
static INLINE int8_t vp10_ref_frame_type(const MV_REFERENCE_FRAME *const rf) {
if (rf[1] > INTRA_FRAME)
return rf[0] + ALTREF_FRAME;
if (rf[1] > INTRA_FRAME) {
return MAX_REF_FRAMES + FWD_RF_OFFSET(rf[0]) +
BWD_RF_OFFSET(rf[1]) * FWD_REF_FRAMES;
}
return rf[0];
}
static MV_REFERENCE_FRAME ref_frame_map[FWD_REF_FRAMES * BWD_REF_FRAMES][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 vp10_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;
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