From 6d81a5c7dc998a914c482bd8aef0d6b2ffd3aa09 Mon Sep 17 00:00:00 2001 From: Amai Prashanth Kumar Date: Tue, 12 Sep 2017 12:59:15 +0000 Subject: [PATCH] viddec3test: dce_buf_lock & unlock of OutBuf_fd Earlier the dce_buf_lock and dce_buf_unlock for OutBuf_fd was done based on eof flag. Resulting memory leak during long run. This patch handles the buffer locking & unlocking properly. Along with code cleanup. Signed-off-by: Amai Prashanth Kumar Signed-off-by: Karthik Ramanan --- viddec3test.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/viddec3test.c b/viddec3test.c index c9d6854..3788d6e 100644 --- a/viddec3test.c +++ b/viddec3test.c @@ -350,6 +350,22 @@ decoder_process(struct decoder *decoder) return -1; } decoder->lastOutBuf = buf; + + inArgs->inputID = (XDAS_Int32)buf; + outBufs->descs[0].buf = buf->fd[0]; + outBufs->descs[1].buf = (buf->multiplanar) ?buf->fd[1]:(XDAS_Int8 *)((outBufs->descs[0].buf)); + + if(buf->multiplanar){ + decoder->outBuf_fd[0] = buf->fd[0]; + decoder->outBuf_fd[1] = buf->fd[1]; + dce_buf_lock(2,decoder->outBuf_fd); + } + else{ + decoder->outBuf_fd[0] = buf->fd[0]; + dce_buf_lock(1,decoder->outBuf_fd); + } + decoder->outBufs->descs[0].bufSize.bytes =decoder->padded_width*decoder->padded_height; + decoder->outBufs->descs[1].bufSize.bytes = decoder->padded_width* (decoder->padded_height/2); } else{ /*For second field decoding, send last output buffer @@ -387,26 +403,6 @@ decoder_process(struct decoder *decoder) break; } - /*set the parameters if it is not the end of file */ - if (!eof) { - inArgs->inputID = (XDAS_Int32)buf; - outBufs->descs[0].buf = buf->fd[0]; - outBufs->descs[1].buf = (buf->multiplanar) ?buf->fd[1]:(XDAS_Int8 *)((outBufs->descs[0].buf)); - - if(decoder->outBufsInUseFlag == XDAS_FALSE){ - if(buf->multiplanar){ - decoder->outBuf_fd[0] = buf->fd[0]; - decoder->outBuf_fd[1] = buf->fd[1]; - dce_buf_lock(2,decoder->outBuf_fd); - } - else{ - decoder->outBuf_fd[0] = buf->fd[0]; - dce_buf_lock(1,decoder->outBuf_fd); - } - decoder->outBufs->descs[0].bufSize.bytes =decoder->padded_width*decoder->padded_height; - decoder->outBufs->descs[1].bufSize.bytes = decoder->padded_width* (decoder->padded_height/2); - } - } do { if (no_process) { @@ -463,7 +459,7 @@ decoder_process(struct decoder *decoder) } if(freeBufCount){ - if(!eof)dce_buf_unlock(freeBufCount,decoder->outBuf_fd); + dce_buf_unlock(freeBufCount,decoder->outBuf_fd); freeBufCount =0; } -- 2.26.2