also subtract preroll when reading ASF simple index object

Message ID 4D827F16.8010608@gmail.com
State Superseded
Headers show

Commit Message

Vladimir Pantelic March 17, 2011, 9:37 p.m.
sorry, 10l for me

Comments

Vladimir Pantelic March 17, 2011, 9:51 p.m. | #1
Vladimir Pantelic wrote:
> sorry, 10l for me
>
>
> 0001-also-subtract-preroll-when-reading-ASF-simple-index.patch

yes, make test passed (there is no test that covers asf+index seek)
Anton Khirnov March 18, 2011, 6:32 a.m. | #2
On Thu, Mar 17, 2011 at 10:37:26PM +0100, Vladimir Pantelic wrote:
> sorry, 10l for me

> From e487239119e7db79cc1772eb8cd671c0ba18e977 Mon Sep 17 00:00:00 2001
> From: Vladimir Pantelic <vladoman@gmail.com>
> Date: Thu, 17 Mar 2011 22:34:52 +0100
> Subject: [PATCH] also subtract preroll when reading ASF simple index object
> 
> this was missed when ASF was changed to return timestamps
> without preroll.
> ---
>  libavformat/asfdec.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
> index 79b3bcb..de7b370 100644
> --- a/libavformat/asfdec.c
> +++ b/libavformat/asfdec.c
> @@ -1218,10 +1218,10 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
>              int pktnum=avio_rl32(s->pb);
>              int pktct =avio_rl16(s->pb);
>              int64_t pos      = s->data_offset + s->packet_size*(int64_t)pktnum;
> -            int64_t index_pts= av_rescale(itime, i, 10000);
> +            int64_t index_pts= FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
>  
>              if(pos != last_pos){
> -            av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d\n", pktnum, pktct);
> +            av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d  pts: %lld\n", pktnum, pktct, index_pts);

%lld -> PRId64 ?

Patch

From e487239119e7db79cc1772eb8cd671c0ba18e977 Mon Sep 17 00:00:00 2001
From: Vladimir Pantelic <vladoman@gmail.com>
Date: Thu, 17 Mar 2011 22:34:52 +0100
Subject: [PATCH] also subtract preroll when reading ASF simple index object

this was missed when ASF was changed to return timestamps
without preroll.
---
 libavformat/asfdec.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 79b3bcb..de7b370 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1218,10 +1218,10 @@  static void asf_build_simple_index(AVFormatContext *s, int stream_index)
             int pktnum=avio_rl32(s->pb);
             int pktct =avio_rl16(s->pb);
             int64_t pos      = s->data_offset + s->packet_size*(int64_t)pktnum;
-            int64_t index_pts= av_rescale(itime, i, 10000);
+            int64_t index_pts= FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
 
             if(pos != last_pos){
-            av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d\n", pktnum, pktct);
+            av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d  pts: %lld\n", pktnum, pktct, index_pts);
             av_add_index_entry(s->streams[stream_index], pos, index_pts, s->packet_size, 0, AVINDEX_KEYFRAME);
             last_pos=pos;
             }
-- 
1.6.0.2