[FFmpeg-devel] [PATCH 3/6] lavf/brstm: add support for seeking

Michael Niedermayer michaelni at gmx.at
Wed Jun 17 13:49:30 CEST 2015


On Tue, Jun 16, 2015 at 05:28:15PM -0500, Rodger Combs wrote:
> ---
>  libavformat/brstm.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/libavformat/brstm.c b/libavformat/brstm.c
> index 1eba943..8adffb8 100644
> --- a/libavformat/brstm.c
> +++ b/libavformat/brstm.c
> @@ -30,6 +30,7 @@ typedef struct BRSTMDemuxContext {
>      uint32_t    current_block;
>      uint32_t    samples_per_block;
>      uint32_t    last_block_used_bytes;
> +    uint32_t    data_start;
>      uint8_t     *table;
>      uint8_t     *adpc;
>      int         bfstm;
> @@ -298,6 +299,8 @@ static int read_header(AVFormatContext *s)
>              }
>              avio_skip(s->pb, start - avio_tell(s->pb));
>  
> +            b->data_start = avio_tell(s->pb);
> +
>              if ((major != 1 || minor) && !b->bfstm)
>                  avpriv_request_sample(s, "Version %d.%d", major, minor);
>  
> @@ -363,6 +366,18 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
>      return ret;
>  }
>  
> +static int read_seek(AVFormatContext *s, int stream_index,
> +                     int64_t timestamp, int flags)
> +{
> +    AVStream *st = s->streams[stream_index];
> +    BRSTMDemuxContext *b = s->priv_data;
> +    timestamp /= b->samples_per_block;

> +    avio_seek(s->pb, b->data_start + timestamp * b->block_size, SEEK_SET);

the return code should be checked, the file could be smaller than the
target the user wants to seek to

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150617/44f4677d/attachment.asc>


More information about the ffmpeg-devel mailing list