[vlc-devel] [PATCH 1/3] omxil: move output handling into DecodeVideoOutput

Thomas Guillem guillem at archos.com
Thu Jul 10 16:29:56 CEST 2014


---
 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 */
-- 
1.7.10.4


-- 


This email and any files transmitted with it are confidential and are 
intended solely for the use of the individual or entity to which they are 
addressed. Access to this e-mail by anyone else is unauthorised. If you are 
not the intended recipient, any disclosure, copying, distribution or any 
action taken or omitted to be taken in reliance on it, is prohibited. 
E-mail messages are not necessarily secure. Archos does not accept 
responsibility for any changes made to this message after it was sent.



More information about the vlc-devel mailing list