Skip to content

Commit fbc8687

Browse files
committed
Removed unused upsampling setting
1 parent c5d50fd commit fbc8687

File tree

3 files changed

+1
-42
lines changed

3 files changed

+1
-42
lines changed

Tests/test_file_avif.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -549,22 +549,6 @@ def test_decoder_codec_available_cannot_decode(self) -> None:
549549
def test_decoder_codec_available_invalid(self) -> None:
550550
assert _avif.decoder_codec_available("foo") is False
551551

552-
@pytest.mark.parametrize("upsampling", ["fastest", "best", "nearest", "bilinear"])
553-
def test_decoder_upsampling(
554-
self, monkeypatch: pytest.MonkeyPatch, upsampling: str
555-
) -> None:
556-
monkeypatch.setattr(AvifImagePlugin, "CHROMA_UPSAMPLING", upsampling)
557-
558-
with Image.open(TEST_AVIF_FILE):
559-
pass
560-
561-
def test_decoder_upsampling_invalid(self, monkeypatch: pytest.MonkeyPatch) -> None:
562-
monkeypatch.setattr(AvifImagePlugin, "CHROMA_UPSAMPLING", "foo")
563-
564-
with pytest.raises(ValueError):
565-
with Image.open(TEST_AVIF_FILE):
566-
pass
567-
568552
def test_p_mode_transparency(self) -> None:
569553
im = Image.new("P", size=(64, 64))
570554
draw = ImageDraw.Draw(im)

src/PIL/AvifImagePlugin.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# Decoder options as module globals, until there is a way to pass parameters
1717
# to Image.open (see https://github.com/python-pillow/Pillow/issues/569)
1818
DECODE_CODEC_CHOICE = "auto"
19-
CHROMA_UPSAMPLING = "auto"
2019
DEFAULT_MAX_THREADS = 0
2120

2221
_VALID_AVIF_MODES = {"RGB", "RGBA"}
@@ -76,7 +75,6 @@ def _open(self) -> None:
7675
self._decoder = _avif.AvifDecoder(
7776
self.fp.read(),
7877
DECODE_CODEC_CHOICE,
79-
CHROMA_UPSAMPLING,
8078
_get_default_max_threads(),
8179
)
8280

src/_avif.c

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
#include <Python.h>
44
#include "avif/avif.h"
55

6-
#if AVIF_VERSION < 80300
7-
#define AVIF_CHROMA_UPSAMPLING_AUTOMATIC AVIF_CHROMA_UPSAMPLING_BILINEAR
8-
#define AVIF_CHROMA_UPSAMPLING_BEST_QUALITY AVIF_CHROMA_UPSAMPLING_BILINEAR
9-
#define AVIF_CHROMA_UPSAMPLING_FASTEST AVIF_CHROMA_UPSAMPLING_NEAREST
10-
#endif
11-
126
typedef struct {
137
avifPixelFormat subsampling;
148
int qmin;
@@ -671,35 +665,18 @@ AvifDecoderNew(PyObject *self_, PyObject *args) {
671665
PyObject *avif_bytes;
672666
AvifDecoderObject *self = NULL;
673667

674-
char *upsampling_str;
675668
char *codec_str;
676669
avifCodecChoice codec;
677-
avifChromaUpsampling upsampling;
678670
int max_threads;
679671

680672
avifResult result;
681673

682674
if (!PyArg_ParseTuple(
683-
args, "Sssi", &avif_bytes, &codec_str, &upsampling_str, &max_threads
675+
args, "Ssi", &avif_bytes, &codec_str, &max_threads
684676
)) {
685677
return NULL;
686678
}
687679

688-
if (!strcmp(upsampling_str, "auto")) {
689-
upsampling = AVIF_CHROMA_UPSAMPLING_AUTOMATIC;
690-
} else if (!strcmp(upsampling_str, "fastest")) {
691-
upsampling = AVIF_CHROMA_UPSAMPLING_FASTEST;
692-
} else if (!strcmp(upsampling_str, "best")) {
693-
upsampling = AVIF_CHROMA_UPSAMPLING_BEST_QUALITY;
694-
} else if (!strcmp(upsampling_str, "nearest")) {
695-
upsampling = AVIF_CHROMA_UPSAMPLING_NEAREST;
696-
} else if (!strcmp(upsampling_str, "bilinear")) {
697-
upsampling = AVIF_CHROMA_UPSAMPLING_BILINEAR;
698-
} else {
699-
PyErr_Format(PyExc_ValueError, "Invalid upsampling option: %s", upsampling_str);
700-
return NULL;
701-
}
702-
703680
if (strcmp(codec_str, "auto") == 0) {
704681
codec = AVIF_CODEC_CHOICE_AUTO;
705682
} else {

0 commit comments

Comments
 (0)