]> git.sesse.net Git - vlc/blobdiff - modules/mux/ogg.c
Revert "MKV: Always set an i_pts in a lace otherwise it disturbs seeking performance"
[vlc] / modules / mux / ogg.c
index d91418cee13807beb3b22af30e53618d7c874d3d..45b6846dc6c3155f9a9ea9069a8c9e47ed045b23 100644 (file)
@@ -75,7 +75,7 @@ vlc_module_end ()
  *****************************************************************************/
 static int Control  ( sout_mux_t *, int, va_list );
 static int AddStream( sout_mux_t *, sout_input_t * );
-static int DelStream( sout_mux_t *, sout_input_t * );
+static void DelStream( sout_mux_t *, sout_input_t * );
 static int Mux      ( sout_mux_t * );
 static int MuxBlock ( sout_mux_t *, sout_input_t * );
 
@@ -152,7 +152,7 @@ typedef struct
     mtime_t i_length;
     int     i_packet_no;
     int     i_serial_no;
-    int     i_keyframe_granule_shift; /* Theora only */
+    int     i_keyframe_granule_shift; /* Theora and Daala only */
     int     i_last_keyframe; /* dirac and theora */
     int     i_num_frames; /* Theora only */
     uint64_t u_last_granulepos; /* Used for correct EOS page */
@@ -381,8 +381,9 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
             !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;
+            assert(p_input->p_fmt == &p_input->fmt);
+            p_input->fmt.video.i_frame_rate = 25;
+            p_input->fmt.video.i_frame_rate_base = 1;
         }
 
         switch( p_stream->i_fourcc )
@@ -439,6 +440,10 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
             msg_Dbg( p_mux, "theora stream" );
             break;
 
+        case VLC_CODEC_DAALA:
+            msg_Dbg( p_mux, "daala stream" );
+            break;
+
         case VLC_CODEC_VP8:
             msg_Dbg( p_mux, "VP8 stream" );
             break;
@@ -550,7 +555,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
 /*****************************************************************************
  * DelStream: Delete an elementary stream from the muxed stream
  *****************************************************************************/
-static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
+static void DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
 {
     sout_mux_sys_t *p_sys  = p_mux->p_sys;
     ogg_stream_t   *p_stream = (ogg_stream_t*)p_input->p_sys;
@@ -591,8 +596,6 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
     }
 
     p_input->p_sys = NULL;
-
-    return 0;
 }
 
 /*****************************************************************************
@@ -746,6 +749,9 @@ static void OggGetSkeletonFisbone( uint8_t **pp_buffer, long *pi_size,
         case VLC_CODEC_THEORA:
             psz_value = "video/theora";
             break;
+        case VLC_CODEC_DAALA:
+            psz_value = "video/daala";
+            break;
         case VLC_CODEC_SPEEX:
             psz_value = "audio/speex";
             break;
@@ -763,7 +769,7 @@ static void OggGetSkeletonFisbone( uint8_t **pp_buffer, long *pi_size,
             break;
         default:
             psz_value = "application/octet-stream";
-            msg_Warn( p_mux, "Unkown fourcc for stream %s, setting Content-Type to %s",
+            msg_Warn( p_mux, "Unknown fourcc for stream %s, setting Content-Type to %s",
                   vlc_fourcc_GetDescription( p_stream->i_cat, p_stream->i_fourcc ),
                   psz_value );
     }
@@ -837,12 +843,14 @@ static void OggGetSkeletonFisbone( uint8_t **pp_buffer, long *pi_size,
     if ( p_input->p_fmt->p_extra )
         SetDWLE( &(*pp_buffer)[44], xiph_CountHeaders( p_input->p_fmt->p_extra, p_input->p_fmt->i_extra ) );
 
-    psz_header = *pp_buffer + FISBONE_BASE_SIZE;
-    memcpy( psz_header, headers.psz_content_type, strlen( headers.psz_content_type ) );
-    psz_header += strlen( headers.psz_content_type );
-    if ( headers.psz_role )
-        memcpy( psz_header, headers.psz_role, strlen( headers.psz_role ) );
-
+    if ( headers.i_size > 0 )
+    {
+        psz_header = *pp_buffer + FISBONE_BASE_SIZE;
+        memcpy( psz_header, headers.psz_content_type, strlen( headers.psz_content_type ) );
+        psz_header += strlen( headers.psz_content_type );
+        if ( headers.psz_role )
+            memcpy( psz_header, headers.psz_role, strlen( headers.psz_role ) );
+    }
     *pi_size = FISBONE_BASE_SIZE + headers.i_size;
 
     free( headers.psz_content_type );
@@ -906,7 +914,7 @@ static int32_t OggFillDsHeader( uint8_t *p_buffer, oggds_header_t *p_oggds_heade
     /* extra header */
     if( p_oggds_header->i_size > 0 )
     {
-        memcpy( &p_buffer[index], p_oggds_header + sizeof(*p_oggds_header), p_oggds_header->i_size );
+        memcpy( &p_buffer[index], (uint8_t *) p_oggds_header + sizeof(*p_oggds_header), p_oggds_header->i_size );
         index += p_oggds_header->i_size;
     }
 
