Skip to content

Commit

Permalink
Remove JPEG annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
vrabaud committed Jan 17, 2025
1 parent 0023461 commit 9e5ec28
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions apps/shared/avifjpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@
#include <libxml/parser.h>
#endif

#if defined(__clang__) && defined(__has_feature)
#if __has_feature(memory_sanitizer)
#include <sanitizer/msan_interface.h>
#define AVIF_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) __msan_unpoison(address, size)
#endif
#endif
#if !defined(AVIF_ANNOTATE_MEMORY_IS_INITIALIZED)
#define AVIF_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) \
do { \
} while (0)
#endif

#define AVIF_MIN(a, b) (((a) < (b)) ? (a) : (b))
#define AVIF_MAX(a, b) (((a) > (b)) ? (a) : (b))

Expand Down Expand Up @@ -921,7 +909,6 @@ static avifBool avifJPEGReadInternal(FILE * f,
unsigned int iccDataLen;
if (read_icc_profile(&cinfo, &iccDataTmp, &iccDataLen)) {
iccData = iccDataTmp;
AVIF_ANNOTATE_MEMORY_IS_INITIALIZED(iccDataTmp, iccDataLen);
if (avifImageSetProfileICC(avif, iccDataTmp, (size_t)iccDataLen) != AVIF_RESULT_OK) {
fprintf(stderr, "Setting ICC profile failed: %s (out of memory)\n", inputFilename);
goto cleanup;
Expand All @@ -948,7 +935,6 @@ static avifBool avifJPEGReadInternal(FILE * f,

int row_stride = cinfo.output_width * cinfo.output_components;
JSAMPARRAY buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, 1);
AVIF_ANNOTATE_MEMORY_IS_INITIALIZED(buffer, row_stride);

avif->width = cinfo.output_width;
avif->height = cinfo.output_height;
Expand Down Expand Up @@ -991,12 +977,8 @@ static avifBool avifJPEGReadInternal(FILE * f,

int row = 0;
while (cinfo.output_scanline < cinfo.output_height) {
if (jpeg_read_scanlines(&cinfo, buffer, 1) < 1) {
goto cleanup;
}
jpeg_read_scanlines(&cinfo, buffer, 1);
uint8_t * pixelRow = &rgb.pixels[row * rgb.rowBytes];
AVIF_ANNOTATE_MEMORY_IS_INITIALIZED(buffer, sizeof(buffer[0]));
AVIF_ANNOTATE_MEMORY_IS_INITIALIZED(buffer[0], rgb.rowBytes);
memcpy(pixelRow, buffer[0], rgb.rowBytes);
++row;
}
Expand Down Expand Up @@ -1362,12 +1344,10 @@ avifBool avifJPEGWrite(const char * outputFilename, const avifImage * avif, int

avifROData remainingExif = { exif.data, exif.size };
while (remainingExif.size > AVIF_JPEG_MAX_MARKER_DATA_LENGTH) {
AVIF_ANNOTATE_MEMORY_IS_INITIALIZED(remainingExif.data, AVIF_JPEG_MAX_MARKER_DATA_LENGTH);
jpeg_write_marker(&cinfo, JPEG_APP0 + 1, remainingExif.data, AVIF_JPEG_MAX_MARKER_DATA_LENGTH);
remainingExif.data += AVIF_JPEG_MAX_MARKER_DATA_LENGTH;
remainingExif.size -= AVIF_JPEG_MAX_MARKER_DATA_LENGTH;
}
AVIF_ANNOTATE_MEMORY_IS_INITIALIZED(remainingExif.data, remainingExif.size);
jpeg_write_marker(&cinfo, JPEG_APP0 + 1, remainingExif.data, (unsigned int)remainingExif.size);
avifRWDataFree(&exif);
} else if (avifImageGetExifOrientationFromIrotImir(avif) != 1) {
Expand Down Expand Up @@ -1399,17 +1379,14 @@ avifBool avifJPEGWrite(const char * outputFilename, const avifImage * avif, int
}
memcpy(xmp.data, AVIF_JPEG_STANDARD_XMP_TAG, AVIF_JPEG_STANDARD_XMP_TAG_LENGTH);
memcpy(xmp.data + AVIF_JPEG_STANDARD_XMP_TAG_LENGTH, avif->xmp.data, avif->xmp.size);
AVIF_ANNOTATE_MEMORY_IS_INITIALIZED(xmp.data, xmp.size);
jpeg_write_marker(&cinfo, JPEG_APP0 + 1, xmp.data, (unsigned int)xmp.size);
avifRWDataFree(&xmp);
}
}

while (cinfo.next_scanline < cinfo.image_height) {
row_pointer[0] = &rgb.pixels[cinfo.next_scanline * rgb.rowBytes];
if (jpeg_write_scanlines(&cinfo, row_pointer, 1) < 1) {
goto cleanup;
}
(void)jpeg_write_scanlines(&cinfo, row_pointer, 1);
}

jpeg_finish_compress(&cinfo);
Expand Down

0 comments on commit 9e5ec28

Please sign in to comment.