[vlc-devel] [PATCH] Removed unused static functions

Maxim Bublis b at codemonkey.ru
Mon Dec 2 10:14:10 CET 2013


---
 modules/demux/oggseek.c | 312 ------------------------------------------------
 1 file changed, 312 deletions(-)

diff --git a/modules/demux/oggseek.c b/modules/demux/oggseek.c
index 0f69d71..2f8c26b 100644
--- a/modules/demux/oggseek.c
+++ b/modules/demux/oggseek.c
@@ -324,142 +324,6 @@ static int64_t get_data( demux_t *p_demux, int64_t i_bytes_to_read )
     return i_result;
 }
 
-/* Find the first first ogg page for p_stream between offsets i_pos1 and i_pos2,
-   return file offset in bytes; -1 is returned on failure */
-
-static int64_t find_first_page( demux_t *p_demux, int64_t i_pos1, int64_t i_pos2,
-                                logical_stream_t *p_stream,
-                                int64_t *pi_kframe, int64_t *pi_frame )
-{
-    int64_t i_result;
-    int64_t i_granulepos;
-    int64_t i_bytes_to_read = i_pos2 - i_pos1 + 1;
-    int64_t i_bytes_read;
-    int64_t i_pages_checked = 0;
-    int64_t i_packets_checked;
-
-    demux_sys_t *p_sys  = p_demux->p_sys;
-
-    ogg_packet op;
-
-    seek_byte( p_demux, i_pos1 );
-
-    if ( i_pos1 == p_stream->i_data_start )
-    {
-        /* set a dummy granulepos at data_start */
-        *pi_kframe = p_stream->i_keyframe_offset;
-        *pi_frame = p_stream->i_keyframe_offset;
-
-        p_sys->b_page_waiting = true;
-        return p_sys->i_input_position;
-    }
-
-    if ( i_bytes_to_read > OGGSEEK_BYTES_TO_READ ) i_bytes_to_read = OGGSEEK_BYTES_TO_READ;
-
-    while ( 1 )
-    {
-
-        if ( p_sys->i_input_position >= i_pos2 )
-        {
-            /* we reached the end and found no pages */
-            *pi_frame=-1;
-            return -1;
-        }
-
-        /* read next chunk */
-        if ( ! ( i_bytes_read = get_data( p_demux, i_bytes_to_read ) ) )
-        {
-            /* EOF */
-            *pi_frame = -1;
-            return -1;
-        }
-
-        i_bytes_to_read = OGGSEEK_BYTES_TO_READ;
-
-        i_result = ogg_sync_pageseek( &p_sys->oy, &p_sys->current_page );
-
-        if ( i_result < 0 )
-        {
-            /* found a page, sync to page start */
-            p_sys->i_input_position -= i_result;
-            i_pos1 = p_sys->i_input_position;
-            continue;
-        }
-
-        if ( i_result > 0 || ( i_result == 0 && p_sys->oy.fill > 3 &&
-                               ! strncmp( (char *)p_sys->oy.data, "OggS" , 4 ) ) )
-        {
-            i_pos1 = p_sys->i_input_position;
-            break;
-        }
-
-        p_sys->i_input_position += i_bytes_read;
-
-    };
-
-    seek_byte( p_demux, p_sys->i_input_position );
-    ogg_stream_reset( &p_stream->os );
-
-    while( 1 )
-    {
-
-        if ( p_sys->i_input_position >= i_pos2 )
-        {
-            /* reached the end of the search region and nothing was found */
-            *pi_frame = -1;
-            return p_sys->i_input_position;
-        }
-
-        p_sys->b_page_waiting = false;
-
-        if ( ! ( i_result = oggseek_read_page( p_demux ) ) )
-        {
-            /* EOF */
-            *pi_frame = -1;
-            return p_sys->i_input_position;
-        }
-
-        // found a page
-        if ( p_stream->os.serialno != ogg_page_serialno( &p_sys->current_page ) )
-        {
-            /* page is not for this stream */
-            p_sys->i_input_position += i_result;
-            if ( ! i_pages_checked ) i_pos1 = p_sys->i_input_position;
-            continue;
-        }
-
-
-        ogg_stream_pagein( &p_stream->os, &p_sys->current_page );
-
-        i_pages_checked++;
-        i_packets_checked = 0;
-
-        if ( ogg_stream_packetout( &p_stream->os, &op ) > 0 )
-        {
-            i_packets_checked++;
-        }
-
-        if ( i_packets_checked )
-        {
-            i_granulepos = ogg_page_granulepos( &p_sys->current_page );
-
-            oggseek_theora_index_entry_add( p_stream, i_granulepos, i_pos1 );
-
-            *pi_kframe =
-                i_granulepos >> p_stream->i_granule_shift;
-
-            *pi_frame = *pi_kframe +
-                i_granulepos - ( *pi_kframe << p_stream->i_granule_shift );
-
-            p_sys->b_page_waiting = true;
-            return i_pos1;
-
-        }
-
-        /*  -> start of next page */
-        p_sys->i_input_position += i_result;
-    }
-}
 
 void Oggseek_ProbeEnd( demux_t *p_demux )
 {
@@ -566,182 +430,6 @@ static inline int64_t frame_to_gpos( logical_stream_t *p_stream, int64_t i_kfram
 }
 
 
-
-
-
-/* seek to a suitable point to begin decoding for i_tframe. We can pre-set bounding positions
-   i_pos_lower and i_pos_higher to narrow the search domain. */
-
-
-static int64_t ogg_seek( demux_t *p_demux, logical_stream_t *p_stream, int64_t i_tframe,
-                         int64_t i_pos_lower, int64_t i_pos_upper, int64_t *pi_pagepos,
-                         bool b_exact )
-{
-    /* For theora:
-     * We do two passes here, first with b_exact set, then with b_exact unset.
-     *
-     * If b_exact is set, we find the highest granulepos <= the target granulepos
-     * from this we extract an estimate of the keyframe (note that there could be other
-     * "hidden" keyframes between the found granulepos and the target).
-     *
-     * On the second pass we find the highest granulepos < target. This places us just before or
-     * at the start of the target keyframe.
-     *
-     * When we come to decode, we start from this second position, discarding any completed
-     * packets on that page, and read pages discarding packets until we get to the target frame.
-     *
-     * The function returns the granulepos which is found,
-     * sets the page offset in pi_pagepos. -1 is returned on error.
-     *
-     * for dirac:
-     *
-     * we find the highest sync frame <= target frame, and return the sync_frame number
-     * b_exact should be set to true
-     *
-     *
-     * the method used is bi-sections:
-     *  - we check the lower keyframe
-     * if this is == target we return
-     * if > target, or we find no keyframes, we go to the lower segment
-     * if < target we divide the segment in two and check the upper half
-     *
-     * This is then repeated until the segment size is too small to hold a packet,
-     * at which point we return our best match
-     *
-     * Two optimisations are made: - anything we discover about keyframes is added to our index
-     * - before calling this function we get approximate bounds from the index
-     *
-     * therefore, subsequent searches become more rapid.
-     *
-     */
-
-    int64_t i_start_pos;
-    int64_t i_end_pos;
-    int64_t i_pagepos;
-    int64_t i_segsize;
-    int64_t i_frame;
-    int64_t i_kframe;
-
-    int64_t i_best_kframe = -1;
-    int64_t i_best_frame = -1;
-    int64_t i_best_pagepos = -1;
-
-    demux_sys_t *p_sys  = p_demux->p_sys;
-
-    if ( i_tframe < p_stream->i_keyframe_offset )
-    {
-        *pi_pagepos = p_stream->i_data_start;
-
-        if ( ! b_exact ) {
-            seek_byte( p_demux, p_stream->i_data_start );
-            return frame_to_gpos( p_stream, p_stream->i_keyframe_offset, 1 );
-        }
-        return frame_to_gpos( p_stream, p_stream->i_keyframe_offset, 0 );
-    }
-
-    if ( i_pos_lower < p_stream->i_data_start )
-    {
-        i_pos_lower = p_stream->i_data_start;
-    }
-
-    if ( i_pos_upper < 0 )
-    {
-        i_pos_upper = p_sys->i_total_length;
-    }
-
-    if ( i_pos_upper > p_sys->i_total_length )
-    {
-        i_pos_upper = p_sys->i_total_length;
-    }
-
-    i_start_pos = i_pos_lower;
-    i_end_pos = i_pos_upper;
-
-    i_segsize = ( i_end_pos - i_start_pos + 1 ) >> 1;
-
-    do
-    {
-        /* see if the frame lies in current segment */
-        if ( i_start_pos < i_pos_lower )
-        {
-            i_start_pos = i_pos_lower;
-        }
-        if ( i_end_pos > i_pos_upper )
-        {
-            i_end_pos = i_pos_upper;
-        }
-
-        if ( i_start_pos >= i_end_pos )
-        {
-            if ( i_start_pos == i_pos_lower)
-            {
-                if ( ! b_exact ) seek_byte( p_demux, i_start_pos );
-                *pi_pagepos = i_start_pos;
-                return frame_to_gpos( p_stream, p_stream->i_keyframe_offset, 1 );
-            }
-            break;
-        }
-
-        if ( p_stream->fmt.i_codec == VLC_CODEC_THEORA || p_stream->fmt.i_codec == VLC_CODEC_OPUS )
-        {
-            i_pagepos = find_first_page( p_demux, i_start_pos, i_end_pos, p_stream,
-                                         &i_kframe, &i_frame );
-        }
-        else return -1;
-
-        if ( i_pagepos != -1 && i_kframe != -1 )
-        {
-            /* found a page */
-
-            if ( b_exact && i_frame >= i_tframe && i_kframe <= i_tframe )
-            {
-                /* got it ! */
-                *pi_pagepos = i_start_pos;
-                return frame_to_gpos( p_stream, i_kframe, i_frame );
-            }
-
-            if ( ( i_kframe < i_tframe || ( b_exact && i_kframe == i_tframe ) )
-                 && i_kframe > i_best_kframe )
-            {
-                i_best_kframe = i_kframe;
-                i_best_frame = i_frame;
-                i_best_pagepos = i_pagepos;
-            }
-
-            if ( i_frame >= i_tframe )
-            {
-                /* check lower half of segment */
-                i_start_pos -= i_segsize;
-                i_end_pos -= i_segsize;
-            }
-
-            else i_start_pos = i_pagepos;
-        }
-        else
-        {
-            /* no keyframe found, check lower segment */
-            i_end_pos -= i_segsize;
-            i_start_pos -= i_segsize;
-        }
-
-        i_segsize = ( i_end_pos - i_start_pos + 1 ) >> 1;
-        i_start_pos += i_segsize;
-
-    } while ( i_segsize > 64 );
-
-    if ( i_best_kframe >- 1 )
-    {
-        if ( !b_exact )
-        {
-            seek_byte( p_demux, i_best_pagepos );
-        }
-        *pi_pagepos = i_best_pagepos;
-        return frame_to_gpos( p_stream, i_best_kframe, i_best_frame );
-    }
-
-    return -1;
-}
-
 static int64_t find_first_page_granule( demux_t *p_demux,
                                 int64_t i_pos1, int64_t i_pos2,
                                 logical_stream_t *p_stream,
-- 
1.8.3.4 (Apple Git-47)




More information about the vlc-devel mailing list