Skip to content

Commit

Permalink
Properly check if an identical chunk has been written before. (AOMedi…
Browse files Browse the repository at this point in the history
…aCodec#1956)

Basically reverting 295cab3 in AOMediaCodec#463
  • Loading branch information
vrabaud authored Jan 22, 2024
1 parent 5905d52 commit b01a8af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,10 +1816,11 @@ static avifResult avifEncoderWriteMediaDataBox(avifEncoder * encoder,
size_t chunkOffset = 0;

// Deduplication - See if an identical chunk to this has already been written
if (item->encodeOutput->samples.count > 0) {
// Doing it when item->encodeOutput->samples.count > 0 would require contiguous memory.
if (item->encodeOutput->samples.count == 1) {
avifEncodeSample * sample = &item->encodeOutput->samples.sample[0];
chunkOffset = avifEncoderFindExistingChunk(s, mdatStartOffset, sample->data.data, sample->data.size);
} else {
} else if (item->encodeOutput->samples.count == 0) {
chunkOffset = avifEncoderFindExistingChunk(s, mdatStartOffset, item->metadataPayload.data, item->metadataPayload.size);
}

Expand Down

0 comments on commit b01a8af

Please sign in to comment.