diff --git a/libavfilter/vf_pixdesctest.c b/libavfilter/vf_pixdesctest.c
index 4b11b8c2b4e2661419439696e9516753adaa310b..9aee48287470c8266061c2fa66f468ffa18fe0b4 100644
--- a/libavfilter/vf_pixdesctest.c
+++ b/libavfilter/vf_pixdesctest.c
@@ -74,7 +74,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
     /* copy palette */
     if (priv->pix_desc->flags & PIX_FMT_PAL ||
         priv->pix_desc->flags & PIX_FMT_PSEUDOPAL)
-        memcpy(outpicref->data[1], picref->data[1], 256*4);
+        memcpy(outpicref->data[1], picref->data[1], AVPALETTE_SIZE);
 
     avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
 }