Cleanup: 64 bit file IO on windows.

Unlike Linux where fseek/tell will be either 32 or 64 bit
depending on the target platform, it will always be 32 bit
on windows.

We had some macro magic in BLI_winstuff.h that substituted
them for 64 bit versions, but that is upsetting the system
headers if they get included after BLI_winstuff.h which
is problematic for D6811.

This diff adds proper functions in blenlib and updates
all calls that were using the BLI_winstuff.h header to
gain 64 bit file IO.

note: Anything that was using the 32 bit versions (ie not
including BLI_winstuff.h) will still be using the 32 bit
versions, which is perhaps a good code quality Friday project.

Differential Revision: https://developer.blender.org/D7160

Reviewers: brecht dfelinto
This commit is contained in:
2020-03-18 12:13:03 -06:00
parent ac74a843d2
commit 9a116c7c2d
9 changed files with 101 additions and 76 deletions

View File

@@ -27,6 +27,7 @@
#include "AVI_avi.h"
#include "avi_intern.h"
#include "avi_endian.h"
#include "BLI_fileops.h"
#ifdef WIN32
# include "BLI_winstuff.h"
@@ -61,7 +62,7 @@ AviError AVI_set_compress_option(
movie->streams[i].sh.right = *((int *)opt_data);
((AviBitmapInfoHeader *)movie->streams[i].sf)->SizeImage =
movie->header->SuggestedBufferSize;
fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET);
BLI_fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET);
awrite(movie,
movie->streams[i].sf,
1,
@@ -84,7 +85,7 @@ AviError AVI_set_compress_option(
movie->streams[i].sh.bottom = *((int *)opt_data);
((AviBitmapInfoHeader *)movie->streams[i].sf)->SizeImage =
movie->header->SuggestedBufferSize;
fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET);
BLI_fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET);
awrite(movie,
movie->streams[i].sf,
1,
@@ -100,7 +101,7 @@ AviError AVI_set_compress_option(
for (i = 0; i < movie->header->Streams; i++) {
if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) {
movie->streams[i].sh.Quality = (*((int *)opt_data)) * 100;
fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET);
BLI_fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET);
awrite(movie,
movie->streams[i].sf,
1,
@@ -120,7 +121,7 @@ AviError AVI_set_compress_option(
for (i = 0; i < movie->header->Streams; i++) {
if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) {
movie->streams[i].sh.Scale = movie->header->MicroSecPerFrame;
fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET);
BLI_fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET);
awrite(movie,
movie->streams[i].sf,
1,
@@ -132,7 +133,7 @@ AviError AVI_set_compress_option(
break;
}
fseek(movie->fp, movie->offset_table[0], SEEK_SET);
BLI_fseek(movie->fp, movie->offset_table[0], SEEK_SET);
awrite(movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH);
break;