Example #1
0
int vp9_alloc_ref_frame_buffers(VP9_COMMON *cm, int width, int height) {
  int i;
  const int ss_x = cm->subsampling_x;
  const int ss_y = cm->subsampling_y;

  vp9_free_ref_frame_buffers(cm);

  for (i = 0; i < FRAME_BUFFERS; ++i) {
    cm->frame_bufs[i].ref_count = 0;
    if (vp9_alloc_frame_buffer(&cm->frame_bufs[i].buf, width, height,
                               ss_x, ss_y,
#if CONFIG_VP9_HIGHBITDEPTH
                               cm->use_highbitdepth,
#endif
                               VP9_ENC_BORDER_IN_PIXELS) < 0)
      goto fail;
  }

  init_frame_bufs(cm);

#if CONFIG_INTERNAL_STATS || CONFIG_VP9_POSTPROC
  if (vp9_alloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y,
#if CONFIG_VP9_HIGHBITDEPTH
                             cm->use_highbitdepth,
#endif
                             VP9_ENC_BORDER_IN_PIXELS) < 0)
    goto fail;
#endif

  return 0;

 fail:
  vp9_free_ref_frame_buffers(cm);
  return 1;
}
int vp9_alloc_ref_frame_buffers(VP9_COMMON *cm, int width, int height) {
  int i;
  const int ss_x = cm->subsampling_x;
  const int ss_y = cm->subsampling_y;
  vpx_get_frame_buffer_cb_fn_t cb = NULL;
  vpx_codec_frame_buffer_t *codec_frame_buffer = NULL;
  void *cb_priv = NULL;

  vp9_free_ref_frame_buffers(cm);

  for (i = 0; i < FRAME_BUFFERS; ++i) {
#if CONFIG_GPU_COMPUTE
    vpx_codec_frame_buffer_t raw_frame_buffer;
    gpu_cb_priv gpu_priv = {cm, &cm->frame_bufs[i].buf};

    if (cm->use_gpu) {
      cb = vp9_gpu_get_frame_buffer;
      codec_frame_buffer = &raw_frame_buffer;
      cb_priv = &gpu_priv;
    }
#if CONFIG_VP9_HIGHBITDEPTH
    // gpu kernels for now do not support higher bit depths.
    assert(cm->use_highbitdepth == 0);
#endif
#endif
    cm->frame_bufs[i].ref_count = 0;
    if (&cm->frame_bufs[i].buf) {
      vp9_free_frame_buffer(&cm->frame_bufs[i].buf);
      if (vp9_realloc_frame_buffer(&cm->frame_bufs[i].buf, width, height,
                                   ss_x, ss_y,
#if CONFIG_VP9_HIGHBITDEPTH
                                   cm->use_highbitdepth,
#endif
                                   VP9_ENC_BORDER_IN_PIXELS,
                                   codec_frame_buffer, cb, cb_priv)){
        goto fail;
      }
    }
  }

  init_frame_bufs(cm);

#if CONFIG_INTERNAL_STATS || CONFIG_VP9_POSTPROC
  if (vp9_alloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y,
#if CONFIG_VP9_HIGHBITDEPTH
                             cm->use_highbitdepth,
#endif
                             VP9_ENC_BORDER_IN_PIXELS) < 0)
    goto fail;
#endif

  return 0;

 fail:
  vp9_free_ref_frame_buffers(cm);
  return 1;
}
Example #3
0
int vp9_alloc_ref_frame_buffers(VP9_COMMON *cm, int width, int height) {
  int i;
  const int ss_x = cm->subsampling_x;
  const int ss_y = cm->subsampling_y;

  vp9_free_ref_frame_buffers(cm);

  for (i = 0; i < FRAME_BUFFERS; ++i) {
    BufferPool *const pool = cm->buffer_pool;
    pool->frame_bufs[i].ref_count = 0;
    if (vp9_alloc_frame_buffer(&pool->frame_bufs[i].buf, width, height,
                               ss_x, ss_y,
#if CONFIG_VP9_HIGHBITDEPTH
                               cm->use_highbitdepth,
#endif
                               VP9_ENC_BORDER_IN_PIXELS,
                               cm->byte_alignment) < 0)
      goto fail;
    if (pool->frame_bufs[i].mvs == NULL) {
      pool->frame_bufs[i].mvs =
          (MV_REF *)vpx_calloc(cm->mi_rows * cm->mi_cols,
                               sizeof(*pool->frame_bufs[i].mvs));
      if (pool->frame_bufs[i].mvs == NULL)
        goto fail;

      pool->frame_bufs[i].mi_rows = cm->mi_rows;
      pool->frame_bufs[i].mi_cols = cm->mi_cols;
    }
  }

  init_frame_bufs(cm);

#if CONFIG_VP9_POSTPROC
  if (vp9_alloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y,
#if CONFIG_VP9_HIGHBITDEPTH
                             cm->use_highbitdepth,
#endif
                             VP9_ENC_BORDER_IN_PIXELS,
                             cm->byte_alignment) < 0)
    goto fail;
#endif

  return 0;

 fail:
  vp9_free_ref_frame_buffers(cm);
  return 1;
}