]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vaapi_encode.c
avcodec/wmalosslessdec: Replace negative channel check by assert
[ffmpeg] / libavcodec / vaapi_encode.c
index 2fb43cf1a46370d7a86ad057ab4f13d54e34de7d..b0235114df2284b8e9a0af7845dcb068bd3a34c4 100644 (file)
@@ -480,7 +480,7 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
                     .width  = roi->right  - roi->left,
                     .height = roi->bottom - roi->top,
                 },
-                .roi_value = av_clip_c(v, INT8_MIN, INT8_MAX),
+                .roi_value = av_clip_int8(v),
             };
         }
 
@@ -579,6 +579,8 @@ static int vaapi_encode_output(AVCodecContext *avctx,
     VAAPIEncodeContext *ctx = avctx->priv_data;
     VACodedBufferSegment *buf_list, *buf;
     VAStatus vas;
+    int total_size = 0;
+    uint8_t *ptr;
     int err;
 
     err = vaapi_encode_wait(avctx, pic);
@@ -595,15 +597,21 @@ static int vaapi_encode_output(AVCodecContext *avctx,
         goto fail;
     }
 
+    for (buf = buf_list; buf; buf = buf->next)
+        total_size += buf->size;
+
+    err = av_new_packet(pkt, total_size);
+    ptr = pkt->data;
+
+    if (err < 0)
+        goto fail_mapped;
+
     for (buf = buf_list; buf; buf = buf->next) {
         av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
                "(status %08x).\n", buf->size, buf->status);
 
-        err = av_new_packet(pkt, buf->size);
-        if (err < 0)
-            goto fail_mapped;
-
-        memcpy(pkt->data, buf->buf, buf->size);
+        memcpy(ptr, buf->buf, buf->size);
+        ptr += buf->size;
     }
 
     if (pic->type == PICTURE_TYPE_IDR)