if( i_quality > 10 ) i_quality = 10;
if( i_quality < 0 ) i_quality = 0;
-#define frame_x_offset 0
-#define frame_y_offset 0
-#define video_hzn 25
-#define video_hzd 1
-#define video_q 5
-
theora_info_init( &p_sys->ti );
p_sys->ti.width = p_enc->fmt_in.video.i_width;
p_sys->ti.height = p_enc->fmt_in.video.i_height;
p_sys->ti.frame_width = p_enc->fmt_in.video.i_width;
p_sys->ti.frame_height = p_enc->fmt_in.video.i_height;
- p_sys->ti.offset_x = frame_x_offset;
- p_sys->ti.offset_y = frame_y_offset;
- p_sys->ti.fps_numerator = video_hzn;
- p_sys->ti.fps_denominator = video_hzd;
+ p_sys->ti.offset_x = 0 /*frame_x_offset*/;
+ p_sys->ti.offset_y = 0/*frame_y_offset*/;
+
+ if( !p_enc->fmt_in.video.i_frame_rate ||
+ !p_enc->fmt_in.video.i_frame_rate_base )
+ {
+ p_sys->ti.fps_numerator = 25;
+ p_sys->ti.fps_denominator = 1;
+ }
+ else
+ {
+ p_sys->ti.fps_numerator = p_enc->fmt_in.video.i_frame_rate;
+ p_sys->ti.fps_denominator = p_enc->fmt_in.video.i_frame_rate_base;
+ }
if( p_enc->fmt_in.video.i_aspect )
{
/* 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_block->i_pts = p_pict->date;;
+ p_block->i_dts = p_block->i_pts = p_pict->date;
return p_block;
}
switch( p_input->p_fmt->i_cat )
{
case VIDEO_ES:
+ if( !p_input->p_fmt->video.i_frame_rate ||
+ !p_input->p_fmt->video.i_frame_rate_base )
+ {
+ msg_Warn( p_mux, "Missing frame rate, assuming 25fps" );
+ p_input->p_fmt->video.i_frame_rate = 25;
+ p_input->p_fmt->video.i_frame_rate_base = 1;
+ }
+
switch( p_stream->i_fourcc )
{
case VLC_FOURCC( 'm', 'p', 'g', 'v' ):
SetDWLE( &p_stream->oggds_header.i_size,
sizeof( oggds_header_t ) - 1);
SetQWLE( &p_stream->oggds_header.i_time_unit,
- I64C(10000000)/(int64_t)25 ); // FIXME (25fps)
+ I64C(10000000) * p_input->p_fmt->video.i_frame_rate_base /
+ (int64_t)p_input->p_fmt->video.i_frame_rate );
SetQWLE( &p_stream->oggds_header.i_samples_per_unit, 1 );
SetDWLE( &p_stream->oggds_header.i_default_len, 1 ); /* ??? */
SetDWLE( &p_stream->oggds_header.i_buffer_size, 1024*1024 );
/* 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);
+ int i_keyframe_frequency_force =
+ 1 << ((op.packet[40] << 6 >> 3) | (op.packet[41] >> 5));
/* granule_shift = i_log( frequency_force -1 ) */
p_stream->i_keyframe_granule_shift = 0;
{
if( p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
{
- /* 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;
+ /* FIXME, we assume only keyframes */
+ op.granulepos = ( ( i_dts - p_sys->i_start_dts ) *
+ p_input->p_fmt->video.i_frame_rate /
+ p_input->p_fmt->video.i_frame_rate_base /
+ I64C(1000000) ) << p_stream->i_keyframe_granule_shift;
}
else
op.granulepos = ( i_dts - p_sys->i_start_dts ) * I64C(10) /