Skip to content

Commit

Permalink
omxil: Feed input data in multiple buffers if needed
Browse files Browse the repository at this point in the history
This fixes decoding of higher resolution content on the raspberry
pi, where the decoder defaults to 80 KB input buffers and doesn't
react if trying to enlarge them in
ImplementationSpecificWorkarounds().

Signed-off-by: Martin Storsjö <[email protected]>
  • Loading branch information
mstorsjo committed Mar 18, 2013
1 parent 567597b commit d7cc0fc
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions modules/codec/omxil/omxil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )

OMX_BUFFERHEADERTYPE *p_header;
block_t *p_block;
int i_input_used = 0;

if( !pp_block || !*pp_block )
return NULL;
Expand Down Expand Up @@ -1218,6 +1219,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
OMX_FillThisBuffer(p_sys->omx_handle, p_header);
}

more_input:
/* Send the input buffer to the component */
OMX_FIFO_GET_TIMEOUT(&p_sys->in.fifo, p_header, 200000);

Expand All @@ -1228,7 +1230,8 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )

if(p_header)
{
p_header->nFilledLen = p_block->i_buffer;
bool decode_more = false;
p_header->nFilledLen = p_block->i_buffer - i_input_used;
p_header->nOffset = 0;
p_header->nFlags = OMX_BUFFERFLAG_ENDOFFRAME;
if (p_sys->b_use_pts && p_block->i_pts)
Expand All @@ -1243,17 +1246,25 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
p_header->pOutputPortPrivate = p_header->pBuffer;
p_header->pBuffer = p_block->p_buffer;
p_header->pAppPrivate = p_block;
i_input_used = p_header->nFilledLen;
}
else
{
if(p_header->nFilledLen > p_header->nAllocLen)
{
msg_Dbg(p_dec, "buffer too small (%i,%i)",
(int)p_header->nFilledLen, (int)p_header->nAllocLen);
p_header->nFilledLen = p_header->nAllocLen;
}
memcpy(p_header->pBuffer, p_block->p_buffer, p_header->nFilledLen );
block_Release(p_block);
memcpy(p_header->pBuffer, p_block->p_buffer + i_input_used, p_header->nFilledLen);
i_input_used += p_header->nFilledLen;
if (i_input_used == p_block->i_buffer)
{
block_Release(p_block);
}
else
{
decode_more = true;
p_header->nFlags &= ~OMX_BUFFERFLAG_ENDOFFRAME;
}
}

/* Convert H.264 NAL format to annex b. Doesn't do anything if
Expand All @@ -1267,7 +1278,10 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
#endif
OMX_EmptyThisBuffer(p_sys->omx_handle, p_header);
p_sys->in.b_flushed = false;
*pp_block = NULL; /* Avoid being fed the same packet again */
if (decode_more)
goto more_input;
else
*pp_block = NULL; /* Avoid being fed the same packet again */
}

reconfig:
Expand Down

0 comments on commit d7cc0fc

Please sign in to comment.