summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/Makefile.am2
-rwxr-xr-xtest/basic/Android.mk125
-rw-r--r--test/encode/h264encode.c12
-rw-r--r--test/putsurface/Android.mk2
-rwxr-xr-xtest/putsurface/putsurface_common.c98
-rw-r--r--test/vainfo/vainfo.c26
-rw-r--r--test/videoprocess/Makefile.am37
-rw-r--r--test/videoprocess/process.cfg76
-rw-r--r--test/videoprocess/videoprocess.cpp1118
-rwxr-xr-xva/Android.mk51
-rw-r--r--va/Makefile.am2
-rwxr-xr-xva/va.c52
-rwxr-xr-xva/va.h119
-rw-r--r--va/va_android.h3
-rwxr-xr-xva/va_backend.h2
-rw-r--r--va/va_backend_tpi.h4
-rw-r--r--va/va_dec_hevc.h501
-rw-r--r--va/va_dec_jpeg.h4
-rw-r--r--va/va_dec_vp8.h25
-rwxr-xr-xva/va_dec_vp9.h308
-rw-r--r--va/va_enc_h264.h148
-rw-r--r--va/va_fool.c98
-rw-r--r--va/va_fool.h17
-rw-r--r--va/va_tpi.h2
-rwxr-xr-xva/va_trace.c647
-rw-r--r--va/va_vpp.h32
-rw-r--r--va/vendor/intel/va_intel_statistics.h13
27 files changed, 2856 insertions, 668 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 14d7612..df215b6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -20,7 +20,7 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-SUBDIRS = common decode encode vainfo
+SUBDIRS = common decode encode vainfo videoprocess
if USE_X11
SUBDIRS += basic putsurface transcode
endif
diff --git a/test/basic/Android.mk b/test/basic/Android.mk
index 1755ec9..e5b3a59 100755
--- a/test/basic/Android.mk
+++ b/test/basic/Android.mk
@@ -1,3 +1,7 @@
+LIBVA_TESTS_SHARED_LIBS := libva-android libva libdl libdrm libcutils libutils
+LIBVA_TESTS_CFLAGS := -DANDROID -Wno-unused-parameter
+LIBVA_TESTS_C_INCLUDES := $(TARGET_OUT_HEADERS)/libva
+
# For test_01
# =====================================================
@@ -8,17 +12,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_01.c \
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS := $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_001
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
@@ -29,17 +28,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_02.c \
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS += $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_02_android
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
@@ -50,17 +44,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_03.c \
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS += $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_03_android
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
@@ -71,17 +60,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_04.c \
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS += $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_04_android
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
@@ -92,17 +76,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_05.c \
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS += $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_05_android
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
@@ -113,17 +92,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_06.c \
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS += $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_06_android
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
@@ -134,17 +108,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_07.c \
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS += $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_07_android
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
@@ -155,17 +124,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_08.c \
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS += $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_08_android
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
@@ -176,17 +140,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_09.c \
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS += $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_09_android
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
@@ -197,17 +156,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_10.c
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS += $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_10_android
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
@@ -218,17 +172,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
test_11.c
-LOCAL_CFLAGS += \
- -DANDROID
-
-LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/vendor/intel/hardware/libva/va/
-
+LOCAL_CFLAGS += $(LIBVA_TESTS_CFLAGS)
+LOCAL_C_INCLUDES := $(LIBVA_TESTS_C_INCLUDES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := test_11_android
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger
+LOCAL_SHARED_LIBRARIES := $(LIBVA_TESTS_SHARED_LIBS)
include $(BUILD_EXECUTABLE)
diff --git a/test/encode/h264encode.c b/test/encode/h264encode.c
index b862393..7da2154 100644
--- a/test/encode/h264encode.c
+++ b/test/encode/h264encode.c
@@ -917,8 +917,8 @@ static int process_cmdline(int argc, char *argv[])
static int init_va(void)
{
VAProfile profile_list[]={VAProfileH264High,VAProfileH264Main,VAProfileH264Baseline,VAProfileH264ConstrainedBaseline};
- VAEntrypoint entrypoints[VAEntrypointMax]={0};
- int num_entrypoints,slice_entrypoint;
+ VAEntrypoint *entrypoints;
+ int num_entrypoints, slice_entrypoint;
int support_encode = 0;
int major_ver, minor_ver;
VAStatus va_status;
@@ -928,6 +928,13 @@ static int init_va(void)
va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
CHECK_VASTATUS(va_status, "vaInitialize");
+ num_entrypoints = vaMaxNumEntrypoints(va_dpy);
+ entrypoints = malloc(num_entrypoints * sizeof(*entrypoints));
+ if (!entrypoints) {
+ fprintf(stderr, "error: failed to initialize VA entrypoints array\n");
+ exit(1);
+ }
+
/* use the highest profile */
for (i = 0; i < sizeof(profile_list)/sizeof(profile_list[0]); i++) {
if ((h264_profile != ~0) && h264_profile != profile_list[i])
@@ -1101,6 +1108,7 @@ static int init_va(void)
printf("Support VAConfigAttribEncMacroblockInfo\n");
}
+ free(entrypoints);
return 0;
}
diff --git a/test/putsurface/Android.mk b/test/putsurface/Android.mk
index 03edb61..628492d 100644
--- a/test/putsurface/Android.mk
+++ b/test/putsurface/Android.mk
@@ -10,7 +10,7 @@ LOCAL_SRC_FILES := \
#putsurface_x11.c
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID -Wno-unused-parameter
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva
diff --git a/test/putsurface/putsurface_common.c b/test/putsurface/putsurface_common.c
index e52bf45..d7d7003 100755
--- a/test/putsurface/putsurface_common.c
+++ b/test/putsurface/putsurface_common.c
@@ -8,11 +8,11 @@
* 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.
@@ -89,7 +89,7 @@ static VASurfaceID csc_render_surface;
typedef struct {
- char * fmt_str;
+ const char * fmt_str;
unsigned int fourcc;
} fourcc_map;
fourcc_map va_fourcc_map[] = {
@@ -114,7 +114,7 @@ unsigned int map_str_to_vafourcc (char * str)
return 0;
}
-char* map_vafourcc_to_str (unsigned int format)
+const char* map_vafourcc_to_str (unsigned int format)
{
static char unknown_format[] = "unknown-format";
unsigned int i;
@@ -161,7 +161,7 @@ ensure_image_formats(void)
if (num_image_formats == 0)
return 0;
- image_formats = malloc(num_image_formats * sizeof(*image_formats));
+ image_formats = (VAImageFormat *) malloc(num_image_formats * sizeof(*image_formats));
if (!image_formats)
return 0;
@@ -210,7 +210,7 @@ ensure_surface_attribs(void)
/* Guess the number of surface attributes, thus including any
pixel-format supported by the VA driver */
num_surface_attribs = VASurfaceAttribCount + num_image_formats;
- surface_attribs = malloc(num_surface_attribs * sizeof(*surface_attribs));
+ surface_attribs = (VASurfaceAttrib *) malloc(num_surface_attribs * sizeof(*surface_attribs));
if (!surface_attribs)
return 0;
@@ -219,7 +219,7 @@ ensure_surface_attribs(void)
if (va_status == VA_STATUS_SUCCESS)
va_surface_attribs = surface_attribs;
else if (va_status == VA_STATUS_ERROR_MAX_NUM_EXCEEDED) {
- va_surface_attribs = realloc(surface_attribs,
+ va_surface_attribs = (VASurfaceAttrib *) realloc(surface_attribs,
num_surface_attribs * sizeof(*va_surface_attribs));
if (!va_surface_attribs) {
free(surface_attribs);
@@ -256,7 +256,8 @@ lookup_surface_attrib(VASurfaceAttribType type, const VAGenericValue *value)
int csc_preparation ()
{
VAStatus va_status;
-
+ VASurfaceAttrib surface_attribs[1], * const s_attrib = &surface_attribs[0];
+
// 1. make sure dst fourcc is supported for vaImage
if (!lookup_image_format(csc_dst_fourcc)) {
test_color_conversion = 0;
@@ -265,7 +266,6 @@ int csc_preparation ()
}
// 2. make sure src_fourcc is supported for vaSurface
- VASurfaceAttrib surface_attribs[1], * const s_attrib = &surface_attribs[0];
s_attrib->type = VASurfaceAttribPixelFormat;
s_attrib->flags = VA_SURFACE_ATTRIB_SETTABLE;
s_attrib->value.type = VAGenericValueTypeInteger;
@@ -292,18 +292,18 @@ int csc_preparation ()
image_format.fourcc = csc_dst_fourcc;
image_format.byte_order = VA_LSB_FIRST;
image_format.bits_per_pixel = 16;
-
+
va_status = vaCreateImage(va_dpy, &image_format,
surface_width, surface_height,
&csc_dst_fourcc_image);
CHECK_VASTATUS(va_status,"vaCreateImage");
-
+
// 3.3 create a temp VASurface for final rendering(vaPutSurface)
s_attrib->value.value.i = VA_FOURCC_NV12;
- va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420,
+ va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420,
surface_width, surface_height,
- &csc_render_surface, 1,
+ &csc_render_surface, 1,
surface_attribs, 1);
CHECK_VASTATUS(va_status,"vaCreateSurfaces");
@@ -328,7 +328,7 @@ static VASurfaceID get_next_free_surface(int *index)
return surface_id[i];
}
-
+
for (i=0; i<SURFACE_NUM; i++) {
surface_status = (VASurfaceStatus)0;
vaQuerySurfaceStatus(va_dpy, surface_id[i], &surface_status);
@@ -356,11 +356,11 @@ static int upload_source_YUV_once_for_all()
int box_width_loc=8;
int row_shift_loc=0;
int i;
-
+
for (i=0; i<SURFACE_NUM; i++) {
printf("\rLoading data into surface %d.....", i);
upload_surface(va_dpy, surface_id[i], box_width_loc, row_shift_loc, 0);
-
+
row_shift_loc++;
if (row_shift_loc==(2*box_width_loc)) row_shift_loc= 0;
}
@@ -384,9 +384,9 @@ static void update_clipbox(VARectangle *cliprects, int width, int height)
{
if (test_clip == 0)
return;
-
+
srand((unsigned)time(NULL));
-
+
cliprects[0].x = (rand() % width);
cliprects[0].y = (rand() % height);
cliprects[0].width = (rand() % (width - cliprects[0].x));
@@ -412,16 +412,16 @@ static void* putsurface_thread(void *data)
unsigned int frame_num=0, start_time, putsurface_time;
VARectangle cliprects[2]; /* client supplied clip list */
int continue_display = 0;
-
+
if (drawable == drawable_thread0)
printf("Enter into thread0\n\n");
if (drawable == drawable_thread1)
printf("Enter into thread1\n\n");
-
+
putsurface_time = 0;
while (!quit) {
VASurfaceID surface_id = VA_INVALID_SURFACE;
-
+
while (surface_id == VA_INVALID_SURFACE)
surface_id = get_next_free_surface(&index);
@@ -432,9 +432,9 @@ static void* putsurface_thread(void *data)
if (check_event)
pthread_mutex_lock(&gmutex);
-
+
start_time = get_tick_count();
- if ((continue_display == 0) && getenv("FRAME_STOP")) {
+ if ((continue_display == 0) && getenv("FRAME_STOP")) {
char c;
printf("Press any key to display frame %d...(c/C to continue)\n", frame_num);
c = getchar();
@@ -447,13 +447,13 @@ static void* putsurface_thread(void *data)
printf("do additional colorcoversion from %s to %s\n", map_vafourcc_to_str(csc_src_fourcc), map_vafourcc_to_str(csc_dst_fourcc));
}
// get image from surface, csc_src_fourcc to csc_dst_fourcc conversion happens
- vaStatus = vaGetImage(va_dpy, surface_id, 0, 0,
+ vaStatus = vaGetImage(va_dpy, surface_id, 0, 0,
surface_width, surface_height, csc_dst_fourcc_image.image_id);
CHECK_VASTATUS(vaStatus,"vaGetImage");
-
+
// render csc_dst_fourcc image to temp surface
vaStatus = vaPutImage(va_dpy, csc_render_surface, csc_dst_fourcc_image.image_id,
- 0, 0, surface_width, surface_height,
+ 0, 0, surface_width, surface_height,
0, 0, surface_width, surface_height);
CHECK_VASTATUS(vaStatus,"vaPutImage");
@@ -475,20 +475,20 @@ static void* putsurface_thread(void *data)
display_field);
CHECK_VASTATUS(vaStatus,"vaPutSurface");
}
-
+
putsurface_time += (get_tick_count() - start_time);
-
+
if (check_event)
pthread_mutex_unlock(&gmutex);
-
+
pthread_mutex_unlock(&surface_mutex[index]); /* locked in get_next_free_surface */
-
+
if ((frame_num % 0xff) == 0) {
fprintf(stderr, "%.2f FPS \r", 256000.0 / (float)putsurface_time);
putsurface_time = 0;
update_clipbox(cliprects, width, height);
}
-
+
if (check_event)
check_window_event(win_display, drawable, &width, &height, &quit);
@@ -496,7 +496,7 @@ static void* putsurface_thread(void *data)
row_shift++;
if (row_shift==(2*box_width)) row_shift= 0;
}
-
+
if (frame_rate != 0) /* rough framerate control */
usleep(1000/frame_rate*1000);
@@ -504,10 +504,10 @@ static void* putsurface_thread(void *data)
if (frame_num >= frame_num_total)
quit = 1;
}
-
- if (drawable == drawable_thread1)
+
+ if (drawable == drawable_thread1)
pthread_exit(NULL);
-
+
return 0;
}
int main(int argc,char **argv)
@@ -595,8 +595,8 @@ int main(int argc,char **argv)
case '1':
sscanf(optarg, "%s", str_src_fmt);
csc_src_fourcc = map_str_to_vafourcc (str_src_fmt);
-
- if (!csc_src_fourcc) {
+
+ if (!csc_src_fourcc) {
printf("invalid fmt1: %s\n", str_src_fmt );
exit(0);
}
@@ -604,8 +604,8 @@ int main(int argc,char **argv)
case '2':
sscanf(optarg, "%s", str_dst_fmt);
csc_dst_fourcc = map_str_to_vafourcc (str_dst_fmt);
-
- if (!csc_dst_fourcc) {
+
+ if (!csc_dst_fourcc) {
printf("invalid fmt1: %s\n", str_dst_fmt );
exit(0);
}
@@ -620,7 +620,7 @@ int main(int argc,char **argv)
if (csc_src_fourcc && csc_dst_fourcc) {
test_color_conversion = 1;
}
-
+
win_display = (void *)open_display();
if (win_display == NULL) {
fprintf(stderr, "Can't open the connection of display!\n");
@@ -642,23 +642,23 @@ int main(int argc,char **argv)
&surface_id[0], SURFACE_NUM,
NULL, 0
);
- }
+ }
CHECK_VASTATUS(va_status, "vaCreateSurfaces");
if (multi_thread == 0) /* upload the content for all surfaces */
upload_source_YUV_once_for_all();
-
+
if (check_event)
pthread_mutex_init(&gmutex, NULL);
-
+
for(i = 0; i< SURFACE_NUM; i++)
pthread_mutex_init(&surface_mutex[i], NULL);
-
- if (multi_thread == 1)
+
+ if (multi_thread == 1)
ret = pthread_create(&thread1, NULL, putsurface_thread, (void*)drawable_thread1);
putsurface_thread((void *)drawable_thread0);
- if (multi_thread == 1)
+ if (multi_thread == 1)
pthread_join(thread1, (void **)&ret);
printf("thread1 is free\n");
@@ -666,7 +666,7 @@ int main(int argc,char **argv)
// destroy temp surface/image
va_status = vaDestroySurfaces(va_dpy, &csc_render_surface, 1);
CHECK_VASTATUS(va_status,"vaDestroySurfaces");
-
+
va_status = vaDestroyImage(va_dpy, csc_dst_fourcc_image.image_id);
CHECK_VASTATUS(va_status,"vaDestroyImage");
}
@@ -676,12 +676,12 @@ int main(int argc,char **argv)
vpp_config_id = VA_INVALID_ID;
}
- vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM);
+ vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM);
vaTerminate(va_dpy);
free(va_image_formats);
free(va_surface_attribs);
close_display(win_display);
-
+
return 0;
}
diff --git a/test/vainfo/vainfo.c b/test/vainfo/vainfo.c
index 3543d80..e18eb5f 100644
--- a/test/vainfo/vainfo.c
+++ b/test/vainfo/vainfo.c
@@ -32,7 +32,8 @@
#define CHECK_VASTATUS(va_status,func, ret) \
if (va_status != VA_STATUS_SUCCESS) { \
fprintf(stderr,"%s failed with error code %d (%s),exit\n",func, va_status, vaErrorStr(va_status)); \
- exit(ret); \
+ ret_val = ret; \
+ goto error; \
}
static char * profile_string(VAProfile profile)
@@ -88,9 +89,11 @@ int main(int argc, const char* argv[])
int major_version, minor_version;
const char *driver;
const char *name = strrchr(argv[0], '/');
- VAProfile profile;
+ VAProfile profile, *profile_list = NULL;
+ int num_profiles, max_num_profiles, i;
VAEntrypoint entrypoint, entrypoints[10];
int num_entrypoint;
+ int ret_val = 0;
if (name)
name++;
@@ -114,9 +117,22 @@ int main(int argc, const char* argv[])
printf("%s: Driver version: %s\n", name, driver ? driver : "<unknown>");
printf("%s: Supported profile and entrypoints\n", name);
- for (profile = VAProfileNone; profile <= VAProfileVP8Version0_3; profile++) {
+ max_num_profiles = vaMaxNumProfiles(va_dpy);
+ profile_list = malloc(max_num_profiles * sizeof(VAProfile));
+
+ if (!profile_list) {
+ printf("Failed to allocate memory for profile list\n");
+ ret_val = 5;
+ goto error;
+ }
+
+ va_status = vaQueryConfigProfiles(va_dpy, profile_list, &num_profiles);
+ CHECK_VASTATUS(va_status, "vaQueryConfigProfiles", 6);
+
+ for (i = 0; i < num_profiles; i++) {
char *profile_str;
+ profile = profile_list[i];
va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints,
&num_entrypoint);
if (va_status == VA_STATUS_ERROR_UNSUPPORTED_PROFILE)
@@ -129,8 +145,10 @@ int main(int argc, const char* argv[])
printf(" %-32s: %s\n", profile_str, entrypoint_string(entrypoints[entrypoint]));
}
+error:
+ free(profile_list);
vaTerminate(va_dpy);
va_close_display(va_dpy);
- return 0;
+ return ret_val;
}
diff --git a/test/videoprocess/Makefile.am b/test/videoprocess/Makefile.am
new file mode 100644
index 0000000..969b5a6
--- /dev/null
+++ b/test/videoprocess/Makefile.am
@@ -0,0 +1,37 @@
+# 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 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.
+
+noinst_PROGRAMS = videoprocess
+
+INCLUDES = -I$(top_srcdir) \
+ -I$(top_srcdir)/test/common \
+ $(NULL)
+
+videoprocess_SOURCES = videoprocess.cpp
+videoprocess_LDADD = $(top_builddir)/va/libva.la \
+ $(top_builddir)/test/common/libva-display.la \
+ $(NULL)
+
+valgrind:(noinst_PROGRAMS)
+ for a in(noinst_PROGRAMS); do \
+ valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
+ done
diff --git a/test/videoprocess/process.cfg b/test/videoprocess/process.cfg
new file mode 100644
index 0000000..a11a0a4
--- /dev/null
+++ b/test/videoprocess/process.cfg
@@ -0,0 +1,76 @@
+#Configuration information for video process test case.
+# This application will firstly loads frames(yv12 format in file) to one type of
+#surface(NV12/YV12/I420) you require, after video processing ,the processed content
+#(NV12/YV12/I420 surface) will be stored to frames(yv12 format in file).
+# Supported features including: denoise, deinterlacing, sharpening, color balance,
+# blending and implicit format conversion(NV12<->YV12<->I420), each time only one
+# kind of processing will be executed in test application, although libva supports
+# multiply filters execution in one time. you can modify this configure to set the
+# filter and the corresponding parameters.
+
+#1.Source YUV(RGB) file information
+SRC_FILE_NAME: /root/clips/YUV/bus_cif.yv12
+SRC_FRAME_WIDTH: 352
+SRC_FRAME_HEIGHT: 288
+SRC_FRAME_FORMAT: NV12
+
+#2.Destination YUV(RGB) file information
+DST_FILE_NAME: ./bus_cif_deinterlacing.yv12
+DST_FRAME_WIDTH: 352
+DST_FRAME_HEIGHT: 288
+DST_FRAME_FORMAT: NV12
+
+#3.How many frames to be processed
+FRAME_SUM: 10
+
+#4.VPP filter type and parameters, the following filters are supported:
+ #(VAProcFilterNone,VAProcFilterNoiseReduction,VAProcFilterDeinterlacing,
+ # VAProcFilterSharpening,VAProcFilterColorBalance,
+ # defalut VAProcFilterNone)
+FILTER_TYPE: VAProcFilterDeinterlacing
+
+#5.VPP filter specific parameters. If they are not specified here,
+#default value will be applied then.
+
+#5.1 Denoise filter paramters
+ #(0.0 ~ 1.0, default 0.5)
+DENOISE_INTENSITY: 0.75
+
+#5.2 Deinterlacding parameters
+ #(VAProcDeinterlacingBob, VAProcDeinterlacingWeave,
+ # VAProcDeinterlacingMotionAdaptive, VAProcDeinterlacingMotionCompensated,
+ # default: VAProcDeinterlacingBob)
+DEINTERLACING_ALGORITHM: VAProcDeinterlacingBob
+
+ #(VA_DEINTERLACING_BOTTOM_FIELD_FIRST |
+ # VA_DEINTERLACING_BOTTOM_FIELD |
+ # VA_DEINTERLACING_ONE_FIELD, defalut 0)
+DEINTERLACING_FLAGS: 0
+
+#5.3 Sharpening parameters
+ # (0.0 ~ 1.0, default 0.5)
+SHARPENING_INTENSITY: 0.75
+
+#5.4 Blending
+ # (0, 1, default 0)
+BLENDING_ENABLED: 0
+ # (VA_BLEND_GLOBAL_ALPHA |
+ # VA_BLEND_LUMA_KEY, defalut 0)
+BLENDING_FLAGS: VA_BLEND_GLOBAL_ALPHA
+ # (0.0 ~ 1.0, default 0.5)
+BLENDING_GLOBAL_ALPHA: 0.5
+ # (1 ~ 254, defalut 1)
+BLENDING_MIN_LUMA: 1
+ # (1 ~ 254, defalut 254)
+BLENDING_MAX_LUMA: 254
+
+#5.5 Color balance parameters
+ #(-180 ~ 180, default 0)
+COLOR_BALANCE_HUE: 0
+ #(0.0 ~ 10.0, default 1.0)
+COLOR_BALANCE_SATURATION: 1.0
+ #(-100 ~ 100, default 0)
+COLOR_BALANCE_BRIGHTNESS: 20
+ #(0.0 ~ 10.0, default 1.0)
+COLOR_BALANCE_CONTRAST: 1.2
+
diff --git a/test/videoprocess/videoprocess.cpp b/test/videoprocess/videoprocess.cpp
new file mode 100644
index 0000000..855fa14
--- /dev/null
+++ b/test/videoprocess/videoprocess.cpp
@@ -0,0 +1,1118 @@
+/*
+ * 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.
+ */
+/*
+ * Video process test case based on LibVA.
+ * This test covers deinterlace, denoise, color balance, sharpening,
+ * blending, scaling and several surface format conversion.
+ * Usage: videoprocess process.cfg
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <sys/time.h>
+#include <assert.h>
+#include <va/va.h>
+#include <va/va_vpp.h>
+#include "va_display.h"
+
+#ifndef VA_FOURCC_I420
+#define VA_FOURCC_I420 0x30323449
+#endif
+
+#define MAX_LEN 1024
+
+#define CHECK_VASTATUS(va_status,func) \
+ if (va_status != VA_STATUS_SUCCESS) { \
+ fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \
+ exit(1); \
+ }
+
+static VADisplay va_dpy = NULL;
+static VAContextID context_id = 0;
+static VAConfigID config_id = 0;
+static VAProcFilterType g_filter_type = VAProcFilterNone;
+static VASurfaceID g_in_surface_id = VA_INVALID_ID;
+static VASurfaceID g_out_surface_id = VA_INVALID_ID;
+
+static FILE* g_config_file_fd = NULL;
+static FILE* g_src_file_fd = NULL;
+static FILE* g_dst_file_fd = NULL;
+
+static char g_config_file_name[MAX_LEN];
+static char g_src_file_name[MAX_LEN];
+static char g_dst_file_name[MAX_LEN];
+static char g_filter_type_name[MAX_LEN];
+
+static uint32_t g_in_pic_width = 352;
+static uint32_t g_in_pic_height = 288;
+static uint32_t g_out_pic_width = 352;
+static uint32_t g_out_pic_height = 288;
+
+static uint32_t g_in_fourcc = VA_FOURCC('N', 'V', '1', '2');
+static uint32_t g_in_format = VA_RT_FORMAT_YUV420;
+static uint32_t g_out_fourcc = VA_FOURCC('N', 'V', '1', '2');
+static uint32_t g_out_format = VA_RT_FORMAT_YUV420;
+
+static uint8_t g_blending_enabled = 0;
+static uint8_t g_blending_min_luma = 1;
+static uint8_t g_blending_max_luma = 254;
+
+static uint32_t g_frame_count = 0;
+
+static int8_t
+read_value_string(FILE *fp, const char* field_name, char* value)
+{
+ char strLine[MAX_LEN];
+ char* field;
+ char* str;
+ uint16_t i;
+
+ if (!fp || !field_name || !value) {
+ printf("Invalid fuction parameters\n");
+ return -1;
+ }
+
+ rewind(fp);
+
+ while (!feof(fp)) {
+ if (!fgets(strLine, MAX_LEN, fp))
+ continue;
+
+ for (i = 0; strLine[i] && i < MAX_LEN; i++)
+ if (strLine[i] != ' ') break;
+
+ if (strLine[i] == '#' || strLine[i] == '\n' || i == 1024)
+ continue;
+
+ field = strtok(&strLine[i], ":");
+ if (strncmp(field, field_name, strlen(field_name)))
+ continue;
+
+ if (!(str = strtok(NULL, ":")))
+ continue;
+
+ /* skip blank space in string */
+ while (*str == ' ')
+ str++;
+
+ *(str + strlen(str)-1) = '\0';
+ strcpy(value, str);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+static int8_t
+read_value_uint8(FILE* fp, const char* field_name, uint8_t* value)
+{
+ char str[MAX_LEN];
+
+ if (read_value_string(fp, field_name, str)) {
+ printf("Failed to find integer field: %s", field_name);
+ return -1;
+ }
+
+ *value = (uint8_t)atoi(str);
+ return 0;
+}
+
+static int8_t
+read_value_uint32(FILE* fp, const char* field_name, uint32_t* value)
+{
+ char str[MAX_LEN];
+
+ if (read_value_string(fp, field_name, str)) {
+ printf("Failed to find integer field: %s", field_name);
+ return -1;
+ }
+
+ *value = (uint32_t)atoi(str);
+ return 0;
+}
+
+static int8_t
+read_value_float(FILE *fp, const char* field_name, float* value)
+{
+ char str[MAX_LEN];
+ if (read_value_string(fp, field_name, str)) {
+ printf("Failed to find float field: %s \n",field_name);
+ return -1;
+ }
+
+ *value = atof(str);
+ return 0;
+}
+
+static float
+adjust_to_range(VAProcFilterValueRange *range, float value)
+{
+ if (value < range->min_value || value > range->max_value){
+ printf("Value: %f exceed range: (%f ~ %f), force to use default: %f \n",
+ value, range->min_value, range->max_value, range->default_value);
+ return range->default_value;
+ }
+
+ return value;
+}
+
+static VAStatus
+create_surface(VASurfaceID * p_surface_id,
+ uint32_t width, uint32_t height,
+ uint32_t fourCC, uint32_t format)
+{
+ VAStatus va_status;
+ VASurfaceAttrib surface_attrib;
+ surface_attrib.type = VASurfaceAttribPixelFormat;
+ surface_attrib.flags = VA_SURFACE_ATTRIB_SETTABLE;
+ surface_attrib.value.type = VAGenericValueTypeInteger;
+ surface_attrib.value.value.i = fourCC;
+
+ va_status = vaCreateSurfaces(va_dpy,
+ format,
+ width ,
+ height,
+ p_surface_id,
+ 1,
+ &surface_attrib,
+ 1);
+ return va_status;
+}
+
+static VAStatus
+construct_nv12_mask_surface(VASurfaceID surface_id,
+ uint8_t min_luma,
+ uint8_t max_luma)
+{
+ VAStatus va_status;
+ VAImage surface_image;
+ void *surface_p = NULL;
+ unsigned char *y_dst, *u_dst, *v_dst;
+ uint32_t row, col;
+
+ va_status = vaDeriveImage(va_dpy, surface_id, &surface_image);
+ CHECK_VASTATUS(va_status, "vaDeriveImage");
+
+ va_status = vaMapBuffer(va_dpy, surface_image.buf, &surface_p);
+ CHECK_VASTATUS(va_status, "vaMapBuffer");
+
+ y_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[0]);
+ u_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
+ v_dst = u_dst;
+
+ /* fill Y plane, the luma values of some pixels is in the range of min_luma~max_luma,
+ * and others are out side of it, in luma key blending case, the pixels with Y value
+ * exceeding the range will be hided*/
+ for (row = 0; row < surface_image.height; row++) {
+ if (row < surface_image.height / 4 || row > surface_image.height * 3 / 4)
+ memset(y_dst, max_luma + 1, surface_image.pitches[0]);
+ else
+ memset(y_dst, (min_luma + max_luma) / 2, surface_image.pitches[0]);
+
+ y_dst += surface_image.pitches[0];
+ }
+
+ /* fill UV plane */
+ for (row = 0; row < surface_image.height / 2; row++) {
+ for (col = 0; col < surface_image.width / 2; col++) {
+ u_dst[col * 2] = 128;
+ u_dst[col * 2 + 1] = 128;
+ }
+ u_dst += surface_image.pitches[1];
+ }
+
+ vaUnmapBuffer(va_dpy, surface_image.buf);
+ vaDestroyImage(va_dpy, surface_image.image_id);
+
+ return VA_STATUS_SUCCESS;
+}
+
+/* Load yv12 frame to NV12/YV12/I420 surface*/
+static VAStatus
+upload_yv12_frame_to_yuv_surface(FILE *fp,
+ VASurfaceID surface_id)
+{
+ VAStatus va_status;
+ VAImage surface_image;
+ unsigned char *y_src, *u_src, *v_src;
+ unsigned char *y_dst, *u_dst, *v_dst;
+ void *surface_p = NULL;
+ uint32_t frame_size, i, row, col;
+ size_t n_items;
+ unsigned char * newImageBuffer = NULL;
+
+ va_status = vaDeriveImage(va_dpy, surface_id, &surface_image);
+ CHECK_VASTATUS(va_status, "vaDeriveImage");
+
+ va_status = vaMapBuffer(va_dpy, surface_image.buf, &surface_p);
+ CHECK_VASTATUS(va_status, "vaMapBuffer");
+
+ if (surface_image.format.fourcc == VA_FOURCC_YV12 ||
+ surface_image.format.fourcc == VA_FOURCC_I420 ||
+ surface_image.format.fourcc == VA_FOURCC_NV12){
+
+ frame_size = surface_image.width * surface_image.height * 3 / 2;
+ newImageBuffer = (unsigned char*)malloc(frame_size);
+ do {
+ n_items = fread(newImageBuffer, frame_size, 1, fp);
+ } while (n_items != 1);
+
+ y_src = newImageBuffer;
+ v_src = newImageBuffer + surface_image.width * surface_image.height;
+ u_src = newImageBuffer + surface_image.width * surface_image.height * 5 / 4;
+
+ y_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[0]);
+
+ if(surface_image.format.fourcc == VA_FOURCC_YV12){
+ v_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
+ u_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[2]);
+ }else if(surface_image.format.fourcc == VA_FOURCC_I420){
+ u_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
+ v_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[2]);
+ }else {
+ u_dst = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
+ v_dst = u_dst;
+ }
+
+ /* Y plane, directly copy */
+ for (row = 0; row < surface_image.height; row++) {
+ memcpy(y_dst, y_src, surface_image.width);
+ y_dst += surface_image.pitches[0];
+ y_src += surface_image.width;
+ }
+
+ /* UV plane */
+ if (surface_image.format.fourcc == VA_FOURCC_YV12||
+ surface_image.format.fourcc == VA_FOURCC_I420){
+ /* UV plane */
+ for (row = 0; row < surface_image.height /2; row ++){
+ memcpy(v_dst, v_src, surface_image.width/2);
+ memcpy(u_dst, u_src, surface_image.width/2);
+
+ v_src += surface_image.width/2;
+ u_src += surface_image.width/2;
+
+ if (surface_image.format.fourcc == VA_FOURCC_YV12){
+ v_dst += surface_image.pitches[1];
+ u_dst += surface_image.pitches[2];
+ } else {
+ v_dst += surface_image.pitches[2];
+ u_dst += surface_image.pitches[1];
+ }
+ }
+ } else if (surface_image.format.fourcc == VA_FOURCC_NV12){
+ for (row = 0; row < surface_image.height / 2; row++) {
+ for (col = 0; col < surface_image.width / 2; col++) {
+ u_dst[col * 2] = u_src[col];
+ u_dst[col * 2 + 1] = v_src[col];
+ }
+
+ u_dst += surface_image.pitches[1];
+ u_src += (surface_image.width / 2);
+ v_src += (surface_image.width / 2);
+ }
+ }
+ } else {
+ printf("Not supported YUV surface fourcc !!! \n");
+ return VA_STATUS_ERROR_INVALID_SURFACE;
+ }
+
+ if (newImageBuffer){
+ free(newImageBuffer);
+ newImageBuffer = NULL;
+ }
+
+ vaUnmapBuffer(va_dpy, surface_image.buf);
+ vaDestroyImage(va_dpy, surface_image.image_id);
+
+ return VA_STATUS_SUCCESS;
+}
+
+/* Store NV12/YV12/I420 surface to yv12 frame*/
+static VAStatus
+store_yuv_surface_to_yv12_frame(FILE *fp,
+ VASurfaceID surface_id)
+{
+ VAStatus va_status;
+ VAImageFormat image_format;
+ VAImage surface_image;
+ void *surface_p = NULL;
+ unsigned char *y_src, *u_src, *v_src;
+ unsigned char *y_dst, *u_dst, *v_dst;
+ uint32_t frame_size, row, col;
+ int32_t ret, n_items;
+ unsigned char * newImageBuffer = NULL;
+
+ va_status = vaDeriveImage(va_dpy, surface_id, &surface_image);
+ CHECK_VASTATUS(va_status, "vaDeriveImage");
+
+ va_status = vaMapBuffer(va_dpy, surface_image.buf, &surface_p);
+ CHECK_VASTATUS(va_status, "vaMapBuffer");
+
+ /* store the surface to one YV12 file or one bmp file*/
+ if (surface_image.format.fourcc == VA_FOURCC_YV12 ||
+ surface_image.format.fourcc == VA_FOURCC_I420 ||
+ surface_image.format.fourcc == VA_FOURCC_NV12){
+
+ uint32_t y_size = surface_image.width * surface_image.height;
+ uint32_t u_size = y_size/4;
+
+ newImageBuffer = (unsigned char*)malloc(y_size * 3 / 2);
+
+ /* stored as YV12 format */
+ y_dst = newImageBuffer;
+ v_dst = newImageBuffer + y_size;
+ u_dst = newImageBuffer + y_size + u_size;
+
+ y_src = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[0]);
+ if (surface_image.format.fourcc == VA_FOURCC_YV12){
+ v_src = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
+ u_src = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[2]);
+ } else if(surface_image.format.fourcc == VA_FOURCC_I420){
+ u_src = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
+ v_src = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[2]);
+ } else if(surface_image.format.fourcc == VA_FOURCC_NV12){
+ u_src = (unsigned char *)((unsigned char*)surface_p + surface_image.offsets[1]);
+ v_src = u_src;
+ }
+
+ /* Y plane copy */
+ for (row = 0; row < surface_image.height; row++) {
+ memcpy(y_dst, y_src, surface_image.width);
+ y_src += surface_image.pitches[0];
+ y_dst += surface_image.width;
+ }
+
+ /* UV plane copy */
+ if (surface_image.format.fourcc == VA_FOURCC_YV12||
+ surface_image.format.fourcc == VA_FOURCC_I420){
+ for (row = 0; row < surface_image.height /2; row ++){
+ memcpy(v_dst, v_src, surface_image.width/2);
+ memcpy(u_dst, u_src, surface_image.width/2);
+
+ v_dst += surface_image.width/2;
+ u_dst += surface_image.width/2;
+
+ if (surface_image.format.fourcc == VA_FOURCC_YV12){
+ v_src += surface_image.pitches[1];
+ u_src += surface_image.pitches[2];
+ } else {
+ v_src += surface_image.pitches[2];
+ u_src += surface_image.pitches[1];
+ }
+ }
+ } else if (surface_image.format.fourcc == VA_FOURCC_NV12){
+ for (row = 0; row < surface_image.height / 2; row++) {
+ for (col = 0; col < surface_image.width /2; col++) {
+ u_dst[col] = u_src[col * 2];
+ v_dst[col] = u_src[col * 2 + 1];
+ }
+
+ u_src += surface_image.pitches[1];
+ u_dst += (surface_image.width / 2);
+ v_dst += (surface_image.width / 2);
+ }
+ }
+
+ /* write frame to file */
+ do {
+ n_items = fwrite(newImageBuffer, y_size * 3 / 2, 1, fp);
+ } while (n_items != 1);
+
+ } else {
+ printf("Not supported YUV surface fourcc !!! \n");
+ return VA_STATUS_ERROR_INVALID_SURFACE;
+ }
+
+ if (newImageBuffer){
+ free(newImageBuffer);
+ newImageBuffer = NULL;
+ }
+
+ vaUnmapBuffer(va_dpy, surface_image.buf);
+ vaDestroyImage(va_dpy, surface_image.image_id);
+
+ return VA_STATUS_SUCCESS;
+}
+
+static VAStatus
+denoise_filter_init(VABufferID *filter_param_buf_id)
+{
+ VAStatus va_status = VA_STATUS_SUCCESS;
+ VAProcFilterParameterBuffer denoise_param;
+ VABufferID denoise_param_buf_id;
+ float intensity;
+
+ VAProcFilterCap denoise_caps;
+ uint32_t num_denoise_caps = 1;
+ va_status = vaQueryVideoProcFilterCaps(va_dpy, context_id,
+ VAProcFilterNoiseReduction,
+ &denoise_caps, &num_denoise_caps);
+ CHECK_VASTATUS(va_status,"vaQueryVideoProcFilterCaps");
+
+ if (read_value_float(g_config_file_fd, "DENOISE_INTENSITY", &intensity)) {
+ printf("Read denoise intensity failed, use default value");
+ intensity = denoise_caps.range.default_value;
+ }
+ intensity = adjust_to_range(&denoise_caps.range, intensity);
+
+ denoise_param.type = VAProcFilterNoiseReduction;
+ denoise_param.value = intensity;
+
+ printf("Denoise intensity: %f\n", intensity);
+
+ va_status = vaCreateBuffer(va_dpy, context_id,
+ VAProcFilterParameterBufferType, sizeof(denoise_param), 1,
+ &denoise_param, &denoise_param_buf_id);
+ CHECK_VASTATUS(va_status,"vaCreateBuffer");
+
+ *filter_param_buf_id = denoise_param_buf_id;
+
+ return va_status;
+}
+
+static VAStatus
+deinterlace_filter_init(VABufferID *filter_param_buf_id)
+{
+ VAStatus va_status = VA_STATUS_SUCCESS;
+ VAProcFilterParameterBufferDeinterlacing deinterlacing_param;
+ VABufferID deinterlacing_param_buf_id;
+ char algorithm_str[MAX_LEN], flags_str[MAX_LEN];
+ uint32_t i;
+
+ /* read and check whether configured deinterlace algorithm is supported */
+ deinterlacing_param.algorithm = VAProcDeinterlacingBob;
+ if (!read_value_string(g_config_file_fd, "DEINTERLACING_ALGORITHM", algorithm_str)) {
+ printf("Deinterlacing algorithm in config: %s \n", algorithm_str);
+ if (!strcmp(algorithm_str, "VAProcDeinterlacingBob"))
+ deinterlacing_param.algorithm = VAProcDeinterlacingBob;
+ else if (!strcmp(algorithm_str, "VAProcDeinterlacingWeave"))
+ deinterlacing_param.algorithm = VAProcDeinterlacingWeave;
+ else if (!strcmp(algorithm_str, "VAProcDeinterlacingMotionAdaptive"))
+ deinterlacing_param.algorithm = VAProcDeinterlacingMotionAdaptive;
+ else if (!strcmp(algorithm_str, "VAProcDeinterlacingMotionCompensated"))
+ deinterlacing_param.algorithm = VAProcDeinterlacingMotionCompensated;
+ } else {
+ printf("Read deinterlace algorithm failed, use default algorithm");
+ deinterlacing_param.algorithm = VAProcDeinterlacingBob;
+ }
+
+ VAProcFilterCapDeinterlacing deinterlacing_caps[VAProcDeinterlacingCount];
+ uint32_t num_deinterlacing_caps = VAProcDeinterlacingCount;
+ va_status = vaQueryVideoProcFilterCaps(va_dpy, context_id,
+ VAProcFilterDeinterlacing,
+ &deinterlacing_caps, &num_deinterlacing_caps);
+ CHECK_VASTATUS(va_status,"vaQueryVideoProcFilterCaps");
+
+ for (i = 0; i < VAProcDeinterlacingCount; i ++)
+ if (deinterlacing_caps[i].type == deinterlacing_param.algorithm)
+ break;
+
+ if (i == VAProcDeinterlacingCount) {
+ printf("Deinterlacing algorithm: %d is not supported by driver, \
+ use defautl algorithm :%d \n",
+ deinterlacing_param.algorithm,
+ VAProcDeinterlacingBob);
+ deinterlacing_param.algorithm = VAProcDeinterlacingBob;
+ }
+
+ /* read and check the deinterlace flags */
+ deinterlacing_param.flags = 0;
+ if (!read_value_string(g_config_file_fd, "DEINTERLACING_FLAG", flags_str)) {
+ if (strstr(flags_str, "VA_DEINTERLACING_BOTTOM_FIELD_FIRST"))
+ deinterlacing_param.flags |= VA_DEINTERLACING_BOTTOM_FIELD_FIRST;
+ if (strstr(flags_str, "VA_DEINTERLACING_BOTTOM_FIELD"))
+ deinterlacing_param.flags |= VA_DEINTERLACING_BOTTOM_FIELD;
+ if (strstr(flags_str, "VA_DEINTERLACING_ONE_FIELD"))
+ deinterlacing_param.flags |= VA_DEINTERLACING_ONE_FIELD;
+ }
+
+ deinterlacing_param.type = VAProcFilterDeinterlacing;
+
+ /* create deinterlace fitler buffer */
+ va_status = vaCreateBuffer(va_dpy, context_id,
+ VAProcFilterParameterBufferType, sizeof(deinterlacing_param), 1,
+ &deinterlacing_param, &deinterlacing_param_buf_id);
+ CHECK_VASTATUS(va_status, "vaCreateBuffer");
+
+ *filter_param_buf_id = deinterlacing_param_buf_id;
+
+ return va_status;
+}
+
+static VAStatus
+sharpening_filter_init(VABufferID *filter_param_buf_id)
+{
+ VAStatus va_status;
+ VAProcFilterParameterBuffer sharpening_param;
+ VABufferID sharpening_param_buf_id;
+ float intensity;
+
+ VAProcFilterCap sharpening_caps;
+ uint32_t num_sharpening_caps = 1;
+ va_status = vaQueryVideoProcFilterCaps(va_dpy, context_id,
+ VAProcFilterSharpening,
+ &sharpening_caps, &num_sharpening_caps);
+ CHECK_VASTATUS(va_status,"vaQueryVideoProcFilterCaps");
+
+ if(read_value_float(g_config_file_fd, "SHARPENING_INTENSITY", &intensity)) {
+ printf("Read sharpening intensity failed, use default value.");
+ intensity = sharpening_caps.range.default_value;
+ }
+
+ intensity = adjust_to_range(&sharpening_caps.range, intensity);
+ printf("Sharpening intensity: %f\n", intensity);
+ sharpening_param.value = intensity;
+
+ sharpening_param.type = VAProcFilterSharpening;
+
+ /* create sharpening fitler buffer */
+ va_status = vaCreateBuffer(va_dpy, context_id,
+ VAProcFilterParameterBufferType, sizeof(sharpening_param), 1,
+ &sharpening_param, &sharpening_param_buf_id);
+
+ *filter_param_buf_id = sharpening_param_buf_id;
+
+ return va_status;
+}
+
+static VAStatus
+color_balance_filter_init(VABufferID *filter_param_buf_id)
+{
+ VAStatus va_status;
+ VAProcFilterParameterBufferColorBalance color_balance_param[4];
+ VABufferID color_balance_param_buf_id;
+ float value;
+ uint32_t i, count;
+ int8_t status;
+
+ VAProcFilterCapColorBalance color_balance_caps[VAProcColorBalanceCount];
+ unsigned int num_color_balance_caps = VAProcColorBalanceCount;
+ va_status = vaQueryVideoProcFilterCaps(va_dpy, context_id,
+ VAProcFilterColorBalance,
+ &color_balance_caps, &num_color_balance_caps);
+ CHECK_VASTATUS(va_status,"vaQueryVideoProcFilterCaps");
+
+ count = 0;
+ printf("Color balance params: ");
+ for (i = 0; i < num_color_balance_caps; i++) {
+ if (color_balance_caps[i].type == VAProcColorBalanceHue) {
+ color_balance_param[count].attrib = VAProcColorBalanceHue;
+ status = read_value_float(g_config_file_fd, "COLOR_BALANCE_HUE", &value);
+ printf("Hue: ");
+ } else if (color_balance_caps[i].type == VAProcColorBalanceSaturation) {
+ color_balance_param[count].attrib = VAProcColorBalanceSaturation;
+ status = read_value_float(g_config_file_fd, "COLOR_BALANCE_SATURATION", &value);
+ printf("Saturation: ");
+ } else if (color_balance_caps[i].type == VAProcColorBalanceBrightness) {
+ color_balance_param[count].attrib = VAProcColorBalanceBrightness;
+ status = read_value_float(g_config_file_fd, "COLOR_BALANCE_BRIGHTNESS", &value);
+ printf("Brightness: ");
+ } else if (color_balance_caps[i].type == VAProcColorBalanceContrast) {
+ color_balance_param[count].attrib = VAProcColorBalanceContrast;
+ status = read_value_float(g_config_file_fd, "COLOR_BALANCE_CONTRAST", &value);
+ printf("Contrast: ");
+ } else {
+ continue;
+ }
+
+ if (status)
+ value = color_balance_caps[i].range.default_value;
+ else
+ value = adjust_to_range(&color_balance_caps[i].range, value);
+
+ color_balance_param[count].value = value;
+ color_balance_param[count].type = VAProcFilterColorBalance;
+ count++;
+
+ printf("%4f, ", value);
+ }
+ printf("\n");
+
+ va_status = vaCreateBuffer(va_dpy, context_id,
+ VAProcFilterParameterBufferType, sizeof(color_balance_param), 4,
+ color_balance_param, &color_balance_param_buf_id);
+
+ *filter_param_buf_id = color_balance_param_buf_id;
+
+ return va_status;
+}
+
+static VAStatus
+blending_state_init(VABlendState *state)
+{
+ VAStatus va_status = VA_STATUS_SUCCESS;
+ char blending_flags_str[MAX_LEN];
+ float global_alpha;
+ uint32_t min_luma, max_luma;
+
+ /* read and check blend state */
+ state->flags = 0;
+ if (!read_value_string(g_config_file_fd, "BLENDING_FLAGS", blending_flags_str)){
+ if (strstr(blending_flags_str, "VA_BLEND_GLOBAL_ALPHA")) {
+ if (read_value_float(g_config_file_fd, "BLENDING_GLOBAL_ALPHA", &global_alpha)) {
+ global_alpha = 1.0 ;
+ printf("Use default global alpha : %4f \n", global_alpha);
+ }
+ state->flags |= VA_BLEND_GLOBAL_ALPHA;
+ state->global_alpha = global_alpha;
+ }
+ if (strstr(blending_flags_str, "VA_BLEND_LUMA_KEY")) {
+ if (read_value_uint8(g_config_file_fd, "BLENDING_MIN_LUMA", &g_blending_min_luma)) {
+ g_blending_min_luma = 1;
+ printf("Use default min luma : %3d \n", g_blending_min_luma);
+ }
+ if (read_value_uint8(g_config_file_fd, "BLENDING_MAX_LUMA", &g_blending_max_luma)) {
+ g_blending_max_luma = 254;
+ printf("Use default max luma : %3d \n", g_blending_max_luma);
+ }
+ state->flags |= VA_BLEND_LUMA_KEY;
+ state->min_luma = g_blending_min_luma * 1.0 / 256;
+ state->max_luma = g_blending_max_luma * 1.0 / 256;
+ }
+
+ printf("Blending type = %s, alpha = %f, min_luma = %3d, max_luma = %3d \n",
+ blending_flags_str, global_alpha, min_luma, max_luma);
+ }
+
+ VAProcPipelineCaps pipeline_caps;
+ va_status = vaQueryVideoProcPipelineCaps(va_dpy, context_id,
+ NULL, 0, &pipeline_caps);
+ CHECK_VASTATUS(va_status,"vaQueryVideoProcPipelineCaps");
+
+ if (!pipeline_caps.blend_flags){
+ printf("Blending is not supported in driver! \n");
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+ }
+
+ if (! (pipeline_caps.blend_flags & state->flags)) {
+ printf("Driver do not support current blending flags: %d", state->flags);
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+ }
+
+ return va_status;
+}
+
+static VAStatus
+video_frame_process(VAProcFilterType filter_type,
+ uint32_t frame_idx,
+ VASurfaceID in_surface_id,
+ VASurfaceID out_surface_id)
+{
+ VAStatus va_status;
+ VAProcPipelineParameterBuffer pipeline_param;
+ VARectangle surface_region, output_region;
+ VABufferID pipeline_param_buf_id = VA_INVALID_ID;
+ VABufferID filter_param_buf_id = VA_INVALID_ID;
+ VABlendState state ;
+ uint32_t filter_count = 1;
+
+ /* create denoise_filter buffer id */
+ switch(filter_type){
+ case VAProcFilterNoiseReduction:
+ denoise_filter_init(&filter_param_buf_id);
+ break;
+ case VAProcFilterDeinterlacing:
+ deinterlace_filter_init(&filter_param_buf_id);
+ break;
+ case VAProcFilterSharpening:
+ sharpening_filter_init(&filter_param_buf_id);
+ break;
+ case VAProcFilterColorBalance:
+ color_balance_filter_init(&filter_param_buf_id);
+ break;
+ default :
+ filter_count = 0;
+ break;
+ }
+
+ /* Fill pipeline buffer */
+ surface_region.x = 0;
+ surface_region.y = 0;
+ surface_region.width = g_in_pic_width;
+ surface_region.height = g_in_pic_height;
+ output_region.x = 0;
+ output_region.y = 0;
+ output_region.width = g_out_pic_width;
+ output_region.height = g_out_pic_height;
+
+ memset(&pipeline_param, 0, sizeof(pipeline_param));
+ pipeline_param.surface = in_surface_id;
+ pipeline_param.surface_region = &surface_region;
+ pipeline_param.output_region = &output_region;
+
+ pipeline_param.filter_flags = 0;
+ pipeline_param.filters = &filter_param_buf_id;
+ pipeline_param.num_filters = filter_count;
+
+ /* Blending related state */
+ if (g_blending_enabled){
+ blending_state_init(&state);
+ pipeline_param.blend_state = &state;
+ }
+
+ va_status = vaCreateBuffer(va_dpy,
+ context_id,
+ VAProcPipelineParameterBufferType,
+ sizeof(pipeline_param),
+ 1,
+ &pipeline_param,
+ &pipeline_param_buf_id);
+ CHECK_VASTATUS(va_status, "vaCreateBuffer");
+
+ va_status = vaBeginPicture(va_dpy,
+ context_id,
+ out_surface_id);
+ CHECK_VASTATUS(va_status, "vaBeginPicture");
+
+ va_status = vaRenderPicture(va_dpy,
+ context_id,
+ &pipeline_param_buf_id,
+ 1);
+ CHECK_VASTATUS(va_status, "vaRenderPicture");
+
+ va_status = vaEndPicture(va_dpy, context_id);
+ CHECK_VASTATUS(va_status, "vaEndPicture");
+
+ if (filter_param_buf_id != VA_INVALID_ID)
+ vaDestroyBuffer(va_dpy,filter_param_buf_id);
+
+ if (pipeline_param_buf_id != VA_INVALID_ID)
+ vaDestroyBuffer(va_dpy,pipeline_param_buf_id);
+
+ return va_status;
+}
+
+static VAStatus
+vpp_context_create()
+{
+ VAStatus va_status = VA_STATUS_SUCCESS;
+ uint32_t i;
+
+ /* VA driver initialization */
+ va_dpy = va_open_display();
+ int32_t major_ver, minor_ver;
+ va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
+ assert(va_status == VA_STATUS_SUCCESS);
+
+ /* Check whether VPP is supported by driver */
+ VAEntrypoint entrypoints[5];
+ int32_t num_entrypoints;
+ num_entrypoints = vaMaxNumEntrypoints(va_dpy);
+ va_status = vaQueryConfigEntrypoints(va_dpy,
+ VAProfileNone,
+ entrypoints,
+ &num_entrypoints);
+ CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints");
+
+ for (i = 0; i < num_entrypoints; i++) {
+ if (entrypoints[i] == VAEntrypointVideoProc)
+ break;
+ }
+
+ if (i == num_entrypoints) {
+ printf("VPP is not supported by driver\n");
+ assert(0);
+ }
+
+ /* Render target surface format check */
+ VAConfigAttrib attrib;
+ attrib.type = VAConfigAttribRTFormat;
+ va_status = vaGetConfigAttributes(va_dpy,
+ VAProfileNone,
+ VAEntrypointVideoProc,
+ &attrib,
+ 1);
+ CHECK_VASTATUS(va_status, "vaGetConfigAttributes");
+ if ((attrib.value != g_out_format)) {
+ printf("RT format %d is not supported by VPP !\n",g_out_format);
+ assert(0);
+ }
+
+ /* Create surface/config/context for VPP pipeline */
+ va_status = create_surface(&g_in_surface_id, g_in_pic_width, g_in_pic_height,
+ g_in_fourcc, g_in_format);
+ CHECK_VASTATUS(va_status, "vaCreateSurfaces for input");
+
+ va_status = create_surface(&g_out_surface_id, g_out_pic_width, g_out_pic_height,
+ g_out_fourcc, g_out_format);
+ CHECK_VASTATUS(va_status, "vaCreateSurfaces for output");
+
+ va_status = vaCreateConfig(va_dpy,
+ VAProfileNone,
+ VAEntrypointVideoProc,
+ &attrib,
+ 1,
+ &config_id);
+ CHECK_VASTATUS(va_status, "vaCreateConfig");
+
+ /* Source surface format check */
+ uint32_t num_surf_attribs = VASurfaceAttribCount;
+ VASurfaceAttrib * surf_attribs = (VASurfaceAttrib*)
+ malloc(sizeof(VASurfaceAttrib) * num_surf_attribs);
+ if (!surf_attribs)
+ assert(0);
+
+ va_status = vaQuerySurfaceAttributes(va_dpy,
+ config_id,
+ surf_attribs,
+ &num_surf_attribs);
+
+ if (va_status == VA_STATUS_ERROR_MAX_NUM_EXCEEDED) {
+ surf_attribs = (VASurfaceAttrib*)realloc(surf_attribs,
+ sizeof(VASurfaceAttrib) * num_surf_attribs);
+ if (!surf_attribs)
+ assert(0);
+ va_status = vaQuerySurfaceAttributes(va_dpy,
+ config_id,
+ surf_attribs,
+ &num_surf_attribs);
+ }
+ CHECK_VASTATUS(va_status, "vaQuerySurfaceAttributes");
+
+ for (i = 0; i < num_surf_attribs; i++) {
+ if (surf_attribs[i].type == VASurfaceAttribPixelFormat &&
+ surf_attribs[i].value.value.i == g_in_fourcc)
+ break;
+ }
+ free(surf_attribs);
+
+ if (i == num_surf_attribs) {
+ printf("Input fourCC %d is not supported by VPP !\n", g_in_fourcc);
+ assert(0);
+ }
+
+ va_status = vaCreateContext(va_dpy,
+ config_id,
+ g_out_pic_width,
+ g_out_pic_height,
+ VA_PROGRESSIVE,
+ &g_out_surface_id,
+ 1,
+ &context_id);
+ CHECK_VASTATUS(va_status, "vaCreateContext");
+
+
+ /* Validate whether currect filter is supported */
+ if (g_filter_type != VAProcFilterNone) {
+ uint32_t supported_filter_num = VAProcFilterCount;
+ VAProcFilterType supported_filter_types[VAProcFilterCount];
+
+ va_status = vaQueryVideoProcFilters(va_dpy,
+ context_id,
+ supported_filter_types,
+ &supported_filter_num);
+
+ CHECK_VASTATUS(va_status, "vaQueryVideoProcFilters");
+
+ for (i = 0; i < supported_filter_num; i++){
+ if (supported_filter_types[i] == g_filter_type)
+ break;
+ }
+
+ if (i == supported_filter_num) {
+ printf("VPP filter type %s is not supported by driver !\n", g_filter_type_name);
+ assert(0);
+ }
+ }
+
+ return va_status;
+}
+
+static void
+vpp_context_destroy()
+{
+ /* Release resource */
+ vaDestroySurfaces(va_dpy, &g_in_surface_id, 1);
+ vaDestroySurfaces(va_dpy, &g_out_surface_id, 1);
+ vaDestroyContext(va_dpy, context_id);
+ vaDestroyConfig(va_dpy, config_id);
+
+ vaTerminate(va_dpy);
+ va_close_display(va_dpy);
+}
+
+static int8_t
+parse_fourcc_and_format(char *str, uint32_t *fourcc, uint32_t *format)
+{
+ if (!strcmp(str, "YV12")){
+ *fourcc = VA_FOURCC('Y', 'V', '1', '2');
+ *format = VA_RT_FORMAT_YUV420;
+ } else if(!strcmp(str, "I420")){
+ *fourcc = VA_FOURCC('I', '4', '2', '0');
+ *format = VA_RT_FORMAT_YUV420;
+ } else if(!strcmp(str, "NV12")){
+ *fourcc = VA_FOURCC('N', 'V', '1', '2');
+ *format = VA_RT_FORMAT_YUV420;
+ } else{
+ printf("Not supported format: %s! Currently only support following format: %s\n",
+ str, "YV12, I420, NV12");
+ assert(0);
+ }
+ return 0;
+}
+
+static int8_t
+parse_basic_parameters()
+{
+ char str[MAX_LEN];
+
+ /* Read src frame file information */
+ read_value_string(g_config_file_fd, "SRC_FILE_NAME", g_src_file_name);
+ read_value_uint32(g_config_file_fd, "SRC_FRAME_WIDTH", &g_in_pic_width);
+ read_value_uint32(g_config_file_fd, "SRC_FRAME_HEIGHT", &g_in_pic_height);
+ read_value_string(g_config_file_fd, "SRC_FRAME_FORMAT", str);
+ parse_fourcc_and_format(str, &g_in_fourcc, &g_in_format);
+
+ /* Read dst frame file information */
+ read_value_string(g_config_file_fd, "DST_FILE_NAME", g_dst_file_name);
+ read_value_uint32(g_config_file_fd, "DST_FRAME_WIDTH", &g_out_pic_width);
+ read_value_uint32(g_config_file_fd, "DST_FRAME_HEIGHT",&g_out_pic_height);
+ read_value_string(g_config_file_fd, "DST_FRAME_FORMAT", str);
+ parse_fourcc_and_format(str, &g_out_fourcc, &g_out_format);
+
+ read_value_uint32(g_config_file_fd, "FRAME_SUM", &g_frame_count);
+
+ /* Read filter type */
+ if (read_value_string(g_config_file_fd, "FILTER_TYPE", g_filter_type_name)){
+ printf("Read filter type error !\n");
+ assert(0);
+ }
+
+ if (!strcmp(g_filter_type_name, "VAProcFilterNoiseReduction"))
+ g_filter_type = VAProcFilterNoiseReduction;
+ else if (!strcmp(g_filter_type_name, "VAProcFilterDeinterlacing"))
+ g_filter_type = VAProcFilterDeinterlacing;
+ else if (!strcmp(g_filter_type_name, "VAProcFilterSharpening"))
+ g_filter_type = VAProcFilterSharpening;
+ else if (!strcmp(g_filter_type_name, "VAProcFilterColorBalance"))
+ g_filter_type = VAProcFilterColorBalance;
+ else if (!strcmp(g_filter_type_name, "VAProcFilterNone"))
+ g_filter_type = VAProcFilterNone;
+ else {
+ printf("Unsupported filter type :%s \n", g_filter_type_name);
+ return -1;
+ }
+
+ /* Check whether blending is enabled */
+ if (read_value_uint8(g_config_file_fd, "BLENDING_ENABLED", &g_blending_enabled))
+ g_blending_enabled = 0;
+
+ if (g_blending_enabled)
+ printf("Blending will be done \n");
+
+ if (g_in_pic_width != g_out_pic_width ||
+ g_in_pic_height != g_out_pic_height)
+ printf("Scaling will be done : from %4d x %4d to %4d x %4d \n",
+ g_in_pic_width, g_in_pic_height,
+ g_out_pic_width, g_out_pic_height);
+
+ if (g_in_fourcc != g_out_fourcc)
+ printf("Format conversion will be done: from %d to %d \n",
+ g_in_fourcc, g_out_fourcc);
+
+ return 0;
+}
+
+int32_t main(int32_t argc, char *argv[])
+{
+ VAStatus va_status;
+ uint32_t i;
+
+ if (argc != 2){
+ printf("Input error! please specify the configure file \n");
+ return -1;
+ }
+
+ /* Parse the configure file for video process*/
+ strcpy(g_config_file_name, argv[1]);
+ if (NULL == (g_config_file_fd = fopen(g_config_file_name, "r"))){
+ printf("Open configure file %s failed!\n",g_config_file_name);
+ assert(0);
+ }
+
+ /* Parse basic parameters */
+ if (parse_basic_parameters()){
+ printf("Parse parameters in configure file error\n");
+ assert(0);
+ }
+
+ va_status = vpp_context_create();
+ if (va_status != VA_STATUS_SUCCESS) {
+ printf("vpp context create failed \n");
+ assert(0);
+ }
+
+ /* Video frame fetch, process and store */
+ if (NULL == (g_src_file_fd = fopen(g_src_file_name, "r"))){
+ printf("Open SRC_FILE_NAME: %s failed, please specify it in config file: %s !\n",
+ g_src_file_name, g_config_file_name);
+ assert(0);
+ }
+
+ if (NULL == (g_dst_file_fd = fopen(g_dst_file_name, "w"))){
+ printf("Open DST_FILE_NAME: %s failed, please specify it in config file: %s !\n",
+ g_dst_file_name, g_config_file_name);
+ assert(0);
+ }
+
+ printf("\nStart to process, processing type is %s ...\n", g_filter_type_name);
+ struct timeval start_time, end_time;
+ gettimeofday(&start_time, NULL);
+
+ for (i = 0; i < g_frame_count; i ++){
+ if (g_blending_enabled) {
+ construct_nv12_mask_surface(g_in_surface_id, g_blending_min_luma, g_blending_max_luma);
+ upload_yv12_frame_to_yuv_surface(g_src_file_fd, g_out_surface_id);
+ } else {
+ upload_yv12_frame_to_yuv_surface(g_src_file_fd, g_in_surface_id);
+ }
+
+ video_frame_process(g_filter_type, i, g_in_surface_id, g_out_surface_id);
+ store_yuv_surface_to_yv12_frame(g_dst_file_fd, g_out_surface_id);
+ }
+
+ gettimeofday(&end_time, NULL);
+ float duration = (end_time.tv_sec - start_time.tv_sec) +
+ (end_time.tv_usec - start_time.tv_usec)/1000000.0;
+ printf("Finish processing, performance: \n" );
+ printf("%d frames processed in: %f s, ave time = %.6fs \n",g_frame_count, duration, duration/g_frame_count);
+
+ if (g_src_file_fd)
+ fclose(g_src_file_fd);
+
+ if (g_dst_file_fd)
+ fclose(g_dst_file_fd);
+
+ if (g_config_file_fd)
+ fclose(g_config_file_fd);
+
+ vpp_context_destroy();
+
+ return 0;
+}
+
diff --git a/va/Android.mk b/va/Android.mk
index fdf2f2f..eae7993 100755
--- a/va/Android.mk
+++ b/va/Android.mk
@@ -25,38 +25,25 @@
LOCAL_PATH:= $(call my-dir)
-LIBVA_DRIVERS_PATH = /system/lib
-
-# Version set to Android Jelly Bean
-ALOG_VERSION_REQ := 4.1
-ALOG_VERSION := $(filter $(ALOG_VERSION_REQ),$(firstword $(sort $(PLATFORM_VERSION) \
- $(ALOG_VERSION_REQ))))
+ifeq ($(ENABLE_IMG_GRAPHICS),true)
+LIBVA_DRIVERS_PATH = /system/lib
include $(CLEAR_VARS)
-#LIBVA_MINOR_VERSION := 31
-#LIBVA_MAJOR_VERSION := 0
-
LOCAL_SRC_FILES := \
va.c \
va_trace.c \
va_fool.c
-LOCAL_CFLAGS += \
+LOCAL_CFLAGS := \
-DANDROID \
-DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" \
- -DLOG_TAG=\"libva\"
-
-# Android Jelly Bean defined ALOGx, older versions use LOGx
-ifeq ($(ALOG_VERSION), $(ALOG_VERSION_REQ))
-LOCAL_CFLAGS += -DANDROID_ALOG
-else
-LOCAL_CFLAGS += -DANDROID_LOG
-endif
+ -DLOG_TAG=\"libva\" \
+ -DANDROID_ALOG
-LOCAL_EXPORT_C_INCLUDE_DIRS += $(LOCAL_PATH)/..
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/..
-LOCAL_C_INCLUDES += \
+LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libva \
$(LOCAL_PATH)/x11 \
$(LOCAL_PATH)/..
@@ -64,8 +51,10 @@ LOCAL_C_INCLUDES += \
LOCAL_COPY_HEADERS := \
va.h \
va_version.h \
+ va_dec_hevc.h \
va_dec_jpeg.h \
va_dec_vp8.h \
+ va_dec_vp9.h \
va_enc.h \
va_enc_h264.h \
va_enc_jpeg.h \
@@ -77,7 +66,7 @@ LOCAL_COPY_HEADERS := \
va_enc_mpeg2.h \
LOCAL_COPY_HEADERS_TO := libva/va
-
+LOCAL_CFLAGS += -Werror
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libva
@@ -102,10 +91,10 @@ LOCAL_SRC_FILES := \
android/va_android.cpp \
drm/va_drm_utils.c
-LOCAL_CFLAGS += \
+LOCAL_CFLAGS := \
-DANDROID -DLOG_TAG=\"libva-android\"
-LOCAL_C_INCLUDES += \
+LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libva \
$(TARGET_OUT_HEADERS)/libdrm \
$(LOCAL_PATH)/drm
@@ -113,7 +102,7 @@ LOCAL_C_INCLUDES += \
LOCAL_COPY_HEADERS_TO := libva/va
LOCAL_COPY_HEADERS := va_android.h
-
+LOCAL_CFLAGS += -Werror
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libva-android
@@ -130,17 +119,17 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
egl/va_egl.c
-LOCAL_CFLAGS += \
+LOCAL_CFLAGS := \
-DANDROID -DLOG_TAG=\"libva-egl\"
-LOCAL_C_INCLUDES += \
+LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libva \
$(LOCAL_PATH)/x11
LOCAL_COPY_HEADERS_TO := libva/va
LOCAL_COPY_HEADERS := egl/va_egl.h egl/va_backend_egl.h
-
+LOCAL_CFLAGS += -Werror
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libva-egl
@@ -156,9 +145,9 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := va_tpi.c
-LOCAL_CFLAGS += -DANDROID -DLOG_TAG=\"libva-tpi\"
+LOCAL_CFLAGS := -DANDROID -DLOG_TAG=\"libva-tpi\"
-LOCAL_C_INCLUDES += \
+LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libva \
$(LOCAL_PATH)/..
@@ -169,8 +158,10 @@ LOCAL_COPY_HEADERS := \
va_backend_tpi.h
LOCAL_SHARED_LIBRARIES := libva
-
+LOCAL_CFLAGS += -Werror
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libva-tpi
include $(BUILD_SHARED_LIBRARY)
+
+endif # $(ENABLE_IMG_GRAPHICS),true)
diff --git a/va/Makefile.am b/va/Makefile.am
index bb9b063..13ea35a 100644
--- a/va/Makefile.am
+++ b/va/Makefile.am
@@ -45,8 +45,10 @@ libva_source_h = \
va_backend_tpi.h \
va_backend_vpp.h \
va_compat.h \
+ va_dec_hevc.h \
va_dec_jpeg.h \
va_dec_vp8.h \
+ va_dec_vp9.h \
va_drmcommon.h \
va_enc.h \
va_enc_h264.h \
diff --git a/va/va.c b/va/va.c
index 935f488..3ea8503 100755
--- a/va/va.c
+++ b/va/va.c
@@ -249,7 +249,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
{ VA_MAJOR_VERSION, VA_MINOR_VERSION },
{ 0, 33 },
{ 0, 32 },
- { -1, }
+ { -1, 0}
};
for (i = 0; compatible_versions[i].major >= 0; i++) {
@@ -633,7 +633,6 @@ VAStatus vaCreateConfig (
{
VADriverContextP ctx;
VAStatus vaStatus = VA_STATUS_SUCCESS;
- int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
@@ -946,14 +945,11 @@ VAStatus vaCreateBuffer (
{
VADriverContextP ctx;
VAStatus vaStatus;
- int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
VA_FOOL_FUNC(va_FoolCreateBuffer, dpy, context, type, size, num_elements, data, buf_id);
- if (ret)
- return VA_STATUS_SUCCESS;
vaStatus = ctx->vtable->vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
@@ -972,8 +968,8 @@ VAStatus vaBufferSetNumElements (
VADriverContextP ctx;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
-
- VA_FOOL_RETURN();
+
+ VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
return ctx->vtable->vaBufferSetNumElements( ctx, buf_id, num_elements );
}
@@ -987,18 +983,15 @@ VAStatus vaMapBuffer (
{
VADriverContextP ctx;
VAStatus va_status;
- int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
-
+
VA_FOOL_FUNC(va_FoolMapBuffer, dpy, buf_id, pbuf);
- if (ret)
- return VA_STATUS_SUCCESS;
va_status = ctx->vtable->vaMapBuffer( ctx, buf_id, pbuf );
- VA_TRACE_LOG(va_TraceMapBuffer, dpy, buf_id, pbuf);
+ VA_TRACE_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf);
return va_status;
}
@@ -1011,11 +1004,8 @@ VAStatus vaUnmapBuffer (
VADriverContextP ctx;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- int ret = 0;
- VA_FOOL_FUNC(va_FoolUnmapBuffer, dpy, buf_id);
- if (ret)
- return VA_STATUS_SUCCESS;
+ VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
return ctx->vtable->vaUnmapBuffer( ctx, buf_id );
}
@@ -1029,7 +1019,7 @@ VAStatus vaDestroyBuffer (
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- VA_FOOL_RETURN();
+ VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
VA_TRACE_LOG(va_TraceDestroyBuffer,
dpy, buffer_id);
@@ -1039,24 +1029,21 @@ VAStatus vaDestroyBuffer (
VAStatus vaBufferInfo (
VADisplay dpy,
- VAContextID context, /* in */
+ VAContextID __maybe_unused context, /* in */
VABufferID buf_id, /* in */
VABufferType *type, /* out */
unsigned int *size, /* out */
unsigned int *num_elements /* out */
)
{
- VADriverContextP ctx;
- int ret = 0;
-
- CHECK_DISPLAY(dpy);
- ctx = CTX(dpy);
+ VADriverContextP ctx;
- VA_FOOL_FUNC(va_FoolBufferInfo, dpy, buf_id, type, size, num_elements);
- if (ret)
- return VA_STATUS_SUCCESS;
-
- return ctx->vtable->vaBufferInfo( ctx, buf_id, type, size, num_elements );
+ CHECK_DISPLAY(dpy);
+ ctx = CTX(dpy);
+
+ VA_FOOL_FUNC(va_FoolBufferInfo, dpy, buf_id, type, size, num_elements);
+
+ return ctx->vtable->vaBufferInfo( ctx, buf_id, type, size, num_elements );
}
VAStatus vaBeginPicture (
@@ -1072,7 +1059,7 @@ VAStatus vaBeginPicture (
ctx = CTX(dpy);
VA_TRACE_ALL(va_TraceBeginPicture, dpy, context, render_target);
- VA_FOOL_RETURN();
+ VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
va_status = ctx->vtable->vaBeginPicture( ctx, context, render_target );
@@ -1092,7 +1079,7 @@ VAStatus vaRenderPicture (
ctx = CTX(dpy);
VA_TRACE_LOG(va_TraceRenderPicture, dpy, context, buffers, num_buffers);
- VA_FOOL_RETURN();
+ VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
return ctx->vtable->vaRenderPicture( ctx, context, buffers, num_buffers );
}
@@ -1108,8 +1095,9 @@ VAStatus vaEndPicture (
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- if (fool_codec == 0)
- va_status = ctx->vtable->vaEndPicture( ctx, context );
+ VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
+
+ va_status = ctx->vtable->vaEndPicture( ctx, context );
/* dump surface content */
VA_TRACE_ALL(va_TraceEndPicture, dpy, context, 1);
diff --git a/va/va.h b/va/va.h
index 0872620..75a4bc0 100755
--- a/va/va.h
+++ b/va/va.h
@@ -78,12 +78,19 @@
#ifndef _VA_H_
#define _VA_H_
+#include <stdint.h>
#include <va/va_version.h>
#ifdef __cplusplus
extern "C" {
#endif
+#ifdef __GNUC__
+# define __maybe_unused __attribute__((__unused__))
+#else
+# define __maybe_unused
+#endif
+
/**
* \mainpage Video Acceleration (VA) API
*
@@ -204,9 +211,11 @@ typedef int VAStatus; /* Return status type from functions */
#define VA_CLEAR_DRAWABLE 0x00000008
/* Color space conversion flags for vaPutSurface() */
+#define VA_SRC_COLOR_MASK 0x000000f0
#define VA_SRC_BT601 0x00000010
#define VA_SRC_BT709 0x00000020
#define VA_SRC_SMPTE_240 0x00000040
+#define VA_SRC_BT2020 0x00000080
/* Scaling flags for vaPutSurface() */
#define VA_FILTER_SCALING_DEFAULT 0x00000000
@@ -216,6 +225,23 @@ typedef int VAStatus; /* Return status type from functions */
#define VA_FILTER_SCALING_MASK 0x00000f00
/*
+ * The upper 16 bits are reserved for VPP filter fast path usage.
+ * Flag to enable auto noise reduction.
+ */
+#define VA_FILTER_NOISEREDUCTION_AUTO 0x00010000
+
+/*
+ * This is to indicate that the color-space conversion uses full range or reduced range.
+ * VA_SOURCE_RANGE_FULL(Full range): Y/Cb/Cr is in [0, 255]. It is mainly used
+ * for JPEG/JFIF formats. The combination with the BT601 flag means that
+ * JPEG/JFIF color-space conversion matrix is used.
+ * VA_SOURCE_RANGE_REDUCED(Reduced range): Y is in [16, 235] and Cb/Cr is in [16, 240].
+ * It is mainly used for the YUV->RGB color-space conversion in SDTV/HDTV/UHDTV.
+ */
+#define VA_SOURCE_RANGE_MASK 0x00020000
+#define VA_SOURCE_RANGE_FULL 0x00020000
+#define VA_SOURCE_RANGE_REDUCED 0x00000000
+/*
* Returns a short english description of error_status
*/
const char *vaErrorStr(VAStatus error_status);
@@ -228,6 +254,16 @@ typedef struct _VARectangle
unsigned short height;
} VARectangle;
+/** \brief Generic motion vector data structure. */
+typedef struct _VAMotionVector {
+ /** \mv0[0]: horizontal motion vector for past reference */
+ /** \mv0[1]: vertical motion vector for past reference */
+ /** \mv1[0]: horizontal motion vector for future reference */
+ /** \mv1[1]: vertical motion vector for future reference */
+ unsigned short mv0[2]; /* past reference */
+ unsigned short mv1[2]; /* future reference */
+} VAMotionVector;
+
/*
* Initialization:
* A display must be obtained by calling vaGetDisplay() before calling
@@ -297,9 +333,13 @@ typedef enum
VAProfileH263Baseline = 11,
VAProfileJPEGBaseline = 12,
VAProfileH264ConstrainedBaseline = 13,
- VAProfileH264MultiviewHigh = 14,
- VAProfileH264StereoHigh = 15,
- VAProfileVP8Version0_3 = 16,
+ VAProfileVP8Version0_3 = 14,
+ VAProfileH264MultiviewHigh = 15,
+ VAProfileH264StereoHigh = 16,
+ VAProfileHEVCMain = 17,
+ VAProfileHEVCMain10 = 18,
+ VAProfileVP9Version0 = 19,
+ VAProfileAVS = 20,
VAProfileMax
} VAProfile;
@@ -395,6 +435,14 @@ typedef enum
* See \c VA_DEC_SLICE_MODE_xxx for the list of slice decoding modes.
*/
VAConfigAttribDecSliceMode = 6,
+ /**
+ * \brief JPEG decoding attribute. Read-only.
+ *
+ * This attribute exposes a number of capabilities of the underlying
+ * JPEG implementation. The attribute value is partitioned into fields as defined in the
+ * VAConfigAttribValDecJPEG union.
+ */
+ VAConfigAttribDecJPEG = 7,
/** @name Attributes for encoding */
/**@{*/
@@ -547,7 +595,7 @@ typedef enum
*
* This attribute conveys whether the driver supports any extended rate control features
* The attribute value is partitioned into fields as defined in the
- * VAConfigAttribRateControlExt union.
+ * VAConfigAttribValEncRateControlExt union.
*/
VAConfigAttribEncRateControlExt = 26,
/**
@@ -632,6 +680,18 @@ typedef struct _VAConfigAttrib {
#define VA_DEC_SLICE_MODE_NORMAL 0x00000001
/** \brief Driver supports base mode for slice decoding */
#define VA_DEC_SLICE_MODE_BASE 0x00000002
+
+/** @name Attribute values for VAConfigAttribDecJPEG */
+/**@{*/
+typedef union _VAConfigAttribValDecJPEG {
+ /** \brief Set to (1 << VA_ROTATION_xxx) for supported rotation angles. */
+ unsigned int rotation;
+ /** \brief Reserved for future use. */
+ unsigned int reserved[3];
+} VAConfigAttribValDecJPEG;
+/** \brief Driver supports subsample mode for slice decoding */
+#define VA_DEC_SLICE_MODE_SUBSAMPLE 0x00000004
+
/**@}*/
/** @name Attribute values for VAConfigAttribEncPackedHeaders */
@@ -672,6 +732,13 @@ typedef struct _VAConfigAttrib {
#define VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS 0x00000001
/** \brief Driver supports an arbitrary number of rows per slice. */
#define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS 0x00000002
+/** \brief Driver supports any number of rows per slice but they must be the same
+ for all slices except for the last one, which must be equal or smaller
+ to the previous slices. */
+#define VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS 0x00000004
+/** \brief Driver supports a maximum slice size requested by the app.
+ The size is sent in VAEncMiscParameterMaxSliceSize. */
+#define VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE 0x00000008
/**@}*/
/** \brief Attribute value for VAConfigAttribEncJPEG */
@@ -1234,7 +1301,7 @@ typedef enum
VAProcFilterParameterBufferType = 42,
VAParsePictureParameterBufferType = 43,
VAParseSliceHeaderGroupBufferType = 44,
-
+
/**
* \brief Intel specific buffer types start at 1001
*/
@@ -1270,6 +1337,8 @@ typedef enum
VAEncMiscParameterTypeROI = 10,
/** \brief Buffer type used for Cyclic intra refresh */
VAEncMiscParameterTypeCIR = 11,
+ /** \brief Buffer type used for temporal layer structure */
+ VAEncMiscParameterTypeTemporalLayerStructure = 12,
/* Intel specific types start at 1001 */
/* VAEntrypointEncFEIIntel */
@@ -1330,6 +1399,17 @@ typedef struct _VAEncMiscParameterBuffer
unsigned int data[0];
} VAEncMiscParameterBuffer;
+/** \brief Temporal Structure*/
+typedef struct _VAEncMiscParameterTemporalLayerStructure
+{
+ /* The number of temporal layers */
+ uint32_t number_of_layers;
+ /* this is Length of the sequence defining frame layer membership. Should be 1-32 */
+ uint32_t periodicity;
+ /*This is Array indicating the layer id for each frame in a sequence of length ts_periodicity.*/
+ uint32_t layer_id[32];
+} VAEncMiscParameterTemporalLayerStructure;
+
/** \brief Rate control parameters */
typedef struct _VAEncMiscParameterRateControl
@@ -2420,10 +2500,13 @@ typedef struct _VAParseSliceHeaderGroupBuffer
unsigned char luma_log2_weight_denom;
unsigned char chroma_log2_weight_denom;
unsigned char cabac_init_idc;
- unsigned char pic_order_cnt_lsb;
+ unsigned char reserved8bit;
+
+ unsigned short pic_order_cnt_lsb;
+ unsigned short reserved16bit;
- unsigned char pic_parameter_set_id;
- unsigned short idr_pic_id;
+ unsigned short idr_pic_id;
+ unsigned char pic_parameter_set_id;
unsigned char colour_plane_id;
char slice_alpha_c0_offset_div2;
@@ -2483,6 +2566,14 @@ typedef struct _VAParsePictureParameterBuffer {
unsigned int value;
} flags;
+ union {
+ struct {
+ unsigned char nalu_header_unit_type : 5;
+ unsigned char nalu_header_ref_idc : 2;
+ } bits;
+ unsigned char value;
+ } nalu_header;
+
unsigned short expected_pic_parameter_set_id;
unsigned char num_slice_groups_minus1;
unsigned char slice_group_map_type;
@@ -2492,6 +2583,8 @@ typedef struct _VAParsePictureParameterBuffer {
unsigned char log2_max_pic_order_cnt_lsb_minus4;
unsigned char pic_order_cnt_type;
unsigned char log2_max_frame_num_minus4;
+ unsigned char idr_flag;
+ unsigned char slice_offset;
/* additionally */
unsigned char residual_colour_transform_flag;
@@ -2618,10 +2711,11 @@ typedef enum
*/
typedef struct _VASurfaceDecodeMBErrors
{
- int status; /* 1 if hardware has returned detailed info below, -1 means this record is invalid */
+ int status; /* 1 if start_mb/end_mb with errors is returned, 2 if num_mb with errors is returned, -1 means this record is invalid */
unsigned int start_mb; /* start mb address with errors */
- unsigned int end_mb; /* end mb address with errors */
+ unsigned int end_mb; /* end mb address with errors */
VADecodeErrorType decode_error_type;
+ unsigned int num_mb; /* number of mbs with errors */
} VASurfaceDecodeMBErrors;
/*
@@ -2654,6 +2748,7 @@ VAStatus vaQuerySurfaceError(
* Pre-defined fourcc codes
*/
#define VA_FOURCC_NV12 0x3231564E
+#define VA_FOURCC_NV21 0x3132564E
#define VA_FOURCC_AI44 0x34344149
#define VA_FOURCC_RGBA 0x41424752
#define VA_FOURCC_RGBX 0x58424752
@@ -3011,8 +3106,8 @@ VAStatus vaDeassociateSubpicture (
* @name Rotation angles
*
* Those values could be used for VADisplayAttribRotation attribute or
- * VAProcPipelineParameterBuffer::rotation_state. The rotation operation
- * is clockwise.
+ * VAProcPipelineParameterBuffer::rotation_state or in VAConfigAttribValDecJPEG.
+ * The rotation operation is clockwise.
*/
/**@{*/
/** \brief No rotation. */
diff --git a/va/va_android.h b/va/va_android.h
index 0193fb0..978becd 100644
--- a/va/va_android.h
+++ b/va/va_android.h
@@ -48,7 +48,8 @@ VADisplay vaGetDisplay (
#ifdef __cplusplus
#ifdef ANDROID
-#include <gui/Surface.h>
+#include <system/window.h>
+#include <utils/StrongPointer.h>
using namespace android;
/*
diff --git a/va/va_backend.h b/va/va_backend.h
index 09f8245..61b9d3a 100755
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -394,7 +394,7 @@ struct VADriverVTable
/* DEPRECATED */
VAStatus
(*vaGetSurfaceAttributes)(
- VADriverContextP dpy,
+ VADriverContextP ctx,
VAConfigID config,
VASurfaceAttrib *attrib_list,
unsigned int num_attribs
diff --git a/va/va_backend_tpi.h b/va/va_backend_tpi.h
index d79ae2a..6b1c85a 100644
--- a/va/va_backend_tpi.h
+++ b/va/va_backend_tpi.h
@@ -36,7 +36,7 @@
struct VADriverVTableTPI
{
VAStatus (*vaCreateSurfacesWithAttribute) (
- VADisplay dpy,
+ VADriverContextP ctx,
int width,
int height,
int format,
@@ -64,7 +64,7 @@ struct VADriverVTableTPI
);
VAStatus (*vaSetTimestampForSurface)(
- VADisplay dpy,
+ VADriverContextP ctx,
VASurfaceID surface,
long long timestamp
);
diff --git a/va/va_dec_hevc.h b/va/va_dec_hevc.h
new file mode 100644
index 0000000..95cf676
--- /dev/null
+++ b/va/va_dec_hevc.h
@@ -0,0 +1,501 @@
+/*
+ * 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.
+ *
+ * @{
+ */
+
+
+
+/****************************
+ * HEVC data structures
+ ****************************/
+
+/**
+ * \brief Description of picture properties of those in DPB surfaces.
+ *
+ * If only progressive scan is supported, each surface contains one whole
+ * frame picture.
+ * Otherwise, each surface contains two fields of whole picture.
+ * In this case, two entries of ReferenceFrames[] may share same picture_id
+ * value.
+ */
+typedef struct _VAPictureHEVC
+{
+ /** \brief reconstructed picture buffer surface index
+ * invalid when taking value VA_INVALID_SURFACE.
+ */
+ VASurfaceID picture_id;
+ /** \brief picture order count.
+ * in HEVC, POCs for top and bottom fields of same picture should
+ * take different values.
+ */
+ int32_t PicOrderCnt;
+ /* described below */
+ uint32_t flags;
+} VAPictureHEVC;
+
+/** flags in VAPictureHEVC could be OR of the following */
+#define VA_PICTURE_HEVC_INVALID 0x00000001
+/** \brief indication of interlace scan picture.
+ * should take same value for all the pictures in sequence.
+ */
+#define VA_PICTURE_HEVC_FIELD_PIC 0x00000002
+/** \brief polarity of the field picture.
+ * top field takes even lines of buffer surface.
+ * bottom field takes odd lines of buffer surface.
+ */
+#define VA_PICTURE_HEVC_BOTTOM_FIELD 0x00000004
+/** \brief Long term reference picture */
+#define VA_PICTURE_HEVC_LONG_TERM_REFERENCE 0x00000008
+/** \brief RefPicSetStCurrBefore of HEVC spec variable
+ * Number of ReferenceFrames[] entries with this bit set equals
+ * NumPocStCurrBefore.
+ */
+#define VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE 0x00000010
+/** \brief RefPicSetStCurrAfter of HEVC spec variable
+ * Number of ReferenceFrames[] entries with this bit set equals
+ * NumPocStCurrAfter.
+ */
+#define VA_PICTURE_HEVC_RPS_ST_CURR_AFTER 0x00000020
+/** \brief RefPicSetLtCurr of HEVC spec variable
+ * Number of ReferenceFrames[] entries with this bit set equals
+ * NumPocLtCurr.
+ */
+#define VA_PICTURE_HEVC_RPS_LT_CURR 0x00000040
+/**
+ * VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE, VA_PICTURE_HEVC_RPS_ST_CURR_AFTER
+ * and VA_PICTURE_HEVC_RPS_LT_CURR of any picture in ReferenceFrames[] should
+ * be exclusive. No more than one of them can be set for any picture.
+ * Sum of NumPocStCurrBefore, NumPocStCurrAfter and NumPocLtCurr
+ * equals NumPocTotalCurr, which should be equal to or smaller than 8.
+ * Application should provide valid values for both short format and long format.
+ * The pictures in DPB with any of these three flags turned on are referred by
+ * the current picture.
+ */
+
+
+
+
+
+/**
+ * \brief HEVC Decoding Picture Parameter Buffer Structure
+ *
+ * This structure conveys picture level parameters and should be sent once
+ * per frame.
+ *
+ */
+typedef struct _VADecPictureParameterBufferHEVC
+{
+ /** \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;
+
+} VADecPictureParameterBufferHEVC;
+
+
+
+/**
+ * \brief HEVC Slice Parameter Buffer Structure For Short Format
+ *
+ * VASliceParameterBufferBaseHEVC 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 long format, this data structure is not sent by application.
+ *
+ */
+typedef struct _VASliceParameterBufferBaseHEVC
+{
+ /** @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. */
+ uint16_t slice_data_flag;
+ /**@}*/
+
+} VASliceParameterBufferBaseHEVC;
+
+
+
+
+/**
+ * \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. */
+ uint16_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.
+ * The slice bit stream may or may not include the start code prefix.
+ */
+ 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_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_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. */
+ uint8_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;
+ /**@}*/
+
+} VASliceParameterBufferHEVC;
+
+
+
+/**
+ * \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];
+} VAIQMatrixBufferHEVC;
+
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VA_DEC_HEVC_H */
diff --git a/va/va_dec_jpeg.h b/va/va_dec_jpeg.h
index 6683998..685e3ff 100644
--- a/va/va_dec_jpeg.h
+++ b/va/va_dec_jpeg.h
@@ -70,8 +70,10 @@ typedef struct _VAPictureParameterBufferJPEGBaseline {
} components[255];
/** \brief Number of components in frame (Nf). */
unsigned char num_components;
- /** \brief Input color space 0: YUV, 1: RGB, others: reserved */
+ /** \brief Input color space 0: YUV, 1: RGB, 2: BGR, others: reserved */
unsigned char color_space;
+ /** \brief Set to VA_ROTATION_* for a single rotation angle reported by VAConfigAttribDecJPEG. */
+ unsigned int rotation;
} VAPictureParameterBufferJPEGBaseline;
/**
diff --git a/va/va_dec_vp8.h b/va/va_dec_vp8.h
index 268ed19..32830cb 100644
--- a/va/va_dec_vp8.h
+++ b/va/va_dec_vp8.h
@@ -54,7 +54,11 @@ typedef struct _VABoolCoderContextVPX
unsigned char range;
/* partition 0 "value" */
unsigned char value;
- /* partition 0 number of shifts before an output byte is available */
+ /*
+ * '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].
+ */
+
unsigned char count;
} VABoolCoderContextVPX;
@@ -83,7 +87,7 @@ typedef struct _VAPictureParameterBufferVP8
union {
struct {
- /* same as key_frame in bitstream syntax */
+ /* same as key_frame in bitstream syntax, 0 means a key frame */
unsigned int key_frame : 1;
/* same as version in bitstream syntax */
unsigned int version : 3;
@@ -107,8 +111,6 @@ typedef struct _VAPictureParameterBufferVP8
unsigned int sign_bias_alternate : 1;
/* same as mb_no_coeff_skip in bitstream syntax */
unsigned int mb_no_coeff_skip : 1;
- /* see section 11.1 for mb_skip_coeff */
- unsigned int mb_skip_coeff : 1;
/* flag to indicate that loop filter should be disabled */
unsigned int loop_filter_disable : 1;
} bits;
@@ -172,7 +174,7 @@ typedef struct _VASliceParameterBufferVP8
*/
unsigned int slice_data_size;
/*
- * offset to the first byte of partition data
+ * offset to the first byte of partition data (control partition)
*/
unsigned int slice_data_offset;
/*
@@ -180,12 +182,20 @@ typedef struct _VASliceParameterBufferVP8
*/
unsigned int slice_data_flag;
/*
- * offset to the first bit of MB from the first byte of partition data
+ * offset to the first bit of MB from the first byte of partition data(slice_data_offset)
*/
unsigned int macroblock_offset;
- /* Partitions */
+ /*
+ * Partitions
+ * (1<<log2_nbr_of_dct_partitions)+1, count both control partition (frame header) and toke partition
+ */
unsigned char 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'
+ */
unsigned int partition_size[9];
} VASliceParameterBufferVP8;
@@ -219,6 +229,7 @@ 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]
*/
unsigned short quantization_index[4][6];
} VAIQMatrixBufferVP8;
diff --git a/va/va_dec_vp9.h b/va/va_dec_vp9.h
new file mode 100755
index 0000000..5503be6
--- /dev/null
+++ b/va/va_dec_vp9.h
@@ -0,0 +1,308 @@
+/*
+ * 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_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
+
+#include <stdint.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
+ * The value must be multiple of 8.
+ */
+ uint16_t frame_width;
+ /** \brief picture height
+ * The value must be multiple of 8.
+ */
+ uint16_t frame_height;
+
+ /** \brief Surface index of decoded current picture
+ */
+ VASurfaceID curr_pic;
+ /** \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.
+ */
+ 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;
+
+ /** \brief The byte count of current frame in the bitstream buffer,
+ * starting from first byte of the buffer.
+ */
+ uint32_t frame_data_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 version number
+ * value can be 0 or 1.
+ */
+ uint8_t version;
+ /**@}*/
+
+} 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;
+
+ /**@}*/
+
+} 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 per segment information
+ */
+ VASegmentParameterVP9 seg_param[8];
+
+ /**@}*/
+
+} VASliceParameterBufferVP9;
+
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VA_DEC_VP9_H */
diff --git a/va/va_enc_h264.h b/va/va_enc_h264.h
index 43aac42..6fe7506 100644
--- a/va/va_enc_h264.h
+++ b/va/va_enc_h264.h
@@ -36,6 +36,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include <va/va_enc.h>
/**
@@ -585,6 +586,124 @@ typedef struct _VAEncMacroblockParameterBufferH264 {
} info;
} VAEncMacroblockParameterBufferH264;
+/**
+ * \brief H.264 Mutiview Coding(MVC) Sequence Parameter Buffer
+ *
+ */
+typedef struct _VAEncSequenceParameterBufferH264_MVC {
+ /** brief Basic common sequence parameter */
+ VAEncSequenceParameterBufferH264 base;
+
+ /** brief Plus 1 specify the max number of views
+ * coded in the video sequence
+ */
+ uint16_t num_views_minus1;
+
+ /** brief Specify the view information in all layers */
+ struct H264SPSExtMVCViewInfo{
+ /** \brief The current view identifier. */
+ uint16_t view_id;
+ /** \brief Specifies the number of view components for inter-view
+ * prediction in the initialized RefPicList0 in decoding
+ * anchor views.
+ */
+ uint8_t num_anchor_refs_l0;
+ /** \brief Specifies the view_id for inter-view prediction in
+ * the initialized RefPicList0 in decoding anchor views.
+ */
+ uint16_t anchor_ref_l0[15];
+ /** \brief Specifies the number of view components for inter-view
+ * prediction in the initialized RefPicList1 in decoding
+ * anchor views
+ */
+ uint8_t num_anchor_refs_l1;
+ /** \brief Specifies the view_id for inter-view prediction in
+ * the initialized RefPicList1 in decoding anchor views.
+ */
+ uint16_t anchor_ref_l1[15];
+ /** \brief Specifies the number of view components for inter-view
+ * prediction in the initialized RefPicList0 in decoding
+ * non-anchor views.
+ */
+ uint8_t num_non_anchor_refs_l0;
+ /** \brief Specifies the view_id for inter-view prediction in
+ * the initialized RefPicList0 in decoding non-anchor views.
+ */
+ uint16_t non_anchor_ref_l0[15];
+ /** \brief Specifies the number of view components for inter-view
+ * prediction in the initialized RefPicList1 in decoding
+ * non-anchor view.
+ */
+ uint8_t num_non_anchor_refs_l1;
+ /** \brief Specifies the view_id for inter-view prediction in
+ * the initialized RefPicList1 in decoding non-anchor views.
+ */
+ uint16_t non_anchor_ref_l1[15];
+ }* view_list;
+
+ /** brief Plus 1 specifies the number of level values
+ * signalled for the coded video sequence
+ */
+ uint8_t num_level_values_signalled_minus1;
+
+ /** brief Level values operation for a set of the operation
+ * points in the current sequence
+ */
+ struct H264SPSExtMVCLevelValue {
+ /** \brief Specifies the level value signalled for the coded video sequence */
+ uint8_t level_idc;
+
+ /** \brief Plus 1 specifies the number of operation points to
+ * which the level indicated by level_idc applies
+ */
+ uint16_t num_applicable_ops_minus1;
+
+ /** \brief Represent the specific operation to the view in the video sequence */
+ struct H264SPSExtMVCLevelValueOps {
+ /** \brief Specify a temporal identifier for the NAL unit */
+ uint8_t temporal_id;
+ /** \brief Specify the number of the views whose level value will be modified */
+ uint16_t num_target_views_minus1;
+ /** \brief Specify the views whose level value will be modified */
+ uint16_t* target_view_id_list;
+ /** \brief Specify the number of views whose level value can be modified */
+ uint16_t num_views_minus1;
+ }* level_value_ops_list;
+
+ }* level_value_list;
+
+} VAEncSequenceParameterBufferH264_MVC;
+
+/**
+ * \brief H.264 Multiview Coding(MVC) Picture Parameter Buffer
+ *
+ */
+typedef struct _VAEncPictureParameterBufferH264_MVC
+{
+ /** brief Basic common picture parameter */
+ VAEncPictureParameterBufferH264 base;
+
+ /** brief Specifes the view id for current picture */
+ uint16_t view_id;
+
+ /** brief Specifes whether the picture is one anchor picture */
+ uint8_t anchor_pic_flag;
+
+ /** brief Specifes whether inter view reference frame
+ * is used to encode current picture.
+ */
+ uint8_t inter_view_flag;
+} VAEncPictureParameterBufferH264_MVC;
+
+typedef struct _VAEncQpBufferH264 {
+ /*
+ * \brief This structure holds luma 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.
+ */
+ unsigned char qp_y;
+} VAEncQpBufferH264;
+
/** \brief Bitstream writer attribute types specific to H.264 encoding. */
typedef enum {
/**
@@ -595,35 +714,6 @@ typedef enum {
VAEncBitstreamAttribMiscMask | 1),
} VAEncBitstreamAttribTypeH264;
-typedef struct _VAEncPictureParameterBufferH264MVC {
- /**
- * \brief Regular H.264 picture parameters
- *
- */
- VAEncPictureParameterBufferH264 base_picture_param;
- /**
- * \brief view id associated with this picture
- *
- */
- unsigned int view_id;
- /**
- * \brief same as H.264 MVC syntax element
- *
- */
- unsigned char anchor_picture_flag;
- /**
- * \brief same as H.264 MVC syntax element
- *
- */
- unsigned char inter_view_flag;
-
- /**
- * \brief Specifies view_id of each element in ReferenceFrames[16]
- *
- */
- unsigned int view_id_dpb[16];
-
-} VAEncPictureParameterBufferH264MVC;
/**
* \brief Allocates a new H.264 bitstream writer.
diff --git a/va/va_fool.c b/va/va_fool.c
index 96e8930..1df177f 100644
--- a/va/va_fool.c
+++ b/va/va_fool.c
@@ -52,6 +52,7 @@
* LIBVA_FOOL_ENCODE=<framename>:
* . if set, encode does nothing, but fill in the coded buffer from the content of files with
* name framename.0,framename.1,..., framename.N, framename.0,..., framename.N,...repeatly
+ * Use file name to determine h264 or vp8
* LIBVA_FOOL_JPEG=<framename>:fill the content of filename to codedbuf for jpeg encoding
* LIBVA_FOOL_POSTP:
* . if set, do nothing for vaPutSurface
@@ -66,6 +67,7 @@ int fool_postp = 0;
#define FOOL_BUFID_MASK 0xffffff00
struct fool_context {
+ int enabled; /* fool_codec is global, and it is for concurent encode/decode */
char *fn_enc;/* file pattern with codedbuf content for encode */
char *segbuf_enc; /* the segment buffer of coded buffer, load frome fn_enc */
int file_count;
@@ -88,11 +90,16 @@ struct fool_context {
};
#define FOOL_CTX(dpy) ((struct fool_context *)((VADisplayContextP)dpy)->vafool)
+
#define DPY2FOOLCTX(dpy) \
struct fool_context *fool_ctx = FOOL_CTX(dpy); \
- \
if (fool_ctx == NULL) \
- return 0; /* let driver go */ \
+ return 0; /* no fool for the context */ \
+
+#define DPY2FOOLCTX_CHK(dpy) \
+ struct fool_context *fool_ctx = FOOL_CTX(dpy); \
+ if ((fool_ctx == NULL) || (fool_ctx->enabled == 0)) \
+ return 0; /* no fool for the context */ \
/* Prototype declarations (functions defined in va.c) */
@@ -104,7 +111,6 @@ int va_parseConfig(char *env, char *env_value);
void va_FoolInit(VADisplay dpy)
{
char env_value[1024];
- int fool_index = 0;
struct fool_context *fool_ctx = calloc(sizeof(struct fool_context), 1);
@@ -157,24 +163,23 @@ int va_FoolEnd(VADisplay dpy)
free(fool_ctx);
((VADisplayContextP)dpy)->vafool = NULL;
-
+
return 0;
}
-
int va_FoolCreateConfig(
VADisplay dpy,
VAProfile profile,
VAEntrypoint entrypoint,
- VAConfigAttrib *attrib_list,
- int num_attribs,
- VAConfigID *config_id /* out */
+ VAConfigAttrib __maybe_unused *attrib_list,
+ int __maybe_unused num_attribs,
+ VAConfigID __maybe_unused *config_id /* out */
)
{
DPY2FOOLCTX(dpy);
fool_ctx->entrypoint = entrypoint;
-
+
/*
* check fool_codec to align with current context
* e.g. fool_codec = decode then for encode, the
@@ -182,29 +187,44 @@ int va_FoolCreateConfig(
* which is not desired
*/
if (((fool_codec & VA_FOOL_FLAG_DECODE) && (entrypoint == VAEntrypointVLD)) ||
- ((fool_codec & VA_FOOL_FLAG_ENCODE) && (entrypoint == VAEntrypointEncSlice)) ||
((fool_codec & VA_FOOL_FLAG_JPEG) && (entrypoint == VAEntrypointEncPicture)))
- ; /* the fool_codec is meaningful */
+ fool_ctx->enabled = 1;
+ else if ((fool_codec & VA_FOOL_FLAG_ENCODE) && (entrypoint == VAEntrypointEncSlice)) {
+ /* H264 is desired */
+ if (((profile == VAProfileH264Baseline ||
+ profile == VAProfileH264Main ||
+ profile == VAProfileH264High ||
+ profile == VAProfileH264ConstrainedBaseline)) &&
+ strstr(fool_ctx->fn_enc, "h264"))
+ fool_ctx->enabled = 1;
+
+ /* vp8 is desired */
+ if ((profile == VAProfileVP8Version0_3) &&
+ strstr(fool_ctx->fn_enc, "vp8"))
+ fool_ctx->enabled = 1;
+ }
+ if (fool_ctx->enabled)
+ va_infoMessage("FOOL is enabled for this context\n");
else
- fool_codec = 0;
+ va_infoMessage("FOOL is not enabled for this context\n");
- return 0; /* driver continue */
+ return 0; /* continue */
}
VAStatus va_FoolCreateBuffer(
VADisplay dpy,
- VAContextID context, /* in */
+ VAContextID __maybe_unused context, /* in */
VABufferType type, /* in */
unsigned int size, /* in */
unsigned int num_elements, /* in */
- void *data, /* in */
+ void __maybe_unused *data, /* in */
VABufferID *buf_id /* out */
)
{
unsigned int new_size = size * num_elements;
unsigned int old_size;
- DPY2FOOLCTX(dpy);
+ DPY2FOOLCTX_CHK(dpy);
old_size = fool_ctx->fool_buf_size[type] * fool_ctx->fool_buf_element[type];
@@ -231,17 +251,19 @@ VAStatus va_FoolBufferInfo(
unsigned int *num_elements /* out */
)
{
- unsigned int magic = buf_id & FOOL_BUFID_MASK;
- DPY2FOOLCTX(dpy);
+ unsigned int magic;
+
+ DPY2FOOLCTX_CHK(dpy);
+ magic = buf_id & FOOL_BUFID_MASK;
if (magic != FOOL_BUFID_MAGIC)
- return 0;
-
+ return 0; /* could be VAImageBufferType from vaDeriveImage */
+
*type = buf_id & 0xff;
*size = fool_ctx->fool_buf_size[*type];
*num_elements = fool_ctx->fool_buf_element[*type];;
- return 1; /* don't call into driver */
+ return 1; /* fool is valid */
}
static int va_FoolFillCodedBufEnc(struct fool_context *fool_ctx)
@@ -282,12 +304,11 @@ static int va_FoolFillCodedBufEnc(struct fool_context *fool_ctx)
return 0;
}
-
static int va_FoolFillCodedBufJPG(struct fool_context *fool_ctx)
{
struct stat file_stat = {0};
VACodedBufferSegment *codedbuf;
- int i, fd = -1;
+ int fd = -1;
if ((fd = open(fool_ctx->fn_jpg, O_RDONLY)) != -1) {
fstat(fd, &file_stat);
@@ -326,32 +347,27 @@ VAStatus va_FoolMapBuffer(
void **pbuf /* out */
)
{
- unsigned int buftype = buf_id & 0xff;
- unsigned int magic = buf_id & FOOL_BUFID_MASK;
- DPY2FOOLCTX(dpy);
+ unsigned int magic, buftype;
+ DPY2FOOLCTX_CHK(dpy);
- if (magic != FOOL_BUFID_MAGIC || buftype >= VABufferTypeMax || !pbuf)
- return 0;
-
- /* buf_id is the buffer type */
+ magic = buf_id & FOOL_BUFID_MASK;
+ if (magic != FOOL_BUFID_MAGIC)
+ return 0; /* could be VAImageBufferType from vaDeriveImage */
+
+ buftype = buf_id & 0xff;
*pbuf = fool_ctx->fool_buf[buftype];
- /* it is coded buffer, fill the fake segment buf from file */
+ /* it is coded buffer, fill coded segment from file */
if (*pbuf && (buftype == VAEncCodedBufferType))
va_FoolFillCodedBuf(fool_ctx);
- return 1; /* don't call into driver */
+ return 1; /* fool is valid */
}
-VAStatus va_FoolUnmapBuffer(
- VADisplay dpy,
- VABufferID buf_id /* in */
-)
+VAStatus va_FoolCheckContinuity(VADisplay dpy)
{
- unsigned int magic = buf_id & FOOL_BUFID_MASK;
+ DPY2FOOLCTX_CHK(dpy);
- if (magic != FOOL_BUFID_MAGIC)
- return 0;
-
- return 1;
+ return 1; /* fool is valid */
}
+
diff --git a/va/va_fool.h b/va/va_fool.h
index 5ea4830..6f4f917 100644
--- a/va/va_fool.h
+++ b/va/va_fool.h
@@ -41,13 +41,10 @@ extern int fool_postp;
#define VA_FOOL_FUNC(fool_func,...) \
if (fool_codec) { \
- ret = fool_func(__VA_ARGS__); \
+ if (fool_func(__VA_ARGS__)) \
+ return VA_STATUS_SUCCESS; \
}
-#define VA_FOOL_RETURN() \
- if (fool_codec) { \
- return VA_STATUS_SUCCESS; \
- }
-
+
void va_FoolInit(VADisplay dpy);
int va_FoolEnd(VADisplay dpy);
@@ -77,11 +74,6 @@ VAStatus va_FoolMapBuffer (
void **pbuf /* out */
);
-VAStatus va_FoolUnmapBuffer(
- VADisplay dpy,
- VABufferID buf_id /* in */
-);
-
VAStatus va_FoolBufferInfo (
VADisplay dpy,
VABufferID buf_id, /* in */
@@ -90,7 +82,8 @@ VAStatus va_FoolBufferInfo (
unsigned int *num_elements /* out */
);
-
+VAStatus va_FoolCheckContinuity(VADisplay dpy);
+
#ifdef __cplusplus
}
#endif
diff --git a/va/va_tpi.h b/va/va_tpi.h
index 3a53926..b7c9c57 100644
--- a/va/va_tpi.h
+++ b/va/va_tpi.h
@@ -62,7 +62,7 @@ typedef struct _VASurfaceAttributeTPI {
unsigned int chroma_u_offset; /* U offset from the beginning of the memory */
unsigned int chroma_v_offset; /* V offset from the beginning of the memory */
unsigned int count; /* buffer count for surface creation */
- unsigned int *buffers; /* buffer handles or user pointers */
+ unsigned long *buffers; /* buffer handles or user pointers */
unsigned int reserved[4]; /* used to pass additional information, like
* Android native window pointer
*/
diff --git a/va/va_trace.c b/va/va_trace.c
index 005da38..a70091e 100755
--- a/va/va_trace.c
+++ b/va/va_trace.c
@@ -56,8 +56,6 @@
* decode/encode or jpeg surfaces
* .LIBVA_TRACE_SURFACE_GEOMETRY=WIDTHxHEIGHT+XOFF+YOFF: only save part of surface context into file
* due to storage bandwidth limitation
- * .LIBVA_TRACE_LOGSIZE=numeric number: truncate the log_file or coded_clip_file, or decoded_yuv_file
- * when the size is bigger than the number
*/
/* global settings */
@@ -65,9 +63,6 @@
/* LIBVA_TRACE */
int trace_flag = 0;
-/* LIBVA_TRACE_LOGSIZE */
-static unsigned int trace_logsize = 0xffffffff; /* truncate the log when the size is bigger than it */
-
/* per context settings */
struct trace_context {
/* LIBVA_TRACE */
@@ -87,7 +82,6 @@ struct trace_context {
VASurfaceID trace_rendertarget; /* current render target */
VAProfile trace_profile; /* current profile for buffers */
VAEntrypoint trace_entrypoint; /* current entrypoint */
- VABufferID trace_codedbuf;
unsigned int trace_frame_no; /* current frame NO */
unsigned int trace_slice_no; /* current slice NO */
@@ -100,7 +94,6 @@ struct trace_context {
unsigned int trace_frame_width; /* current frame width */
unsigned int trace_frame_height; /* current frame height */
- unsigned int trace_sequence_start; /* get a new sequence for encoding or not */
};
#define TRACE_CTX(dpy) ((struct trace_context *)((VADisplayContextP)dpy)->vatrace)
@@ -183,11 +176,6 @@ void va_TraceInit(VADisplay dpy)
}
/* may re-get the global settings for multiple context */
- if (va_parseConfig("LIBVA_TRACE_LOGSIZE", &env_value[0]) == 0) {
- trace_logsize = atoi(env_value);
- va_infoMessage("LIBVA_TRACE_LOGSIZE is on, size is %d\n", trace_logsize);
- }
-
if ((trace_flag & VA_TRACE_FLAG_LOG) && (va_parseConfig("LIBVA_TRACE_BUFDATA", NULL) == 0)) {
trace_flag |= VA_TRACE_FLAG_BUFDATA;
va_infoMessage("LIBVA_TRACE_BUFDATA is on, dump buffer into log file\n");
@@ -272,22 +260,6 @@ void va_TraceEnd(VADisplay dpy)
}
-static unsigned int file_size(FILE *fp)
-{
- struct stat buf;
-
- fstat(fileno(fp), &buf);
-
- return buf.st_size;
-}
-
-
-static void truncate_file(FILE *fp)
-{
- ftruncate(fileno(fp), 0);
- rewind(fp);
-}
-
void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...)
{
va_list args;
@@ -295,13 +267,11 @@ void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...)
if (!(trace_flag & VA_TRACE_FLAG_LOG))
return;
- if (file_size(trace_ctx->trace_fp_log) >= trace_logsize)
- truncate_file(trace_ctx->trace_fp_log);
if (msg) {
struct timeval tv;
if (gettimeofday(&tv, NULL) == 0)
- fprintf(trace_ctx->trace_fp_log, "[%04d:%06d] ",
+ fprintf(trace_ctx->trace_fp_log, "[%04d.%06d] ",
(unsigned int)tv.tv_sec & 0xffff, (unsigned int)tv.tv_usec);
va_start(args, msg);
vfprintf(trace_ctx->trace_fp_log, msg, args);
@@ -310,39 +280,6 @@ void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...)
fflush(trace_ctx->trace_fp_log);
}
-void va_TraceCodedBuf(VADisplay dpy)
-{
- VACodedBufferSegment *buf_list = NULL;
- VAStatus va_status;
- int i = 0;
-
- DPY2TRACECTX(dpy);
-
- /* can only truncate at a sequence boudary */
- if (((file_size(trace_ctx->trace_fp_log) >= trace_logsize))
- && trace_ctx->trace_sequence_start) {
- va_TraceMsg(trace_ctx, "==========truncate file %s\n", trace_ctx->trace_codedbuf_fn);
- truncate_file(trace_ctx->trace_fp_log);
- }
-
- trace_ctx->trace_sequence_start = 0; /* only truncate coded file when meet next new sequence */
-
- va_status = vaMapBuffer(dpy, trace_ctx->trace_codedbuf, (void **)(&buf_list));
- if (va_status != VA_STATUS_SUCCESS)
- return;
-
- va_TraceMsg(trace_ctx, "==========dump codedbuf into file %s\n", trace_ctx->trace_codedbuf_fn);
-
- while (buf_list != NULL) {
- va_TraceMsg(trace_ctx, "\tVACodedBufferSegment[%d].size = %d\n", i++, buf_list->size);
- if (trace_ctx->trace_fp_codedbuf)
- fwrite(buf_list->buf, buf_list->size, 1, trace_ctx->trace_fp_codedbuf);
- buf_list = buf_list->next;
- }
- vaUnmapBuffer(dpy,trace_ctx->trace_codedbuf);
- va_TraceMsg(trace_ctx, NULL);
-}
-
void va_TraceSurface(VADisplay dpy)
{
@@ -366,10 +303,6 @@ void va_TraceSurface(VADisplay dpy)
va_TraceMsg(trace_ctx, "==========dump surface data in file %s\n", trace_ctx->trace_surface_fn);
- if ((file_size(trace_ctx->trace_fp_surface) >= trace_logsize)) {
- va_TraceMsg(trace_ctx, "==========truncate file %s\n", trace_ctx->trace_surface_fn);
- truncate_file(trace_ctx->trace_fp_surface);
- }
va_TraceMsg(trace_ctx, NULL);
va_status = vaLockSurface(
@@ -435,11 +368,12 @@ void va_TraceSurface(VADisplay dpy)
void va_TraceInitialize (
VADisplay dpy,
- int *major_version, /* out */
- int *minor_version /* out */
+ int __maybe_unused *major_version, /* out */
+ int __maybe_unused *minor_version /* out */
)
{
- DPY2TRACECTX(dpy);
+ DPY2TRACECTX(dpy);
+
TRACE_FUNCNAME(idx);
}
@@ -458,7 +392,7 @@ void va_TraceCreateConfig(
VAEntrypoint entrypoint,
VAConfigAttrib *attrib_list,
int num_attribs,
- VAConfigID *config_id /* out */
+ VAConfigID __maybe_unused *config_id /* out */
)
{
int i;
@@ -466,7 +400,7 @@ void va_TraceCreateConfig(
DPY2TRACECTX(dpy);
TRACE_FUNCNAME(idx);
-
+
va_TraceMsg(trace_ctx, "\tprofile = %d\n", profile);
va_TraceMsg(trace_ctx, "\tentrypoint = %d\n", entrypoint);
va_TraceMsg(trace_ctx, "\tnum_attribs = %d\n", num_attribs);
@@ -534,19 +468,50 @@ static void va_TraceSurfaceAttributes(
num = VASurfaceAttribCount;
for (i=0; i<num; i++) {
+ int type = p->value.type;
+
va_TraceMsg(trace_ctx, "\tattrib_list[%i] =\n", i);
va_TraceMsg(trace_ctx, "\t\ttype = %d\n", p->type);
va_TraceMsg(trace_ctx, "\t\tflags = %d\n", p->flags);
- va_TraceMsg(trace_ctx, "\t\tvalue.type = %d\n", p->value.type);
- if (p->value.type == VAGenericValueTypeInteger)
+ va_TraceMsg(trace_ctx, "\t\tvalue.type = %d\n", type);
+ switch (type) {
+ case VAGenericValueTypeInteger:
va_TraceMsg(trace_ctx, "\t\tvalue.value.i = 0x%08x\n", p->value.value.i);
- else if (p->value.type == VAGenericValueTypeFloat)
- va_TraceMsg(trace_ctx, "\t\tvalue.value.f = %f\n", p->value.value.f);
- else if (p->value.type == VAGenericValueTypePointer)
+ break;
+ case VAGenericValueTypeFloat:
+ va_TraceMsg(trace_ctx, "\t\tvalue.value.f = %f\n", p->value.value.f);
+ break;
+ case VAGenericValueTypePointer:
va_TraceMsg(trace_ctx, "\t\tvalue.value.p = %p\n", p->value.value.p);
- else if (p->value.type == VAGenericValueTypeFunc)
+ if ((p->type == VASurfaceAttribExternalBufferDescriptor) && p->value.value.p) {
+ VASurfaceAttribExternalBuffers *tmp = (VASurfaceAttribExternalBuffers *) p->value.value.p;
+ unsigned int j;
+
+ va_TraceMsg(trace_ctx, "\t\t--VASurfaceAttribExternalBufferDescriptor\n");
+ va_TraceMsg(trace_ctx, "\t\t pixel_format=0x%08x\n", tmp->pixel_format);
+ va_TraceMsg(trace_ctx, "\t\t width=%d\n", tmp->width);
+ va_TraceMsg(trace_ctx, "\t\t height=%d\n", tmp->height);
+ va_TraceMsg(trace_ctx, "\t\t data_size=%d\n", tmp->data_size);
+ va_TraceMsg(trace_ctx, "\t\t num_planes=%d\n", tmp->num_planes);
+ va_TraceMsg(trace_ctx, "\t\t pitches[4]=%d %d %d %d\n",
+ tmp->pitches[0], tmp->pitches[1], tmp->pitches[2], tmp->pitches[3]);
+ va_TraceMsg(trace_ctx, "\t\t offsets[4]=%d %d %d %d\n",
+ tmp->offsets[0], tmp->offsets[1], tmp->offsets[2], tmp->offsets[3]);
+ va_TraceMsg(trace_ctx, "\t\t flags=0x%08x\n", tmp->flags);
+ va_TraceMsg(trace_ctx, "\t\t num_buffers=0x%08x\n", tmp->num_buffers);
+ va_TraceMsg(trace_ctx, "\t\t buffers=%p\n", tmp->buffers);
+ for (j = 0; j < tmp->num_buffers; j++) {
+ va_TraceMsg(trace_ctx, "\t\t\tbuffers[%d]=%p\n", j, tmp->buffers[j]);
+ }
+ }
+ break;
+ case VAGenericValueTypeFunc:
va_TraceMsg(trace_ctx, "\t\tvalue.value.fn = %p\n", p->value.value.fn);
+ break;
+ default:
+ break;
+ }
p++;
}
@@ -682,11 +647,11 @@ static char * buffer_type_to_string(int type)
void va_TraceCreateBuffer (
VADisplay dpy,
- VAContextID context, /* in */
+ VAContextID __maybe_unused context, /* in */
VABufferType type, /* in */
unsigned int size, /* in */
unsigned int num_elements, /* in */
- void *data, /* in */
+ void __maybe_unused *data, /* in */
VABufferID *buf_id /* out */
)
{
@@ -773,6 +738,11 @@ void va_TraceMapBuffer (
va_TraceMsg(trace_ctx, "\t reserved = 0x%08x\n", buf_list->reserved);
va_TraceMsg(trace_ctx, "\t buf = 0x%08x\n", buf_list->buf);
+ if (trace_ctx->trace_fp_codedbuf) {
+ va_TraceMsg(trace_ctx, "\tDump the content to file\n");
+ fwrite(buf_list->buf, buf_list->size, 1, trace_ctx->trace_fp_codedbuf);
+ }
+
buf_list = buf_list->next;
}
va_TraceMsg(trace_ctx, NULL);
@@ -793,7 +763,9 @@ static void va_TraceVABuffers(
unsigned int dump_size = 64;
DPY2TRACECTX(dpy);
-
+
+ va_TraceMsg(trace_ctx, "\t context = %d, buffer = %d, type = %d, size = %d, num_elements = %d\n",
+ context, buffer, type, size, num_elements);
va_TraceMsg(trace_ctx, "--%s\n", buffer_type_to_string(type));
if (dump_size>size)
@@ -824,18 +796,17 @@ static void va_TraceVABuffers(
static void va_TraceVAPictureParameterBufferMPEG2(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAPictureParameterBufferMPEG2 *p=(VAPictureParameterBufferMPEG2 *)data;
DPY2TRACECTX(dpy);
va_TraceMsg(trace_ctx,"VAPictureParameterBufferMPEG2\n");
-
va_TraceMsg(trace_ctx,"\thorizontal size= %d\n", p->horizontal_size);
va_TraceMsg(trace_ctx,"\tvertical size= %d\n", p->vertical_size);
va_TraceMsg(trace_ctx,"\tforward reference picture= %d\n", p->forward_reference_picture);
@@ -863,18 +834,17 @@ static void va_TraceVAPictureParameterBufferMPEG2(
static void va_TraceVAIQMatrixBufferMPEG2(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAIQMatrixBufferMPEG2 *p=(VAIQMatrixBufferMPEG2 *)data;
DPY2TRACECTX(dpy);
va_TraceMsg(trace_ctx,"VAIQMatrixBufferMPEG2\n");
-
va_TraceMsg(trace_ctx,"\tload_intra_quantiser_matrix = %d\n", p->load_intra_quantiser_matrix);
va_TraceMsg(trace_ctx,"\tload_non_intra_quantiser_matrix = %d\n", p->load_non_intra_quantiser_matrix);
va_TraceMsg(trace_ctx,"\tload_chroma_intra_quantiser_matrix = %d\n", p->load_chroma_intra_quantiser_matrix);
@@ -891,11 +861,11 @@ static void va_TraceVAIQMatrixBufferMPEG2(
static void va_TraceVASliceParameterBufferMPEG2(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VASliceParameterBufferMPEG2 *p=(VASliceParameterBufferMPEG2 *)data;
@@ -907,7 +877,6 @@ static void va_TraceVASliceParameterBufferMPEG2(
trace_ctx->trace_slice_size = p->slice_data_size;
va_TraceMsg(trace_ctx,"VASliceParameterBufferMPEG2\n");
-
va_TraceMsg(trace_ctx,"\tslice_data_size = %d\n", p->slice_data_size);
va_TraceMsg(trace_ctx,"\tslice_data_offset = %d\n", p->slice_data_offset);
va_TraceMsg(trace_ctx,"\tslice_data_flag = %d\n", p->slice_data_flag);
@@ -923,11 +892,11 @@ static void va_TraceVASliceParameterBufferMPEG2(
static void va_TraceVAPictureParameterBufferJPEG(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
int i;
@@ -948,17 +917,18 @@ static void va_TraceVAPictureParameterBufferJPEG(
static void va_TraceVAIQMatrixBufferJPEG(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
int i, j;
static char tmp[1024];
VAIQMatrixBufferJPEGBaseline *p=(VAIQMatrixBufferJPEGBaseline *)data;
DPY2TRACECTX(dpy);
+
va_TraceMsg(trace_ctx,"*VAIQMatrixParameterBufferJPEG\n");
va_TraceMsg(trace_ctx,"\tload_quantiser_table =\n");
for (i = 0; i < 4; ++i) {
@@ -976,16 +946,17 @@ static void va_TraceVAIQMatrixBufferJPEG(
static void va_TraceVASliceParameterBufferJPEG(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
int i;
VASliceParameterBufferJPEGBaseline *p=(VASliceParameterBufferJPEGBaseline *)data;
DPY2TRACECTX(dpy);
+
va_TraceMsg(trace_ctx,"*VASliceParameterBufferJPEG\n");
va_TraceMsg(trace_ctx,"\tslice_data_size = %u\n", p->slice_data_size);
va_TraceMsg(trace_ctx,"\tslice_data_offset = %u\n", p->slice_data_offset);
@@ -1004,11 +975,11 @@ static void va_TraceVASliceParameterBufferJPEG(
static void va_TraceVAHuffmanTableBufferJPEG(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
int i, j;
@@ -1034,27 +1005,27 @@ static void va_TraceVAHuffmanTableBufferJPEG(
for (j = 0; j < 16; ++j) {
sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].num_ac_codes[j]);
}
- va_TraceMsg(trace_ctx,"\t\tnum_dc_codes =%s\n", tmp);
+ va_TraceMsg(trace_ctx,"\t\tnum_ac_codes =%s\n", tmp);
memset(tmp, 0, sizeof tmp);
for (j = 0; j < 162; ++j) {
sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].ac_values[j]);
}
- va_TraceMsg(trace_ctx,"\t\tnum_dc_codes =%s\n", tmp);
+ va_TraceMsg(trace_ctx,"\t\tac_values =%s\n", tmp);
memset(tmp, 0, sizeof tmp);
for (j = 0; j < 2; ++j) {
sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].pad[j]);
}
- va_TraceMsg(trace_ctx,"\t\tnum_dc_codes =%s\n", tmp);
+ va_TraceMsg(trace_ctx,"\t\tpad =%s\n", tmp);
}
}
static void va_TraceVAPictureParameterBufferMPEG4(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
int i;
@@ -1110,11 +1081,11 @@ static void va_TraceVAPictureParameterBufferMPEG4(
static void va_TraceVAIQMatrixBufferMPEG4(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
int i;
@@ -1139,18 +1110,17 @@ static void va_TraceVAIQMatrixBufferMPEG4(
static void va_TraceVAEncSequenceParameterBufferMPEG4(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncSequenceParameterBufferMPEG4 *p = (VAEncSequenceParameterBufferMPEG4 *)data;
DPY2TRACECTX(dpy);
-
+
va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferMPEG4\n");
-
va_TraceMsg(trace_ctx, "\tprofile_and_level_indication = %d\n", p->profile_and_level_indication);
va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period);
va_TraceMsg(trace_ctx, "\tvideo_object_layer_width = %d\n", p->video_object_layer_width);
@@ -1164,24 +1134,21 @@ static void va_TraceVAEncSequenceParameterBufferMPEG4(
va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp);
va_TraceMsg(trace_ctx, NULL);
- /* start a new sequce, coded log file can be truncated */
- trace_ctx->trace_sequence_start = 1;
-
return;
}
static void va_TraceVAEncPictureParameterBufferMPEG4(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncPictureParameterBufferMPEG4 *p = (VAEncPictureParameterBufferMPEG4 *)data;
DPY2TRACECTX(dpy);
-
+
va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferMPEG4\n");
va_TraceMsg(trace_ctx, "\treference_picture = 0x%08x\n", p->reference_picture);
va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture);
@@ -1193,19 +1160,17 @@ static void va_TraceVAEncPictureParameterBufferMPEG4(
va_TraceMsg(trace_ctx, "\tpicture_type = %d\n", p->picture_type);
va_TraceMsg(trace_ctx, NULL);
- trace_ctx->trace_codedbuf = p->coded_buf;
-
return;
}
static void va_TraceVASliceParameterBufferMPEG4(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VASliceParameterBufferMPEG4 *p=(VASliceParameterBufferMPEG4 *)data;
@@ -1244,11 +1209,11 @@ static inline void va_TraceFlagIfNotZero(
static void va_TraceVAPictureParameterBufferH264(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
int i;
@@ -1311,7 +1276,7 @@ static void va_TraceVAPictureParameterBufferH264(
va_TraceMsg(trace_ctx, "\tframe_num = %d\n", p->frame_num);
va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_default_active_minus1 = %d\n", p->num_ref_idx_l0_default_active_minus1);
va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_default_active_minus1 = %d\n", p->num_ref_idx_l1_default_active_minus1);
-
+
va_TraceMsg(trace_ctx, NULL);
return;
@@ -1319,11 +1284,11 @@ static void va_TraceVAPictureParameterBufferH264(
static void va_TraceVASliceParameterBufferH264(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
int i;
@@ -1412,11 +1377,11 @@ static void va_TraceVASliceParameterBufferH264(
static void va_TraceVAIQMatrixBufferH264(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data
)
{
@@ -1456,11 +1421,11 @@ static void va_TraceVAIQMatrixBufferH264(
static void va_TraceVAEncSequenceParameterBufferH264(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncSequenceParameterBufferH264 *p = (VAEncSequenceParameterBufferH264 *)data;
@@ -1513,20 +1478,17 @@ static void va_TraceVAEncSequenceParameterBufferH264(
va_TraceMsg(trace_ctx, NULL);
- /* start a new sequce, coded log file can be truncated */
- trace_ctx->trace_sequence_start = 1;
-
return;
}
static void va_TraceVAEncPictureParameterBufferH264(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncPictureParameterBufferH264 *p = (VAEncPictureParameterBufferH264 *)data;
@@ -1580,23 +1542,21 @@ static void va_TraceVAEncPictureParameterBufferH264(
va_TraceMsg(trace_ctx, NULL);
- trace_ctx->trace_codedbuf = p->coded_buf;
-
return;
}
static void va_TraceVAEncSliceParameterBuffer(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncSliceParameterBuffer* p = (VAEncSliceParameterBuffer*)data;
DPY2TRACECTX(dpy);
-
+
va_TraceMsg(trace_ctx, "\t--VAEncSliceParameterBuffer\n");
va_TraceMsg(trace_ctx, "\tstart_row_number = %d\n", p->start_row_number);
@@ -1612,11 +1572,11 @@ static void va_TraceVAEncSliceParameterBuffer(
static void va_TraceVAEncSliceParameterBufferH264(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncSliceParameterBufferH264* p = (VAEncSliceParameterBufferH264*)data;
@@ -1730,11 +1690,11 @@ static void va_TraceVAEncSliceParameterBufferH264(
static void va_TraceVAEncPackedHeaderParameterBufferType(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncPackedHeaderParameterBuffer* p = (VAEncPackedHeaderParameterBuffer*)data;
@@ -1763,6 +1723,7 @@ static void va_TraceVAEncMiscParameterBuffer(
{
VAEncMiscParameterBuffer* tmp = (VAEncMiscParameterBuffer*)data;
DPY2TRACECTX(dpy);
+ uint32_t i;
switch (tmp->type) {
case VAEncMiscParameterTypeFrameRate:
@@ -1824,6 +1785,16 @@ static void va_TraceVAEncMiscParameterBuffer(
va_TraceMsg(trace_ctx, "\tmax_frame_size = %d\n", p->max_frame_size);
break;
}
+ case VAEncMiscParameterTypeTemporalLayerStructure:
+ {
+ VAEncMiscParameterTemporalLayerStructure *p = (VAEncMiscParameterTemporalLayerStructure *)tmp->data;
+ va_TraceMsg(trace_ctx,"\t--VAEncMiscParameterTypeTemporalLayerStructure\n");
+ va_TraceMsg(trace_ctx,"\tnumber_of_layers = %d\n", p->number_of_layers);
+ va_TraceMsg(trace_ctx,"\tperiodicity = %d\n", p->periodicity);
+ for(i=0;i<p->periodicity;i++)
+ va_TraceMsg(trace_ctx,"\tlayer_id[%d] = %d\n", i, p->layer_id[i]);
+ break;
+ }
default:
va_TraceMsg(trace_ctx, "Unknown VAEncMiscParameterBuffer(type = %d):\n", tmp->type);
va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data);
@@ -1847,9 +1818,10 @@ static void va_TraceVAPictureParameterBufferVC1(
{
VAPictureParameterBufferVC1* p = (VAPictureParameterBufferVC1*)data;
DPY2TRACECTX(dpy);
-
+
va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferVC1\n");
-
+ va_TraceMsg(trace_ctx, "\t context = %d, buffer = %d, type = %d, size = %d, num_elements = %d\n",
+ context, buffer, type, size, num_elements);
va_TraceMsg(trace_ctx, "\tforward_reference_picture = 0x%08x\n", p->forward_reference_picture);
va_TraceMsg(trace_ctx, "\tbackward_reference_picture = 0x%08x\n", p->backward_reference_picture);
va_TraceMsg(trace_ctx, "\tinloop_decoded_picture = 0x%08x\n", p->inloop_decoded_picture);
@@ -1942,11 +1914,11 @@ static void va_TraceVAPictureParameterBufferVC1(
static void va_TraceVASliceParameterBufferVC1(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void* data
)
{
@@ -1967,11 +1939,11 @@ static void va_TraceVASliceParameterBufferVC1(
static void va_TraceVAEncSequenceParameterBufferVP8(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncSequenceParameterBufferVP8 *p = (VAEncSequenceParameterBufferVP8 *)data;
@@ -1996,19 +1968,16 @@ static void va_TraceVAEncSequenceParameterBufferVP8(
va_TraceMsg(trace_ctx, NULL);
- /* start a new sequce, coded log file can be truncated */
- trace_ctx->trace_sequence_start = 1;
-
return;
}
static void va_TraceVAEncPictureParameterBufferVP8(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused uffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncPictureParameterBufferVP8 *p = (VAEncPictureParameterBufferVP8 *)data;
@@ -2027,7 +1996,7 @@ static void va_TraceVAEncPictureParameterBufferVP8(
va_TraceMsg(trace_ctx, "\tref_flags.bits.no_ref_last = %d\n", p->ref_flags.bits.no_ref_last);
va_TraceMsg(trace_ctx, "\tref_flags.bits.no_ref_gf = %d\n", p->ref_flags.bits.no_ref_gf);
va_TraceMsg(trace_ctx, "\tref_flags.bits.no_ref_arf = %d\n", p->ref_flags.bits.no_ref_arf);
- va_TraceMsg(trace_ctx, "\tref_flags.bits.no_ref_arf = 0x%08x\n", p->ref_flags.bits.reserved);
+ va_TraceMsg(trace_ctx, "\tref_flags.bits.reserved = 0x%08x\n", p->ref_flags.bits.reserved);
va_TraceMsg(trace_ctx, "\tpic_flags.bits.frame_type = %d\n", p->pic_flags.bits.frame_type);
va_TraceMsg(trace_ctx, "\tpic_flags.bits.version = %d\n", p->pic_flags.bits.version);
@@ -2069,18 +2038,16 @@ static void va_TraceVAEncPictureParameterBufferVP8(
va_TraceMsg(trace_ctx, NULL);
- trace_ctx->trace_codedbuf = p->coded_buf;
-
return;
}
static void va_TraceVAPictureParameterBufferVP8(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
char tmp[1024];
@@ -2109,7 +2076,6 @@ static void va_TraceVAPictureParameterBufferVP8(
va_TraceMsg(trace_ctx, "\tsign_bias_golden = %d\n", p->pic_fields.bits.sign_bias_golden);
va_TraceMsg(trace_ctx, "\tsign_bias_alternate = %d\n", p->pic_fields.bits.sign_bias_alternate);
va_TraceMsg(trace_ctx, "\tmb_no_coeff_skip = %d\n", p->pic_fields.bits.mb_no_coeff_skip);
- va_TraceMsg(trace_ctx, "\tmb_skip_coeff = %d\n", p->pic_fields.bits.mb_skip_coeff);
va_TraceMsg(trace_ctx, "\tloop_filter_disable = %d\n", p->pic_fields.bits.loop_filter_disable);
va_TraceMsg(trace_ctx, "\tmb_segment_tree_probs: 0x%2x, 0x%2x, 0x%2x\n",
@@ -2153,11 +2119,11 @@ static void va_TraceVAPictureParameterBufferVP8(
static void va_TraceVASliceParameterBufferVP8(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VASliceParameterBufferVP8 *p = (VASliceParameterBufferVP8 *)data;
@@ -2182,11 +2148,11 @@ static void va_TraceVASliceParameterBufferVP8(
static void va_TraceVAIQMatrixBufferVP8(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
char tmp[1024];
@@ -2210,11 +2176,11 @@ static void va_TraceVAIQMatrixBufferVP8(
}
static void va_TraceVAProbabilityBufferVP8(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
char tmp[1024];
@@ -2240,7 +2206,7 @@ static void va_TraceVAProbabilityBufferVP8(
void va_TraceBeginPicture(
VADisplay dpy,
- VAContextID context,
+ VAContextID __maybe_unused context,
VASurfaceID render_target
)
{
@@ -2248,7 +2214,6 @@ void va_TraceBeginPicture(
TRACE_FUNCNAME(idx);
- va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
va_TraceMsg(trace_ctx, "\trender_targets = 0x%08x\n", render_target);
va_TraceMsg(trace_ctx, "\tframe_count = #%d\n", trace_ctx->trace_frame_no);
va_TraceMsg(trace_ctx, NULL);
@@ -2317,11 +2282,11 @@ static void va_TraceMPEG2Buf(
static void va_TraceVAEncSequenceParameterBufferH263(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncSequenceParameterBufferH263 *p = (VAEncSequenceParameterBufferH263 *)data;
@@ -2336,25 +2301,22 @@ static void va_TraceVAEncSequenceParameterBufferH263(
va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp);
va_TraceMsg(trace_ctx, NULL);
- /* start a new sequce, coded log file can be truncated */
- trace_ctx->trace_sequence_start = 1;
-
return;
}
static void va_TraceVAEncPictureParameterBufferH263(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncPictureParameterBufferH263 *p = (VAEncPictureParameterBufferH263 *)data;
DPY2TRACECTX(dpy);
-
+
va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferH263\n");
va_TraceMsg(trace_ctx, "\treference_picture = 0x%08x\n", p->reference_picture);
va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture);
@@ -2364,23 +2326,21 @@ static void va_TraceVAEncPictureParameterBufferH263(
va_TraceMsg(trace_ctx, "\tpicture_type = 0x%08x\n", p->picture_type);
va_TraceMsg(trace_ctx, NULL);
- trace_ctx->trace_codedbuf = p->coded_buf;
-
return;
}
static void va_TraceVAEncPictureParameterBufferJPEG(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncPictureParameterBufferJPEG *p = (VAEncPictureParameterBufferJPEG *)data;
int i;
-
+
DPY2TRACECTX(dpy);
va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferJPEG\n");
@@ -2396,55 +2356,68 @@ static void va_TraceVAEncPictureParameterBufferJPEG(
va_TraceMsg(trace_ctx, "\tsample_bit_depth = %d\n", p->sample_bit_depth);
va_TraceMsg(trace_ctx, "\tnum_scan = %d\n", p->num_scan);
va_TraceMsg(trace_ctx, "\tnum_components = %d\n", p->num_components);
- va_TraceMsg(trace_ctx, "\tcomponent_id[] = ");
- for (i=0; i<4; i++)
- va_TraceMsg(trace_ctx, "%d\t", p->component_id[i]);
- va_TraceMsg(trace_ctx, "\n");
- va_TraceMsg(trace_ctx, "\tquantiser_table_selector[] = ");
- for (i=0; i<4; i++)
- va_TraceMsg(trace_ctx, "%d\t", p->quantiser_table_selector[i]);
- va_TraceMsg(trace_ctx, "\n");
- va_TraceMsg(trace_ctx, "\tquality = %d\n", p->picture_height);
-
+ for (i=0; i<p->num_components; i++)
+ va_TraceMsg(trace_ctx, "\tcomponent_id[%d] = %d\n", i, p->component_id[i]);
+
+ if (p->quality > 0)
+ va_TraceMsg(trace_ctx, "\tquality = %d\n", p->quality);
+ else
+ va_TraceMsg(trace_ctx, "\tquantiser_table_selector[] = %d %d %d %d\n",
+ p->quantiser_table_selector[0],
+ p->quantiser_table_selector[1],
+ p->quantiser_table_selector[2],
+ p->quantiser_table_selector[3]);
+
va_TraceMsg(trace_ctx, NULL);
- trace_ctx->trace_codedbuf = p->coded_buf;
-
return;
}
static void va_TraceVAEncQMatrixBufferJPEG(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAQMatrixBufferJPEG *p = (VAQMatrixBufferJPEG *)data;
DPY2TRACECTX(dpy);
-
+
va_TraceMsg(trace_ctx, "\t--VAQMatrixBufferJPEG\n");
- va_TraceMsg(trace_ctx, "\tload_lum_quantiser_matrix = %d", p->load_lum_quantiser_matrix);
+ va_TraceMsg(trace_ctx, "\tload_lum_quantiser_matrix = %d\n", p->load_lum_quantiser_matrix);
if (p->load_lum_quantiser_matrix) {
int i;
- for (i = 0; i < 64; i++) {
- if ((i % 8) == 0)
- va_TraceMsg(trace_ctx, "\n\t");
- va_TraceMsg(trace_ctx, "\t0x%02x", p->lum_quantiser_matrix[i]);
+ for (i = 0; i < 8; i++) {
+ va_TraceMsg(trace_ctx,
+ "\t\t0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ p->lum_quantiser_matrix[i*8],
+ p->lum_quantiser_matrix[i*8 + 1],
+ p->lum_quantiser_matrix[i*8 + 2],
+ p->lum_quantiser_matrix[i*8 + 3],
+ p->lum_quantiser_matrix[i*8 + 4],
+ p->lum_quantiser_matrix[i*8 + 5],
+ p->lum_quantiser_matrix[i*8 + 6],
+ p->lum_quantiser_matrix[i*8 + 7]);
}
- va_TraceMsg(trace_ctx, "\n");
}
- va_TraceMsg(trace_ctx, "\tload_chroma_quantiser_matrix = %08x\n", p->load_chroma_quantiser_matrix);
+
+ va_TraceMsg(trace_ctx, "\tload_chroma_quantiser_matrix = %d\n", p->load_chroma_quantiser_matrix);
if (p->load_chroma_quantiser_matrix) {
int i;
- for (i = 0; i < 64; i++) {
- if ((i % 8) == 0)
- va_TraceMsg(trace_ctx, "\n\t");
- va_TraceMsg(trace_ctx, "\t0x%02x", p->chroma_quantiser_matrix[i]);
+ for (i = 0; i < 8; i++) {
+ va_TraceMsg(trace_ctx,
+ "\t\t0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ p->chroma_quantiser_matrix[i*8],
+ p->chroma_quantiser_matrix[i*8 + 1],
+ p->chroma_quantiser_matrix[i*8 + 2],
+ p->chroma_quantiser_matrix[i*8 + 3],
+ p->chroma_quantiser_matrix[i*8 + 4],
+ p->chroma_quantiser_matrix[i*8 + 5],
+ p->chroma_quantiser_matrix[i*8 + 6],
+ p->chroma_quantiser_matrix[i*8 + 7]);
}
- va_TraceMsg(trace_ctx, "\n");
}
va_TraceMsg(trace_ctx, NULL);
@@ -2455,16 +2428,16 @@ static void va_TraceVAEncQMatrixBufferJPEG(
static void va_TraceVAEncSliceParameterBufferJPEG(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data)
{
VAEncSliceParameterBufferJPEG *p = (VAEncSliceParameterBufferJPEG *)data;
int i;
-
+
DPY2TRACECTX(dpy);
va_TraceMsg(trace_ctx, "\t--VAEncSliceParameterBufferJPEG\n");
@@ -2485,14 +2458,16 @@ static void va_TraceVAEncSliceParameterBufferJPEG(
static void va_TraceH263Buf(
VADisplay dpy,
- VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VAContextID __maybe_unused context,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *pbuf
)
{
+ DPY2TRACECTX(dpy);
+
switch (type) {
case VAPictureParameterBufferType:/* print MPEG4 buffer */
va_TraceVAPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
@@ -2856,7 +2831,7 @@ static void va_TraceVC1Buf(
static void
va_TraceProcFilterParameterBufferDeinterlacing(
VADisplay dpy,
- VAContextID context,
+ VAContextID __maybe_unused context,
VAProcFilterParameterBufferBase *base
)
{
@@ -2872,7 +2847,7 @@ va_TraceProcFilterParameterBufferDeinterlacing(
static void
va_TraceProcFilterParameterBufferColorBalance(
VADisplay dpy,
- VAContextID context,
+ VAContextID __maybe_unused context,
VAProcFilterParameterBufferBase *base
)
{
@@ -2894,7 +2869,7 @@ va_TraceProcFilterParameterBufferBase(
{
DPY2TRACECTX(dpy);
- va_TraceMsg(trace_ctx, "\t type = %d\n", base->type);
+ va_TraceMsg(trace_ctx, "\t type = %d, context = %d\n", base->type, context);
}
static void
@@ -2909,7 +2884,7 @@ va_TraceProcFilterParameterBuffer(
unsigned int size;
unsigned int num_elements;
VAProcFilterParameterBufferBase *base_filter = NULL;
- int i;
+ unsigned int i;
DPY2TRACECTX(dpy);
@@ -2966,15 +2941,15 @@ static void
va_TraceVAProcPipelineParameterBuffer(
VADisplay dpy,
VAContextID context,
- VABufferID buffer,
- VABufferType type,
- unsigned int size,
- unsigned int num_elements,
+ VABufferID __maybe_unused buffer,
+ VABufferType __maybe_unused type,
+ unsigned int __maybe_unused size,
+ unsigned int __maybe_unused num_elements,
void *data
)
{
VAProcPipelineParameterBuffer *p = (VAProcPipelineParameterBuffer *)data;
- int i;
+ unsigned int i;
DPY2TRACECTX(dpy);
@@ -3075,7 +3050,7 @@ va_TraceNoneBuf(
void va_TraceRenderPicture(
VADisplay dpy,
- VAContextID context,
+ VAContextID __maybe_unused context,
VABufferID *buffers,
int num_buffers
)
@@ -3088,7 +3063,6 @@ void va_TraceRenderPicture(
TRACE_FUNCNAME(idx);
- va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
va_TraceMsg(trace_ctx, "\tnum_buffers = %d\n", num_buffers);
if (buffers == NULL)
return;
@@ -3161,14 +3135,14 @@ void va_TraceRenderPicture(
break;
case VAProfileVP8Version0_3:
for (j=0; j<num_elements; j++) {
- va_TraceMsg(trace_ctx, "\telement[%d] = ", j);
+ va_TraceMsg(trace_ctx, "\telement[%d] =\n", j);
va_TraceVP8Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
}
break;
case VAProfileNone:
for (j=0; j<num_elements; j++) {
- va_TraceMsg(trace_ctx, "\telement[%d] = ", j);
+ va_TraceMsg(trace_ctx, "\telement[%d] =\n", j);
va_TraceNoneBuf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
}
@@ -3185,8 +3159,8 @@ void va_TraceRenderPicture(
void va_TraceEndPicture(
VADisplay dpy,
- VAContextID context,
- int endpic_done
+ VAContextID __maybe_unused context,
+ int __maybe_unused endpic_done
)
{
int encode, decode, jpeg;
@@ -3194,7 +3168,6 @@ void va_TraceEndPicture(
TRACE_FUNCNAME(idx);
- va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
va_TraceMsg(trace_ctx, "\trender_targets = 0x%08x\n", trace_ctx->trace_rendertarget);
/* avoid to create so many empty files */
@@ -3207,12 +3180,6 @@ void va_TraceEndPicture(
(jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG)))
va_TraceSurface(dpy);
- /* trace coded buffer, do it after HW completes rendering */
- if ((encode || jpeg) && (trace_flag & VA_TRACE_FLAG_CODEDBUF)) {
- vaSyncSurface(dpy, trace_ctx->trace_rendertarget);
- va_TraceCodedBuf(dpy);
- }
-
/* trace decoded surface, do it after HW completes rendering */
if (decode && ((trace_flag & VA_TRACE_FLAG_SURFACE_DECODE))) {
vaSyncSurface(dpy, trace_ctx->trace_rendertarget);
@@ -3225,20 +3192,19 @@ void va_TraceEndPicture(
void va_TraceSyncSurface(
VADisplay dpy,
- VASurfaceID render_target
+ VASurfaceID __maybe_unused render_target
)
{
DPY2TRACECTX(dpy);
TRACE_FUNCNAME(idx);
- va_TraceMsg(trace_ctx, "\trender_target = 0x%08x\n", render_target);
va_TraceMsg(trace_ctx, NULL);
}
void va_TraceQuerySurfaceAttributes(
VADisplay dpy,
- VAConfigID config,
+ VAConfigID __maybe_unused config,
VASurfaceAttrib *attrib_list,
unsigned int *num_attribs
)
@@ -3246,7 +3212,6 @@ void va_TraceQuerySurfaceAttributes(
DPY2TRACECTX(dpy);
TRACE_FUNCNAME(idx);
- va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config);
va_TraceSurfaceAttributes(trace_ctx, attrib_list, num_attribs);
va_TraceMsg(trace_ctx, NULL);
@@ -3256,7 +3221,7 @@ void va_TraceQuerySurfaceAttributes(
void va_TraceQuerySurfaceStatus(
VADisplay dpy,
- VASurfaceID render_target,
+ VASurfaceID __maybe_unused render_target,
VASurfaceStatus *status /* out */
)
{
@@ -3264,7 +3229,6 @@ void va_TraceQuerySurfaceStatus(
TRACE_FUNCNAME(idx);
- va_TraceMsg(trace_ctx, "\trender_target = 0x%08x\n", render_target);
if (status)
va_TraceMsg(trace_ctx, "\tstatus = 0x%08x\n", *status);
va_TraceMsg(trace_ctx, NULL);
@@ -3338,14 +3302,13 @@ void va_TraceQueryDisplayAttributes (
static void va_TraceDisplayAttributes (
VADisplay dpy,
VADisplayAttribute *attr_list,
- int num_attributes
+ int __maybe_unused num_attributes
)
{
int i;
DPY2TRACECTX(dpy);
- va_TraceMsg(trace_ctx, "\tnum_attributes = %d\n", num_attributes);
if (attr_list == NULL)
return;
diff --git a/va/va_vpp.h b/va/va_vpp.h
index 290fa16..4b4f648 100644
--- a/va/va_vpp.h
+++ b/va/va_vpp.h
@@ -322,6 +322,8 @@ typedef enum _VAProcColorStandardType {
VAProcColorStandardXVYCC601,
/** \brief xvYCC709. */
VAProcColorStandardXVYCC709,
+ /** \brief ITU-R BT.2020. */
+ VAProcColorStandardBT2020,
/** \brief Number of color standards. */
VAProcColorStandardCount
} VAProcColorStandardType;
@@ -426,6 +428,21 @@ typedef struct _VABlendState {
#define VA_PIPELINE_FLAG_END 0x00000004
/**@}*/
+/** @name Chroma Siting flag */
+/**@{*/
+#define VA_CHROMA_SITING_UNKNOWN 0x00000000
+/** \brief Chroma samples are co-sited vertically on the top with the luma samples. */
+#define VA_CHROMA_SITING_VERTICAL_TOP 0x00000001
+/** \brief Chroma samples are not co-sited vertically with the luma samples. */
+#define VA_CHROMA_SITING_VERTICAL_CENTER 0x00000002
+/** \brief Chroma samples are co-sited vertically on the bottom with the luma samples. */
+#define VA_CHROMA_SITING_VERTICAL_BOTTOM 0x00000003
+/** \brief Chroma samples are co-sited horizontally on the left with the luma samples. */
+#define VA_CHROMA_SITING_HORIZONTAL_LEFT 0x00000004
+/** \brief Chroma samples are not co-sited horizontally with the luma samples. */
+#define VA_CHROMA_SITING_HORIZONTAL_CENTER 0x00000008
+/**@}*/
+
/** \brief Video processing pipeline capabilities. */
typedef struct _VAProcPipelineCaps {
/** \brief Pipeline flags. See VAProcPipelineParameterBuffer::pipeline_flags. */
@@ -607,6 +624,7 @@ typedef struct _VAProcPipelineParameterBuffer {
* \c VA_SRC_SMPTE_240.
* - Scaling: \c VA_FILTER_SCALING_DEFAULT, \c VA_FILTER_SCALING_FAST,
* \c VA_FILTER_SCALING_HQ, \c VA_FILTER_SCALING_NL_ANAMORPHIC.
+ * - Enable auto noise reduction: \c VA_FILTER_NOISEREDUCTION_AUTO.
*/
unsigned int filter_flags;
/**
@@ -692,6 +710,20 @@ typedef struct _VAProcPipelineParameterBuffer {
VASurfaceID *additional_outputs;
/** \brief Number of additional output surfaces. */
unsigned int num_additional_outputs;
+ /**
+ * \brief Flag to indicate the input surface flag such as chroma-siting,
+ * range flag and so on.
+ *
+ * The lower 4 bits are still used as chroma-siting flag
+ * The range_flag bit is used to indicate that the range flag of color-space conversion.
+ * -\ref VA_SOURCE_RANGE_FULL(Full range): Y/Cb/Cr is in [0, 255].It is
+ * mainly used for JPEG/JFIF formats. The combination with the BT601 flag
+ * means that JPEG/JFIF color-space conversion matrix is used.
+ * -\ref VA_SOURCE_RANGE_FULL(Reduced range): Y is in [16, 235] and Cb/Cr
+ * is in [16, 240]. It is mainly used for the YUV<->RGB color-space
+ * conversion in SDTV/HDTV/UHDTV.
+ */
+ unsigned int input_surface_flag;
} VAProcPipelineParameterBuffer;
/**
diff --git a/va/vendor/intel/va_intel_statistics.h b/va/vendor/intel/va_intel_statistics.h
index d63ca78..8b326e1 100644
--- a/va/vendor/intel/va_intel_statistics.h
+++ b/va/vendor/intel/va_intel_statistics.h
@@ -111,7 +111,7 @@ typedef struct _VAStatsStatisticsParameter16x16Intel
/** \brief VAStatsMotionVectorBufferTypeIntel. Motion vector buffer layout.
* Motion vector output is per 4x4 block. For each 4x4 block there is a pair of past and future
- * reference MVs as defined in VAMotionVectorIntel. Depending on Subblock partition,
+ * reference MVs as defined in VAMotionVector. Depending on Subblock partition,
* for the shape that is not 4x4, the MV is replicated so each 4x4 block has a pair of MVs.
* If only past reference is used, future MV should be ignored, and vice versa.
* The 16x16 block is in raster scan order, within the 16x16 block, each 4x4 block MV is ordered as below in memory.
@@ -130,17 +130,6 @@ typedef struct _VAStatsStatisticsParameter16x16Intel
*
**/
-/** \brief Motion vector data structure. */
-typedef struct _VAMotionVectorIntel {
- /** \mv0[0]: horizontal motion vector for past reference */
- /** \mv0[1]: vertical motion vector for past reference */
- /** \mv1[0]: horizontal motion vector for future reference */
- /** \mv1[1]: vertical motion vector for future reference */
- unsigned short mv0[2]; /* past reference */
- unsigned short mv1[2]; /* future reference */
-} VAMotionVectorIntel;
-
-
/** \brief VAStatsStatisticsBufferTypeIntel. Statistics buffer layout.
* 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