viddec3test: dce_buf_lock & unlock of OutBuf_fd
authorAmai Prashanth Kumar <x0270680@ti.com>
Tue, 12 Sep 2017 12:59:15 +0000 (12:59 +0000)
committerKarthik Ramanan <a0393906@ti.com>
Thu, 14 Sep 2017 06:09:14 +0000 (11:39 +0530)
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 <x0270680@ti.com>
Signed-off-by: Karthik Ramanan <a0393906@ti.com>
viddec3test.c

index c9d685491aaa224e41e97b2dce33fcd743962dd8..3788d6eef8553ba0210a0c5d39b58393d1f6b275 100644 (file)
@@ -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;
                }