Skip to content

Commit

Permalink
Optimize hdr
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhuai committed Feb 5, 2024
1 parent 9055437 commit df8d8cf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/imageinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,14 +652,15 @@ inline bool try_hdr(ReadInterface &ri, size_t length, ImageInfo &info) {
return false;
}

int read = 6;
off_t offset = 6;
const size_t piece = 64;
std::string header;
static const std::regex x_pattern(R"(\s[+-]X\s(\d+)\s)");
static const std::regex y_pattern(R"(\s[+-]Y\s(\d+)\s)");
while (read < length) {
header += ri.read_buffer(read, std::min<size_t>(length - read, piece)).to_string();
read += piece;
while (offset < length) {
buffer = ri.read_buffer(offset, std::min<size_t>(length - offset, piece));
offset += (off_t)buffer.size();
header += buffer.to_string();
std::smatch x_results;
std::smatch y_results;
std::regex_search(header, x_results, x_pattern);
Expand Down

0 comments on commit df8d8cf

Please sign in to comment.