| Index: source/libvpx/vp9/encoder/vp9_encoder.h
 | 
| diff --git a/source/libvpx/vp9/encoder/vp9_encoder.h b/source/libvpx/vp9/encoder/vp9_encoder.h
 | 
| index 69edfded13efcfe40eee13f29f716b6a2f889cca..c3679ca0b8e3f1e48eb5884c944373e6d68b799f 100644
 | 
| --- a/source/libvpx/vp9/encoder/vp9_encoder.h
 | 
| +++ b/source/libvpx/vp9/encoder/vp9_encoder.h
 | 
| @@ -17,6 +17,7 @@
 | 
|  #include "vpx/internal/vpx_codec_internal.h"
 | 
|  #include "vpx/vp8cx.h"
 | 
|  
 | 
| +#include "vp9/common/vp9_alloccommon.h"
 | 
|  #include "vp9/common/vp9_ppflags.h"
 | 
|  #include "vp9/common/vp9_entropymode.h"
 | 
|  #include "vp9/common/vp9_thread_common.h"
 | 
| @@ -47,7 +48,6 @@ extern "C" {
 | 
|  #endif
 | 
|  
 | 
|  #define DEFAULT_GF_INTERVAL         10
 | 
| -#define INVALID_REF_BUFFER_IDX      -1  // Marks an invalid reference buffer id.
 | 
|  
 | 
|  typedef struct {
 | 
|    int nmvjointcost[MV_JOINTS];
 | 
| @@ -517,8 +517,8 @@ static INLINE int frame_is_kf_gf_arf(const VP9_COMP *cpi) {
 | 
|           (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref);
 | 
|  }
 | 
|  
 | 
| -static INLINE int get_ref_frame_idx(const VP9_COMP *cpi,
 | 
| -                                    MV_REFERENCE_FRAME ref_frame) {
 | 
| +static INLINE int get_ref_frame_map_idx(const VP9_COMP *cpi,
 | 
| +                                        MV_REFERENCE_FRAME ref_frame) {
 | 
|    if (ref_frame == LAST_FRAME) {
 | 
|      return cpi->lst_fb_idx;
 | 
|    } else if (ref_frame == GOLDEN_FRAME) {
 | 
| @@ -528,12 +528,19 @@ static INLINE int get_ref_frame_idx(const VP9_COMP *cpi,
 | 
|    }
 | 
|  }
 | 
|  
 | 
| +static INLINE int get_ref_frame_buf_idx(const VP9_COMP *const cpi,
 | 
| +                                        int ref_frame) {
 | 
| +  const VP9_COMMON *const cm = &cpi->common;
 | 
| +  const int map_idx = get_ref_frame_map_idx(cpi, ref_frame);
 | 
| +  return (map_idx != INVALID_IDX) ? cm->ref_frame_map[map_idx] : INVALID_IDX;
 | 
| +}
 | 
| +
 | 
|  static INLINE YV12_BUFFER_CONFIG *get_ref_frame_buffer(
 | 
|      VP9_COMP *cpi, MV_REFERENCE_FRAME ref_frame) {
 | 
|    VP9_COMMON *const cm = &cpi->common;
 | 
| -  BufferPool *const pool = cm->buffer_pool;
 | 
| -  return &pool->frame_bufs[cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]]
 | 
| -      .buf;
 | 
| +  const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
 | 
| +  return
 | 
| +      buf_idx != INVALID_IDX ? &cm->buffer_pool->frame_bufs[buf_idx].buf : NULL;
 | 
|  }
 | 
|  
 | 
|  static INLINE int get_token_alloc(int mb_rows, int mb_cols) {
 | 
| 
 |