* modules/codec/theora.c, modules/mux/ogg.c: proper granulepos generation for theora streams.
* modules/mux/ogg.c: ignore pts from headers.
* theora.c: theora decoder module making use of libtheora.
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: theora.c,v 1.11 2003/10/09 11:48:41 gbazin Exp $
+ * $Id: theora.c,v 1.12 2003/10/09 18:53:00 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
/* Ogg packet to block */
p_block = block_New( p_enc, oggpacket.bytes );
memcpy( p_block->p_buffer, oggpacket.packet, oggpacket.bytes );
- p_block->i_dts = p_pict->date;//oggpacket.granulepos;
+ p_block->i_dts = p_block->i_pts = p_pict->date;;
return p_block;
}
* ogg.c: ogg muxer module for vlc
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: ogg.c,v 1.15 2003/10/09 11:48:41 gbazin Exp $
+ * $Id: ogg.c,v 1.16 2003/10/09 18:53:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
sout_buffer_t *p_buf;
p_buf = sout_FifoShow( p_fifo );
+ if( p_buf->i_dts ) // To ignore vorbis and theora header packets
if( i_stream < 0 || p_buf->i_dts < i_dts )
{
i_dts = p_buf->i_dts;
mtime_t i_length;
int i_packet_no;
int i_serial_no;
+ int i_keyframe_granule_shift; /* Theora only */
ogg_stream_state os;
oggds_header_t oggds_header;
}
p_og = sout_BufferDuplicate( p_mux->p_sout,
p_stream->pp_sout_headers[0] );
+
+ /* Get keyframe_granule_shift for theora granulepos calculation */
+ if( p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
+ {
+ int i_keyframe_frequency_force = 1 << (op.packet[36] >> 3);
+
+ /* granule_shift = i_log( frequency_force -1 ) */
+ p_stream->i_keyframe_granule_shift = 0;
+ i_keyframe_frequency_force--;
+ while( i_keyframe_frequency_force )
+ {
+ p_stream->i_keyframe_granule_shift++;
+ i_keyframe_frequency_force >>= 1;
+ }
+ }
}
else
{
{
if( p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
{
- op.granulepos = op.packetno; /* FIXME */
+ /* FIXME, we assume only keyframes and 25fps */
+ op.granulepos = ( ( i_dts - p_sys->i_start_dts ) * I64C(25)
+ / I64C(1000000) ) << p_stream->i_keyframe_granule_shift;
}
else
op.granulepos = ( i_dts - p_sys->i_start_dts ) * I64C(10) /
* transcode.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: transcode.c,v 1.39 2003/10/09 12:31:05 gbazin Exp $
+ * $Id: transcode.c,v 1.40 2003/10/09 18:53:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
/* find encoder */
- id->ff_enc = NULL;
+ id->ff_enc = id->ff_enc_c = NULL;
i_ff_codec = get_ff_codec( id->f_dst.i_fourcc );
if( i_ff_codec != 0 )
{
}
free( id->ff_dec_c );
- free( id->ff_enc_c );
+ if( id->ff_enc_c ) free( id->ff_enc_c );
free( id->p_buffer );
}
}
/* Set the pts of the frame being encoded (segfaults with mpeg4!)*/
- if( id->f_dst.i_fourcc == VLC_FOURCC( 'm', 'p', 'g', 'v' ) )
+ if( id->p_encoder ||
+ id->f_dst.i_fourcc == VLC_FOURCC( 'm', 'p', 'g', 'v' ) )
frame->pts = p_sys->i_output_pts;
else
frame->pts = 0;
sout_buffer_t *p_out;
p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer );
memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
+ p_out->i_dts = p_block->i_dts;
+ p_out->i_pts = p_block->i_pts;
sout_BufferChain( out, p_out );
block_Release( p_block );
}