[FFmpeg-devel] [PATCH] Seeking and resync support in nuv demuxer

Michael Niedermayer michaelni
Sat May 24 13:51:27 CEST 2008


On Sat, May 24, 2008 at 11:21:52AM +0200, elupus wrote:
> On Sat, 24 May 2008 11:16:57 +0200, elupus wrote:
> 
> > Hi,
> > 
> > Here is a patch too support seeking in nuv files. It adds index generation,
> > read_timestamp and arbitrary postion resync support.
> > 
> > To notice if a stream resync is required (input stream location changed
> > outside demuxer), it stores a stream position on each read. Also since
> > resync positions in nuv files are quite scarce, it also considers all
> > indexed locations as valid.
> > 
> > I noticed something odd while doing this patch. What is packet.pos supposed
> > to mean. In the nuv demuxer it means where in the stream the payload part
> > of a demuxpacket starts. This position is not a position where reading can
> > start as the header must be read first. So shouldn't the pkt.pos mean the
> > location where the header for the packet starts?
> > 
> > Also too speed up seeks using av_seek_frame_binary, I added index entries
> > when a timestamp is found using read_timestamp. However wouldn't it be
> > better to add this to av_seek_frame_binary? perhaps only when
> > AVFMT_GENERIC_INDEX is set in format.
> > 
> > On the note of AVFMT_GENERIC_INDEX, that only works if the stream is set to
> > require parsing. Non parsed packets are not considered. Even if they have
> > PKT_FLAG_KEY set.
> > 
> > Joakim
> 
> And the classic of forgetting the attachment.
> 
> Joakim
Content-Description: Attached file: nuv.patch
> Index: nuv.c
> ===================================================================
> --- nuv.c	(revision 12279)
> +++ nuv.c	(working copy)
[...]
> @@ -212,6 +214,11 @@
>                  pkt->pos = url_ftell(pb) - copyhdrsize;
>                  pkt->pts = AV_RL32(&hdr[4]);
>                  pkt->stream_index = ctx->v_id;
> +                if(hdr[2] == 0) {
> +                  AVStream *st = s->streams[pkt->stream_index];
> +                  pkt->flags |= PKT_FLAG_KEY;
> +                  av_add_index_entry(st, pkt->pos + copyhdrsize - HDRSIZE, pkt->pts, pkt->size - copyhdrsize + HDRSIZE, 0, AVINDEX_KEYFRAME);
> +                }

inconsistant indention


[...]

> +/**
> + * \brief Check if given position is a known stream position
> + * \return TRUE if the position is known
> + */
> +static int nuv_valid_position(AVFormatContext *s, int64_t pos)
> +{
> +    int i, j;
> +    AVStream *st;
> +
> +    for (i = 0; i < s->nb_streams; i++) {
> +        st = s->streams[i];
> +        for (j = 0; j < st->nb_index_entries; j++) {
> +            if (st->index_entries[j].pos == pos)
> +                break;
> +        }
> +        if (j != st->nb_index_entries)
> +            break;
> +    }
> +
> +    return i != s->nb_streams;
> +}

Unneeded and too inefficient anyway

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

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080524/d7ef2284/attachment.pgp>



More information about the ffmpeg-devel mailing list