Skip to content

Commit 49e3f6b

Browse files
committed
Improve based on review comments
1 parent 1348e92 commit 49e3f6b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

shared-bindings/jpegio/JpegDecoder.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@
3333
#include "shared-module/displayio/Bitmap.h"
3434

3535
//| class JpegDecoder:
36-
//| """A JPEG decoder"""
36+
//| """A JPEG decoder
37+
//|
38+
//| A JPEG decoder allocates a few thousand bytes of memory. To reduce memory fragmentation,
39+
//| create a single JpegDecoder object and use it anytime a JPEG image needs to be decoded.
40+
//| """
3741
//|
3842
//| def __init__(self) -> None: ...
3943
//|
@@ -45,6 +49,7 @@ STATIC mp_obj_t jpegio_jpegdecoder_make_new(const mp_obj_type_t *type, size_t n_
4549

4650
jpegio_jpegdecoder_obj_t *self = mp_obj_malloc(jpegio_jpegdecoder_obj_t, &jpegio_jpegdecoder_type);
4751
self->base.type = &jpegio_jpegdecoder_type;
52+
common_hal_jpegio_jpegdecoder_construct(self);
4853

4954
return MP_OBJ_FROM_PTR(self);
5055
}

shared-module/jpegio/JpegDecoder.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
#include "shared-bindings/bitmaptools/__init__.h"
3131
#include "shared-module/jpegio/JpegDecoder.h"
3232

33+
// Given a pointer `ptr` to the field `field_name` inside a structure of type `type`,
34+
// retrieve a pointer to the containing object.
35+
// This is used to retrieve the jpegio_jpegdecoder_obj_t object given the JDEC.
36+
// Similar macros of this type are frequently employed in low-level code, but this is
37+
// not standardized.
3338
#define CONTAINER_OF(ptr, type, field_name) ((type *)(void *)(((uint8_t *)ptr) - offsetof(type, field_name)))
3439

3540
static void check_jresult(JRESULT j) {

0 commit comments

Comments
 (0)