[vlc-commits] omxil: move output handling into DecodeVideoOutput

Thomas Guillem git at videolan.org
Fri Jul 11 09:44:58 CEST 2014


vlc | branch: master | Thomas Guillem <guillem at archos.com> | Thu Jul 10 16:29:56 2014 +0200| [4884ef317fa5c03e06723cd0b2eeb09cecde37c4] | committer: Jean-Baptiste Kempf

omxil: move output handling into DecodeVideoOutput

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4884ef317fa5c03e06723cd0b2eeb09cecde37c4
---

 modules/codec/omxil/omxil.c |  133 ++++++++++++++++++++++++-------------------
 1 file changed, 76 insertions(+), 57 deletions(-)

diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index af27dd7..23a4af6 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -1196,12 +1196,85 @@ static OMX_ERRORTYPE PortReconfigure(decoder_t *p_dec, OmxPort *p_port)
 }
 
 /*****************************************************************************
+ * DecodeVideoOutput
+ *****************************************************************************/
+static int DecodeVideoOutput( decoder_t *p_dec, OmxPort *p_port, picture_t **pp_pic )
+{
+    VLC_UNUSED( p_dec );
+    OMX_BUFFERHEADERTYPE *p_header;
+    picture_t *p_pic = NULL, *p_next_pic;
+    OMX_ERRORTYPE omx_error;
+
+    while(!p_pic)
+    {
+        OMX_FIFO_PEEK(&p_port->fifo, p_header);
+        if(!p_header) break; /* No frame available */
+
+        if(p_port->b_update_def)
+        {
+            omx_error = GetPortDefinition(p_dec, p_port, p_port->p_fmt);
+            p_port->b_update_def = 0;
+            CHECK_ERROR(omx_error, "GetPortDefinition failed");
+        }
+
+        if(p_header->nFilledLen)
+        {
+            p_pic = p_header->pAppPrivate;
+            if(!p_pic)
+            {
+                /* We're not in direct rendering mode.
+                 * Get a new picture and copy the content */
+                p_pic = decoder_NewPicture( p_dec );
+
+                if (p_pic)
+                    CopyOmxPicture(p_port->definition.format.video.eColorFormat,
+                                   p_pic, p_port->definition.format.video.nSliceHeight,
+                                   p_port->i_frame_stride,
+                                   p_header->pBuffer + p_header->nOffset,
+                                   p_port->i_frame_stride_chroma_div, NULL);
+            }
+
+            if (p_pic)
+                p_pic->date = FromOmxTicks(p_header->nTimeStamp);
+            p_header->nFilledLen = 0;
+            p_header->pAppPrivate = 0;
+        }
+
+        /* Get a new picture */
+        if(p_port->b_direct && !p_header->pAppPrivate)
+        {
+            p_next_pic = decoder_NewPicture( p_dec );
+            if(!p_next_pic) break;
+
+            OMX_FIFO_GET(&p_port->fifo, p_header);
+            p_header->pAppPrivate = p_next_pic;
+            p_header->pInputPortPrivate = p_header->pBuffer;
+            p_header->pBuffer = p_next_pic->p[0].p_pixels;
+        }
+        else
+        {
+            OMX_FIFO_GET(&p_port->fifo, p_header);
+        }
+
+#ifdef OMXIL_EXTRA_DEBUG
+        msg_Dbg( p_dec, "FillThisBuffer %p, %p", p_header, p_header->pBuffer );
+#endif
+        OMX_FillThisBuffer(p_port->omx_handle, p_header);
+    }
+
+    *pp_pic = p_pic;
+    return 0;
+error:
+    return -1;
+}
+
+/*****************************************************************************
  * DecodeVideo: Called to decode one frame
  *****************************************************************************/
 static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
-    picture_t *p_pic = NULL, *p_next_pic;
+    picture_t *p_pic = NULL;
     OMX_ERRORTYPE omx_error;
     unsigned int i;
 
@@ -1250,62 +1323,8 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
     }
 
     /* Take care of decoded frames first */
-    while(!p_pic)
-    {
-        OMX_FIFO_PEEK(&p_sys->out.fifo, p_header);
-        if(!p_header) break; /* No frame available */
-
-        if(p_sys->out.b_update_def)
-        {
-            omx_error = GetPortDefinition(p_dec, &p_sys->out, p_sys->out.p_fmt);
-            p_sys->out.b_update_def = 0;
-            CHECK_ERROR(omx_error, "GetPortDefinition failed");
-        }
-
-        if(p_header->nFilledLen)
-        {
-            p_pic = p_header->pAppPrivate;
-            if(!p_pic)
-            {
-                /* We're not in direct rendering mode.
-                 * Get a new picture and copy the content */
-                p_pic = decoder_NewPicture( p_dec );
-
-                if (p_pic)
-                    CopyOmxPicture(p_sys->out.definition.format.video.eColorFormat,
-                                   p_pic, p_sys->out.definition.format.video.nSliceHeight,
-                                   p_sys->out.i_frame_stride,
-                                   p_header->pBuffer + p_header->nOffset,
-                                   p_sys->out.i_frame_stride_chroma_div, NULL);
-            }
-
-            if (p_pic)
-                p_pic->date = FromOmxTicks(p_header->nTimeStamp);
-            p_header->nFilledLen = 0;
-            p_header->pAppPrivate = 0;
-        }
-
-        /* Get a new picture */
-        if(p_sys->out.b_direct && !p_header->pAppPrivate)
-        {
-            p_next_pic = decoder_NewPicture( p_dec );
-            if(!p_next_pic) break;
-
-            OMX_FIFO_GET(&p_sys->out.fifo, p_header);
-            p_header->pAppPrivate = p_next_pic;
-            p_header->pInputPortPrivate = p_header->pBuffer;
-            p_header->pBuffer = p_next_pic->p[0].p_pixels;
-        }
-        else
-        {
-            OMX_FIFO_GET(&p_sys->out.fifo, p_header);
-        }
-
-#ifdef OMXIL_EXTRA_DEBUG
-        msg_Dbg( p_dec, "FillThisBuffer %p, %p", p_header, p_header->pBuffer );
-#endif
-        OMX_FillThisBuffer(p_sys->omx_handle, p_header);
-    }
+    if( DecodeVideoOutput( p_dec, &p_sys->out, &p_pic ) != 0 )
+        goto error;
 
 more_input:
     /* Send the input buffer to the component */



More information about the vlc-commits mailing list