Commit 4884ef31 authored by Thomas Guillem's avatar Thomas Guillem Committed by Jean-Baptiste Kempf

omxil: move output handling into DecodeVideoOutput

Signed-off-by: default avatarMartin Storsjö <martin@martin.st>
parent 76bff8bf
......@@ -1195,13 +1195,86 @@ static OMX_ERRORTYPE PortReconfigure(decoder_t *p_dec, OmxPort *p_port)
return omx_error;
}
/*****************************************************************************
* 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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment