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; }
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; }
static vpx_codec_err_t decoder_destroy(vpx_codec_alg_priv_t *ctx) { if (ctx->frame_workers != NULL) { int i; for (i = 0; i < ctx->num_frame_workers; ++i) { VPxWorker *const worker = &ctx->frame_workers[i]; FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1; vpx_get_worker_interface()->end(worker); vp9_remove_common(&frame_worker_data->pbi->common); #if CONFIG_VP9_POSTPROC vp9_free_postproc_buffers(&frame_worker_data->pbi->common); #endif vp9_decoder_remove(frame_worker_data->pbi); vpx_free(frame_worker_data->scratch_buffer); #if CONFIG_MULTITHREAD pthread_mutex_destroy(&frame_worker_data->stats_mutex); pthread_cond_destroy(&frame_worker_data->stats_cond); #endif vpx_free(frame_worker_data); } #if CONFIG_MULTITHREAD pthread_mutex_destroy(&ctx->buffer_pool->pool_mutex); #endif } if (ctx->buffer_pool) { vp9_free_ref_frame_buffers(ctx->buffer_pool); vp9_free_internal_frame_buffers(&ctx->buffer_pool->int_frame_buffers); } vpx_free(ctx->frame_workers); vpx_free(ctx->buffer_pool); vpx_free(ctx); return VPX_CODEC_OK; }
void vp9_remove_common(VP9_COMMON *cm) { vp9_free_ref_frame_buffers(cm); vp9_free_context_buffers(cm); vpx_free(cm->fc); cm->fc = NULL; vpx_free(cm->frame_contexts); cm->frame_contexts = NULL; }
void vp9_remove_common(VP9_COMMON *cm) { vp9_free_ref_frame_buffers(cm); vp9_free_context_buffers(cm); vp9_free_internal_frame_buffers(&cm->int_frame_buffers); }