/** * \brief Free memory allocated to frame * \param pic picture pointer * \return 1 on success, 0 on failure */ int kvz_videoframe_free(videoframe_t * const frame) { kvz_image_free(frame->source); frame->source = NULL; kvz_image_free(frame->rec); frame->rec = NULL; kvz_cu_array_free(&frame->cu_array); FREE_POINTER(frame->sao_luma); FREE_POINTER(frame->sao_chroma); free(frame); return 1; }
/** * \brief Remove picture from picturelist * \param list list to use * \param n index to remove * \return 1 on success */ int kvz_image_list_rem(image_list_t * const list, const unsigned n) { // Must be within list boundaries if (n >= list->used_size) { return 0; } kvz_image_free(list->images[n]); if (!kvz_cu_array_free(list->cu_arrays[n])) { fprintf(stderr, "Could not free cu_array!\n"); assert(0); //Stop here return 0; } // The last item is easy to remove if (n == list->used_size - 1) { list->images[n] = NULL; list->cu_arrays[n] = NULL; list->pocs[n] = 0; list->used_size--; } else { int i = n; // Shift all following pics one backward in the list for (i = n; i < list->used_size - 1; ++i) { list->images[i] = list->images[i + 1]; list->cu_arrays[i] = list->cu_arrays[i + 1]; list->pocs[i] = list->pocs[i + 1]; } list->images[list->used_size - 1] = NULL; list->cu_arrays[list->used_size - 1] = NULL; list->pocs[list->used_size - 1] = 0; list->used_size--; } return 1; }
/** * \brief Free memory allocated to the picture_list * \param list image_list pointer * \return 1 on success, 0 on failure */ int kvz_image_list_destroy(image_list_t *list) { unsigned int i; if (list->used_size > 0) { for (i = 0; i < list->used_size; ++i) { kvz_image_free(list->images[i]); list->images[i] = NULL; kvz_cu_array_free(list->cu_arrays[i]); list->cu_arrays[i] = NULL; list->pocs[i] = 0; } } if (list->size > 0) { free(list->images); free(list->cu_arrays); free(list->pocs); } list->images = NULL; list->cu_arrays = NULL; list->pocs = NULL; free(list); return 1; }