[FFmpeg-cvslog] wtv: permit root table and first sectors to be located beyond 2GB boundary

Peter Ross git at videolan.org
Tue Dec 18 14:19:55 CET 2012


ffmpeg | branch: master | Peter Ross <pross at xvid.org> | Tue Dec 18 00:42:13 2012 +1100| [95015634f5017897a61f4883bc217b0f7efbc40c] | committer: Peter Ross

wtv: permit root table and first sectors to be located beyond 2GB boundary

Fixes ticket #2025.

Signed-off-by: Peter Ross <pross at xvid.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=95015634f5017897a61f4883bc217b0f7efbc40c
---

 libavformat/wtvdec.c |    4 ++--
 libavformat/wtvenc.c |    7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 0706145..ee80719 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -149,7 +149,7 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int
     WtvFile *wf;
     uint8_t *buffer;
 
-    if (avio_seek(s->pb, first_sector << WTV_SECTOR_BITS, SEEK_SET) < 0)
+    if (avio_seek(s->pb, (int64_t)first_sector << WTV_SECTOR_BITS, SEEK_SET) < 0)
         return NULL;
 
     wf = av_mallocz(sizeof(WtvFile));
@@ -922,7 +922,7 @@ static int read_header(AVFormatContext *s)
     avio_skip(s->pb, 4);
     root_sector = avio_rl32(s->pb);
 
-    avio_seek(s->pb, root_sector << WTV_SECTOR_BITS, SEEK_SET);
+    avio_seek(s->pb, (int64_t)root_sector << WTV_SECTOR_BITS, SEEK_SET);
     root_size = avio_read(s->pb, root, root_size);
     if (root_size < 0)
         return AVERROR_INVALIDDATA;
diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c
index 8300662..304bd14 100644
--- a/libavformat/wtvenc.c
+++ b/libavformat/wtvenc.c
@@ -546,7 +546,7 @@ static void write_fat(AVIOContext *pb, int start_sector, int nb_sectors, int shi
     write_pad(pb, WTV_SECTOR_SIZE - ((nb_sectors << 2) % WTV_SECTOR_SIZE));
 }
 
-static int write_fat_sector(AVFormatContext *s, int64_t start_pos, int nb_sectors, int sector_bits, int depth)
+static int64_t write_fat_sector(AVFormatContext *s, int64_t start_pos, int nb_sectors, int sector_bits, int depth)
 {
     int64_t start_sector = start_pos >> WTV_SECTOR_BITS;
     int shift = sector_bits - WTV_SECTOR_BITS;
@@ -672,11 +672,10 @@ static int finish_file(AVFormatContext *s, enum WtvFileIndex index, int64_t star
 
     //write fat table
     if (w->depth > 0) {
-        w->first_sector = write_fat_sector(s, start_pos, nb_sectors, sector_bits, w->depth);
+        w->first_sector = write_fat_sector(s, start_pos, nb_sectors, sector_bits, w->depth) >> WTV_SECTOR_BITS;
     } else {
-        w->first_sector = start_pos;
+        w->first_sector = start_pos >> WTV_SECTOR_BITS;
     }
-    w->first_sector >>= WTV_SECTOR_BITS;
 
     w->length |= 1ULL<<60;
     if (sector_bits == WTV_SECTOR_BITS)



More information about the ffmpeg-cvslog mailing list