From: Kitae Kim Date: Wed, 2 Jan 2013 04:51:25 +0000 (+0900) Subject: maurcodec: Fixed the way to encode video. X-Git-Tag: TizenStudio_2.0_p2.3~1089 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e88fe368742b5d72ae4783f7792d3c3b7c9b8d8;p=sdk%2Femulator%2Fqemu.git maurcodec: Fixed the way to encode video. As the memory leak issue is fixed, encoding function has been modified. However, the modification for encoding function was wrong. In case of encoding video, it does not need to allocate memory for an input buffer. Signed-off-by: Kitae Kim --- diff --git a/tizen/src/hw/maru_codec.c b/tizen/src/hw/maru_codec.c index 41e8972..b9595e7 100644 --- a/tizen/src/hw/maru_codec.c +++ b/tizen/src/hw/maru_codec.c @@ -402,7 +402,8 @@ static void qemu_init_pix_fmt_info(void) } static int qemu_avpicture_fill(AVPicture *picture, uint8_t **ptr, - int pix_fmt, int width, int height) + int pix_fmt, int width, + int height, bool encode) { int size, w2, h2, size2; int stride, stride2; @@ -427,11 +428,12 @@ static int qemu_avpicture_fill(AVPicture *picture, uint8_t **ptr, 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); - if (!ptr) { - ERR("failed to allocate memory.\n"); - return -1; + if (!encode) { + *ptr = av_mallocz(fsize); + if (!ptr) { + ERR("failed to allocate memory.\n"); + return -1; + } } picture->data[0] = *ptr; picture->data[1] = picture->data[0] + size; @@ -924,8 +926,8 @@ int qemu_avcodec_encode_video(SVCodecState *s, int ctx_index) avctx->width, avctx->height); #endif - ret = qemu_avpicture_fill((AVPicture *)pict, inputBuf, avctx->pix_fmt, - avctx->width, avctx->height); + ret = qemu_avpicture_fill((AVPicture *)pict, &inputBuf, avctx->pix_fmt, + avctx->width, avctx->height, true); if (ret < 0) { ERR("after avpicture_fill, ret:%d\n", ret); @@ -1099,7 +1101,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, - avctx->width, avctx->height); + avctx->width, avctx->height, false); TRACE("after avpicture_fill: %d\n", numBytes); if (numBytes < 0) { ERR("picture size:%d is wrong.\n", numBytes);