avcodec: va: change vlc_va_Get arguments

Provide the AVCodecContext and the full AVFrame. It will be used by the
new vaapi va module.
This commit is contained in:
Thomas Guillem 2021-07-08 12:53:09 +02:00
parent 2721256e9b
commit e3b5b5b07b
6 changed files with 22 additions and 13 deletions

View File

@ -192,8 +192,10 @@ static picture_context_t* NewSurfacePicContext(vlc_va_t *va, vlc_va_surface_t *v
return &pic_ctx->ctx.s;
}
static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
static int Get(vlc_va_t *va, picture_t *pic, AVCodecContext *ctx, AVFrame *frame)
{
(void) ctx;
vlc_va_sys_t *sys = va->sys;
vlc_va_surface_t *va_surface = va_pool_Get(sys->va_pool);
if (unlikely(va_surface == NULL))
@ -204,7 +206,7 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
va_surface_Release(va_surface);
return VLC_ENOMEM;
}
data[3] = (uint8_t*)sys->hw_surface[va_surface_GetIndex(va_surface)];
frame->data[3] = (uint8_t*)sys->hw_surface[va_surface_GetIndex(va_surface)];
return VLC_SUCCESS;
}

View File

@ -191,8 +191,9 @@ static picture_context_t* NewSurfacePicContext(vlc_va_t *va, vlc_va_surface_t *v
return &pic_ctx->ctx.s;
}
static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
static int Get(vlc_va_t *va, picture_t *pic, AVCodecContext *ctx, AVFrame *frame)
{
(void) ctx;
vlc_va_sys_t *sys = va->sys;
/* Check the device */
@ -215,7 +216,7 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
va_surface_Release(va_surface);
return VLC_ENOITEM;
}
data[3] = (uint8_t*)DXVA2_PICCONTEXT_FROM_PICCTX(pic->context)->ctx.picsys.surface;
frame->data[3] = (uint8_t*)DXVA2_PICCONTEXT_FROM_PICCTX(pic->context)->ctx.picsys.surface;
return VLC_SUCCESS;
}

View File

@ -31,7 +31,7 @@ typedef struct vlc_decoder_device vlc_decoder_device;
typedef struct vlc_video_context vlc_video_context;
struct vlc_va_operations {
int (*get)(vlc_va_t *, picture_t *pic, uint8_t **surface);
int (*get)(vlc_va_t *, picture_t *pic, AVCodecContext *ctx, AVFrame *frame);
void (*close)(vlc_va_t *);
};
@ -87,15 +87,17 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,
* AV_PIX_FMT_VAAPI - VASurfaceID
*
* @param pic pointer to VLC picture containing the surface [IN/OUT]
* @param surface pointer to the AVFrame data[0] and data[3] pointers [OUT]
* @param ctx pointer to the current AVCodecContext [IN]
* @param frame pointer to the AVFrame [IN]
*
* @note This function needs not be reentrant.
*
* @return VLC_SUCCESS on success, otherwise an error code.
*/
static inline int vlc_va_Get(vlc_va_t *va, picture_t *pic, uint8_t **surface)
static inline int vlc_va_Get(vlc_va_t *va, picture_t *pic, AVCodecContext *ctx,
AVFrame *frame)
{
return va->ops->get(va, pic, surface);
return va->ops->get(va, pic, ctx, frame);
}
/**

View File

@ -150,8 +150,10 @@ static picture_context_t *vaapi_dec_pic_context_copy(picture_context_t *src)
return &pic_ctx->ctx.s;
}
static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
static int Get(vlc_va_t *va, picture_t *pic, AVCodecContext *ctx, AVFrame *frame)
{
(void) ctx;
vlc_va_sys_t *sys = va->sys;
vlc_va_surface_t *va_surface = va_pool_Get(sys->va_pool);
if (unlikely(va_surface == NULL))
@ -170,7 +172,7 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
vaapi_ctx->ctx.va_dpy = sys->hw_ctx.display;
vaapi_ctx->va_surface = va_surface;
vlc_vaapi_PicSetContext(pic, &vaapi_ctx->ctx);
data[3] = (void *) (uintptr_t) vaapi_ctx->ctx.surface;
frame->data[3] = (void *) (uintptr_t) vaapi_ctx->ctx.surface;
return VLC_SUCCESS;
}

View File

@ -1395,7 +1395,7 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame)
return -1;
/* data[3] will contains the format-specific surface handle. */
if (vlc_va_Get(va, pic, &frame->data[0]))
if (vlc_va_Get(va, pic, ctx, frame))
{
msg_Err(dec, "hardware acceleration picture allocation failed");
picture_Release(pic);

View File

@ -109,8 +109,10 @@ static vlc_vdp_video_field_t *Get(vlc_va_sys_t *sys)
return field;
}
static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data)
static int Lock(vlc_va_t *va, picture_t *pic, AVCodecContext *ctx, AVFrame *frame)
{
(void) ctx;
vlc_va_sys_t *sys = va->sys;
vlc_vdp_video_field_t *field = Get(sys);
if (field == NULL)
@ -120,7 +122,7 @@ static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data)
field->context.vctx = vlc_video_context_Hold(sys->vctx);
pic->context = &field->context;
data[3] = (void *)(uintptr_t)field->frame->surface;
frame->data[3] = (void *)(uintptr_t)field->frame->surface;
return VLC_SUCCESS;
}