You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
libxvid: Make codec use the init-cleanup flag and mark it as init-thread-safe
This takes care of memory leaks on init error.
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include "libavutil/mathematics.h"
|
#include "libavutil/mathematics.h"
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "internal.h"
|
||||||
#include "libxvid.h"
|
#include "libxvid.h"
|
||||||
#include "mpegvideo.h"
|
#include "mpegvideo.h"
|
||||||
|
|
||||||
@@ -778,8 +779,12 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
struct xvid_context *x = avctx->priv_data;
|
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);
|
av_freep(&avctx->extradata);
|
||||||
if (x->twopassbuffer) {
|
if (x->twopassbuffer) {
|
||||||
av_free(x->twopassbuffer);
|
av_free(x->twopassbuffer);
|
||||||
@@ -824,4 +829,6 @@ AVCodec ff_libxvid_encoder = {
|
|||||||
.close = xvid_encode_close,
|
.close = xvid_encode_close,
|
||||||
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
|
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
|
||||||
.priv_class = &xvid_class,
|
.priv_class = &xvid_class,
|
||||||
|
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
|
||||||
|
FF_CODEC_CAP_INIT_CLEANUP,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user