[FFmpeg-cvslog] mpegvideo_enc: don't use deprecated avcodec_encode_video().
Anton Khirnov
git at videolan.org
Sat Aug 18 15:26:30 CEST 2012
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Aug 15 09:35:18 2012 +0200| [7f9aaa499b8a5ce066cc17aac6ebbdf0111980b6] | committer: Anton Khirnov
mpegvideo_enc: don't use deprecated avcodec_encode_video().
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f9aaa499b8a5ce066cc17aac6ebbdf0111980b6
---
libavcodec/mpegvideo_enc.c | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index d527ace..65f2281 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1068,6 +1068,22 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
return 0;
}
+static int encode_frame(AVCodecContext *c, AVFrame *frame)
+{
+ AVPacket pkt = { 0 };
+ int ret, got_output;
+
+ av_init_packet(&pkt);
+ av_init_packet(&pkt);
+ ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
+ if (ret < 0)
+ return ret;
+
+ ret = pkt.size;
+ av_free_packet(&pkt);
+ return ret;
+}
+
static int estimate_best_b_count(MpegEncContext *s)
{
AVCodec *codec = avcodec_find_encoder(s->avctx->codec_id);
@@ -1075,8 +1091,6 @@ static int estimate_best_b_count(MpegEncContext *s)
AVFrame input[FF_MAX_B_FRAMES + 2];
const int scale = s->avctx->brd_scale;
int i, j, out_size, p_lambda, b_lambda, lambda2;
- int outbuf_size = s->width * s->height; // FIXME
- uint8_t *outbuf = av_malloc(outbuf_size);
int64_t best_rd = INT64_MAX;
int best_b_count = -1;
@@ -1153,8 +1167,9 @@ static int estimate_best_b_count(MpegEncContext *s)
input[0].pict_type = AV_PICTURE_TYPE_I;
input[0].quality = 1 * FF_QP2LAMBDA;
- out_size = avcodec_encode_video(c, outbuf,
- outbuf_size, &input[0]);
+
+ out_size = encode_frame(c, &input[0]);
+
//rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT;
for (i = 0; i < s->max_b_frames + 1; i++) {
@@ -1163,14 +1178,15 @@ static int estimate_best_b_count(MpegEncContext *s)
input[i + 1].pict_type = is_p ?
AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_B;
input[i + 1].quality = is_p ? p_lambda : b_lambda;
- out_size = avcodec_encode_video(c, outbuf, outbuf_size,
- &input[i + 1]);
+
+ out_size = encode_frame(c, &input[i + 1]);
+
rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3);
}
/* get the delayed frames */
while (out_size) {
- out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
+ out_size = encode_frame(c, NULL);
rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3);
}
@@ -1182,7 +1198,6 @@ static int estimate_best_b_count(MpegEncContext *s)
}
}
- av_freep(&outbuf);
avcodec_close(c);
av_freep(&c);
More information about the ffmpeg-cvslog
mailing list