Commit 0030303b authored by James Zern's avatar James Zern

Remove redundant ptr checks in calls to vpx_free

vpx_free if used contains this check. If replaced, well behaved free
will behave similarly.

Change-Id: I25483aaa8b39255b9a8cf388d6e5eaa20a908ae1
parent 7725a7eb
......@@ -473,22 +473,16 @@ void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows)
if (pbi->b_multithreaded_rd)
{
if (pbi->mt_current_mb_col)
{
vpx_free(pbi->mt_current_mb_col);
pbi->mt_current_mb_col = NULL ;
}
/* Free above_row buffers. */
if (pbi->mt_yabove_row)
{
for (i=0; i< mb_rows; i++)
{
if (pbi->mt_yabove_row[i])
{
vpx_free(pbi->mt_yabove_row[i]);
pbi->mt_yabove_row[i] = NULL ;
}
}
vpx_free(pbi->mt_yabove_row);
pbi->mt_yabove_row = NULL ;
......@@ -498,11 +492,8 @@ void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows)
{
for (i=0; i< mb_rows; i++)
{
if (pbi->mt_uabove_row[i])
{
vpx_free(pbi->mt_uabove_row[i]);
pbi->mt_uabove_row[i] = NULL ;
}
}
vpx_free(pbi->mt_uabove_row);
pbi->mt_uabove_row = NULL ;
......@@ -512,11 +503,8 @@ void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows)
{
for (i=0; i< mb_rows; i++)
{
if (pbi->mt_vabove_row[i])
{
vpx_free(pbi->mt_vabove_row[i]);
pbi->mt_vabove_row[i] = NULL ;
}
}
vpx_free(pbi->mt_vabove_row);
pbi->mt_vabove_row = NULL ;
......@@ -527,11 +515,8 @@ void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows)
{
for (i=0; i< mb_rows; i++)
{
if (pbi->mt_yleft_col[i])
{
vpx_free(pbi->mt_yleft_col[i]);
pbi->mt_yleft_col[i] = NULL ;
}
}
vpx_free(pbi->mt_yleft_col);
pbi->mt_yleft_col = NULL ;
......@@ -541,11 +526,8 @@ void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows)
{
for (i=0; i< mb_rows; i++)
{
if (pbi->mt_uleft_col[i])
{
vpx_free(pbi->mt_uleft_col[i]);
pbi->mt_uleft_col[i] = NULL ;
}
}
vpx_free(pbi->mt_uleft_col);
pbi->mt_uleft_col = NULL ;
......@@ -555,11 +537,8 @@ void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows)
{
for (i=0; i< mb_rows; i++)
{
if (pbi->mt_vleft_col[i])
{
vpx_free(pbi->mt_vleft_col[i]);
pbi->mt_vleft_col[i] = NULL ;
}
}
vpx_free(pbi->mt_vleft_col);
pbi->mt_vleft_col = NULL ;
......@@ -644,29 +623,17 @@ void vp8_decoder_remove_threads(VP8D_COMP *pbi)
sem_destroy(&pbi->h_event_end_decoding);
if (pbi->h_decoding_thread)
{
vpx_free(pbi->h_decoding_thread);
pbi->h_decoding_thread = NULL;
}
if (pbi->h_event_start_decoding)
{
vpx_free(pbi->h_event_start_decoding);
pbi->h_event_start_decoding = NULL;
}
if (pbi->mb_row_di)
{
vpx_free(pbi->mb_row_di);
pbi->mb_row_di = NULL ;
}
if (pbi->de_thread_data)
{
vpx_free(pbi->de_thread_data);
pbi->de_thread_data = NULL;
}
}
}
......
......@@ -262,39 +262,32 @@ static void setup_features(VP8_COMP *cpi)
void vp8_dealloc_compressor_data(VP8_COMP *cpi)
{
if(cpi->tplist!=0)
vpx_free(cpi->tplist);
cpi->tplist = NULL;
// Delete last frame MV storage buffers
if (cpi->lfmv != 0)
vpx_free(cpi->lfmv);
cpi->lfmv = 0;
if (cpi->lf_ref_frame_sign_bias != 0)
vpx_free(cpi->lf_ref_frame_sign_bias);
cpi->lf_ref_frame_sign_bias = 0;
if (cpi->lf_ref_frame != 0)
vpx_free(cpi->lf_ref_frame);
cpi->lf_ref_frame = 0;
// Delete sementation map
if (cpi->segmentation_map != 0)
vpx_free(cpi->segmentation_map);
cpi->segmentation_map = 0;
if (cpi->active_map != 0)
vpx_free(cpi->active_map);
cpi->active_map = 0;
// Delete first pass motion map
if (cpi->fp_motion_map != 0)
vpx_free(cpi->fp_motion_map);
cpi->fp_motion_map = 0;
......@@ -319,23 +312,19 @@ void vp8_dealloc_compressor_data(VP8_COMP *cpi)
cpi->tok = 0;
// Structure used to monitor GF usage
if (cpi->gf_active_flags != 0)
vpx_free(cpi->gf_active_flags);
cpi->gf_active_flags = 0;
if(cpi->mb.pip)
vpx_free(cpi->mb.pip);
cpi->mb.pip = 0;
#if !(CONFIG_REALTIME_ONLY)
if(cpi->total_stats)
vpx_free(cpi->total_stats);
cpi->total_stats = 0;
if(cpi->this_frame_stats)
vpx_free(cpi->this_frame_stats);
cpi->this_frame_stats = 0;
......@@ -442,7 +431,6 @@ static void segmentation_test_function(VP8_PTR ptr)
set_segment_data(ptr, &feature_data[0][0], SEGMENT_DELTADATA);
// Delete sementation map
if (seg_map != 0)
vpx_free(seg_map);
seg_map = 0;
......@@ -536,7 +524,6 @@ static void cyclic_background_refresh(VP8_COMP *cpi, int Q, int lf_adjustment)
set_segment_data((VP8_PTR)cpi, &feature_data[0][0], SEGMENT_DELTADATA);
// Delete sementation map
if (seg_map != 0)
vpx_free(seg_map);
seg_map = 0;
......@@ -1310,7 +1297,6 @@ static void alloc_raw_frame_buffers(VP8_COMP *cpi)
static int vp8_alloc_partition_data(VP8_COMP *cpi)
{
if(cpi->mb.pip)
vpx_free(cpi->mb.pip);
cpi->mb.pip = vpx_calloc((cpi->common.mb_cols + 1) *
......@@ -1357,7 +1343,6 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
"Failed to allocate scaled source buffer");
if (cpi->tok != 0)
vpx_free(cpi->tok);
{
......@@ -1373,7 +1358,6 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
// Structures used to minitor GF usage
if (cpi->gf_active_flags != 0)
vpx_free(cpi->gf_active_flags);
CHECK_MEM_ERROR(cpi->gf_active_flags, vpx_calloc(1, cm->mb_rows * cm->mb_cols));
......@@ -1381,12 +1365,10 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
#if !(CONFIG_REALTIME_ONLY)
if(cpi->total_stats)
vpx_free(cpi->total_stats);
cpi->total_stats = vpx_calloc(1, vp8_firstpass_stats_sz(cpi->common.MBs));
if(cpi->this_frame_stats)
vpx_free(cpi->this_frame_stats);
cpi->this_frame_stats = vpx_calloc(1, vp8_firstpass_stats_sz(cpi->common.MBs));
......@@ -1407,7 +1389,6 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
cpi->mt_sync_range = 16;
#endif
if(cpi->tplist);
vpx_free(cpi->tplist);
CHECK_MEM_ERROR(cpi->tplist, vpx_malloc(sizeof(TOKENLIST) * cpi->common.mb_rows));
......
......@@ -39,10 +39,7 @@ vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf)
{
if (ybf)
{
if (ybf->buffer_alloc)
{
duck_free(ybf->buffer_alloc);
}
ybf->buffer_alloc = 0;
}
......
......@@ -271,17 +271,17 @@ void bicubic_coefficient_destroy()
{
if (!g_first_time)
{
if (g_b_scaler.l_w) vpx_free(g_b_scaler.l_w);
vpx_free(g_b_scaler.l_w);
if (g_b_scaler.l_h) vpx_free(g_b_scaler.l_h);
vpx_free(g_b_scaler.l_h);
if (g_b_scaler.l_h_uv) vpx_free(g_b_scaler.l_h_uv);
vpx_free(g_b_scaler.l_h_uv);
if (g_b_scaler.c_w) vpx_free(g_b_scaler.c_w);
vpx_free(g_b_scaler.c_w);
if (g_b_scaler.c_h) vpx_free(g_b_scaler.c_h);
vpx_free(g_b_scaler.c_h);
if (g_b_scaler.c_h_uv) vpx_free(g_b_scaler.c_h_uv);
vpx_free(g_b_scaler.c_h_uv);
vpx_memset(&g_b_scaler, 0, sizeof(BICUBIC_SCALER_STRUCT));
}
......@@ -342,21 +342,21 @@ int bicubic_coefficient_setup(int in_width, int in_height, int out_width, int ou
d_h_uv = (in_height / 2) / gcd_h_uv;
// allocate memory for the coefficents
if (g_b_scaler.l_w) vpx_free(g_b_scaler.l_w);
vpx_free(g_b_scaler.l_w);
if (g_b_scaler.l_h) vpx_free(g_b_scaler.l_h);
vpx_free(g_b_scaler.l_h);
if (g_b_scaler.l_h_uv) vpx_free(g_b_scaler.l_h_uv);
vpx_free(g_b_scaler.l_h_uv);
g_b_scaler.l_w = (short *)vpx_memalign(32, out_width * 2);
g_b_scaler.l_h = (short *)vpx_memalign(32, out_height * 2);
g_b_scaler.l_h_uv = (short *)vpx_memalign(32, out_height * 2);
if (g_b_scaler.c_w) vpx_free(g_b_scaler.c_w);
vpx_free(g_b_scaler.c_w);
if (g_b_scaler.c_h) vpx_free(g_b_scaler.c_h);
vpx_free(g_b_scaler.c_h);
if (g_b_scaler.c_h_uv) vpx_free(g_b_scaler.c_h_uv);
vpx_free(g_b_scaler.c_h_uv);
g_b_scaler.c_w = (short *)vpx_memalign(32, g_b_scaler.nw * 4 * 2);
g_b_scaler.c_h = (short *)vpx_memalign(32, g_b_scaler.nh * 4 * 2);
......
......@@ -24,10 +24,7 @@ vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf)
{
if (ybf)
{
if (ybf->buffer_alloc)
{
duck_free(ybf->buffer_alloc);
}
ybf->buffer_alloc = 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment