The rationale is that before the alternative AVStats API, in most cases
coded_frame was only used to communicate key_frame, pict_type and
quality to the caller.

These values are not required for the encoding or muxing, and only serve
a pure statistical value. Additionally, its per-frame statistics, and
the new AVStats API ise directly associated with the packet (and
consequentely with the frame) they belong to.

There was agreement that there was no usecase for coded_frame, as it is
a full-sized AVFrame container used for just 2-3 int-sized properties,
which shouldn't even belong into the AVCodecContext in the first place.

Now key_frame is exported via the appropriate avpacket.flags, which
is something already in place since several years, and all the others
compression values (pict_type, quality and error) are exported via
AVStats packet side data, and copied to the decoded frame.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 doc/APIchanges             |  3 +++
 libavcodec/avcodec.h       |  5 +++++
 libavcodec/pthread_frame.c |  4 ++++
 libavcodec/utils.c         | 16 ++++++++++++++++
 libavcodec/version.h       |  5 ++++-
 5 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 591c8c7..1effece 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxxxxx - lavc 56.24.1
+  Deprecate avctx.coded_frame in favour of AVStats-style reporting.
+
 2015-xx-xx - xxxxxx - lavc 56.24, lavu 54.14 - avcodec.h, avutil.h, metadata.h
   Add AV_PKT_DATA_STATISTICS and AV_FRAME_DATA_STATISTICS to carry compression
   statistic in the form of an AVStats structure from the packet to the
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e5705ef..22125af 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2527,12 +2527,17 @@ typedef struct AVCodecContext {
     attribute_deprecated int lowres;
 #endif
 
+#if FF_API_CODED_FRAME
     /**
      * the picture in the bitstream
      * - encoding: Set by libavcodec.
      * - decoding: unused
+     *
+     * @deprecated use AVStats side data instead
      */
+    attribute_deprecated
     AVFrame *coded_frame;
+#endif /* FF_API_CODED_FRAME */
 
     /**
      * thread count
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index effc9a5..c760ba2 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -215,7 +215,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
     }
 
     if (for_user) {
+#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/utils.c b/libavcodec/utils.c
index 2669519..5b2ecc1 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1188,11 +1188,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])
@@ -1320,7 +1324,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);
@@ -1548,6 +1556,8 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
                 avpkt->data = avpkt->buf->data;
         }
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
         stats = (AVStats *)av_packet_get_side_data(avpkt,
                                                    AV_PKT_DATA_STATISTICS,
                                                    NULL);
@@ -1559,6 +1569,8 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
             for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
                 avctx->coded_frame->error[i] = stats->error[i];
         }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif /* FF_API_CODED_FRAME */
 
         avctx->frame_number++;
     }
@@ -1855,7 +1867,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/version.h b/libavcodec/version.h
index c478ca3..76eec16 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 56
 #define LIBAVCODEC_VERSION_MINOR 24
-#define LIBAVCODEC_VERSION_MICRO  0
+#define LIBAVCODEC_VERSION_MICRO  1
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
@@ -165,5 +165,8 @@
 #ifndef FF_API_STREAM_CODEC_TAG
 #define FF_API_STREAM_CODEC_TAG  (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_CODED_FRAME
+#define FF_API_CODED_FRAME       (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
-- 
1.9.5 (Apple Git-50.3)

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to