diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2011-04-27 08:28:51 -0700 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-05-03 22:29:00 -0400 |
commit | fb22c237152ea62f51b8e1c96a782bae4c8709c1 (patch) | |
tree | ea22f82cd1088833382731d20d8cef6fa988a545 | |
parent | f8b1245922cf4c7692750e9198cf57598f9647d5 (diff) | |
download | ffmpeg-fb22c237152ea62f51b8e1c96a782bae4c8709c1.tar.gz |
mpegvideo: don't av_malloc(0).
-rw-r--r-- | libavcodec/mpegvideo.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 5b400b6a4a..6ccc50f4f3 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -520,6 +520,8 @@ av_cold int MPV_common_init(MpegEncContext *s) s->flags= s->avctx->flags; s->flags2= s->avctx->flags2; + if (s->width && s->height) { + s->mb_width = (s->width + 15) / 16; s->mb_stride = s->mb_width + 1; s->b8_stride = s->mb_width*2 + 1; @@ -599,11 +601,16 @@ av_cold int MPV_common_init(MpegEncContext *s) FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail) } } + + } + FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, MAX_PICTURE_COUNT * sizeof(Picture), fail) for(i = 0; i < MAX_PICTURE_COUNT; i++) { avcodec_get_frame_defaults((AVFrame *)&s->picture[i]); } + if (s->width && s->height) { + FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, mb_array_size*sizeof(uint8_t), fail) if(s->codec_id==CODEC_ID_MPEG4 || (s->flags & CODEC_FLAG_INTERLACED_ME)){ @@ -658,9 +665,12 @@ av_cold int MPV_common_init(MpegEncContext *s) s->visualization_buffer[1] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH); s->visualization_buffer[2] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH); } + } s->context_initialized = 1; + if (s->width && s->height) { + s->thread_context[0]= s; threads = s->avctx->thread_count; @@ -676,6 +686,8 @@ av_cold int MPV_common_init(MpegEncContext *s) s->thread_context[i]->end_mb_y = (s->mb_height*(i+1) + s->avctx->thread_count/2) / s->avctx->thread_count; } + } + return 0; fail: MPV_common_end(s); |