[MPlayer-cvslog] r37200 - trunk/libmpdemux/demux_real.c

reimar subversion at mplayerhq.hu
Tue May 13 23:06:39 CEST 2014


Author: reimar
Date: Tue May 13 23:06:38 2014
New Revision: 37200

Log:
demux_real: Improve buffer allocation for interleaved audio handling.

Allocate buffers where they are needed.
This avoids code duplication, allocating them when they are not
needed, and might avoid a crash if an audio stream is specified
via -aid that does not exist in the headers but does exist in the
file since then we might run the deinterleaving without having
the buffers allocated first (note: I have not tested this can
actually happen).

Modified:
   trunk/libmpdemux/demux_real.c

Modified: trunk/libmpdemux/demux_real.c
==============================================================================
--- trunk/libmpdemux/demux_real.c	Sun May 11 01:48:24 2014	(r37199)
+++ trunk/libmpdemux/demux_real.c	Tue May 13 23:06:38 2014	(r37200)
@@ -744,6 +744,10 @@ got_audio:
         if ((priv->intl_id[demuxer->audio->id] == mmioFOURCC('I', 'n', 't', '4')) ||
             (priv->intl_id[demuxer->audio->id] == mmioFOURCC('g', 'e', 'n', 'r')) ||
             (priv->intl_id[demuxer->audio->id] == mmioFOURCC('s', 'i', 'p', 'r'))) {
+            if (!priv->audio_buf) {
+                priv->audio_buf = calloc(priv->sub_packet_h[demuxer->audio->id], priv->audiopk_size[demuxer->audio->id]);
+                priv->audio_timestamp = calloc(priv->sub_packet_h[demuxer->audio->id], sizeof(double));
+            }
             sps = priv->sub_packet_size[demuxer->audio->id];
             sph = priv->sub_packet_h[demuxer->audio->id];
             cfs = priv->coded_framesize[demuxer->audio->id];
@@ -1078,8 +1082,6 @@ if((unsigned)rm_stream_id<MAX_STREAMS){
 	sh_audio_t *sh = demuxer->a_streams[mp_stream_id];
 	demuxer->audio->id=mp_stream_id;
 	demuxer->audio->sh=sh;
-	priv->audio_buf = calloc(priv->sub_packet_h[demuxer->audio->id], priv->audiopk_size[demuxer->audio->id]);
-	priv->audio_timestamp = calloc(priv->sub_packet_h[demuxer->audio->id], sizeof(double));
         mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected RM audio ID = %d (rm id %d)\n",mp_stream_id, rm_stream_id);
 	goto got_audio;
     }
@@ -1509,8 +1511,6 @@ static demuxer_t* demux_open_real(demuxe
 
 		    if(demuxer->audio->id==stream_id){
 			demuxer->audio->sh=sh;
-        	priv->audio_buf = calloc(priv->sub_packet_h[demuxer->audio->id], priv->audiopk_size[demuxer->audio->id]);
-        	priv->audio_timestamp = calloc(priv->sub_packet_h[demuxer->audio->id], sizeof(double));
 		    }
 
 		    ++a_streams;


More information about the MPlayer-cvslog mailing list