Commit 35bd842a authored by Gildas Bazin's avatar Gildas Bazin

* modules/stream_out/transcode.c: couple of fixes.
* modules/codec/theora.c, modules/mux/ogg.c: proper granulepos generation for theora streams.
* modules/mux/ogg.c: ignore pts from headers.
parent 0bb8f399
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* theora.c: theora decoder module making use of libtheora. * theora.c: theora decoder module making use of libtheora.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -696,7 +696,7 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict ) ...@@ -696,7 +696,7 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict )
/* Ogg packet to block */ /* Ogg packet to block */
p_block = block_New( p_enc, oggpacket.bytes ); p_block = block_New( p_enc, oggpacket.bytes );
memcpy( p_block->p_buffer, oggpacket.packet, 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; return p_block;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ogg.c: ogg muxer module for vlc * ogg.c: ogg muxer module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com> * Gildas Bazin <gbazin@netcourrier.com>
...@@ -174,6 +174,7 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts ) ...@@ -174,6 +174,7 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
sout_buffer_t *p_buf; sout_buffer_t *p_buf;
p_buf = sout_FifoShow( p_fifo ); 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 ) if( i_stream < 0 || p_buf->i_dts < i_dts )
{ {
i_dts = p_buf->i_dts; i_dts = p_buf->i_dts;
...@@ -211,6 +212,7 @@ typedef struct ...@@ -211,6 +212,7 @@ typedef struct
mtime_t i_length; mtime_t i_length;
int i_packet_no; int i_packet_no;
int i_serial_no; int i_serial_no;
int i_keyframe_granule_shift; /* Theora only */
ogg_stream_state os; ogg_stream_state os;
oggds_header_t oggds_header; oggds_header_t oggds_header;
...@@ -606,6 +608,21 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts ) ...@@ -606,6 +608,21 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
} }
p_og = sout_BufferDuplicate( p_mux->p_sout, p_og = sout_BufferDuplicate( p_mux->p_sout,
p_stream->pp_sout_headers[0] ); 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 else
{ {
...@@ -866,7 +883,9 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -866,7 +883,9 @@ static int Mux( sout_mux_t *p_mux )
{ {
if( p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) ) 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 else
op.granulepos = ( i_dts - p_sys->i_start_dts ) * I64C(10) / op.granulepos = ( i_dts - p_sys->i_start_dts ) * I64C(10) /
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* transcode.c * transcode.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -1223,7 +1223,7 @@ static int transcode_video_ffmpeg_new( sout_stream_t *p_stream, ...@@ -1223,7 +1223,7 @@ static int transcode_video_ffmpeg_new( sout_stream_t *p_stream,
/* find encoder */ /* 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 ); i_ff_codec = get_ff_codec( id->f_dst.i_fourcc );
if( i_ff_codec != 0 ) if( i_ff_codec != 0 )
{ {
...@@ -1395,7 +1395,7 @@ static void transcode_video_ffmpeg_close ( sout_stream_t *p_stream, sout_stream_ ...@@ -1395,7 +1395,7 @@ static void transcode_video_ffmpeg_close ( sout_stream_t *p_stream, sout_stream_
} }
free( id->ff_dec_c ); free( id->ff_dec_c );
free( id->ff_enc_c ); if( id->ff_enc_c ) free( id->ff_enc_c );
free( id->p_buffer ); free( id->p_buffer );
} }
...@@ -1637,7 +1637,8 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1637,7 +1637,8 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
} }
/* Set the pts of the frame being encoded (segfaults with mpeg4!)*/ /* 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; frame->pts = p_sys->i_output_pts;
else else
frame->pts = 0; frame->pts = 0;
...@@ -1675,6 +1676,8 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1675,6 +1676,8 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
sout_buffer_t *p_out; sout_buffer_t *p_out;
p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer ); 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); 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 ); sout_BufferChain( out, p_out );
block_Release( p_block ); block_Release( p_block );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment