Wed May 4 15:25:00 2022 +0800

This commit is contained in:
Ziyang Zhou
2022-05-04 15:25:00 +08:00
commit 7b6ae28f7f
1145 changed files with 270040 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2012 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _VA_ANDROID_H_
#define _VA_ANDROID_H_
#include <va/va.h>
/** \brief Android Gralloc buffer memory type. */
#define VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_GRALLOC 0x00100000
/** \brief Android ION buffer memory type. */
#define VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_ION 0x00200000
#ifdef __cplusplus
extern "C" {
#endif
/*
* Returns a suitable VADisplay for VA API
*/
VADisplay vaGetDisplay(
void *android_dpy
);
#ifdef __cplusplus
}
#endif
#endif /* _VA_ANDROID_H_ */

View File

@@ -0,0 +1,695 @@
/*
* Copyright (c) 2007 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Video Decode Acceleration -Backend API
*/
#ifndef _VA_BACKEND_H_
#define _VA_BACKEND_H_
#include <va/va.h>
typedef struct VADriverContext *VADriverContextP;
typedef struct VADisplayContext *VADisplayContextP;
/** \brief VA display types. */
enum {
/** \brief Mask to major identifier for VA display type. */
VA_DISPLAY_MAJOR_MASK = 0xf0,
/** \brief VA/X11 API is used, through vaGetDisplay() entry-point. */
VA_DISPLAY_X11 = 0x10,
/** \brief VA/GLX API is used, through vaGetDisplayGLX() entry-point. */
VA_DISPLAY_GLX = (VA_DISPLAY_X11 | (1 << 0)),
/** \brief VA/Android API is used, through vaGetDisplay() entry-point. */
VA_DISPLAY_ANDROID = 0x20,
/** \brief VA/DRM API is used, through vaGetDisplayDRM() entry-point. */
VA_DISPLAY_DRM = 0x30,
/** \brief VA/DRM API is used, with a render-node device path */
VA_DISPLAY_DRM_RENDERNODES = (VA_DISPLAY_DRM | (1 << 0)),
/** \brief VA/Wayland API is used, through vaGetDisplayWl() entry-point. */
VA_DISPLAY_WAYLAND = 0x40,
};
struct VADriverVTable {
VAStatus(*vaTerminate)(VADriverContextP ctx);
VAStatus(*vaQueryConfigProfiles)(
VADriverContextP ctx,
VAProfile *profile_list, /* out */
int *num_profiles /* out */
);
VAStatus(*vaQueryConfigEntrypoints)(
VADriverContextP ctx,
VAProfile profile,
VAEntrypoint *entrypoint_list, /* out */
int *num_entrypoints /* out */
);
VAStatus(*vaGetConfigAttributes)(
VADriverContextP ctx,
VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttrib *attrib_list, /* in/out */
int num_attribs
);
VAStatus(*vaCreateConfig)(
VADriverContextP ctx,
VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttrib *attrib_list,
int num_attribs,
VAConfigID *config_id /* out */
);
VAStatus(*vaDestroyConfig)(
VADriverContextP ctx,
VAConfigID config_id
);
VAStatus(*vaQueryConfigAttributes)(
VADriverContextP ctx,
VAConfigID config_id,
VAProfile *profile, /* out */
VAEntrypoint *entrypoint, /* out */
VAConfigAttrib *attrib_list, /* out */
int *num_attribs /* out */
);
VAStatus(*vaCreateSurfaces)(
VADriverContextP ctx,
int width,
int height,
int format,
int num_surfaces,
VASurfaceID *surfaces /* out */
);
VAStatus(*vaDestroySurfaces)(
VADriverContextP ctx,
VASurfaceID *surface_list,
int num_surfaces
);
VAStatus(*vaCreateContext)(
VADriverContextP ctx,
VAConfigID config_id,
int picture_width,
int picture_height,
int flag,
VASurfaceID *render_targets,
int num_render_targets,
VAContextID *context /* out */
);
VAStatus(*vaDestroyContext)(
VADriverContextP ctx,
VAContextID context
);
VAStatus(*vaCreateBuffer)(
VADriverContextP ctx,
VAContextID context, /* in */
VABufferType type, /* in */
unsigned int size, /* in */
unsigned int num_elements, /* in */
void *data, /* in */
VABufferID *buf_id
);
VAStatus(*vaBufferSetNumElements)(
VADriverContextP ctx,
VABufferID buf_id, /* in */
unsigned int num_elements /* in */
);
VAStatus(*vaMapBuffer)(
VADriverContextP ctx,
VABufferID buf_id, /* in */
void **pbuf /* out */
);
VAStatus(*vaUnmapBuffer)(
VADriverContextP ctx,
VABufferID buf_id /* in */
);
VAStatus(*vaDestroyBuffer)(
VADriverContextP ctx,
VABufferID buffer_id
);
VAStatus(*vaBeginPicture)(
VADriverContextP ctx,
VAContextID context,
VASurfaceID render_target
);
VAStatus(*vaRenderPicture)(
VADriverContextP ctx,
VAContextID context,
VABufferID *buffers,
int num_buffers
);
VAStatus(*vaEndPicture)(
VADriverContextP ctx,
VAContextID context
);
VAStatus(*vaSyncSurface)(
VADriverContextP ctx,
VASurfaceID render_target
);
VAStatus(*vaQuerySurfaceStatus)(
VADriverContextP ctx,
VASurfaceID render_target,
VASurfaceStatus *status /* out */
);
VAStatus(*vaQuerySurfaceError)(
VADriverContextP ctx,
VASurfaceID render_target,
VAStatus error_status,
void **error_info /*out*/
);
VAStatus(*vaPutSurface)(
VADriverContextP ctx,
VASurfaceID surface,
void* draw, /* Drawable of window system */
short srcx,
short srcy,
unsigned short srcw,
unsigned short srch,
short destx,
short desty,
unsigned short destw,
unsigned short desth,
VARectangle *cliprects, /* client supplied clip list */
unsigned int number_cliprects, /* number of clip rects in the clip list */
unsigned int flags /* de-interlacing flags */
);
VAStatus(*vaQueryImageFormats)(
VADriverContextP ctx,
VAImageFormat *format_list, /* out */
int *num_formats /* out */
);
VAStatus(*vaCreateImage)(
VADriverContextP ctx,
VAImageFormat *format,
int width,
int height,
VAImage *image /* out */
);
VAStatus(*vaDeriveImage)(
VADriverContextP ctx,
VASurfaceID surface,
VAImage *image /* out */
);
VAStatus(*vaDestroyImage)(
VADriverContextP ctx,
VAImageID image
);
VAStatus(*vaSetImagePalette)(
VADriverContextP ctx,
VAImageID image,
/*
* pointer to an array holding the palette data. The size of the array is
* num_palette_entries * entry_bytes in size. The order of the components
* in the palette is described by the component_order in VAImage struct
*/
unsigned char *palette
);
VAStatus(*vaGetImage)(
VADriverContextP ctx,
VASurfaceID surface,
int x, /* coordinates of the upper left source pixel */
int y,
unsigned int width, /* width and height of the region */
unsigned int height,
VAImageID image
);
VAStatus(*vaPutImage)(
VADriverContextP ctx,
VASurfaceID surface,
VAImageID image,
int src_x,
int src_y,
unsigned int src_width,
unsigned int src_height,
int dest_x,
int dest_y,
unsigned int dest_width,
unsigned int dest_height
);
VAStatus(*vaQuerySubpictureFormats)(
VADriverContextP ctx,
VAImageFormat *format_list, /* out */
unsigned int *flags, /* out */
unsigned int *num_formats /* out */
);
VAStatus(*vaCreateSubpicture)(
VADriverContextP ctx,
VAImageID image,
VASubpictureID *subpicture /* out */
);
VAStatus(*vaDestroySubpicture)(
VADriverContextP ctx,
VASubpictureID subpicture
);
VAStatus(*vaSetSubpictureImage)(
VADriverContextP ctx,
VASubpictureID subpicture,
VAImageID image
);
VAStatus(*vaSetSubpictureChromakey)(
VADriverContextP ctx,
VASubpictureID subpicture,
unsigned int chromakey_min,
unsigned int chromakey_max,
unsigned int chromakey_mask
);
VAStatus(*vaSetSubpictureGlobalAlpha)(
VADriverContextP ctx,
VASubpictureID subpicture,
float global_alpha
);
VAStatus(*vaAssociateSubpicture)(
VADriverContextP ctx,
VASubpictureID subpicture,
VASurfaceID *target_surfaces,
int num_surfaces,
short src_x, /* upper left offset in subpicture */
short src_y,
unsigned short src_width,
unsigned short src_height,
short dest_x, /* upper left offset in surface */
short dest_y,
unsigned short dest_width,
unsigned short dest_height,
/*
* whether to enable chroma-keying or global-alpha
* see VA_SUBPICTURE_XXX values
*/
unsigned int flags
);
VAStatus(*vaDeassociateSubpicture)(
VADriverContextP ctx,
VASubpictureID subpicture,
VASurfaceID *target_surfaces,
int num_surfaces
);
VAStatus(*vaQueryDisplayAttributes)(
VADriverContextP ctx,
VADisplayAttribute *attr_list, /* out */
int *num_attributes /* out */
);
VAStatus(*vaGetDisplayAttributes)(
VADriverContextP ctx,
VADisplayAttribute *attr_list, /* in/out */
int num_attributes
);
VAStatus(*vaSetDisplayAttributes)(
VADriverContextP ctx,
VADisplayAttribute *attr_list,
int num_attributes
);
/* used by va trace */
VAStatus(*vaBufferInfo)(
VADriverContextP ctx, /* in */
VABufferID buf_id, /* in */
VABufferType *type, /* out */
unsigned int *size, /* out */
unsigned int *num_elements /* out */
);
/* lock/unlock surface for external access */
VAStatus(*vaLockSurface)(
VADriverContextP ctx,
VASurfaceID surface,
unsigned int *fourcc, /* out for follow argument */
unsigned int *luma_stride,
unsigned int *chroma_u_stride,
unsigned int *chroma_v_stride,
unsigned int *luma_offset,
unsigned int *chroma_u_offset,
unsigned int *chroma_v_offset,
unsigned int *buffer_name, /* if it is not NULL, assign the low lever
* surface buffer name
*/
void **buffer /* if it is not NULL, map the surface buffer for
* CPU access
*/
);
VAStatus(*vaUnlockSurface)(
VADriverContextP ctx,
VASurfaceID surface
);
/* DEPRECATED */
VAStatus
(*vaGetSurfaceAttributes)(
VADriverContextP dpy,
VAConfigID config,
VASurfaceAttrib *attrib_list,
unsigned int num_attribs
);
VAStatus
(*vaCreateSurfaces2)(
VADriverContextP ctx,
unsigned int format,
unsigned int width,
unsigned int height,
VASurfaceID *surfaces,
unsigned int num_surfaces,
VASurfaceAttrib *attrib_list,
unsigned int num_attribs
);
VAStatus
(*vaQuerySurfaceAttributes)(
VADriverContextP dpy,
VAConfigID config,
VASurfaceAttrib *attrib_list,
unsigned int *num_attribs
);
VAStatus
(*vaAcquireBufferHandle)(
VADriverContextP ctx,
VABufferID buf_id, /* in */
VABufferInfo * buf_info /* in/out */
);
VAStatus
(*vaReleaseBufferHandle)(
VADriverContextP ctx,
VABufferID buf_id /* in */
);
VAStatus(*vaCreateMFContext)(
VADriverContextP ctx,
VAMFContextID *mfe_context /* out */
);
VAStatus(*vaMFAddContext)(
VADriverContextP ctx,
VAMFContextID mf_context,
VAContextID context
);
VAStatus(*vaMFReleaseContext)(
VADriverContextP ctx,
VAMFContextID mf_context,
VAContextID context
);
VAStatus(*vaMFSubmit)(
VADriverContextP ctx,
VAMFContextID mf_context,
VAContextID *contexts,
int num_contexts
);
VAStatus(*vaCreateBuffer2)(
VADriverContextP ctx,
VAContextID context, /* in */
VABufferType type, /* in */
unsigned int width, /* in */
unsigned int height, /* in */
unsigned int *unit_size, /* out */
unsigned int *pitch, /* out */
VABufferID *buf_id /* out */
);
VAStatus(*vaQueryProcessingRate)(
VADriverContextP ctx, /* in */
VAConfigID config_id, /* in */
VAProcessingRateParameter *proc_buf,/* in */
unsigned int *processing_rate /* out */
);
VAStatus
(*vaExportSurfaceHandle)(
VADriverContextP ctx,
VASurfaceID surface_id, /* in */
uint32_t mem_type, /* in */
uint32_t flags, /* in */
void *descriptor /* out */
);
VAStatus(*vaSyncSurface2)(
VADriverContextP ctx,
VASurfaceID surface,
uint64_t timeout_ns
);
VAStatus(*vaSyncBuffer)(
VADriverContextP ctx,
VABufferID buf_id,
uint64_t timeout_ns
);
VAStatus
(*vaCopy)(
VADriverContextP ctx, /* in */
VACopyObject *dst, /* in */
VACopyObject *src, /* in */
VACopyOption option /* in */
);
/** \brief Reserved bytes for future use, must be zero */
unsigned long reserved[54];
};
struct VADriverContext {
void *pDriverData;
/**
* The core VA implementation hooks.
*
* This structure is allocated from libva with calloc().
*/
struct VADriverVTable *vtable;
/**
* The VA/GLX implementation hooks.
*
* This structure is intended for drivers that implement the
* VA/GLX API. The driver implementation is responsible for the
* allocation and deallocation of this structure.
*/
struct VADriverVTableGLX *vtable_glx;
/**
* The VA/EGL implementation hooks.
*
* This structure is intended for drivers that implement the
* VA/EGL API. The driver implementation is responsible for the
* allocation and deallocation of this structure.
*/
struct VADriverVTableEGL *vtable_egl;
/**
* The third-party/private implementation hooks.
*
* This structure is intended for drivers that implement the
* private API. The driver implementation is responsible for the
* allocation and deallocation of this structure.
*/
void *vtable_tpi;
void *native_dpy;
int x11_screen;
int version_major;
int version_minor;
int max_profiles;
int max_entrypoints;
int max_attributes;
int max_image_formats;
int max_subpic_formats;
int max_display_attributes;
const char *str_vendor;
void *handle; /* dlopen handle */
/**
* \brief DRM state.
*
* This field holds driver specific data for DRM-based
* drivers. This structure is allocated from libva with
* calloc(). Do not deallocate from within VA driver
* implementations.
*
* All structures shall be derived from struct drm_state. So, for
* instance, this field holds a dri_state structure for VA/X11
* drivers that use the DRM protocol.
*/
void *drm_state;
void *glx; /* opaque for GLX code */
/** \brief VA display type. */
unsigned long display_type;
/**
* The VA/Wayland implementation hooks.
*
* This structure is intended for drivers that implement the
* VA/Wayland API. libVA allocates this structure with calloc()
* and owns the resulting memory.
*/
struct VADriverVTableWayland *vtable_wayland;
/**
* \brief The VA/VPP implementation hooks.
*
* This structure is allocated from libva with calloc().
*/
struct VADriverVTableVPP *vtable_vpp;
char *override_driver_name;
void *pDisplayContext;
/**
* Error callback.
*
* This is set by libva when the driver is opened, and will not be
* changed thereafter. The driver can call it with an error message,
* which will be propagated to the API user through their error
* callbacks, or sent to a default output if no callback is available.
*
* It is expected that end users will always be able to see these
* messages, so it should be called only for serious errors. For
* example, hardware problems or fatal configuration errors.
*
* @param pDriverContext Pointer to the driver context structure
* being used by the current driver.
* @param message Message to send to the API user. This must be a
* null-terminated string.
*/
void (*error_callback)(VADriverContextP pDriverContext,
const char *message);
/**
* Info callback.
*
* This has the same behaviour as the error callback, but has its
* own set of callbacks to the API user.
*
* It should be used for informational messages which may be useful
* for an application programmer or for debugging. For example, minor
* configuration errors, or information about the reason when another
* API call generates an error return. It is not expected that end
* users will see these messages.
*
* @param pDriverContext Pointer to the driver context structure
* being used by the current driver.
* @param message Message to send to the API user. This must be a
* null-terminated string.
*/
void (*info_callback)(VADriverContextP pDriverContext,
const char *message);
/**
* \brief The VA/Protected implementation hooks.
*
* This structure is allocated from libva with calloc().
*/
struct VADriverVTableProt *vtable_prot;
unsigned long reserved[37]; /* reserve for future add-ins, decrease the subscript accordingly */
};
#define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
struct VADisplayContext {
int vadpy_magic;
VADisplayContextP pNext;
VADriverContextP pDriverContext;
int (*vaIsValid)(
VADisplayContextP ctx
);
void (*vaDestroy)(
VADisplayContextP ctx
);
VAStatus(*vaGetDriverName)(
VADisplayContextP ctx,
char **driver_name
);
void *opaque; /* opaque for display extensions (e.g. GLX) */
void *vatrace; /* opaque for VA trace context */
void *vafool; /* opaque for VA fool context */
VAMessageCallback error_callback;
void *error_callback_user_context;
VAMessageCallback info_callback;
void *info_callback_user_context;
VAStatus(*vaGetNumCandidates)(
VADisplayContextP ctx,
int * num_candidates
);
VAStatus(*vaGetDriverNameByIndex)(
VADisplayContextP ctx,
char **driver_name,
int candidate_index
);
/** \brief Reserved bytes for future use, must be zero */
unsigned long reserved[30];
};
typedef VAStatus(*VADriverInit)(
VADriverContextP driver_context
);
#endif /* _VA_BACKEND_H_ */

View File

@@ -0,0 +1,81 @@
/*
* Copyright (c) 2020 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VA_BACKEND_PROT_H
#define VA_BACKEND_PROT_H
#include <va/va_prot.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \brief VTable version for VA/PROTECTION hooks. */
#define VA_DRIVER_VTABLE_PROT_VERSION 1
struct VADriverVTableProt {
unsigned int version;
VAStatus
(*vaCreateProtectedSession)(
VADriverContextP ctx,
VAConfigID config_id,
VAProtectedSessionID *protected_session
);
VAStatus
(*vaDestroyProtectedSession)(
VADriverContextP ctx,
VAProtectedSessionID protected_session
);
VAStatus
(*vaAttachProtectedSession)(
VADriverContextP ctx,
VAContextID context,
VAProtectedSessionID protected_session
);
VAStatus
(*vaDetachProtectedSession)(
VADriverContextP ctx,
VAContextID context
);
VAStatus
(*vaProtectedSessionExecute)(
VADriverContextP ctx,
VAProtectedSessionID protected_session,
VABufferID buf_id
);
/** \brief Reserved bytes for future use, must be zero */
unsigned long reserved[VA_PADDING_MEDIUM];
};
#ifdef __cplusplus
}
#endif
#endif /* VA_BACKEND_PROT_H */

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2007-2011 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VA_BACKEND_VPP_H
#define VA_BACKEND_VPP_H
#include <va/va_vpp.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \brief VTable version for VA/VPP hooks. */
#define VA_DRIVER_VTABLE_VPP_VERSION 1
struct VADriverVTableVPP {
unsigned int version;
VAStatus
(*vaQueryVideoProcFilters)(
VADriverContextP ctx,
VAContextID context,
VAProcFilterType *filters,
unsigned int *num_filters
);
VAStatus
(*vaQueryVideoProcFilterCaps)(
VADriverContextP ctx,
VAContextID context,
VAProcFilterType type,
void *filter_caps,
unsigned int *num_filter_caps
);
VAStatus
(*vaQueryVideoProcPipelineCaps)(
VADriverContextP ctx,
VAContextID context,
VABufferID *filters,
unsigned int num_filters,
VAProcPipelineCaps *pipeline_caps
);
/** \brief Reserved bytes for future use, must be zero */
unsigned long reserved[16];
};
#ifdef __cplusplus
}
#endif
#endif /* VA_BACKEND_VPP_H */

View File

