/*! * \param *dc The DecodingContext containing macroblock array we want to freed. * * This function free **mb_array, which is an array of pointers to macroblock elements. * mb_array is in a DecodingContext structure. There can only be one mb_array at a time. * Please note that in order to avoid memory leak, this function begin by calling freeMbArrayContent(). */ void freeMbArray(DecodingContext_t *dc) { if (dc->mb_array != NULL) { freeMbArrayContent(dc); free(dc->mb_array); dc->mb_array = NULL; TRACE_1(MB, ">> mb_array freed\n"); } }
/*! * \param *dc The current DecodingContext. * \return 0 if slice allocation fail, 1 otherwise. */ int decode_slice(DecodingContext_t *dc) { TRACE_INFO(SLICE, "> " BLD_GREEN "decodeSlice()\n" CLR_RESET); int retcode = SUCCESS; // New slice allocation dc->active_slice = (slice_t*)calloc(1, sizeof(slice_t)); if (dc->active_slice == NULL) { TRACE_ERROR(SLICE, "Unable to alloc new Slice!\n"); retcode = FAILURE; } else { // First, check for valid SPS and PPS retcode = checkDecodingContext(dc); // Slice header if (retcode == SUCCESS) { retcode = decodeSliceHeader(dc, dc->active_slice); printSliceHeader(dc); } // Slice datas if (retcode == SUCCESS) { retcode = decodeSliceData(dc, dc->active_slice); } // Export IDR slice if (retcode == SUCCESS && dc->IdrPicFlag == true) { retcode = export_idr(dc); } // Free macroblocks in **mb_array freeMbArrayContent(dc); // Free slice free_slice(&dc->active_slice); } return retcode; }