]> git.sesse.net Git - vlc/commitdiff
* modules/mux/ogg.c, modules/codec/theora.c: changes for theora alpha 3 support ...
authorGildas Bazin <gbazin@videolan.org>
Wed, 28 Apr 2004 20:02:13 +0000 (20:02 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 28 Apr 2004 20:02:13 +0000 (20:02 +0000)
modules/codec/theora.c
modules/mux/ogg.c

index b5ea3761d020760caf94358a7f0a11d407917cc0..9392fd9025c8420b4a6818afbcefc96093427133 100644 (file)
@@ -492,22 +492,26 @@ static int OpenEncoder( vlc_object_t *p_this )
     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 )
     {
@@ -625,7 +629,7 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict )
     /* 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;
 }
index 2d5e81a4d51fd2d172761ea97691ed1affa688ed..0ad04d2481f41f3b060b1055a42a82703950760b 100644 (file)
@@ -328,6 +328,14 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
     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' ):
@@ -352,7 +360,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
             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 );
@@ -597,7 +606,8 @@ static block_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
             /* 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;
@@ -909,9 +919,11 @@ static int Mux( sout_mux_t *p_mux )
         {
             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) /