@@ -992,7 +1000,9 @@ static bool OggCreateHeaders( sout_mux_t *p_mux )
             sout_input_t *p_input = p_mux->pp_inputs[i];
             p_stream = (ogg_stream_t*)p_input->p_sys;
 
-            bool video = ( p_stream->i_fourcc == VLC_CODEC_THEORA || p_stream->i_fourcc == VLC_CODEC_DIRAC );
+            bool video = ( p_stream->i_fourcc == VLC_CODEC_THEORA ||
+                           p_stream->i_fourcc == VLC_CODEC_DIRAC ||
+                           p_stream->i_fourcc == VLC_CODEC_DAALA );
             if( ( ( pass == 0 && !video ) || ( pass == 1 && video ) ) )
                 continue;
 
@@ -1007,9 +1017,10 @@ static bool OggCreateHeaders( sout_mux_t *p_mux )
             if( p_stream->i_fourcc == VLC_CODEC_VORBIS ||
                 p_stream->i_fourcc == VLC_CODEC_SPEEX ||
                 p_stream->i_fourcc == VLC_CODEC_OPUS ||
-                p_stream->i_fourcc == VLC_CODEC_THEORA )
+                p_stream->i_fourcc == VLC_CODEC_THEORA ||
+                p_stream->i_fourcc == VLC_CODEC_DAALA )
             {
-                /* First packet in order: vorbis/speex/theora info */
+                /* First packet in order: vorbis/speex/opus/theora/daala info */
                 unsigned pi_size[XIPH_MAX_HEADER_COUNT];
                 void     *pp_data[XIPH_MAX_HEADER_COUNT];
                 unsigned i_count;
@@ -1033,8 +1044,9 @@ static bool OggCreateHeaders( sout_mux_t *p_mux )
                 ogg_stream_packetin( &p_stream->os, &op );
                 p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
 
-                /* Get keyframe_granule_shift for theora granulepos calculation */
-                if( p_stream->i_fourcc == VLC_CODEC_THEORA )
+                /* Get keyframe_granule_shift for theora or daala granulepos calculation */
+                if( p_stream->i_fourcc == VLC_CODEC_THEORA ||
+                    p_stream->i_fourcc == VLC_CODEC_DAALA )
                 {
                     p_stream->i_keyframe_granule_shift =
                         ( (op.packet[40] & 0x03) << 3 ) | ( (op.packet[41] & 0xe0) >> 5 );
@@ -1170,7 +1182,8 @@ static bool OggCreateHeaders( sout_mux_t *p_mux )
         if( p_stream->i_fourcc == VLC_CODEC_VORBIS ||
             p_stream->i_fourcc == VLC_CODEC_SPEEX ||
             p_stream->i_fourcc == VLC_CODEC_OPUS ||
-            p_stream->i_fourcc == VLC_CODEC_THEORA )
+            p_stream->i_fourcc == VLC_CODEC_THEORA ||
+            p_stream->i_fourcc == VLC_CODEC_DAALA )
         {
             unsigned pi_size[XIPH_MAX_HEADER_COUNT];
             void     *pp_data[XIPH_MAX_HEADER_COUNT];
@@ -1571,6 +1584,7 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
         p_stream->i_fourcc != VLC_CODEC_SPEEX &&
         p_stream->i_fourcc != VLC_CODEC_OPUS &&
         p_stream->i_fourcc != VLC_CODEC_THEORA &&
+        p_stream->i_fourcc != VLC_CODEC_DAALA &&
         p_stream->i_fourcc != VLC_CODEC_VP8 &&
         p_stream->i_fourcc != VLC_CODEC_DIRAC )
     {
@@ -1612,7 +1626,8 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
     }
     else if( p_stream->i_cat == VIDEO_ES )
     {
-        if( p_stream->i_fourcc == VLC_CODEC_THEORA )
+        if( p_stream->i_fourcc == VLC_CODEC_THEORA ||
+            p_stream->i_fourcc == VLC_CODEC_DAALA )
         {
             p_stream->i_num_frames++;
             if( p_data->i_flags & BLOCK_FLAG_TYPE_I )