Commit 0e3f762c authored by Jean-Paul Saman's avatar Jean-Paul Saman

davinci video: cleanup

parent 1142a1ed
......@@ -45,7 +45,6 @@
* Local prototypes
*****************************************************************************/
static picture_t *DecodeVideoBlock( decoder_t *, block_t ** );
static picture_t *DecodeVideoBlockInner( decoder_t *, block_t **, int );
/*****************************************************************************
* Video decoder
......@@ -218,11 +217,6 @@ static inline void davinci_CopyXDMPicture( decoder_t *p_dec, picture_t *p_pic, X
* DecodeBlock: the whole thing
****************************************************************************/
static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
{
return DecodeVideoBlockInner( p_dec, pp_block, 0 );
}
static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, int i_extra )
{
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_block;
......@@ -257,7 +251,9 @@ static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, i
msg_Err( p_dec, "Failed to get buffer info" );
goto error;
}
}
if( p_sys->in.numBufs == 0 )
{
/* Allocate input buffer */
if( davinci_AllocateBuffer( status.bufInfo.minNumInBufs,
status.bufInfo.minInBufSize, &p_sys->in )
......@@ -266,7 +262,9 @@ static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, i
msg_Err( p_dec, "Failed to allocate input buffers" );
goto error;
}
}
if( p_sys->out.numBufs == 0 )
{
/* Allocate output buffer(s) */
if( davinci_AllocateBuffer( status.bufInfo.minNumOutBufs,
status.bufInfo.minOutBufSize, &p_sys->out )
......@@ -287,23 +285,23 @@ static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, i
/* Setup input arguments */
in_args.size = sizeof( in_args );
in_args.numBytes = __MIN( i_extra + p_block->i_buffer,
in_args.numBytes = __MIN( p_dec->fmt_in.i_extra + p_block->i_buffer,
(size_t)p_sys->in.bufSizes[0] );
in_args.inputID = 1;
/* Setup input buffer */
assert( p_block->i_buffer <= (size_t)p_sys->in.bufSizes[0] );
if( i_extra > 0 )
if( p_dec->fmt_in.i_extra > 0 )
{
memcpy( p_sys->in.bufs[0], p_dec->fmt_in.p_extra, i_extra );
memcpy( p_sys->in.bufs[0], p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra );
}
memcpy( p_sys->in.bufs[0] + i_extra, p_block->p_buffer,
in_args.numBytes - i_extra );
memcpy( p_sys->in.bufs[0] + p_dec->fmt_in.i_extra, p_block->p_buffer,
in_args.numBytes - p_dec->fmt_in.i_extra );
#ifdef DEBUG_DAVINCI
msg_Dbg( p_dec, "Frame is %d bytes (%d extra), %dx%d, type %s",
(int)in_args.numBytes, i_extra, (int)status.outputWidth,
(int)in_args.numBytes, p_dec->fmt_in.i_extra, (int)status.outputWidth,
(int)status.outputHeight,
status.contentType == IVIDEO_PROGRESSIVE ? "progressive" :
status.contentType == IVIDEO_INTERLACED ? "interlaced" :
......@@ -318,25 +316,6 @@ static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, i
{
msg_Err( p_dec, "Video decoding failed: %s",
davinci_GetExtendedError(out_args.extendedError ) );
#if 0
if( (unsigned int)out_args.extendedError == 0x402 )
{
printf("frame was %d bytes\n",(unsigned int)in_args.numBytes);
unsigned int j;
for(j=0;j<(unsigned int)in_args.numBytes;j++)
printf("%.2x ",p_sys->in.bufs[0][j]&0xff);
printf("\n");
CERuntime_exit();
abort();
}
#endif
if( i_extra == 0 && p_dec->fmt_in.i_extra > 0 )
{
msg_Dbg( p_dec, "Trying again with p_extra" );
return DecodeVideoBlockInner( p_dec, pp_block, p_dec->fmt_in.i_extra );
}
goto error;
}
......@@ -349,8 +328,8 @@ static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, i
if( in_args.numBytes > out_args.bytesConsumed )
msg_Err( p_dec, "%d bytes were not consumed", (int)(out_args.bytesConsumed - in_args.numBytes) );
p_block->p_buffer += out_args.bytesConsumed - i_extra;
p_block->i_buffer -= out_args.bytesConsumed - i_extra;
p_block->p_buffer += out_args.bytesConsumed - p_dec->fmt_in.i_extra;
p_block->i_buffer -= out_args.bytesConsumed - p_dec->fmt_in.i_extra;
p_dec->fmt_out.video.i_width = status.outputWidth;
p_dec->fmt_out.video.i_height = status.outputHeight;
......
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