Removing CONFIG_DEBUG checks on assertions.
Adding CHECK_MEM_ERROR macro to vp9_common.h and removing two duplicated ones from vp9_onyx_int.h and vp9_onyxd_int.h. Change-Id: I916afec61b3019f18193135dac7c35ed0f89b8b6
This commit is contained in:
parent
a3664258c5
commit
8e6ce6bb9e
@ -72,6 +72,23 @@ static int get_unsigned_bits(unsigned int num_values) {
|
||||
return cat;
|
||||
}
|
||||
|
||||
#if CONFIG_DEBUG
|
||||
#define CHECK_MEM_ERROR(cm, lval, expr) do { \
|
||||
lval = (expr); \
|
||||
if (!lval) \
|
||||
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, \
|
||||
"Failed to allocate "#lval" at %s:%d", \
|
||||
__FILE__, __LINE__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define CHECK_MEM_ERROR(cm, lval, expr) do { \
|
||||
lval = (expr); \
|
||||
if (!lval) \
|
||||
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, \
|
||||
"Failed to allocate "#lval); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define SYNC_CODE_0 0x49
|
||||
#define SYNC_CODE_1 0x83
|
||||
#define SYNC_CODE_2 0x42
|
||||
|
@ -9,12 +9,9 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
|
||||
#if defined(CONFIG_DEBUG) && CONFIG_DEBUG
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#include "./vpx_config.h"
|
||||
#include "vp9/common/vp9_treecoder.h"
|
||||
|
||||
static void tree2tok(struct vp9_token *const p, vp9_tree t,
|
||||
|
@ -8,6 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "vp9/common/vp9_common.h"
|
||||
#include "vp9/common/vp9_entropy.h"
|
||||
#include "vp9/common/vp9_entropymode.h"
|
||||
@ -24,11 +26,6 @@
|
||||
#include "vp9/decoder/vp9_dsubexp.h"
|
||||
#include "vp9/decoder/vp9_treereader.h"
|
||||
|
||||
|
||||
#if CONFIG_DEBUG
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
// #define DEBUG_DEC_MV
|
||||
#ifdef DEBUG_DEC_MV
|
||||
int dec_mvcount = 0;
|
||||
@ -748,9 +745,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
||||
&cm->fc.NMVcount, xd->allow_high_precision_mv);
|
||||
break;
|
||||
default:
|
||||
#if CONFIG_DEBUG
|
||||
assert(0);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1059,7 +1059,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
||||
|
||||
// Create the segmentation map structure and set to 0
|
||||
if (!pc->last_frame_seg_map)
|
||||
CHECK_MEM_ERROR(pc->last_frame_seg_map,
|
||||
CHECK_MEM_ERROR(pc, pc->last_frame_seg_map,
|
||||
vpx_calloc((pc->mi_rows * pc->mi_cols), 1));
|
||||
|
||||
vp9_setup_block_dptrs(xd, pc->subsampling_x, pc->subsampling_y);
|
||||
|
@ -41,22 +41,4 @@ typedef struct VP9Decompressor {
|
||||
int initial_height;
|
||||
} VP9D_COMP;
|
||||
|
||||
|
||||
#if CONFIG_DEBUG
|
||||
#define CHECK_MEM_ERROR(lval,expr) do {\
|
||||
lval = (expr); \
|
||||
if(!lval) \
|
||||
vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
|
||||
"Failed to allocate "#lval" at %s:%d", \
|
||||
__FILE__,__LINE__);\
|
||||
} while(0)
|
||||
#else
|
||||
#define CHECK_MEM_ERROR(lval,expr) do {\
|
||||
lval = (expr); \
|
||||
if(!lval) \
|
||||
vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
|
||||
"Failed to allocate "#lval);\
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#endif // VP9_DECODER_VP9_TREEREADER_H_
|
||||
|
@ -553,12 +553,10 @@ static void pack_mb_tokens(vp9_writer* const bc,
|
||||
*tp = p;
|
||||
}
|
||||
|
||||
static void write_sb_mv_ref(vp9_writer *bc, MB_PREDICTION_MODE m,
|
||||
static void write_sb_mv_ref(vp9_writer *w, MB_PREDICTION_MODE m,
|
||||
const vp9_prob *p) {
|
||||
#if CONFIG_DEBUG
|
||||
assert(NEARESTMV <= m && m <= NEWMV);
|
||||
#endif
|
||||
write_token(bc, vp9_sb_mv_ref_tree, p,
|
||||
write_token(w, vp9_sb_mv_ref_tree, p,
|
||||
vp9_sb_mv_ref_encoding_array - NEARESTMV + m);
|
||||
}
|
||||
|
||||
|
@ -129,8 +129,7 @@ static void calc_av_activity(VP9_COMP *cpi, int64_t activity_sum) {
|
||||
unsigned int tmp;
|
||||
|
||||
// Create a list to sort to
|
||||
CHECK_MEM_ERROR(sortlist,
|
||||
vpx_calloc(sizeof(unsigned int),
|
||||
CHECK_MEM_ERROR(&cpi->common, sortlist, vpx_calloc(sizeof(unsigned int),
|
||||
cpi->common.MBs));
|
||||
|
||||
// Copy map to sort list
|
||||
@ -323,21 +322,17 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
|
||||
MACROBLOCKD * const xd = &x->e_mbd;
|
||||
MODE_INFO *mi = &ctx->mic;
|
||||
MB_MODE_INFO * const mbmi = &xd->mode_info_context->mbmi;
|
||||
#if CONFIG_DEBUG || CONFIG_INTERNAL_STATS
|
||||
MB_PREDICTION_MODE mb_mode = mi->mbmi.mode;
|
||||
#endif
|
||||
int mb_mode_index = ctx->best_mode_index;
|
||||
const int mis = cpi->common.mode_info_stride;
|
||||
const int bh = 1 << mi_height_log2(bsize), bw = 1 << mi_width_log2(bsize);
|
||||
const MB_PREDICTION_MODE mb_mode = mi->mbmi.mode;
|
||||
|
||||
#if CONFIG_DEBUG
|
||||
assert(mb_mode < MB_MODE_COUNT);
|
||||
assert(mb_mode_index < MAX_MODES);
|
||||
assert(mi->mbmi.ref_frame[0] < MAX_REF_FRAMES);
|
||||
assert(mi->mbmi.ref_frame[1] < MAX_REF_FRAMES);
|
||||
#endif
|
||||
|
||||
assert(mi->mbmi.sb_type == bsize);
|
||||
|
||||
// Restore the coding context of the MB to that that was in place
|
||||
// when the mode was picked for it
|
||||
for (y = 0; y < bh; y++) {
|
||||
|
@ -324,8 +324,9 @@ static void separate_arf_mbs(VP9_COMP *cpi) {
|
||||
|
||||
int *arf_not_zz;
|
||||
|
||||
CHECK_MEM_ERROR(arf_not_zz,
|
||||
vpx_calloc(cm->mb_rows * cm->mb_cols * sizeof(*arf_not_zz), 1));
|
||||
CHECK_MEM_ERROR(cm, arf_not_zz,
|
||||
vpx_calloc(cm->mb_rows * cm->mb_cols * sizeof(*arf_not_zz),
|
||||
1));
|
||||
|
||||
// We are not interested in results beyond the alt ref itself.
|
||||
if (n_frames > cpi->frames_till_gf_update_due)
|
||||
|
@ -871,7 +871,7 @@ void vp9_alloc_compressor_data(VP9_COMP *cpi) {
|
||||
{
|
||||
unsigned int tokens = get_token_alloc(cm->mb_rows, cm->mb_cols);
|
||||
|
||||
CHECK_MEM_ERROR(cpi->tok, vpx_calloc(tokens, sizeof(*cpi->tok)));
|
||||
CHECK_MEM_ERROR(cm, cpi->tok, vpx_calloc(tokens, sizeof(*cpi->tok)));
|
||||
}
|
||||
|
||||
// Data used for real time vc mode to see if gf needs refreshing
|
||||
@ -880,12 +880,12 @@ void vp9_alloc_compressor_data(VP9_COMP *cpi) {
|
||||
cpi->gf_update_recommended = 0;
|
||||
|
||||
vpx_free(cpi->mb_activity_map);
|
||||
CHECK_MEM_ERROR(cpi->mb_activity_map,
|
||||
CHECK_MEM_ERROR(cm, cpi->mb_activity_map,
|
||||
vpx_calloc(sizeof(unsigned int),
|
||||
cm->mb_rows * cm->mb_cols));
|
||||
|
||||
vpx_free(cpi->mb_norm_activity_map);
|
||||
CHECK_MEM_ERROR(cpi->mb_norm_activity_map,
|
||||
CHECK_MEM_ERROR(cm, cpi->mb_norm_activity_map,
|
||||
vpx_calloc(sizeof(unsigned int),
|
||||
cm->mb_rows * cm->mb_cols));
|
||||
}
|
||||
@ -1293,15 +1293,16 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cpi->common.error.setjmp = 1;
|
||||
cm->error.setjmp = 1;
|
||||
|
||||
CHECK_MEM_ERROR(cpi->mb.ss, vpx_calloc(sizeof(search_site), (MAX_MVSEARCH_STEPS * 8) + 1));
|
||||
CHECK_MEM_ERROR(cm, cpi->mb.ss, vpx_calloc(sizeof(search_site),
|
||||
(MAX_MVSEARCH_STEPS * 8) + 1));
|
||||
|
||||
vp9_create_common(&cpi->common);
|
||||
vp9_create_common(cm);
|
||||
|
||||
init_config((VP9_PTR)cpi, oxcf);
|
||||
|
||||
cpi->common.current_video_frame = 0;
|
||||
cm->current_video_frame = 0;
|
||||
cpi->kf_overspend_bits = 0;
|
||||
cpi->kf_bitrate_adjustment = 0;
|
||||
cpi->frames_till_gf_update_due = 0;
|
||||
@ -1309,7 +1310,7 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
|
||||
cpi->non_gf_bitrate_adjustment = 0;
|
||||
|
||||
// Set reference frame sign bias for ALTREF frame to 1 (for now)
|
||||
cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 1;
|
||||
cm->ref_frame_sign_bias[ALTREF_FRAME] = 1;
|
||||
|
||||
cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL;
|
||||
|
||||
@ -1318,28 +1319,27 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
|
||||
cpi->gold_is_alt = 0;
|
||||
|
||||
// Create the encoder segmentation map and set all entries to 0
|
||||
CHECK_MEM_ERROR(cpi->segmentation_map,
|
||||
vpx_calloc(cpi->common.mi_rows * cpi->common.mi_cols, 1));
|
||||
CHECK_MEM_ERROR(cm, cpi->segmentation_map,
|
||||
vpx_calloc(cm->mi_rows * cm->mi_cols, 1));
|
||||
|
||||
// And a copy in common for temporal coding
|
||||
CHECK_MEM_ERROR(cm->last_frame_seg_map,
|
||||
vpx_calloc(cpi->common.mi_rows * cpi->common.mi_cols, 1));
|
||||
CHECK_MEM_ERROR(cm, cm->last_frame_seg_map,
|
||||
vpx_calloc(cm->mi_rows * cm->mi_cols, 1));
|
||||
|
||||
// And a place holder structure is the coding context
|
||||
// for use if we want to save and restore it
|
||||
CHECK_MEM_ERROR(cpi->coding_context.last_frame_seg_map_copy,
|
||||
vpx_calloc(cpi->common.mi_rows * cpi->common.mi_cols, 1));
|
||||
CHECK_MEM_ERROR(cm, cpi->coding_context.last_frame_seg_map_copy,
|
||||
vpx_calloc(cm->mi_rows * cm->mi_cols, 1));
|
||||
|
||||
CHECK_MEM_ERROR(cpi->active_map, vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols, 1));
|
||||
vpx_memset(cpi->active_map, 1, (cpi->common.mb_rows * cpi->common.mb_cols));
|
||||
CHECK_MEM_ERROR(cm, cpi->active_map, vpx_calloc(cm->MBs, 1));
|
||||
vpx_memset(cpi->active_map, 1, cm->MBs);
|
||||
cpi->active_map_enabled = 0;
|
||||
|
||||
for (i = 0; i < (sizeof(cpi->mbgraph_stats) /
|
||||
sizeof(cpi->mbgraph_stats[0])); i++) {
|
||||
CHECK_MEM_ERROR(cpi->mbgraph_stats[i].mb_stats,
|
||||
vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols *
|
||||
sizeof(*cpi->mbgraph_stats[i].mb_stats),
|
||||
1));
|
||||
CHECK_MEM_ERROR(cm, cpi->mbgraph_stats[i].mb_stats,
|
||||
vpx_calloc(cm->MBs *
|
||||
sizeof(*cpi->mbgraph_stats[i].mb_stats), 1));
|
||||
}
|
||||
|
||||
#ifdef ENTROPY_STATS
|
||||
@ -2421,8 +2421,7 @@ static void full_to_model_counts(
|
||||
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
|
||||
if (l >= 3 && k == 0)
|
||||
continue;
|
||||
full_to_model_count(model_count[i][j][k][l],
|
||||
full_count[i][j][k][l]);
|
||||
full_to_model_count(model_count[i][j][k][l], full_count[i][j][k][l]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -634,21 +634,4 @@ extern int vp9_calc_ss_err(YV12_BUFFER_CONFIG *source,
|
||||
|
||||
extern void vp9_alloc_compressor_data(VP9_COMP *cpi);
|
||||
|
||||
#if CONFIG_DEBUG
|
||||
#define CHECK_MEM_ERROR(lval,expr) do {\
|
||||
lval = (expr); \
|
||||
if(!lval) \
|
||||
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\
|
||||
"Failed to allocate "#lval" at %s:%d", \
|
||||
__FILE__,__LINE__);\
|
||||
} while(0)
|
||||
#else
|
||||
#define CHECK_MEM_ERROR(lval,expr) do {\
|
||||
lval = (expr); \
|
||||
if(!lval) \
|
||||
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\
|
||||
"Failed to allocate "#lval);\
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#endif // VP9_ENCODER_VP9_ONYX_INT_H_
|
||||
|
Loading…
Reference in New Issue
Block a user