[FFmpeg-cvslog] lavc: drop encode() support for video.

Anton Khirnov git at videolan.org
Fri Feb 24 04:35:03 CET 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Thu Feb 23 11:02:11 2012 +0100| [ff311c091854a2cf2d49b5ecfa6759084fe643a7] | committer: Anton Khirnov

lavc: drop encode() support for video.

All video encoders have been converted to encode2(), all new encoders
should also use only encode2().

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff311c091854a2cf2d49b5ecfa6759084fe643a7
---

 libavcodec/utils.c |   48 ++++++++----------------------------------------
 1 files changed, 8 insertions(+), 40 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index c88f379..67c9e36 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1082,9 +1082,6 @@ int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf
 }
 #endif
 
-#define MAX_CODED_FRAME_SIZE(width, height)\
-    (8*(width)*(height) + FF_MIN_BUFFER_SIZE)
-
 int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
                                               AVPacket *avpkt,
                                               const AVFrame *frame,
@@ -1103,44 +1100,15 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
     if (av_image_check_size(avctx->width, avctx->height, 0, avctx))
         return AVERROR(EINVAL);
 
-    if (avctx->codec->encode2) {
-        *got_packet_ptr = 0;
-        ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
-        if (!ret) {
-            if (!*got_packet_ptr)
-                avpkt->size = 0;
-            else if (!(avctx->codec->capabilities & CODEC_CAP_DELAY))
-                avpkt->pts = avpkt->dts = frame->pts;
-        }
-    } else {
-        /* for compatibility with encoders not supporting encode2(), we need to
-           allocate a packet buffer if the user has not provided one or check
-           the size otherwise */
-        int buf_size = avpkt->size;
-
-        if (!user_packet)
-            buf_size = MAX_CODED_FRAME_SIZE(avctx->width, avctx->height);
-
-        if ((ret = ff_alloc_packet(avpkt, buf_size)))
-            return ret;
-
-        /* encode the frame */
-        ret = avctx->codec->encode(avctx, avpkt->data, avpkt->size, frame);
-        if (ret >= 0) {
-            if (!ret) {
-                /* no output. if the packet data was allocated by libavcodec,
-                   free it */
-                if (!user_packet)
-                    av_freep(&avpkt->data);
-            } else if (avctx->coded_frame) {
-                avpkt->pts    = avctx->coded_frame->pts;
-                avpkt->flags |= AV_PKT_FLAG_KEY*avctx->coded_frame->key_frame;
-            }
+    av_assert0(avctx->codec->encode2);
 
-            avpkt->size     = ret;
-            *got_packet_ptr = (ret > 0);
-            ret             = 0;
-        }
+    *got_packet_ptr = 0;
+    ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
+    if (!ret) {
+        if (!*got_packet_ptr)
+            avpkt->size = 0;
+        else if (!(avctx->codec->capabilities & CODEC_CAP_DELAY))
+            avpkt->pts = avpkt->dts = frame->pts;
     }
 
     if (!ret)



More information about the ffmpeg-cvslog mailing list