On Fri, 18 Oct 2013, Luca Barbato wrote:
Use an helper function to seek by sector to avoid possible mistakes due
shifting by WTV_SECTOR_BITS a 32bit entity.
---
libavformat/wtv.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
The commit message should say something about the fact that we tried to
handle it by making the shift amount a 64 bit integer and that this didn't
work. You can probably copypaste that pargraph from my version of the
patch.
diff --git a/libavformat/wtv.c b/libavformat/wtv.c
index 5099739..ad27fc6 100644
--- a/libavformat/wtv.c
+++ b/libavformat/wtv.c
@@ -48,10 +48,12 @@
*
*/
-#define WTV_SECTOR_BITS INT64_C(12)
+#define WTV_SECTOR_BITS 12
#define WTV_SECTOR_SIZE (1 << WTV_SECTOR_BITS)
#define WTV_BIGSECTOR_BITS 18
+#define SHIFT_SECTOR_BITS(a) ((int64_t)(a) << WTV_SECTOR_BITS)
+
typedef struct {
AVIOContext *pb_filesystem; /** file system (AVFormatContext->pb) */
@@ -64,6 +66,11 @@ typedef struct {
int64_t length;
} WtvFile;
+static int seek_by_sector(AVIOContext *pb, int64_t sector, int64_t offset)
+{
+ return avio_seek(pb, SHIFT_SECTOR_BITS(sector) + offset, SEEK_SET);
+}
This needs to return int64_t and not just int.
There's an av_malloc(some_sectors << WTV_SECTOR_BITS) that could use the
shifting macro for completeness sake (even though I doubt it ever tries to
malloc > 2GB anyway).
Other than this, your patch looks good to me.
// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel