diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 094e03d8fac33798593f7ec621e7476aa98564ba..5f2fa4966ce7d861d2572fdb54ff60f335db0a89 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -173,7 +173,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
     }else
         s->maxval=1;
     /* more check if YUV420 */
-    if (av_pix_fmt_descriptors[avctx->pix_fmt].flags & PIX_FMT_PLANAR) {
+    if (av_pix_fmt_desc_get(avctx->pix_fmt)->flags & PIX_FMT_PLANAR) {
         if ((avctx->width & 1) != 0)
             return AVERROR_INVALIDDATA;
         h = (avctx->height * 2);
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index b09649202da8a0d503e650d2923454a511586e17..7d8792f0ffc0ba1b1ac5de4734b444a9306af856 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -89,7 +89,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
              "P%c\n%d %d\n", c, avctx->width, h1);
     s->bytestream += strlen(s->bytestream);
     if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE) {
-        int maxdepth = (1 << (av_pix_fmt_descriptors[avctx->pix_fmt].comp[0].depth_minus1 + 1)) - 1;
+        int maxdepth = (1 << (av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth_minus1 + 1)) - 1;
         snprintf(s->bytestream, s->bytestream_end - s->bytestream,
                  "%d\n", maxdepth);
         s->bytestream += strlen(s->bytestream);