From: Kitae Kim Date: Fri, 28 Dec 2012 10:55:34 +0000 (+0900) Subject: marucodec: Fixed a memory leak while decoding video. X-Git-Tag: TizenStudio_2.0_p2.3~1106 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ba338d71bae9b90f5dbade9dd0e4f5eeaaeec50;p=sdk%2Femulator%2Fqemu.git marucodec: Fixed a memory leak while decoding video. The pointer variable that refers to allocated memory address used incorrectly. That is why the memory leak happed during decoding video. Signed-off-by: Kitae Kim --- diff --git a/tizen/src/hw/maru_codec.c b/tizen/src/hw/maru_codec.c index 7c0daed..39524aa 100644 --- a/tizen/src/hw/maru_codec.c +++ b/tizen/src/hw/maru_codec.c @@ -401,7 +401,7 @@ static void qemu_init_pix_fmt_info(void) pix_fmt_info[PIX_FMT_YUV411P].y_chroma_shift = 0; } -static int qemu_avpicture_fill(AVPicture *picture, uint8_t *ptr, +static int qemu_avpicture_fill(AVPicture *picture, uint8_t **ptr, int pix_fmt, int width, int height) { int size, w2, h2, size2; @@ -425,16 +425,15 @@ static int qemu_avpicture_fill(AVPicture *picture, uint8_t *ptr, h2 = DIV_ROUND_UP_X(height, pinfo->y_chroma_shift); size2 = stride2 * h2; fsize = size + 2 * size2; - TRACE("stride: %d, stride2: %d, size: %d, size2: %d, fsize: %d\n", stride, stride2, size, size2, fsize); - ptr = av_mallocz(fsize); + *ptr = av_mallocz(fsize); if (!ptr) { ERR("failed to allocate memory.\n"); return -1; } - picture->data[0] = ptr; + picture->data[0] = *ptr; picture->data[1] = picture->data[0] + size; picture->data[2] = picture->data[1] + size2; picture->data[3] = NULL; @@ -1052,6 +1051,7 @@ int qemu_avcodec_decode_audio(SVCodecState *s, int ctx_index) TRACE("before free input buffer and output buffer!\n"); if (samples) { + TRACE("release allocated audio buffer.\n"); av_free(samples); samples = NULL; } @@ -1098,7 +1098,7 @@ void qemu_av_picture_copy(SVCodecState *s, int ctx_index) offset = s->codec_param.mmap_offset; - numBytes = qemu_avpicture_fill(&dst, buffer, avctx->pix_fmt, + numBytes = qemu_avpicture_fill(&dst, &buffer, avctx->pix_fmt, avctx->width, avctx->height); TRACE("after avpicture_fill: %d\n", numBytes); if (numBytes < 0) { @@ -1112,6 +1112,7 @@ void qemu_av_picture_copy(SVCodecState *s, int ctx_index) TRACE("after copy image buffer from host to guest.\n"); if (buffer) { + TRACE("release allocated picture.\n"); av_free(buffer); }