diff --git a/src/alf.c b/src/alf.c index af587000..c92190fc 100644 --- a/src/alf.c +++ b/src/alf.c @@ -3320,7 +3320,7 @@ void kvz_alf_create(videoframe_t *frame, enum kvz_chroma_format chroma_format) init_alf_covariance(&alf_info->alf_covariance_frame_chroma[k], chroma_coeffs); } - alf_info->alf_covariance_cc_alf[MAX_NUM_COMPONENT - 1] = malloc(num_ctus_in_pic * MAX_NUM_CC_ALF_FILTERS * (MAX_NUM_COMPONENT - 1) * sizeof(*alf_info->alf_covariance_cc_alf[MAX_NUM_COMPONENT - 1])); + alf_info->alf_covariance_cc_alf[MAX_NUM_COMPONENT - 1] = malloc(num_ctus_in_pic * MAX_NUM_CC_ALF_FILTERS * (MAX_NUM_COMPONENT - 1) * sizeof(alf_covariance)); for (int comp_idx = 0; comp_idx < (MAX_NUM_COMPONENT - 1); comp_idx++) { alf_info->alf_covariance_cc_alf[comp_idx] = &alf_info->alf_covariance_cc_alf[MAX_NUM_COMPONENT - 1][comp_idx * MAX_NUM_CC_ALF_FILTERS * num_ctus_in_pic]; @@ -3355,8 +3355,8 @@ void kvz_alf_create(videoframe_t *frame, enum kvz_chroma_format chroma_format) alf_info->best_filter_control = malloc(num_ctus_in_pic * sizeof(*alf_info->best_filter_control)); // Classification - alf_info->classifier = malloc(pic_height * sizeof(**alf_info->classifier)); - alf_info->classifier[0] = malloc(pic_height * pic_width * sizeof(*alf_info->classifier)); + alf_info->classifier = malloc(pic_height * sizeof(alf_classifier*)); + alf_info->classifier[0] = malloc(pic_height * pic_width * sizeof(alf_classifier)); for (int i = 1; i < pic_height; i++) { diff --git a/src/alf.h b/src/alf.h index 4155c901..862b284d 100644 --- a/src/alf.h +++ b/src/alf.h @@ -166,13 +166,22 @@ typedef enum { //---------------------------------------------------------------- //-------------------------typedef structs---------------------------- +#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__linux__) +#define PACK(__Declaration__) __Declaration__ __attribute__((__packed__)) +#else +#define PACK(__Declaration__) __pragma(pack(push, 1)) __Declaration__ __pragma(pack(pop)) +#endif + + +PACK( typedef struct alf_covariance { + double pix_acc; + int64_t ee[MAX_ALF_NUM_CLIPPING_VALUES][MAX_ALF_NUM_CLIPPING_VALUES][MAX_NUM_ALF_LUMA_COEFF][MAX_NUM_ALF_LUMA_COEFF]; + int32_t y[MAX_ALF_NUM_CLIPPING_VALUES][MAX_NUM_ALF_LUMA_COEFF]; int num_coeff; int num_bins; - double y[MAX_ALF_NUM_CLIPPING_VALUES][MAX_NUM_ALF_LUMA_COEFF]; - double ee[MAX_ALF_NUM_CLIPPING_VALUES][MAX_ALF_NUM_CLIPPING_VALUES][MAX_NUM_ALF_LUMA_COEFF][MAX_NUM_ALF_LUMA_COEFF]; - double pix_acc; -} alf_covariance; +} alf_covariance;) + typedef struct clp_rng { int min; @@ -188,8 +197,8 @@ typedef struct clp_rngs { } clp_rngs; typedef struct alf_classifier { - int class_idx; - int transpose_idx; + uint8_t class_idx; + uint8_t transpose_idx; } alf_classifier; typedef struct cc_alf_filter_param {