Mercurial > mplayer.hg
comparison libmpcodecs/vd_ffmpeg.c @ 21498:f2c58d4fb683
Fix memleak if vd_ffmpeg init fails
author | reimar |
---|---|
date | Wed, 06 Dec 2006 10:41:34 +0000 |
parents | af4c8fd34494 |
children | fa99b3d31d13 |
comparison
equal
deleted
inserted
replaced
21497:4a4af5271542 | 21498:f2c58d4fb683 |
---|---|
240 memset(ctx, 0, sizeof(vd_ffmpeg_ctx)); | 240 memset(ctx, 0, sizeof(vd_ffmpeg_ctx)); |
241 | 241 |
242 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh->codec->dll); | 242 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh->codec->dll); |
243 if(!lavc_codec){ | 243 if(!lavc_codec){ |
244 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh->codec->dll); | 244 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh->codec->dll); |
245 uninit(sh); | |
245 return 0; | 246 return 0; |
246 } | 247 } |
247 | 248 |
248 if(vd_use_slices && (lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND) && !do_vis_debug) | 249 if(vd_use_slices && (lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND) && !do_vis_debug) |
249 ctx->do_slices=1; | 250 ctx->do_slices=1; |
404 if(lavc_param_threads > 1) | 405 if(lavc_param_threads > 1) |
405 avcodec_thread_init(avctx, lavc_param_threads); | 406 avcodec_thread_init(avctx, lavc_param_threads); |
406 /* open it */ | 407 /* open it */ |
407 if (avcodec_open(avctx, lavc_codec) < 0) { | 408 if (avcodec_open(avctx, lavc_codec) < 0) { |
408 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantOpenCodec); | 409 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantOpenCodec); |
410 uninit(sh); | |
409 return 0; | 411 return 0; |
410 } | 412 } |
411 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n"); | 413 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n"); |
412 ctx->last_aspect=-3; | 414 ctx->last_aspect=-3; |
413 return 1; //mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12); | 415 return 1; //mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12); |
427 ctx->qp_sum / avctx->coded_frame->coded_picture_number, | 429 ctx->qp_sum / avctx->coded_frame->coded_picture_number, |
428 1.0/(ctx->inv_qp_sum / avctx->coded_frame->coded_picture_number) | 430 1.0/(ctx->inv_qp_sum / avctx->coded_frame->coded_picture_number) |
429 ); | 431 ); |
430 } | 432 } |
431 | 433 |
432 if (avcodec_close(avctx) < 0) | 434 if (avctx && avctx->codec && avcodec_close(avctx) < 0) |
433 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec); | 435 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec); |
434 | 436 |
435 av_freep(&avctx->extradata); | 437 av_freep(&avctx->extradata); |
436 av_freep(&avctx->palctrl); | 438 av_freep(&avctx->palctrl); |
437 av_freep(&avctx->slice_offset); | 439 av_freep(&avctx->slice_offset); |