VGMStream: Clean up FFmpeg code somewhat
Remove deprecated functions, make use of free functions that clear the pointers before returning, etc. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
b571c3f62a
commit
0fd4c327e4
1 changed files with 4 additions and 14 deletions
|
@ -918,35 +918,26 @@ static void free_ffmpeg_config(ffmpeg_codec_data* data) {
|
||||||
|
|
||||||
if (data->packet) {
|
if (data->packet) {
|
||||||
av_packet_unref(data->packet);
|
av_packet_unref(data->packet);
|
||||||
av_free(data->packet);
|
av_freep(&(data->packet));
|
||||||
data->packet = NULL;
|
|
||||||
}
|
}
|
||||||
if (data->frame) {
|
if (data->frame) {
|
||||||
av_frame_unref(data->frame);
|
av_frame_unref(data->frame);
|
||||||
av_free(data->frame);
|
av_freep(&(data->frame));
|
||||||
data->frame = NULL;
|
|
||||||
}
|
}
|
||||||
if (data->codecCtx) {
|
if (data->codecCtx) {
|
||||||
avcodec_close(data->codecCtx);
|
|
||||||
avcodec_free_context(&data->codecCtx);
|
avcodec_free_context(&data->codecCtx);
|
||||||
data->codecCtx = NULL;
|
|
||||||
}
|
}
|
||||||
if (data->formatCtx) {
|
if (data->formatCtx) {
|
||||||
avformat_close_input(&data->formatCtx);
|
avformat_close_input(&data->formatCtx);
|
||||||
//avformat_free_context(data->formatCtx); /* done in close_input */
|
|
||||||
data->formatCtx = NULL;
|
|
||||||
}
|
}
|
||||||
if (data->ioCtx) {
|
if (data->ioCtx) {
|
||||||
/* buffer passed in is occasionally freed and replaced.
|
/* buffer passed in is occasionally freed and replaced.
|
||||||
* the replacement must be free'd as well (below) */
|
* the replacement must be free'd as well (below) */
|
||||||
data->buffer = data->ioCtx->buffer;
|
data->buffer = data->ioCtx->buffer;
|
||||||
avio_context_free(&data->ioCtx);
|
avio_context_free(&data->ioCtx);
|
||||||
//av_free(data->ioCtx); /* done in context_free (same thing) */
|
|
||||||
data->ioCtx = NULL;
|
|
||||||
}
|
}
|
||||||
if (data->buffer) {
|
if (data->buffer) {
|
||||||
av_free(data->buffer);
|
av_freep(&(data->buffer));
|
||||||
data->buffer = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo avformat_find_stream_info may cause some Win Handle leaks? related to certain option
|
//todo avformat_find_stream_info may cause some Win Handle leaks? related to certain option
|
||||||
|
@ -959,8 +950,7 @@ void free_ffmpeg(ffmpeg_codec_data* data) {
|
||||||
free_ffmpeg_config(data);
|
free_ffmpeg_config(data);
|
||||||
|
|
||||||
if (data->header_block) {
|
if (data->header_block) {
|
||||||
av_free(data->header_block);
|
av_freep(&(data->header_block));
|
||||||
data->header_block = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close_streamfile(data->sf);
|
close_streamfile(data->sf);
|
||||||
|
|
Loading…
Reference in a new issue