[FFmpeg-devel] [PATCH] fix seeking and index generation

Michael Niedermayer michaelni
Tue Aug 24 21:06:38 CEST 2010


On Sat, Aug 14, 2010 at 01:03:12AM +0200, Michael Chinen wrote:
> On Fri, Aug 13, 2010 at 10:58 PM, Baptiste Coudurier
> <baptiste.coudurier at gmail.com> wrote:
> > On Sun, Aug 08, 2010 at 09:00:25PM +0200, Michael Chinen wrote:
> >> On Sun, Aug 8, 2010 at 5:40 PM, Michael Chinen <mchinen at gmail.com> wrote:
> >> > Thanks. ?I found a much better way to fix this, but I'm having some
> >> > issues testing, and will submit a new patch tomorrow.
> >>
> >> Here is an updated patch that is less destructive and passes all
> >> regression tests.
> >>
> >> More investigation showed that av_find_stream_info wasn't setting the
> >> start offset correctly for the parser.
> >
> > Can you clarify "start offset" ?
> 
> More specifically, AVCodecParserContext.cur_offset and
> next_frame_offset weren't being set to the ftell when the parser
> starts getting input (which is not 0 for formats with headers.)  As a
> result, the pos for the first indexes started at 0 for generic index
> building.
> 
> >
> >
> >> @@ -1148,6 +1154,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
> >> ? ? ? ? ? ? ?s->cur_st = st;
> >> ? ? ? ? ? ? ?st->cur_ptr = st->cur_pkt.data;
> >> ? ? ? ? ? ? ?st->cur_len = st->cur_pkt.size;
> >> +
> >> ? ? ? ? ? ? ?if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {
> >> ? ? ? ? ? ? ? ? ?st->parser = av_parser_init(st->codec->codec_id);
> >> ? ? ? ? ? ? ? ? ?if (!st->parser) {
> >
> > Cosmetics must be separated.
> 
> Sorry, I missed this.  Fixed.
> 
> Michael

>  libavcodec/avcodec.h |    1 +
>  libavformat/utils.c  |   12 ++++++++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> dc845572408de8e6e384778f011ec5c53a84c6be  0001-fix-index_entries-pos-was-being-set-wrong-for-files-.patch
> From 77412b4fbe75b8e2c2da3e1acb3d39439d33ec12 Mon Sep 17 00:00:00 2001
> From: Michael Chinen <mchinen at gmail.com>
> Date: Sun, 8 Aug 2010 17:24:35 +0200
> Subject: [PATCH] fix index_entries pos (was being set wrong for files with data_offset > 0)
> 
> ---
>  libavcodec/avcodec.h |    1 +
>  libavformat/utils.c  |   12 ++++++++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 9186bf5..31bbbd6 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3725,6 +3725,7 @@ typedef struct AVCodecParserContext {
>      int flags;
>  #define PARSER_FLAG_COMPLETE_FRAMES           0x0001
>  #define PARSER_FLAG_ONCE                      0x0002
> +#define PARSER_FLAG_FETCH_OFFSET              0x0004
>  
>      int64_t offset;      ///< byte offset from starting packet start
>      int64_t cur_frame_end[AV_PARSER_PTS_NB];
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 1aa965c..60036de 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -1043,6 +1043,12 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
>          /* select current input stream component */
>          st = s->cur_st;
>          if (st) {
> +            if(st->parser && (st->parser->flags & PARSER_FLAG_FETCH_OFFSET) &&
> +               (s->iformat->flags & AVFMT_GENERIC_INDEX)) {
> +                st->parser->next_frame_offset =
> +                st->parser->cur_offset        = st->cur_pkt.pos;
> +                st->parser->flags ^= PARSER_FLAG_FETCH_OFFSET;
> +            }

fliping the meaning of PARSER_FLAG_FETCH_OFFSET should simplify the code
also the existing and this can be factored i guess

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

I wish the Xiph folks would stop pretending they've got something they
do not.  Somehow I fear this will remain a wish. -- M?ns Rullg?rd
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100824/c95ffaed/attachment.pgp>



More information about the ffmpeg-devel mailing list