vp8:fix threading issues

1 - stops de allocating before threads are closed.
2 - limits threads to mb_rows when mb_rows < partitions

BUG=webm:851
Bug: 30436808

Change-Id: Ie017818ed28103ca9d26d57087f31361b642e09b
(cherry picked from commit 70cca742efa20617c70c3209aa614a70f282f90e)

static int get_free_fb (VP8_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 int get_free_fb (VP8_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;
}
