Commit aa6c7546 authored by Yaowu Xu's avatar Yaowu Xu

Merge remote-tracking branch 'webm/master' into nextgenv2

parents 557cb9a8 6261fcf3
This diff is collapsed.
This diff is collapsed.
......@@ -2496,8 +2496,9 @@ static void resize_mv_buffer(VP10_COMMON *cm) {
vpx_free(cm->cur_frame->mvs);
cm->cur_frame->mi_rows = cm->mi_rows;
cm->cur_frame->mi_cols = cm->mi_cols;
cm->cur_frame->mvs = (MV_REF *)vpx_calloc(cm->mi_rows * cm->mi_cols,
sizeof(*cm->cur_frame->mvs));
CHECK_MEM_ERROR(cm, cm->cur_frame->mvs,
(MV_REF *)vpx_calloc(cm->mi_rows * cm->mi_cols,
sizeof(*cm->cur_frame->mvs)));
}
static void resize_context_buffers(VP10_COMMON *cm, int width, int height) {
......
......@@ -64,13 +64,13 @@ CYCLIC_REFRESH *vp10_cyclic_refresh_alloc(int mi_rows, int mi_cols) {
cr->map = vpx_calloc(mi_rows * mi_cols, sizeof(*cr->map));
if (cr->map == NULL) {
vpx_free(cr);
vp10_cyclic_refresh_free(cr);
return NULL;
}
last_coded_q_map_size = mi_rows * mi_cols * sizeof(*cr->last_coded_q_map);
cr->last_coded_q_map = vpx_malloc(last_coded_q_map_size);
if (cr->last_coded_q_map == NULL) {
vpx_free(cr);
vp10_cyclic_refresh_free(cr);
return NULL;
}
assert(MAXQ <= 255);
......
......@@ -1788,8 +1788,9 @@ VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf,
}
if (cpi->b_calculate_consistency) {
cpi->ssim_vars = vpx_malloc(sizeof(*cpi->ssim_vars) *
4 * cpi->common.mi_rows * cpi->common.mi_cols);
CHECK_MEM_ERROR(cm, cpi->ssim_vars,
vpx_malloc(sizeof(*cpi->ssim_vars) * 4 *
cpi->common.mi_rows * cpi->common.mi_cols));
cpi->worst_consistency = 100.0;
}
#endif
......@@ -2611,16 +2612,16 @@ static void loopfilter_frame(VP10_COMP *cpi, VP10_COMMON *cm) {
vpx_extend_frame_inner_borders(cm->frame_to_show);
}
static INLINE void alloc_frame_mvs(const VP10_COMMON *cm,
static INLINE void alloc_frame_mvs(VP10_COMMON *const cm,
int buffer_idx) {
RefCntBuffer *const new_fb_ptr = &cm->buffer_pool->frame_bufs[buffer_idx];
if (new_fb_ptr->mvs == NULL ||
new_fb_ptr->mi_rows < cm->mi_rows ||
new_fb_ptr->mi_cols < cm->mi_cols) {
vpx_free(new_fb_ptr->mvs);
new_fb_ptr->mvs =
(MV_REF *)vpx_calloc(cm->mi_rows * cm->mi_cols,
sizeof(*new_fb_ptr->mvs));
CHECK_MEM_ERROR(cm, new_fb_ptr->mvs,
(MV_REF *)vpx_calloc(cm->mi_rows * cm->mi_cols,
sizeof(*new_fb_ptr->mvs)));
new_fb_ptr->mi_rows = cm->mi_rows;
new_fb_ptr->mi_cols = cm->mi_cols;
}
......@@ -2667,12 +2668,13 @@ void vp10_scale_references(VP10_COMP *cpi) {
if (force_scaling ||
new_fb_ptr->buf.y_crop_width != cm->width ||
new_fb_ptr->buf.y_crop_height != cm->height) {
vpx_realloc_frame_buffer(&new_fb_ptr->buf,
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
cm->use_highbitdepth,
VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
NULL, NULL, NULL);
if (vpx_realloc_frame_buffer(&new_fb_ptr->buf, cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
cm->use_highbitdepth,
VP9_ENC_BORDER_IN_PIXELS,
cm->byte_alignment, NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
scale_and_extend_frame(ref, &new_fb_ptr->buf, (int)cm->bit_depth);
cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
alloc_frame_mvs(cm, new_fb);
......@@ -2692,11 +2694,12 @@ void vp10_scale_references(VP10_COMP *cpi) {
if (force_scaling ||
new_fb_ptr->buf.y_crop_width != cm->width ||
new_fb_ptr->buf.y_crop_height != cm->height) {
vpx_realloc_frame_buffer(&new_fb_ptr->buf,
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
NULL, NULL, NULL);
if (vpx_realloc_frame_buffer(&new_fb_ptr->buf, cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
VP9_ENC_BORDER_IN_PIXELS,
cm->byte_alignment, NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
scale_and_extend_frame(ref, &new_fb_ptr->buf);
cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
alloc_frame_mvs(cm, new_fb);
......@@ -2993,14 +2996,15 @@ static void set_frame_size(VP10_COMP *cpi) {
alloc_frame_mvs(cm, cm->new_fb_idx);
// Reset the frame pointers to the current frame size.
vpx_realloc_frame_buffer(get_frame_new_buffer(cm),
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
if (vpx_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
cm->use_highbitdepth,
#endif
VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
NULL, NULL, NULL);
VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
alloc_util_frame_buffers(cpi);
init_motion_estimation(cpi);
......@@ -3816,12 +3820,14 @@ static void setup_denoiser_buffer(VP10_COMP *cpi) {
VP10_COMMON *const cm = &cpi->common;
if (cpi->oxcf.noise_sensitivity > 0 &&
!cpi->denoiser.frame_buffer_initialized) {
vp10_denoiser_alloc(&(cpi->denoiser), cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
if (vp10_denoiser_alloc(&cpi->denoiser, cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
cm->use_highbitdepth,
#endif
VP9_ENC_BORDER_IN_PIXELS);
VP9_ENC_BORDER_IN_PIXELS))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate denoiser");
}
}
#endif
......@@ -3829,21 +3835,15 @@ static void setup_denoiser_buffer(VP10_COMP *cpi) {
int vp10_receive_raw_frame(VP10_COMP *cpi, unsigned int frame_flags,
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
int64_t end_time) {
VP10_COMMON *volatile const cm = &cpi->common;
VP10_COMMON *const cm = &cpi->common;
struct vpx_usec_timer timer;
volatile int res = 0;
int res = 0;
const int subsampling_x = sd->subsampling_x;
const int subsampling_y = sd->subsampling_y;
#if CONFIG_VP9_HIGHBITDEPTH
const int use_highbitdepth = (sd->flags & YV12_FLAG_HIGHBITDEPTH) != 0;
#endif
if (setjmp(cm->error.jmp)) {
cm->error.setjmp = 0;
return -1;
}
cm->error.setjmp = 1;
#if CONFIG_VP9_HIGHBITDEPTH
check_initial_width(cpi, use_highbitdepth, subsampling_x, subsampling_y);
#else
......@@ -3877,7 +3877,6 @@ int vp10_receive_raw_frame(VP10_COMP *cpi, unsigned int frame_flags,
res = -1;
}
cm->error.setjmp = 0;
return res;
}
......
......@@ -461,6 +461,7 @@ static void resize_multistep(const uint8_t *const input,
int filteredlength = length;
if (!tmpbuf) {
tmpbuf = (uint8_t *)malloc(sizeof(uint8_t) * length);
if (tmpbuf == NULL) return;
otmp = tmpbuf;
} else {
otmp = buf;
......@@ -520,6 +521,7 @@ void vp10_resize_plane(const uint8_t *const input,
uint8_t *tmpbuf = (uint8_t *)malloc(sizeof(uint8_t) *
(width < height ? height : width));
uint8_t *arrbuf = (uint8_t *)malloc(sizeof(uint8_t) * (height + height2));
if (intbuf == NULL || tmpbuf == NULL || arrbuf == NULL) goto Error;
assert(width > 0);
assert(height > 0);
assert(width2 > 0);
......@@ -532,6 +534,8 @@ void vp10_resize_plane(const uint8_t *const input,
resize_multistep(arrbuf, height, arrbuf + height, height2, tmpbuf);
fill_arr_to_col(output + i, out_stride, height2, arrbuf + height);
}
Error:
free(intbuf);
free(tmpbuf);
free(arrbuf);
......@@ -754,6 +758,7 @@ static void highbd_resize_multistep(const uint16_t *const input,
int filteredlength = length;
if (!tmpbuf) {
tmpbuf = (uint16_t *)malloc(sizeof(uint16_t) * length);
if (tmpbuf == NULL) return;
otmp = tmpbuf;
} else {
otmp = buf;
......@@ -816,6 +821,7 @@ void vp10_highbd_resize_plane(const uint8_t *const input,
uint16_t *tmpbuf = (uint16_t *)malloc(sizeof(uint16_t) *
(width < height ? height : width));
uint16_t *arrbuf = (uint16_t *)malloc(sizeof(uint16_t) * (height + height2));
if (intbuf == NULL || tmpbuf == NULL || arrbuf == NULL) goto Error;
for (i = 0; i < height; ++i) {
highbd_resize_multistep(CONVERT_TO_SHORTPTR(input + in_stride * i), width,
intbuf + width2 * i, width2, tmpbuf, bd);
......@@ -827,6 +833,8 @@ void vp10_highbd_resize_plane(const uint8_t *const input,
highbd_fill_arr_to_col(CONVERT_TO_SHORTPTR(output + i), out_stride, height2,
arrbuf + height);
}
Error:
free(intbuf);
free(tmpbuf);
free(arrbuf);
......
......@@ -14,6 +14,7 @@
#include "./vpx_config.h"
#include "vpx/vpx_encoder.h"
#include "vpx_ports/vpx_once.h"
#include "vpx_ports/system_state.h"
#include "vpx/internal/vpx_codec_internal.h"
#include "./vpx_version.h"
#include "vp10/encoder/encoder.h"
......@@ -873,18 +874,21 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
const vpx_image_t *img,
vpx_codec_pts_t pts,
unsigned long duration,
vpx_enc_frame_flags_t flags,
vpx_enc_frame_flags_t enc_flags,
unsigned long deadline) {
vpx_codec_err_t res = VPX_CODEC_OK;
volatile vpx_codec_err_t res = VPX_CODEC_OK;
volatile vpx_enc_frame_flags_t flags = enc_flags;
VP10_COMP *const cpi = ctx->cpi;
const vpx_rational_t *const timebase = &ctx->cfg.g_timebase;
size_t data_sz;
if (cpi == NULL) return VPX_CODEC_INVALID_PARAM;
if (img != NULL) {
res = validate_img(ctx, img);
// TODO(jzern) the checks related to cpi's validity should be treated as a
// failure condition, encoder setup is done fully in init() currently.
if (res == VPX_CODEC_OK && cpi != NULL) {
if (res == VPX_CODEC_OK) {
// There's no codec control for multiple alt-refs so check the encoder
// instance for its status to determine the compressed data size.
data_sz = ctx->cfg.g_w * ctx->cfg.g_h * get_image_bps(img) / 8 *
......@@ -912,6 +916,14 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
return VPX_CODEC_INVALID_PARAM;
}
if (setjmp(cpi->common.error.jmp)) {
cpi->common.error.setjmp = 0;
res = update_error_state(ctx, &cpi->common.error);
vpx_clear_system_state();
return res;
}
cpi->common.error.setjmp = 1;
vp10_apply_encoding_flags(cpi, flags);
// Handle fixed keyframe intervals
......@@ -923,8 +935,7 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
}
}
// Initialize the encoder instance on the first frame.
if (res == VPX_CODEC_OK && cpi != NULL) {
if (res == VPX_CODEC_OK) {
unsigned int lib_flags = 0;
YV12_BUFFER_CONFIG sd;
int64_t dst_time_stamp = timebase_units_to_ticks(timebase, pts);
......@@ -963,7 +974,8 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
* the buffer size anyway.
*/
if (cx_data_sz < ctx->cx_data_sz / 2) {
ctx->base.err_detail = "Compressed data buffer too small";
vpx_internal_error(&cpi->common.error, VPX_CODEC_ERROR,
"Compressed data buffer too small");
return VPX_CODEC_ERROR;
}
}
......@@ -1040,6 +1052,7 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
}
}
cpi->common.error.setjmp = 0;
return res;
}
......
......@@ -440,6 +440,11 @@ int vp8_denoiser_allocate(VP8_DENOISER *denoiser, int width, int height,
denoiser->yv12_last_source.frame_size);
denoiser->denoise_state = vpx_calloc((num_mb_rows * num_mb_cols), 1);
if (!denoiser->denoise_state)
{
vp8_denoiser_free(denoiser);
return 1;
}
memset(denoiser->denoise_state, 0, (num_mb_rows * num_mb_cols));
vp8_denoiser_set_parameters(denoiser, mode);
denoiser->nmse_source_diff = 0;
......
......@@ -1318,9 +1318,11 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
#if CONFIG_TEMPORAL_DENOISING
if (cpi->oxcf.noise_sensitivity > 0) {
vp8_denoiser_free(&cpi->denoiser);
vp8_denoiser_allocate(&cpi->denoiser, width, height,
cm->mb_rows, cm->mb_cols,
cpi->oxcf.noise_sensitivity);
if (vp8_denoiser_allocate(&cpi->denoiser, width, height,
cm->mb_rows, cm->mb_cols,
cpi->oxcf.noise_sensitivity))
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate denoiser");
}
#endif
}
......@@ -1832,9 +1834,11 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf)
{
int width = (cpi->oxcf.Width + 15) & ~15;
int height = (cpi->oxcf.Height + 15) & ~15;
vp8_denoiser_allocate(&cpi->denoiser, width, height,
cm->mb_rows, cm->mb_cols,
cpi->oxcf.noise_sensitivity);
if (vp8_denoiser_allocate(&cpi->denoiser, width, height,
cm->mb_rows, cm->mb_cols,
cpi->oxcf.noise_sensitivity))
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate denoiser");
}
}
#endif
......
......@@ -67,10 +67,11 @@ struct vpx_codec_alg_priv
FRAGMENT_DATA fragments;
};
static void vp8_init_ctx(vpx_codec_ctx_t *ctx)
static int vp8_init_ctx(vpx_codec_ctx_t *ctx)
{
vpx_codec_alg_priv_t *priv =
(vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv));
if (!priv) return 1;
ctx->priv = (vpx_codec_priv_t *)priv;
ctx->priv->init_flags = ctx->init_flags;
......@@ -85,6 +86,8 @@ static void vp8_init_ctx(vpx_codec_ctx_t *ctx)
priv->cfg = *ctx->config.dec;
ctx->config.dec = &priv->cfg;
}
return 0;
}
static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx,
......@@ -103,7 +106,7 @@ static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx,
* information becomes known.
*/
if (!ctx->priv) {
vp8_init_ctx(ctx);
if (vp8_init_ctx(ctx)) return VPX_CODEC_MEM_ERROR;
priv = (vpx_codec_alg_priv_t *)ctx->priv;
/* initialize number of fragments to zero */
......
......@@ -728,10 +728,8 @@ static const vp9_coeff_probs_model default_coef_probs_32x32[PLANE_TYPES] = {
};
static void extend_to_full_distribution(vpx_prob *probs, vpx_prob p) {
// TODO(aconverse): model[PIVOT_NODE] should never be zero.
// https://code.google.com/p/webm/issues/detail?id=1089
memcpy(probs, vp9_pareto8_full[p == 0 ? 254 : p - 1],
MODEL_NODES * sizeof(vpx_prob));
assert(p != 0);
memcpy(probs, vp9_pareto8_full[p - 1], MODEL_NODES * sizeof(vpx_prob));
}
void vp9_model_to_full_probs(const vpx_prob *model, vpx_prob *full) {
......
This diff is collapsed.
......@@ -1221,8 +1221,9 @@ static void resize_mv_buffer(VP9_COMMON *cm) {
vpx_free(cm->cur_frame->mvs);
cm->cur_frame->mi_rows = cm->mi_rows;
cm->cur_frame->mi_cols = cm->mi_cols;
cm->cur_frame->mvs = (MV_REF *)vpx_calloc(cm->mi_rows * cm->mi_cols,
sizeof(*cm->cur_frame->mvs));
CHECK_MEM_ERROR(cm, cm->cur_frame->mvs,
(MV_REF *)vpx_calloc(cm->mi_rows * cm->mi_cols,
sizeof(*cm->cur_frame->mvs)));
}
static void resize_context_buffers(VP9_COMMON *cm, int width, int height) {
......
......@@ -29,13 +29,13 @@ CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols) {
cr->map = vpx_calloc(mi_rows * mi_cols, sizeof(*cr->map));
if (cr->map == NULL) {
vpx_free(cr);
vp9_cyclic_refresh_free(cr);
return NULL;
}
last_coded_q_map_size = mi_rows * mi_cols * sizeof(*cr->last_coded_q_map);
cr->last_coded_q_map = vpx_malloc(last_coded_q_map_size);
if (cr->last_coded_q_map == NULL) {
vpx_free(cr);
vp9_cyclic_refresh_free(cr);
return NULL;
}
assert(MAXQ <= 255);
......@@ -44,7 +44,7 @@ CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols) {
consec_zero_mv_size = mi_rows * mi_cols * sizeof(*cr->consec_zero_mv);
cr->consec_zero_mv = vpx_malloc(consec_zero_mv_size);
if (cr->consec_zero_mv == NULL) {
vpx_free(cr);
vp9_cyclic_refresh_free(cr);
return NULL;
}
memset(cr->consec_zero_mv, 0, consec_zero_mv_size);
......
......@@ -12,9 +12,8 @@
#include "vp9/encoder/vp9_cost.h"
/* round(-log2(i/256.) * (1 << VP9_PROB_COST_SHIFT))
Begins and ends with a bogus entry to satisfy use of prob=0 in the firstpass.
https://code.google.com/p/webm/issues/detail?id=1089 */
const uint16_t vp9_prob_cost[257] = {
Begins with a bogus entry for simpler addressing. */
const uint16_t vp9_prob_cost[256] = {
4096, 4096, 3584, 3284, 3072, 2907, 2772, 2659, 2560, 2473, 2395, 2325,
2260, 2201, 2147, 2096, 2048, 2003, 1961, 1921, 1883, 1847, 1813, 1780,
1748, 1718, 1689, 1661, 1635, 1609, 1584, 1559, 1536, 1513, 1491, 1470,
......@@ -36,13 +35,14 @@ const uint16_t vp9_prob_cost[257] = {
125, 122, 119, 115, 112, 109, 105, 102, 99, 95, 92, 89,
86, 82, 79, 76, 73, 70, 66, 63, 60, 57, 54, 51,
48, 45, 42, 38, 35, 32, 29, 26, 23, 20, 18, 15,
12, 9, 6, 3, 3};
12, 9, 6, 3};
static void cost(int *costs, vpx_tree tree, const vpx_prob *probs,
int i, int c) {
const vpx_prob prob = probs[i / 2];
int b;
assert(prob != 0);
for (b = 0; b <= 1; ++b) {
const int cc = c + vp9_cost_bit(prob, b);
const vpx_tree_index ii = tree[i + b];
......
......@@ -18,7 +18,7 @@
extern "C" {
#endif
extern const uint16_t vp9_prob_cost[257];
extern const uint16_t vp9_prob_cost[256];
// The factor to scale from cost in bits to cost in vp9_prob_cost units.
#define VP9_PROB_COST_SHIFT 9
......
......@@ -1766,8 +1766,9 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
}
if (cpi->b_calculate_consistency) {
cpi->ssim_vars = vpx_malloc(sizeof(*cpi->ssim_vars) *
4 * cpi->common.mi_rows * cpi->common.mi_cols);
CHECK_MEM_ERROR(cm, cpi->ssim_vars,
vpx_malloc(sizeof(*cpi->ssim_vars) * 4 *
cpi->common.mi_rows * cpi->common.mi_cols));
cpi->worst_consistency = 100.0;
}
......@@ -2631,16 +2632,16 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
vpx_extend_frame_inner_borders(cm->frame_to_show);
}
static INLINE void alloc_frame_mvs(const VP9_COMMON *cm,
static INLINE void alloc_frame_mvs(VP9_COMMON *const cm,
int buffer_idx) {
RefCntBuffer *const new_fb_ptr = &cm->buffer_pool->frame_bufs[buffer_idx];
if (new_fb_ptr->mvs == NULL ||
new_fb_ptr->mi_rows < cm->mi_rows ||
new_fb_ptr->mi_cols < cm->mi_cols) {
vpx_free(new_fb_ptr->mvs);
new_fb_ptr->mvs =
(MV_REF *)vpx_calloc(cm->mi_rows * cm->mi_cols,
sizeof(*new_fb_ptr->mvs));
CHECK_MEM_ERROR(cm, new_fb_ptr->mvs,
(MV_REF *)vpx_calloc(cm->mi_rows * cm->mi_cols,
sizeof(*new_fb_ptr->mvs)));
new_fb_ptr->mi_rows = cm->mi_rows;
new_fb_ptr->mi_cols = cm->mi_cols;
}
......@@ -2678,12 +2679,13 @@ void vp9_scale_references(VP9_COMP *cpi) {
if (force_scaling ||
new_fb_ptr->buf.y_crop_width != cm->width ||
new_fb_ptr->buf.y_crop_height != cm->height) {
vpx_realloc_frame_buffer(&new_fb_ptr->buf,
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
cm->use_highbitdepth,
VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
NULL, NULL, NULL);
if (vpx_realloc_frame_buffer(&new_fb_ptr->buf, cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
cm->use_highbitdepth,
VP9_ENC_BORDER_IN_PIXELS,
cm->byte_alignment, NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
scale_and_extend_frame(ref, &new_fb_ptr->buf, (int)cm->bit_depth);
cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
alloc_frame_mvs(cm, new_fb);
......@@ -2703,11 +2705,12 @@ void vp9_scale_references(VP9_COMP *cpi) {
if (force_scaling ||
new_fb_ptr->buf.y_crop_width != cm->width ||
new_fb_ptr->buf.y_crop_height != cm->height) {
vpx_realloc_frame_buffer(&new_fb_ptr->buf,
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
NULL, NULL, NULL);
if (vpx_realloc_frame_buffer(&new_fb_ptr->buf, cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
VP9_ENC_BORDER_IN_PIXELS,
cm->byte_alignment, NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
vp9_scale_and_extend_frame(ref, &new_fb_ptr->buf);
cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
alloc_frame_mvs(cm, new_fb);
......@@ -2954,12 +2957,14 @@ static void setup_denoiser_buffer(VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
if (cpi->oxcf.noise_sensitivity > 0 &&
!cpi->denoiser.frame_buffer_initialized) {
vp9_denoiser_alloc(&(cpi->denoiser), cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
if (vp9_denoiser_alloc(&cpi->denoiser, cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
cm->use_highbitdepth,
#endif
VP9_ENC_BORDER_IN_PIXELS);
VP9_ENC_BORDER_IN_PIXELS))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate denoiser");
}
}
#endif
......@@ -3032,14 +3037,15 @@ static void set_frame_size(VP9_COMP *cpi) {
alloc_frame_mvs(cm, cm->new_fb_idx);
// Reset the frame pointers to the current frame size.
vpx_realloc_frame_buffer(get_frame_new_buffer(cm),
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
if (vpx_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
cm->use_highbitdepth,
#endif
VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
NULL, NULL, NULL);
VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
alloc_util_frame_buffers(cpi);
init_motion_estimation(cpi);
......@@ -3889,21 +3895,15 @@ static void check_initial_width(VP9_COMP *cpi,
int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags,
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
int64_t end_time) {
VP9_COMMON *volatile const cm = &cpi->common;
VP9_COMMON *const cm = &cpi->common;
struct vpx_usec_timer timer;
volatile int res = 0;
int res = 0;
const int subsampling_x = sd->subsampling_x;
const int subsampling_y = sd->subsampling_y;
#if CONFIG_VP9_HIGHBITDEPTH
const int use_highbitdepth = (sd->flags & YV12_FLAG_HIGHBITDEPTH) != 0;
#endif
if (setjmp(cm->error.jmp)) {
cm->error.setjmp = 0;
return -1;
}
cm->error.setjmp = 1;
#if CONFIG_VP9_HIGHBITDEPTH
check_initial_width(cpi, use_highbitdepth, subsampling_x, subsampling_y);
#else
......@@ -3937,7 +3937,6 @@ int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags,
res = -1;
}
cm->error.setjmp = 0;
return res;
}
......
......@@ -286,29 +286,37 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi) {
set_block_thresholds(cm, rd);
set_partition_probs(cm, xd);
if (!cpi->sf.use_nonrd_pick_mode || cm->frame_type == KEY_FRAME)
fill_token_costs(x->token_costs, cm->fc->coef_probs);
if (cpi->sf.partition_search_type != VAR_BASED_PARTITION ||
cm->frame_type == KEY_FRAME) {
for (i = 0; i < PARTITION_CONTEXTS; ++i)
vp9_cost_tokens(cpi->partition_cost[i], get_partition_probs(xd, i),
vp9_partition_tree);
}
if (cpi->oxcf.pass == 1) {
if (!frame_is_intra_only(cm))
vp9_build_nmv_cost_table(
x->nmvjointcost,
cm->allow_high_precision_mv ? x->nmvcost_hp : x->nmvcost,
&cm->fc->nmvc, cm->allow_high_precision_mv);
} else {
if (!cpi->sf.use_nonrd_pick_mode || cm->frame_type == KEY_FRAME)
fill_token_costs(x->token_costs, cm->fc->coef_probs);
if (cpi->sf.partition_search_type != VAR_BASED_PARTITION ||
cm->frame_type == KEY_FRAME) {
for (i = 0; i < PARTITION_CONTEXTS; ++i)
vp9_cost_tokens(cpi->partition_cost[i], get_partition_probs(xd, i),
vp9_partition_tree);
}
if (!cpi->sf.use_nonrd_pick_mode || (cm->current_video_frame & 0x07) == 1 ||
cm->frame_type == KEY_FRAME) {
fill_mode_costs(cpi);
if (!cpi->sf.use_nonrd_pick_mode || (cm->current_video_frame & 0x07) == 1 ||
cm->frame_type == KEY_FRAME) {
fill_mode_costs(cpi);
if (!frame_is_intra_only(cm)) {
vp9_build_nmv_cost_table(x->nmvjointcost,
cm->allow_high_precision_mv ? x->nmvcost_hp
: x->nmvcost,
&cm->fc->nmvc, cm->allow_high_precision_mv);
if (!frame_is_intra_only(cm)) {
vp9_build_nmv_cost_table(
x->nmvjointcost,
cm->allow_high_precision_mv ? x->nmvcost_hp : x->nmvcost,
&cm->fc->nmvc, cm->allow_high_precision_mv);
for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
vp9_cost_tokens((int *)cpi->inter_mode_cost[i],