On Fri, Aug 17, 2012 at 11:50 PM, Anton Khirnov <[email protected]> wrote:
>
> Module: libav
> Branch: master
> Commit: 7f9aaa499b8a5ce066cc17aac6ebbdf0111980b6
>
> Author:    Anton Khirnov <[email protected]>
> Committer: Anton Khirnov <[email protected]>
> Date:      Wed Aug 15 09:35:18 2012 +0200
>
> mpegvideo_enc: don't use deprecated avcodec_encode_video().
>
> ---
>
>  libavcodec/mpegvideo_enc.c |   31 +++++++++++++++++++++++--------
>  1 files 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);

Why the double init?

> +    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);
>
>
> _______________________________________________
> libav-commits mailing list
> [email protected]
> https://lists.libav.org/mailman/listinfo/libav-commits
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to