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

Michael Niedermayer michaelni
Sat Jun 7 17:01:28 CEST 2008


On Sat, Jun 07, 2008 at 03:22:44PM +0200, elupus wrote:
> On Wed, 28 May 2008 21:55:30 +0200, Reimar D?ffinger wrote:
> 
> > On Wed, May 28, 2008 at 02:10:24AM +0200, elupus wrote:
> >> [26 quoted lines suppressed]
> > 
> > Just a quick comment: IMO you really should use the "standard" way to
> > search for a pattern:
> > use a uint32_t and shift in each character and compare against MKTAG(...).
> > On match, for comparing the remaining 'j' you can then each time read in
> > and compare a full 4 bytes, so no need for an extra loop.
> 
> So here's a updated patch that uses MKTAG and shifts in data. Not sure it
> ends up much simpler.

Just a few quick comments, i wont take the fun away from the maintainer
to approve/reject it ...


[...]
> +/**
> + * \brief looks for the string RTjjjjjjjjjj in the stream too resync reading
> + * \return TRUE if the syncword is found.
> + */
> +static int nuv_resync(AVFormatContext *s, int64_t pos_limit) {
> +    ByteIOContext *pb = s->pb;
> +    uint32_t tag;
> +

> +    tag = get_be32(pb);

unneeded


> +    while(!url_feof(pb) && url_ftell(pb) < pos_limit) {
> +        if(tag != MKBETAG('R','T','j','j')) {
> +            tag = (tag << 8) | get_byte(pb);
> +            continue;
> +        }

> +        tag = get_be32(pb);
> +        if(tag != MKBETAG('j','j','j','j'))
> +          continue;

inconsistant indention


> +
> +        tag = get_be32(pb);
> +        if(tag != MKBETAG('j','j','j','j'))
> +          continue;
> +
> +        return 1;

tag = get_be32(pb);
if(tag == MKBETAG('j','j','j','j'))
    return 1;


[...]
> +            case NUV_SEEKP:
> +                break;
> +            case NUV_AUDIO:
> +            case NUV_VIDEO:
> +                pos = url_ftell(s->pb) - HDRSIZE;
> +                dts = AV_RL32(&hdr[4]);
> +                // TODO - add general support in av_gen_search, so it adds positions after reading timestamps
> +                av_add_index_entry(s->streams[frametype == NUV_VIDEO ? ctx->v_id : ctx->a_id]
> +                                 , pos, dts, size + HDRSIZE, 0, hdr[2] == 0 ? AVINDEX_KEYFRAME : 0);
> +
> +                if ((frametype == NUV_VIDEO && stream_index == ctx->v_id) ||
> +                    (frametype == NUV_AUDIO && stream_index == ctx->a_id)) {
> +                    *ppos = pos;
> +                    return dts;
> +                }
> +            default:
> +                url_fskip(pb, size);
> +                break;

the NUV_SEEKP case can be put after default, needing 1 break; less


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

Frequently ignored awnser#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.
-------------- 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/20080607/fda84318/attachment.pgp>



More information about the ffmpeg-devel mailing list