On Thu, May 12, 2011 at 10:25:54AM +0200, Vladimir Pantelic wrote:
> Vladimir Pantelic wrote:
>
> >atm the asf logic is:
> >
> >if( index_exists ) {
> > index = search_by_index()
> > if( index< 0 ) {
> > return -1;
> > }
> > // index success
> >} else {
> > try binary search
> > ...
> >}
> >
> >maybe it should be:
> >
> >if( index_exists ) {
> > index = search_by_index()
> > if( index>= 0 ) {
> > // index success
> > ...
> > return ...;
> > }
> >}
> >// no index or index search fail, try binary
> >try binary search
> >...
>
> patch attached
> From 15f02f4decb7fa1a330bd322f001bcf744183064 Mon Sep 17 00:00:00 2001
> From: Vladimir Pantelic <[email protected]>
> Date: Thu, 12 May 2011 10:21:19 +0200
> Subject: [PATCH] make asfdec fallback to binary search internally
>
> lavf will do that anyway in case seek by index fails
> ---
> libavformat/asfdec.c | 15 ++++++++-------
> 1 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
> index 77c8449..e2161fd 100644
> --- a/libavformat/asfdec.c
> +++ b/libavformat/asfdec.c
> @@ -1269,21 +1269,22 @@ static int asf_read_seek(AVFormatContext *s, int
> stream_index, int64_t pts, int
> if (!asf->index_read)
> asf_build_simple_index(s, stream_index);
>
> - if(!(asf->index_read && st->index_entries)){
> - if(av_seek_frame_binary(s, stream_index, pts, flags)<0)
> - return -1;
> - }else{
> + if((asf->index_read && st->index_entries)){
> index= av_index_search_timestamp(st, pts, flags);
> - if(index<0)
> - return -1;
> -
> + if(index >= 0) {
> /* find the position */
> pos = st->index_entries[index].pos;
>
> /* do the seek */
> av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
> avio_seek(s->pb, pos, SEEK_SET);
> + asf_reset_header(s);
> + return 0;
> + }
> }
> + /* no index or seeking by index failed */
> + if(av_seek_frame_binary(s, stream_index, pts, flags)<0)
> + return -1;
> asf_reset_header(s);
> return 0;
> }
Tested that testsuite and fate still pass.
Queued.
regards,
Reinhard
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel