diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index e67f098a6dab42e3f693ea04cbb186ac159800f1..345c7e1ebe86a087f5832e3ee79948b30549cc42 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -350,6 +350,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
                ncomponents > 2 ? s->cdx[2] : 0,
                ncomponents > 2 ? s->cdy[2] : 0);
     }
+    s->avctx->bits_per_raw_sample = s->precision;
     return 0;
 }