diff --git a/ffmpeg.c b/ffmpeg.c
index 635ac311e2c62ce6cf8bb104a115ff9663ad0d80..ce9cac7846b4a38c6a0e0609784855bfdf9e601d 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -49,6 +49,7 @@
 #include "libavutil/parseutils.h"
 #include "libavutil/samplefmt.h"
 #include "libavutil/fifo.h"
+#include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/dict.h"
 #include "libavutil/mathematics.h"
@@ -1264,6 +1265,7 @@ static void do_video_stats(OutputStream *ost, int frame_size)
         frame_number = ost->st->nb_frames;
         fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
                 ost->quality / (float)FF_QP2LAMBDA);
+
         if (enc->coded_frame && (enc->flags&CODEC_FLAG_PSNR))
             fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
 
@@ -1583,6 +1585,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
                 for (j = 0; j < 32; j++)
                     snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log2(qp_histogram[j] + 1)));
             }
+
             if ((enc->flags&CODEC_FLAG_PSNR) && (enc->coded_frame || is_last_report)) {
                 int j;
                 double error, error_sum = 0;
diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c
index 6aede994e5f1e02ac504ebc2d622eb9260d55dcc..6ceb6584876d9ea11811cdd269e16f82b71db4bf 100644
--- a/libavcodec/aliaspixenc.c
+++ b/libavcodec/aliaspixenc.c
@@ -33,8 +33,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     int width, height, bits_pixel, i, j, length, ret;
     uint8_t *in_buf, *buf;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     width  = avctx->width;
     height = avctx->height;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index cc2f3cce4dad13ea6357c8e8ebe5873825f7e7cd..6cfbea4324968b3a1b58996d11f5d119719de3a5 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2773,12 +2773,16 @@ typedef struct AVCodecContext {
      int lowres;
 #endif
 
+#if FF_API_CODED_FRAME
     /**
      * the picture in the bitstream
      * - encoding: Set by libavcodec.
      * - decoding: unused
+     *
+     * @deprecated use the quality factor packet side data instead
      */
-    AVFrame *coded_frame;
+    attribute_deprecated AVFrame *coded_frame;
+#endif
 
     /**
      * thread count
diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c
index 27723151202ab02805c8346a4b7720bd3db2d11a..fc72e5dedd5715614da5a3e27117143cd4142e06 100644
--- a/libavcodec/bmpenc.c
+++ b/libavcodec/bmpenc.c
@@ -74,8 +74,12 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     int bit_count = avctx->bits_per_coded_sample;
     uint8_t *ptr, *buf;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     switch (avctx->pix_fmt) {
     case AV_PIX_FMT_RGB444:
         compression = BMP_BITFIELDS;
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 5eba9f65ed3f36dbb487115d5188eae73f0b1594..930240216c4d9114b4336688e7bb95619ae80834 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -388,8 +388,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
     FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale,
                       ctx->m.mb_num * sizeof(uint8_t), fail);
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->key_frame = 1;
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     if (avctx->thread_count > MAX_THREADS) {
         av_log(avctx, AV_LOG_ERROR, "too many threads\n");
@@ -1040,7 +1044,11 @@ static void dnxhd_load_picture(DNXHDEncContext *ctx, const AVFrame *frame)
         ctx->thread[i]->dct_uv_offset = ctx->m.uvlinesize*8;
     }
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     ctx->m.avctx->coded_frame->interlaced_frame = frame->interlaced_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     ctx->cur_field = frame->interlaced_frame && !frame->top_field_first;
 }
 
@@ -1101,7 +1109,11 @@ encode_coding_unit:
         goto encode_coding_unit;
     }
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->quality = ctx->qscale * FF_QP2LAMBDA;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, sizeof(int));
     if (!sd)
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index cc5678ca91c27e66fbdb9cfa3c7fc3599678f3e8..81cee0d372c8393138bd1158b45bf416ee5cdcd8 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -722,8 +722,12 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,
 
     c->pix_fmt                = s->sys->pix_fmt;
     s->frame                  = frame;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     c->coded_frame->key_frame = 1;
     c->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     s->buf = pkt->data;
     c->execute(c, dv_encode_video_segment, s->work_chunks, NULL,
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index b1380ec209cdae22fcb62fc632b19407e0bb86dd..af42a18608b6f8064b9a1c537d3ed4beba6796eb 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -853,7 +853,11 @@ static av_cold int encode_init(AVCodecContext *avctx)
     if ((ret = ffv1_allocate_initial_states(s)) < 0)
         return ret;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     if (!s->transparency)
         s->plane_count = 2;
@@ -1314,7 +1318,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     if (avctx->flags & CODEC_FLAG_PASS1)
         avctx->stats_out[0] = '\0';
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->key_frame = f->key_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     f->picture_number++;
     pkt->size   = buf_p - pkt->data;
diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c
index 5c1f7ad5262fb95594c8435bc8494f2221c983a7..b679e289d355fdf2626fb291ffdae61f9a7e42bf 100644
--- a/libavcodec/flashsvenc.c
+++ b/libavcodec/flashsvenc.c
@@ -254,13 +254,21 @@ static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     //mark the frame type so the muxer can mux it correctly
     if (I_frame) {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         avctx->coded_frame->pict_type      = AV_PICTURE_TYPE_I;
         avctx->coded_frame->key_frame      = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
         s->last_key_frame = avctx->frame_number;
         ff_dlog(avctx, "Inserting keyframe at frame %d\n", avctx->frame_number);
     } else {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
         avctx->coded_frame->key_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     }
 
     if (I_frame)
diff --git a/libavcodec/gif.c b/libavcodec/gif.c
index d92a0bcb4eda8c3c726ede3277efcc88e79ff25f..7ac95d26c819726fb5c0efd8a76dee1e2bb9baad 100644
--- a/libavcodec/gif.c
+++ b/libavcodec/gif.c
@@ -221,8 +221,12 @@ static av_cold int gif_encode_init(AVCodecContext *avctx)
         av_log(avctx, AV_LOG_ERROR, "GIF does not support resolutions above 65535x65535\n");
         return AVERROR(EINVAL);
     }
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     s->transparent_index = -1;
 
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index a860f83758d529698e783e33461acac020ad65ed..ad8870936a48ad622e9e32babef734341ebdbe93 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -231,8 +231,12 @@ static av_cold int encode_init(AVCodecContext *avctx)
     if (!avctx->extradata)
         return AVERROR(ENOMEM);
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     s->bps = desc->comp[0].depth_minus1 + 1;
     s->yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 60a74270911cf19b3312ed5b3b6d9495da142349..f6ed4be364821e719b9cf4045eff937c7c21cc6b 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -414,8 +414,12 @@ memfail:
 
 static av_cold int encode_init_ls(AVCodecContext *ctx)
 {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     ctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     ctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     if (ctx->pix_fmt != AV_PIX_FMT_GRAY8  &&
         ctx->pix_fmt != AV_PIX_FMT_GRAY16 &&
diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c
index 256d0ca5be030f91929955c9ed032f31045838a7..7387da4a65d22b0d496d7ade454194f88721e210 100644
--- a/libavcodec/lclenc.c
+++ b/libavcodec/lclenc.c
@@ -135,8 +135,12 @@ static av_cold int encode_init(AVCodecContext *avctx)
     if (!avctx->extradata)
         return AVERROR(ENOMEM);
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     c->compression = avctx->compression_level == FF_COMPRESSION_DEFAULT ?
                             COMP_ZLIB_NORMAL :
diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c
index 4ba56c40b2ffcbcfcfc78fc454a36e3b5e7f7b71..2d69318ee21dc4ec3041e69d93d6c1cf481a43a0 100644
--- a/libavcodec/libschroedingerenc.c
+++ b/libavcodec/libschroedingerenc.c
@@ -383,12 +383,16 @@ static int libschroedinger_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         goto error;
 
     memcpy(pkt->data, p_frame_output->p_encbuf, p_frame_output->size);
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->key_frame = p_frame_output->key_frame;
+    avctx->coded_frame->pts = p_frame_output->frame_num;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     /* Use the frame number of the encoded frame as the pts. It is OK to
      * do so since Dirac is a constant frame rate codec. It expects input
      * to be of constant frame rate. */
-    pkt->pts =
-    avctx->coded_frame->pts = p_frame_output->frame_num;
+    pkt->pts = p_frame_output->frame_num;
     pkt->dts = p_schro_params->dts++;
     enc_size = p_frame_output->size;
 
diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index ccfb21ea0bc51446bba55e7fc760fe199ae95f77..43880072ca901075823a424a44f791e1d0e0538b 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -344,7 +344,11 @@ static int encode_frame(AVCodecContext* avc_context, AVPacket *pkt,
     // HACK: assumes no encoder delay, this is true until libtheora becomes
     // multithreaded (which will be disabled unless explicitly requested)
     pkt->pts = pkt->dts = frame->pts;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avc_context->coded_frame->key_frame = !(o_packet.granulepos & h->keyframe_mask);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     if (!(o_packet.granulepos & h->keyframe_mask))
         pkt->flags |= AV_PKT_FLAG_KEY;
     *got_packet = 1;
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index ff052c5b5837354510b7a0064ced3a44066b1ba4..7d301803b17f1b965034accaca70928b900dc251 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -692,14 +692,26 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
     if (ret >= 0) {
         memcpy(pkt->data, cx_frame->buf, pkt->size);
         pkt->pts = pkt->dts = cx_frame->pts;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         avctx->coded_frame->pts       = cx_frame->pts;
         avctx->coded_frame->key_frame = !!(cx_frame->flags & VPX_FRAME_IS_KEY);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
         if (!!(cx_frame->flags & VPX_FRAME_IS_KEY)) {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
             avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
             pkt->flags |= AV_PKT_FLAG_KEY;
         } else {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
             avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
         }
 
         if (cx_frame->have_sse) {
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 60938cf3c2597482073d7063b87db922c02bb81b..048edbf0e1adb78ca7685e40a72475f743f728de 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -287,6 +287,8 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
     pkt->pts = pic_out.i_pts;
     pkt->dts = pic_out.i_dts;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     switch (pic_out.i_type) {
     case X264_TYPE_IDR:
     case X264_TYPE_I:
@@ -300,6 +302,8 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
         ctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
         break;
     }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
     if (ret) {
@@ -309,7 +313,11 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
             return AVERROR(ENOMEM);
         *(int *)sd = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         ctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     }
 
     *got_packet = ret;
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 19c7742b6d91253e87772bfc9cef8356570f5a4c..c577a7218f56c0bcbdb54775de2235dfa8d09512 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -298,6 +298,8 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     pkt->pts = x265pic_out.pts;
     pkt->dts = x265pic_out.dts;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     switch (x265pic_out.sliceType) {
     case X265_TYPE_IDR:
     case X265_TYPE_I:
@@ -310,6 +312,8 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
         break;
     }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     *got_packet = 1;
     return 0;
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index e26204ccbf1aaa2a122b3830df2bbebec907c654..a1b48c04d99eb494212d6a600aff6d1ea1950660 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -159,7 +159,11 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt,
         return 0;
     }
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pts = pic_out.i_pts;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     pkt->pts = pic_out.i_pts;
     if (avctx->has_b_frames) {
         if (!x4->out_frame_count)
@@ -169,6 +173,8 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt,
     } else
         pkt->dts = pkt->pts;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     switch (pic_out.i_type) {
     case XAVS_TYPE_IDR:
     case XAVS_TYPE_I:
@@ -182,15 +188,25 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt,
         avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
         break;
     }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     /* There is no IDR frame in AVS JiZhun */
     /* Sequence header is used as a flag */
     if (pic_out.i_type == XAVS_TYPE_I) {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
         pkt->flags |= AV_PKT_FLAG_KEY;
     }
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, sizeof(int));
     if (!sd)
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 976066c8a0dbb17a349138ad21519200be2fe2b3..25c2476573ea9c881a2c789017c5ddfc27c76116 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -779,6 +779,8 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
         *got_packet = 1;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         avctx->coded_frame->quality = xvid_enc_stats.quant * FF_QP2LAMBDA;
         if (xvid_enc_stats.type == XVID_TYPE_PVOP)
             avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
@@ -788,14 +790,24 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             avctx->coded_frame->pict_type = AV_PICTURE_TYPE_S;
         else
             avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
         if (xvid_enc_frame.out_flags & XVID_KEYFRAME) {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
             avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
             pkt->flags  |= AV_PKT_FLAG_KEY;
             if (x->quicktime_format)
                 return xvid_strip_vol_header(avctx, pkt,
                                              xvid_enc_stats.hlength, xerr);
         } else {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
             avctx->coded_frame->key_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
         }
 
         pkt->size = xerr;
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 2716c7014d0fa7b408506c8ee5c76531afe9a322..c8d5a45a0e2eb83eb0def7189a561414c50d2461 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -285,8 +285,12 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch));
     if (!s->scratch)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 8ddfc02cf3080d42d49dd7ee1c32df0521fb49ec..0143d9dad82df0c357e9664497e34125ead5e4ee 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1617,7 +1617,11 @@ static void frame_end(MpegEncContext *s)
     if (s->pict_type!= AV_PICTURE_TYPE_B)
         s->last_non_b_pict_type = s->pict_type;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     av_frame_copy_props(s->avctx->coded_frame, s->current_picture.f);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 }
 
 static void update_noise_reduction(MpegEncContext *s)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 1f40086d287c52276da9b5856eeb004d7a50c3b7..0589cf1daaf39a0a2d8fd714c376ee3fc819fbe6 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1137,6 +1137,8 @@ static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, AVFrame
     switch (lock_params.pictureType) {
     case NV_ENC_PIC_TYPE_IDR:
         pkt->flags |= AV_PKT_FLAG_KEY;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     case NV_ENC_PIC_TYPE_I:
         avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
         break;
@@ -1154,6 +1156,8 @@ static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, AVFrame
         av_log(avctx, AV_LOG_ERROR, "Please report this error and include as much information on how to reproduce it as possible.\n");
         res = AVERROR_EXTERNAL;
         goto error;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     }
 
     pkt->pts = lock_params.outputTimeStamp;
diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c
index b361380ff69eba3cc99b6a398cc3096ab71f6c6a..03f6454fbc2fb84c034ef64ef36ef2a1b80f5fec 100644
--- a/libavcodec/pamenc.c
+++ b/libavcodec/pamenc.c
@@ -129,8 +129,12 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
 static av_cold int pam_encode_init(AVCodecContext *avctx)
 {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     return 0;
 }
diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c
index 2a4eb8ef59bb67af5d0745c3460354fca741cc1e..fef34bed9b5bab5c251c4d5c240150d834d86fc5 100644
--- a/libavcodec/pcxenc.c
+++ b/libavcodec/pcxenc.c
@@ -35,8 +35,12 @@ static const uint32_t monoblack_pal[16] = { 0x000000, 0xFFFFFF };
 
 static av_cold int pcx_encode_init(AVCodecContext *avctx)
 {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     return 0;
 }
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 94f2b108aeb31a599c1a3aec51a0e7c5cc5241ec..ad05311aabf4a75ab2007c177ae837374aa2d2b4 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -627,8 +627,12 @@ static av_cold int png_enc_init(AVCodecContext *avctx)
         avctx->bits_per_coded_sample = 8;
     }
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     ff_huffyuvencdsp_init(&s->hdsp);
 
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index 9f9d9f5eb08f514cc8c603ee384644b540de9805..05460ea85509f310d19c3f9dfa8372a01cd41cb1 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -120,8 +120,12 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
 static av_cold int pnm_encode_init(AVCodecContext *avctx)
 {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     return 0;
 }
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 46f932f596c395dd96ed447df80f688c5f6f6e88..8e873cd33ec1f1c18aaae09eb49da2a0c4aa9940 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1125,8 +1125,12 @@ static av_cold int encode_init(AVCodecContext *avctx)
     int interlaced = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
 
     avctx->bits_per_raw_sample = 10;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     ctx->fdct      = prores_fdct;
     ctx->scantable = interlaced ? ff_prores_interlaced_scan
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 8987c12fe783390da18d7880fd4b58cb541ff1ec..406641a78e83626bd13e645304d25e37dc39c8aa 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -242,7 +242,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
     if (for_user) {
         dst->delay       = src->thread_count - 1;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         dst->coded_frame = src->coded_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     } else {
         if (dst->codec->update_thread_context)
             err = dst->codec->update_thread_context(dst, src);
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index ac53bc4fb59349b4cc89aa8308cd186c45f35e34..88e0b486191d93fc8b5d7971a67a613894536321 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -466,12 +466,16 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
             bs->FrameType & MFX_FRAMETYPE_xIDR)
             new_pkt.flags |= AV_PKT_FLAG_KEY;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         if (bs->FrameType & MFX_FRAMETYPE_I || bs->FrameType & MFX_FRAMETYPE_xI)
             avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
         else if (bs->FrameType & MFX_FRAMETYPE_P || bs->FrameType & MFX_FRAMETYPE_xP)
             avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
         else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType & MFX_FRAMETYPE_xB)
             avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
         av_freep(&bs);
 
diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index 5fd633a582b218354b1f221ed3e85dc752c7f1da..9440f8f55623b67eb2331fa2a9d9d5f48334cc33 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -385,8 +385,12 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     av_picture_copy(&s->previous_frame, (const AVPicture *)pict,
                     avctx->pix_fmt, avctx->width, avctx->height);
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->key_frame = s->key_frame;
     avctx->coded_frame->pict_type = pict_type;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     if (s->key_frame)
         pkt->flags |= AV_PKT_FLAG_KEY;
diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
index 8a1b1dc4d027b595d4f61c0030c1980f9c80c38f..a6b6617c5bab2c9e1430d29620e2fac09caa2b3e 100644
--- a/libavcodec/rawenc.c
+++ b/libavcodec/rawenc.c
@@ -35,7 +35,11 @@ static av_cold int raw_encode_init(AVCodecContext *avctx)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc);
     if(!avctx->codec_tag)
         avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c
index 14efabeb03a39a219c93bbcb0ef3e81e44e95514..a16d079562ad0bdde19196db5d2dd90abba963fa 100644
--- a/libavcodec/sgienc.c
+++ b/libavcodec/sgienc.c
@@ -50,8 +50,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     unsigned int bytes_per_channel, pixmax, put_be;
     unsigned char *end_buf;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     width  = avctx->width;
     height = avctx->height;
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index f391c9553685c213fdc1f3d6a11842b5022fdd8d..cb3bc451b22e960066adf5c64e66c59cf9c261a1 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -611,8 +611,12 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         s->pict_type = AV_PICTURE_TYPE_I;
     s->quality = pict->quality;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = s->pict_type;
     avctx->coded_frame->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, sizeof(int));
     if (!sd)
diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
index 57e47b12d23c045498e9c728af6a3d7f02729dfa..e8a3dee4b2cc9c192640e4af71fcef18bc20f62a 100644
--- a/libavcodec/targaenc.c
+++ b/libavcodec/targaenc.c
@@ -172,8 +172,12 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
 static av_cold int targa_encode_init(AVCodecContext *avctx)
 {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->key_frame = 1;
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     return 0;
 }
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 273f8e4039844eb4efa3f544b7993ab0e638623b..543dcaf151eeb0dbe126bf9b6b1a61b82ee75522 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -521,8 +521,12 @@ fail:
 static av_cold int encode_init(AVCodecContext *avctx)
 {
     TiffEncoderContext *s = avctx->priv_data;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     avctx->coded_frame->key_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     s->avctx = avctx;
 
     return 0;
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 0456bd9a507d3b004963c1ca358c53d65fa86c76..16601dd96558a9806bfe9ed0d54df7cc44a9714b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1529,11 +1529,15 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
 
     if (av_codec_is_encoder(avctx->codec)) {
         int i;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         avctx->coded_frame = av_frame_alloc();
         if (!avctx->coded_frame) {
             ret = AVERROR(ENOMEM);
             goto free_and_end;
         }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
         if (avctx->codec->sample_fmts) {
             for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
                 if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
@@ -1756,7 +1760,11 @@ free_and_end:
         av_opt_free(avctx->priv_data);
     av_opt_free(avctx);
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     av_frame_free(&avctx->coded_frame);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     av_dict_free(&tmp);
     av_freep(&avctx->priv_data);
@@ -2907,7 +2915,11 @@ av_cold int avcodec_close(AVCodecContext *avctx)
     av_freep(&avctx->priv_data);
     if (av_codec_is_encoder(avctx->codec)) {
         av_freep(&avctx->extradata);
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         av_frame_free(&avctx->coded_frame);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     }
     avctx->codec = NULL;
     avctx->active_thread_type = 0;
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index 0cf593038a1aa3ce7323312e6356c1411cca5540..8a3ec5d12995807237985b3ef61274642f2dd491 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -613,8 +613,12 @@ static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
      * At least currently Ut Video is IDR only.
      * Set flags accordingly.
      */
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->key_frame = 1;
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     pkt->size   = bytestream2_tell_p(&pb);
     pkt->flags |= AV_PKT_FLAG_KEY;
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index c19d755818a0f41fdffb89204370d93511e83a73..65684bbb84c8bd3edd2f8a0a6f5e988cbb1a1bd8 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -91,7 +91,11 @@ static av_cold int encode_init(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     s->pack_line_8  = v210_planar_pack_8_c;
     s->pack_line_10 = v210_planar_pack_10_c;
diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c
index 90653784a78cd58d7d0b781e11c8157413eec2e8..19487dc219c172decd51927de0ddb01d49a1d187 100644
--- a/libavcodec/v410enc.c
+++ b/libavcodec/v410enc.c
@@ -47,8 +47,12 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         return ret;
     dst = pkt->data;
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->key_frame = 1;
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     y = (uint16_t *)pic->data[0];
     u = (uint16_t *)pic->data[1];
diff --git a/libavcodec/version.h b/libavcodec/version.h
index df0f25234aa3fb37c80063f3d8d7b52ca76caba1..c79e2bacd0a89115d638a43abab5ca5807dff5c1 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 56
 #define LIBAVCODEC_VERSION_MINOR  50
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
@@ -196,5 +196,8 @@
 #ifndef FF_API_RC_STRATEGY
 #define FF_API_RC_STRATEGY       (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_CODED_FRAME
+#define FF_API_CODED_FRAME       (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
index 46bda2a97d7fbbfec7ed2e8b6dbad966bcff244e..02adfa725e4a57bad4e01ac5a57180fe17cfa91d 100644
--- a/libavcodec/zmbvenc.c
+++ b/libavcodec/zmbvenc.c
@@ -133,8 +133,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     c->curfrm++;
     if(c->curfrm == c->keyint)
         c->curfrm = 0;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     avctx->coded_frame->pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
     avctx->coded_frame->key_frame = keyframe;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     chpal = !keyframe && memcmp(p->data[1], c->pal2, 1024);
 
     palptr = (uint32_t*)p->data[1];
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 64ac09c1c7afe1e3c17bc03ef1da681253fbcc2e..cc2be377958bf0434fae53f75a613dac7f0afbf3 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -987,7 +987,11 @@ fail:
 static int v4l2_read_packet(AVFormatContext *ctx, AVPacket *pkt)
 {
     struct video_data *s = ctx->priv_data;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     AVFrame *frame = ctx->streams[0]->codec->coded_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     int res;
 
     av_init_packet(pkt);
@@ -995,10 +999,14 @@ static int v4l2_read_packet(AVFormatContext *ctx, AVPacket *pkt)
         return res;
     }
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
     if (frame && s->interlaced) {
         frame->interlaced_frame = 1;
         frame->top_field_first = s->top_field_first;
     }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     return pkt->size;
 }