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 committed Jan 23, 2024
1 parent 4f7d822 commit 0a14938
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 @@ -1432,10 +1432,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 0a14938

Please sign in to comment.