diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 442b9efe2735f77bf56d7f735783fc0f68be83f8..e12b677a932912228580d365aae53f7f9dc04dfe 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -504,13 +504,13 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
         goto free_and_end;
     }
     avctx->frame_number = 0;
-    if(avctx->codec->init){
-        if (avctx->codec->max_lowres < avctx->lowres) {
-            av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
-                   avctx->codec->max_lowres);
-            goto free_and_end;
-        }
+    if (avctx->codec->max_lowres < avctx->lowres) {
+        av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
+               avctx->codec->max_lowres);
+        goto free_and_end;
+    }
 
+    if(avctx->codec->init){
         ret = avctx->codec->init(avctx);
         if (ret < 0) {
             goto free_and_end;