diff options
Diffstat (limited to 'ethosu/mlw_codec')
-rw-r--r-- | ethosu/mlw_codec/mlw_codecmodule.c | 6 | ||||
-rw-r--r-- | ethosu/mlw_codec/mlw_encode.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/ethosu/mlw_codec/mlw_codecmodule.c b/ethosu/mlw_codec/mlw_codecmodule.c index de945ab3..6dde12dc 100644 --- a/ethosu/mlw_codec/mlw_codecmodule.c +++ b/ethosu/mlw_codec/mlw_codecmodule.c @@ -53,7 +53,7 @@ method_encode (PyObject *self, PyObject *args) return NULL; /* Unpack the length of the input integer list. */ - int input_length = PyObject_Length (input_list_object); + int input_length = (int)PyObject_Length (input_list_object); if (input_length < 0) input_length = 0; @@ -73,7 +73,7 @@ method_encode (PyObject *self, PyObject *args) item = PyList_GetItem(input_list_object, i); if (!PyLong_Check(item)) input_buffer[i] = 0; - input_buffer[i] = PyLong_AsLong(item); + input_buffer[i] = (int16_t)PyLong_AsLong(item); } /* We don't know the output length required, we guess worst case, @@ -126,7 +126,7 @@ method_decode(PyObject *self, PyObject *args) /* Unpack the input buffer and length from the bytearray object. */ uint8_t *input_buffer = (uint8_t *) PyByteArray_AsString(input_bytearray_object); - int input_length = PyByteArray_Size(input_bytearray_object); + int input_length = (int)PyByteArray_Size(input_bytearray_object); /* We don't know the output length required, we guess, but the guess * will be too small, the mlw_decode call will do a resize (upwards) diff --git a/ethosu/mlw_codec/mlw_encode.c b/ethosu/mlw_codec/mlw_encode.c index 7820106e..04afa3ee 100644 --- a/ethosu/mlw_codec/mlw_encode.c +++ b/ethosu/mlw_codec/mlw_encode.c @@ -33,8 +33,12 @@ #define ZERO_RUN_THRES 4 +#ifndef min #define min(a,b) ((a)<(b)?(a):(b)) +#endif +#ifndef max #define max(a,b) ((a)>(b)?(a):(b)) +#endif typedef struct palette { int16_t lut[32]; @@ -258,7 +262,7 @@ static void create_palette( int freq[512], // Setup the 32 entry palette int palette_max_val = 0, val, cnt, pal_cnt=0; for(i=0; i<max_palette_size; i++) { - cnt = freq64[i]>>16; + cnt = (int)(freq64[i]>>16); val = freq64[i]&0xffff; if ( cnt==0 ) break; |