The rationale is that before the alternative AVPacketCodingParams API,
in most cases coded_frame was only used to communicate key_frame,
pict_type and quality to the caller (or a few other random fields).

These values are not required for the encoding or muxing, and only serve
a pure parametrical value. Additionally, it is per-frame data, and
the new AVPacketCodingParams API is directly associated with the packet
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
AVPacketCodingParams packet side data.

Signed-off-by: Vittorio Giovara <[email protected]>
---
 doc/APIchanges             |  3 +++
 libavcodec/avcodec.h       |  5 +++++
 libavcodec/pthread_frame.c |  4 ++++
 libavcodec/utils.c         | 18 ++++++++++++++++++
 libavcodec/version.h       |  5 ++++-
 5 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 08bd913..d45b6ab 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxxxxxx - lavc 56.25.1
+  Deprecate avctx.coded_frame in favour of AVPacketCodingParams-style 
reporting.
+
 2015-xx-xx - xxxxxxx - lavc 56.25.0 - avcodec.h
   Add AV_PKT_DATA_CODING_PARAMS and to carry AVPacket compression parameters
   in the form of an AVPacketCodingParams structure.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index eb28e7b..4323933 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2556,12 +2556,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 52d0bcc..779d8f2 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1186,11 +1186,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])
@@ -1318,7 +1322,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);
@@ -1533,7 +1541,9 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
 
     ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
     if (!ret) {
+#if FF_API_CODED_FRAME
         AVPacketCodingParams *params;
+#endif /* FF_API_CODED_FRAME */
 
         if (!*got_packet_ptr)
             avpkt->size = 0;
@@ -1546,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
         params = (AVPacketCodingParams *)
             av_packet_get_side_data(avpkt, AV_PKT_DATA_CODING_PARAMS, NULL);
         if (params) {
@@ -1561,6 +1573,8 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
             cf->sample_aspect_ratio = frame->sample_aspect_ratio;
             cf->pts                 = frame->pts;
         }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif /* FF_API_CODED_FRAME */
 
         avctx->frame_number++;
     }
@@ -1857,7 +1871,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 c57bd85..fbef12d 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 56
 #define LIBAVCODEC_VERSION_MINOR 25
-#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
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to