diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
index 97836b3ab1..e32b07ce8a 100644
--- a/libavcodec/cinepak.c
+++ b/libavcodec/cinepak.c
@@ -46,6 +46,20 @@
 #include "avcodec.h"
 #include "internal.h"
 
+/* allow to choose which output formats are to be supported,
+ * if nothing specific is enabled explicitly, activate all */
+#if !defined(CINEPAK_ENABLE_DECODE_TO_RGB32) && \
+    !defined(CINEPAK_ENABLE_DECODE_TO_RGB24) && \
+    !defined(CINEPAK_ENABLE_DECODE_TO_RGB565) && \
+    !defined(CINEPAK_ENABLE_DECODE_TO_YUV420P) && \
+    !defined(CINEPAK_ENABLE_DECODE_TO_PAL8)
+#define CINEPAK_ENABLE_DECODE_TO_RGB32
+#define CINEPAK_ENABLE_DECODE_TO_RGB24
+#define CINEPAK_ENABLE_DECODE_TO_RGB565
+#define CINEPAK_ENABLE_DECODE_TO_YUV420P
+#define CINEPAK_ENABLE_DECODE_TO_PAL8
+#endif
+
 /* rounding to nearest; truncation would be slightly faster
  * but it noticeably affects the picture quality;
  * unless we become extremely desperate to use every single cycle
@@ -64,11 +78,21 @@
  */
 
 typedef union cvid_codebook {
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB32
     uint32_t   rgb32[256][ 4];
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB24
     uint8_t    rgb24[256][12];
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB565
     uint16_t  rgb565[256][ 4];
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P
     uint8_t  yuv420p[256][ 6];
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_PAL8
     uint8_t     pal8[256][ 4];
+#endif
 } cvid_codebook;
 
 #define MAX_STRIPS      32    /* an arbitrary limit -- rl */
@@ -233,6 +257,7 @@ static int cinepak_decode_vectors_##pixel_format (CinepakContext *s, cvid_strip
  * (instead of in-loop checking) */\
         VECTOR_STREAM_PARSING\
 
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB32
 DECODE_CODEBOOK(rgb32)
     uint32_t *p = codebook->rgb32[0];
 
@@ -320,7 +345,9 @@ DECODE_VECTORS(rgb32)
 
     return 0;
 }
+#endif /* #ifdef CINEPAK_ENABLE_DECODE_TO_RGB32 */
 
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB24
 DECODE_CODEBOOK(rgb24)
     uint8_t *p = codebook->rgb24[0];
 
@@ -411,7 +438,9 @@ DECODE_VECTORS(rgb24)
 
     return 0;
 }
+#endif /* #ifdef CINEPAK_ENABLE_DECODE_TO_RGB24 */
 
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB565
 DECODE_CODEBOOK(rgb565)
     uint16_t *p = codebook->rgb565[0];
 
@@ -498,7 +527,9 @@ DECODE_VECTORS(rgb565)
 
     return 0;
 }
+#endif /* #ifdef CINEPAK_ENABLE_DECODE_TO_RGB565 */
 
+#ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P
 /* a simplistic version to begin with, it is also fast -- rl */
 DECODE_CODEBOOK(yuv420p)
     uint8_t *p = codebook->yuv420p[0];
@@ -620,7 +651,9 @@ DECODE_VECTORS(yuv420p)
 
     return 0;
 }
+#endif /* #ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P */
 
+#ifdef CINEPAK_ENABLE_DECODE_TO_PAL8
 /* here we do not expect anything besides palettized video,
  * nor check the data for validity, which should be ok,
  * to the best of our knowledge we do not write beyond the bounds */
@@ -702,6 +735,7 @@ DECODE_VECTORS(pal8)
 
     return 0;
 }
+#endif /* #ifdef CINEPAK_ENABLE_DECODE_TO_PAL8 */
 
 static int cinepak_decode_strip (CinepakContext *s,
                                  cvid_strip *strip, const uint8_t *data, int size)
@@ -844,20 +878,38 @@ static int cinepak_decode (CinepakContext *s)
 
 /* given a palettized input */
 static const enum AVPixelFormat pixfmt_list[] = {
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB24
     AV_PIX_FMT_RGB24,
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB32
     AV_PIX_FMT_RGB32,
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB565
     AV_PIX_FMT_RGB565,
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P
     AV_PIX_FMT_YUV420P,
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_PAL8
     AV_PIX_FMT_PAL8, /* only when input is palettized */
+#endif
     AV_PIX_FMT_NONE
 };
 
 /* given a non-palettized input */
 static const enum AVPixelFormat pixfmt_list_2[] = {
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB24
     AV_PIX_FMT_RGB24,
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB32
     AV_PIX_FMT_RGB32,
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB565
     AV_PIX_FMT_RGB565,
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P
     AV_PIX_FMT_YUV420P,
+#endif
     AV_PIX_FMT_NONE
 };
 
@@ -891,16 +943,26 @@ static av_cold int cinepak_decode_init(AVCodecContext *avctx)
  break;\
 
     switch (avctx->pix_fmt) {
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB32
     case AV_PIX_FMT_RGB32:   DECODE_TO(rgb32)
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB24
     case AV_PIX_FMT_RGB24:   DECODE_TO(rgb24)
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_RGB565
     case AV_PIX_FMT_RGB565:  DECODE_TO(rgb565)
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P
     case AV_PIX_FMT_YUV420P: DECODE_TO(yuv420p)
+#endif
+#ifdef CINEPAK_ENABLE_DECODE_TO_PAL8
     case AV_PIX_FMT_PAL8:
         if (!s->palette_video) {
             av_log(avctx, AV_LOG_ERROR, "Palettized output not supported without palettized input\n");
             return AVERROR(EINVAL);
         }
         DECODE_TO(pal8)
+#endif
     default:
         av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format %s\n", av_get_pix_fmt_name(avctx->pix_fmt));
         return AVERROR(EINVAL);
