---
The generic end_frame taking an MpegEncContext (wtf?) is no longer commonc - 
there seems little point in it.

 libavcodec/vaapi_mpeg2.c | 53 ++++++++++++++++++++++++++++++++++++------------
 1 file changed, 40 insertions(+), 13 deletions(-)

diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c
index 3ea868c..5b415b5 100644
--- a/libavcodec/vaapi_mpeg2.c
+++ b/libavcodec/vaapi_mpeg2.c
@@ -22,7 +22,7 @@

 #include "mpegutils.h"
 #include "mpegvideo.h"
-#include "vaapi_internal.h"
+#include "vaapi_decode.h"
 #include "internal.h"

 /** Reconstruct bitstream f_code */
@@ -43,15 +43,17 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx,
                                    av_unused uint32_t size)
 {
     const MpegEncContext *s = avctx->priv_data;
-    struct vaapi_context *vactx = avctx->hwaccel_context;
+    VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private;
     VAPictureParameterBufferMPEG2 *pic_param;
     VAIQMatrixBufferMPEG2         *iq_matrix;
     int i;

-    vactx->slice_param_size = sizeof(VASliceParameterBufferMPEG2);
+    pic->output_surface = ff_vaapi_get_surface_id(s->current_picture_ptr->f);

     /* Fill in VAPictureParameterBufferMPEG2 */
-    pic_param = ff_vaapi_alloc_pic_param(vactx, 
sizeof(VAPictureParameterBufferMPEG2));
+    pic_param = ff_vaapi_decode_alloc_param_buffer(avctx, pic,
+                                                   
VAPictureParameterBufferType,
+                                                   sizeof(*pic_param));
     if (!pic_param)
         return -1;
     pic_param->horizontal_size                                  = s->width;
@@ -83,7 +85,9 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx,
     }

     /* Fill in VAIQMatrixBufferMPEG2 */
-    iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferMPEG2));
+    iq_matrix = ff_vaapi_decode_alloc_param_buffer(avctx, pic,
+                                                   VAIQMatrixBufferType,
+                                                   sizeof(*iq_matrix));
     if (!iq_matrix)
         return -1;
     iq_matrix->load_intra_quantiser_matrix              = 1;
@@ -101,11 +105,28 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx,
     return 0;
 }

+static int vaapi_mpeg2_end_frame(AVCodecContext *avctx)
+{
+    MpegEncContext     *s   = avctx->priv_data;
+    VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private;
+    int ret;
+
+    ret = ff_vaapi_decode_issue(avctx, pic);
+    if (ret < 0)
+        goto fail;
+
+    ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
+
+fail:
+    return ret;
+}
+
 static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx,
                                     const uint8_t *buffer,
                                     uint32_t size)
 {
     const MpegEncContext *s = avctx->priv_data;
+    VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private;
     VASliceParameterBufferMPEG2 *slice_param;
     GetBitContext gb;
     uint32_t quantiser_scale_code, intra_slice_flag, macroblock_offset;
@@ -124,7 +145,9 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx,
     macroblock_offset = get_bits_count(&gb);

     /* Fill in VASliceParameterBufferMPEG2 */
-    slice_param = (VASliceParameterBufferMPEG2 
*)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size);
+    slice_param = ff_vaapi_decode_alloc_slice_buffer(avctx, pic,
+                                                     sizeof(*slice_param),
+                                                     buffer, size);
     if (!slice_param)
         return -1;
     slice_param->macroblock_offset              = macroblock_offset;
@@ -136,11 +159,15 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx,
 }

 AVHWAccel ff_mpeg2_vaapi_hwaccel = {
-    .name           = "mpeg2_vaapi",
-    .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = AV_CODEC_ID_MPEG2VIDEO,
-    .pix_fmt        = AV_PIX_FMT_VAAPI,
-    .start_frame    = vaapi_mpeg2_start_frame,
-    .end_frame      = ff_vaapi_mpeg_end_frame,
-    .decode_slice   = vaapi_mpeg2_decode_slice,
+    .name                 = "mpeg2_vaapi",
+    .type                 = AVMEDIA_TYPE_VIDEO,
+    .id                   = AV_CODEC_ID_MPEG2VIDEO,
+    .pix_fmt              = AV_PIX_FMT_VAAPI,
+    .start_frame          = &vaapi_mpeg2_start_frame,
+    .end_frame            = &vaapi_mpeg2_end_frame,
+    .decode_slice         = &vaapi_mpeg2_decode_slice,
+    .frame_priv_data_size = sizeof(VAAPIDecodePicture),
+    .init                 = &ff_vaapi_decode_init,
+    .uninit               = &ff_vaapi_decode_uninit,
+    .priv_data_size       = sizeof(VAAPIDecodeContext),
 };
-- 
2.8.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to