@@ -0,0 +1,116 @@
/*
* Copyright (c) 2007-2011 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_compat.h
* \brief The Compatibility API
*
* This file contains the \ref api_compat "Compatibility API".
*/
#ifndef VA_COMPAT_H
#define VA_COMPAT_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_compat Compatibility API
*
* The Compatibility API allows older programs that are not ported to
* the current API to still build and run correctly. In particular,
* this exposes older API to allow for backwards source compatibility.
*
* @{
*/
/**
* Makes a string literal out of the macro argument
*/
#define VA_CPP_HELPER_STRINGIFY(x) \
VA_CPP_HELPER_STRINGIFY_(x)
#define VA_CPP_HELPER_STRINGIFY_(x) \
#x
/**
* Concatenates two macro arguments at preprocessing time.
*/
#define VA_CPP_HELPER_CONCAT(a, b) \
VA_CPP_HELPER_CONCAT_(a, b)
#define VA_CPP_HELPER_CONCAT_(a, b) \
a ## b
/**
* Generates the number of macro arguments at preprocessing time.
* <http://groups.google.com/group/comp.std.c/browse_thread/thread/77ee8c8f92e4a3fb/346fc464319b1ee5>
*
* Note: this doesn't work for macros with no arguments
*/
#define VA_CPP_HELPER_N_ARGS(...) \
VA_CPP_HELPER_N_ARGS_(__VA_ARGS__, VA_CPP_HELPER_N_ARGS_LIST_REV())
#define VA_CPP_HELPER_N_ARGS_(...) \
VA_CPP_HELPER_N_ARGS_LIST(__VA_ARGS__)
#define VA_CPP_HELPER_N_ARGS_LIST(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a12, a13, a14, a15, a16, N, ...) N
#define VA_CPP_HELPER_N_ARGS_LIST_REV() \
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
/**
* Generates a versioned function alias.
*
* VA_CPP_HELPER_ALIAS(vaSomeFunction, 0,32,0) will generate
* .symber vaSomeFunction_0_32_0, vaSomeFunction@VA_API_0.32.0
*/
#define VA_CPP_HELPER_ALIAS(func, major, minor, micro) \
VA_CPP_HELPER_ALIAS_(func, major, minor, micro, "@")
#define VA_CPP_HELPER_ALIAS_DEFAULT(func, major, minor, micro) \
VA_CPP_HELPER_ALIAS_(func, major, minor, micro, "@@")
#define VA_CPP_HELPER_ALIAS_(func, major, minor, micro, binding) \
asm(".symver " #func "_" #major "_" #minor "_" #micro ", " \
#func binding "VA_API_" #major "." #minor "." #micro)
/* vaCreateSurfaces() */
#ifndef VA_COMPAT_DISABLED
#define vaCreateSurfaces(dpy, ...) \
VA_CPP_HELPER_CONCAT(vaCreateSurfaces, \
VA_CPP_HELPER_N_ARGS(dpy, __VA_ARGS__)) \
(dpy, __VA_ARGS__)
#endif
#define vaCreateSurfaces6(dpy, width, height, format, num_surfaces, surfaces) \
(vaCreateSurfaces)(dpy, format, width, height, surfaces, num_surfaces, \
NULL, 0)
#define vaCreateSurfaces8(dpy, format, width, height, surfaces, num_surfaces, attribs, num_attribs) \
(vaCreateSurfaces)(dpy, format, width, height, surfaces, num_surfaces, \
attribs, num_attribs)
/*@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_COMPAT_H */

View File

@@ -0,0 +1,695 @@
/*
* Copyright (c) 2019 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_dec_av1.h
* \brief The AV1 decoding API
*
* This file contains the \ref api_dec_av1 "AV1 decoding API".
*/
#ifndef VA_DEC_AV1_H
#define VA_DEC_AV1_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_dec_av1 AV1 decoding API
*
* This AV1 decoding API supports 8-bit/10bit 420 format only.
*
* @{
*/
/** Attribute value for VAConfigAttribDecAV1Features.
*
* This attribute decribes the supported features of a AV1
* decoder configuration.
*
*/
typedef union VAConfigAttribValDecAV1Features {
struct {
/** large scale tile
*
* This conveys whether AV1 large scale tile is supported by HW.
* 0 - unsupported, 1 - supported.
*/
uint32_t lst_support : 2;
/* Reserved for future use. */
uint32_t reserved : 30;
} bits;
uint32_t value;
} VAConfigAttribValDecAV1Features;
/**
* \brief AV1 Decoding Picture Parameter Buffer Structure
*
* This structure conveys picture level parameters.
* App should send a surface with this data structure down to VAAPI once
* per frame.
*
*/
/** \brief Segmentation Information
*/
typedef struct _VASegmentationStructAV1 {
union {
struct {
/** Indicates whether segmentation map related syntax elements
* are present or not for current frame. If equal to 0,
* the segmentation map related syntax elements are
* not present for the current frame and the control flags of
* segmentation map related tables feature_data[][], and
* feature_mask[] are not valid and shall be ignored by accelerator.
*/
uint32_t enabled : 1;
/** Value 1 indicates that the segmentation map are updated
* during the decoding of this frame.
* Value 0 means that the segmentation map from the previous
* frame is used.
*/
uint32_t update_map : 1;
/** Value 1 indicates that the updates to the segmentation map
* are coded relative to the existing segmentation map.
* Value 0 indicates that the new segmentation map is coded
* without reference to the existing segmentation map.
*/
uint32_t temporal_update : 1;
/** Value 1 indicates that new parameters are about to be
* specified for each segment.
* Value 0 indicates that the segmentation parameters
* should keep their existing values.
*/
uint32_t update_data : 1;
/** \brief Reserved bytes for future use, must be zero */
uint32_t reserved : 28;
} bits;
uint32_t value;
} segment_info_fields;
/** \brief Segmentation parameters for current frame.
* feature_data[segment_id][feature_id]
* where segment_id has value range [0..7] indicating the segment id.
* and feature_id is defined as
typedef enum {
SEG_LVL_ALT_Q, // Use alternate Quantizer ....
SEG_LVL_ALT_LF_Y_V, // Use alternate loop filter value on y plane vertical
SEG_LVL_ALT_LF_Y_H, // Use alternate loop filter value on y plane horizontal
SEG_LVL_ALT_LF_U, // Use alternate loop filter value on u plane
SEG_LVL_ALT_LF_V, // Use alternate loop filter value on v plane
SEG_LVL_REF_FRAME, // Optional Segment reference frame
SEG_LVL_SKIP, // Optional Segment (0,0) + skip mode
SEG_LVL_GLOBALMV,
SEG_LVL_MAX
} SEG_LVL_FEATURES;
* feature_data[][] is equivalent to variable FeatureData[][] in spec,
* which is after clip3() operation.
* Clip3(x, y, z) = (z < x)? x : ((z > y)? y : z);
* The limit is defined in Segmentation_Feature_Max[ SEG_LVL_MAX ] = {
* 255, MAX_LOOP_FILTER, MAX_LOOP_FILTER, MAX_LOOP_FILTER, MAX_LOOP_FILTER, 7, 0, 0 }
*/
int16_t feature_data[8][8];
/** \brief indicates if a feature is enabled or not.
* Each bit field itself is the feature_id. Index is segment_id.
* feature_mask[segment_id] & (1 << feature_id) equal to 1 specify that the feature of
* feature_id for segment of segment_id is enabled, otherwise disabled.
*/
uint8_t feature_mask[8];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VASegmentationStructAV1;
/** \brief Film Grain Information
*/
typedef struct _VAFilmGrainStructAV1 {
union {
struct {
/** \brief Specify whether or not film grain is applied on current frame.
* If set to 0, all the rest parameters should be set to zero
* and ignored.
*/
uint32_t apply_grain : 1;
uint32_t chroma_scaling_from_luma : 1;
uint32_t grain_scaling_minus_8 : 2;
uint32_t ar_coeff_lag : 2;
uint32_t ar_coeff_shift_minus_6 : 2;
uint32_t grain_scale_shift : 2;
uint32_t overlap_flag : 1;
uint32_t clip_to_restricted_range : 1;
/** \brief Reserved bytes for future use, must be zero */
uint32_t reserved : 20;
} bits;
uint32_t value;
} film_grain_info_fields;
uint16_t grain_seed;
/* value range [0..14] */
uint8_t num_y_points;
uint8_t point_y_value[14];
uint8_t point_y_scaling[14];
/* value range [0..10] */
uint8_t num_cb_points;
uint8_t point_cb_value[10];
uint8_t point_cb_scaling[10];
/* value range [0..10] */
uint8_t num_cr_points;
uint8_t point_cr_value[10];
uint8_t point_cr_scaling[10];
/* value range [-128..127] */
int8_t ar_coeffs_y[24];
int8_t ar_coeffs_cb[25];
int8_t ar_coeffs_cr[25];
uint8_t cb_mult;
uint8_t cb_luma_mult;
uint16_t cb_offset;
uint8_t cr_mult;
uint8_t cr_luma_mult;
uint16_t cr_offset;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAFilmGrainStructAV1;
typedef enum {
/** identity transformation, 0-parameter */
VAAV1TransformationIdentity = 0,
/** translational motion, 2-parameter */
VAAV1TransformationTranslation = 1,
/** simplified affine with rotation + zoom only, 4-parameter */
VAAV1TransformationRotzoom = 2,
/** affine, 6-parameter */
VAAV1TransformationAffine = 3,
/** transformation count */
VAAV1TransformationCount
} VAAV1TransformationType;
typedef struct _VAWarpedMotionParamsAV1 {
/** \brief Specify the type of warped motion */
VAAV1TransformationType wmtype;
/** \brief Specify warp motion parameters
* wm.wmmat[] corresponds to gm_params[][] in spec.
* Details in AV1 spec section 5.9.24 or refer to libaom code
* https://aomedia.googlesource.com/aom/+/refs/heads/master/av1/decoder/decodeframe.c
*/
int32_t wmmat[8];
/* valid or invalid on affine set */
uint8_t invalid;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAWarpedMotionParamsAV1;
/**
* \brief AV1 Decoding Picture Parameter Buffer Structure
*
* This structure conveys picture level parameters and should be sent once
* per frame.
*
*/
typedef struct _VADecPictureParameterBufferAV1 {
/**@{*/
/** \brief sequence level information
*/
/** \brief AV1 bit stream profile
*/
uint8_t profile;
uint8_t order_hint_bits_minus_1;
/** \brief bit depth index
* value range [0..2]
* 0 - bit depth 8;
* 1 - bit depth 10;
* 2 - bit depth 12;
*/
uint8_t bit_depth_idx;
/** \brief corresponds to AV1 spec variable of the same name. */
uint8_t matrix_coefficients;
union {
struct {
uint32_t still_picture : 1;
uint32_t use_128x128_superblock : 1;
uint32_t enable_filter_intra : 1;
uint32_t enable_intra_edge_filter : 1;
/** read_compound_tools */
uint32_t enable_interintra_compound : 1;
uint32_t enable_masked_compound : 1;
uint32_t enable_dual_filter : 1;
uint32_t enable_order_hint : 1;
uint32_t enable_jnt_comp : 1;
uint32_t enable_cdef : 1;
uint32_t mono_chrome : 1;
uint32_t color_range : 1;
uint32_t subsampling_x : 1;
uint32_t subsampling_y : 1;
va_deprecated uint32_t chroma_sample_position : 1;
uint32_t film_grain_params_present : 1;
/** \brief Reserved bytes for future use, must be zero */
uint32_t reserved : 16;
} fields;
uint32_t value;
} seq_info_fields;
/** \brief Picture level information
*/
/** \brief buffer description of decoded current picture
*/
VASurfaceID current_frame;
/** \brief display buffer of current picture
* Used for film grain applied decoded picture.
* Valid only when apply_grain equals 1.
*/
VASurfaceID current_display_picture;
/** \brief number of anchor frames for large scale tile
* This parameter gives the number of entries of anchor_frames_list[].
* Value range [0..128].
*/
uint8_t anchor_frames_num;
/** \brief anchor frame list for large scale tile
* For large scale tile applications, the anchor frames could come from
* previously decoded frames in current sequence (aka. internal), or
* from external sources.
* For external anchor frames, application should call API
* vaCreateBuffer() to generate frame buffers and populate them with
* pixel frames. And this process may happen multiple times.
* The array anchor_frames_list[] is used to register all the available
* anchor frames from both external and internal, up to the current
* frame instance. If a previously registerred anchor frame is no longer
* needed, it should be removed from the list. But it does not prevent
* applications from relacing the frame buffer with new anchor frames.
* Please note that the internal anchor frames may not still be present
* in the current DPB buffer. But if it is in the anchor_frames_list[],
* it should not be replaced with other frames or removed from memory
* until it is not shown in the list.
* This number of entries of the list is given by parameter anchor_frames_num.
*/
VASurfaceID *anchor_frames_list;
/** \brief Picture resolution minus 1
* Picture original resolution. If SuperRes is enabled,
* this is the upscaled resolution.
* value range [0..65535]
*/
uint16_t frame_width_minus1;
uint16_t frame_height_minus1;
/** \brief Output frame buffer size in unit of tiles
* Valid only when large_scale_tile equals 1.
* value range [0..65535]
*/
uint16_t output_frame_width_in_tiles_minus_1;
uint16_t output_frame_height_in_tiles_minus_1;
/** \brief Surface indices of reference frames in DPB.
*
* Contains a list of uncompressed frame buffer surface indices as references.
* Application needs to make sure all the entries point to valid frames
* except for intra frames by checking ref_frame_id[]. If missing frame
* is identified, application may choose to perform error recovery by
* pointing problematic index to an alternative frame buffer.
* Driver is not responsible to validate reference frames' id.
*/
VASurfaceID ref_frame_map[8];
/** \brief Reference frame indices.
*
* Contains a list of indices into ref_frame_map[8].
* It specifies the reference frame correspondence.
* The indices of the array are defined as [LAST_FRAME LAST_FRAME,
* LAST2_FRAME LAST_FRAME, …, ALTREF_FRAME LAST_FRAME], where each
* symbol is defined as:
* enum{INTRA_FRAME = 0, LAST_FRAME, LAST2_FRAME, LAST3_FRAME, GOLDEN_FRAME,
* BWDREF_FRAME, ALTREF2_FRAME, ALTREF_FRAME};
*/
uint8_t ref_frame_idx[7];
/** \brief primary reference frame index
* Index into ref_frame_idx[], specifying which reference frame contains
* propagated info that should be loaded at the start of the frame.
* When value equals PRIMARY_REF_NONE (7), it indicates there is
* no primary reference frame.
* value range [0..7]
*/
uint8_t primary_ref_frame;
uint8_t order_hint;
VASegmentationStructAV1 seg_info;
VAFilmGrainStructAV1 film_grain_info;
/** \brief tile structure
* When uniform_tile_spacing_flag == 1, width_in_sbs_minus_1[] and
* height_in_sbs_minus_1[] should be ignored, which will be generated
* by driver based on tile_cols and tile_rows.
*/
uint8_t tile_cols;
uint8_t tile_rows;
/* The width/height of a tile minus 1 in units of superblocks. Though the
* maximum number of tiles is 64, since ones of the last tile are computed
* from ones of the other tiles and frame_width/height, they are not
* necessarily specified.
*/
uint16_t width_in_sbs_minus_1[63];
uint16_t height_in_sbs_minus_1[63];
/** \brief number of tiles minus 1 in large scale tile list
* Same as AV1 semantic element.
* Valid only when large_scale_tiles == 1.
*/
uint16_t tile_count_minus_1;
/* specify the tile index for context updating */
uint16_t context_update_tile_id;
union {
struct {
/** \brief flags for current picture
* same syntax and semantic as those in AV1 code
*/
/** \brief Frame Type
* 0: KEY_FRAME;
* 1: INTER_FRAME;
* 2: INTRA_ONLY_FRAME;
* 3: SWITCH_FRAME
* For SWITCH_FRAME, application shall set error_resilient_mode = 1,
* refresh_frame_flags, etc. appropriately. And driver will convert it
* to INTER_FRAME.
*/
uint32_t frame_type : 2;
uint32_t show_frame : 1;
uint32_t showable_frame : 1;
uint32_t error_resilient_mode : 1;
uint32_t disable_cdf_update : 1;
uint32_t allow_screen_content_tools : 1;
uint32_t force_integer_mv : 1;
uint32_t allow_intrabc : 1;
uint32_t use_superres : 1;
uint32_t allow_high_precision_mv : 1;
uint32_t is_motion_mode_switchable : 1;
uint32_t use_ref_frame_mvs : 1;
/* disable_frame_end_update_cdf is coded as refresh_frame_context. */
uint32_t disable_frame_end_update_cdf : 1;
uint32_t uniform_tile_spacing_flag : 1;
uint32_t allow_warped_motion : 1;
/** \brief indicate if current frame in large scale tile mode */
uint32_t large_scale_tile : 1;
/** \brief Reserved bytes for future use, must be zero */
uint32_t reserved : 15;
} bits;
uint32_t value;
} pic_info_fields;
/** \brief Supper resolution scale denominator.
* When use_superres=1, superres_scale_denominator must be in the range [9..16].
* When use_superres=0, superres_scale_denominator must be 8.
*/
uint8_t superres_scale_denominator;
/** \brief Interpolation filter.
* value range [0..4]
*/
uint8_t interp_filter;
/** \brief luma loop filter levels.
* value range [0..63].
*/
uint8_t filter_level[2];
/** \brief chroma loop filter levels.
* value range [0..63].
*/
uint8_t filter_level_u;
uint8_t filter_level_v;
union {
struct {
/** \brief flags for reference pictures
* same syntax and semantic as those in AV1 code
*/
uint8_t sharpness_level : 3;
uint8_t mode_ref_delta_enabled : 1;
uint8_t mode_ref_delta_update : 1;
/** \brief Reserved bytes for future use, must be zero */
uint8_t reserved : 3;
} bits;
uint8_t value;
} loop_filter_info_fields;
/** \brief The adjustment needed for the filter level based on
* the chosen reference frame.
* value range [-64..63].
*/
int8_t ref_deltas[8];
/** \brief The adjustment needed for the filter level based on
* the chosen mode.
* value range [-64..63].
*/
int8_t mode_deltas[2];
/** \brief quantization
*/
/** \brief Y AC index
* value range [0..255]
*/
uint8_t base_qindex;
/** \brief Y DC delta from Y AC
* value range [-64..63]
*/
int8_t y_dc_delta_q;
/** \brief U DC delta from Y AC
* value range [-64..63]
*/
int8_t u_dc_delta_q;
/** \brief U AC delta from Y AC
* value range [-64..63]
*/
int8_t u_ac_delta_q;
/** \brief V DC delta from Y AC
* value range [-64..63]
*/
int8_t v_dc_delta_q;
/** \brief V AC delta from Y AC
* value range [-64..63]
*/
int8_t v_ac_delta_q;
/** \brief quantization_matrix
*/
union {
struct {
uint16_t using_qmatrix : 1;
/** \brief qm level
* value range [0..15]
* Invalid if using_qmatrix equals 0.
*/
uint16_t qm_y : 4;
uint16_t qm_u : 4;
uint16_t qm_v : 4;
/** \brief Reserved bytes for future use, must be zero */
uint16_t reserved : 3;
} bits;
uint16_t value;
} qmatrix_fields;
union {
struct {
/** \brief delta_q parameters
*/
uint32_t delta_q_present_flag : 1;
uint32_t log2_delta_q_res : 2;
/** \brief delta_lf parameters
*/
uint32_t delta_lf_present_flag : 1;
uint32_t log2_delta_lf_res : 2;
/** \brief CONFIG_LOOPFILTER_LEVEL
*/
uint32_t delta_lf_multi : 1;
/** \brief read_tx_mode
* value range [0..2]
*/
uint32_t tx_mode : 2;
/* AV1 frame reference mode semantic */
uint32_t reference_select : 1;
uint32_t reduced_tx_set_used : 1;
uint32_t skip_mode_present : 1;
/** \brief Reserved bytes for future use, must be zero */
uint32_t reserved : 20;
} bits;
uint32_t value;
} mode_control_fields;
/** \brief CDEF parameters
*/
/* value range [0..3] */
uint8_t cdef_damping_minus_3;
/* value range [0..3] */
uint8_t cdef_bits;
/** Encode cdef strength:
*
* The cdef_y_strengths[] and cdef_uv_strengths[] are expected to be packed
* with both primary and secondary strength. The secondary strength is
* given in the lower two bits and the primary strength is given in the next
* four bits.
*
* cdef_y_strengths[] & cdef_uv_strengths[] should be derived as:
* (cdef_y_strengths[]) = (cdef_y_pri_strength[] << 2) | (cdef_y_sec_strength[] & 0x03)
* (cdef_uv_strengths[]) = (cdef_uv_pri_strength[] << 2) | (cdef_uv_sec_strength[] & 0x03)
* In which, cdef_y_pri_strength[]/cdef_y_sec_strength[]/cdef_uv_pri_strength[]/cdef_uv_sec_strength[]
* are variables defined in AV1 Spec 5.9.19. The cdef_y_strengths[] & cdef_uv_strengths[]
* are corresponding to LIBAOM variables cm->cdef_strengths[] & cm->cdef_uv_strengths[] respectively.
*/
/* value range [0..63] */
uint8_t cdef_y_strengths[8];
/* value range [0..63] */
uint8_t cdef_uv_strengths[8];
/** \brief loop restoration parameters
*/
union {
struct {
uint16_t yframe_restoration_type : 2;
uint16_t cbframe_restoration_type : 2;
uint16_t crframe_restoration_type : 2;
uint16_t lr_unit_shift : 2;
uint16_t lr_uv_shift : 1;
/** \brief Reserved bytes for future use, must be zero */
uint16_t reserved : 7;
} bits;
uint16_t value;
} loop_restoration_fields;
/** \brief global motion
*/
VAWarpedMotionParamsAV1 wm[7];
/**@}*/
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_MEDIUM];
} VADecPictureParameterBufferAV1;
/**
* \brief AV1 Slice Parameter Buffer Structure
*
* This structure conveys parameters related to bit stream data and should be
* sent once per tile.
*
* It uses the name VASliceParameterBufferAV1 to be consistent with other codec,
* but actually means VATileParameterBufferAV1.
*
* Slice data buffer of VASliceDataBufferType is used
* to send the bitstream.
*
* Please note that host decoder is responsible to parse out the
* per tile information. And the bit stream in sent to driver in per
* tile granularity.
*/
typedef struct _VASliceParameterBufferAV1 {
/**@{*/
/** \brief The byte count of current tile in the bitstream buffer,
* starting from first byte of the buffer.
* It uses the name slice_data_size to be consistent with other codec,
* but actually means tile_data_size.
*/
uint32_t slice_data_size;
/**
* offset to the first byte of the data buffer.
*/
uint32_t slice_data_offset;
/**
* see VA_SLICE_DATA_FLAG_XXX definitions
*/
uint32_t slice_data_flag;
uint16_t tile_row;
uint16_t tile_column;
va_deprecated uint16_t tg_start;
va_deprecated uint16_t tg_end;
/** \brief anchor frame index for large scale tile.
* index into an array AnchorFrames of the frames that the tile uses
* for prediction.
* valid only when large_scale_tile equals 1.
*/
uint8_t anchor_frame_idx;
/** \brief tile index in the tile list.
* Valid only when large_scale_tile is enabled.
* Driver uses this field to decide the tile output location.
*/
uint16_t tile_idx_in_tile_list;
/**@}*/
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VASliceParameterBufferAV1;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_DEC_AV1_H */

View File

@@ -0,0 +1,616 @@
/*
* Copyright (c) 2014 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_dec_hevc.h
* \brief The HEVC decoding API
*
* This file contains the \ref api_dec_hevc "HEVC decoding API".
*/
#ifndef VA_DEC_HEVC_H
#define VA_DEC_HEVC_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_dec_hevc HEVC decoding API
*
* This HEVC decoding API supports Main and Main Still Picture profiles.
* And it supports both short slice format and long slice format.
*
* @{
*/
/**
* \brief HEVC Decoding Picture Parameter Buffer Structure
*
* This structure conveys picture level parameters and should be sent once
* per frame.
*
*/
typedef struct _VAPictureParameterBufferHEVC {
/** \brief buffer description of decoded current picture
* only VA_PICTURE_HEVC_FIELD_PIC and VA_PICTURE_HEVC_BOTTOM_FIELD
* of "flags" fields are meaningful.
*/
VAPictureHEVC CurrPic;
/** \brief buffer description of reference frames in DPB */
VAPictureHEVC ReferenceFrames[15];
/** \brief picture width, shall be integer multiple of minimum CB size. */
uint16_t pic_width_in_luma_samples;
/** \brief picture height, shall be integer multiple of minimum CB size. */
uint16_t pic_height_in_luma_samples;
union {
struct {
/** following flags have same syntax and semantic as those in HEVC spec */
uint32_t chroma_format_idc : 2;
uint32_t separate_colour_plane_flag : 1;
uint32_t pcm_enabled_flag : 1;
uint32_t scaling_list_enabled_flag : 1;
uint32_t transform_skip_enabled_flag : 1;
uint32_t amp_enabled_flag : 1;
uint32_t strong_intra_smoothing_enabled_flag : 1;
uint32_t sign_data_hiding_enabled_flag : 1;
uint32_t constrained_intra_pred_flag : 1;
uint32_t cu_qp_delta_enabled_flag : 1;
uint32_t weighted_pred_flag : 1;
uint32_t weighted_bipred_flag : 1;
uint32_t transquant_bypass_enabled_flag : 1;
uint32_t tiles_enabled_flag : 1;
uint32_t entropy_coding_sync_enabled_flag : 1;
uint32_t pps_loop_filter_across_slices_enabled_flag : 1;
uint32_t loop_filter_across_tiles_enabled_flag : 1;
uint32_t pcm_loop_filter_disabled_flag : 1;
/** set based on sps_max_num_reorder_pics of current temporal layer. */
uint32_t NoPicReorderingFlag : 1;
/** picture has no B slices */
uint32_t NoBiPredFlag : 1;
uint32_t ReservedBits : 11;
} bits;
uint32_t value;
} pic_fields;
/** following parameters have same syntax with those in HEVC spec */
/** \brief DPB size for current temporal layer */
uint8_t sps_max_dec_pic_buffering_minus1;
uint8_t bit_depth_luma_minus8;
uint8_t bit_depth_chroma_minus8;
uint8_t pcm_sample_bit_depth_luma_minus1;
uint8_t pcm_sample_bit_depth_chroma_minus1;
uint8_t log2_min_luma_coding_block_size_minus3;
uint8_t log2_diff_max_min_luma_coding_block_size;
uint8_t log2_min_transform_block_size_minus2;
uint8_t log2_diff_max_min_transform_block_size;
uint8_t log2_min_pcm_luma_coding_block_size_minus3;
uint8_t log2_diff_max_min_pcm_luma_coding_block_size;
uint8_t max_transform_hierarchy_depth_intra;
uint8_t max_transform_hierarchy_depth_inter;
int8_t init_qp_minus26;
uint8_t diff_cu_qp_delta_depth;
int8_t pps_cb_qp_offset;
int8_t pps_cr_qp_offset;
uint8_t log2_parallel_merge_level_minus2;
uint8_t num_tile_columns_minus1;
uint8_t num_tile_rows_minus1;
/**
* when uniform_spacing_flag equals 1, application should populate
* column_width_minus[], and row_height_minus1[] with approperiate values.
*/
uint16_t column_width_minus1[19];
uint16_t row_height_minus1[21];
/**
* The Following Parameters are needed for Short Slice Format Only.
* Only format decoding can ignore them.
*/
/**
* \brief Parameters needed for parsing slice segment headers
*/
union {
struct {
/** following parameters have same syntax with those in HEVC spec */
uint32_t lists_modification_present_flag : 1;
uint32_t long_term_ref_pics_present_flag : 1;
uint32_t sps_temporal_mvp_enabled_flag : 1;
uint32_t cabac_init_present_flag : 1;
uint32_t output_flag_present_flag : 1;
uint32_t dependent_slice_segments_enabled_flag : 1;
uint32_t pps_slice_chroma_qp_offsets_present_flag : 1;
uint32_t sample_adaptive_offset_enabled_flag : 1;
uint32_t deblocking_filter_override_enabled_flag : 1;
uint32_t pps_disable_deblocking_filter_flag : 1;
uint32_t slice_segment_header_extension_present_flag : 1;
/** current picture with NUT between 16 and 21 inclusive */
uint32_t RapPicFlag : 1;
/** current picture with NUT between 19 and 20 inclusive */
uint32_t IdrPicFlag : 1;
/** current picture has only intra slices */
uint32_t IntraPicFlag : 1;
uint32_t ReservedBits : 18;
} bits;
uint32_t value;
} slice_parsing_fields;
/** following parameters have same syntax with those in HEVC spec */
uint8_t log2_max_pic_order_cnt_lsb_minus4;
uint8_t num_short_term_ref_pic_sets;
uint8_t num_long_term_ref_pic_sps;
uint8_t num_ref_idx_l0_default_active_minus1;
uint8_t num_ref_idx_l1_default_active_minus1;
int8_t pps_beta_offset_div2;
int8_t pps_tc_offset_div2;
uint8_t num_extra_slice_header_bits;
/**
* \brief number of bits that structure
* short_term_ref_pic_set( num_short_term_ref_pic_sets ) takes in slice
* segment header when short_term_ref_pic_set_sps_flag equals 0.
* if short_term_ref_pic_set_sps_flag equals 1, the value should be 0.
* the bit count is calculated after emulation prevention bytes are removed
* from bit streams.
* This variable is used for accelorater to skip parsing the
* short_term_ref_pic_set( num_short_term_ref_pic_sets ) structure.
*/
uint32_t st_rps_bits;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_MEDIUM];
} VAPictureParameterBufferHEVC;
/**
* \brief HEVC Decoding Picture Parameter Buffer Structure for Range Extension
*
* This structure conveys picture level HEVC Range Extension parameters
* and should be sent once per frame. This data structure should be sent
* together with VAPictureParameterBufferHEVC in a single buffer of
* \ref VAPictureParameterBufferHEVCExtension since each frame
* of HEVC range extension contains both picture level parameters and picture
* level range extension parameters. They should be parsed together. The buffer
* type is same as \ref VAPictureParameterBufferHEVC.
*
*/
typedef struct _VAPictureParameterBufferHEVCRext {
union {
struct {
/** \brief HEVC range extension flags
* The following flags bears the same syntax and semantics as
* those defined in HEVC bit stream spec.
*/
uint32_t transform_skip_rotation_enabled_flag : 1;
uint32_t transform_skip_context_enabled_flag : 1;
uint32_t implicit_rdpcm_enabled_flag : 1;
uint32_t explicit_rdpcm_enabled_flag : 1;
uint32_t extended_precision_processing_flag : 1;
uint32_t intra_smoothing_disabled_flag : 1;
uint32_t high_precision_offsets_enabled_flag : 1;
uint32_t persistent_rice_adaptation_enabled_flag : 1;
uint32_t cabac_bypass_alignment_enabled_flag : 1;
uint32_t cross_component_prediction_enabled_flag : 1;
uint32_t chroma_qp_offset_list_enabled_flag : 1;
/** \brief Reserved bytes for future use, must be zero */
uint32_t reserved : 21;
} bits;
uint32_t value;
} range_extension_pic_fields;
/** \brief HEVC range extension flags
* The following flags bears the same syntax and semantics as
* those defined in HEVC bit stream spec.
*/
uint8_t diff_cu_chroma_qp_offset_depth;
uint8_t chroma_qp_offset_list_len_minus1;
uint8_t log2_sao_offset_scale_luma;
uint8_t log2_sao_offset_scale_chroma;
uint8_t log2_max_transform_skip_block_size_minus2;
int8_t cb_qp_offset_list[6];
int8_t cr_qp_offset_list[6];
} VAPictureParameterBufferHEVCRext;
/**
*\brief HEVC Decoding Picture Parameter Buffer Structure for
*Screen Content extension
*
*This structure conveys picture level HEVC Scc parameters
*and should be sent once per frame. This data structure should be sent
*together with VAPictureParameterBufferHEVC and VAPictureParameterBufferHEVCRext
*in a single buffer of \ref VAPictureParameterBufferHEVCExtension since each
*frame of HEVC SCC contains picture level parameters, picture level range
*extension parameters and picture level Scc parameters. They should be parsed
*together and the buffer type is same as \ref VAPictureParameterBufferHEVC.
*
*/
typedef struct _VAPictureParameterBufferHEVCScc {
union {
struct {
/** \brief HEVC Scc extension flags
* The following flags bears the same syntax and semantics as
* those defined in HEVC bit stream spec.
*/
/* indicates if intra block copy (IBC) is enabled or not. */
uint32_t pps_curr_pic_ref_enabled_flag : 1;
/* indicates if Palette Mode is enabled or not. */
uint32_t palette_mode_enabled_flag : 1;
/* controls the presence and inference of the use_integer_mv_flag syntax
* in slice segment header that specifies the resolution of motion
* vectors for inter prediction.
*/
uint32_t motion_vector_resolution_control_idc : 2;
/* specifies that the intra boundary filtering process is
* disabled or not for intra prediction.
*/
uint32_t intra_boundary_filtering_disabled_flag : 1;
/* specifies that an adaptive colour transform may be applied
* to the residual in the decoding process.
*/
uint32_t residual_adaptive_colour_transform_enabled_flag : 1;
/* specifies that slice_act_y_qp_offset, slice_act_cb_qp_offset,
* slice_act_cr_qp_offset are present in the slice header
*/
uint32_t pps_slice_act_qp_offsets_present_flag : 1;
/** \brief Reserved bytes for future use, must be zero */
uint32_t reserved : 25;
} bits;
uint32_t value;
} screen_content_pic_fields;
/* specifies the maximum allowed palette size. */
uint8_t palette_max_size;
/* Correspond to HEVC syntax elements of the same names.
* It specifies the difference between the maximum allowed palette
* predictor size and the maximum allowed palette size.
* App needs to enforce that the variable PaletteMaxPredictorSize,
* which is derived as follows:
* PaletteMaxPredictorSize = palette_max_size + delta_palette_max_predictor_size
* should have a value range of [0..128].
*/
uint8_t delta_palette_max_predictor_size;
/** \brief Size of initial palette predictor.
* It is derived from pps_num_palette_predictor_initializer or
* sps_num_palette_predictor_initializer_minus1.
* Details in HEVC SCC spec section 9.3.2.3.
*/
uint8_t predictor_palette_size;
/** \brief Palette predictor initializer.
* It is derived from pps_palette_predictor_initializers[][]
* or sps_palette_predictor_initializers[][].
* Details in HEVC SCC spec section 9.3.2.3.
*/
uint16_t predictor_palette_entries[3][128];
/* are used to determine the offsets that are applied to the
* quantization parameter values for the luma, Cb and Cr
* components, respectively.
*/
int8_t pps_act_y_qp_offset_plus5;
int8_t pps_act_cb_qp_offset_plus5;
int8_t pps_act_cr_qp_offset_plus3;
} VAPictureParameterBufferHEVCScc;
/**
* \brief HEVC Decoding Picture Parameter Buffer Structure including Extensions
*
* This structure conveys picture level HEVC parameters including basic version 1
* and range extension and screen content extension.
* The data buffer should be sent once per frame.
*
*/
typedef struct _VAPictureParameterBufferHEVCExtension {
/** \brief basic HEVC picture parameters data structure
*/
VAPictureParameterBufferHEVC base;
/** \brief HEVC range extension picture parameters data structure
*/
VAPictureParameterBufferHEVCRext rext;
/** \brief HEVC screen content picture parameters data structure
*/
VAPictureParameterBufferHEVCScc scc;
} VAPictureParameterBufferHEVCExtension;
/**
* \brief HEVC Slice Parameter Buffer Structure For Long Format
*
* VASliceParameterBufferHEVC structure should be accompanied by a
* slice data buffer, which holds the whole raw slice NAL unit bit streams
* including start code prefix and emulation prevention bytes not removed.
*
* This structure conveys parameters related to slice segment header and should
* be sent once per slice.
*
* For short format, this data structure is not sent by application.
*
*/
typedef struct _VASliceParameterBufferHEVC {
/** @name Codec-independent Slice Parameter Buffer base. */
/**@{*/
/** \brief Number of bytes in the slice data buffer for this slice
* counting from and including NAL unit header.
*/
uint32_t slice_data_size;
/** \brief The offset to the NAL unit header for this slice */
uint32_t slice_data_offset;
/** \brief Slice data buffer flags. See \c VA_SLICE_DATA_FLAG_XXX. */
uint32_t slice_data_flag;
/**
* \brief Byte offset from NAL unit header to the begining of slice_data().
*
* This byte offset is relative to and includes the NAL unit header
* and represents the number of bytes parsed in the slice_header()
* after the removal of any emulation prevention bytes in
* there. However, the slice data buffer passed to the hardware is
* the original bitstream, thus including any emulation prevention
* bytes.
*/
uint32_t slice_data_byte_offset;
/** HEVC syntax element. */
uint32_t slice_segment_address;
/** \brief index into ReferenceFrames[]
* RefPicList[0][] corresponds to RefPicList0[] of HEVC variable.
* RefPicList[1][] corresponds to RefPicList1[] of HEVC variable.
* value range [0..14, 0xFF], where 0xFF indicates invalid entry.
*/
uint8_t RefPicList[2][15];
union {
uint32_t value;
struct {
/** current slice is last slice of picture. */
uint32_t LastSliceOfPic : 1;
/** HEVC syntax element. */
uint32_t dependent_slice_segment_flag : 1;
/** HEVC syntax element. */
uint32_t slice_type : 2;
/** HEVC syntax element. */
uint32_t color_plane_id : 2;
/** HEVC syntax element. */
uint32_t slice_sao_luma_flag : 1;
/** HEVC syntax element. */
uint32_t slice_sao_chroma_flag : 1;
/** HEVC syntax element. */
uint32_t mvd_l1_zero_flag : 1;
/** HEVC syntax element. */
uint32_t cabac_init_flag : 1;
/** HEVC syntax element. */
uint32_t slice_temporal_mvp_enabled_flag : 1;
/** HEVC syntax element. */
uint32_t slice_deblocking_filter_disabled_flag : 1;
/** HEVC syntax element. */
uint32_t collocated_from_l0_flag : 1;
/** HEVC syntax element. */
uint32_t slice_loop_filter_across_slices_enabled_flag : 1;
uint32_t reserved : 18;
} fields;
} LongSliceFlags;
/** HEVC syntax element. Collocated Reference Picture Index.
* index to RefPicList[0][] or RefPicList[1][].
* when slice_temporal_mvp_enabled_flag equals 0, it should take value 0xFF.
* value range [0..14, 0xFF].
*/
uint8_t collocated_ref_idx;
/** HEVC syntax element.
* if num_ref_idx_active_override_flag equals 0, host decoder should
* set its value to num_ref_idx_l0_default_active_minus1.
*/
uint8_t num_ref_idx_l0_active_minus1;
/** HEVC syntax element.
* if num_ref_idx_active_override_flag equals 0, host decoder should
* set its value to num_ref_idx_l1_default_active_minus1.
*/
uint8_t num_ref_idx_l1_active_minus1;
/** HEVC syntax element. */
int8_t slice_qp_delta;
/** HEVC syntax element. */
int8_t slice_cb_qp_offset;
/** HEVC syntax element. */
int8_t slice_cr_qp_offset;
/** HEVC syntax element. */
int8_t slice_beta_offset_div2;
/** HEVC syntax element. */
int8_t slice_tc_offset_div2;
/** HEVC syntax element. */
uint8_t luma_log2_weight_denom;
/** HEVC syntax element. */
int8_t delta_chroma_log2_weight_denom;
/** HEVC syntax element. */
int8_t delta_luma_weight_l0[15];
/** HEVC syntax element. */
int8_t luma_offset_l0[15];
/** HEVC syntax element. */
int8_t delta_chroma_weight_l0[15][2];
/** corresponds to HEVC spec variable of the same name. */
int8_t ChromaOffsetL0[15][2];
/** HEVC syntax element. */
int8_t delta_luma_weight_l1[15];
/** HEVC syntax element. */
int8_t luma_offset_l1[15];
/** HEVC syntax element. */
int8_t delta_chroma_weight_l1[15][2];
/** corresponds to HEVC spec variable of the same name. */
int8_t ChromaOffsetL1[15][2];
/** HEVC syntax element. */
uint8_t five_minus_max_num_merge_cand;
/** HEVC syntax element. */
uint16_t num_entry_point_offsets;
/** HEVC syntax element. */
uint16_t entry_offset_to_subset_array;
/** \brief Number of emulation prevention bytes in slice header. */
uint16_t slice_data_num_emu_prevn_bytes;
/**@}*/
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW - 2];
} VASliceParameterBufferHEVC;
/**
* \brief HEVC Extented Slice Parameter Buffer Structure For Long Format
*
* This data structure contains extension profiles (range extension and screen content).
*
* VASliceParameterBufferHEVCRext structure should be accompanied by a
* slice data buffer, which holds the whole raw slice NAL unit bit streams
* including start code prefix and emulation prevention bytes not removed.
*
* This structure conveys parameters related to slice segment header and should
* be sent once per slice with VASliceParameterBufferHEVC in a single buffer of
* \ref VASliceParameterBufferHEVCExtension and the buffer type is same as \ref
* VASliceParameterBufferHEVC.
*
* For short format, this data structure is not sent by application.
*
*/
typedef struct _VASliceParameterBufferHEVCRext {
/* below four parameters are used to replace data types of the
* corresponding parameters of those in \# VASliceParameterBufferHEVC.
*/
int16_t luma_offset_l0[15];
int16_t ChromaOffsetL0[15][2];
int16_t luma_offset_l1[15];
int16_t ChromaOffsetL1[15][2];
union {
struct {
uint32_t cu_chroma_qp_offset_enabled_flag : 1;
uint32_t use_integer_mv_flag : 1;
/** \brief Reserved bytes for future use, must be zero */
uint32_t reserved : 30;
} bits;
uint32_t value;
} slice_ext_flags;
/** \brief Screen Content Extension parameters.
* data range [-12..12]
*/
int8_t slice_act_y_qp_offset;
int8_t slice_act_cb_qp_offset;
int8_t slice_act_cr_qp_offset;
} VASliceParameterBufferHEVCRext;
/**
* \brief HEVC Decoding Slice Parameter Buffer Structure For Long Format including Extensions
*
* This data structure contains both baseline HEVC profiles (main, main10)
* and extension profiles (range extension and screen content).
*
* VASliceParameterBufferHEVCExtension structure should be accompanied by a
* slice data buffer, which holds the whole raw slice NAL unit bit streams
* including start code prefix and emulation prevention bytes not removed.
*
* This structure conveys parameters related to slice segment header and should
* be sent once per slice. For HEVC range extension and HEVC Scc decoding,
* application should parse both basic slice parameters and extented slice
* parameters into this buffer structure and sent it.
*
* For short format, this data structure is not sent by application.
*
*/
typedef struct _VASliceParameterBufferHEVCExtension {
/** \brief baseline HEVC slice parameters data structure */
VASliceParameterBufferHEVC base;
/** \brief extented HEVC slice parameters data structure */
VASliceParameterBufferHEVCRext rext;
} VASliceParameterBufferHEVCExtension;
/**
* \brief HEVC Inverse Quantization Matrix Buffer Structure
*
* This structure is sent once per frame,
* and only when scaling_list_enabled_flag = 1.
* When sps_scaling_list_data_present_flag = 0, app still
* needs to send in this structure with default matrix values.
*
* Matrix entries are in raster scan order which follows HEVC spec.
*/
typedef struct _VAIQMatrixBufferHEVC {
/**
* \brief scaling lists,
* corresponds to same HEVC spec syntax element
* ScalingList[ i ][ MatrixID ][ j ].
*
* \brief 4x4 scaling,
* correspongs i = 0, MatrixID is in the range of 0 to 5,
* inclusive. And j is in the range of 0 to 15, inclusive.
*/
uint8_t ScalingList4x4[6][16];
/**
* \brief 8x8 scaling,
* correspongs i = 1, MatrixID is in the range of 0 to 5,
* inclusive. And j is in the range of 0 to 63, inclusive.
*/
uint8_t ScalingList8x8[6][64];
/**
* \brief 16x16 scaling,
* correspongs i = 2, MatrixID is in the range of 0 to 5,
* inclusive. And j is in the range of 0 to 63, inclusive.
*/
uint8_t ScalingList16x16[6][64];
/**
* \brief 32x32 scaling,
* correspongs i = 3, MatrixID is in the range of 0 to 1,
* inclusive. And j is in the range of 0 to 63, inclusive.
*/
uint8_t ScalingList32x32[2][64];
/**
* \brief DC values of the 16x16 scaling lists,
* corresponds to HEVC spec syntax
* scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8
* with sizeID = 2 and matrixID in the range of 0 to 5, inclusive.
*/
uint8_t ScalingListDC16x16[6];
/**
* \brief DC values of the 32x32 scaling lists,
* corresponds to HEVC spec syntax
* scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8
* with sizeID = 3 and matrixID in the range of 0 to 1, inclusive.
*/
uint8_t ScalingListDC32x32[2];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAIQMatrixBufferHEVC;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_DEC_HEVC_H */

View File

@@ -0,0 +1,155 @@
/*
* Copyright (c) 2007-2012 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_dec_jpeg.h
* \brief The JPEG decoding API
*
* This file contains the \ref api_dec_jpeg "JPEG decoding API".
*/
#ifndef VA_DEC_JPEG_H
#define VA_DEC_JPEG_H
#ifdef __cplusplus
extern "C" {
#endif
#include <va/va.h>
/**
* \defgroup api_dec_jpeg JPEG decoding API
*
* This JPEG decoding API supports Baseline profile only.
*
* @{
*/
/**
* \brief Picture parameter for JPEG decoding.
*
* This structure holds information from the frame header, along with
* definitions from additional segments.
*/
typedef struct _VAPictureParameterBufferJPEGBaseline {
/** \brief Picture width in pixels. */
uint16_t picture_width;
/** \brief Picture height in pixels. */
uint16_t picture_height;
struct {
/** \brief Component identifier (Ci). */
uint8_t component_id;
/** \brief Horizontal sampling factor (Hi). */
uint8_t h_sampling_factor;
/** \brief Vertical sampling factor (Vi). */
uint8_t v_sampling_factor;
/* \brief Quantization table selector (Tqi). */
uint8_t quantiser_table_selector;
} components[255];
/** \brief Number of components in frame (Nf). */
uint8_t num_components;
/** \brief Input color space 0: YUV, 1: RGB, 2: BGR, others: reserved */
uint8_t color_space;
/** \brief Set to VA_ROTATION_* for a single rotation angle reported by VAConfigAttribDecJPEG. */
uint32_t rotation;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_MEDIUM - 1];
} VAPictureParameterBufferJPEGBaseline;
/**
* \brief Quantization table for JPEG decoding.
*
* This structure holds the complete quantization tables. This is an
* aggregation of all quantization table (DQT) segments maintained by
* the application. i.e. up to 4 quantization tables are stored in
* there for baseline profile.
*
* The #load_quantization_table array can be used as a hint to notify
* the VA driver implementation about which table(s) actually changed
* since the last submission of this buffer.
*
* The #quantiser_table values are specified in zig-zag scan order.
*/
typedef struct _VAIQMatrixBufferJPEGBaseline {
/** \brief Specifies which #quantiser_table is valid. */
uint8_t load_quantiser_table[4];
/** \brief Quanziation tables indexed by table identifier (Tqi). */
uint8_t quantiser_table[4][64];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAIQMatrixBufferJPEGBaseline;
/**
* \brief Slice parameter for JPEG decoding.
*
* This structure holds information from the scan header, along with
* definitions from additional segments. The associated slice data
* buffer holds all entropy coded segments (ECS) in the scan.
*/
typedef struct _VASliceParameterBufferJPEGBaseline {
/** @name Codec-independent Slice Parameter Buffer base. */
/**@{*/
/** \brief Number of bytes in the slice data buffer for this slice. */
uint32_t slice_data_size;
/** \brief The offset to the first byte of the first MCU. */
uint32_t slice_data_offset;
/** \brief Slice data buffer flags. See \c VA_SLICE_DATA_FLAG_xxx. */
uint32_t slice_data_flag;
/**@}*/
/** \brief Scan horizontal position. */
uint32_t slice_horizontal_position;
/** \brief Scan vertical position. */
uint32_t slice_vertical_position;
struct {
/** \brief Scan component selector (Csj). */
uint8_t component_selector;
/** \brief DC entropy coding table selector (Tdj). */
uint8_t dc_table_selector;
/** \brief AC entropy coding table selector (Taj). */
uint8_t ac_table_selector;
} components[4];
/** \brief Number of components in scan (Ns). */
uint8_t num_components;
/** \brief Restart interval definition (Ri). */
uint16_t restart_interval;
/** \brief Number of MCUs in a scan. */
uint32_t num_mcus;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VASliceParameterBufferJPEGBaseline;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_DEC_JPEG_H */

View File

@@ -0,0 +1,249 @@
/*
* Copyright (c) 2007-2012 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_dec_vp.h
* \brief VP8 decoding API
*
* This file contains the \ref api_dec_vp8 "VP8 decoding API".
*/
#ifndef VA_DEC_VP8_H
#define VA_DEC_VP8_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_dec_vp8 VP8 decoding API
*
* @{
*/
/**
* \brief VPX Bool Coder Context structure
*
* This common structure is defined for potential sharing by other VP formats
*
*/
typedef struct _VABoolCoderContextVPX {
/* partition 0 "range" */
uint8_t range;
/* partition 0 "value" */
uint8_t value;
/*
* 'partition 0 number of shifts before an output byte is available'
* it is the number of remaining bits in 'value' for decoding, range [0, 7].
*/
uint8_t count;
} VABoolCoderContextVPX;
/**
* \brief VP8 Decoding Picture Parameter Buffer Structure
*
* This structure conveys frame level parameters and should be sent once
* per frame.
*
*/
typedef struct _VAPictureParameterBufferVP8 {
/* frame width in pixels */
uint32_t frame_width;
/* frame height in pixels */
uint32_t frame_height;
/* specifies the "last" reference frame */
VASurfaceID last_ref_frame;
/* specifies the "golden" reference frame */
VASurfaceID golden_ref_frame;
/* specifies the "alternate" referrence frame */
VASurfaceID alt_ref_frame;
/* specifies the out-of-loop deblocked frame, not used currently */
VASurfaceID out_of_loop_frame;
union {
struct {
/* same as key_frame in bitstream syntax, 0 means a key frame */
uint32_t key_frame : 1;
/* same as version in bitstream syntax */
uint32_t version : 3;
/* same as segmentation_enabled in bitstream syntax */
uint32_t segmentation_enabled : 1;
/* same as update_mb_segmentation_map in bitstream syntax */
uint32_t update_mb_segmentation_map : 1;
/* same as update_segment_feature_data in bitstream syntax */
uint32_t update_segment_feature_data : 1;
/* same as filter_type in bitstream syntax */
uint32_t filter_type : 1;
/* same as sharpness_level in bitstream syntax */
uint32_t sharpness_level : 3;
/* same as loop_filter_adj_enable in bitstream syntax */
uint32_t loop_filter_adj_enable : 1;
/* same as mode_ref_lf_delta_update in bitstream syntax */
uint32_t mode_ref_lf_delta_update : 1;
/* same as sign_bias_golden in bitstream syntax */
uint32_t sign_bias_golden : 1;
/* same as sign_bias_alternate in bitstream syntax */
uint32_t sign_bias_alternate : 1;
/* same as mb_no_coeff_skip in bitstream syntax */
uint32_t mb_no_coeff_skip : 1;
/* flag to indicate that loop filter should be disabled */
uint32_t loop_filter_disable : 1;
} bits;
uint32_t value;
} pic_fields;
/*
* probabilities of the segment_id decoding tree and same as
* mb_segment_tree_probs in the spec.
*/
uint8_t mb_segment_tree_probs[3];
/* Post-adjustment loop filter levels for the 4 segments */
uint8_t loop_filter_level[4];
/* loop filter deltas for reference frame based MB level adjustment */
int8_t loop_filter_deltas_ref_frame[4];
/* loop filter deltas for coding mode based MB level adjustment */
int8_t loop_filter_deltas_mode[4];
/* same as prob_skip_false in bitstream syntax */
uint8_t prob_skip_false;
/* same as prob_intra in bitstream syntax */
uint8_t prob_intra;
/* same as prob_last in bitstream syntax */
uint8_t prob_last;
/* same as prob_gf in bitstream syntax */
uint8_t prob_gf;
/*
* list of 4 probabilities of the luma intra prediction mode decoding
* tree and same as y_mode_probs in frame header
*/
uint8_t y_mode_probs[4];
/*
* list of 3 probabilities of the chroma intra prediction mode decoding
* tree and same as uv_mode_probs in frame header
*/
uint8_t uv_mode_probs[3];
/*
* updated mv decoding probabilities and same as mv_probs in
* frame header
*/
uint8_t mv_probs[2][19];
VABoolCoderContextVPX bool_coder_ctx;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAPictureParameterBufferVP8;
/**
* \brief VP8 Slice Parameter Buffer Structure
*
* This structure conveys parameters related to data partitions and should be
* sent once per frame. Slice data buffer of VASliceDataBufferType is used
* to send the partition data.
*
*/
typedef struct _VASliceParameterBufferVP8 {
/*
* number of bytes in the slice data buffer for the partitions
*/
uint32_t slice_data_size;
/*
* offset to the first byte of partition data (control partition)
*/
uint32_t slice_data_offset;
/*
* see VA_SLICE_DATA_FLAG_XXX definitions
*/
uint32_t slice_data_flag;
/*
* offset to the first bit of MB from the first byte of partition data(slice_data_offset)
*/
uint32_t macroblock_offset;
/*
* Partitions
* (1<<log2_nbr_of_dct_partitions)+1, count both control partition (frame header) and toke partition
*/
uint8_t num_of_partitions;
/*
* partition_size[0] is remaining bytes of control partition after parsed by application.
* exclude current byte for the remaining bits in bool_coder_ctx.
* exclude the uncompress data chunk since first_part_size 'excluding the uncompressed data chunk'
*/
uint32_t partition_size[9];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VASliceParameterBufferVP8;
/**
* \brief VP8 Coefficient Probability Data Buffer Structure
*
* Contains the contents of the token probability table, which may be
* incrementally modified in the frame header. There are four dimensions to
* the token probability array. The outermost dimension is indexed by the
* type of plane being decoded; the next dimension is selected by the
* position of the coefficient being decoded; the third dimension, * roughly
* speaking, measures the "local complexity" or extent to which nearby
* coefficients are non-zero; the fourth, and final, dimension of the token
* probability array is indexed by the position in the token tree structure,
* as are all tree probability arrays. This structure is sent once per frame.
*
*/
typedef struct _VAProbabilityDataBufferVP8 {
uint8_t dct_coeff_probs[4][8][3][11];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAProbabilityDataBufferVP8;
/**
* \brief VP8 Inverse Quantization Matrix Buffer Structure
*
* Contains quantization indices for yac(0),ydc(1),y2dc(2),y2ac(3),uvdc(4),
* uvac(5) for each segment (0-3). When segmentation is disabled, only
* quantization_index[0][] will be used. This structure is sent once per frame.
*/
typedef struct _VAIQMatrixBufferVP8 {
/*
* array first dimensional is segment and 2nd dimensional is Q index
* all Q indexs should be clipped to be range [0, 127]
*/
uint16_t quantization_index[4][6];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAIQMatrixBufferVP8;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_DEC_VP8_H */

View File

@@ -0,0 +1,312 @@
/*
* Copyright (c) 2014 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_dec_vp9.h
* \brief The VP9 decoding API
*
* This file contains the \ref api_dec_vp9 "VP9 decoding API".
*/
#ifndef VA_DEC_VP9_H
#define VA_DEC_VP9_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_dec_vp9 VP9 decoding API
*
* This VP9 decoding API supports 8-bit 420 format only.
*
* @{
*/
/**
* \brief VP9 Decoding Picture Parameter Buffer Structure
*
* This structure conveys picture level parameters.
* App should send a surface with this data structure down to VAAPI once
* per frame.
*
*/
typedef struct _VADecPictureParameterBufferVP9 {
/** \brief picture width
* Picture original resolution. The value may not be multiple of 8.
*/
uint16_t frame_width;
/** \brief picture height
* Picture original resolution. The value may not be multiple of 8.
*/
uint16_t frame_height;
/** \brief Surface indices of reference frames in DPB.
*
* Each entry of the list specifies the surface index of the picture
* that is referred by current picture or will be referred by any future
* picture.
* Application who calls this API should update this list based on the
* refreshing information from VP9 bitstream.
*/
VASurfaceID reference_frames[8];
union {
struct {
/** \brief flags for current picture
* same syntax and semantic as those in VP9 code
*/
uint32_t subsampling_x : 1;
uint32_t subsampling_y : 1;
uint32_t frame_type : 1;
uint32_t show_frame : 1;
uint32_t error_resilient_mode : 1;
uint32_t intra_only : 1;
uint32_t allow_high_precision_mv : 1;
uint32_t mcomp_filter_type : 3;
uint32_t frame_parallel_decoding_mode : 1;
uint32_t reset_frame_context : 2;
uint32_t refresh_frame_context : 1;
uint32_t frame_context_idx : 2;
uint32_t segmentation_enabled : 1;
/** \brief corresponds to variable temporal_update in VP9 code.
*/
uint32_t segmentation_temporal_update : 1;
/** \brief corresponds to variable update_mb_segmentation_map
* in VP9 code.
*/
uint32_t segmentation_update_map : 1;
/** \brief Index of reference_frames[] and points to the
* LAST reference frame.
* It corresponds to active_ref_idx[0] in VP9 code.
*/
uint32_t last_ref_frame : 3;
/** \brief Sign Bias of the LAST reference frame.
* It corresponds to ref_frame_sign_bias[LAST_FRAME] in VP9 code.
*/
uint32_t last_ref_frame_sign_bias : 1;
/** \brief Index of reference_frames[] and points to the
* GOLDERN reference frame.
* It corresponds to active_ref_idx[1] in VP9 code.
*/
uint32_t golden_ref_frame : 3;
/** \brief Sign Bias of the GOLDERN reference frame.
* Corresponds to ref_frame_sign_bias[GOLDERN_FRAME] in VP9 code.
*/
uint32_t golden_ref_frame_sign_bias : 1;
/** \brief Index of reference_frames[] and points to the
* ALTERNATE reference frame.
* Corresponds to active_ref_idx[2] in VP9 code.
*/
uint32_t alt_ref_frame : 3;
/** \brief Sign Bias of the ALTERNATE reference frame.
* Corresponds to ref_frame_sign_bias[ALTREF_FRAME] in VP9 code.
*/
uint32_t alt_ref_frame_sign_bias : 1;
/** \brief Lossless Mode
* LosslessFlag = base_qindex == 0 &&
* y_dc_delta_q == 0 &&
* uv_dc_delta_q == 0 &&
* uv_ac_delta_q == 0;
* Where base_qindex, y_dc_delta_q, uv_dc_delta_q and uv_ac_delta_q
* are all variables in VP9 code.
*/
uint32_t lossless_flag : 1;
} bits;
uint32_t value;
} pic_fields;
/* following parameters have same syntax with those in VP9 code */
uint8_t filter_level;
uint8_t sharpness_level;
/** \brief number of tile rows specified by (1 << log2_tile_rows).
* It corresponds the variable with same name in VP9 code.
*/
uint8_t log2_tile_rows;
/** \brief number of tile columns specified by (1 << log2_tile_columns).
* It corresponds the variable with same name in VP9 code.
*/
uint8_t log2_tile_columns;
/** \brief Number of bytes taken up by the uncompressed frame header,
* which corresponds to byte length of function
* read_uncompressed_header() in VP9 code.
* Specifically, it is the byte count from bit stream buffer start to
* the last byte of uncompressed frame header.
* If there are other meta data in the buffer before uncompressed header,
* its size should be also included here.
*/
uint8_t frame_header_length_in_bytes;
/** \brief The byte count of compressed header the bitstream buffer,
* which corresponds to syntax first_partition_size in code.
*/
uint16_t first_partition_size;
/** These values are segment probabilities with same names in VP9
* function setup_segmentation(). They should be parsed directly from
* bitstream by application.
*/
uint8_t mb_segment_tree_probs[7];
uint8_t segment_pred_probs[3];
/** \brief VP9 Profile definition
* value range [0..3].
*/
uint8_t profile;
/** \brief VP9 bit depth per sample
* same for both luma and chroma samples.
*/
uint8_t bit_depth;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_MEDIUM];
} VADecPictureParameterBufferVP9;
/**
* \brief VP9 Segmentation Parameter Data Structure
*
* This structure conveys per segment parameters.
* 8 of this data structure will be included in VASegmentationParameterBufferVP9
* and sent to API in a single buffer.
*
*/
typedef struct _VASegmentParameterVP9 {
union {
struct {
/** \brief Indicates if per segment reference frame indicator
* is enabled.
* Corresponding to variable feature_enabled when
* j == SEG_LVL_REF_FRAME in function setup_segmentation() VP9 code.
*/
uint16_t segment_reference_enabled : 1;
/** \brief Specifies per segment reference indication.
* 0: reserved
* 1: Last ref
* 2: golden
* 3: altref
* Value can be derived from variable data when
* j == SEG_LVL_REF_FRAME in function setup_segmentation() VP9 code.
*/
uint16_t segment_reference : 2;
/** \brief Indicates if per segment skip feature is enabled.
* Corresponding to variable feature_enabled when
* j == SEG_LVL_SKIP in function setup_segmentation() VP9 code.
*/
uint16_t segment_reference_skipped : 1;
} fields;
uint16_t value;
} segment_flags;
/** \brief Specifies the filter level information per segment.
* The value corresponds to variable lfi->lvl[seg][ref][mode] in VP9 code,
* where m is [ref], and n is [mode] in FilterLevel[m][n].
*/
uint8_t filter_level[4][2];
/** \brief Specifies per segment Luma AC quantization scale.
* Corresponding to y_dequant[qindex][1] in vp9_mb_init_quantizer()
* function of VP9 code.
*/
int16_t luma_ac_quant_scale;
/** \brief Specifies per segment Luma DC quantization scale.
* Corresponding to y_dequant[qindex][0] in vp9_mb_init_quantizer()
* function of VP9 code.
*/
int16_t luma_dc_quant_scale;
/** \brief Specifies per segment Chroma AC quantization scale.
* Corresponding to uv_dequant[qindex][1] in vp9_mb_init_quantizer()
* function of VP9 code.
*/
int16_t chroma_ac_quant_scale;
/** \brief Specifies per segment Chroma DC quantization scale.
* Corresponding to uv_dequant[qindex][0] in vp9_mb_init_quantizer()
* function of VP9 code.
*/
int16_t chroma_dc_quant_scale;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VASegmentParameterVP9;
/**
* \brief VP9 Slice Parameter Buffer Structure
*
* This structure conveys parameters related to segmentation data and should be
* sent once per frame.
*
* When segmentation is disabled, only SegParam[0] has valid values,
* all other entries should be populated with 0.
* Otherwise, all eight entries should be valid.
*
* Slice data buffer of VASliceDataBufferType is used
* to send the bitstream which should include whole or part of partition 0
* (at least compressed header) to the end of frame.
*
*/
typedef struct _VASliceParameterBufferVP9 {
/** \brief The byte count of current frame in the bitstream buffer,
* starting from first byte of the buffer.
* It uses the name slice_data_size to be consitent with other codec,
* but actually means frame_data_size.
*/
uint32_t slice_data_size;
/**
* offset to the first byte of partition data (control partition)
*/
uint32_t slice_data_offset;
/**
* see VA_SLICE_DATA_FLAG_XXX definitions
*/
uint32_t slice_data_flag;
/**
* \brief per segment information
*/
VASegmentParameterVP9 seg_param[8];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VASliceParameterBufferVP9;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_DEC_VP9_H */

View File

@@ -0,0 +1,61 @@
/*
* va_drm.h - Raw DRM API
*
* Copyright (c) 2012 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VA_DRM_H
#define VA_DRM_H
#include <va/va.h>
/**
* \file va_drm.h
* \brief The raw DRM API
*
* This file contains the \ref api_drm "Raw DRM API".
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* \brief Returns a VA display derived from the specified DRM connection.
*
* This function returns a (possibly cached) VA display from the
* specified DRM connection @fd.
*
* @param[in] fd the DRM connection descriptor
* @return the VA display
*/
VADisplay
vaGetDisplayDRM(int fd);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_DRM_H */

View File

@@ -0,0 +1,179 @@
/*
* va_drmcommon.h - Common utilities for DRM-based drivers
*
* Copyright (c) 2012 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VA_DRM_COMMON_H
#define VA_DRM_COMMON_H
#include <stdint.h>
/** \brief DRM authentication type. */
enum {
/** \brief Disconnected. */
VA_DRM_AUTH_NONE = 0,
/**
* \brief Connected. Authenticated with DRI1 protocol.
*
* @deprecated
* This is a deprecated authentication type. All DRI-based drivers have
* been migrated to use the DRI2 protocol. Newly written drivers shall
* use DRI2 protocol only, or a custom authentication means. e.g. opt
* for authenticating on the VA driver side, instead of libva side.
*/
VA_DRM_AUTH_DRI1 = 1,
/**
* \brief Connected. Authenticated with DRI2 protocol.
*
* This is only useful to VA/X11 drivers. The libva-x11 library provides
* a helper function VA_DRI2Authenticate() for authenticating the
* connection. However, DRI2 conformant drivers don't need to call that
* function since authentication happens on the libva side, implicitly.
*/
VA_DRM_AUTH_DRI2 = 2,
/**
* \brief Connected. Authenticated with some alternate raw protocol.
*
* This authentication mode is mainly used in non-VA/X11 drivers.
* Authentication happens through some alternative method, at the
* discretion of the VA driver implementation.
*/
VA_DRM_AUTH_CUSTOM = 3
};
/** \brief Base DRM state. */
struct drm_state {
/** \brief DRM connection descriptor. */
int fd;
/** \brief DRM authentication type. */
int auth_type;
/** \brief Reserved bytes for future use, must be zero */
int va_reserved[8];
};
/** \brief Kernel DRM buffer memory type. */
#define VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM 0x10000000
/** \brief DRM PRIME memory type (old version)
*
* This supports only single objects with restricted memory layout.
* Used with VASurfaceAttribExternalBuffers.
*/
#define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME 0x20000000
/** \brief DRM PRIME memory type
*
* Used with VADRMPRIMESurfaceDescriptor.
*/
#define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 0x40000000
/**
* \brief External buffer descriptor for a DRM PRIME surface.
*
* For export, call vaExportSurfaceHandle() with mem_type set to
* VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 and pass a pointer to an
* instance of this structure to fill.
* If VA_EXPORT_SURFACE_SEPARATE_LAYERS is specified on export, each
* layer will contain exactly one plane. For example, an NV12
* surface will be exported as two layers, one of DRM_FORMAT_R8 and
* one of DRM_FORMAT_GR88.
* If VA_EXPORT_SURFACE_COMPOSED_LAYERS is specified on export,
* there will be exactly one layer.
*
* For import, call vaCreateSurfaces() with the MemoryType attribute
* set to VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 and the
* ExternalBufferDescriptor attribute set to point to an array of
* num_surfaces instances of this structure.
* The number of planes which need to be provided for a given layer
* is dependent on both the format and the format modifier used for
* the objects containing it. For example, the format DRM_FORMAT_RGBA
* normally requires one plane, but with the format modifier
* I915_FORMAT_MOD_Y_TILED_CCS it requires two planes - the first
* being the main data plane and the second containing the color
* control surface.
* Note that a given driver may only support a subset of possible
* representations of a particular format. For example, it may only
* support NV12 surfaces when they are contained within a single DRM
* object, and therefore fail to create such surfaces if the two
* planes are in different DRM objects.
* Note that backend driver will retrieve the resource represent by fd,
* and a valid surface ID is generated. Backend driver will not close
* the file descriptor. Application should handle the release of the fd.
* releasing the fd will not impact the existence of the surface.
*/
typedef struct _VADRMPRIMESurfaceDescriptor {
/** Pixel format fourcc of the whole surface (VA_FOURCC_*). */
uint32_t fourcc;
/** Width of the surface in pixels. */
uint32_t width;
/** Height of the surface in pixels. */
uint32_t height;
/** Number of distinct DRM objects making up the surface. */
uint32_t num_objects;
/** Description of each object. */
struct {
/** DRM PRIME file descriptor for this object. */
int fd;
/** Total size of this object (may include regions which are
* not part of the surface). */
uint32_t size;
/** Format modifier applied to this object. */
uint64_t drm_format_modifier;
} objects[4];
/** Number of layers making up the surface. */
uint32_t num_layers;
/** Description of each layer in the surface. */
struct {
/** DRM format fourcc of this layer (DRM_FOURCC_*). */
uint32_t drm_format;
/** Number of planes in this layer. */
uint32_t num_planes;
/** Index in the objects array of the object containing each
* plane. */
uint32_t object_index[4];
/** Offset within the object of each plane. */
uint32_t offset[4];
/** Pitch of each plane. */
uint32_t pitch[4];
} layers[4];
} VADRMPRIMESurfaceDescriptor;
/**
* \brief List of DRM format modifiers.
*
* To allocate surfaces with one of the modifiers specified in the array, call
* vaCreateSurfaces() with the VASurfaceAttribDRMFormatModifiers attribute set
* to point to an array of num_surfaces instances of this structure. The driver
* will select the optimal modifier in the list.
*
* DRM format modifiers are defined in drm_fourcc.h in the Linux kernel.
*/
typedef struct _VADRMFormatModifierList {
/** Number of modifiers. */
uint32_t num_modifiers;
/** Array of modifiers. */
uint64_t *modifiers;
} VADRMFormatModifierList;
#endif /* VA_DRM_COMMON_H */

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2007 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _VA_EGL_H_
#define _VA_EGL_H_
#warning The APIs / data structures included in this file are deprecated
#endif /* _VA_EGL_H_ */

View File

@@ -0,0 +1,986 @@
/*
* Copyright (c) 2021 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_enc_av1.h
* \brief AV1 encoding API
*
* This file contains the \ref api_enc_av1 "AV1 encoding API".
*
*/
#ifndef VA_ENC_AV1_H
#define VA_ENC_AV1_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/**
* \defgroup api_enc_av1 AV1 encoding API
*
* This AV1 encoding API supports 8-bit/10bit 420 format only.
*
* @{
*/
/** \brief Attribute value for VAConfigAttribEncAV1.
*
* This attribute decribes the supported features of an AV1
* encoder configuration.
*
* All of the field values in this attribute are VA_FEATURE_* values,
* indicating support for the corresponding feature.
*
*/
typedef union _VAConfigAttribValEncAV1 {
struct {
/**
* \brief Use 128x128 superblock.
*
* Allows setting use_128x128_superblock in the SPS.
*/
uint32_t support_128x128_superblock : 2;
/**
* \brief Intra filter.
* Allows setting enable_filter_intra in the SPS.
*/
uint32_t support_filter_intra : 2;
/**
* \brief Intra edge filter.
* Allows setting enable_intra_edge_filter in the SPS.
*/
uint32_t support_intra_edge_filter : 2;
/**
* \brief Interintra compound.
* Allows setting enable_interintra_compound in the SPS.
*/
uint32_t support_interintra_compound : 2;
/**
* \brief Masked compound.
* Allows setting enable_masked_compound in the SPS.
*/
uint32_t support_masked_compound : 2;
/**
* \brief Warped motion.
* Allows setting enable_warped_motion in the SPS.
*/
uint32_t support_warped_motion : 2;
/**
* \brief Palette mode.
* Allows setting palette_mode in the PPS.
*/
uint32_t support_palette_mode : 2;
/**
* \brief Dual filter.
* Allows setting enable_dual_filter in the SPS.
*/
uint32_t support_dual_filter : 2;
/**
* \brief Jnt compound.
* Allows setting enable_jnt_comp in the SPS.
*/
uint32_t support_jnt_comp : 2;
/**
* \brief Refrence frame mvs.
* Allows setting enable_ref_frame_mvs in the SPS.
*/
uint32_t support_ref_frame_mvs : 2;
/**
* \brief Super resolution.
* Allows setting enable_superres in the SPS.
*/
uint32_t support_superres : 2;
/**
* \brief Restoration.
* Allows setting enable_restoration in the SPS.
*/
uint32_t support_restoration : 2;
/**
* \brief Allow intraBC.
* Allows setting allow_intrabc in the PPS.
*/
uint32_t support_allow_intrabc : 2;
/**
* \brief Cdef channel strength.
* Allows setting cdef_y_strengths and cdef_uv_strengths in PPS.
*/
uint32_t support_cdef_channel_strength : 2;
/** \brief Reserved bits for future, must be zero. */
uint32_t reserved : 4;
} bits;
uint32_t value;
} VAConfigAttribValEncAV1;
/** \brief Attribute value for VAConfigAttribEncAV1Ext1. */
typedef union _VAConfigAttribValEncAV1Ext1 {
struct {
/**
* \brief Fields indicate which types of interpolation filter are supported.
* (interpolation_filter & 0x01) == 1: eight_tap filter is supported, 0: not.
* (interpolation_filter & 0x02) == 1: eight_tap_smooth filter is supported, 0: not.
* (interpolation_filter & 0x04) == 1: eight_sharp filter is supported, 0: not.
* (interpolation_filter & 0x08) == 1: bilinear filter is supported, 0: not.
* (interpolation_filter & 0x10) == 1: switchable filter is supported, 0: not.
*/
uint32_t interpolation_filter : 5;
/**
* \brief Min segmentId block size accepted.
* Application need to send seg_id_block_size in PPS equal or larger than this value.
*/
uint32_t min_segid_block_size_accepted : 8;
/**
* \brief Type of segment feature supported.
* (segment_feature_support & 0x01) == 1: SEG_LVL_ALT_Q is supported, 0: not.
* (segment_feature_support & 0x02) == 1: SEG_LVL_ALT_LF_Y_V is supported, 0: not.
* (segment_feature_support & 0x04) == 1: SEG_LVL_ALT_LF_Y_H is supported, 0: not.
* (segment_feature_support & 0x08) == 1: SEG_LVL_ALT_LF_U is supported, 0: not.
* (segment_feature_support & 0x10) == 1: SEG_LVL_ALT_LF_V is supported, 0: not.
* (segment_feature_support & 0x20) == 1: SEG_LVL_REF_FRAME is supported, 0: not.
* (segment_feature_support & 0x40) == 1: SEG_LVL_SKIP is supported, 0: not.
* (segment_feature_support & 0x80) == 1: SEG_LVL_GLOBALMV is supported, 0: not.
*/
uint32_t segment_feature_support : 8;
/** \brief Reserved bits for future, must be zero. */
uint32_t reserved : 11;
} bits;
uint32_t value;
} VAConfigAttribValEncAV1Ext1;
/** \brief Attribute value for VAConfigAttribEncAV1Ext2. */
typedef union _VAConfigAttribValEncAV1Ext2 {
struct {
/**
* \brief Tile size bytes minus1.
* Specify the number of bytes needed to code tile size supported.
* This value need to be set in frame header obu.
*/
uint32_t tile_size_bytes_minus1 : 2;
/**
* \brief Tile size bytes minus1.
* Specify the fixed number of bytes needed to code syntax obu_size.
*/
uint32_t obu_size_bytes_minus1 : 2;
/**
* \brief tx_mode supported.
* (tx_mode_support & 0x01) == 1: ONLY_4X4 is supported, 0: not.
* (tx_mode_support & 0x02) == 1: TX_MODE_LARGEST is supported, 0: not.
* (tx_mode_support & 0x04) == 1: TX_MODE_SELECT is supported, 0: not.
*/
uint32_t tx_mode_support : 3;
/**
* \brief Max tile num minus1.
* Specify the max number of tile supported by driver.
*/
uint32_t max_tile_num_minus1 : 13;
/** \brief Reserved bits for future, must be zero. */
uint32_t reserved : 12;
} bits;
uint32_t value;
} VAConfigAttribValEncAV1Ext2;
/**
* \brief Packed header types specific to AV1 encoding.
*
* Types of packed headers generally used for AV1 encoding.
*
*/
typedef enum {
/**
* \brief Packed Sequence Parameter Set (SPS).
*
* The corresponding packed header data buffer shall contain the
* complete sequence_header_obu() syntax element.
*
*/
VAEncPackedHeaderAV1_SPS = VAEncPackedHeaderSequence,
/**
* \brief Packed Picture Parameter Set (PPS).
*
* The corresponding packed header data buffer shall contain the
* complete frame_header_obu() syntax element.
*
*/
VAEncPackedHeaderAV1_PPS = VAEncPackedHeaderPicture,
} VAEncPackedHeaderTypeAV1;
/**
* \brief AV1 Encoding Sequence Parameter Buffer Structure.
*
* This structure conveys sequence level parameters.
*
*/
typedef struct _VAEncSequenceParameterBufferAV1 {
/** \brief AV1 profile setting.
* value range [0..2].
*/
uint8_t seq_profile;
/** \brief Level Setting of current operation point.
* value range [0..23].
*/
uint8_t seq_level_idx;
/** \brief Tier Setting of current operation point.
* value range [0..1].
*/
uint8_t seq_tier;
uint8_t reserved8b;
/** \brief Period between intra_only frames. */
uint32_t intra_period;
/** \brief Period between I/P frames.
* For hierarchical structure, this is the anchor frame distance.
*/
uint32_t ip_period;
/* \brief RC related fields. RC modes are set with VAConfigAttribRateControl. */
/* For AV1, CBR implies HRD conformance and VBR implies no HRD conformance. */
/**
* \brief Initial bitrate set for this sequence in CBR or VBR modes.
*
* This field represents the initial bitrate value for CBR mode or
* initial max bitrate value for VBR mode in this sequence.
* i.e. if the encoder pipeline was created with a #VAConfigAttribRateControl
* attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
*
* The bitrate can be modified later on through
* #VAEncMiscParameterRateControl buffers.
*/
uint32_t bits_per_second;
union {
struct {
/** \brief Still picture encoding, no inter frame referencing. */
uint32_t still_picture : 1;
/** \brief Force using 128x128 or 64x64 Supper block */
uint32_t use_128x128_superblock : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_filter_intra : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_intra_edge_filter : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_interintra_compound : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_masked_compound : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_warped_motion : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_dual_filter : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_order_hint : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_jnt_comp : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_ref_frame_mvs : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_superres : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_cdef : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t enable_restoration : 1;
/** \brief Reserved bytes for future use, must be zero. */
uint32_t reserved_bits : 18;
} bits;
uint32_t value;
} seq_fields;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..7].
*/
uint8_t order_hint_bits_minus_1;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_HIGH];
} VAEncSequenceParameterBufferAV1;
#define VA_AV1_MAX_SEGMENTS 8
#define VA_AV1_SEG_LVL_MAX 8
/**
* \brief Segment parameters
*/
typedef struct _VAEncSegParamAV1 {
union {
struct {
/** \brief Indicates if segmentation is enabled in the current frame.
* If disabled, all the below parameters in the structure should
* be set to 0, and ignored by driver.
*/
uint8_t segmentation_enabled : 1;
/**
* When segmentation_enabled equals 1 and segment_number > 0,
* this parameter equals 1 indicates the segmentation map may
* come from application, and that "Segment map data buffer"
* should be provided with populated segment_id. If equals 0,
* segmentation map should be inherited from a reference frame
* (specified by \c primary_ref_frame). When segmentation_enabled or
* segment_number equals 0, this parameter should be set to 0
* and ignored by driver.
*/
uint8_t segmentation_update_map : 1;
/**
* When segmentation_update_map equals 1, this parameter equaling 1
* indicates segment id per block will be determined either from
* reference frame or from app. Equaling 0 means segment id per block
* will come from app. When segmentation_temporal_update equals 0,
* this parameter should be set to 0 and ignored by driver.
*/
uint8_t segmentation_temporal_update : 1;
/** \brief Reserved bytes for future use, must be zero. */
uint8_t reserved : 5;
} bits;
uint8_t value;
} seg_flags;
/**
* If segmentation_enabled equals 1, this parameter indicates
* the number of segments conveyed through VAAPI. In this case,
* if segment_number equals 0, it will force the driver to determine
* how many segments would be created as well as the segmentation map
* to be generated. Also the driver shall write the segmentation_params()
* syntax in the uncompressed header at \c bit_offset_segmentation (back-annotation).
* In application, the rest parameters in this structure should be all
* set to 0 and ignored by driver. And app should NOT send the
* "Segment map data buffer". In packed uncompressed header
* bitstream, app should write syntax element segmentation_enabled
* as 0 and segmentation_params() should be only 1-bit-long.
* If segment_number > 0, and segmentation_update_map = 1, app should provide
* the "Segment map data buffer" and populate the rest of the
* current data structure. And that underline encoder would honor
* the segmentation parameters feature_data[0..segment_number-1][]
* and feature_mask[0..segment_number-1], etc.
* Value range [0..8].
*/
uint8_t segment_number;
/** \brief segment parameters.
* feature_data[][] is equivalent to variable FeatureData[][] in spec,
* which is after clip3() operation.
* Clip3(x, y, z) = (z<x)? x : ((z > y)? y : z);
* The limit is defined in Segmentation_Feature_Max[ SEG_LVL_MAX ] = {
* 255, MAX_LOOP_FILTER, MAX_LOOP_FILTER, MAX_LOOP_FILTER,
* MAX_LOOP_FILTER, 7, 0, 0 }
*/
int16_t feature_data[VA_AV1_MAX_SEGMENTS][VA_AV1_SEG_LVL_MAX];
/** \brief Bit field to indicate each feature is enabled or not per
* segment_id. Each bit is the feature_id.
*/
uint8_t feature_mask[VA_AV1_MAX_SEGMENTS];
/** \brief Reserved bytes for future use, must be zero. */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncSegParamAV1;
/**
* \brief Segment map data buffer.
*
* This buffer is optional depending on the value of av1_segments.segmentation_enabled.
* If av1_segments.segmentation_enabled in the picture parameters equals 1,
* and RateControlMethod is not CQP and this surface is not provided by App,
* the encoder will determine the per block segmentation map. In this case,
* App should not provide the segmentation parameter data structure
* in frame header as well. If av1_segments.segmentation_enabled equals 1
* and the segmentation map buffer is provided, app should embed the
* segmentation info in frame header, populate the VAEncSegParamAV1 structure with
* #VAEncMacroblockMapBufferType and the driver as well as the underline encoder
* should honor what is given by the app.
*/
typedef struct _VAEncSegMapBufferAV1 {
/** \brief Segment map data size. */
uint32_t segmentMapDataSize;
/**
* \brief Segment map.
* Size of this map is indicated by \ref segmentMapDataSize and each element
* in this map contains the segment id of a particular block.
* The element is indexed by raster scan order.
* The value of each entry should be in the range [0..7], inclusive.
*/
uint8_t *pSegmentMap;
} VAEncSegMapBufferAV1;
typedef enum {
/** \brief Identity transformation, 0-parameter. */
VAAV1EncTransformationIdentity = 0,
/** \brief Translational motion, 2-parameter. */
VAAV1EncTransformationTranslation = 1,
/** \brief Simplified affine with rotation + zoom only, 4-parameter. */
VAAV1EncTransformationRotzoom = 2,
/** \brief Affine, 6-parameter. */
VAAV1EncTransformationAffine = 3,
/** \brief Transformation count. */
VAAV1EncTransformationCount
} VAEncTransformationTypeAV1;
typedef struct _VAEncWarpedMotionParamsAV1{
/** \brief Specify the type of warped motion. */
VAEncTransformationTypeAV1 wmtype;
/** \brief Specify warp motion parameters.
* wm.wmmat[] corresponds to gm_params[][] in spec.
* Details in AV1 spec section 5.9.24 or refer to libaom code
* https://aomedia.googlesource.com/aom/+/refs/heads/master/av1/decoder/decodeframe.c.
*/
int32_t wmmat[8];
/** \brief Valid or invalid on affine set. */
uint8_t invalid;
/** \brief Reserved bytes for future use, must be zero. */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncWarpedMotionParamsAV1;
/**
* \brief Reference frame control.
*
* Suggest which frame to be used as reference along with preferred search order.
*
* search_idx#: index into ref_frame_idx[] to indicate that frame will be included
* in the reference list if value in range [1..7]. Invalid when value is 0.
* The order of the search_idx# indicates the preferred search order.
*
*/
typedef union {
struct
{
/**
* \brief Value used as index into ref_frame_idx[] to indicate that frame
* will be included in the reference list.
* valid value range: [1..7], invalid when value is 0.
*/
uint32_t search_idx0 : 3;
/**
* \brief Value used as index into ref_frame_idx[] to indicate that frame
* will be included in the reference list.
* valid value range: [1..7], invalid when value is 0.
*/
uint32_t search_idx1 : 3;
/**
* \brief Value used as index into ref_frame_idx[] to indicate that frame
* will be included in the reference list.
* valid value range: [1..7], invalid when value is 0.
*/
uint32_t search_idx2 : 3;
/**
* \brief Value used as index into ref_frame_idx[] to indicate that frame
* will be included in the reference list.
* valid value range: [1..7], invalid when value is 0.
*/
uint32_t search_idx3 : 3;
/**
* \brief Value used as index into ref_frame_idx[] to indicate that frame
* will be included in the reference list.
* valid value range: [1..7], invalid when value is 0.
*/
uint32_t search_idx4 : 3;
/**
* \brief Value used as index into ref_frame_idx[] to indicate that frame
* will be included in the reference list.
* valid value range: [1..7], invalid when value is 0.
*/
uint32_t search_idx5 : 3;
/**
* \brief Value used as index into ref_frame_idx[] to indicate that frame
* will be included in the reference list.
* valid value range: [1..7], invalid when value is 0.
*/
uint32_t search_idx6 : 3;
/** \brief Reserved bytes for future use, must be zero. */
uint32_t Reserved : 11;
} fields;
uint32_t value;
} VARefFrameCtrlAV1;
/**
* \brief AV1 Encoding Picture Parameter Buffer Structure.
*
* This structure conveys picture level parameters.
*
*/
typedef struct _VAEncPictureParameterBufferAV1
{
/** \brief AV1 encoder may support SupRes and dynamic scaling function.
* For SupRes, underline encoder is responsible to do downscaling.
* For dynamic scaling, app should provide the scaled raw source.
*/
/** \brief Raw source frame width in pixels. */
uint16_t frame_width_minus_1;
/** \brief Raw source frame height in pixels. */
uint16_t frame_height_minus_1;
/** \brief Surface to store reconstructed frame, not used for enc only case. */
VASurfaceID reconstructed_frame;
/** \brief Buffer to store coded data. */
VABufferID coded_buf;
/** \brief Reference frame buffers.
* Each entry of the array specifies the surface index of the picture
* that is referred by current picture or will be referred by any future
* picture. The valid entries take value from 0 to 127, inclusive.
* Non-valid entries, those do not point to pictures which are referred
* by current picture or future pictures, should take value 0xFF.
* Other values are not allowed.
*
* Application should update this array based on the refreshing
* information expected.
*/
VASurfaceID reference_frames[8];
/** \brief Reference index list.
* Contains a list of indices into refernce_frames[].
* Indice with refernce frames range: [LAST_FRAME - LAST_FRAME,
* LAST2_FRAME - LAST_FRAME, ..., ALTREF2_FRAME - LAST_FRAME].
* #define LAST_FRAME 1
* #define LAST2_FRAME 2
* #define LAST3_FRAME 3
* #define GOLDEN_FRAME 4
* #define BWDREF_FRAME 5
* #define ALTREF_FRAME 6
* #define ALTREF2_FRAME 7
* value range [0..7].
*/
uint8_t ref_frame_idx[7];
uint8_t reserved8bits0;
/** \brief primary reference frame.
* Index into reference_frames[]
* segment id map, context table, etc. come from the reference
* frame pointed by this index.
* value range [0..7].
*/
uint8_t primary_ref_frame;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint8_t order_hint;
uint16_t reserved16bits0;
/** \brief Suggest which frames to be used as references.
* see struct #VARefFrameCtrl for details.
*/
VARefFrameCtrlAV1 ref_frame_ctrl_l0;
VARefFrameCtrlAV1 ref_frame_ctrl_l1;
union {
struct {
/** \brief frame type.
* 0: key_frame.
* 1: inter_frame.
* 2: intra_only frame.
* 3: switch_frame (app needs to set error_resilient_mode = 1,
* refresh_frame_flags, etc approperately.).
*/
uint32_t frame_type : 2;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t error_resilient_mode : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t disable_cdf_update : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t use_superres : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t allow_high_precision_mv : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t use_ref_frame_mvs : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t disable_frame_end_update_cdf : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t reduced_tx_set : 1;
/** \brief For single tile group, app may choose to use one frame obu
* to replace one frame header obu + one tile group obu.
* Invalid if num_tile_groups_minus1 > 0.
*/
uint32_t enable_frame_obu : 1;
/** \brief Indicate the current frame will be used as a long term reference. */
uint32_t long_term_reference : 1;
/** \brief If the encoded frame will not be referred by other frames,
* its recon may not be generated in order to save memory bandwidth.
*/
uint32_t disable_frame_recon : 1;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint32_t allow_intrabc : 1;
/** \brief Equal to 1 indicates that intra blocks may use palette encoding.
* Otherwise disable palette encoding.
*/
uint32_t palette_mode_enable : 1;
/** \brief Reserved bytes for future use, must be zero. */
uint32_t reserved : 18;
} bits;
uint32_t value;
} picture_flags;
/** \brief Block size for each Segment ID in Segment Map.
* 0: 16x16 block size, default value;
* 1: 32x32 block size;
* 2: 64x64 block size;
* 3: 8x8 block size.
*/
uint8_t seg_id_block_size;
/** \brief Number of tile groups minus 1.
* value range [0..255].
*/
uint8_t num_tile_groups_minus1;
/** \brief Temporal id of the frame.*/
uint8_t temporal_id;
/** \brief Deblock filter parameters.
* value range [0..63].
*/
uint8_t filter_level[2];
uint8_t filter_level_u;
uint8_t filter_level_v;
union {
struct {
/** \brief Sharpness level for deblock filter.
* value range [0..7].
*/
uint8_t sharpness_level : 3;
uint8_t mode_ref_delta_enabled : 1;
uint8_t mode_ref_delta_update : 1;
/** \brief Reserved bytes for future use, must be zero. */
uint8_t reserved : 3;
} bits;
uint8_t value;
} loop_filter_flags;
/** \brief Super resolution scale denominator.
* value range [9..16].
*/
uint8_t superres_scale_denominator;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint8_t interpolation_filter;
/** \brief Loop filter ref deltas.
* value range [-63..63].
*/
int8_t ref_deltas[8];
/** \brief Loop filter mode deltas.
* value range [-63..63].
*/
int8_t mode_deltas[2];
/** \brief Quantization params. */
uint8_t base_qindex;
int8_t y_dc_delta_q;
int8_t u_dc_delta_q;
int8_t u_ac_delta_q;
int8_t v_dc_delta_q;
int8_t v_ac_delta_q;
/** \brief Min value for base q index for BRC.
* value range [1..255].
*/
uint8_t min_base_qindex;
/** \brief Max value for base q index for BRC.
* value range [1..255].
*/
uint8_t max_base_qindex;
/** \brief Quantization matrix. */
union {
struct {
/** \brief Corresponds to AV1 syntax element of the same name. */
uint16_t using_qmatrix : 1;
/** \brief Following parameters only valid when using_qmatrix == 1. */
uint16_t qm_y : 4;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint16_t qm_u : 4;
/** \brief Corresponds to AV1 syntax element of the same name. */
uint16_t qm_v : 4;
/** \brief Reserved bytes for future use, must be zero. */
uint16_t reserved : 3;
} bits;
uint16_t value;
} qmatrix_flags;
uint16_t reserved16bits1;
union {
struct {
/** \brief Specify whether quantizer index delta values are present.
* value range [0..1]. */
uint32_t delta_q_present : 1;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..3]. */
uint32_t delta_q_res : 2;
/** \brief Specify whether loop filter delta values are present.
* value range [0..1]. */
uint32_t delta_lf_present : 1;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..3]. */
uint32_t delta_lf_res : 2;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..1]. */
uint32_t delta_lf_multi : 1;
/** \brief Corresponds to AV1 syntax element of the same name.
* 0: ONLY_4X4;
* 1: TX_MODE_LARGEST;
* 2: TX_MODE_SELECT;
* 3: Invalid.
*/
uint32_t tx_mode : 2;
/** \brief Indicates whether to use single or compound reference prediction.
* 0: SINGLE_REFERENCE;
* 1: COMPOUND_REFERENCE;
* 2: REFERENCE_MODE_SELECT.
* 3: Invalid.
*
* Value 2 means driver make decision to use single reference or compound reference.
*/
uint32_t reference_mode : 2;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..1].
*/
uint32_t skip_mode_present : 1;
/** \brief Reserved bytes for future use, must be zero. */
uint32_t reserved : 20;
} bits;
uint32_t value;
} mode_control_flags;
/** \brief Segmentation parameters. */
VAEncSegParamAV1 segments;
/** \brief Number of tile columns. */
uint8_t tile_cols;
/** \brief Number of tile rows. */
uint8_t tile_rows;
uint16_t reserved16bits2;
/** \brief The last tile column or row size needs to be derived. */
uint16_t width_in_sbs_minus_1[63];
uint16_t height_in_sbs_minus_1[63];
/** \brief specify which tile to use for the CDF update.
* value range [0..127]*/
uint16_t context_update_tile_id;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..3].
*/
uint8_t cdef_damping_minus_3;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..3].
*/
uint8_t cdef_bits;
/** \brief CDEF Y strengths.
* value range [0..63]*/
uint8_t cdef_y_strengths[8];
/** \brief CDEF UV strengths.
* value range [0..63]*/
uint8_t cdef_uv_strengths[8];
union {
struct {
/** \brief Restoration type for Y frame.
* value range [0..3].
*/
uint16_t yframe_restoration_type : 2;
/** \brief Restoration type for Cb frame.
* value range [0..3].
*/
uint16_t cbframe_restoration_type : 2;
/** \brief Restoration type for Cr frame.
* value range [0..3].
*/
uint16_t crframe_restoration_type : 2;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..2].
*/
uint16_t lr_unit_shift : 2;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..1].
*/
uint16_t lr_uv_shift : 1;
/** \brief Reserved bytes for future use, must be zero. */
uint16_t reserved : 7;
} bits;
uint16_t value;
} loop_restoration_flags;
/** \brief Global motion. */
VAEncWarpedMotionParamsAV1 wm[7];
/**
* Offset in bits for syntax base_q_idx in packed frame header bit stream
* from the start of the packed header data.
* In BRC mode, this parameter should be set and driver will update base_q_idx in
* uncompressed header according to this offset.
* In CQP mode, this parameter should be set to 0 and ignored by driver.
*/
uint32_t bit_offset_qindex;
/**
* Offset in bits for syntax segmentation_enabled of frame header OBU
* in packed frame header bit stream from the start of the packed header data.
* Valid only in auto segmentation mode. Other than that, this parameter
* should be set to 0 and ignored by driver.
*/
uint32_t bit_offset_segmentation;
/**
* Offset in bits for syntax loop_filter_params() in packed frame
* header bit stream from the start of the packed header data.
* In BRC mode, this parameter should be set and driver will update filter params
* in packed frame header according to this offset.
* In CQP mode, this parameter should be set to 0 and ignored by driver.
*/
uint32_t bit_offset_loopfilter_params;
/**
* In BRC mode, underline encoder should generate the approperiate
* CDEF values and write back into uncompressed header. And app
* should provide default CDEF values in packed header. This parameter
* should point to the starting bit of cdef_params() syntax structure
* in packed header.
* In CQP mode, this parameter should be set to 0 and ignored by driver.
*/
uint32_t bit_offset_cdef_params;
/**
* In BRC mode, this parameter indicates the actual bit usage of
* cdef_params() syntax structure in packed uncompressed header.
* In CQP mode, this parameter should be set to 0 and ignored by driver.
*/
uint32_t size_in_bits_cdef_params;
/**
* Offset in bytes for syntax obu_size of frame header OBU in packed
* frame header bit stream from the start of the packed header. The frame
* header OBU size depends on the encoded tile sizes. It applies to both
* Frame Header OBU and Frame OBU if obu_size needs to be updated by
* underline encoder. Otherwise, app can set it to 0 and ignored by driver.
*
* In BRC mode, obu_size needs to be updated and this parameter should be set.
* In CQP mode, this parameter should be set to 0 and ignored by driver.
*/
uint32_t byte_offset_frame_hdr_obu_size;
/**
* Frame header OBU bit stream size in bits. The frame header obu packed bit
* stream contains an obu header, a 4-byte long obu_size field, frame_header_obu()
* syntax chain, and a trailing bit if not inside a frame obu. If \c enable_frame_obu == 1,
* the value should include and up to the last bit of frame_header_obu() and
* excluding the bits generated by byte_alignment(). If \c enable_frame_obu == 0,
* the value should include and up to the trailing bit at the end of the frame
* header obu. The size will be used by encoder to calculate the final frame
* header size after bit shifting due to auto segmentation.
* In CQP mode, this parameter should be set to 0 and ignored by driver.
*/
uint32_t size_in_bits_frame_hdr_obu;
/** \brief Tile Group OBU header */
union {
struct {
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..1].
*/
uint8_t obu_extension_flag : 1;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..1].
*/
uint8_t obu_has_size_field : 1;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..7].
*/
uint8_t temporal_id : 3;
/** \brief Corresponds to AV1 syntax element of the same name.
* value range [0..2].
*/
uint8_t spatial_id : 2;
/** \brief Reserved bytes for future use, must be zero. */
uint8_t reserved : 1;
} bits;
uint8_t value;
} tile_group_obu_hdr_info;
/** \brief The number of frames skipped prior to the current frame.
* It includes only the skipped frames that were not counted before.
* App may generate the "show_existing_frame" short frame header OBUs
* and send to driver with the next frame. Default value 0.
*/
uint8_t number_skip_frames;
uint16_t reserved16bits3;
/** \brief Indicates the application forced frame size change in bytes.
* When the value is positive, the frame size is reduced. Otherwise, the frame
* size increases. The parameter can be used when application skips frames with
* setting of NumSkipFrames. And application can also use it for other scenarios
* such as inserting "show_existing_frame" at very end of the sequence.
*/
int32_t skip_frames_reduced_size;
/** \brief Reserved bytes for future use, must be zero. */
uint32_t va_reserved[VA_PADDING_HIGH];
} VAEncPictureParameterBufferAV1;
/**
* \brief Tile Group Buffer.
*/
typedef struct _VAEncTileGroupBufferAV1 {
/** \brief Tile group start location.
* The position of the first tile in current tile group
* in raster scan order across the frame.
* value range [0..127].
*/
uint8_t tg_start;
/** \brief Tile group end location.
* The position of the last tile in current tile group
* in raster scan order across the frame.
* value range [0..127].
*/
uint8_t tg_end;
/** \brief Reserved bytes for future use, must be zero. */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncTileGroupBufferAV1;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_ENC_AV1_H */

View File

@@ -0,0 +1,659 @@
/*
* Copyright (c) 2007-2011 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_enc_h264.h
* \brief The H.264 encoding API
*
* This file contains the \ref api_enc_h264 "H.264 encoding API".
*/
#ifndef VA_ENC_H264_H
#define VA_ENC_H264_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_enc_h264 H.264 encoding API
*
* @{
*/
/**
* @name Picture flags
*
* Those flags flags are meant to signal when a picture marks the end
* of a sequence, a stream, or even both at once.
*
* @{
*/
/**
* \brief Marks the last picture in the sequence.
*
* i.e. the driver appends \c end_of_seq() NAL unit to the encoded frame.
*/
#define H264_LAST_PICTURE_EOSEQ 0x01
/**
* \brief Marks the last picture in the stream.
*
* i.e. the driver appends \c end_of_stream() NAL unit to the encoded frame.
*/
#define H264_LAST_PICTURE_EOSTREAM 0x02
/**@}*/
/**
* \brief Packed header types specific to H.264 encoding.
*
* Types of packed headers generally used for H.264 encoding. Each
* associated packed header data buffer shall contain the start code
* prefix 0x000001 followed by the complete NAL unit, thus also
* including the \c nal_unit_type.
*
* Note: the start code prefix can contain an arbitrary number of leading
* zeros. The driver will skip them for emulation prevention bytes insertion,
* if necessary.
*/
typedef enum {
/**
* \brief Packed Sequence Parameter Set (SPS).
*
* The corresponding packed header data buffer shall contain the
* complete seq_parameter_set_rbsp() syntax element.
*
* Note: packed \c nal_unit_type shall be equal to 7.
*/
VAEncPackedHeaderH264_SPS = VAEncPackedHeaderSequence,
/**
* \brief Packed Picture Parameter Set (PPS).
*
* The corresponding packed header data buffer shall contain the
* complete pic_parameter_set_rbsp() syntax element.
*
* Note: packed \c nal_unit_type shall be equal to 8.
*/
VAEncPackedHeaderH264_PPS = VAEncPackedHeaderPicture,
/**
* \brief Packed slice header.
*
* The corresponding packed header data buffer shall contain the
* \c slice_header() syntax element only, along with any start
* code prefix and NAL unit type preceeding it. i.e. this means
* that the buffer does not contain any of the \c slice_data() or
* the \c rbsp_slice_trailing_bits().
*
* Note: packed \c nal_unit_type shall be equal to 1 (non-IDR
* picture), or 5 (IDR picture).
*/
VAEncPackedHeaderH264_Slice = VAEncPackedHeaderSlice,
/**
* \brief Packed Supplemental Enhancement Information (SEI).
*
* The corresponding packed header data buffer shall contain the
* complete sei_rbsp() syntax element, thus including several
* sei_message() elements if necessary.
*
* Note: packed \c nal_unit_type shall be equal to 6.
*
* @deprecated
* This is a deprecated packed header flag, All applications can use
* \c VA_ENC_PACKED_HEADER_RAW_DATA to pass the corresponding packed
* SEI header data buffer to the driver
*/
VAEncPackedHeaderH264_SEI va_deprecated_enum = (0x80000000 | 1),
} VAEncPackedHeaderTypeH264;
/**
* \brief Sequence parameter for H.264 encoding in baseline, main & high
* profiles.
*
* This structure holds information for \c seq_parameter_set_data() as
* defined by the H.264 specification.
*
* If packed sequence headers mode is used, i.e. if the encoding
* pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE
* flag, then the driver expects two more buffers to be provided to
* the same \c vaRenderPicture() as this buffer:
* - a #VAEncPackedHeaderParameterBuffer with type set to
* VAEncPackedHeaderType::VAEncPackedHeaderSequence ;
* - a #VAEncPackedHeaderDataBuffer which holds the actual packed
* header data.
*
* If \c seq_scaling_matrix_present_flag is set to \c 1, then a
* #VAIQMatrixBufferH264 buffer shall also be provided within the same
* \c vaRenderPicture() call as this sequence parameter buffer.
*/
typedef struct _VAEncSequenceParameterBufferH264 {
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t seq_parameter_set_id;
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t level_idc;
/** \brief Period between I frames. */
uint32_t intra_period;
/** \brief Period between IDR frames. */
uint32_t intra_idr_period;
/** \brief Period between I/P frames. */
uint32_t ip_period;
/**
* \brief Initial bitrate set for this sequence in CBR or VBR modes.
*
* This field represents the initial bitrate value for this
* sequence if CBR or VBR mode is used, i.e. if the encoder
* pipeline was created with a #VAConfigAttribRateControl
* attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
*
* The bitrate can be modified later on through
* #VAEncMiscParameterRateControl buffers.
*/
uint32_t bits_per_second;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t max_num_ref_frames;
/** \brief Picture width in macroblocks. */
uint16_t picture_width_in_mbs;
/** \brief Picture height in macroblocks. */
uint16_t picture_height_in_mbs;
union {
struct {
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t chroma_format_idc : 2;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t frame_mbs_only_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t mb_adaptive_frame_field_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t seq_scaling_matrix_present_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t direct_8x8_inference_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t log2_max_frame_num_minus4 : 4;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t pic_order_cnt_type : 2;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t log2_max_pic_order_cnt_lsb_minus4 : 4;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t delta_pic_order_always_zero_flag : 1;
} bits;
uint32_t value;
} seq_fields;
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t bit_depth_luma_minus8;
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t bit_depth_chroma_minus8;
/** if pic_order_cnt_type == 1 */
/**@{*/
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t num_ref_frames_in_pic_order_cnt_cycle;
/** \brief Same as the H.264 bitstream syntax element. */
int32_t offset_for_non_ref_pic;
/** \brief Same as the H.264 bitstream syntax element. */
int32_t offset_for_top_to_bottom_field;
/** \brief Same as the H.264 bitstream syntax element. */
int32_t offset_for_ref_frame[256];
/**@}*/
/** @name Cropping (optional) */
/**@{*/
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t frame_cropping_flag;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t frame_crop_left_offset;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t frame_crop_right_offset;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t frame_crop_top_offset;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t frame_crop_bottom_offset;
/**@}*/
/** @name VUI parameters (optional) */
/**@{*/
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t vui_parameters_present_flag;
union {
struct {
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t aspect_ratio_info_present_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t timing_info_present_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t bitstream_restriction_flag : 1;
/** \brief Range: 0 to 16, inclusive. */
uint32_t log2_max_mv_length_horizontal : 5;
/** \brief Range: 0 to 16, inclusive. */
uint32_t log2_max_mv_length_vertical : 5;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t fixed_frame_rate_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t low_delay_hrd_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t motion_vectors_over_pic_boundaries_flag: 1;
/** \brief Reserved for future use, must be zero */
uint32_t reserved : 16;
} bits;
uint32_t value;
} vui_fields;
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t aspect_ratio_idc;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t sar_width;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t sar_height;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t num_units_in_tick;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t time_scale;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
/**@}*/
} VAEncSequenceParameterBufferH264;
/**
* \brief Picture parameter for H.264 encoding in baseline, main & high
* profiles.
*
* This structure holds information for \c pic_parameter_set_rbsp() as
* defined by the H.264 specification.
*
* If packed picture headers mode is used, i.e. if the encoding
* pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
* flag, then the driver expects two more buffers to be provided to
* the same \c vaRenderPicture() as this buffer:
* - a #VAEncPackedHeaderParameterBuffer with type set to
* VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
* - a #VAEncPackedHeaderDataBuffer which holds the actual packed
* header data.
*
* If \c pic_scaling_matrix_present_flag is set to \c 1, then a
* #VAIQMatrixBufferH264 buffer shall also be provided within the same
* \c vaRenderPicture() call as this picture parameter buffer.
*/
typedef struct _VAEncPictureParameterBufferH264 {
/**
* \brief Information about the picture to be encoded.
*
* See #VAPictureH264 for further description of each field.
* Note that CurrPic.picture_id represents the reconstructed
* (decoded) picture. User provides a scratch VA surface ID here.
*/
VAPictureH264 CurrPic;
/**
* \brief Decoded Picture Buffer (DPB).
*
* This array represents the list of reconstructed (decoded)
* frames used as reference. It is important to keep track of
* reconstructed frames so that they can be used later on as
* reference for P or B-frames encoding.
*/
VAPictureH264 ReferenceFrames[16];
/**
* \brief Output encoded bitstream.
*
* \ref coded_buf has type #VAEncCodedBufferType. It should be
* large enough to hold the compressed NAL slice and possibly SPS
* and PPS NAL units.
*/
VABufferID coded_buf;
/** \brief The picture parameter set referred to in the slice header. */
uint8_t pic_parameter_set_id;
/** \brief The active sequence parameter set. Range: 0 to 31, inclusive. */
uint8_t seq_parameter_set_id;
/**
* \brief OR'd flags describing whether the picture is the last one or not.
*
* This fields holds 0 if the picture to be encoded is not the last
* one in the stream or sequence. Otherwise, it is a combination of
* \ref H264_LAST_PICTURE_EOSEQ or \ref H264_LAST_PICTURE_EOSTREAM.
*/
uint8_t last_picture;
/** \brief The picture identifier.
* Range: 0 to \f$2^{log2\_max\_frame\_num\_minus4 + 4} - 1\f$, inclusive.
*/
uint16_t frame_num;
/** \brief \c pic_init_qp_minus26 + 26. */
uint8_t pic_init_qp;
/** \brief Maximum reference index for reference picture list 0.
* Range: 0 to 31, inclusive.
*/
uint8_t num_ref_idx_l0_active_minus1;
/** \brief Maximum reference index for reference picture list 1.
* Range: 0 to 31, inclusive.
*/
uint8_t num_ref_idx_l1_active_minus1;
/** \brief Range: -12 to 12, inclusive. */
int8_t chroma_qp_index_offset;
/** \brief Range: -12 to 12, inclusive. */
int8_t second_chroma_qp_index_offset;
union {
struct {
/** \brief Is picture an IDR picture? */
uint32_t idr_pic_flag : 1;
/** \brief Is picture a reference picture? */
uint32_t reference_pic_flag : 2;
/** \brief Selects CAVLC (0) or CABAC (1) entropy coding mode. */
uint32_t entropy_coding_mode_flag : 1;
/** \brief Is weighted prediction applied to P slices? */
uint32_t weighted_pred_flag : 1;
/** \brief Range: 0 to 2, inclusive. */
uint32_t weighted_bipred_idc : 2;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t constrained_intra_pred_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t transform_8x8_mode_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t deblocking_filter_control_present_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t redundant_pic_cnt_present_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t pic_order_present_flag : 1;
/** \brief Same as the H.264 bitstream syntax element. */
uint32_t pic_scaling_matrix_present_flag : 1;
} bits;
uint32_t value;
} pic_fields;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncPictureParameterBufferH264;
typedef struct _VAEncQPBufferH264 {
/*
* \brief This structure holds QP per 16x16 macroblock. Buffer size shall be
* sufficient to fit the slice or frame to be encoded depending on if it is a
* slice level or frame level encoding.
*/
uint8_t qp;
} VAEncQPBufferH264;
/**
* \brief Slice parameter for H.264 encoding in baseline, main & high profiles.
*
* This structure holds information for \c
* slice_layer_without_partitioning_rbsp() as defined by the H.264
* specification.
*
* If packed slice headers mode is used, i.e. if the encoding
* pipeline was configured with the #VA_ENC_PACKED_HEADER_SLICE
* flag, then the driver expects two more buffers to be provided to
* the same \c vaRenderPicture() as this buffer:
* - a #VAEncPackedHeaderParameterBuffer with type set to
* VAEncPackedHeaderType::VAEncPackedHeaderSlice ;
* - a #VAEncPackedHeaderDataBuffer which holds the actual packed
* header data.
*
* If per-macroblock encoder configuration is needed, \c macroblock_info
* references a buffer of type #VAEncMacroblockParameterBufferH264. This
* buffer is not passed to vaRenderPicture() and it can be re-used
* without re-allocating the whole buffer.
*/
typedef struct _VAEncSliceParameterBufferH264 {
/** \brief Starting MB address for this slice. */
uint32_t macroblock_address;
/** \brief Number of macroblocks in this slice. */
uint32_t num_macroblocks;
/**
* \brief Per-MB encoder configuration buffer, or \c VA_INVALID_ID.
*
* If per-MB encoder configuration is needed, then \ref macroblock_info
* references a buffer of type #VAEncMacroblockParameterBufferH264
* (\c VAEncMacroblockParameterBufferType). Otherwise, buffer id
* is set to \c VA_INVALID_ID and per-MB configuration is derived
* from this slice parameter.
*
* The \c macroblock_info buffer must hold \ref num_macroblocks
* elements.
*/
VABufferID macroblock_info;
/** \brief Slice type.
* Range: 0..2, 5..7, i.e. no switching slices.
*/
uint8_t slice_type;
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t pic_parameter_set_id;
/** \brief Same as the H.264 bitstream syntax element. */
uint16_t idr_pic_id;
/** @name If pic_order_cnt_type == 0 */
/**@{*/
/** \brief The picture order count modulo MaxPicOrderCntLsb. */
uint16_t pic_order_cnt_lsb;
/** \brief Valid if \c pic_order_present_flag and this is a bottom field. */
int32_t delta_pic_order_cnt_bottom;
/**@}*/
/** @name If pic_order_cnt_type == 1 && !delta_pic_order_always_zero_flag */
/**@{*/
/** \brief [0]: top, [1]: bottom. */
int32_t delta_pic_order_cnt[2];
/**@}*/
/** @name If slice_type == B */
/**@{*/
uint8_t direct_spatial_mv_pred_flag;
/**@}*/
/** @name If slice_type == P */
/**@{*/
/** \brief Specifies if
* \ref _VAEncPictureParameterBufferH264::num_ref_idx_l0_active_minus1 or
* \ref _VAEncPictureParameterBufferH264::num_ref_idx_l1_active_minus1 are
* overriden by the values for this slice.
*/
uint8_t num_ref_idx_active_override_flag;
/** \brief Maximum reference index for reference picture list 0.
* Range: 0 to 31, inclusive.
*/
uint8_t num_ref_idx_l0_active_minus1;
/** \brief Maximum reference index for reference picture list 1.
* Range: 0 to 31, inclusive.
*/
uint8_t num_ref_idx_l1_active_minus1;
/** \brief Reference picture list 0 (for P slices). */
VAPictureH264 RefPicList0[32];
/** \brief Reference picture list 1 (for B slices). */
VAPictureH264 RefPicList1[32];
/**@}*/
/** @name pred_weight_table() */
/**@{*/
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t luma_log2_weight_denom;
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t chroma_log2_weight_denom;
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t luma_weight_l0_flag;
/** \brief Same as the H.264 bitstream syntax element. */
signed short luma_weight_l0[32];
/** \brief Same as the H.264 bitstream syntax element. */
signed short luma_offset_l0[32];
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t chroma_weight_l0_flag;
/** \brief Same as the H.264 bitstream syntax element. */
signed short chroma_weight_l0[32][2];
/** \brief Same as the H.264 bitstream syntax element. */
signed short chroma_offset_l0[32][2];
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t luma_weight_l1_flag;
/** \brief Same as the H.264 bitstream syntax element. */
signed short luma_weight_l1[32];
/** \brief Same as the H.264 bitstream syntax element. */
signed short luma_offset_l1[32];
/** \brief Same as the H.264 bitstream syntax element. */
uint8_t chroma_weight_l1_flag;
/** \brief Same as the H.264 bitstream syntax element. */
signed short chroma_weight_l1[32][2];
/** \brief Same as the H.264 bitstream syntax element. */
signed short chroma_offset_l1[32][2];
/**@}*/
/** \brief Range: 0 to 2, inclusive. */
uint8_t cabac_init_idc;
/** \brief Same as the H.264 bitstream syntax element. */
int8_t slice_qp_delta;
/** @name If deblocking_filter_control_present_flag */
/**@{*/
/** \brief Range: 0 to 2, inclusive. */
uint8_t disable_deblocking_filter_idc;
/** \brief Same as the H.264 bitstream syntax element. */
int8_t slice_alpha_c0_offset_div2;
/** \brief Same as the H.264 bitstream syntax element. */
int8_t slice_beta_offset_div2;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
/**@}*/
} VAEncSliceParameterBufferH264;
/**
* @name Macroblock neighbour availability bits
*
* \anchor api_enc_h264_mb_pred_avail_bits
* Definitions for macroblock neighbour availability bits used in
* intra prediction mode (non MBAFF only).
*
* @{
*/
/** \brief References macroblock in the top-left corner. */
#define VA_MB_PRED_AVAIL_TOP_LEFT (1 << 2)
/** \brief References macroblock above the current macroblock. */
#define VA_MB_PRED_AVAIL_TOP (1 << 4)
/** \brief References macroblock in the top-right corner. */
#define VA_MB_PRED_AVAIL_TOP_RIGHT (1 << 3)
/** \brief References macroblock on the left of the current macroblock. */
#define VA_MB_PRED_AVAIL_LEFT (1 << 6)
/**@}*/
/**
* \brief Macroblock parameter for H.264 encoding in baseline, main & high
* profiles.
*
* This structure holds per-macroblock information. The buffer must be
* allocated with as many elements (macroblocks) as necessary to fit
* the slice to be encoded. Besides, the per-macroblock records must
* be written in a strict raster order and with no gap. i.e. every
* macroblock, regardless of its type, shall have an entry.
*/
typedef struct _VAEncMacroblockParameterBufferH264 {
/**
* \brief Quantization parameter.
*
* Requested quantization parameter. Range: 0 to 51, inclusive.
* If \ref qp is set to 0xff, then the actual value is derived
* from the slice-level value: \c pic_init_qp + \c slice_qp_delta.
*/
uint8_t qp;
union {
/** @name Data for intra macroblock */
/**@{*/
union {
struct {
/**
* \brief Flag specified to override MB neighbour
* availability bits from VME stage.
*
* This flag specifies that macroblock neighbour
* availability bits from the VME stage are overriden
* by the \ref pred_avail_flags hereunder.
*/
uint32_t pred_avail_override_flag : 1;
/**
* \brief Bitwise representation of which macroblocks
* are available for intra prediction.
*
* If the slice is intra-coded, this field represents
* the macroblocks available for intra prediction.
* See \ref api_enc_h264_mb_pred_avail_bits
* "macroblock neighbour availability" bit definitions.
*/
uint32_t pred_avail_flags : 8;
} bits;
uint32_t value;
} intra_fields;
/**@}*/
/** @name Data for inter macroblock */
/**@{*/
union {
struct {
uint32_t reserved;
} bits;
uint32_t value;
} inter_fields;
/**@}*/
} info;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncMacroblockParameterBufferH264;
/**
* \brief MB partition modes and 1/2 1/4 motion search configuration
*
* Specifies MB partition modes that are disabled. Specifies Half-pel
* mode and Quarter-pel mode searching
*/
typedef struct _VAEncMiscParameterSubMbPartPelH264 {
uint32_t disable_inter_sub_mb_partition;
union {
struct {
uint32_t disable_16x16_inter_mb_partition : 1;
uint32_t disable_16x8_inter_mb_partition : 1;
uint32_t disable_8x16_inter_mb_partition : 1;
uint32_t disable_8x8_inter_mb_partition : 1;
uint32_t disable_8x4_inter_mb_partition : 1;
uint32_t disable_4x8_inter_mb_partition : 1;
uint32_t disable_4x4_inter_mb_partition : 1;
uint32_t reserved : 1;
} bits;
uint8_t value;
} inter_sub_mb_partition_mask;
/**
* \brief Precison of motion search
* 0:Integer mode searching
* 1:Half-pel mode searching
* 2:Reserved
* 3:Quarter-pel mode searching
*/
uint32_t enable_sub_pel_mode;
uint8_t sub_pel_mode;
uint8_t reserved[3];
} VAEncMiscParameterSubMbPartPelH264;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_ENC_H264_H */

View File

@@ -0,0 +1,958 @@
/*
* Copyright (c) 2007-2014 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_enc_hevc.h
* \brief The HEVC encoding API
*
* This file contains the \ref api_enc_hevc "HEVC encoding API".
*
*/
#ifndef VA_ENC_HEVC_H
#define VA_ENC_HEVC_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/**
* \defgroup api_enc_hevc HEVC encoding API
*
* @{
*/
/** Attribute value for VAConfigAttribEncHEVCFeatures.
*
* This attribute decribes the supported features of an HEVC/H.265
* encoder configuration.
*
* All of the field values in this attribute are VA_FEATURE_* values,
* indicating support for the corresponding feature.
*/
typedef union VAConfigAttribValEncHEVCFeatures {
struct {
/** Separate colour planes.
*
* Allows setting separate_colour_plane_flag in the SPS.
*/
uint32_t separate_colour_planes : 2;
/** Scaling lists.
*
* Allows scaling_list() elements to be present in both the SPS
* and the PPS. The decoded form of the scaling lists must also
* be supplied in a VAQMatrixBufferHEVC buffer when scaling lists
* are enabled.
*/
uint32_t scaling_lists : 2;
/** Asymmetric motion partitions.
*
* Allows setting amp_enabled_flag in the SPS.
*/
uint32_t amp : 2;
/** Sample adaptive offset filter.
*
* Allows setting slice_sao_luma_flag and slice_sao_chroma_flag
* in slice headers.
*/
uint32_t sao : 2;
/** PCM sample blocks.
*
* Allows setting pcm_enabled_flag in the SPS. When enabled
* PCM parameters must be supplied with the sequence parameters,
* including block sizes which may be further constrained as
* noted in the VAConfigAttribEncHEVCBlockSizes attribute.
*/
uint32_t pcm : 2;
/** Temporal motion vector Prediction.
*
* Allows setting slice_temporal_mvp_enabled_flag in slice
* headers.
*/
uint32_t temporal_mvp : 2;
/** Strong intra smoothing.
*
* Allows setting strong_intra_smoothing_enabled_flag in the SPS.
*/
uint32_t strong_intra_smoothing : 2;
/** Dependent slices.
*
* Allows setting dependent_slice_segment_flag in slice headers.
*/
uint32_t dependent_slices : 2;
/** Sign data hiding.
*
* Allows setting sign_data_hiding_enable_flag in the PPS.
*/
uint32_t sign_data_hiding : 2;
/** Constrained intra prediction.
*
* Allows setting constrained_intra_pred_flag in the PPS.
*/
uint32_t constrained_intra_pred : 2;
/** Transform skipping.
*
* Allows setting transform_skip_enabled_flag in the PPS.
*/
uint32_t transform_skip : 2;
/** QP delta within coding units.
*
* Allows setting cu_qp_delta_enabled_flag in the PPS.
*/
uint32_t cu_qp_delta : 2;
/** Weighted prediction.
*
* Allows setting weighted_pred_flag and weighted_bipred_flag in
* the PPS. The pred_weight_table() data must be supplied with
* every slice header when weighted prediction is enabled.
*/
uint32_t weighted_prediction : 2;
/** Transform and quantisation bypass.
*
* Allows setting transquant_bypass_enabled_flag in the PPS.
*/
uint32_t transquant_bypass : 2;
/** Deblocking filter disable.
*
* Allows setting slice_deblocking_filter_disabled_flag.
*/
uint32_t deblocking_filter_disable : 2;
/* Reserved,should not be used, avoid conflict with VA_ATTRIB_NOT_SUPPORTED. */
uint32_t reserved : 2;
} bits;
uint32_t value;
} VAConfigAttribValEncHEVCFeatures;
/** Attribute value for VAConfigAttribEncHEVCBlockSizes.
*
* This attribute describes the supported coding tree and transform block
* sizes of an HEVC/H.265 encoder configuration
*/
typedef union VAConfigAttribValEncHEVCBlockSizes {
struct {
/** Largest supported size of coding tree blocks.
*
* CtbLog2SizeY must not be larger than this.
*/
uint32_t log2_max_coding_tree_block_size_minus3 : 2;
/** Smallest supported size of coding tree blocks.
*
* CtbLog2SizeY must not be smaller than this.
*
* This may be the same as the maximum size, indicating that only
* one CTB size is supported.
*/
uint32_t log2_min_coding_tree_block_size_minus3 : 2;
/** Smallest supported size of luma coding blocks.
*
* MinCbLog2SizeY must not be smaller than this.
*/
uint32_t log2_min_luma_coding_block_size_minus3 : 2;
/** Largest supported size of luma transform blocks.
*
* MaxTbLog2SizeY must not be larger than this.
*/
uint32_t log2_max_luma_transform_block_size_minus2 : 2;
/** Smallest supported size of luma transform blocks.
*
* MinTbLog2SizeY must not be smaller than this.
*/
uint32_t log2_min_luma_transform_block_size_minus2 : 2;
/** Largest supported transform hierarchy depth in inter
* coding units.
*
* max_transform_hierarchy_depth_inter must not be larger
* than this.
*/
uint32_t max_max_transform_hierarchy_depth_inter : 2;
/** Smallest supported transform hierarchy depth in inter
* coding units.
*
* max_transform_hierarchy_depth_inter must not be smaller
* than this.
*/
uint32_t min_max_transform_hierarchy_depth_inter : 2;
/** Largest supported transform hierarchy depth in intra
* coding units.
*
* max_transform_hierarchy_depth_intra must not be larger
* than this.
*/
uint32_t max_max_transform_hierarchy_depth_intra : 2;
/** Smallest supported transform hierarchy depth in intra
* coding units.
*
* max_transform_hierarchy_depth_intra must not be smaller
* than this.
*/
uint32_t min_max_transform_hierarchy_depth_intra : 2;
/** Largest supported size of PCM coding blocks.
*
* Log2MaxIpcmCbSizeY must not be larger than this.
*/
uint32_t log2_max_pcm_coding_block_size_minus3 : 2;
/** Smallest supported size of PCM coding blocks.
*
* Log2MinIpcmCbSizeY must not be smaller than this.
*/
uint32_t log2_min_pcm_coding_block_size_minus3 : 2;
/** Reserved for future use. */
uint32_t reserved : 10;
} bits;
uint32_t value;
} VAConfigAttribValEncHEVCBlockSizes;
/**
* @name Picture flags
*
* Those flags flags are meant to signal when a picture marks the end
* of a sequence, a stream, or even both at once.
*
* @{
*/
/**
* \brief Marks the last picture in the sequence.
*
* i.e. the driver appends \c end_of_seq() NAL unit to the encoded frame.
*/
#define HEVC_LAST_PICTURE_EOSEQ 0x01
/**
* \brief Marks the last picture in the stream.
*
* i.e. the driver appends \c end_of_stream() NAL unit to the encoded frame.
*/
#define HEVC_LAST_PICTURE_EOSTREAM 0x02
/**@}*/
/**
* \brief Packed header types specific to HEVC encoding.
*
* Types of packed headers generally used for HEVC encoding. Each
* associated packed header data buffer shall contain the start code
* prefix 0x000001 followed by the complete NAL unit, thus also
* including the \c nal_unit_type.
*
* Note: the start code prefix can contain an arbitrary number of leading
* zeros. The driver will skip them for emulation prevention bytes insertion,
* if necessary.
*/
typedef enum {
/**
* \brief Packed Video Parameter Set (VPS).
*
* The corresponding packed header data buffer shall contain the
* complete video_parameter_set_rbsp() syntax element.
*
* Note: packed \c nal_unit_type shall be equal to 32.
*/
VAEncPackedHeaderHEVC_VPS = VAEncPackedHeaderSequence,
/**
* \brief Packed Sequence Parameter Set (SPS).
*
* The corresponding packed header data buffer shall contain the
* complete seq_parameter_set_rbsp() syntax element.
*
* Note: packed \c nal_unit_type shall be equal to 33.
*/
VAEncPackedHeaderHEVC_SPS = VAEncPackedHeaderSequence,
/**
* \brief Packed Picture Parameter Set (PPS).
*
* The corresponding packed header data buffer shall contain the
* complete pic_parameter_set_rbsp() syntax element.
*
* Note: packed \c nal_unit_type shall be equal to 34.
*/
VAEncPackedHeaderHEVC_PPS = VAEncPackedHeaderPicture,
/**
* \brief Packed slice header.
*
* The corresponding packed header data buffer shall contain the
* \c slice_header() syntax element only, along with any start
* code prefix and NAL unit type preceeding it. i.e. this means
* that the buffer does not contain any of the \c slice_data() or
* the \c rbsp_slice_trailing_bits().
*
* Note: packed \c nal_unit_type shall be equal to 0 to 9 (non-IRAP
* picture), or 16 to 21 (IRAP picture).
*/
VAEncPackedHeaderHEVC_Slice = VAEncPackedHeaderSlice,
/**
* \brief Packed Supplemental Enhancement Information (SEI).
*
* The corresponding packed header data buffer shall contain the
* complete sei_rbsp() syntax element, thus including several
* sei_message() elements if necessary.
*
* Note: packed \c nal_unit_type shall be equal to 39 or 40.
*
* @deprecated
* This is a deprecated packed header flag, All applications can use
* \c VA_ENC_PACKED_HEADER_RAW_DATA to pass the corresponding packed
* SEI header data buffer to the driver
*/
VAEncPackedHeaderHEVC_SEI va_deprecated_enum = (0x80000000 | 1),
} VAEncPackedHeaderTypeHEVC;
/**
* \brief Sequence parameter for HEVC encoding in main & main 10
* profiles.
*
* This structure holds information for \c seq_parameter_set_data() as
* defined by the HEVC specification.
*
* If packed sequence headers mode is used, i.e. if the encoding
* pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE
* flag, then the driver expects two more buffers to be provided to
* the same \c vaRenderPicture() as this buffer:
* - a #VAEncPackedHeaderParameterBuffer with type set to
* VAEncPackedHeaderType::VAEncPackedHeaderSequence ;
* - a #VAEncPackedHeaderDataBuffer which holds the actual packed
* header data.
*
* If \c seq_scaling_matrix_present_flag is set to \c 1, then a
* #VAQMatrixBufferHEVC buffer shall also be provided within the same
* \c vaRenderPicture() call as this sequence parameter buffer.
*/
typedef struct _VAEncSequenceParameterBufferHEVC {
/** \brief Same as the HEVC bitstream syntax element.
* value range [1..2].
*/
uint8_t general_profile_idc;
/** \brief Same as the HEVC bitstream syntax element.
* general_level_idc shall be set equal to a value of 30 times the level
* numbers allowed [1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2]
*/
uint8_t general_level_idc;
/** \brief Same as the HEVC bitstream syntax element.
* Only value 0 is allowed for level value below 4, exclusive.
*/
uint8_t general_tier_flag;
/** \brief Period between I frames. */
uint32_t intra_period;
/** \brief Period between IDR frames. */
uint32_t intra_idr_period;
/** \brief Period between I/P frames. */
uint32_t ip_period;
/**
* \brief Initial bitrate set for this sequence in CBR or VBR modes.
*
* This field represents the initial bitrate value for this
* sequence if CBR or VBR mode is used, i.e. if the encoder
* pipeline was created with a #VAConfigAttribRateControl
* attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
*
* The bitrate can be modified later on through
* #VAEncMiscParameterRateControl buffers.
*/
uint32_t bits_per_second;
/** \brief Picture width in pixel samples.
* Its value must be multiple of min CU size.
*/
uint16_t pic_width_in_luma_samples;
/** \brief Picture height in pixel samples.
* Its value must be multiple of min CU size.
*/
uint16_t pic_height_in_luma_samples;
union {
struct {
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t chroma_format_idc : 2;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t separate_colour_plane_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t bit_depth_luma_minus8 : 3;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t bit_depth_chroma_minus8 : 3;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t scaling_list_enabled_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t strong_intra_smoothing_enabled_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t amp_enabled_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t sample_adaptive_offset_enabled_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t pcm_enabled_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t pcm_loop_filter_disabled_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t sps_temporal_mvp_enabled_flag : 1;
/** \brief Indicates whether or not the encoding is in low delay mode.
* 0 normal sequence
* 1 no random access B will be coded . and the coding type could be only I, P or LDB
* this flag only indicates the frame coding type of the sequence.
*/
uint32_t low_delay_seq : 1;
/** \brief Indicates whether or not the encoding is in dyadic hierarchical GOP structure
* the default value 0, BRC would treat is as flat structure. if HierachicalFlag == 1,
* application would enable Qp Modulation
*/
uint32_t hierachical_flag : 1;
/** \brief keep for future , should be set to 0 */
uint32_t reserved_bits : 14;
} bits;
uint32_t value;
} seq_fields;
/** \brief Same as the HEVC bitstream syntax element.
* value range [0..3]
*/
uint8_t log2_min_luma_coding_block_size_minus3;
/** \brief Same as the HEVC bitstream syntax element.
*/
uint8_t log2_diff_max_min_luma_coding_block_size;
/** \brief Same as the HEVC bitstream syntax element.
* value range [0..3]
*/
uint8_t log2_min_transform_block_size_minus2;
/** \brief Same as the HEVC bitstream syntax element.
*/
uint8_t log2_diff_max_min_transform_block_size;
/** \brief Same as the HEVC bitstream syntax element.
* value range [2]
*/
uint8_t max_transform_hierarchy_depth_inter;
/** \brief Same as the HEVC bitstream syntax element.
* value range [2]
*/
uint8_t max_transform_hierarchy_depth_intra;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t pcm_sample_bit_depth_luma_minus1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t pcm_sample_bit_depth_chroma_minus1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t log2_min_pcm_luma_coding_block_size_minus3;
/** \brief Derived from the HEVC bitstream syntax element.
* log2_min_pcm_luma_coding_block_size_minus3 +
* log2_diff_max_min_pcm_luma_coding_block_size
*/
uint32_t log2_max_pcm_luma_coding_block_size_minus3;
/** @name VUI parameters (optional) */
/**@{*/
/** \brief Same as the HEVC bitstream syntax element. */
uint8_t vui_parameters_present_flag;
union {
struct {
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t aspect_ratio_info_present_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t neutral_chroma_indication_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t field_seq_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t vui_timing_info_present_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t bitstream_restriction_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t tiles_fixed_structure_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t motion_vectors_over_pic_boundaries_flag : 1;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t restricted_ref_pic_lists_flag : 1;
/** \brief Range: 0 to 16, inclusive. */
uint32_t log2_max_mv_length_horizontal : 5;
/** \brief Range: 0 to 16, inclusive. */
uint32_t log2_max_mv_length_vertical : 5;
} bits;
uint32_t value;
} vui_fields;
/** \brief Same as the HEVC bitstream syntax element. */
uint8_t aspect_ratio_idc;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t sar_width;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t sar_height;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t vui_num_units_in_tick;
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t vui_time_scale;
/** \brief Same as the HEVC bitstream syntax element. */
uint16_t min_spatial_segmentation_idc;
/** \brief Same as the HEVC bitstream syntax element. */
uint8_t max_bytes_per_pic_denom;
/** \brief Same as the HEVC bitstream syntax element. */
uint8_t max_bits_per_min_cu_denom;
/** \brief SCC flags to enable/disable features, including IBC and palette mode at present.*/
union {
struct {
/** \brief Same as the HEVC bitstream syntax element. */
uint32_t palette_mode_enabled_flag : 1;
/** \brief Reserved bits for future use, must be zero */
uint32_t reserved : 31;
} bits;
uint32_t value;
} scc_fields;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_MEDIUM - 1];
/**@}*/
} VAEncSequenceParameterBufferHEVC;
/****************************
* HEVC data structures
****************************/
/**
* \brief Picture parameter for HEVC encoding in main & main 10
* profiles.
*
* This structure holds information for \c pic_parameter_set_rbsp() as
* defined by the HEVC specification.
*
* If packed picture headers mode is used, i.e. if the encoding
* pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
* flag, then the driver expects two more buffers to be provided to
* the same \c vaRenderPicture() as this buffer:
* - a #VAEncPackedHeaderParameterBuffer with type set to
* VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
* - a #VAEncPackedHeaderDataBuffer which holds the actual packed
* header data.
*
* If \c pic_scaling_matrix_present_flag is set to \c 1, then a
* #VAQMatrixBufferHEVC buffer shall also be provided within the same
* \c vaRenderPicture() call as this picture parameter buffer.
*/
typedef struct _VAEncPictureParameterBufferHEVC {
/**
* \brief Information about the picture to be encoded.
*
* See #VAPictureHEVC for further description of each field.
* Note that decoded_curr_pic.picture_id represents the reconstructed
* (decoded) picture. User provides a scratch VA surface ID here.
* Long term reference and RPS related fields should be set to 0
* and ignored.
*/
VAPictureHEVC decoded_curr_pic;
/**
* \brief Decoded Picture Buffer (DPB).
*
* This array represents the list of reconstructed (decoded)
* frames used as reference. It is important to keep track of
* reconstructed frames so that they can be used later on as
* reference for P or B-frames encoding.
*/
VAPictureHEVC reference_frames[15];
/**
* \brief Output encoded bitstream.
*
* \ref coded_buf has type #VAEncCodedBufferType. It should be
* large enough to hold the compressed NAL slice and possibly VPS, SPS
* and PPS NAL units, and other NAL units such as SEI.
*/
VABufferID coded_buf;
/** \brief collocated reference picture buffer index of ReferenceFrames[].
* Please note it is different from HEVC syntac element collocated_ref_idx.
* When the HEVC syntax element slice_temporal_mvp_enable_flag takes value 0,
* collocated_ref_pic_index should take value 0xFF. .
* Range: [0..14, 0xFF]
*/
uint8_t collocated_ref_pic_index;
/**
* \brief OR'd flags describing whether the picture is the last one or not.
*
* This fields holds 0 if the picture to be encoded is not the last
* one in the stream or sequence. Otherwise, it is a combination of
* \ref HEVC_LAST_PICTURE_EOSEQ or \ref HEVC_LAST_PICTURE_EOSTREAM.
*/
uint8_t last_picture;
/** \brief \c init_qp_minus26 + 26. */
uint8_t pic_init_qp;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint8_t diff_cu_qp_delta_depth;
/** \brief Corresponds to HEVC syntax element of the same name. */
int8_t pps_cb_qp_offset;
/** \brief Corresponds to HEVC syntax element of the same name. */
int8_t pps_cr_qp_offset;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint8_t num_tile_columns_minus1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint8_t num_tile_rows_minus1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint8_t column_width_minus1[19];
/** \brief Corresponds to HEVC syntax element of the same name. */
uint8_t row_height_minus1[21];
/** \brief Corresponds to HEVC syntax element of the same name. */
uint8_t log2_parallel_merge_level_minus2;
/** \brief Application may set the CTU bit size limit based on
* spec requirement (A.3.2), or other value for special purpose.
* If the value is set 0, no bit size limit is checked.
*/
uint8_t ctu_max_bitsize_allowed;
/** \brief Maximum reference index for reference picture list 0.
* value range: [0..14].
*/
uint8_t num_ref_idx_l0_default_active_minus1;
/** \brief Maximum reference index for reference picture list 1.
* value range: [0..14].
*/
uint8_t num_ref_idx_l1_default_active_minus1;
/** \brief PPS header
* Used by GPU to generate new slice headers in slice size control.
* value range: [0..63].
*/
uint8_t slice_pic_parameter_set_id;
/** \brief NAL unit type
* Used by GPU to generate new slice headers in slice size control.
* value range: [0..63].
*/
uint8_t nal_unit_type;
union {
struct {
/** \brief Is picture an IDR picture? */
uint32_t idr_pic_flag : 1;
/** \brief Picture type.
* I - 1;
* P - 2;
* B - 3;
* B1 - 4;
* B2 - 5;
* B1 and B2 are frame types for hierachical B, explanation
* can refer to num_b_in_gop[].
*/
uint32_t coding_type : 3;
/** \brief Is picture a reference picture? */
uint32_t reference_pic_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t dependent_slice_segments_enabled_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t sign_data_hiding_enabled_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t constrained_intra_pred_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t transform_skip_enabled_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t cu_qp_delta_enabled_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t weighted_pred_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t weighted_bipred_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t transquant_bypass_enabled_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t tiles_enabled_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t entropy_coding_sync_enabled_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t loop_filter_across_tiles_enabled_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t pps_loop_filter_across_slices_enabled_flag : 1;
/** \brief A combination of HEVC syntax element of
* sps_scaling_list_data_present_flag and
* pps_scaling_list_data_present_flag
* when scaling_list_enable_flag is 0, it must be 0.
*/
uint32_t scaling_list_data_present_flag : 1;
/** \brief indicate the current picture contains significant
* screen contents (text, characters, etc.) or animated image.
* GPU may want to treat them differently from normal video.
* For example, encoder may choose a small transform unit size
* and may use transform skip mode.
*/
uint32_t screen_content_flag : 1;
/**
* When either weighted_pred_flag or weighted_bipred_flag is
* turned on, the flag enable_gpu_weighted_prediction requests
* GPU to determine weighted prediction factors. In this case,
* the following parameters in slice control data structure
* shall be ignored:
* luma_log2_weight_denom, delta_chroma_log2_weight_denom,
* luma_offset_l0[15], luma_offset_l1[15],
* delta_luma_weight_l0[15], delta_luma_weight_l1[15],
* chroma_offset_l0[15][2], chroma_offset_l1[15][2],
* and delta_chroma_weight_l0[15][2], delta_chroma_weight_l1[15][2].
*/
uint32_t enable_gpu_weighted_prediction : 1;
/** \brief HEVC syntax element in slice segment header
* GPU uses it to generate new slice headers in slice size control.
*/
uint32_t no_output_of_prior_pics_flag : 1;
uint32_t reserved : 11;
} bits;
uint32_t value;
} pic_fields;
/** \brief When hierachical_level_plus1 > 0, hierachical_level_plus1-1 indicates
*the current frame's level.when it > 0. B1, B2 setting in CodingType can be treated as B,
*hirachical level is determined by this variable.When hierachical_level_plus1 == 0,
*hierarchical level information still comes from coding_type.
*/
uint8_t hierarchical_level_plus1;
/** \brief Reserved bytes for future use, must be zero */
uint8_t va_byte_reserved;
/** \brief SCC flags to enable/disable feature, only IBC at present.*/
union {
struct {
/** \brief Same as the HEVC bitstream syntax element. */
uint16_t pps_curr_pic_ref_enabled_flag : 1;
/** \brief Reserved bits for future use, must be zero */
uint16_t reserved : 15;
} bits;
uint16_t value;
} scc_fields;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_HIGH - 1];
} VAEncPictureParameterBufferHEVC;
/**
* \brief Slice parameter for HEVC encoding in main & main 10 profiles.
*
* This structure holds information for \c
* slice_segment_layer_rbsp() as defined by the HEVC
* specification.
*
* If packed slice headers mode is used, i.e. if the encoding
* pipeline was configured with the #VA_ENC_PACKED_HEADER_SLICE
* flag, then the driver expects two more buffers to be provided to
* the same \c vaRenderPicture() as this buffer:
* - a #VAEncPackedHeaderParameterBuffer with type set to
* VAEncPackedHeaderType::VAEncPackedHeaderSlice ;
* - a #VAEncPackedHeaderDataBuffer which holds the actual packed
* header data.
*
*/
typedef struct _VAEncSliceParameterBufferHEVC {
/** \brief Starting CTU address for this slice. */
uint32_t slice_segment_address;
/** \brief Number of CTUs in this slice. */
uint32_t num_ctu_in_slice;
/** \brief Slice type.
* Corresponds to HEVC syntax element of the same name.
*/
uint8_t slice_type;
/** \brief Same as the HEVC bitstream syntax element. */
uint8_t slice_pic_parameter_set_id;
/** \brief Maximum reference index for reference picture list 0.
* Range: 0 to 14, inclusive.
*/
uint8_t num_ref_idx_l0_active_minus1;
/** \brief Maximum reference index for reference picture list 1.
* Range: 0 to 14, inclusive.
*/
uint8_t num_ref_idx_l1_active_minus1;
/** \brief Reference picture list 0 (for P slices). */
VAPictureHEVC ref_pic_list0[15];
/** \brief Reference picture list 1 (for B slices). */
VAPictureHEVC ref_pic_list1[15];
/**@}*/
/** @name pred_weight_table() */
/**@{*/
/** \brief Same as the HEVC bitstream syntax element. */
uint8_t luma_log2_weight_denom;
/** \brief Same as the HEVC bitstream syntax element. */
int8_t delta_chroma_log2_weight_denom;
/** \brief Same as the HEVC bitstream syntax element. */
int8_t delta_luma_weight_l0[15];
/** \brief Same as the HEVC bitstream syntax element. */
int8_t luma_offset_l0[15];
/** \brief Same as the HEVC bitstream syntax element. */
int8_t delta_chroma_weight_l0[15][2];
/** \brief Same as the HEVC spec variable ChromaOffsetL0[]. */
int8_t chroma_offset_l0[15][2];
/** \brief Same as the HEVC bitstream syntax element. */
int8_t delta_luma_weight_l1[15];
/** \brief Same as the HEVC bitstream syntax element. */
int8_t luma_offset_l1[15];
/** \brief Same as the HEVC bitstream syntax element. */
int8_t delta_chroma_weight_l1[15][2];
/** \brief Same as the HEVC spec variable ChromaOffsetL1[]. */
int8_t chroma_offset_l1[15][2];
/**@}*/
/** \brief Corresponds to HEVC spec variable MaxNumMergeCand.
* Range: [1..5].
*/
uint8_t max_num_merge_cand;
/** \brief Same as the HEVC bitstream syntax element. */
int8_t slice_qp_delta;
/** \brief Same as the HEVC bitstream syntax element. */
int8_t slice_cb_qp_offset;
/** \brief Same as the HEVC bitstream syntax element. */
int8_t slice_cr_qp_offset;
/** \brief Same as the HEVC bitstream syntax element. */
int8_t slice_beta_offset_div2;
/** \brief Same as the HEVC bitstream syntax element. */
int8_t slice_tc_offset_div2;
union {
struct {
/** \brief Indicates if current slice is the last one in picture */
uint32_t last_slice_of_pic_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name */
uint32_t dependent_slice_segment_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name */
uint32_t colour_plane_id : 2;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t slice_temporal_mvp_enabled_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t slice_sao_luma_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t slice_sao_chroma_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name.
* if this flag is set to 0, num_ref_idx_l0_active_minus1 should be
* equal to num_ref_idx_l0_default_active_minus1
* as well as for that for l1.
*/
uint32_t num_ref_idx_active_override_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t mvd_l1_zero_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t cabac_init_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t slice_deblocking_filter_disabled_flag : 2;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t slice_loop_filter_across_slices_enabled_flag : 1;
/** \brief Corresponds to HEVC syntax element of the same name. */
uint32_t collocated_from_l0_flag : 1;
} bits;
uint32_t value;
} slice_fields;
/**
* \brief bit offset of syntax element pred_weight_table() in slice segment header.
* It aligns with the starting position of the current packed slice header.
* It is used when encoder prefers to override the weighted prediction parameters passed in
* from application.
* Please refer to enable_gpu_weighted_prediction in VAEncPictureParameterBufferHEVC.
*/
uint32_t pred_weight_table_bit_offset;
/**
* \brief bit length of syntax element pred_weight_table() in slice segment header.
* It is used when encoder prefers to override the weighted prediction parameters passed in
* from application.
* Please refer to enable_gpu_weighted_prediction in VAEncPictureParameterBufferHEVC.
*/
uint32_t pred_weight_table_bit_length;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_MEDIUM - 2];
/**@}*/
} VAEncSliceParameterBufferHEVC;
/**
* \brief HEVC Quantization Matrix Buffer Structure
*
* This structure is sent once per frame,
* and only when scaling_list_enabled_flag = 1 and scaling_list_data_present_flag = 1.
* Only when scaling_list_data_present_flag = 1, app still
* needs to send in this structure. When scaling_list_enabled_flag = 1 and
* scaling_list_data_present_flag = 0, driver is responsible to generate
* the default scaling list values.
*
* Matrix entries are in raster scan order which follows HEVC spec.
*/
typedef struct _VAQMatrixBufferHEVC {
/**
* \brief scaling lists,
* corresponds to same HEVC spec syntax element
* ScalingList[ i ][ MatrixID ][ j ].
*
* \brief 4x4 scaling,
*/
uint8_t scaling_lists_4x4[3][2][16];
/**
* \brief 8x8 scaling,
*/
uint8_t scaling_lists_8x8[3][2][64];
/**
* \brief 16x16 scaling,
* correspongs i = 2, MatrixID is in the range of 0 to 5,
* inclusive. And j is in the range of 0 to 63, inclusive.
*/
uint8_t scaling_lists_16x16[3][2][64];
/**
* \brief 32x32 scaling,
* correspongs i = 3, MatrixID is in the range of 0 to 1,
* inclusive. And j is in the range of 0 to 63, inclusive.
*/
uint8_t scaling_lists_32x32[2][64];
/**
* \brief DC values of the 16x16 scaling lists,
* corresponds to HEVC spec syntax
* scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8
* with sizeID = 2 and matrixID in the range of 0 to 5, inclusive.
*/
uint8_t scaling_list_dc_16x16[3][2];
/**
* \brief DC values of the 32x32 scaling lists,
* corresponds to HEVC spec syntax
* scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8
* with sizeID = 3 and matrixID in the range of 0 to 1, inclusive.
*/
uint8_t scaling_list_dc_32x32[2];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAQMatrixBufferHEVC;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_ENC_HEVC_H */

View File

@@ -0,0 +1,162 @@
/*
* Copyright (c) 2007-2013 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_enc_jpeg.h
* \brief JPEG encoding API
*
* This file contains the \ref api_enc_jpeg "JPEG encoding API".
*/
#ifndef VA_ENC_JPEG_H
#define VA_ENC_JPEG_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_enc_jpeg JPEG encoding API
*
* @{
*/
/**
* \brief JPEG Encoding Picture Parameter Buffer Structure
*
* This structure conveys picture level parameters.
*
*/
typedef struct _VAEncPictureParameterBufferJPEG {
/** \brief holds reconstructed picture. */
VASurfaceID reconstructed_picture;
/** \brief picture width. */
uint16_t picture_width;
/** \brief picture height. */
uint16_t picture_height;
/** \brief holds coded data. */
VABufferID coded_buf;
/**
* \brief pic_flags
*
*/
union {
struct {
/**
* \brief profile:
* 0 - Baseline, 1 - Extended, 2 - Lossless, 3 - Hierarchical
*/
uint32_t profile : 2;
/**
* \brief progressive:
* 0 - sequential, 1 - extended, 2 - progressive
*/
uint32_t progressive : 1;
/**
* \brief huffman:
* 0 - arithmetic, 1 - huffman
*/
uint32_t huffman : 1;
/**
* \brief interleaved:
* 0 - non interleaved, 1 - interleaved
*/
uint32_t interleaved : 1;
/**
* \brief differential:
* 0 - non differential, 1 - differential
*/
uint32_t differential : 1;
} bits;
uint32_t value;
} pic_flags;
/** \brief number of bits per sample. */
uint8_t sample_bit_depth;
/** \brief total number of scans in image. */
uint8_t num_scan;
/** \brief number of image components in frame. */
uint16_t num_components;
/** \brief Component identifier (Ci). */
uint8_t component_id[4];
/** \brief Quantization table selector (Tqi). */
uint8_t quantiser_table_selector[4];
/** \brief number from 1 to 100 that specifies quality of image. */
uint8_t quality;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncPictureParameterBufferJPEG;
/**
* \brief Slice parameter for JPEG encoding.
*
* This structure conveys slice (scan) level parameters.
*
*/
typedef struct _VAEncSliceParameterBufferJPEG {
/** \brief Restart interval definition (Ri). */
uint16_t restart_interval;
/** \brief number of image components in a scan. */
uint16_t num_components;
struct {
/** \brief Scan component selector (Csj). */
uint8_t component_selector;
/** \brief DC entropy coding table selector (Tdj). */
uint8_t dc_table_selector;
/** \brief AC entropy coding table selector (Taj). */
uint8_t ac_table_selector;
} components[4];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncSliceParameterBufferJPEG;
/**
* \brief Quantization table for JPEG encoding.
*
*/
typedef struct _VAQMatrixBufferJPEG {
/** \brief load luma quantization table. */
int32_t load_lum_quantiser_matrix;
/** \brief load chroma quantization table. */
int32_t load_chroma_quantiser_matrix;
/** \brief luma quantization table. */
uint8_t lum_quantiser_matrix[64];
/** \brief chroma quantization table. */
uint8_t chroma_quantiser_matrix[64];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAQMatrixBufferJPEG;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_ENC_JPEG_H */

View File

@@ -0,0 +1,308 @@
/*
* Copyright (c) 2012 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_enc_mpeg2.h
* \brief The MPEG-2 encoding API
*
* This file contains the \ref api_enc_mpeg2 "MPEG-2 encoding API".
*/
#ifndef _VA_ENC_MPEG2_H_
#define _VA_ENC_MPEG2_H_
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_enc_mpeg2 MPEG-2 encoding API
*
* @{
*/
/**
* \brief MPEG-2 Quantization Matrix Buffer
*
*/
typedef VAIQMatrixBufferMPEG2 VAQMatrixBufferMPEG2;
/**
* \brief Packed header types specific to MPEG-2 encoding.
*
* Types of packed headers generally used for MPEG-2 encoding.
*/
typedef enum {
/**
* \brief Packed Sequence Parameter Set (SPS).
*
*/
VAEncPackedHeaderMPEG2_SPS = VAEncPackedHeaderSequence,
/**
* \brief Packed Picture Parameter Set (PPS).
*
*/
VAEncPackedHeaderMPEG2_PPS = VAEncPackedHeaderPicture,
/**
* \brief Packed slice header.
*
*/
VAEncPackedHeaderMPEG2_Slice = VAEncPackedHeaderSlice,
} VAEncPackedHeaderTypeMPEG2;
/**
* \brief Sequence parameter for MPEG-2 encoding
*
* This structure holds information for \c sequence_header() and
* sequence_extension().
*
* If packed sequence headers mode is used, i.e. if the encoding
* pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE
* flag, then the driver expects two more buffers to be provided to
* the same \c vaRenderPicture() as this buffer:
* - a #VAEncPackedHeaderParameterBuffer with type set to
* VAEncPackedHeaderType::VAEncPackedHeaderSequence ;
* - a #VAEncPackedHeaderDataBuffer which holds the actual packed
* header data.
*
*/
typedef struct _VAEncSequenceParameterBufferMPEG2 {
/** \brief Period between I frames. */
uint32_t intra_period;
/** \brief Period between I/P frames. */
uint32_t ip_period;
/** \brief Picture width.
*
* A 14bits unsigned inter, the lower 12bits
* is horizontal_size_value, and the upper
* 2bits is \c horizontal_size_extension
*
*/
uint16_t picture_width;
/** \brief Picture height.
*
* A 14bits unsigned inter, the lower 12bits
* is vertical_size_value, and the upper 2bits is
* vertical_size_size_extension
*
*/
uint16_t picture_height;
/**
* \brief Initial bitrate set for this sequence in CBR or VBR modes.
*
* This field represents the initial bitrate value for this
* sequence if CBR or VBR mode is used, i.e. if the encoder
* pipeline was created with a #VAConfigAttribRateControl
* attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
*
* bits_per_second may be derived from bit_rate.
*
*/
uint32_t bits_per_second;
/**
* \brief Frame rate
*
* Derived from frame_rate_value, frame_rate_extension_n and
* frame_rate_extension_d
*
*/
float frame_rate;
/** \brief Same as the element in sequence_header() */
uint16_t aspect_ratio_information;
/** \brief Define the size of VBV */
uint32_t vbv_buffer_size;
union {
struct {
/** \brief Same as the element in Sequence extension() */
uint32_t profile_and_level_indication : 8;
/** \brief Same as the element in Sequence extension() */
uint32_t progressive_sequence : 1;
/** \brief Same as the element in Sequence extension() */
uint32_t chroma_format : 2;
/** \brief Same as the element in Sequence extension() */
uint32_t low_delay : 1;
/** \brief Same as the element in Sequence extension() */
uint32_t frame_rate_extension_n : 2;
/** \brief Same as the element in Sequence extension() */
uint32_t frame_rate_extension_d : 5;
} bits;
uint32_t value;
} sequence_extension;
/** \brief Flag to indicate the following GOP header are being updated */
uint32_t new_gop_header;
union {
struct {
/** \brief Time code */
uint32_t time_code : 25;
/** \brief Same as the element in GOP header */
uint32_t closed_gop : 1;
/** \brief SAme as the element in GOP header */
uint32_t broken_link : 1;
} bits;
uint32_t value;
} gop_header;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncSequenceParameterBufferMPEG2;
/**
* \brief Picture parameter for MPEG-2 encoding
*
* This structure holds information for picture_header() and
* picture_coding_extension()
*
* If packed picture headers mode is used, i.e. if the encoding
* pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
* flag, then the driver expects two more buffers to be provided to
* the same \c vaRenderPicture() as this buffer:
* - a #VAEncPackedHeaderParameterBuffer with type set to
* VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
* - a #VAEncPackedHeaderDataBuffer which holds the actual packed
* header data.
*
*/
typedef struct _VAEncPictureParameterBufferMPEG2 {
/** \brief Forward reference picture */
VASurfaceID forward_reference_picture;
/** \brief Backward reference picture */
VASurfaceID backward_reference_picture;
/** \brief Reconstructed(decoded) picture */
VASurfaceID reconstructed_picture;
/**
* \brief Output encoded bitstream.
*
* \ref coded_buf has type #VAEncCodedBufferType. It should be
* large enough to hold the compressed NAL slice and possibly SPS
* and PPS NAL units.
*/
VABufferID coded_buf;
/**
* \brief Flag to indicate the picture is the last one or not.
*
* This fields holds 0 if the picture to be encoded is not
* the last one in the stream. Otherwise, it
* is \ref MPEG2_LAST_PICTURE_EOSTREAM.
*/
uint8_t last_picture;
/** \brief Picture type */
VAEncPictureType picture_type;
/** \brief Same as the element in picture_header() */
uint32_t temporal_reference;
/** \brief Same as the element in picture_header() */
uint32_t vbv_delay;
/** \brief Same as the element in Picture coding extension */
uint8_t f_code[2][2];
union {
struct {
/** \brief Same as the element in Picture coding extension */
uint32_t intra_dc_precision : 2;
/** \brief Same as the element in Picture coding extension */
uint32_t picture_structure : 2;
/** \brief Same as the element in Picture coding extension */
uint32_t top_field_first : 1;
/** \brief Same as the element in Picture coding extension */
uint32_t frame_pred_frame_dct : 1;
/** \brief Same as the element in Picture coding extension */
uint32_t concealment_motion_vectors : 1;
/** \brief Same as the element in Picture coding extension */
uint32_t q_scale_type : 1;
/** \brief Same as the element in Picture coding extension */
uint32_t intra_vlc_format : 1;
/** \brief Same as the element in Picture coding extension */
uint32_t alternate_scan : 1;
/** \brief Same as the element in Picture coding extension */
uint32_t repeat_first_field : 1;
/** \brief Same as the element in Picture coding extension */
uint32_t progressive_frame : 1;
/** \brief Same as the element in Picture coding extension */
uint32_t composite_display_flag : 1;
} bits;
uint32_t value;
} picture_coding_extension;
/* \brief Parameters for composite display
*
* Valid only when omposite_display_flag is 1
*/
union {
struct {
/** \brief Same as the element in Picture coding extension */
uint32_t v_axis : 1;
/** \brief Same as the element in Picture coding extension */
uint32_t field_sequence : 3;
/** \brief Same as the element in Picture coding extension */
uint32_t sub_carrier : 1;
/** \brief Same as the element in Picture coding extension */
uint32_t burst_amplitude : 7;
/** \brief Same as the element in Picture coding extension */
uint32_t sub_carrier_phase : 8;
} bits;
uint32_t value;
} composite_display;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncPictureParameterBufferMPEG2;
/**
* \brief Slice parameter for MPEG-2 encoding
*
*/
typedef struct _VAEncSliceParameterBufferMPEG2 {
/** \brief Starting MB address for this slice. */
uint32_t macroblock_address;
/** \brief Number of macroblocks in this slice. */
uint32_t num_macroblocks;
/** \brief Same as the element in slice() */
int32_t quantiser_scale_code;
/** \brief Flag to indicate intra slice */
int32_t is_intra_slice;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncSliceParameterBufferMPEG2;
typedef struct _VAEncMiscParameterExtensionDataSeqDisplayMPEG2 {
/** should always be 0x02 to identify it is Sequence Display Extension ISO-13818 */
uint8_t extension_start_code_identifier;
/** these field should follow ISO-13818 6.3.6 */
uint8_t video_format;
uint8_t colour_description;
uint8_t colour_primaries;
uint8_t transfer_characteristics;
uint8_t matrix_coefficients;
uint16_t display_horizontal_size;
uint16_t display_vertical_size;
} VAEncMiscParameterExtensionDataSeqDisplayMPEG2;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* _VA_ENC_MPEG2_H_ */

View File

@@ -0,0 +1,350 @@
/*
* Copyright (c) 2007-2012 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_enc_vp8.h
* \brief VP8 encoding API
*
* This file contains the \ref api_enc_vp8 "VP8 encoding API".
*/
#ifndef VA_ENC_VP8_H
#define VA_ENC_VP8_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_enc_vp8 VP8 encoding API
*
* @{
*/
/**
* \brief VP8 Encoding Sequence Parameter Buffer Structure
*
* This structure conveys sequence level parameters.
*
*/
typedef struct _VAEncSequenceParameterBufferVP8 {
/* frame width in pixels */
uint32_t frame_width;
/* frame height in pixels */
uint32_t frame_height;
/* horizontal scale */
uint32_t frame_width_scale;
/* vertical scale */
uint32_t frame_height_scale;
/* whether to enable error resilience features */
uint32_t error_resilient;
/* auto keyframe placement, non-zero means enable auto keyframe placement */
uint32_t kf_auto;
/* keyframe minimum interval */
uint32_t kf_min_dist;
/* keyframe maximum interval */
uint32_t kf_max_dist;
/* RC related fields. RC modes are set with VAConfigAttribRateControl */
/* For VP8, CBR implies HRD conformance and VBR implies no HRD conformance */
/**
* Initial bitrate set for this sequence in CBR or VBR modes.
*
* This field represents the initial bitrate value for this
* sequence if CBR or VBR mode is used, i.e. if the encoder
* pipeline was created with a #VAConfigAttribRateControl
* attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
*
* The bitrate can be modified later on through
* #VAEncMiscParameterRateControl buffers.
*/
uint32_t bits_per_second;
/* Period between I frames. */
uint32_t intra_period;
/* reference and reconstructed frame buffers
* Used for driver auto reference management when configured through
* VAConfigAttribEncAutoReference.
*/
VASurfaceID reference_frames[4];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncSequenceParameterBufferVP8;
/**
* \brief VP8 Encoding Picture Parameter Buffer Structure
*
* This structure conveys picture level parameters.
*
*/
typedef struct _VAEncPictureParameterBufferVP8 {
/* surface to store reconstructed frame */
VASurfaceID reconstructed_frame;
/*
* surfaces to store reference frames in non auto reference mode
* VA_INVALID_SURFACE can be used to denote an invalid reference frame.
*/
VASurfaceID ref_last_frame;
VASurfaceID ref_gf_frame;
VASurfaceID ref_arf_frame;
/* buffer to store coded data */
VABufferID coded_buf;
union {
struct {
/* force this frame to be a keyframe */
uint32_t force_kf : 1;
/* don't reference the last frame */
uint32_t no_ref_last : 1;
/* don't reference the golden frame */
uint32_t no_ref_gf : 1;
/* don't reference the alternate reference frame */
uint32_t no_ref_arf : 1;
/* The temporal id the frame belongs to. */
uint32_t temporal_id : 8;
/**
* following two flags indicate the reference order
* LastRef is specified by 01b;
* GoldRef is specified by 10b;
* AltRef is specified by 11b;
* first_ref specifies the reference frame which is searched first.
* second_ref specifies the reference frame which is searched second
* if there is.
*/
uint32_t first_ref : 2;
uint32_t second_ref : 2;
/** \brief Reserved for future use, must be zero */
uint32_t reserved : 16;
} bits;
uint32_t value;
} ref_flags;
union {
struct {
/* version */
uint32_t frame_type : 1;
uint32_t version : 3;
/* show_frame */
uint32_t show_frame : 1;
/* color_space */
uint32_t color_space : 1;
/* 0: bicubic, 1: bilinear, other: none */
uint32_t recon_filter_type : 2;
/* 0: no loop fitler, 1: simple loop filter */
uint32_t loop_filter_type : 2;
/* 0: disabled, 1: normal, 2: simple */
uint32_t auto_partitions : 1;
/* same as log2_nbr_of_dct_partitions in frame header syntax */
uint32_t num_token_partitions : 2;
/**
* The following fields correspond to the same VP8 syntax elements
* in the frame header.
*/
/**
* 0: clamping of reconstruction pixels is disabled,
* 1: clamping enabled.
*/
uint32_t clamping_type : 1;
/* indicate segmentation is enabled for the current frame. */
uint32_t segmentation_enabled : 1;
/**
* Determines if the MB segmentation map is updated in the current
* frame.
*/
uint32_t update_mb_segmentation_map : 1;
/**
* Indicates if the segment feature data is updated in the current
* frame.
*/
uint32_t update_segment_feature_data : 1;
/**
* indicates if the MB level loop filter adjustment is enabled for
* the current frame (0 off, 1 on).
*/
uint32_t loop_filter_adj_enable : 1;
/**
* Determines whether updated token probabilities are used only for
* this frame or until further update.
* It may be used by application to enable error resilient mode.
* In this mode probability updates are allowed only at Key Frames.
*/
uint32_t refresh_entropy_probs : 1;
/**
* Determines if the current decoded frame refreshes the golden frame.
*/
uint32_t refresh_golden_frame : 1;
/**
* Determines if the current decoded frame refreshes the alternate
* reference frame.
*/
uint32_t refresh_alternate_frame : 1;
/**
* Determines if the current decoded frame refreshes the last frame
* reference buffer.
*/
uint32_t refresh_last : 1;
/**
* Determines if the golden reference is replaced by another reference.
*/
uint32_t copy_buffer_to_golden : 2;
/**
* Determines if the alternate reference is replaced by another reference.
*/
uint32_t copy_buffer_to_alternate : 2;
/**
* Controls the sign of motion vectors when the golden frame is referenced.
*/
uint32_t sign_bias_golden : 1;
/**
* Controls the sign of motion vectors when the alternate frame is
* referenced.
*/
uint32_t sign_bias_alternate : 1;
/**
* Enables or disables the skipping of macroblocks containing no
* non-zero coefficients.
*/
uint32_t mb_no_coeff_skip : 1;
/**
* Enforces unconditional per-MB loop filter delta update setting frame
* header flags mode_ref_lf_delta_update, all mb_mode_delta_update_flag[4],
* and all ref_frame_delta_update_flag[4] to 1.
* Since loop filter deltas are not automatically refreshed to default
* values at key frames, dropped frame with delta update may prevent
* correct decoding from the next key frame.
* Encoder application is advised to set this flag to 1 at key frames.
*/
uint32_t forced_lf_adjustment : 1;
uint32_t reserved : 2;
} bits;
uint32_t value;
} pic_flags;
/**
* Contains a list of 4 loop filter level values (updated value if applicable)
* controlling the deblocking filter strength. Each entry represents a segment.
* When segmentation is disabled, use entry 0.
* When loop_filter_level is 0, loop filter shall be disabled.
*/
int8_t loop_filter_level[4];
/**
* Contains a list of 4 delta values for reference frame based MB-level
* loop filter adjustment.
* If no update, then set to 0.
*/
int8_t ref_lf_delta[4];
/**
* Contains a list of 4 delta values for coding mode based MB-level loop
* filter adjustment.
* If no update, then set to 0.
*/
int8_t mode_lf_delta[4];
/**
* Controls the deblocking filter sensitivity.
* Corresponds to the same VP8 syntax element in frame header.
*/
uint8_t sharpness_level;
/**
* Application supplied maximum clamp value for Qindex used in quantization.
* Qindex will not be allowed to exceed this value.
* It has a valid range [0..127] inclusive.
*/
uint8_t clamp_qindex_high;
/**
* Application supplied minimum clamp value for Qindex used in quantization.
* Qindex will not be allowed to be lower than this value.
* It has a valid range [0..127] inclusive.
* Condition clamp_qindex_low <= clamp_qindex_high must be guaranteed,
* otherwise they are ignored.
*/
uint8_t clamp_qindex_low;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncPictureParameterBufferVP8;
/**
* \brief VP8 MB Segmentation ID Buffer
*
* application provides buffer containing the initial segmentation id for each
* MB, in raster scan order. Rate control may reassign it.
* For an 640x480 video, the buffer has 1200 entries.
* the value of each entry should be in the range [0..3], inclusive.
* If segmentation is not enabled, application does not need to provide it.
*/
typedef struct _VAEncMBMapBufferVP8 {
/**
* number of MBs in the frame.
* It is also the number of entries of mb_segment_id[];
*/
uint32_t num_mbs;
/**
* per MB Segmentation ID Buffer
*/
uint8_t *mb_segment_id;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncMBMapBufferVP8;
/**
* \brief VP8 Quantization Matrix Buffer Structure
*
* Contains quantization index for yac(0-3) for each segment and quantization
* index deltas, ydc(0), y2dc(1), y2ac(2), uvdc(3), uvac(4) that are applied
* to all segments. When segmentation is disabled, only quantization_index[0]
* will be used. This structure is sent once per frame.
*/
typedef struct _VAQMatrixBufferVP8 {
uint16_t quantization_index[4];
int16_t quantization_index_delta[5];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAQMatrixBufferVP8;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_ENC_VP8_H */

View File

@@ -0,0 +1,603 @@
/*
* Copyright (c) 2007-2015 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_enc_vp9.h
* \brief VP9 encoding API
*
* This file contains the \ref api_enc_vp9 "VP9 encoding API".
*
*/
#ifndef VA_ENC_VP9_H
#define VA_ENC_VP9_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_enc_vp9 VP9 encoding API
*
* @{
*/
/**
* \brief VP9 Encoding Status Data Buffer Structure
*
* This structure is used to convey status data from encoder to application.
* Driver allocates VACodedBufferVP9Status as a private data buffer.
* Driver encapsulates the status buffer with a VACodedBufferSegment,
* and sets VACodedBufferSegment.status to be VA_CODED_BUF_STATUS_CODEC_SPECIFIC.
* And driver associates status data segment to the bit stream buffer segment
* by setting VACodedBufferSegment.next of coded_buf (bit stream) to the private
* buffer segment of status data.
* Application accesses it by calling VAMapBuffer() with VAEncCodedBufferType.
*/
typedef struct _VACodedBufferVP9Status {
/** Final quantization index used (yac), determined by BRC.
* Application is providing quantization index deltas
* ydc(0), y2dc(1), y2ac(2), uvdc(3), uvac(4) that are applied to all segments
* and segmentation qi deltas, they will not be changed by BRC.
*/
uint16_t base_qp_index;
/** Final loopfilter levels for the frame, if segmentation is disabled only
* index 0 is used.
* If loop_filter_level is 0, it indicates loop filter is disabled.
*/
uint8_t loop_filter_level;
/**
* Long term reference frame indication from BRC. BRC recommends the
* current frame that is being queried is a good candidate for a long
* term reference.
*/
uint8_t long_term_indication;
/* suggested next frame width */
uint16_t next_frame_width;
/* suggested next frame height */
uint16_t next_frame_height;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VACodedBufferVP9Status;
/**
* \brief VP9 Encoding Sequence Parameter Buffer Structure
*
* This structure conveys sequence level parameters.
*
*/
typedef struct _VAEncSequenceParameterBufferVP9 {
/** \brief Frame size note:
* Picture resolution may change frame by frame.
* Application needs to allocate surfaces and frame buffers based on
* max frame resolution in case resolution changes for later frames.
* The source and recon surfaces allocated should be 64x64(SB) aligned
* on both horizontal and vertical directions.
* But buffers on the surfaces need to be aligned to CU boundaries.
*/
/* maximum frame width in pixels for the whole sequence */
uint32_t max_frame_width;
/* maximum frame height in pixels for the whole sequence */
uint32_t max_frame_height;
/* auto keyframe placement, non-zero means enable auto keyframe placement */
uint32_t kf_auto;
/* keyframe minimum interval */
uint32_t kf_min_dist;
/* keyframe maximum interval */
uint32_t kf_max_dist;
/* RC related fields. RC modes are set with VAConfigAttribRateControl */
/* For VP9, CBR implies HRD conformance and VBR implies no HRD conformance */
/**
* Initial bitrate set for this sequence in CBR or VBR modes.
*
* This field represents the initial bitrate value for this
* sequence if CBR or VBR mode is used, i.e. if the encoder
* pipeline was created with a #VAConfigAttribRateControl
* attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
*
* The bitrate can be modified later on through
* #VAEncMiscParameterRateControl buffers.
*/
uint32_t bits_per_second;
/* Period between key frames */
uint32_t intra_period;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncSequenceParameterBufferVP9;
/**
* \brief VP9 Encoding Picture Parameter Buffer Structure
*
* This structure conveys picture level parameters.
*
*/
typedef struct _VAEncPictureParameterBufferVP9 {
/** VP9 encoder may support dynamic scaling function.
* If enabled (enable_dynamic_scaling is set), application may request
* GPU encodes picture with a different resolution from the raw source.
* GPU should handle the scaling process of source and
* all reference frames.
*/
/* raw source frame width in pixels */
uint32_t frame_width_src;
/* raw source frame height in pixels */
uint32_t frame_height_src;
/* to be encoded frame width in pixels */
uint32_t frame_width_dst;
/* to be encoded frame height in pixels */
uint32_t frame_height_dst;
/* surface to store reconstructed frame, not used for enc only case */
VASurfaceID reconstructed_frame;
/** \brief reference frame buffers
* Each entry of the array specifies the surface index of the picture
* that is referred by current picture or will be referred by any future
* picture. The valid entries take value from 0 to 127, inclusive.
* Non-valid entries, those do not point to pictures which are referred
* by current picture or future pictures, should take value 0xFF.
* Other values are not allowed.
*
* Application should update this array based on the refreshing
* information expected.
*/
VASurfaceID reference_frames[8];
/* buffer to store coded data */
VABufferID coded_buf;
union {
struct {
/* force this frame to be a keyframe */
uint32_t force_kf : 1;
/** \brief Indiates which frames to be used as reference.
* (Ref_frame_ctrl & 0x01) ? 1: last frame as reference frame, 0: not.
* (Ref_frame_ctrl & 0x02) ? 1: golden frame as reference frame, 0: not.
* (Ref_frame_ctrl & 0x04) ? 1: alt frame as reference frame, 0: not.
* L0 is for forward prediction.
* L1 is for backward prediction.
*/
uint32_t ref_frame_ctrl_l0 : 3;
uint32_t ref_frame_ctrl_l1 : 3;
/** \brief Last Reference Frame index
* Specifies the index to RefFrameList[] which points to the LAST
* reference frame. It corresponds to active_ref_idx[0] in VP9 code.
*/
uint32_t ref_last_idx : 3;
/** \brief Specifies the Sign Bias of the LAST reference frame.
* It corresponds to ref_frame_sign_bias[LAST_FRAME] in VP9 code.
*/
uint32_t ref_last_sign_bias : 1;
/** \brief GOLDEN Reference Frame index
* Specifies the index to RefFrameList[] which points to the Golden
* reference frame. It corresponds to active_ref_idx[1] in VP9 code.
*/
uint32_t ref_gf_idx : 3;
/** \brief Specifies the Sign Bias of the GOLDEN reference frame.
* It corresponds to ref_frame_sign_bias[GOLDEN_FRAME] in VP9 code.
*/
uint32_t ref_gf_sign_bias : 1;
/** \brief Alternate Reference Frame index
* Specifies the index to RefFrameList[] which points to the Alternate
* reference frame. It corresponds to active_ref_idx[2] in VP9 code.
*/
uint32_t ref_arf_idx : 3;
/** \brief Specifies the Sign Bias of the ALTERNATE reference frame.
* It corresponds to ref_frame_sign_bias[ALTREF_FRAME] in VP9 code.
*/
uint32_t ref_arf_sign_bias : 1;
/* The temporal id the frame belongs to */
uint32_t temporal_id : 8;
uint32_t reserved : 5;
} bits;
uint32_t value;
} ref_flags;
union {
struct {
/**
* Indicates if the current frame is a key frame or not.
* Corresponds to the same VP9 syntax element in frame tag.
*/
uint32_t frame_type : 1;
/** \brief show_frame
* 0: current frame is not for display
* 1: current frame is for display
*/
uint32_t show_frame : 1;
/**
* The following fields correspond to the same VP9 syntax elements
* in the frame header.
*/
uint32_t error_resilient_mode : 1;
/** \brief Indicate intra-only for inter pictures.
* Must be 0 for key frames.
* 0: inter frame use both intra and inter blocks
* 1: inter frame use only intra blocks.
*/
uint32_t intra_only : 1;
/** \brief Indicate high precision mode for Motion Vector prediction
* 0: normal mode
* 1: high precision mode
*/
uint32_t allow_high_precision_mv : 1;
/** \brief Motion Compensation Filter type
* 0: eight-tap (only this mode is supported now.)
* 1: eight-tap-smooth
* 2: eight-tap-sharp
* 3: bilinear
* 4: switchable
*/
uint32_t mcomp_filter_type : 3;
uint32_t frame_parallel_decoding_mode : 1;
uint32_t reset_frame_context : 2;
uint32_t refresh_frame_context : 1;
uint32_t frame_context_idx : 2;
uint32_t segmentation_enabled : 1;
/* corresponds to variable temporal_update in VP9 code.
* Indicates whether Segment ID is from bitstream or from previous
* frame.
* 0: Segment ID from bitstream
* 1: Segment ID from previous frame
*/
uint32_t segmentation_temporal_update : 1;
/* corresponds to variable update_mb_segmentation_map in VP9 code.
* Indicates how hardware determines segmentation ID
* 0: intra block - segment id is 0;
* inter block - segment id from previous frame
* 1: intra block - segment id from bitstream (app or GPU decides)
* inter block - depends on segmentation_temporal_update
*/
uint32_t segmentation_update_map : 1;
/** \brief Specifies if the picture is coded in lossless mode.
*
* lossless_mode = base_qindex == 0 && y_dc_delta_q == 0 \
* && uv_dc_delta_q == 0 && uv_ac_delta_q == 0;
* Where base_qindex, y_dc_delta_q, uv_dc_delta_q and uv_ac_delta_q
* are all variables in VP9 code.
*
* When enabled, tx_mode needs to be set to 4x4 only and all
* tu_size in CU record set to 4x4 for entire frame.
* Software also has to program such that final_qindex=0 and
* final_filter_level=0 following the Quant Scale and
* Filter Level Table in Segmentation State section.
* Hardware forces Hadamard Tx when this bit is set.
* When lossless_mode is on, BRC has to be turned off.
* 0: normal mode
* 1: lossless mode
*/
uint32_t lossless_mode : 1;
/** \brief MV prediction mode. Corresponds to VP9 variable with same name.
* comp_prediction_mode = 0: single prediction ony,
* comp_prediction_mode = 1: compound prediction,
* comp_prediction_mode = 2: hybrid prediction
*
* Not mandatory. App may suggest the setting based on power or
* performance. Kernal may use it as a guildline and decide the proper
* setting on its own.
*/
uint32_t comp_prediction_mode : 2;
/** \brief Indicate how segmentation is specified
* 0 application specifies segmentation partitioning and
* relevant parameters.
* 1 GPU may decide on segmentation. If application already
* provides segmentation information, GPU may choose to
* honor it and further split into more levels if possible.
*/
uint32_t auto_segmentation : 1;
/** \brief Indicate super frame syntax should be inserted
* 0 current frame is not encapsulated in super frame structure
* 1 current fame is to be encapsulated in super frame structure.
* super frame index syntax will be inserted by encoder at
* the end of current frame.
*/
uint32_t super_frame_flag : 1;
uint32_t reserved : 10;
} bits;
uint32_t value;
} pic_flags;
/** \brief indicate which frames in DPB should be refreshed.
* same syntax and semantic as in VP9 code.
*/
uint8_t refresh_frame_flags;
/** \brief Base Q index in the VP9 term.
* Added with per segment delta Q index to get Q index of Luma AC.
*/
uint8_t luma_ac_qindex;
/**
* Q index delta from base Q index in the VP9 term for Luma DC.
*/
int8_t luma_dc_qindex_delta;
/**
* Q index delta from base Q index in the VP9 term for Chroma AC.
*/
int8_t chroma_ac_qindex_delta;
/**
* Q index delta from base Q index in the VP9 term for Chroma DC.
*/
int8_t chroma_dc_qindex_delta;
/** \brief filter level
* Corresponds to the same VP9 syntax element in frame header.
*/
uint8_t filter_level;
/**
* Controls the deblocking filter sensitivity.
* Corresponds to the same VP9 syntax element in frame header.
*/
uint8_t sharpness_level;
/** \brief Loop filter level reference delta values.
* Contains a list of 4 delta values for reference frame based block-level
* loop filter adjustment.
* If no update, set to 0.
* value range [-63..63]
*/
int8_t ref_lf_delta[4];
/** \brief Loop filter level mode delta values.
* Contains a list of 4 delta values for coding mode based MB-level loop
* filter adjustment.
* If no update, set to 0.
* value range [-63..63]
*/
int8_t mode_lf_delta[2];
/**
* Offset from starting position of output bitstream in bits where
* ref_lf_delta[] should be inserted. This offset should cover any metadata
* ahead of uncompressed header in inserted bit stream buffer (the offset
* should be same as that for final output bitstream buffer).
*
* In BRC mode, always insert ref_lf_delta[] (This implies uncompressed
* header should have mode_ref_delta_enabled=1 and mode_ref_delta_update=1).
*/
uint16_t bit_offset_ref_lf_delta;
/**
* Offset from starting position of output bitstream in bits where
* mode_lf_delta[] should be inserted.
*
* In BRC mode, always insert mode_lf_delta[] (This implies uncompressed
* header should have mode_ref_delta_enabled=1 and mode_ref_delta_update=1).
*/
uint16_t bit_offset_mode_lf_delta;
/**
* Offset from starting position of output bitstream in bits where (loop)
* filter_level should be inserted.
*/
uint16_t bit_offset_lf_level;
/**
* Offset from starting position of output bitstream in bits where
* Base Qindex should be inserted.
*/
uint16_t bit_offset_qindex;
/**
* Offset from starting position of output bitstream in bits where
* First Partition Size should be inserted.
*/
uint16_t bit_offset_first_partition_size;
/**
* Offset from starting position of output bitstream in bits where
* segmentation_enabled is located in bitstream. When auto_segmentation
* is enabled, GPU uses this offset to locate and update the
* segmentation related information.
*/
uint16_t bit_offset_segmentation;
/** \brief length in bit of segmentation portion from the location
* in bit stream where segmentation_enabled syntax is coded.
* When auto_segmentation is enabled, GPU uses this bit size to locate
* and update the information after segmentation.
*/
uint16_t bit_size_segmentation;
/** \brief log2 of number of tile rows
* Corresponds to the same VP9 syntax element in frame header.
* value range [0..2]
*/
uint8_t log2_tile_rows;
/** \brief log2 of number of tile columns
* Corresponds to the same VP9 syntax element in frame header.
* value range [0..6]
*/
uint8_t log2_tile_columns;
/** \brief indicate frame-skip happens
* Application may choose to drop/skip one or mulitple encoded frames or
* to-be-encoded frame due to various reasons such as insufficient
* bandwidth.
* Application uses the following three flags to inform GPU about frame-skip.
*
* value range of skip_frame_flag: [0..2]
* 0 - encode as normal, no skip;
* 1 - one or more frames were skipped by application prior to the
* current frame. Encode the current frame as normal. The driver
* will pass the number_skip_frames and skip_frames_size
* to bit rate control for adjustment.
* 2 - the current frame is to be skipped. Do not encode it but encrypt
* the packed header contents. This is for the secure encoding case
* where application generates a frame of all skipped blocks.
* The packed header will contain the skipped frame.
*/
uint8_t skip_frame_flag;
/** \brief The number of frames skipped prior to the current frame.
* It includes only the skipped frames that were not counted before,
* and does not include the frame with skip_frame_flag == 2.
* Valid when skip_frame_flag = 1.
*/
uint8_t number_skip_frames;
/** \brief When skip_frame_flag = 1, the size of the skipped frames in bits.
* It includes only the skipped frames that were not counted before,
* and does not include the frame size with skip_frame_flag = 2.
* When skip_frame_flag = 2, it is the size of the current skipped frame
* that is to be encrypted.
*/
uint32_t skip_frames_size;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_MEDIUM];
} VAEncPictureParameterBufferVP9;
/**
* \brief Per segment parameters
*/
typedef struct _VAEncSegParamVP9 {
union {
struct {
/** \brief Indicates if per segment reference frame indicator is enabled.
* Corresponding to variable feature_enabled when
* j == SEG_LVL_REF_FRAME in function setup_segmentation() VP9 code.
*/
uint8_t segment_reference_enabled : 1;
/** \brief Specifies per segment reference indication.
* 0: reserved
* 1: Last ref
* 2: golden
* 3: altref
* Value can be derived from variable data when
* j == SEG_LVL_REF_FRAME in function setup_segmentation() VP9 code.
* value range: [0..3]
*/
uint8_t segment_reference : 2;
/** \brief Indicates if per segment skip mode is enabled.
* Corresponding to variable feature_enabled when
* j == SEG_LVL_SKIP in function setup_segmentation() VP9 code.
*/
uint8_t segment_reference_skipped : 1;
uint8_t reserved : 4;
} bits;
uint8_t value;
} seg_flags;
/** \brief Specifies per segment Loop Filter Delta.
* Must be 0 when segmentation_enabled == 0.
* value range: [-63..63]
*/
int8_t segment_lf_level_delta;
/** \brief Specifies per segment QIndex Delta.
* Must be 0 when segmentation_enabled == 0.
* value range: [-255..255]
*/
int16_t segment_qindex_delta;
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncSegParamVP9;
/**
* Structure to convey all segment related information.
* If segmentation is disabled, this data structure is still required.
* In this case, only seg_data[0] contains valid data.
* This buffer is sent once per frame.
*
* The buffer is created with VABufferType VAQMatrixBufferType.
*
*/
typedef struct _VAEncMiscParameterTypeVP9PerSegmantParam {
/**
* Parameters for 8 segments.
*/
VAEncSegParamVP9 seg_data[8];
/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
} VAEncMiscParameterTypeVP9PerSegmantParam;
/**
* \brief VP9 Block Segmentation ID Buffer
*
* The application provides a buffer of VAEncMacroblockMapBufferType containing
* the initial segmentation id for each 8x8 block, one byte each, in raster scan order.
* Rate control may reassign it. For example, a 640x480 video, the buffer has 4800 entries.
* The value of each entry should be in the range [0..7], inclusive.
* If segmentation is not enabled, the application does not need to provide it.
*/
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_ENC_VP9_H */

View File

@@ -0,0 +1,168 @@
/*
* Copyright (c) 2007-2017 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_fei.h
* \brief The FEI encoding common API
*/
#ifndef VA_FEI_H
#define VA_FEI_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/**
* \defgroup api_fei FEI encoding common API
*
* @{
*/
/**
* \brief FEI specific attribute definitions
*/
/** @name Attribute values for VAConfigAttribFEIFunctionType
*
* This is only for VAEntrypointFEI
* The desired type should be passed to driver when creating the configuration.
* If VA_FEI_FUNCTION_ENC_PAK is set, VA_FEI_FUNCTION_ENC and VA_FEI_FUNCTION_PAK
* will be ignored if set also. Combination of VA_FEI_FUNCTION_ENC and VA_FEI_FUNCTION_PAK
* is not valid. If VA_FEI_FUNCTION_ENC is set, there will be no bitstream output.
* If VA_FEI_FUNCTION_PAK is set, two extra input buffers for PAK are needed:
* VAEncFEIMVBufferType and VAEncFEIMBCodeBufferType.
* VA_FEI_FUNCTION_ENC_PAK is recommended for best performance.
*
**/
/**@{*/
/** \brief ENC only is supported */
#define VA_FEI_FUNCTION_ENC 0x00000001
/** \brief PAK only is supported */
#define VA_FEI_FUNCTION_PAK 0x00000002
/** \brief ENC_PAK is supported */
#define VA_FEI_FUNCTION_ENC_PAK 0x00000004
/**@}*/
/** \brief Attribute value for VAConfigAttribStats */
typedef union _VAConfigAttribValStats {
struct {
/** \brief Max number of past reference frames that are supported. */
uint32_t max_num_past_references : 4;
/** \brief Max number of future reference frames that are supported. */
uint32_t max_num_future_references : 4;
/** \brief Number of supported output buffers for VAStatsStatisticsParameter->outputs */
uint32_t num_outputs : 3;
/** \brief Interlaced content is supported */
uint32_t interlaced : 1;
uint32_t reserved : 20;
} bits;
uint32_t value;
} VAConfigAttribValStats;
typedef struct _VAPictureStats {
VASurfaceID picture_id;
/*
* see flags below.
*/
uint32_t flags;
} VAPictureStats;
/* flags in VAPictureStats could be one of the following */
#define VA_PICTURE_STATS_INVALID 0x00000001
#define VA_PICTURE_STATS_PROGRESSIVE 0x00000000
#define VA_PICTURE_STATS_TOP_FIELD 0x00000002
#define VA_PICTURE_STATS_BOTTOM_FIELD 0x00000004
/** \brief picutre surface content updated indicator.
* The picture surface content is updated, it means temporary buffer like downscaled pixel data in driver
* internal needs be forced freshing
**/
#define VA_PICTURE_STATS_CONTENT_UPDATED 0x00000010
/** \brief Motion Vector and Statistics frame level controls.
* common part VAStatsStatisticsParameterBufferType for a MB or CTB
**/
typedef struct _VAStatsStatisticsParameter {
/** \brief Source surface ID. */
VAPictureStats input;
/** \brief Past reference surface ID pointer. */
VAPictureStats *past_references;
/** \brief Past reference surface number */
uint32_t num_past_references;
/** \brief Statistics output for past reference surface.
* Only enabling statistics output for past reference picture when *past_ref_stat_buf is a valid
* VABufferID, it is needed in case app wants statistics data of both reference and current pictures
* in very special use cases for better performance.
* The output layout is defined by VAStatsStatisticsBufferType(for progressive and top field of
* interlaced case) and VAStatsStatisticsBottomFieldBufferType(only for interlaced case), only
* pixel_average_16x16/pixel_average_8x8 and variance_16x16/variance_8x8 data are valid.
**/
VABufferID *past_ref_stat_buf;
/** \brief Future reference surface ID pointer. */
VAPictureStats *future_references;
/** \brief Future reference surface number */
uint32_t num_future_references;
/** \brief Statistics output for future reference surface.
* Only enabling statistics output for future reference picture when *past_ref_stat_buf is a valid
* VABufferID, it is needed in case app wants statistics data of both reference and current pictures
* in very special use cases for better performance.
* The output layout is defined by VAStatsStatisticsBufferType(for progressive and top field of
* interlaced case) and VAStatsStatisticsBottomFieldBufferType(only for interlaced case), only
* pixel_average_16x16/pixel_average_8x8 and variance_16x16/variance_8x8 data are valid.
**/
VABufferID *future_ref_stat_buf;
/** \brief ID of the output buffer.
* The number of outputs is determined by below DisableMVOutput and DisableStatisticsOutput.
* The output layout is defined by VAStatsMVBufferType, VAStatsStatisticsBufferType(for progressive and
* top field of interlaced case) and VAStatsStatisticsBottomFieldBufferType(only for interlaced case).
**/
VABufferID *outputs;
/** \brief MV predictor. It is valid only when mv_predictor_ctrl is not 0.
* Each block has a pair of MVs, one for past and one for future reference
* as defined by VAMotionVector. The block is in raster scan order.
* Buffer size shall not be less than the number of blocks multiplied by sizeof(VAMotionVector).
**/
VABufferID mv_predictor;
/** \brief QP input buffer. It is valid only when mb_qp is set to 1.
* The data in this buffer correspond to the input source.
* One QP per MB or CTB block in raster scan order, each QP is a signed char (8-bit) value.
**/
VABufferID qp;
} VAStatsStatisticsParameter;
#ifdef __cplusplus
}
#endif
#endif /* VA_FEI_H */

View File

@@ -0,0 +1,504 @@
/*
* Copyright (c) 2007-2017 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_fei_h264.h
* \brief The FEI encoding H264 special API
*/
#ifndef VA_FEI_H264_H
#define VA_FEI_H264_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "va_fei.h"
/**
* \defgroup api_fei_h264 H.264 FEI encoding API
*
* @{
*/
/** \brief FEI frame level control buffer for H.264 */
typedef struct _VAEncMiscParameterFEIFrameControlH264 {
uint32_t function; /* one of the VAConfigAttribFEIFunctionType values */
/** \brief MB (16x16) control input buffer. It is valid only when (mb_input | mb_size_ctrl)
* is set to 1. The data in this buffer correspond to the input source. 16x16 MB is in raster scan order,
* each MB control data structure is defined by VAEncFEIMBControlH264.
* Buffer size shall not be less than the number of 16x16 blocks multiplied by
* sizeof(VAEncFEIMBControlH264).
* Note: if mb_qp is set, VAEncQPBufferH264 is expected.
*/
VABufferID mb_ctrl;
/** \brief distortion output of MB ENC or ENC_PAK.
* Each 16x16 block has one distortion data with VAEncFEIDistortionH264 layout
* Buffer size shall not be less than the number of 16x16 blocks multiplied by
* sizeof(VAEncFEIDistortionH264).
*/
VABufferID distortion;
/** \brief MVs data output of MB ENC.
* Each 16x16 block has one MVs data with layout VAMotionVector
* Buffer size shall not be less than the number of 16x16 blocks multiplied by
* sizeof(VAMotionVector) * 16.
*/
VABufferID mv_data;
/** \brief MBCode data output of MB ENC.
* Each 16x16 block has one MB Code data with layout VAEncFEIMBCodeH264
* Buffer size shall not be less than the number of 16x16 blocks multiplied by
* sizeof(VAEncFEIMBCodeH264).
*/
VABufferID mb_code_data;
/** \brief QP input buffer with layout VAEncQPBufferH264. It is valid only when mb_qp is set to 1.
* The data in this buffer correspond to the input source.
* One QP per 16x16 block in raster scan order, each QP is a signed char (8-bit) value.
**/
VABufferID qp;
/** \brief MV predictor. It is valid only when mv_predictor_enable is set to 1.
* Each 16x16 block has one or more pair of motion vectors and the corresponding
* reference indexes as defined by VAEncFEIMVPredictorH264. 16x16 block is in raster scan order.
* Buffer size shall not be less than the number of 16x16 blocks multiplied by
* sizeof(VAEncFEIMVPredictorH264). */
VABufferID mv_predictor;
/** \brief number of MV predictors. It must not be greater than maximum supported MV predictor. */
uint32_t num_mv_predictors_l0 : 16;
uint32_t num_mv_predictors_l1 : 16;
/** \brief motion search method definition
* 0: default value, diamond search
* 1: full search
* 2: diamond search
**/
uint32_t search_path : 8;
/** \brief maximum number of Search Units, valid range is [1, 63]
* 0 is treated as 1. reference search locations are grouped in a predefined pattern,
* and all locations within the same group must be either all are chosen or all are skipped.
* These predefined groups are called search unit (SU).*/
uint32_t len_sp : 8;
uint32_t reserved0 : 16;
/** \brief defines the bit-mask for disabling sub-partition
* The lower 4 bits are for the major partitions (sub-macroblock) and the higher 3 bits for minor partitions (with sub-partition for 4x(8x8) sub-macroblocks.
* xxxxxx1 : 16x16 sub-macroblock disabled
* xxxxx1x : 2x(16x8) sub-macroblock within 16x16 disabled
* xxxx1xx : 2x(8x16) sub-macroblock within 16x16 disabled
* xxx1xxx : 1x(8x8) sub-partition for 4x(8x8) within 16x16 disabled
* xx1xxxx : 2x(8x4) sub-partition for 4x(8x8) within 16x16 disabled
* x1xxxxx : 2x(4x8) sub-partition for 4x(8x8) within 16x16 disabled
* 1xxxxxx : 4x(4x4) sub-partition for 4x(8x8) within 16x16 disabled
* 1111111 : Invalid
* 0000000 : default value */
uint32_t sub_mb_part_mask : 7;
/** specifies which Luma Intra partition is enabled/disabled for intra mode decision.
* xxxx1: luma_intra_16x16 disabled
* xxx1x: luma_intra_8x8 disabled
* xx1xx: luma_intra_4x4 disabled
* xx111: intra prediction is disabled */
uint32_t intra_part_mask : 5;
/** when set to 1, neighbor MV will be used as predictor; when set to 0, no neighbor MV will be used as predictor.*/
uint32_t multi_pred_l0 : 1;
/** when set to 1, neighbor MV will be used as predictor; when set to 0, no neighbor MV will be used as predictor.*/
uint32_t multi_pred_l1 : 1;
/**defines the half/quarter pel modes. The mode is inclusive, ie., higher precision mode samples lower precision locations.
* 00b: integer mode searching
* 01b: half-pel mode searching
* 10b: reserved
* 11b: quarter-pel mode searching */
uint32_t sub_pel_mode : 2;
/** specifies distortion measure adjustments used for the inter motion search SAD comparison.
* 00b: none
* 10b: Haar transform adjusted*/
uint32_t inter_sad : 2;
/** specifies distortion measure adjustments used for the intra motion search SAD comparison.
* 00b: none
* 10b: Haar transform adjusted*/
uint32_t intra_sad : 2;
/** specifies if the output distortion is the raw distortion or cost adjusted distortion.
* 0: Raw Distortion without Cost
* 1: Distortion with added Cost */
uint32_t distortion_type : 1;
/** when set to 1, enables the additional calls on Fraction & Bidirectional Refinement*/
uint32_t repartition_check_enable : 1;
/** defines whether adaptive searching is enabled for IME(Integer Motion Estimation).
* 0: disable
* 1: enable */
uint32_t adaptive_search : 1;
/** enables using the motion vector as an extra predictor provided by the host. If it is set,
* host needs to provide a buffer with motion vectors and the associated reference index for
* each 16x16 block as defined . The host can call processing function to get motion vectors and use as predictor.
* 0: MV predictor disabled
* 1: MV predictor enabled */
uint32_t mv_predictor_enable : 1;
/** enables using the QP buffer to set the QP for each block*/
uint32_t mb_qp : 1;
/** enable mb_ctrl buffer to handle MB*/
uint32_t mb_input : 1;
/** when this flag is set, mb_ctrl must be set too and a buffer with per MB input
* needs to be provided and MaxSizeInWord and */
uint32_t mb_size_ctrl : 1;
/** when this flag is set, extra distortion between the current MB and co-located MB is provided.
* Extra distortion output has performance impact, set it only when it is needed.*/
uint32_t colocated_mb_distortion : 1;
uint32_t reserved1 : 4;
/** \brief motion search window(ref_width * ref_height) */
uint32_t ref_width : 8;
uint32_t ref_height : 8;
/** \brief predefined motion search windows. If selected, len_sp, window(ref_width * ref_eight)
* and search_path setting are ignored.
* 0: not use predefined search window
* 1: Tiny, len_sp=4, 24x24 window and diamond search
* 2: Small, len_sp=9, 28x28 window and diamond search
* 3: Diamond, len_sp=16, 48x40 window and diamond search
* 4: Large Diamond, len_sp=32, 48x40 window and diamond search
* 5: Exhaustive, len_sp=48, 48x40 window and full search
* 6: Extend Diamond, len_sp=16, 64x40 window and diamond search
* 7: Extend Large Diamond, len_sp=32, 64x40 window and diamond search
* 8: Extend Exhaustive, len_sp=48, 64x40 window and full search
**/
uint32_t search_window : 4;
uint32_t reserved2 : 12;
/** \brief max frame size control with multi passes QP setting */
uint32_t max_frame_size;
/** \brief number of passes, every pass has different QP */
uint32_t num_passes;
/** \brief delta QP list for every pass */
uint8_t *delta_qp;
uint32_t reserved3[VA_PADDING_LOW];
} VAEncMiscParameterFEIFrameControlH264;
/** \brief FEI MB level control data structure */
typedef struct _VAEncFEIMBControlH264 {
/** \brief when set, correposndent MB is coded as intra */
uint32_t force_to_intra : 1;
/** \brief when set, correposndent MB is coded as skip */
uint32_t force_to_skip : 1;
/** \brief specifies whether this macroblock should be coded as a non-skipped macroblock. */
uint32_t force_to_nonskip : 1;
uint32_t enable_direct_bias_adjustment : 1;
uint32_t enable_motion_bias_adjustment : 1;
uint32_t ext_mv_cost_scaling_factor : 3;
uint32_t reserved0 : 24;
uint32_t reserved1;
uint32_t reserved2;
uint32_t reserved3 : 16;
/** \brief when mb_size_ctrl is set, size here is used to budget accumulatively. Set to 0xFF if don't care. */
uint32_t target_size_in_word : 8;
/** \brief specifies the max size of each MB */
uint32_t max_size_in_word : 8;
} VAEncFEIMBControlH264;
/** \brief Application can use this definition as reference to allocate the buffer
* based on MaxNumPredictor returned from attribute VAConfigAttribFEIMVPredictors query.
**/
typedef struct _VAEncFEIMVPredictorH264 {
/** \brief Reference index corresponding to the entry of RefPicList0 & RefPicList1 in VAEncSliceParameterBufferH264.
* Note that RefPicList0 & RefPicList1 needs to be the same for all slices.
* ref_idx_l0_x : index to RefPicList0; ref_idx_l1_x : index to RefPicList1; x : 0 - MaxNumPredictor.
**/
struct {
uint8_t ref_idx_l0 : 4;
uint8_t ref_idx_l1 : 4;
} ref_idx[4]; /* index is predictor number */
uint32_t reserved;
/** \brief MV. MaxNumPredictor must be the returned value from attribute VAConfigAttribFEIMVPredictors query.
* Even application doesn't use the maximum predictors, the VAFEIMVPredictorH264 structure size
* has to be defined as maximum so each MB can be at a fixed location.
* Note that 0x8000 must be used for correspondent intra block.
**/
VAMotionVector mv[4]; /* MaxNumPredictor is 4 */
} VAEncFEIMVPredictorH264;
/** \brief FEI output */
/**
* Motion vector output is per 4x4 block. For each 4x4 block there is a pair of MVs
* for RefPicList0 and RefPicList1 and each MV is 4 bytes including horizontal and vertical directions.
* Depending on Subblock partition, for the shape that is not 4x4, the MV is replicated
* so each 4x4 block has a pair of MVs. The 16x16 block has 32 MVs (128 bytes).
* 0x8000 is used for correspondent intra block. The 16x16 block is in raster scan order,
* within the 16x16 block, each 4x4 block MV is ordered as below in memory.
* The buffer size shall be greater than or equal to the number of 16x16 blocks multiplied by 128 bytes.
* Note that, when separate ENC and PAK is enabled, the exact layout of this buffer is needed for PAK input.
* App can reuse this buffer, or copy to a different buffer as PAK input.
* Layout is defined as Generic motion vector data structure VAMotionVector
* 16x16 Block
* -----------------------------------------
* | 1 | 2 | 5 | 6 |
* -----------------------------------------
* | 3 | 4 | 7 | 8 |
* -----------------------------------------
* | 9 | 10 | 13 | 14 |
* -----------------------------------------
* | 11 | 12 | 15 | 16 |
* -----------------------------------------
**/
/** \brief VAEncFEIMBCodeH264 defines the data structure for VAEncFEIMBCodeBufferType per 16x16 MB block.
* it is output buffer of ENC and ENC_PAK modes, it's also input buffer of PAK mode.
* The 16x16 block is in raster scan order. Buffer size shall not be less than the number of 16x16 blocks
* multiplied by sizeof(VAEncFEIMBCodeH264). Note that, when separate ENC and PAK is enabled,
* the exact layout of this buffer is needed for PAK input. App can reuse this buffer,
* or copy to a different buffer as PAK input, reserved elements must not be modified when used as PAK input.
**/
typedef struct _VAEncFEIMBCodeH264 {
//DWORD 0~2
uint32_t reserved0[3];
//DWORD 3
uint32_t inter_mb_mode : 2;
uint32_t mb_skip_flag : 1;
uint32_t reserved1 : 1;
uint32_t intra_mb_mode : 2;
uint32_t reserved2 : 1;
uint32_t field_mb_polarity_flag : 1;
uint32_t mb_type : 5;
uint32_t intra_mb_flag : 1;
uint32_t field_mb_flag : 1;
uint32_t transform8x8_flag : 1;
uint32_t reserved3 : 1;
uint32_t dc_block_coded_cr_flag : 1;
uint32_t dc_block_coded_cb_flag : 1;
uint32_t dc_block_coded_y_flag : 1;
uint32_t reserved4 : 12;
//DWORD 4
uint32_t horz_origin : 8;
uint32_t vert_origin : 8;
uint32_t cbp_y : 16;
//DWORD 5
uint32_t cbp_cb : 16;
uint32_t cbp_cr : 16;
//DWORD 6
uint32_t qp_prime_y : 8;
uint32_t reserved5 : 17;
uint32_t mb_skip_conv_disable : 1;
uint32_t is_last_mb : 1;
uint32_t enable_coefficient_clamp : 1;
uint32_t direct8x8_pattern : 4;
//DWORD 7 8 and 9
union {
/* Intra MBs */
struct {
uint32_t luma_intra_pred_modes0 : 16;
uint32_t luma_intra_pred_modes1 : 16;
uint32_t luma_intra_pred_modes2 : 16;
uint32_t luma_intra_pred_modes3 : 16;
uint32_t chroma_intra_pred_mode : 2;
uint32_t intra_pred_avail_flag : 5;
uint32_t intra_pred_avail_flagF : 1;
uint32_t reserved6 : 24;
} intra_mb;
/* Inter MBs */
struct {
uint32_t sub_mb_shapes : 8;
uint32_t sub_mb_pred_modes : 8;
uint32_t reserved7 : 16;
uint32_t ref_idx_l0_0 : 8;
uint32_t ref_idx_l0_1 : 8;
uint32_t ref_idx_l0_2 : 8;
uint32_t ref_idx_l0_3 : 8;
uint32_t ref_idx_l1_0 : 8;
uint32_t ref_idx_l1_1 : 8;
uint32_t ref_idx_l1_2 : 8;
uint32_t ref_idx_l1_3 : 8;
} inter_mb;
} mb_mode;
//DWORD 10
uint32_t reserved8 : 16;
uint32_t target_size_in_word : 8;
uint32_t max_size_in_word : 8;
//DWORD 11~14
uint32_t reserved9[4];
//DWORD 15
uint32_t reserved10;
} VAEncFEIMBCodeH264; // 64 bytes
/** \brief VAEncFEIDistortionH264 defines the data structure for VAEncFEIDistortionBufferType per 16x16 MB block.
* It is output buffer of ENC and ENC_PAK modes, The 16x16 block is in raster scan order.
* Buffer size shall not be less than the number of 16x16 blocks multiple by sizeof(VAEncFEIDistortionH264).
**/
typedef struct _VAEncFEIDistortionH264 {
/** \brief Inter-prediction-distortion associated with motion vector i (co-located with subblock_4x4_i).
* Its meaning is determined by sub-shape. It must be zero if the corresponding sub-shape is not chosen.
**/
uint16_t inter_distortion[16];
uint32_t best_inter_distortion : 16;
uint32_t best_intra_distortion : 16;
uint32_t colocated_mb_distortion : 16;
uint32_t reserved0 : 16;
uint32_t reserved1[2];
} VAEncFEIDistortionH264; // 48 bytes
/** \brief Motion Vector and Statistics frame level controls.
* VAStatsStatisticsParameterBufferType for H264 16x16 block
**/
typedef struct _VAStatsStatisticsParameterH264 {
VAStatsStatisticsParameter stats_params;
uint32_t frame_qp : 8;
/** \brief length of search path */
uint32_t len_sp : 8;
/** \brief motion search method definition
* 0: default value, diamond search
* 1: full search
* 2: diamond search
**/
uint32_t search_path : 8;
uint32_t reserved0 : 8;
uint32_t sub_mb_part_mask : 7;
/** \brief sub pixel mode definition
* 00b: integer mode searching
* 01b: half-pel mode searching
* 10b: reserved
* 11b: quarter-pel mode searching
**/
uint32_t sub_pel_mode : 2;
/** \brief distortion measure adjustment for inter search SAD comparison
* 00b: none
* 01b: reserved
* 10b: Haar transform adjusted
* 11b: reserved
**/
uint32_t inter_sad : 2;
/** \brief distortion measure adjustment for intra search SAD comparison
* 00b: none
* 01b: reserved
* 10b: Haar transform adjusted
* 11b: reserved
**/
uint32_t intra_sad : 2;
uint32_t adaptive_search : 1;
/** \brief indicate if future or/and past MV in mv_predictor buffer is valid.
* 0: MV predictor disabled
* 1: MV predictor enabled for past reference
* 2: MV predictor enabled for future reference
* 3: MV predictor enabled for both past and future references
**/
uint32_t mv_predictor_ctrl : 3;
uint32_t mb_qp : 1;
/** \brief forward transform enable
* 0: disable
* 1: enable, needs frame_qp or mb_qp input for transform
**/
uint32_t ft_enable : 1;
/** \brief luma intra mode partition mask
* xxxx1: luma_intra_16x16 disabled
* xxx1x: luma_intra_8x8 disabled
* xx1xx: luma_intra_4x4 disabled
* xx111: intra prediction is disabled
**/
uint32_t intra_part_mask : 5;
uint32_t reserved1 : 8;
/** \brief motion search window(ref_width * ref_height) */
uint32_t ref_width : 8;
uint32_t ref_height : 8;
/** \brief predefined motion search windows. If selected, len_sp, window(ref_width * ref_eight)
* and search_path setting are ignored.
* 0: not use predefined search window
* 1: Tiny, len_sp=4, 24x24 window and diamond search
* 2: Small, len_sp=9, 28x28 window and diamond search
* 3: Diamond, len_sp=16, 48x40 window and diamond search
* 4: Large Diamond, len_sp=32, 48x40 window and diamond search
* 5: Exhaustive, len_sp=48, 48x40 window and full search
* 6: Extend Diamond, len_sp=16, 64x40 window and diamond search
* 7: Extend Large Diamond, len_sp=32, 64x40 window and diamond search
* 8: Extend Exhaustive, len_sp=48, 64x40 window and full search
**/
uint32_t search_window : 4;
uint32_t reserved2 : 12;
/** \brief MVOutput. When set to 1, MV output is NOT provided */
uint32_t disable_mv_output : 1;
/** \brief StatisticsOutput. When set to 1, Statistics output is NOT provided. */
uint32_t disable_statistics_output : 1;
/** \brief block 8x8 data enabling in statistics output */
uint32_t enable_8x8_statistics : 1;
uint32_t reserved3 : 29;
uint32_t reserved4[2];
} VAStatsStatisticsParameterH264;
/** \brief VAStatsStatisticsH264. H264 Statistics buffer layout for VAStatsStatisticsBufferType
* and VAStatsStatisticsBottomFieldBufferType(for interlaced only).
* Statistics output is per 16x16 block. Data structure per 16x16 block is defined below.
* The 16x16 block is in raster scan order. The buffer size shall be greater than or equal to
* the number of 16x16 blocks multiplied by sizeof(VAStatsStatisticsH264).
**/
typedef struct _VAStatsStatisticsH264 {
/** \brief past reference */
uint32_t best_inter_distortion0 : 16;
uint32_t inter_mode0 : 16;
/** \brief future reference */
uint32_t best_inter_distortion1 : 16;
uint32_t inter_mode1 : 16;
uint32_t best_intra_distortion : 16;
uint32_t intra_mode : 16;
uint32_t num_non_zero_coef : 16;
uint32_t reserved0 : 16;
uint32_t sum_coef;
/** \brief DWORD 5 flat info **/
uint32_t mb_is_flat : 1;
uint32_t reserved1 : 31;
/** \brief DWORD 6 variance for block16x16**/
uint32_t variance_16x16;
/** \brief DWORD 7 ~ 10, variance for block8x8 **/
uint32_t variance_8x8[4];
/** \brief DWORD 11 pixel_average for block16x16 **/
uint32_t pixel_average_16x16;
/** \brief DWORD 12 ~ 15, pixel_average for block8x8 **/
uint32_t pixel_average_8x8[4];
} VAStatsStatisticsH264; // 64 bytes
#ifdef __cplusplus
}
#endif
#endif /* VA_FEI_H264_H */

View File

@@ -0,0 +1,251 @@
/*
* Copyright (c) 2007-2017 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_fei_hevc.h
* \brief The FEI encoding HEVC special API
*/
#ifndef __VA_FEI_HEVC_H__
#define __VA_FEI_HEVC_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "va_fei.h"
/**
* \defgroup api_fei_hevc HEVC FEI encoding API
*
* @{
*/
/** \brief FEI frame level control buffer for HEVC */
typedef struct _VAEncMiscParameterFEIFrameControlHEVC {
/* one of the VAConfigAttribFEIFunctionType values */
uint32_t function;
/** \brief CTB control input buffer. It is valid only when per_ctb_input
* is set to 1. The data in this buffer correspond to the input source. CTB is in raster scan order,
* each CTB control data structure is defined by VAEncFEICTBControlHEVC.
* Buffer size shall not be less than the number of CTBs multiplied by
* sizeof(VAEncFEICTBControlHEVC).
*/
VABufferID ctb_ctrl;
/** \brief CTB cmd per CTB data output of ENC
* it is reserved for CTB level information
* it should include CU split information and other CTB datas .
* Each CTB block has one CTB cmd data.
*/
VABufferID ctb_cmd;
/** \brief CU record data output of ENC
* it is reserved for CU level information
* it should include CU detail data. include mode,MV, reference etc.
* Each CTB block has one CU record data.
*/
VABufferID cu_record;
/** \brief distortion output of ENC or ENC_PAK.
* Each CTB has one distortion data with VAEncFEIDistortionHevc
* Buffer size shall not be less than the number of CTBs multiplied by
* sizeof(VAEncFEIDistortionHevc).
*/
VABufferID distortion;
/** \brief Qp input buffer. It is valid only when per_block_qp is set to 1.
* The data in this buffer correspond to the input source.
* One Qp per block block is in raster scan order, each Qp is a signed char (8-bit) value.
**/
VABufferID qp;
/** \brief MV predictor. It is valid only when mv_predictor_input is set to non-zero.
* Each CTB block has one or more pair of motion vectors and the corresponding
* reference indexes as defined by VAEncFEIMVPredictorHEVC. 32x32 block is in raster scan order.
* Buffer size shall not be less than the number of 16x16 blocks multiplied by
* sizeof(VAEncFEIMVPredictorHEVC). */
VABufferID mv_predictor;
/** \brief number of MV predictors L0 and L1. the maximum number of motion vector predictor for a 16x16, 32x32 or
* 64x64 block is four, it must not be greater than maximum supported MV predictor,
**/
uint32_t num_mv_predictors_l0 : 16;
uint32_t num_mv_predictors_l1 : 16;
/** \brief control parameters */
uint32_t search_path : 8;
uint32_t len_sp : 8;
uint32_t reserved0 : 16;
/** \brief multi pred l0/1
* 0000: no internal MV predictor will be used
* 0001: spatial MV predictors
* 0100/1000: Reserved
**/
uint32_t multi_pred_l0 : 4;
uint32_t multi_pred_l1 : 4;
/** \brief defines the motion vector precision, like integer/half/quarter pel.
* 00b: integer pel
* 01b: half-pel
* 10b: reserved
* 11b: quarter-pel
*/
uint32_t sub_pel_mode : 2;
uint32_t adaptive_search : 1;
/** \brief mv_predictor_input
* 000: MV predictor disabled
* 001: MV predictor enabled per 16x16 block
* 010: MV predictor enabled per 32x32 block
* 011: MV predictor enabled per 64x64 block
* 111: MV predictor enabled, block size can vary and is determined by BlockSize in motion vector predictor buffer
* 100/101/110: Reserved
**/
uint32_t mv_predictor_input : 3;
/** \brief enables per CTB or CU qp */
uint32_t per_block_qp : 1;
/** \brief enables the per CTB input , if 1, need ctb_ctrl to be a real surface ID*/
uint32_t per_ctb_input : 1;
/** when this flag is set, extra distortion between current CTB and co-located CTB is provided.
* Extra distortion output has performance impact, set it only when it is needed */
uint32_t colocated_ctb_distortion : 1;
/** brief specifies whether this CTB should be forced to split to remove Inter big LCU: do not check Inter 32x32
* PUs. Every 32x32 LCU is split at least once. It can be used to improved performance.
* 0: ENC determined block type
* 1: Force to split
**/
uint32_t force_lcu_split : 1;
/** \brief enables CU64x64 check */
uint32_t enable_cu64_check : 1;
/** \brief enables CU64x64 asymmetric motion partition check */
uint32_t enable_cu64_amp_check : 1;
/** \brief specifies if check the 64x64 merge candidate
* 0: after skip check,
* 1: only skip check for 64x64
Default: 0. This field is used by LCU64 bi-directional.
**/
uint32_t cu64_skip_check_only : 1;
uint32_t reserved1 : 11;
/** specifies the search region width in pixels.
* When bidirectional search is enabled, this applies to both search regions */
uint32_t ref_width : 8;
/** specifies the reference region height in pixels. When bidirectional search is enabled,
* this applies to both search regions. */
uint32_t ref_height : 8;
/** \brief search window similar for AVC
* defines predefined search windows. If it is selected, RefWidth, RefHeight, LenSP and SearchPath are ignored.
* 0 : not use predefined search window
* 1 : Tiny (4 SUs) 24x24 window diamond search
* 2 : Small (9 SUs) 28x28 window diamond search
* 3 : Diamond (16 SUs) 48x40 window diamond search
* 4 : Large Diamond (32 SUs) 48x40 window diamond search
* 5 : Exhaustive 48x40 window full search
* 6 : (64 SUs) 64x64 window full search
* Note: option 1, 2, 3 and 4 are valid only when CAP parameter SearchWindow64Support is 0.
* And option 6 is valid only when SearchWindow64Support is 1.*/
uint32_t search_window : 8;
/** \brief number of internal MV predictors for IME searches */
uint32_t max_num_ime_search_center : 3;
/** \brief fast intra prediction enabling bit. It is used as a trade-off between speed and quality.
* The flag will be ignored if it's unsupported in the driver*/
uint32_t fast_intra_mode : 1;
uint32_t reserved2 : 4;
/** \brief specifies number of splits that encoder could be run concurrently
* 1: level 1, default value
* 2: level 2
* 4: level 3
**/
uint32_t num_concurrent_enc_frame_partition : 8;
uint32_t reserved3 : 24;
/** \brief max frame size control with multi passes QP setting */
uint32_t max_frame_size;
/** \brief number of passes, every pass has different QP */
uint32_t num_passes;
/** \brief delta QP list for every pass */
uint8_t *delta_qp;
uint32_t reserved4[2];
} VAEncMiscParameterFEIFrameControlHEVC;
/** \brief Application can use this definition as reference to allocate the buffer
* based on MaxNumPredictor returned from attribute VAConfigAttribFEIMVPredictors query.
* this buffer allocation is always based on 16x16 block even block size is indicated as 32x32 or 64x64, and buffer
* layout is always in 32x32 block raster scan order even block size is 16x16 or 64x64. If 32x32 block size is set,
* only the data in the first 16x16 block (block 0) is used for 32x32 block. If 64x64 block size is set
* MV layout is still in 32x32 raster scan order, the same as 32x32 and the first 16x16
* block within each 32x32 block needs to have intended MV data (four 32x32 blocks will have the same MV data in the
* correspondent first 16x16 block). Data structure for each 16x16 block is defined as below (same as AVC except
* BlockSize/Reserved bits).
**/
typedef struct _VAEncFEIMVPredictorHEVC {
/** \brief Feference index corresponding to the entry of RefPicList0 & RefPicList1 in slice header (final reference
* list). Note that RefPicList0 & RefPicList1 needs to be the same for all slices.
* Ref0xIndex RefPicList0; Ref1xIndex RefPicList1; x 0 ~ MaxNumPredictor */
struct {
uint8_t ref_idx_l0 : 4;
uint8_t ref_idx_l1 : 4;
} ref_idx[4]; /* index is predictor number */
/** \brief Valid only when MVPredictor is set to 011 for HEVC. Only valid in the first 16x16 block.
* 00: MV predictor disabled for this 32x32 block
* 01: MV predictor enabled per 16x16 block for this 32x32 block
* 10: MV predictor enabled per 32x32 block, the rest of 16x16 block data within this 32x32 block are ignored
* 11: Reserved */
uint32_t block_size : 2;
uint32_t reserved : 30;
VAMotionVector mv[4]; /* MaxNumPredictor is 4 */
} VAEncFEIMVPredictorHEVC; //40 bytes
/** \brief FEI CTB level control data structure */
typedef struct _VAEncFEICTBControlHEVC {
// DWORD 0
uint32_t force_to_intra : 1;
uint32_t force_to_inter : 1;
uint32_t force_to_skip : 1;
/** \brief force all coeff to zero */
uint32_t force_to_zero_coeff : 1;
uint32_t reserved0 : 28;
// DWORD 1
uint32_t reserved1;
// DWORD 2
uint32_t reserved2;
// DWORD 3
uint32_t reserved3;
} VAEncFEICTBControlHEVC;
/** \brief VAEncFEIDistortionHevc defines the data structure for VAEncFEIDistortionBufferType per CTB block.
* It is output buffer of ENC and ENC_PAK modes, The CTB block is in raster scan order.
* Buffer size shall not be less than the number of CTB blocks multiple by sizeof(VAEncFEIDistortionHevc).
**/
typedef struct _VAEncFEIDistortionHevc {
/** best CTB distortion */
uint32_t best_distortion;
/** only when colocated_ctb_distortion in VAEncMiscParameterFEIFrameControlHEVC is set */
uint32_t colocated_ctb_distortion;
} VAEncFEIDistortionHevc;
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,515 @@
/*
* Copyright (c) 2020 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file va_prot.h
* \brief Protected content API.
*
* This file contains the \ref api_prot "Protected content API".
*/
#ifndef VA_PROT_H
#define VA_PROT_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup api_prot Protected content API
*
* @{
* \section prolouge Prolouge
* Video streaming is ubiquitous and the support for video streaming is widely
* available across client open systems such as PCs, MACs, Chromebooks etc. and
* closed systems such as settop box, smart TVs, DVDs etc. By default,
* video streaming is not considered premium due to various constraints such as
* resolution, quality, production cost etc. but recently streaming of premium
* video(1080p+) has become norm. The streaming of premium video in open systems
* such as PCs, MACs, Chromebooks etc. makes video particularly susceptible to
* piracy (due to non-video playback usages of such systems) resulting in
* millions of dollars of loss to content creators.
*
* Digital Rights Management(DRM) has been proposed to stop piracy of premium
* video streams across a wide spectrum. There are some known open/closed DRM
* standards such as [Widevine by Google](https://www.widevine.com/),
* [PlayReady by Microsoft](https://www.microsoft.com/playready/),
* [FairPlay by Apple](https://developer.apple.com/streaming/fps/),
* [Merlin by Sony](https://www.marlin-community.com/), etc... Each DRM
* standard has its properties but all DRM standards support a common
* mechanism. This common mechanism involves cryptographical method for
* authenticating the client system, delivering bitstream and required
* cryptographic assets to client system and then cryptographically processing
* bitstream in client system. The cryptographic methods used in these steps
* are asymmetric such as RSA, DH etc. and symmetric such as AES CTR, CBC etc.
* encryption mechanisms. The authentication of client system, delivery of
* bitstream and cryptographic assets to client system is performed using
* asymmetric cryptographic mechanism while bitstream is encrypted and processed
* using symmetric cryptographic. In DRM world, authentication of client system,
* delivery of bitstream and required cryptographic assets to client system is
* loosely called provisioning and license acquisition while the processing of
* cryptographically secure bitstream is divided as video decryption/decoding,
* audio decryption/playback, video display. Besides DRM standards, Video/Audio
* bitstream encryption standard such as
* [Common Encryption Standard(CENC)](https://www.iso.org/standard/76597.html)
* provides a mechanism to normalize bitstream encryption methods across vendors
* while providing flexibility.
*
* \section DRM Pipeline
* Most DRM standards execute the following deep pipeline to playback
* contents on client systems from streaming servers - provisioning uses
* provisioning servers, licence aquisition uses license servers, video
* bitstream delivery uses content servers and decryption/decoding, audio
* bitstream delivery uses content servers and decyption/playback,
* display/playback. The system level HWDRM sequence diagram is following -
* ![HWDRM sequence diagram](https://user-images.githubusercontent.com/75039699/102427278-df284e80-3fc5-11eb-9a3e-129b5f6b567a.png)
* and HWDRM pipeline view is following -
* ![HWDRM pipeline view](https://user-images.githubusercontent.com/75039699/102427357-04b55800-3fc6-11eb-8b8c-f34fc44ec061.png)
*
* \section LibVA Protected Content APIs
* The LibVA Protected APIs are designed to enable DRM capabilities or
* facilitate isolated communicaiton with TEE.
* The VAEntrypointProtectedTEEComm is to define interfaces for Application
* to TEE direct communication to perform various TEE centric operations
* such as standalone provisioning of platform at factory or provisioning
* TEE for other usages, providing TEE capabilities etc.
* The VAEntrypointProtectedContent is to define interfaces for protected
* video playback using HWDRM. This entry point co-ordinates assets across
* TEE/GPU/Display for HWDRM playback.
*
* The difference between Protected Content and Protected TEE Communication
* is that Protected Content Entrypoint does not provide isolated entry
* point for TEE and invokes TEE only from HWDRM perspective.
*
* Protected Content Entrypoint
* The most of DRM standards execute following deep pipeline to playback
* contents on client systems from streaming servers - provisioning uses
* provisioning servers, licence aquisition uses license servers, video
* bitstream delivery uses content servers and decryption/decoding, audio
* bitstream delivery uses content servers and decyption/playback,
* display/playback.
*
* The Provisioning and License aquisition implementations are Independent
* Hardware Vendor (IHV) specific but most IHVs use some form of Trusted
* Execution Environment (TEE) to prepare client platform or system for DRM
* content playback. The provisioning operations use provisioning servers (as
* instructed in DRM standard) and client system TEE. The communication between
* provisioning servers and client system TEE uses asymmetic cryptographic
* mechanism. This step provides a way to establish root-of-trust between
* client system and streaming servers. Once root-of-trust is established then
* client system requests for license aquisition for a particular streaming
* title. The license aquisition involves communication between licensing
* servers and TEE using asymmetic cryptographic mechanism. At end of this step,
* client system TEE has required assets to decrypt/decode. Although these
* communication does not direcly involve video aspect of GPU but **facilitate
* GPU required assets to playback premium contents**.
*
* To support DRM standard requirements in playback pipeline, OSes and HWs
* incorporate various methods to protect full playback pipeline. These
* methods of protection could be SW based or HW based. The SW based protection
* mechanism of DRMs is called SWDRM while HW based protection mechanism is
* called HWDRM. There is no previous support in LibVA to support either DRM
* mechanism.
*
* For DRM capabilities, APIs inolve creation of protected session to
* communicate with TEE and then using these protected sessions to process
* video/audio data. The philophashy behind these API is to leverage existing
* LibVA infrastructure as much as possible.
*
* Note: TEE could be any secure HW device such as ME-FW or FPGA Secure
* Enclave or NPU Secure Enclave. There are 2 concepts here TEE Type such
* as ME-FW or FPGA or NPU; TEE Type Client such as for AMT or HDCP or
* something else etc.
*
* \section description Detailed Description
* The Protected content API provides a general mechanism for opening
* protected session with TEE and if required then \ref priming GPU/Display.
* The behavior of protected session API depends on parameterization/
* configuration of protected session. Just for TEE tasks, protected
* session is parameterized/configured as TEE Communication while for
* HWDRM, protected session is parameterized/confgured as Protected
* Content.
*
* TEE Communication Entrypoint
* With TEE Communication parameterization/configuration, client
* executes TEE workloads in TEE with TEE Communication protected
* session.
*
* Protected Content Entrypoint
* With Protected Content parameterization/configuration, client
* executes HWDRM playback workloads HW accelerating protected video
* content decryption/decoding with protected content session.
*
* Before calling vaCreateProtectedSession, VAConfigID is obtained using
* existing libva mechanism to determine configuration parameters of
* protected session. The VAConfigID is determined in this way so that
* Protected Session implementation aligns with existing libva implementation.
* After obtaining VAConfigID, Protected Session needs to be created but
* note this is a session and not a context. Refer VAProtectedSessionID
* for more details.
*
* Note:- Protected session represents session object that has all security
* information needed for Secure Enclave to operate certain operations.
*
* \subsection priming Priming
* Priming is used to refer various types of initializations. For example,
* if license acquisition is being performed then priming means that TEE is
* already provisioned aka TEE has some sort of "cryptographic" whitelist of
* servers that TEE will use to do license acquisition for video playback. If
* HWDRM video playback is being performed then priming means that HWDRM
* eco-system TEE/GPU/Display has proper keys to do proper video playback etc.
*
* Protected content API uses the following paradigm for protected content
* session:
* - \ref api_pc_caps
* - \ref api_pc_setup
* - \ref api_pc_exec
* - \ref api_pc_attach
*
* \subsection api_pc_caps Query for supported cipher mode, block size, mode
*
* Checking whether protected content is supported can be performed with
* vaQueryConfigEntrypoints() and the profile argument set to
* #VAProfileProtected. If protected content is supported, then the list of
* returned entry-points will include #VAEntrypointProtectedContent
*
* \code
* VAEntrypoint *entrypoints;
* int i, num_entrypoints, supportsProtectedContent = 0;
*
* num_entrypoints = vaMaxNumEntrypoints();
* entrypoints = malloc(num_entrypoints * sizeof(entrypoints[0]);
* vaQueryConfigEntrypoints(va_dpy, VAProfileProtected, entrypoints,
* &num_entrypoints);
*
* for (i = 0; !supportsProtectedContent && i < num_entrypoints; i++) {
* if (entrypoints[i] == VAEntrypointProtectedContent)
* supportsProtectedContent = 1;
* }
* \endcode
*
* Then, the vaGetConfigAttributes() function is used to query the protected
* session capabilities.
*
* \code
* VAConfigAttrib attribs;
* attribs[0].type = VAConfigAttribProtectedContentCipherAlgorithm;
* attribs[1].type = VAConfigAttribProtectedContentCipherBlockSize;
* attribs[2].type = VAConfigAttribProtectedContentCipherMode;
* attribs[3].type = VAConfigAttribProtectedContentCipherSampleType;
* attribs[4].type = VAConfigAttribProtectedContentUsage;
* vaGetConfigAttributes(va_dpy, VAProfileProtected,
* VAEntrypointProtectedContent, attribs, 5);
* if ((attribs[1].value & VA_PC_CIPHER_AES) == 0) {
* // not find desired cipher algorithm
* assert(0);
* }
* if ((attribs[2].value & VA_PC_BLOCK_SIZE_128) == 0) {
* // not find desired block size
* assert(0);
* }
* if ((attribs[3].value & VA_PC_CIPHER_MODE_CBC) == 0) {
* // not find desired counter mode
* assert(0);
* }
* if ((attribs[4].value & VA_PC_SAMPLE_TYPE_SUBSAMPLE) == 0) {
* // not find desired sample type
* assert(0);
* }
* if ((attribs[5].value & VA_PC_USAGE_WIDEVINE) == 0) {
* // not find desired usage
* assert(0);
* }
* \endcode
*
* \subsection api_pc_setup Set up a protected content session
*
* TEE Communication Entrypoint
* The protected content session provides a TEE session that is used to extract
* TEE information. This information could be used to peform TEE operations.
*
* Protected Content Entrypoint
* The protected content session can be attached to VA decode/encode/vp context
* to do decryption/protection in the pipeline.
* Before creating a protected content session, it needs to create a config
* first via vaCreateConfig(). Then using this config id to create a protected
* content session via vaCreateProtectedSession().
*
* The general control flow is demonstrated by the following pseudo-code:
* \code
* // Create config
* VAConfigID config_id;
*
* attribs[0].value = VA_PC_CIPHER_AES;
* attribs[1].value = VA_PC_BLOCK_SIZE_128;
* attribs[2].value = VA_PC_CIPHER_MODE_CBC;
* attribs[3].value = VA_PC_SAMPLE_TYPE_SUBSAMPLE;
* attribs[4].value = VA_PC_USAGE_WIDEVINE;
* va_status = vaCreateConfig(va_dpy, VAProfileProtected,
* VAEntrypointProtectedContent, attribs, 5, &config_id);
* CHECK_VASTATUS(va_status, "vaCreateConfig");
* \endcode
*
* Once the config is set up, we can create protected content session via
vaCreateProtectedSession().
* \code
* // Create a protected session
* VAProtectedSessionID crypto_session;
*
* va_status = vaCreateProtectedSession(va_dpy, config_id, &crypto_session);
* CHECK_VASTATUS(va_status, "vaCreateProtectedSession");
* \endcode
*
* \subsection api_pc_exec TEE communication via vaProtectedSessionExecute()
*
* TEE Communication Entrypoint
* App needs to communicate with TEE to get TEE information or \ref priming
* "prime" TEE with information that will be utilized for future TEE
* operations/tasks.
*
* Protected Content Entrypoint
* Before starting decryption/encryption operation in GPU, app may need to
* communicate with TEE to get encrypted assets for \ref priming HWDRM pipeline
* for decryption. App need to call vaProtectedSessionExecute() to get this
* asset. The following pseudo-code demonstrates getting session assets via
* vaProtectedSessionExecute() as an example.
*
* In this example, the vaCreateBuffer is called with exec_buffer mainly becasue TEE
* Communication Entrypoint buffers are CPU bound and buffer size is small enough to
* have extra copy operation without impacting performance.
*
* \code
* uint32_t app_id = 0xFF;
* VABufferID buffer;
* VAProtectedSessionExecuteBuffer exec_buff = {0};
*
* exec_buff.function_id = GET_SESSION_ID;
* exec_buff.input.data = nullptr;
* exec_buff.input.data_size = 0;
* exec_buff.output.data = &app_id;
* exec_buff.output.max_data_size = sizeof(app_id);
* va_status = vaCreateBuffer(
* va_dpy,
* crypto_session,
* (VABufferType) VAProtectedSessionExecuteBufferType,
* sizeof(exec_buff),
* 1,
* &exec_buff,
* &buffer);
*
* va_status = vaProtectedSessionExecute(va_dpy, crypto_session, buffer);
*
* vaDestroyBuffer(va_dpy, buffer);
* \endcode
*
* \subsection api_pc_attach Attach/Detach protected content session to the VA
* context which want to enable/disable decryption/protection
*
* Protected content session is attached to VA decode/encode/vp context to
* enable protected decoding/encoding/video processing per frame or entire
* stream. If protected session attached per frame then application has 2
* options for decoding/encoding skip processing i.e. accomodating clear
* frames - 1. Application could do detach after each frame is processed
* to process clear frame 2. Application could remains attached to decode/
* encode session but specify enryption byte length to 0.
* The video processing does not has option #2 mainly because API does
* not provide skip processing.
*
* \code
* vaAttachProtectedSession(va_dpy, decode_ctx, crypto_session);
* foreach (iteration) {
* vaBeginPicture(va_dpy, decode_ctx, surface);
* ...
* vaRenderPicture(va_dpy, decode_ctx, &buf_id1, 1);
* vaRenderPicture(va_dpy, decode_ctx, &buf_id2, 1);
* // Buffer holding encryption parameters, i.e. VAEncryptionParameterBufferType buffer
* vaRenderPicture(va_dpy, decode_ctx, &buf_id_enc_param, 1);
* ...
* vaEndPicture(va_dpy, decode_ctx);
* }
* vaDetachProtectedSession(va_dpy, decode_ctx);
* \endcode
*
* or it could be frame-by-frame attaching/detaching as following:
*
* \code
* foreach (iteration) {
* if (encrypted)
* vaAttachProtectedSession(va_dpy, decode_ctx, crypto_session);
* vaBeginPicture(va_dpy, decode_ctx, surface);
* ...
* vaRenderPicture(va_dpy, decode_ctx, &buf_id1, 1);
* vaRenderPicture(va_dpy, decode_ctx, &buf_id2, 1);
* // Buffer holding encryption parameters, i.e. VAEncryptionParameterBufferType buffer
* vaRenderPicture(va_dpy, decode_ctx, &buf_id_enc_param, 1);
* ...
* vaEndPicture(va_dpy, decode_ctx);
*
* if (encrypted)
* vaDetachProtectedSession(va_dpy, decode_ctx);
* // check encrypted variable for next frame
* }
* \endcode
*/
/**
* ProtectedSessions and Contexts
*
* According to #VAContextID, Context represents a "virtual" video decode,
* encode or video processing pipeline. Surfaces are render targets for a given
* context. The data in the surfaces are not accessible to the client except if
* derived image is supported and the internal data format of the surface is
* implementation specific. Application can create a video decode, encode or
* processing context which represents a "virtualized" hardware device.
*
* Since Protected Session does not virtualize any HW device or build any
* pipeline but rather accessorize existing virtualized HW device or pipeline
* to operate in protected mode so we decided to create separate function.
* Beside this, a virtualized HW device or pipeline could own several protected
* sessions and operate in those protected modes without ever re-creating
* virtualization of HW device or re-building HW pipeline (an unique protected
* environment multiplexing capability in Intel HW).
*
* The returned protected_session represents a notion of Host and TEE clients
* while representing protection status in GPU and Display.
*
* Both contexts and protected sessions are identified by unique IDs and its
* implementation specific internals are kept opaque to the clients
*/
typedef VAGenericID VAProtectedSessionID;
/** \brief TEE Execucte Function ID. */
typedef enum _VA_TEE_EXEC_FUNCTION_ID {
VA_TEE_EXECUTE_FUNCTION_ID_PASS_THROUGH = 0x00000001,
VA_TEE_EXECUTE_FUNCTION_ID_GET_FIRMWARE_VERSION = 0x00000002,
} VA_TEE_EXECUTE_FUNCTION_ID;
/** \brief Input/Output buffer of VAProtectedSessionExecuteBuffer */
typedef struct _VAProtectedSessionBuffer {
/*
* This is used when this buffer refer to output buffer. The maximum size of
* data that the driver can return in the output buffer. It is not used for
* input buffer.
*/
uint32_t max_data_size;
/*
* If it is used for input buffer, it is the size of the input data. If it is
* used for output buffer, it is the returns size of the output data written
* by the driver.
*/
uint32_t data_size;
/*
* data pointer of this buffer
*/
void *data;
uint32_t va_reserved[VA_PADDING_LOW];
} VAProtectedSessionBuffer;
/** \brief Buffer for vaProtectedSessionExecute() */
typedef struct _VAProtectedSessionExecuteBuffer {
/** \brief Specify the function to execute. It is IHV's implementation
* specific */
uint32_t function_id;
/** \brief Input buffer */
VAProtectedSessionBuffer input;
/** \brief Output buffer */
VAProtectedSessionBuffer output;
/** \brief Return the result of this function. The status result is IHV's
* implementation specific */
uint32_t status;
uint32_t va_reserved[VA_PADDING_LOW];
} VAProtectedSessionExecuteBuffer;
/**
* \brief Create a protected session
*
* Create a protected session
*
* @param[in] dpy the VA display
* @param[in] config_id configuration for the protected session
* @param[out] protected_session created protected session id upon return
*/
VAStatus vaCreateProtectedSession(VADisplay dpy, VAConfigID config_id,
VAProtectedSessionID *protected_session);
/**
* \brief Destroy a protected session
*
* Destroy a protected session
*
* @param[in] dpy the VA display
* @param[in] protected_session protected session to be destroyed
*/
VAStatus vaDestroyProtectedSession(VADisplay dpy,
VAProtectedSessionID protected_session);
/**
* \brief Attach a protected content session to VA context
*
* Attach a protected content session to the context to enable
* decryption/protection
*
* @param[in] dpy the VA display
* @param[in] id the VA decode/encode/vp context
* @param[in] protected_session the protected session to attach
*/
VAStatus vaAttachProtectedSession(VADisplay dpy, VAGenericID id,
VAProtectedSessionID protected_session);
/**
* \brief Detach the protected content session from the VA context
*
* Detach protected content session of the context to disable
* decryption/protection
*
* @param[in] dpy the VA display
* @param[in] id TEE client id to be detached
*/
VAStatus vaDetachProtectedSession(VADisplay dpy, VAGenericID id);
/**
* \brief Execute provides a general mechanism for TEE client tasks execution.
*
* vaProtectedSessionExecute provides a mechanism for TEE clients to execute
* specific tasks. The implementation may differ between IHVs.
* This is a synchronous API.
*
* @param[in] dpy the VA display
* @param[in] protected_session the protected session
* @param[in,out] buf_id the VA buffer
*/
VAStatus vaProtectedSessionExecute(VADisplay dpy,
VAProtectedSessionID protected_session,
VABufferID buf_id);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* VA_PROT_H */

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2017 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _VA_STR_H_
#define _VA_STR_H_
#include <va/va.h>
#ifdef __cplusplus
extern "C" {
#endif
const char *vaProfileStr(VAProfile profile);
const char *vaEntrypointStr(VAEntrypoint entrypoint);
const char *vaConfigAttribTypeStr(VAConfigAttribType configAttribType);
const char *vaBufferTypeStr(VABufferType bufferType);
const char *vaStatusStr(VAStatus status);
#ifdef __cplusplus
}
#endif
#endif /* _VA_STR_H_ */

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2007-2009 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _VA_TPI_H_
#define _VA_TPI_H_
#warning The APIs / data structures included in this file are deprecated
#endif

View File

@@ -0,0 +1,87 @@
/*
* Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VA_VERSION_H
#define VA_VERSION_H
/**
* VA_MAJOR_VERSION:
*
* The major version of VA-API (1, if %VA_VERSION is 1.2.3)
*/
#define VA_MAJOR_VERSION 1
/**
* VA_MINOR_VERSION:
*
* The minor version of VA-API (2, if %VA_VERSION is 1.2.3)
*/
#define VA_MINOR_VERSION 14
/**
* VA_MICRO_VERSION:
*
* The micro version of VA-API (3, if %VA_VERSION is 1.2.3)
*/
#define VA_MICRO_VERSION 0
/**
* VA_VERSION:
*
* The full version of VA-API, like 1.2.3
*/
#define VA_VERSION 1.14.0
/**
* VA_VERSION_S:
*
* The full version of VA-API, in string form (suited for string
* concatenation)
*/
#define VA_VERSION_S "1.14.0"
/**
* VA_VERSION_HEX:
*
* Numerically encoded version of VA-API, like 0x010203
*/
#define VA_VERSION_HEX ((VA_MAJOR_VERSION << 24) | \
(VA_MINOR_VERSION << 16) | \
(VA_MICRO_VERSION << 8))
/**
* VA_CHECK_VERSION:
* @major: major version, like 1 in 1.2.3
* @minor: minor version, like 2 in 1.2.3
* @micro: micro version, like 3 in 1.2.3
*
* Evaluates to %TRUE if the version of VA-API is greater than
* @major, @minor and @micro
*/
#define VA_CHECK_VERSION(major,minor,micro) \
(VA_MAJOR_VERSION > (major) || \
(VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION > (minor)) || \
(VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION == (minor) && VA_MICRO_VERSION >= (micro)))
#endif /* VA_VERSION_H */

File diff suppressed because it is too large Load Diff