]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/qsvenc.c
avcodec/qsvenc: Set MaxKpbs to rc_max_rate for CBR and VBR (bitrate is equal to rc_ma...
[ffmpeg] / libavcodec / qsvenc.c
index 88e0b486191d93fc8b5d7971a67a613894536321..e5d3fa605d0e9606a5b19f178dc1fd2dc2f6398b 100644 (file)
@@ -58,7 +58,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
     q->param.mfx.TargetUsage        = q->preset;
     q->param.mfx.GopPicSize         = FFMAX(0, avctx->gop_size);
     q->param.mfx.GopRefDist         = FFMAX(-1, avctx->max_b_frames) + 1;
-    q->param.mfx.GopOptFlag         = avctx->flags & CODEC_FLAG_CLOSED_GOP ?
+    q->param.mfx.GopOptFlag         = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ?
                                       MFX_GOP_CLOSED : 0;
     q->param.mfx.IdrInterval        = q->idr_interval;
     q->param.mfx.NumSlice           = avctx->slices;
@@ -78,7 +78,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
     q->param.mfx.FrameInfo.BitDepthChroma = 8;
     q->param.mfx.FrameInfo.Width          = FFALIGN(avctx->width, q->width_align);
 
-    if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) {
+    if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
        /* A true field layout (TFF or BFF) is not important here,
           it will specified later during frame encoding. But it is important
           to specify is frame progressive or not because allowed heigh alignment
@@ -100,7 +100,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
         q->param.mfx.FrameInfo.FrameRateExtD  = avctx->time_base.num;
     }
 
-    if (avctx->flags & CODEC_FLAG_QSCALE) {
+    if (avctx->flags & AV_CODEC_FLAG_QSCALE) {
         q->param.mfx.RateControlMethod = MFX_RATECONTROL_CQP;
         ratecontrol_desc = "constant quantization parameter (CQP)";
     } else if (avctx->rc_max_rate == avctx->bit_rate) {
@@ -121,7 +121,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
     case MFX_RATECONTROL_VBR:
         q->param.mfx.InitialDelayInKB = avctx->rc_initial_buffer_occupancy / 1000;
         q->param.mfx.TargetKbps       = avctx->bit_rate / 1000;
-        q->param.mfx.MaxKbps          = avctx->bit_rate / 1000;
+        q->param.mfx.MaxKbps          = avctx->rc_max_rate / 1000;
         break;
     case MFX_RATECONTROL_CQP:
         quant = avctx->global_quality / FF_QP2LAMBDA;
@@ -189,7 +189,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q)
     }
 
     avctx->extradata = av_malloc(extradata.SPSBufSize + need_pps * extradata.PPSBufSize +
-                                 FF_INPUT_BUFFER_PADDING_SIZE);
+                                 AV_INPUT_BUFFER_PADDING_SIZE);
     if (!avctx->extradata)
         return AVERROR(ENOMEM);
 
@@ -197,7 +197,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q)
     if (need_pps)
         memcpy(avctx->extradata + extradata.SPSBufSize, pps_buf, extradata.PPSBufSize);
     avctx->extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize;
-    memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+    memset(avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
     return 0;
 }
@@ -419,7 +419,7 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
     do {
         ret = MFXVideoENCODE_EncodeFrameAsync(q->session, NULL, surf, bs, &sync);
         if (ret == MFX_WRN_DEVICE_BUSY) {
-            av_usleep(1);
+            av_usleep(500);
             continue;
         }
         break;