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

Michael Niedermayer michaelni
Wed May 28 21:24:46 CEST 2008


On Wed, May 28, 2008 at 02:10:24AM +0200, elupus wrote:
> On Sat, 24 May 2008 21:53:35 +0200, Michael Niedermayer wrote:
> 
> > On Sat, May 24, 2008 at 01:28:42PM +0200, elupus wrote:
> > 
> > [...]
> >> Index: nuv.c
> >> ===================================================================
> >> --- nuv.c	(revision 12279)
> >> +++ nuv.c	(working copy)
> >> @@ -209,9 +209,14 @@
> >>                  ret = av_new_packet(pkt, copyhdrsize + size);
> >>                  if (ret < 0)
> >>                      return ret;
> >> -                pkt->pos = url_ftell(pb) - copyhdrsize;
> >> +                pkt->pos = url_ftell(pb) - HDRSIZE;
> >>                  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, pkt->pts, size + HDRSIZE, 0, AVINDEX_KEYFRAME);
> >> +                }
> >>                  memcpy(pkt->data, hdr, copyhdrsize);
> >>                  ret = get_buffer(pb, pkt->data + copyhdrsize, size);
> >>                  return ret;
> > 
> > The change to pkt->pos should also be in a seperate patch :)
> > besides the indention i already mentioned ...
> 
> Damn you, I was hoping you wouldn't spot that :). Horrible todo in svn
> without having some system for stackable commits. Might resend that when I
> get a git repo setup instead.
> 
> > 
> >> +                if ((frametype == NUV_VIDEO && stream_index == ctx->v_id) ||
> >> +                    (frametype == NUV_VIDEO && stream_index == ctx->a_id)) {
> > 
> > are both supposed to be VIDEO ?
> 
> Heh. no.
> 
> >> +                url_fskip(pb, size);
> >> +                break;
> >> +            case NUV_SEEKP:
> >> +                break;
> >> +            default:
> >> +                url_fskip(pb, size);
> >> +                break;
> > 
> > duplicate
> 
> Fixed
> 
> > 
> >> +        }
> >> +    }
> > 
> >> +    return AV_NOPTS_VALUE;
> >> +
> >> +
> >> +}
> > 
> > are the empty lines intended?
> > 
> 
> Rremoved.
> 
> Joakim
Content-Description: Attached file: nuv_timestamp.patch
> Index: libavformat/nuv.c
> ===================================================================
> --- libavformat/nuv.c	(revision 13481)
> +++ libavformat/nuv.c	(working copy)
> @@ -236,6 +241,86 @@
>      return AVERROR(EIO);
>  }
>  
> +/**
> + * \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;
> +    int i;
> +    char c;
> +
> +    c = get_byte(pb);
> +    while(!url_feof(pb) && url_ftell(pb) < pos_limit) {
> +        if(c != 'R') {
> +            c = get_byte(pb);
> +            continue;
> +        }
> +        c = get_byte(pb);
> +        if(c != 'T')
> +            continue;
> +
> +        for(i=0;i<10;i++) {
> +            c = get_byte(pb);
> +            if(c != 'j')
> +                break;
> +        }
> +        if(i==10)
> +            return 1;
> +    }
> +    return 0;
> +}

This can be simplified, anyway, i leave the further review and approval to
the nuv maintainer, unless reimar ignores the patch but i dont think he will

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- 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/20080528/ee007df7/attachment.pgp>



More information about the ffmpeg-devel mailing list