oggseek.h 2.8 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*****************************************************************************
 * oggseek.h : ogg seeking functions for ogg demuxer vlc
 *****************************************************************************
 * Copyright (C) 2008 - 2010 Gabriel Finch <salsaman@gmail.com>
 *
 * Authors: Gabriel Finch <salsaman@gmail.com>
 * adapted from: http://lives.svn.sourceforge.net/viewvc/lives/trunk/lives-plugins
 * /plugins/decoders/ogg_theora_decoder.c
 *
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
10 11 12
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
13 14 15 16
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
17 18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
19
 *
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
20 21 22
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/

#define PAGE_HEADER_BYTES 27

#define OGGSEEK_BYTES_TO_READ 8500

/* index entries are structured as follows:
 *   - for theora, highest granulepos -> pagepos (bytes) where keyframe begins
 *  - for dirac, kframe (sync point) -> pagepos of sequence start (?)
 */

/* this is typedefed to demux_index_entry_t in ogg.h */
struct oggseek_index_entry
{
    demux_index_entry_t *p_next;
    demux_index_entry_t *p_prev;

    /* value is highest granulepos for theora, sync frame for dirac */
    int64_t i_value;
    int64_t i_pagepos;

    /* not used for theora because the granulepos tells us this */
    int64_t i_pagepos_end;
};

52 53 54 55 56
int64_t Ogg_GetKeyframeGranule ( logical_stream_t *p_stream, int64_t i_granule );
bool    Ogg_IsKeyFrame ( logical_stream_t *, ogg_packet * );

int64_t Oggseek_GranuleToAbsTimestamp ( logical_stream_t *p_stream, int64_t i_granule,
                                       bool b_presentation );
57
int     Oggseek_BlindSeektoAbsoluteTime ( demux_t *, logical_stream_t *, int64_t, bool );
58 59 60
int     Oggseek_BlindSeektoPosition ( demux_t *, logical_stream_t *, double f, bool );
int     Oggseek_SeektoAbsolutetime ( demux_t *, logical_stream_t *, int64_t i_granulepos );
const demux_index_entry_t *OggSeek_IndexAdd ( logical_stream_t *, int64_t, int64_t );
61
void    Oggseek_ProbeEnd( demux_t * );
62

63 64
void oggseek_index_entries_free ( demux_index_entry_t * );

65
int64_t oggseek_read_page ( demux_t * );