Commit 184e6f1f authored by Jean-Paul Saman's avatar Jean-Paul Saman

davinci: video.c: do not query XDM_GETSTATUS on each decoded picture.

On each picture the video decoder wrapper did query XDM_GETSTATUS for decoder status,
but error information is alread available in p_sys->out_args in member 'extendedError'.
This patch saves one syscall every picture (except the first). The first picture defines
the output properties of the decoded pictures and these must be stored in p_dec->fmt_out.video.*
to obtain correctly sized pictures (picture_t).
parent 28f42bf7
......@@ -63,6 +63,9 @@ struct decoder_sys_t
XDM_BufDesc in;
XDM_BufDesc out;
/* picture properties */
bool b_progressive;
};
/*****************************************************************************
......@@ -319,12 +322,11 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
}
#endif
/* Setup input arguments */
/* Setup input buffer */
p_sys->in_args.numBytes = __MIN( p_dec->fmt_in.i_extra + p_block->i_buffer,
(size_t)p_sys->in.bufSizes[0] );
p_sys->in_args.inputID++;
/* Setup input buffer */
assert( p_block->i_buffer <= (size_t)p_sys->in.bufSizes[0] );
if( p_dec->fmt_in.i_extra > 0 )
......@@ -334,46 +336,54 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
memcpy( p_sys->in.bufs[0] + p_dec->fmt_in.i_extra, p_block->p_buffer,
p_sys->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)p_sys->in_args.numBytes, p_dec->fmt_in.i_extra,
(int)p_sys->status.outputWidth,
(int)p_sys->status.outputHeight,
p_sys->status.contentType == IVIDEO_PROGRESSIVE ? "progressive" :
p_sys->status.contentType == IVIDEO_INTERLACED ? "interlaced" :
"unknown" );
#endif
/* Decode the video */
if( VIDDEC_process( p_sys->handle, &p_sys->in, &p_sys->out,
&p_sys->in_args, &p_sys->out_args ) != VIDDEC_EOK )
{
msg_Err( p_dec, "Video decoding failed: %s",
davinci_GetExtendedError(p_sys->out_args.extendedError ) );
davinci_GetExtendedError( p_sys->out_args.extendedError ) );
goto error;
}
if( VIDDEC_control( p_sys->handle, XDM_GETSTATUS,
&p_sys->dparams, &p_sys->status ) != VIDDEC_EOK )
if( p_dec->fmt_out.video.i_width == 0 ||
p_dec->fmt_out.video.i_height == 0 ||
p_dec->fmt_out.video.i_aspect == 0 )
{
msg_Err( p_dec, "Failed to get decoder status" );
goto error;
if( VIDDEC_control( p_sys->handle, XDM_GETSTATUS,
&p_sys->dparams, &p_sys->status ) != VIDDEC_EOK )
{
msg_Err( p_dec, "Failed to get decoder status" );
goto error;
}
p_dec->fmt_out.video.i_width = p_sys->status.outputWidth;
p_dec->fmt_out.video.i_height = p_sys->status.outputHeight;
p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_sys->status.outputWidth
/ p_sys->status.outputHeight; /* FIXME */
p_sys->b_progressive = (p_sys->status.contentType == IVIDEO_INTERLACED) ? false : true;
#ifdef DEBUG_DAVINCI
msg_Dbg( p_dec, "Frame is %d bytes (%d extra), %dx%d, type %s",
(int)p_sys->in_args.numBytes, p_dec->fmt_in.i_extra,
(int)p_sys->status.outputWidth, (int)p_sys->status.outputHeight,
p_sys->status.contentType == IVIDEO_PROGRESSIVE ? "progressive" :
p_sys->status.contentType == IVIDEO_INTERLACED ? "interlaced" :
"unknown" );
#endif
}
#ifdef DEBUG_DAVINCI
if( p_sys->in_args.numBytes > p_sys->out_args.bytesConsumed )
msg_Err( p_dec, "%d bytes were not consumed",
(int)(p_sys->out_args.bytesConsumed - p_sys->in_args.numBytes) );
davinci_FrameType( p_dec, p_sys->out_args.decodedFrameType );
#endif
p_block->p_buffer += p_sys->out_args.bytesConsumed - p_dec->fmt_in.i_extra;
p_block->i_buffer -= p_sys->out_args.bytesConsumed - p_dec->fmt_in.i_extra;
p_dec->fmt_out.video.i_width = p_sys->status.outputWidth;
p_dec->fmt_out.video.i_height = p_sys->status.outputHeight;
p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_sys->status.outputWidth
/ p_sys->status.outputHeight; /* FIXME */
/* Get a new picture */
p_pic = decoder_NewPicture( p_dec );
if( !p_pic )
......@@ -381,12 +391,7 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
msg_Err( p_dec, "Could not get picture" );
goto error;
}
p_pic->b_progressive = (p_sys->status.contentType == IVIDEO_INTERLACED) ?
false : true;
#ifdef DEBUG_DAVINCI
davinci_FrameType( p_dec, p_sys->out_args.decodedFrameType );
#endif
p_pic->b_progressive = p_sys->b_progressive;
davinci_CopyXDMtoPicture( p_pic, &p_sys->out );
......
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