Constrain the max depth based on number of ref frames

Limit the maximum depth of the pyramid coding structure based on
the number of reference frames available to the coding frames.

Change-Id: I10da14c6bfe365dfd490828160401125ed8a7808
diff --git a/av1/ratectrl_qmode.cc b/av1/ratectrl_qmode.cc
index 22068e5..f1b67ae 100644
--- a/av1/ratectrl_qmode.cc
+++ b/av1/ratectrl_qmode.cc
@@ -201,7 +201,7 @@
     ref_frame_manager->UpdateRefFrameTable(&gop_frame);
     gop_struct.gop_frame_list.push_back(gop_frame);
     ConstructGopMultiLayer(&gop_struct, ref_frame_manager,
-                           ref_frame_manager->ForwardMaxSize(), arf_depth + 1,
+                           ref_frame_manager->MaxRefFrame() - 1, arf_depth + 1,
                            order_start, order_end);
     // Overlay
     gop_frame =
diff --git a/av1/reference_manager.h b/av1/reference_manager.h
index c2098ec..951d65d 100644
--- a/av1/reference_manager.h
+++ b/av1/reference_manager.h
@@ -73,6 +73,7 @@
   void UpdateOrder(int global_order_idx);
   int ColocatedRefIdx(int global_order_idx);
   int ForwardMaxSize() const { return forward_max_size_; }
+  int MaxRefFrame() const { return max_ref_frames_; }
   int CurGlobalOrderIdx() const { return cur_global_order_idx_; }
   void UpdateRefFrameTable(GopFrame *gop_frame);
   ReferenceFrame GetPrimaryRefFrame(const GopFrame &gop_frame) const;