changeset 1643:76835bed88ca

free demux/ds/sh
author arpi
date Wed, 22 Aug 2001 23:54:57 +0000
parents 78fa0713b823
children 6591cd06b356
files demuxer.c demuxer.h
diffstat 2 files changed, 36 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/demuxer.c	Wed Aug 22 23:54:38 2001 +0000
+++ b/demuxer.c	Wed Aug 22 23:54:57 2001 +0000
@@ -21,6 +21,11 @@
 #include "codec-cfg.h"
 #include "stheader.h"
 
+void free_demuxer_stream(demux_stream_t *ds){
+    ds_free_packs(ds);
+    free(ds);
+}
+
 demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id){
   demux_stream_t* ds=malloc(sizeof(demux_stream_t));
   ds->buffer_pos=ds->buffer_size=0;
@@ -74,6 +79,13 @@
     return demuxer->a_streams[id];
 }
 
+void free_sh_audio(sh_audio_t* sh){
+    if(sh->a_in_buffer) free(sh->a_in_buffer);
+    if(sh->a_buffer) free(sh->a_buffer);
+    if(sh->wf) free(sh->wf);
+    free(sh);
+}
+
 sh_video_t* new_sh_video(demuxer_t *demuxer,int id){
     if(demuxer->v_streams[id]){
         mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_VideoStreamRedefined,id);
@@ -85,6 +97,27 @@
     return demuxer->v_streams[id];
 }
 
+void free_sh_video(sh_video_t* sh){
+//    if(sh->our_out_buffer) free(sh->our_out_buffer);
+//    if(sh->bih) free(sh->bih);
+    free(sh);
+}
+
+void free_demuxer(demuxer_t *demuxer){
+    int i;
+    // free streams:
+    for(i=0;i<256;i++){
+	if(demuxer->a_streams[i]) free_sh_audio(demuxer->a_streams[i]);
+	if(demuxer->v_streams[i]) free_sh_video(demuxer->v_streams[i]);
+    }
+    //if(sh_audio) free_sh_audio(sh_audio);
+    //if(sh_video) free_sh_video(sh_video);
+    // free demuxers:
+    free_demuxer_stream(demuxer->audio);
+    free_demuxer_stream(demuxer->video);
+    free(demuxer);
+}
+
 
 void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp){
 //    demux_packet_t* dp=new_demux_packet(len);
@@ -481,8 +514,6 @@
 return demuxer;
 }
 
-
-
 int demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags);
 int demux_seek_asf(demuxer_t *demuxer,float rel_seek_secs,int flags);
 int demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags);
--- a/demuxer.h	Wed Aug 22 23:54:38 2001 +0000
+++ b/demuxer.h	Wed Aug 22 23:54:57 2001 +0000
@@ -94,6 +94,8 @@
 
 demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id);
 demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id);
+void free_demuxer_stream(demux_stream_t *ds);
+void free_demuxer(demuxer_t *demuxer);
 
 void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp);
 void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,off_t pos,int flags);
@@ -150,3 +152,4 @@
 int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
 
 
+