Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if(NOT MSVC)
endif ()
endif()

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
4 changes: 2 additions & 2 deletions examples/heif_dec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ int main(int argc, char** argv)
//while ((opt = getopt(argc, argv, "q:s")) != -1) {
while (true) {
int option_index = 0;
int c = getopt_long(argc, argv, "hq:sd:C:vo:", long_options, &option_index);
int c = getopt_long(argc, argv, (char*)"hq:sd:C:vo:", long_options, &option_index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of all these (char*) casts, it might be cleaner to change the getopt* implementation in the extras directory.

if (c == -1) {
break;
}
Expand All @@ -261,7 +261,7 @@ int main(int argc, char** argv)
break;
case '?':
std::cerr << "\n";
// fallthrough
[[fallthrough]];
case 'h':
show_help(argv[0]);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/heif_enc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ int main(int argc, char** argv)

while (true) {
int option_index = 0;
int c = getopt_long(argc, argv, "hq:Lo:vPp:t:b:AEe:C:"
int c = getopt_long(argc, argv, (char*)"hq:Lo:vPp:t:b:AEe:C:"
#if WITH_UNCOMPRESSED_CODEC
"U"
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/heif_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int main(int argc, char** argv)

while (true) {
int option_index = 0;
int c = getopt_long(argc, argv, "dhv", long_options, &option_index);
int c = getopt_long(argc, argv, (char*)"dhv", long_options, &option_index);
if (c == -1)
break;

Expand Down
2 changes: 1 addition & 1 deletion examples/heif_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int main(int argc, char** argv)

while (true) {
int option_index = 0;
int c = getopt_long(argc, argv, "d:m:hv", long_options, &option_index);
int c = getopt_long(argc, argv, (char*)"d:m:hv", long_options, &option_index);
if (c == -1)
break;

Expand Down
2 changes: 1 addition & 1 deletion examples/heif_thumbnailer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main(int argc, char** argv)
int size = 512; // default thumbnail size
bool thumbnail_from_primary_image_only = false;

while ((opt = getopt(argc, argv, "s:hpv")) != -1) {
while ((opt = getopt(argc, argv, (char*)"s:hpv")) != -1) {
switch (opt) {
case 's':
size = atoi(optarg);
Expand Down
31 changes: 26 additions & 5 deletions libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@
#define M_PI 3.14159265358979323846
#endif

#include <unistd.h> // TODO: Windows
#if !defined(_WIN32) && !defined(_WIN64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#ifndef _WIN32 should generally be enough to detect all Windows.

Btw, unistd.h is available for MinGW (just pulls in io.h and adds a few more constants), but I guess you'd still want to handle the temp file creation in a consistent way for all Windows builds...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temp file creation is currently not used. I did some experiments with it and it may be an option later on, but currently, it is never called.

#include <unistd.h>
#else
#include <fcntl.h>
#include <io.h>
#endif


Fraction::Fraction(int32_t num, int32_t den)
{
Expand Down Expand Up @@ -155,7 +161,7 @@ bool Fraction::is_valid() const
return denominator != 0;
}

uint32_t from_fourcc(const char* string)
static uint32_t from_fourcc(const char* string)
{
return ((string[0] << 24) |
(string[1] << 16) |
Expand Down Expand Up @@ -1406,8 +1412,15 @@ void Box_iloc::set_use_tmp_file(bool flag)
{
m_use_tmpfile = flag;
if (flag) {
#if !defined(_WIN32) && !defined(_WIN64)
strcpy(m_tmp_filename, "/tmp/libheif-XXXXXX");
m_tmpfile_fd = mkstemp(m_tmp_filename);
#else
char tmpname[L_tmpnam_s];
// TODO: check return value (errno_t)
tmpnam_s(tmpname, L_tmpnam_s);
_sopen_s(&m_tmpfile_fd, tmpname, _O_CREAT | _O_TEMPORARY | _O_TRUNC | _O_RDWR, _SH_DENYRW, _S_IREAD | _S_IWRITE);
#endif
}
}

Expand Down Expand Up @@ -1629,7 +1642,11 @@ Error Box_iloc::append_data(heif_item_id item_ID,
extent.length = data.size();

if (m_use_tmpfile && construction_method==0) {
#if !defined(_WIN32) && !defined(_WIN64)
ssize_t cnt = ::write(m_tmpfile_fd, data.data(), data.size());
#else
int cnt = _write(m_tmpfile_fd, data.data(), data.size());
#endif
if (cnt < 0) {
std::stringstream sstr;
sstr << "Could not write to tmp file: error " << errno;
Expand Down Expand Up @@ -1883,7 +1900,11 @@ Error Box_iloc::write_mdat_after_iloc(StreamWriter& writer)

if (m_use_tmpfile) {
std::vector<uint8_t> data(extent.length);
#if !defined(_WIN32) && !defined(_WIN64)
ssize_t cnt = ::read(m_tmpfile_fd, data.data(), extent.length);
#else
int cnt = _read(m_tmpfile_fd, data.data(), extent.length);
#endif
if (cnt<0) {
std::stringstream sstr;
sstr << "Cannot read tmp data file, error " << errno;
Expand Down Expand Up @@ -2632,7 +2653,7 @@ Error Box_ipma::parse(BitstreamRange& range)

int assoc_cnt = range.read8();
for (int k = 0; k < assoc_cnt; k++) {
PropertyAssociation association;
PropertyAssociation association{};

uint16_t index;
if (get_flags() & 1) {
Expand Down Expand Up @@ -3902,9 +3923,9 @@ Error Box_cmin::write(StreamWriter& writer) const
}


std::array<double,9> mul(const std::array<double,9>& a, const std::array<double,9>& b)
static std::array<double,9> mul(const std::array<double,9>& a, const std::array<double,9>& b)
{
std::array<double,9> m;
std::array<double, 9> m{};

m[0] = a[0]*b[0] + a[1]*b[3] + a[2]*b[6];
m[1] = a[0]*b[1] + a[1]*b[4] + a[2]*b[7];
Expand Down