diff --git a/modules/codec/x265.c b/modules/codec/x265.c
index 50fe3285a31b5994eb772ccaf97d7a9de3b70c1a..9c3c2311c4f35d0743ea15311fa5171e5284868c 100644
--- a/modules/codec/x265.c
+++ b/modules/codec/x265.c
@@ -39,6 +39,9 @@
 #ifndef X265_MAX_FRAME_THREADS
 # define X265_MAX_FRAME_THREADS 16
 #endif
+#if X265_BUILD > 210 && X265_BUILD <= 214
+#define X265_OUTPUT_ARRAY 1
+#endif
 
 /*****************************************************************************
  * Module descriptor
@@ -74,7 +77,7 @@ static block_t *Encode(encoder_t *p_enc, picture_t *p_pict)
     x265_picture pic;
 
     x265_picture_init(&p_sys->param, &pic);
-#ifdef MAX_SCALABLE_LAYERS
+#ifdef X265_OUTPUT_ARRAY
     /* Handle API changes for scalable layers output in x265 4.0 */
     x265_picture *pics[MAX_SCALABLE_LAYERS] = {NULL};
     pics[0] = &pic;
@@ -97,7 +100,7 @@ static block_t *Encode(encoder_t *p_enc, picture_t *p_pict)
 
     x265_nal *nal;
     uint32_t i_nal = 0;
-#ifdef MAX_SCALABLE_LAYERS
+#ifdef X265_OUTPUT_ARRAY
     x265_encoder_encode(p_sys->h, &nal, &i_nal,
                         likely(p_pict) ? &pic : NULL, pics);
 #else