Skip to content

Commit

Permalink
Shorten avifIOPartialRead() in avifincrtest_helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
y-guyon committed Jun 3, 2022
1 parent 1af7274 commit e82b5af
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions tests/avifincrtest_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,28 +117,14 @@ typedef struct
size_t fullSize;
} avifROPartialData;

// Implementation of avifIOReadFunc simulating a stream from an array.
// Implementation of avifIOReadFunc simulating a stream from an array. See avifIOReadFunc documentation.
// io->data is expected to point to avifROPartialData.
static avifResult avifIOPartialRead(struct avifIO * io, uint32_t readFlags, uint64_t offset, size_t size, avifROData * out)
{
const avifROPartialData * data = (avifROPartialData *)io->data;

// The behavior below is described in the comment above avifIOReadFunc's declaration.
if (readFlags != 0) {
return AVIF_RESULT_IO_ERROR;
}
if (!data) {
if ((readFlags != 0) || !data || (data->fullSize < offset)) {
return AVIF_RESULT_IO_ERROR;
}
if (data->fullSize < offset) {
return AVIF_RESULT_IO_ERROR;
}
if (data->fullSize == offset) {
out->data = data->available.data;
out->size = 0;
return AVIF_RESULT_OK;
}

if (data->fullSize < (offset + size)) {
size = data->fullSize - offset;
}
Expand Down

0 comments on commit e82b5af

Please sign in to comment.