mirror of
https://github.com/mpv-player/mpv
synced 2024-08-28 05:46:13 +02:00
change malloc and free to av_ variants where needed.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14432 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
2ac89bd388
commit
479bdb2c08
@ -72,7 +72,7 @@ static int init(sh_audio_t *sh_audio)
|
|||||||
|
|
||||||
/* alloc extra data */
|
/* alloc extra data */
|
||||||
if (sh_audio->wf && sh_audio->wf->cbSize > 0) {
|
if (sh_audio->wf && sh_audio->wf->cbSize > 0) {
|
||||||
lavc_context->extradata = malloc(sh_audio->wf->cbSize);
|
lavc_context->extradata = av_malloc(sh_audio->wf->cbSize);
|
||||||
lavc_context->extradata_size = sh_audio->wf->cbSize;
|
lavc_context->extradata_size = sh_audio->wf->cbSize;
|
||||||
memcpy(lavc_context->extradata, (char *)sh_audio->wf + sizeof(WAVEFORMATEX),
|
memcpy(lavc_context->extradata, (char *)sh_audio->wf + sizeof(WAVEFORMATEX),
|
||||||
lavc_context->extradata_size);
|
lavc_context->extradata_size);
|
||||||
@ -120,9 +120,8 @@ static void uninit(sh_audio_t *sh)
|
|||||||
|
|
||||||
if (avcodec_close(lavc_context) < 0)
|
if (avcodec_close(lavc_context) < 0)
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec);
|
mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec);
|
||||||
if (lavc_context->extradata)
|
av_freep(&lavc_context->extradata);
|
||||||
free(lavc_context->extradata);
|
av_freep(&lavc_context);
|
||||||
free(lavc_context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
|
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
|
||||||
|
@ -281,7 +281,7 @@ static int init(sh_video_t *sh){
|
|||||||
{
|
{
|
||||||
avctx->flags |= CODEC_FLAG_EXTERN_HUFF;
|
avctx->flags |= CODEC_FLAG_EXTERN_HUFF;
|
||||||
avctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER);
|
avctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER);
|
||||||
avctx->extradata = malloc(avctx->extradata_size);
|
avctx->extradata = av_malloc(avctx->extradata_size);
|
||||||
memcpy(avctx->extradata, sh->bih+sizeof(BITMAPINFOHEADER),
|
memcpy(avctx->extradata, sh->bih+sizeof(BITMAPINFOHEADER),
|
||||||
avctx->extradata_size);
|
avctx->extradata_size);
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ static int init(sh_video_t *sh){
|
|||||||
|| sh->format == mmioFOURCC('R', 'V', '4', '0')
|
|| sh->format == mmioFOURCC('R', 'V', '4', '0')
|
||||||
){
|
){
|
||||||
avctx->extradata_size= 8;
|
avctx->extradata_size= 8;
|
||||||
avctx->extradata = malloc(avctx->extradata_size);
|
avctx->extradata = av_malloc(avctx->extradata_size);
|
||||||
if(sh->bih->biSize!=sizeof(*sh->bih)+8){
|
if(sh->bih->biSize!=sizeof(*sh->bih)+8){
|
||||||
/* only 1 packet per frame & sub_id from fourcc */
|
/* only 1 packet per frame & sub_id from fourcc */
|
||||||
((uint32_t*)avctx->extradata)[0] = 0;
|
((uint32_t*)avctx->extradata)[0] = 0;
|
||||||
@ -338,7 +338,7 @@ static int init(sh_video_t *sh){
|
|||||||
))
|
))
|
||||||
{
|
{
|
||||||
avctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER);
|
avctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER);
|
||||||
avctx->extradata = malloc(avctx->extradata_size);
|
avctx->extradata = av_malloc(avctx->extradata_size);
|
||||||
memcpy(avctx->extradata, sh->bih+1, avctx->extradata_size);
|
memcpy(avctx->extradata, sh->bih+1, avctx->extradata_size);
|
||||||
}
|
}
|
||||||
/* Pass palette to codec */
|
/* Pass palette to codec */
|
||||||
@ -359,7 +359,7 @@ static int init(sh_video_t *sh){
|
|||||||
if (sh->ImageDesc &&
|
if (sh->ImageDesc &&
|
||||||
sh->format == mmioFOURCC('S','V','Q','3')){
|
sh->format == mmioFOURCC('S','V','Q','3')){
|
||||||
avctx->extradata_size = (*(int*)sh->ImageDesc) - sizeof(int);
|
avctx->extradata_size = (*(int*)sh->ImageDesc) - sizeof(int);
|
||||||
avctx->extradata = malloc(avctx->extradata_size);
|
avctx->extradata = av_malloc(avctx->extradata_size);
|
||||||
memcpy(avctx->extradata, ((int*)sh->ImageDesc)+1, avctx->extradata_size);
|
memcpy(avctx->extradata, ((int*)sh->ImageDesc)+1, avctx->extradata_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,22 +395,14 @@ static void uninit(sh_video_t *sh){
|
|||||||
if (avcodec_close(avctx) < 0)
|
if (avcodec_close(avctx) < 0)
|
||||||
mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec);
|
mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec);
|
||||||
|
|
||||||
if (avctx->extradata_size)
|
av_freep(&avctx->extradata);
|
||||||
free(avctx->extradata);
|
|
||||||
avctx->extradata=NULL;
|
|
||||||
#if LIBAVCODEC_BUILD >= 4689
|
#if LIBAVCODEC_BUILD >= 4689
|
||||||
if (avctx->palctrl)
|
av_freep(&avctx->palctrl);
|
||||||
free(avctx->palctrl);
|
|
||||||
avctx->palctrl=NULL;
|
|
||||||
#endif
|
#endif
|
||||||
if(avctx->slice_offset!=NULL)
|
av_freep(&avctx->slice_offset);
|
||||||
free(avctx->slice_offset);
|
|
||||||
avctx->slice_offset=NULL;
|
|
||||||
|
|
||||||
if (avctx)
|
av_freep(&avctx);
|
||||||
free(avctx);
|
av_freep(&ctx->pic);
|
||||||
if (ctx->pic)
|
|
||||||
free(ctx->pic);
|
|
||||||
if (ctx)
|
if (ctx)
|
||||||
free(ctx);
|
free(ctx);
|
||||||
}
|
}
|
||||||
@ -601,7 +593,7 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){
|
|||||||
#if LIBAVCODEC_BUILD >= 4689
|
#if LIBAVCODEC_BUILD >= 4689
|
||||||
// Palette support: libavcodec copies palette to *data[1]
|
// Palette support: libavcodec copies palette to *data[1]
|
||||||
if (mpi->bpp == 8)
|
if (mpi->bpp == 8)
|
||||||
mpi->planes[1] = malloc(AVPALETTE_SIZE);
|
mpi->planes[1] = av_malloc(AVPALETTE_SIZE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pic->data[0]= mpi->planes[0];
|
pic->data[0]= mpi->planes[0];
|
||||||
@ -677,8 +669,8 @@ static void release_buffer(struct AVCodecContext *avctx, AVFrame *pic){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Palette support: free palette buffer allocated in get_buffer
|
// Palette support: free palette buffer allocated in get_buffer
|
||||||
if ( mpi && (mpi->bpp == 8) && (mpi->planes[1] != NULL))
|
if ( mpi && (mpi->bpp == 8))
|
||||||
free(mpi->planes[1]);
|
av_freep(&mpi->planes[1]);
|
||||||
|
|
||||||
#if LIBAVCODEC_BUILD >= 4644
|
#if LIBAVCODEC_BUILD >= 4644
|
||||||
if(pic->type!=FF_BUFFER_TYPE_USER){
|
if(pic->type!=FF_BUFFER_TYPE_USER){
|
||||||
@ -751,7 +743,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
|||||||
dp_hdr_t *hdr= (dp_hdr_t*)data;
|
dp_hdr_t *hdr= (dp_hdr_t*)data;
|
||||||
|
|
||||||
if(avctx->slice_offset==NULL)
|
if(avctx->slice_offset==NULL)
|
||||||
avctx->slice_offset= malloc(sizeof(int)*1000);
|
avctx->slice_offset= av_malloc(sizeof(int)*1000);
|
||||||
|
|
||||||
// for(i=0; i<25; i++) printf("%02X ", ((uint8_t*)data)[i]);
|
// for(i=0; i<25; i++) printf("%02X ", ((uint8_t*)data)[i]);
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ static int config(struct vf_instance_s* vf,
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
lavc_venc_context->intra_matrix =
|
lavc_venc_context->intra_matrix =
|
||||||
malloc(sizeof(*lavc_venc_context->intra_matrix)*64);
|
av_malloc(sizeof(*lavc_venc_context->intra_matrix)*64);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((tmp = strsep(&lavc_param_intra_matrix, ",")) && (i < 64))
|
while ((tmp = strsep(&lavc_param_intra_matrix, ",")) && (i < 64))
|
||||||
@ -448,10 +448,7 @@ static int config(struct vf_instance_s* vf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i != 64)
|
if (i != 64)
|
||||||
{
|
av_freep(&lavc_venc_context->intra_matrix);
|
||||||
free(lavc_venc_context->intra_matrix);
|
|
||||||
lavc_venc_context->intra_matrix = NULL;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
mp_msg(MSGT_MENCODER, MSGL_V, "Using user specified intra matrix\n");
|
mp_msg(MSGT_MENCODER, MSGL_V, "Using user specified intra matrix\n");
|
||||||
}
|
}
|
||||||
@ -460,7 +457,7 @@ static int config(struct vf_instance_s* vf,
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
lavc_venc_context->inter_matrix =
|
lavc_venc_context->inter_matrix =
|
||||||
malloc(sizeof(*lavc_venc_context->inter_matrix)*64);
|
av_malloc(sizeof(*lavc_venc_context->inter_matrix)*64);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((tmp = strsep(&lavc_param_inter_matrix, ",")) && (i < 64))
|
while ((tmp = strsep(&lavc_param_inter_matrix, ",")) && (i < 64))
|
||||||
@ -471,10 +468,7 @@ static int config(struct vf_instance_s* vf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i != 64)
|
if (i != 64)
|
||||||
{
|
av_freep(&lavc_venc_context->inter_matrix);
|
||||||
free(lavc_venc_context->inter_matrix);
|
|
||||||
lavc_venc_context->inter_matrix = NULL;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
mp_msg(MSGT_MENCODER, MSGL_V, "Using user specified inter matrix\n");
|
mp_msg(MSGT_MENCODER, MSGL_V, "Using user specified inter matrix\n");
|
||||||
}
|
}
|
||||||
@ -652,7 +646,7 @@ static int config(struct vf_instance_s* vf,
|
|||||||
size= ftell(stats_file);
|
size= ftell(stats_file);
|
||||||
fseek(stats_file, 0, SEEK_SET);
|
fseek(stats_file, 0, SEEK_SET);
|
||||||
|
|
||||||
lavc_venc_context->stats_in= malloc(size + 1);
|
lavc_venc_context->stats_in= av_malloc(size + 1);
|
||||||
lavc_venc_context->stats_in[size]=0;
|
lavc_venc_context->stats_in[size]=0;
|
||||||
|
|
||||||
if(fread(lavc_venc_context->stats_in, size, 1, stats_file)<1){
|
if(fread(lavc_venc_context->stats_in, size, 1, stats_file)<1){
|
||||||
@ -728,8 +722,7 @@ static int config(struct vf_instance_s* vf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* free second pass buffer, its not needed anymore */
|
/* free second pass buffer, its not needed anymore */
|
||||||
if(lavc_venc_context->stats_in) free(lavc_venc_context->stats_in);
|
av_freep(&lavc_venc_context->stats_in);
|
||||||
lavc_venc_context->stats_in= NULL;
|
|
||||||
if(lavc_venc_context->bits_per_sample)
|
if(lavc_venc_context->bits_per_sample)
|
||||||
mux_v->bih->biBitCount= lavc_venc_context->bits_per_sample;
|
mux_v->bih->biBitCount= lavc_venc_context->bits_per_sample;
|
||||||
if(lavc_venc_context->extradata_size){
|
if(lavc_venc_context->extradata_size){
|
||||||
@ -907,12 +900,8 @@ static void uninit(struct vf_instance_s* vf){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LIBAVCODEC_BUILD >= 4675
|
#if LIBAVCODEC_BUILD >= 4675
|
||||||
if (lavc_venc_context->intra_matrix)
|
av_freep(&lavc_venc_context->intra_matrix);
|
||||||
free(lavc_venc_context->intra_matrix);
|
av_freep(&lavc_venc_context->inter_matrix);
|
||||||
lavc_venc_context->intra_matrix = NULL;
|
|
||||||
if (lavc_venc_context->inter_matrix)
|
|
||||||
free(lavc_venc_context->inter_matrix);
|
|
||||||
lavc_venc_context->inter_matrix = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
avcodec_close(lavc_venc_context);
|
avcodec_close(lavc_venc_context);
|
||||||
@ -920,11 +909,9 @@ static void uninit(struct vf_instance_s* vf){
|
|||||||
if(stats_file) fclose(stats_file);
|
if(stats_file) fclose(stats_file);
|
||||||
|
|
||||||
/* free rc_override */
|
/* free rc_override */
|
||||||
if(lavc_venc_context->rc_override) free(lavc_venc_context->rc_override);
|
av_freep(&lavc_venc_context->rc_override);
|
||||||
lavc_venc_context->rc_override= NULL;
|
|
||||||
|
|
||||||
if(vf->priv->context) free(vf->priv->context);
|
av_freep(&vf->priv->context);
|
||||||
vf->priv->context= NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================//
|
//===========================================================================//
|
||||||
|
Loading…
Reference in New Issue
Block a user