[Ffmpeg-devel] Where to free the memory (AVCodecContext) allocated by avcodec_alloc_context()?
Mat
heavensdoor78
Tue Oct 4 09:28:49 CEST 2005
QuickTime wrote:
>Dear maillisters:
>Where to free the memory (AVCodecContext) allocated by avcodec_alloc_context()?
>Please check the following codes!
>
>//@file:output_example.c
>/*
> * add an audio output stream
> */
>AVStream *add_audio_stream(AVFormatContext *oc, int codec_id)
>{
> AVCodecContext *c;
> AVStream *st;
>
> st = av_new_stream(oc, 1);
> if (!st) {
> fprintf(stderr, "Could not alloc stream\n");
> exit(1);
> }
>
> c = st->codec;
> c->codec_id = codec_id;
> c->codec_type = CODEC_TYPE_AUDIO;
>
> /* put sample parameters */
> c->bit_rate = 64000;
> c->sample_rate = 44100;
> c->channels = 2;
> return st;
>}
>...
>
>
I tested output_example with my debugger weeks ago and I wrote the
results in the ML...
I proposed to add some lines in output_example.c after the line
av_write_trailer(oc) :
if (video_st)
av_free(video_st->codec);
if (audio_st)
av_free(audio_st->codec);
With this changes here (and in some other encoders' file) my debugger
says it's ok (no leaks)
More information about the ffmpeg-devel
mailing list