summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 759208e)
raw | patch | inline | side by side (parent: 759208e)
author | Amarinder Bindra <a-bindra@ti.com> | |
Tue, 1 Oct 2013 10:54:24 +0000 (16:24 +0530) | ||
committer | Amarinder Bindra <a-bindra@ti.com> | |
Thu, 3 Oct 2013 14:01:11 +0000 (19:31 +0530) |
When the end of file is encountered, the buffers need to be unlocked
and freed by adding the flush mechanism via the codec.
This adds the mechanism and removes the code where the fd were unlocked
during the decoder close.
Signed-off-by: Amarinder Bindra <a-bindra@ti.com>
and freed by adding the flush mechanism via the codec.
This adds the mechanism and removes the code where the fd were unlocked
during the decoder close.
Signed-off-by: Amarinder Bindra <a-bindra@ti.com>
viddec3test.c | patch | blob | history |
diff --git a/viddec3test.c b/viddec3test.c
index ed93d0b21c741dc1d56f90ab745b587b1f2af236..b5f796f141eb5fb2e3b4c5bd1e691e9271bcf985 100644 (file)
--- a/viddec3test.c
+++ b/viddec3test.c
static void
decoder_close(struct decoder *decoder)
{
- int i;
- /* fix me: all the output buffers are not unlocked in process.So calling unlock
- * for all the buffers */
- for(i=0;i<decoder->num_outBuf;i++){
- dce_buf_unlock(1,&decoder->disp->buf[i]->fd[0]);
- if(decoder->disp->multiplanar)
- dce_buf_unlock(1,&decoder->disp->buf[i]->fd[1]);
- }
/* free output buffers allocated by display */
disp_free_buffers(decoder->disp,decoder->num_outBuf);
struct buffer *buf;
int freeBufCount =0;
int i, n;
+ XDAS_Int32 err;
+ int eof = 0; /* end of file flag */
buf = disp_get_vid_buffer(decoder->disp);
if (!buf) {
MSG("%p: rewound.", decoder);
continue;
}
+ eof = 1; /* set the flag for end of file to 1 */
+ /* Control call call with XDM_FLUSH command */
+ err = VIDDEC3_control(decoder->codec, XDM_FLUSH,
+ decoder->dynParams, decoder->status);
inBufs->numBufs = 0;
inArgs->inputID = 0;
- inArgs->numBytes =0;
-
}
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));
- 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);
-
-
- if (no_process) {
- /* Do not process. This is for benchmarking. We need to "fake"
- * the outArgs. */
- outArgs->outputID[0] = buf;
- outArgs->outputID[1] = NULL;
- outArgs->freeBufID[0] = buf;
- outArgs->freeBufID[1] = NULL;
- outArgs->outBufsInUseFlag = 0;
-
- } else {
- XDAS_Int32 err;
- suseconds_t tproc;
- tproc = mark(NULL);
- err = VIDDEC3_process(decoder->codec, inBufs, outBufs, inArgs, outArgs);
- DBG("%p: processed returned in: %ldus", decoder, (long int)mark(&tproc));
- if (err) {
- ERROR("%p: process returned error: %d", decoder, err);
- ERROR("%p: extendedError: %08x", decoder, outArgs->extendedError);
- if (XDM_ISFATALERROR(outArgs->extendedError))
- return -1;
+ 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);
}
- for (i = 0; outArgs->outputID[i]; i++) {
- /* calculate offset to region of interest */
- XDM_Rect *r = &(outArgs->displayBufs.bufDesc[0].activeFrameRegion);
+ do {
+ if (no_process) {
+ /* Do not process. This is for benchmarking. We need to "fake"
+ * the outArgs. */
+ outArgs->outputID[0] = buf;
+ outArgs->outputID[1] = NULL;
+ outArgs->freeBufID[0] = buf;
+ outArgs->freeBufID[1] = NULL;
+ outArgs->outBufsInUseFlag = 0;
- /* get the output buffer and write it to file */
- buf = (struct buffer *)outArgs->outputID[i];
- disp_post_vid_buffer(decoder->disp, buf,
- r->topLeft.x, r->topLeft.y,
- r->bottomRight.x - r->topLeft.x,
- r->bottomRight.y - r->topLeft.y);
- }
+ } else {
+ suseconds_t tproc;
+ tproc = mark(NULL);
+ err = VIDDEC3_process(decoder->codec, inBufs, outBufs, inArgs, outArgs);
+ DBG("%p: processed returned in: %ldus", decoder, (long int)mark(&tproc));
+ if (err) {
+ ERROR("%p: process returned error: %d", decoder, err);
+ ERROR("%p: extendedError: %08x", decoder, outArgs->extendedError);
+ if (XDM_ISFATALERROR(outArgs->extendedError))
+ return -1;
+ }
+ }
- for (i = 0; outArgs->freeBufID[i]; i++) {
- buf = (struct buffer *)outArgs->freeBufID[i];
- disp_put_vid_buffer(decoder->disp, buf);
+ for (i = 0; outArgs->outputID[i]; i++) {
+ /* calculate offset to region of interest */
+ XDM_Rect *r = &(outArgs->displayBufs.bufDesc[0].activeFrameRegion);
- if(buf->multiplanar){
- decoder->outBuf_fd[freeBufCount++] = buf->fd[0];
- decoder->outBuf_fd[freeBufCount++] = buf->fd[1];
+ /* get the output buffer and write it to file */
+ buf = (struct buffer *)outArgs->outputID[i];
+ disp_post_vid_buffer(decoder->disp, buf,
+ r->topLeft.x, r->topLeft.y,
+ r->bottomRight.x - r->topLeft.x,
+ r->bottomRight.y - r->topLeft.y);
}
- else{
- decoder->outBuf_fd[freeBufCount++] = buf->fd[0];
+
+ for (i = 0; outArgs->freeBufID[i]; i++) {
+ buf = (struct buffer *)outArgs->freeBufID[i];
+ disp_put_vid_buffer(decoder->disp, buf);
+
+ if(buf->multiplanar){
+ decoder->outBuf_fd[freeBufCount++] = buf->fd[0];
+ decoder->outBuf_fd[freeBufCount++] = buf->fd[1];
+ }
+ else{
+ decoder->outBuf_fd[freeBufCount++] = buf->fd[0];
+ }
}
- }
- if(freeBufCount){
- dce_buf_unlock(freeBufCount,decoder->outBuf_fd);
- freeBufCount =0;
- }
- if (outArgs->outBufsInUseFlag) {
- MSG("%p: TODO... outBufsInUseFlag", decoder); // XXX
- }
+ if(freeBufCount){
+ dce_buf_unlock(freeBufCount,decoder->outBuf_fd);
+ freeBufCount =0;
+ }
+ if (outArgs->outBufsInUseFlag) {
+ MSG("%p: TODO... outBufsInUseFlag", decoder); // XXX
+ }
+ } while ((err == 0) && eof);
return (inBufs->numBufs > 0) ? 0 : -1;
}