diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-03-25 23:30:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-03-25 23:30:33 +0300 |
commit | 192021f068e9e9e0c140ebc8f7ca40934f99f684 (patch) | |
tree | 6054e3a7add211664d4ae8ce610c02911802f685 /source/blender/imbuf | |
parent | 4bf152fbcd15d0523dac6260dab43b007f7262dc (diff) |
check for null data when using ffmpegs swscale (for corrupt/partially corrupt videos)
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/intern/anim.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c index 1700790c4fa..1e6c1e3aedd 100644 --- a/source/blender/imbuf/intern/anim.c +++ b/source/blender/imbuf/intern/anim.c @@ -784,25 +784,28 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { 0, 0, 0 }; int i; unsigned char* r; - - sws_scale(anim->img_convert_ctx, - anim->pFrame->data, - anim->pFrame->linesize, - 0, - anim->pCodecCtx->height, - dst2, - dstStride2); - - /* workaround: sws_scale - sets alpha = 0... */ - - r = (unsigned char*) ibuf->rect; - - for (i = 0; i < ibuf->x * ibuf->y;i++){ - r[3] = 0xff; - r+=4; + + /* This means the data wasnt read properly, this check stops crashing */ + if (anim->pFrame->data[0]!=0 || anim->pFrame->data[1]!=0 || anim->pFrame->data[2]!=0 || anim->pFrame->data[3]!=0) { + + sws_scale(anim->img_convert_ctx, + anim->pFrame->data, + anim->pFrame->linesize, + 0, + anim->pCodecCtx->height, + dst2, + dstStride2); + + /* workaround: sws_scale + sets alpha = 0... */ + + r = (unsigned char*) ibuf->rect; + + for (i = 0; i < ibuf->x * ibuf->y;i++){ + r[3] = 0xff; + r+=4; + } } - av_free_packet(&packet); break; } |