aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/libxvid.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-04-07 01:47:18 +0200
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-04-24 14:55:11 +0100
commit18db1286b04557aa2d2df7efbcb65ae825d5a469 (patch)
treed77dc78b9c8c1d41dcdc01cf64e9405aff12345a /libavcodec/libxvid.c
parenteae7338e1592f4a398b7c3cb9d1ac854b7a44ff8 (diff)
downloadffmpeg-18db1286b04557aa2d2df7efbcb65ae825d5a469.tar.gz
libxvid: Make codec use the init-cleanup flag and mark it as init-thread-safe
This takes care of memory leaks on init error.
Diffstat (limited to 'libavcodec/libxvid.c')
-rw-r--r--libavcodec/libxvid.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 6486ad1855..46da773052 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -33,6 +33,7 @@
#include "libavutil/mathematics.h"
#include "avcodec.h"
+#include "internal.h"
#include "libxvid.h"
#include "mpegvideo.h"
@@ -778,8 +779,12 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx)
{
struct xvid_context *x = avctx->priv_data;
- xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
+ if (x->encoder_handle) {
+ xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
+ x->encoder_handle = NULL;
+ }
+ av_frame_free(&avctx->coded_frame);
av_freep(&avctx->extradata);
if (x->twopassbuffer) {
av_free(x->twopassbuffer);
@@ -824,4 +829,6 @@ AVCodec ff_libxvid_encoder = {
.close = xvid_encode_close,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
.priv_class = &xvid_class,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
+ FF_CODEC_CAP_INIT_CLEANUP,
};