Commit d2d600b7 authored by Ivan Kalvachev's avatar Ivan Kalvachev

Check all critical xvmc struct fields in ff_xvmc_field_start()

and log error if they are not correct. All other functions
are supposedly called after that one, so use assert() for them.

Originally committed as revision 17317 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent aeedac95
...@@ -38,10 +38,8 @@ ...@@ -38,10 +38,8 @@
void ff_xvmc_init_block(MpegEncContext *s) void ff_xvmc_init_block(MpegEncContext *s)
{ {
struct xvmc_pixfmt_render *render = (struct xvmc_pixfmt_render*)s->current_picture.data[2]; struct xvmc_pixfmt_render *render = (struct xvmc_pixfmt_render*)s->current_picture.data[2];
if (!render || render->magic_id != AV_XVMC_RENDER_MAGIC) { assert(render && render->magic_id == AV_XVMC_RENDER_MAGIC);
assert(0);
return; // make sure that this is a render packet
}
s->block = (DCTELEM *)(render->data_blocks + render->next_free_data_block_num * 64); s->block = (DCTELEM *)(render->data_blocks + render->next_free_data_block_num * 64);
} }
...@@ -67,20 +65,37 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) ...@@ -67,20 +65,37 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
int ff_xvmc_field_start(MpegEncContext*s, AVCodecContext *avctx) int ff_xvmc_field_start(MpegEncContext*s, AVCodecContext *avctx)
{ {
struct xvmc_pixfmt_render *last, *next, *render = (struct xvmc_pixfmt_render*)s->current_picture.data[2]; struct xvmc_pixfmt_render *last, *next, *render = (struct xvmc_pixfmt_render*)s->current_picture.data[2];
const int mb_block_count = 4 + (1 << s->chroma_format);
assert(avctx); assert(avctx);
if (!render || render->magic_id != AV_XVMC_RENDER_MAGIC) if (!render || render->magic_id != AV_XVMC_RENDER_MAGIC ||
!render->data_blocks || !render->mv_blocks){
av_log(avctx, AV_LOG_ERROR,
"Render token doesn't look as expected.\n");
return -1; // make sure that this is a render packet return -1; // make sure that this is a render packet
}
render->picture_structure = s->picture_structure; render->picture_structure = s->picture_structure;
render->flags = s->first_field ? 0 : XVMC_SECOND_FIELD; render->flags = s->first_field ? 0 : XVMC_SECOND_FIELD;
if (render->filled_mv_blocks_num) { if (render->filled_mv_blocks_num) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"Rendering surface contains %i unprocessed blocks\n", "Rendering surface contains %i unprocessed blocks.\n",
render->filled_mv_blocks_num); render->filled_mv_blocks_num);
return -1; return -1;
} }
if (render->total_number_of_mv_blocks < 1 ||
render->total_number_of_data_blocks < mb_block_count) {
av_log(avctx, AV_LOG_ERROR,
"Rendering surface doesn't provide enough block structures to work with.\n");
return -1;
}
if (render->total_number_of_mv_blocks < 1 ||
render->total_number_of_data_blocks < mb_block_count) {
av_log(avctx, AV_LOG_ERROR,
"Rendering surface doesn't provide enough block structures to work with.\n");
return -1;
}
render->p_future_surface = NULL; render->p_future_surface = NULL;
render->p_past_surface = NULL; render->p_past_surface = NULL;
......
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