Commit d7cc0fc2 authored by Martin Storsjö's avatar Martin Storsjö

omxil: Feed input data in multiple buffers if needed

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: default avatarMartin Storsjö <martin@martin.st>
parent 567597b4
...@@ -1134,6 +1134,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) ...@@ -1134,6 +1134,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
OMX_BUFFERHEADERTYPE *p_header; OMX_BUFFERHEADERTYPE *p_header;
block_t *p_block; block_t *p_block;
int i_input_used = 0;
if( !pp_block || !*pp_block ) if( !pp_block || !*pp_block )
return NULL; return NULL;
...@@ -1218,6 +1219,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) ...@@ -1218,6 +1219,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
OMX_FillThisBuffer(p_sys->omx_handle, p_header); OMX_FillThisBuffer(p_sys->omx_handle, p_header);
} }
more_input:
/* Send the input buffer to the component */ /* Send the input buffer to the component */
OMX_FIFO_GET_TIMEOUT(&p_sys->in.fifo, p_header, 200000); OMX_FIFO_GET_TIMEOUT(&p_sys->in.fifo, p_header, 200000);
...@@ -1228,7 +1230,8 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) ...@@ -1228,7 +1230,8 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
if(p_header) 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->nOffset = 0;
p_header->nFlags = OMX_BUFFERFLAG_ENDOFFRAME; p_header->nFlags = OMX_BUFFERFLAG_ENDOFFRAME;
if (p_sys->b_use_pts && p_block->i_pts) if (p_sys->b_use_pts && p_block->i_pts)
...@@ -1243,17 +1246,25 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) ...@@ -1243,17 +1246,25 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
p_header->pOutputPortPrivate = p_header->pBuffer; p_header->pOutputPortPrivate = p_header->pBuffer;
p_header->pBuffer = p_block->p_buffer; p_header->pBuffer = p_block->p_buffer;
p_header->pAppPrivate = p_block; p_header->pAppPrivate = p_block;
i_input_used = p_header->nFilledLen;
} }
else else
{ {
if(p_header->nFilledLen > p_header->nAllocLen) 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; p_header->nFilledLen = p_header->nAllocLen;
} }
memcpy(p_header->pBuffer, p_block->p_buffer, p_header->nFilledLen ); memcpy(p_header->pBuffer, p_block->p_buffer + i_input_used, p_header->nFilledLen);
block_Release(p_block); 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 /* Convert H.264 NAL format to annex b. Doesn't do anything if
...@@ -1267,7 +1278,10 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) ...@@ -1267,7 +1278,10 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
#endif #endif
OMX_EmptyThisBuffer(p_sys->omx_handle, p_header); OMX_EmptyThisBuffer(p_sys->omx_handle, p_header);
p_sys->in.b_flushed = false; 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: reconfig:
......
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