[MPlayer-cvslog] r38399 - in trunk: libmpdemux/muxer.c libmpdemux/muxer.h mencoder.c
reimar
subversion at mplayerhq.hu
Tue Aug 30 23:26:51 EEST 2022
Author: reimar
Date: Tue Aug 30 23:26:51 2022
New Revision: 38399
Log:
mencoder.c/muxer.c: add functions to close and free muxer.
Makes behaviour clearer than mencoder using
low-level functions directly and frees some
more memory before exit to make leaks easier
to spot.
Modified:
trunk/libmpdemux/muxer.c
trunk/libmpdemux/muxer.h
trunk/mencoder.c
Modified: trunk/libmpdemux/muxer.c
==============================================================================
--- trunk/libmpdemux/muxer.c Tue Aug 30 22:48:45 2022 (r38398)
+++ trunk/libmpdemux/muxer.c Tue Aug 30 23:26:51 2022 (r38399)
@@ -69,6 +69,34 @@ fail:
return NULL;
}
+off_t muxer_close(muxer_t *muxer)
+{
+ off_t size;
+ /* flush muxer just in case, this is a no-op unless
+ * we created a stream but never wrote frames to it... */
+ muxer_flush(muxer);
+ if (muxer->cont_write_index) muxer_write_index(muxer);
+ size=stream_tell(muxer->stream);
+ stream_seek(muxer->stream,0);
+ if (muxer->cont_write_header) muxer_write_header(muxer); // update header
+ return size;
+}
+
+void muxer_free(muxer_t *muxer)
+{
+ int num;
+ for (num = 0; muxer->streams[num]; ++num) {
+ free(muxer->streams[num]->priv);
+ muxer->streams[num]->priv = NULL;
+ free(muxer->streams[num]);
+ muxer->streams[num] = NULL;
+ }
+ free(muxer->idx);
+ muxer->idx = NULL;
+ muxer->idx_size = 0;
+ free(muxer);
+}
+
/* Flush the internal muxer buffer.
* This is normally called from muxer_write_chunk() once all streams
* have seen frames. */
Modified: trunk/libmpdemux/muxer.h
==============================================================================
--- trunk/libmpdemux/muxer.h Tue Aug 30 22:48:45 2022 (r38398)
+++ trunk/libmpdemux/muxer.h Tue Aug 30 23:26:51 2022 (r38399)
@@ -133,6 +133,8 @@ extern const m_option_t mpegopts_conf[];
extern const m_option_t nuvopts_conf[];
muxer_t *muxer_new_muxer(int type,stream_t *stream);
+off_t muxer_close(muxer_t *muxer);
+void muxer_free(muxer_t *muxer);
void muxer_flush(muxer_t *m);
#define muxer_new_stream(muxer,a) muxer->cont_new_stream(muxer,a)
#define muxer_stream_fix_parameters(muxer, a) muxer->fix_stream_parameters(a)
Modified: trunk/mencoder.c
==============================================================================
--- trunk/mencoder.c Tue Aug 30 22:48:45 2022 (r38398)
+++ trunk/mencoder.c Tue Aug 30 23:26:51 2022 (r38399)
@@ -1699,13 +1699,7 @@ if(aencoder)
if(aencoder->fixup)
aencoder->fixup(aencoder);
-/* flush muxer just in case, this is a no-op unless
- * we created a stream but never wrote frames to it... */
-muxer_flush(muxer);
-if (muxer->cont_write_index) muxer_write_index(muxer);
-muxer_f_size=stream_tell(muxer->stream);
-stream_seek(muxer->stream,0);
-if (muxer->cont_write_header) muxer_write_header(muxer); // update header
+muxer_f_size=muxer_close(muxer);
#if 0
if(ferror(muxer_f) || fclose(muxer_f) != 0) {
mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, out_filename);
@@ -1730,6 +1724,9 @@ if(sh_audio)
mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_AudioStreamResult,
(float)(mux_a->size/mux_a->timer*8.0f/1000.0f), (int)(mux_a->size/mux_a->timer), (uint64_t)mux_a->size, (float)mux_a->timer);
+muxer_free(muxer);
+muxer=NULL;
+mux_v=mux_a=NULL;
m_config_free(mconfig);
m_entry_list_free(filelist);
if(sh_audio){ uninit_audio(sh_audio);sh_audio=NULL; }
More information about the MPlayer-cvslog
mailing list