diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index d738d06ee63cdf7e93f48907871c5f4ab4fac227..46e2e2c3fc118e8f825ca3f8219eeebfd81c6824 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1259,7 +1259,7 @@ static int encode_frame(AVCodecContext *c, AVFrame *frame)
 
 static int estimate_best_b_count(MpegEncContext *s)
 {
-    AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
+    const AVCodec *codec = avcodec_find_encoder(s->avctx->codec_id);
     AVCodecContext *c = avcodec_alloc_context3(NULL);
     const int scale = s->brd_scale;
     int i, j, out_size, p_lambda, b_lambda, lambda2;