viddec3test:Handling outBufsInUseFlag for interlaced contents
authorPrasad, Ram <x0038811@ti.com>
Thu, 7 Sep 2017 15:25:14 +0000 (15:25 +0000)
committerKarthik Ramanan <a0393906@ti.com>
Thu, 7 Sep 2017 10:39:58 +0000 (16:09 +0530)
When outBufsInUseFlag is set in case of  interlaced
streams, for second field decoding, new output buffer
should not be sent but the buffer which was sent for first
field decoding needs to be sent.
Thsi patch takes care of this issue.

Signed-off-by: Ramprasad N <x0038811@ti.com>
viddec3test.c

index a187c40e071602f4ef61344d15f475327c9acfb1..dc50391a1d8432e54af66bdf6a90dc9991dbe964 100644 (file)
@@ -60,6 +60,8 @@ struct decoder {
        size_t *outBuf_fd;
        suseconds_t tdisp;
        int id;
+       struct buffer *lastOutBuf;
+       int outBufsInUseFlag;
 };
 
 
@@ -309,6 +311,8 @@ decoder_open(int argc, char **argv)
        decoder->outArgs = dce_alloc(sizeof(IVIDDEC3_OutArgs));
        decoder->outArgs->size = sizeof(IVIDDEC3_OutArgs);
 
+       decoder->outBufsInUseFlag = XDAS_FALSE;
+
        decoder->tdisp = mark(NULL);
 
        return decoder;
@@ -339,10 +343,21 @@ decoder_process(struct decoder *decoder)
        for (i = 0; i < 2; i++) {
                n = demux_read(decoder->demux, decoder->input, decoder->input_sz);
                if (n) {
-                       buf = disp_get_vid_buffer(decoder->disp);
-                       if (!buf) {
-                               ERROR("%p: fail: out of buffers", decoder);
-                               return -1;
+                       if(decoder->outBufsInUseFlag == XDAS_FALSE){
+                               buf = disp_get_vid_buffer(decoder->disp);
+                               if (!buf) {
+                                       ERROR("%p: fail: out of buffers", decoder);
+                                       return -1;
+                               }
+                               decoder->lastOutBuf = buf;
+                       }
+                       else{
+                               /*For second field decoding, send last output buffer
+                                 decoder uses buffer which was sent for first field
+                                 decoding. No need to pass the buffer. This decision is
+                                 taken based on outArgs->outBufsInUseFlag
+                                */
+                               buf = decoder->lastOutBuf;
                        }
                        inBufs->descs[0].bufSize.bytes = n;
                        inArgs->numBytes = n;
@@ -378,18 +393,19 @@ decoder_process(struct decoder *decoder)
                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);
+               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);
                }
-               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 {
@@ -450,9 +466,9 @@ decoder_process(struct decoder *decoder)
             if(!eof)dce_buf_unlock(freeBufCount,decoder->outBuf_fd);
                        freeBufCount =0;
                }
-               if (outArgs->outBufsInUseFlag) {
-                       MSG("%p: TODO... outBufsInUseFlag", decoder); // XXX
-               }
+
+               decoder->outBufsInUseFlag = outArgs->outBufsInUseFlag;
+
        } while ((err == 0) && eof && !no_process);
 
        return (inBufs->numBufs > 0) ? 0 : -1;