rename picture_init to picture alloc and picture_destroy to picture_free

This commit is contained in:
Laurent Fasnacht 2014-05-02 10:58:28 +02:00
parent b76f7377b6
commit 92e14cc80d
3 changed files with 15 additions and 13 deletions

View file

@ -359,7 +359,7 @@ static int encoder_state_init_one(encoder_state * const state, const encoder_sta
state->frame = 0; state->frame = 0;
state->poc = 0; state->poc = 0;
state->cur_pic = picture_init(width, height, width_in_lcu, height_in_lcu); state->cur_pic = picture_alloc(width, height, width_in_lcu, height_in_lcu);
if (!state->cur_pic) { if (!state->cur_pic) {
printf("Error allocating picture!\r\n"); printf("Error allocating picture!\r\n");
@ -415,8 +415,8 @@ int encoder_state_init(encoder_state * const encoder_state, const encoder_contro
} }
static int encoder_state_finalize_one(encoder_state * const encoder_state) { static int encoder_state_finalize_one(encoder_state * const encoder_state) {
picture_destroy(encoder_state->cur_pic); picture_free(encoder_state->cur_pic);
FREE_POINTER(encoder_state->cur_pic); encoder_state->cur_pic = NULL;
bitstream_finalize(&encoder_state->stream); bitstream_finalize(&encoder_state->stream);
return 1; return 1;
@ -1389,7 +1389,7 @@ void encoder_next_frame(encoder_state *encoder_state) {
picture_list_add(encoder_state->ref, encoder_state->cur_pic); picture_list_add(encoder_state->ref, encoder_state->cur_pic);
// Allocate new memory to current picture // Allocate new memory to current picture
// TODO: reuse memory from old reference // TODO: reuse memory from old reference
encoder_state->cur_pic = picture_init(encoder_state->cur_pic->width, encoder_state->cur_pic->height, encoder_state->cur_pic->width_in_lcu, encoder_state->cur_pic->height_in_lcu); encoder_state->cur_pic = picture_alloc(encoder_state->cur_pic->width, encoder_state->cur_pic->height, encoder_state->cur_pic->width_in_lcu, encoder_state->cur_pic->height_in_lcu);
// Copy pointer from the last cur_pic because we don't want to reallocate it // Copy pointer from the last cur_pic because we don't want to reallocate it
MOVE_POINTER(encoder_state->cur_pic->coeff_y,encoder_state->ref->pics[0]->coeff_y); MOVE_POINTER(encoder_state->cur_pic->coeff_y,encoder_state->ref->pics[0]->coeff_y);

View file

@ -172,8 +172,8 @@ int picture_list_destroy(picture_list *list)
unsigned int i; unsigned int i;
if (list->used_size > 0) { if (list->used_size > 0) {
for (i = 0; i < list->used_size; ++i) { for (i = 0; i < list->used_size; ++i) {
picture_destroy(list->pics[i]); picture_free(list->pics[i]);
FREE_POINTER(list->pics[i]); list->pics[i] = NULL;
} }
} }
@ -221,8 +221,8 @@ int picture_list_rem(picture_list *list, unsigned n, int8_t destroy)
} }
if (destroy) { if (destroy) {
picture_destroy(list->pics[n]); picture_free(list->pics[n]);
FREE_POINTER(list->pics[n]); list->pics[n] = NULL;
} }
// The last item is easy to remove // The last item is easy to remove
@ -246,8 +246,8 @@ int picture_list_rem(picture_list *list, unsigned n, int8_t destroy)
* \param pic picture pointer * \param pic picture pointer
* \return picture pointer * \return picture pointer
*/ */
picture *picture_init(int32_t width, int32_t height, picture *picture_alloc(const int32_t width, const int32_t height,
int32_t width_in_lcu, int32_t height_in_lcu) const int32_t width_in_lcu, const int32_t height_in_lcu)
{ {
picture *pic = (picture *)malloc(sizeof(picture)); picture *pic = (picture *)malloc(sizeof(picture));
unsigned int luma_size = width * height; unsigned int luma_size = width * height;
@ -306,7 +306,7 @@ picture *picture_init(int32_t width, int32_t height,
* \param pic picture pointer * \param pic picture pointer
* \return 1 on success, 0 on failure * \return 1 on success, 0 on failure
*/ */
int picture_destroy(picture *pic) int picture_free(picture * const pic)
{ {
free(pic->u_data); free(pic->u_data);
free(pic->v_data); free(pic->v_data);
@ -333,6 +333,8 @@ int picture_destroy(picture *pic)
FREE_POINTER(pic->sao_luma); FREE_POINTER(pic->sao_luma);
FREE_POINTER(pic->sao_chroma); FREE_POINTER(pic->sao_chroma);
free(pic);
return 1; return 1;
} }

View file

@ -213,9 +213,9 @@ typedef struct {
yuv_t * alloc_yuv_t(int luma_size); yuv_t * alloc_yuv_t(int luma_size);
void dealloc_yuv_t(yuv_t * yuv); void dealloc_yuv_t(yuv_t * yuv);
picture * picture_init(int32_t width, int32_t height, picture * picture_alloc(int32_t width, int32_t height,
int32_t width_in_lcu, int32_t height_in_lcu); int32_t width_in_lcu, int32_t height_in_lcu);
int picture_destroy(picture *pic); int picture_free(picture *pic);
void picture_blit_pixels(const pixel* orig, pixel *dst, void picture_blit_pixels(const pixel* orig, pixel *dst,
unsigned width, unsigned height, unsigned width, unsigned height,