return VLC_SUCCESS;
}
-static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
-{
- mtime_t i_dts;
- int i_stream, i;
-
- for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
- {
- block_fifo_t *p_fifo = p_mux->pp_inputs[i]->p_fifo;
- block_t *p_buf;
-
- if( block_FifoCount( p_fifo ) <= 1 )
- {
- if( p_mux->pp_inputs[i]->p_fmt->i_cat != SPU_ES )
- {
- return -1; // wait that all fifo have at least 2 packets
- }
- /* For SPU, we wait only 1 packet */
- continue;
- }
-
- p_buf = block_FifoShow( p_fifo );
- if( i_stream < 0 || p_buf->i_dts < i_dts )
- {
- i_dts = p_buf->i_dts;
- i_stream = i;
- }
- }
- if( pi_stream )
- {
- *pi_stream = i_stream;
- }
- if( pi_dts )
- {
- *pi_dts = i_dts;
- }
- return i_stream;
-}
-
/*****************************************************************************
* Mux:
*****************************************************************************/
for( ;; )
{
sout_input_t *p_input;
- int i_stream;
mp4_stream_t *p_stream;
block_t *p_data;
mtime_t i_dts;
- if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
+ int i_stream = sout_MuxGetStream( p_mux, 2, &i_dts);
+ if( i_stream < 0 )
{
return( VLC_SUCCESS );
}
if( p_stream->i_entry_count >= p_stream->i_entry_max - 1 )
{
p_stream->i_entry_max += 1000;
- p_stream->entry =
- realloc( p_stream->entry,
+ p_stream->entry = xrealloc( p_stream->entry,
p_stream->i_entry_max * sizeof( mp4_entry_t ) );
}
else if( p_stream->fmt.i_cat == VIDEO_ES )
{
int i_width = p_stream->fmt.video.i_width << 16;
- if( p_stream->fmt.video.i_aspect > 0 )
+ if( p_stream->fmt.video.i_sar_num > 0 &&
+ p_stream->fmt.video.i_sar_den > 0 )
{
- i_width = (int64_t)p_stream->fmt.video.i_aspect *
- ((int64_t)p_stream->fmt.video.i_height << 16) /
- VOUT_ASPECT_FACTOR;
+ i_width = (int64_t)p_stream->fmt.video.i_sar_num *
+ ((int64_t)p_stream->fmt.video.i_width << 16) /
+ p_stream->fmt.video.i_sar_den;
}
// width (presentation)
bo_add_32be( tkhd, i_width );
mp4_stream_t *tk = p_sys->pp_streams[i];
if( tk->fmt.i_cat == VIDEO_ES )
{
- if( p_stream->fmt.video.i_aspect )
- i_width = (int64_t)p_stream->fmt.video.i_aspect *
- ((int64_t)p_stream->fmt.video.i_height<<16) / VOUT_ASPECT_FACTOR;
+ if( tk->fmt.video.i_sar_num > 0 &&
+ tk->fmt.video.i_sar_den > 0 )
+ i_width = (int64_t)tk->fmt.video.i_sar_num *
+ ((int64_t)tk->fmt.video.i_width << 16) /
+ tk->fmt.video.i_sar_den;
else
- i_width = p_stream->fmt.video.i_width << 16;
- i_height = p_stream->fmt.video.i_height;
+ i_width = tk->fmt.video.i_width << 16;
+ i_height = tk->fmt.video.i_height;
break;
}
}
if( !p_buffer )
{
p_bo->i_buffer_size = __MAX( i_size, 1024 );
- p_bo->p_buffer = malloc( p_bo->i_buffer_size );
+ p_bo->p_buffer = xmalloc( p_bo->i_buffer_size );
}
else
{
else if( p_bo->b_grow )
{
p_bo->i_buffer_size += 1024;
- p_bo->p_buffer = realloc( p_bo->p_buffer, p_bo->i_buffer_size );
-
+ p_bo->p_buffer = xrealloc( p_bo->p_buffer, p_bo->i_buffer_size );
p_bo->p_buffer[p_bo->i_buffer] = i;
}