diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2009-01-20 08:32:47 -0800 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2009-01-20 08:32:47 -0800 |
commit | 7f29d4f8c9dc92d9d493f7c04fac8fa17265ad7d (patch) | |
tree | 5ae900764079a5f969e99e9464e18eefaee0e01a |
vdpinfo-0.0.1
-rw-r--r-- | LICENSE | 23 | ||||
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | VDPDeviceImpl.h | 138 | ||||
-rw-r--r-- | functions.py | 78 | ||||
-rw-r--r-- | vdpinfo.cpp | 368 |
5 files changed, 619 insertions, 0 deletions
@@ -0,0 +1,23 @@ +Copyright (c) 2008 Wladimir J. van der Laan + +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, sublicense, 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 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 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS 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. + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..756171d --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +CXXFLAGS=-O3 -ffast-math -g -march=opteron +LDFLAGS=-lvdpau -lX11 + +PROGRAMS=vdpinfo + +all: $(PROGRAMS) + +vdpinfo: vdpinfo.o + $(CXX) -o $@ $^ $(LDFLAGS) + +clean: + rm -f *.o $(PROGRAMS) diff --git a/VDPDeviceImpl.h b/VDPDeviceImpl.h new file mode 100644 index 0000000..b5392aa --- /dev/null +++ b/VDPDeviceImpl.h @@ -0,0 +1,138 @@ +#ifndef H_VDPDeviceImpl +#define H_VDPDeviceImpl +#include <assert.h> +struct VDPDeviceImpl { + VDPDeviceImpl(VdpDevice device, VdpGetProcAddress *get_proc_address); + VdpDevice device; + + VdpGetErrorString *GetErrorString; + VdpGetProcAddress *GetProcAddress; + VdpGetApiVersion *GetApiVersion; + VdpGetInformationString *GetInformationString; + VdpDeviceDestroy *DeviceDestroy; + VdpGenerateCSCMatrix *GenerateCSCMatrix; + VdpVideoSurfaceQueryCapabilities *VideoSurfaceQueryCapabilities; + VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities *VideoSurfaceQueryGetPutBitsYCbCrCapabilities; + VdpVideoSurfaceCreate *VideoSurfaceCreate; + VdpVideoSurfaceDestroy *VideoSurfaceDestroy; + VdpVideoSurfaceGetParameters *VideoSurfaceGetParameters; + VdpVideoSurfaceGetBitsYCbCr *VideoSurfaceGetBitsYCbCr; + VdpVideoSurfacePutBitsYCbCr *VideoSurfacePutBitsYCbCr; + VdpOutputSurfaceQueryCapabilities *OutputSurfaceQueryCapabilities; + VdpOutputSurfaceQueryGetPutBitsNativeCapabilities *OutputSurfaceQueryGetPutBitsNativeCapabilities; + VdpOutputSurfaceQueryPutBitsIndexedCapabilities *OutputSurfaceQueryPutBitsIndexedCapabilities; + VdpOutputSurfaceQueryPutBitsYCbCrCapabilities *OutputSurfaceQueryPutBitsYCbCrCapabilities; + VdpOutputSurfaceCreate *OutputSurfaceCreate; + VdpOutputSurfaceDestroy *OutputSurfaceDestroy; + VdpOutputSurfaceGetParameters *OutputSurfaceGetParameters; + VdpOutputSurfaceGetBitsNative *OutputSurfaceGetBitsNative; + VdpOutputSurfacePutBitsNative *OutputSurfacePutBitsNative; + VdpOutputSurfacePutBitsIndexed *OutputSurfacePutBitsIndexed; + VdpOutputSurfacePutBitsYCbCr *OutputSurfacePutBitsYCbCr; + VdpBitmapSurfaceQueryCapabilities *BitmapSurfaceQueryCapabilities; + VdpBitmapSurfaceCreate *BitmapSurfaceCreate; + VdpBitmapSurfaceDestroy *BitmapSurfaceDestroy; + VdpBitmapSurfaceGetParameters *BitmapSurfaceGetParameters; + VdpBitmapSurfacePutBitsNative *BitmapSurfacePutBitsNative; + VdpOutputSurfaceRenderOutputSurface *OutputSurfaceRenderOutputSurface; + VdpOutputSurfaceRenderBitmapSurface *OutputSurfaceRenderBitmapSurface; + VdpDecoderQueryCapabilities *DecoderQueryCapabilities; + VdpDecoderCreate *DecoderCreate; + VdpDecoderDestroy *DecoderDestroy; + VdpDecoderGetParameters *DecoderGetParameters; + VdpDecoderRender *DecoderRender; + VdpVideoMixerQueryFeatureSupport *VideoMixerQueryFeatureSupport; + VdpVideoMixerQueryParameterSupport *VideoMixerQueryParameterSupport; + VdpVideoMixerQueryAttributeSupport *VideoMixerQueryAttributeSupport; + VdpVideoMixerQueryParameterValueRange *VideoMixerQueryParameterValueRange; + VdpVideoMixerQueryAttributeValueRange *VideoMixerQueryAttributeValueRange; + VdpVideoMixerCreate *VideoMixerCreate; + VdpVideoMixerSetFeatureEnables *VideoMixerSetFeatureEnables; + VdpVideoMixerSetAttributeValues *VideoMixerSetAttributeValues; + VdpVideoMixerGetFeatureSupport *VideoMixerGetFeatureSupport; + VdpVideoMixerGetFeatureEnables *VideoMixerGetFeatureEnables; + VdpVideoMixerGetParameterValues *VideoMixerGetParameterValues; + VdpVideoMixerGetAttributeValues *VideoMixerGetAttributeValues; + VdpVideoMixerDestroy *VideoMixerDestroy; + VdpVideoMixerRender *VideoMixerRender; + VdpPresentationQueueTargetDestroy *PresentationQueueTargetDestroy; + VdpPresentationQueueCreate *PresentationQueueCreate; + VdpPresentationQueueDestroy *PresentationQueueDestroy; + VdpPresentationQueueSetBackgroundColor *PresentationQueueSetBackgroundColor; + VdpPresentationQueueGetBackgroundColor *PresentationQueueGetBackgroundColor; + VdpPresentationQueueGetTime *PresentationQueueGetTime; + VdpPresentationQueueDisplay *PresentationQueueDisplay; + VdpPresentationQueueBlockUntilSurfaceIdle *PresentationQueueBlockUntilSurfaceIdle; + VdpPresentationQueueQuerySurfaceStatus *PresentationQueueQuerySurfaceStatus; + VdpPreemptionCallbackRegister *PreemptionCallbackRegister; + VdpPresentationQueueTargetCreateX11 *PresentationQueueTargetCreateX11; +}; +#define GETADDR(device, function_id, function_pointer) \ + assert(get_proc_address(device, function_id, function_pointer) == VDP_STATUS_OK) +VDPDeviceImpl::VDPDeviceImpl(VdpDevice device, VdpGetProcAddress *get_proc_address): + device(device) +{ + GETADDR(device, VDP_FUNC_ID_GET_ERROR_STRING, (void**)&GetErrorString); + GETADDR(device, VDP_FUNC_ID_GET_PROC_ADDRESS, (void**)&GetProcAddress); + GETADDR(device, VDP_FUNC_ID_GET_API_VERSION, (void**)&GetApiVersion); + GETADDR(device, VDP_FUNC_ID_GET_INFORMATION_STRING, (void**)&GetInformationString); + GETADDR(device, VDP_FUNC_ID_DEVICE_DESTROY, (void**)&DeviceDestroy); + GETADDR(device, VDP_FUNC_ID_GENERATE_CSC_MATRIX, (void**)&GenerateCSCMatrix); + GETADDR(device, VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES, (void**)&VideoSurfaceQueryCapabilities); + GETADDR(device, VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES, (void**)&VideoSurfaceQueryGetPutBitsYCbCrCapabilities); + GETADDR(device, VDP_FUNC_ID_VIDEO_SURFACE_CREATE, (void**)&VideoSurfaceCreate); + GETADDR(device, VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, (void**)&VideoSurfaceDestroy); + GETADDR(device, VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS, (void**)&VideoSurfaceGetParameters); + GETADDR(device, VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR, (void**)&VideoSurfaceGetBitsYCbCr); + GETADDR(device, VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR, (void**)&VideoSurfacePutBitsYCbCr); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES, (void**)&OutputSurfaceQueryCapabilities); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_GET_PUT_BITS_NATIVE_CAPABILITIES, (void**)&OutputSurfaceQueryGetPutBitsNativeCapabilities); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES, (void**)&OutputSurfaceQueryPutBitsIndexedCapabilities); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES, (void**)&OutputSurfaceQueryPutBitsYCbCrCapabilities); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_CREATE, (void**)&OutputSurfaceCreate); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY, (void**)&OutputSurfaceDestroy); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS, (void**)&OutputSurfaceGetParameters); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE, (void**)&OutputSurfaceGetBitsNative); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE, (void**)&OutputSurfacePutBitsNative); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED, (void**)&OutputSurfacePutBitsIndexed); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR, (void**)&OutputSurfacePutBitsYCbCr); + GETADDR(device, VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES, (void**)&BitmapSurfaceQueryCapabilities); + GETADDR(device, VDP_FUNC_ID_BITMAP_SURFACE_CREATE, (void**)&BitmapSurfaceCreate); + GETADDR(device, VDP_FUNC_ID_BITMAP_SURFACE_DESTROY, (void**)&BitmapSurfaceDestroy); + GETADDR(device, VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS, (void**)&BitmapSurfaceGetParameters); + GETADDR(device, VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE, (void**)&BitmapSurfacePutBitsNative); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, (void**)&OutputSurfaceRenderOutputSurface); + GETADDR(device, VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE, (void**)&OutputSurfaceRenderBitmapSurface); + GETADDR(device, VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES, (void**)&DecoderQueryCapabilities); + GETADDR(device, VDP_FUNC_ID_DECODER_CREATE, (void**)&DecoderCreate); + GETADDR(device, VDP_FUNC_ID_DECODER_DESTROY, (void**)&DecoderDestroy); + GETADDR(device, VDP_FUNC_ID_DECODER_GET_PARAMETERS, (void**)&DecoderGetParameters); + GETADDR(device, VDP_FUNC_ID_DECODER_RENDER, (void**)&DecoderRender); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT, (void**)&VideoMixerQueryFeatureSupport); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT, (void**)&VideoMixerQueryParameterSupport); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT, (void**)&VideoMixerQueryAttributeSupport); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_VALUE_RANGE, (void**)&VideoMixerQueryParameterValueRange); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_VALUE_RANGE, (void**)&VideoMixerQueryAttributeValueRange); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_CREATE, (void**)&VideoMixerCreate); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES, (void**)&VideoMixerSetFeatureEnables); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES, (void**)&VideoMixerSetAttributeValues); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT, (void**)&VideoMixerGetFeatureSupport); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES, (void**)&VideoMixerGetFeatureEnables); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES, (void**)&VideoMixerGetParameterValues); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES, (void**)&VideoMixerGetAttributeValues); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_DESTROY, (void**)&VideoMixerDestroy); + GETADDR(device, VDP_FUNC_ID_VIDEO_MIXER_RENDER, (void**)&VideoMixerRender); + GETADDR(device, VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY, (void**)&PresentationQueueTargetDestroy); + GETADDR(device, VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE, (void**)&PresentationQueueCreate); + GETADDR(device, VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY, (void**)&PresentationQueueDestroy); + GETADDR(device, VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR, (void**)&PresentationQueueSetBackgroundColor); + GETADDR(device, VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR, (void**)&PresentationQueueGetBackgroundColor); + GETADDR(device, VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME, (void**)&PresentationQueueGetTime); + GETADDR(device, VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY, (void**)&PresentationQueueDisplay); + GETADDR(device, VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, (void**)&PresentationQueueBlockUntilSurfaceIdle); + GETADDR(device, VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS, (void**)&PresentationQueueQuerySurfaceStatus); + GETADDR(device, VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER, (void**)&PreemptionCallbackRegister); + GETADDR(device, VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11, (void**)&PresentationQueueTargetCreateX11); +} +#undef GETADDR +#endif diff --git a/functions.py b/functions.py new file mode 100644 index 0000000..3a7d430 --- /dev/null +++ b/functions.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# Build VDPDeviceImpl.h +# (C) Wladimir J. van der Laan 2008 +from sys import stderr + +def process_file(fname): + """Process include file""" + f = open(fname, "r") + while True: + line = f.readline() + if not line: + break + line = line.rstrip() + if line.startswith("#define VDP_FUNC_ID_"): + begin = line.find("VDP_") + end = line.find(" ", begin) + funcname = line[begin:end] + functions.append(funcname) + if line.startswith("typedef") and line.endswith("("): + begin = line.rfind("Vdp") + end = line.find("(") + typename = line[begin:end] + types[typename[3:].lower()] = typename + f.close() + +def lower_case(s): + "BLA_BLA to blabla" + parts = s.split("_") + parts = [x.lower() for x in parts] + return "".join(parts) + +functions = [] +types = {} + +process_file("/usr/include/vdpau/vdpau.h") +process_file("/usr/include/vdpau/vdpau_x11.h") + +# Prototype +proto = [] +for f in functions: + if f == "VDP_FUNC_ID_BASE_WINSYS": # skip this one + continue + base = f[12:] + # to camelcase + base = lower_case(base) + try: + proto.append((f, types[base], types[base][3:])) + except KeyError: + stderr.write("No prototype found for %s (%s)\n" %(f, base)) + +# We now have an array of prototypes and VDP_FUNC_ID... +# Build our impl class +print "#ifndef H_VDPDeviceImpl" +print "#define H_VDPDeviceImpl" +print "#include <assert.h>" +print "struct VDPDeviceImpl {" +print " VDPDeviceImpl(VdpDevice device, VdpGetProcAddress *get_proc_address);" +print " VdpDevice device;" +print +for (id, type, name) in proto: + print " %s *%s;" % (type, name) +print "};"; + +print "#define GETADDR(device, function_id, function_pointer) \\" +print " assert(get_proc_address(device, function_id, function_pointer) == VDP_STATUS_OK)" + +print "VDPDeviceImpl::VDPDeviceImpl(VdpDevice device, VdpGetProcAddress *get_proc_address):" +print " device(device)" +print "{" +# look'em up +for (id, type, name) in proto: + print " GETADDR(device, %s, (void**)&%s);" % (id, name) +print "}" + +print "#undef GETADDR" + +print "#endif" +#print proto diff --git a/vdpinfo.cpp b/vdpinfo.cpp new file mode 100644 index 0000000..b3a2920 --- /dev/null +++ b/vdpinfo.cpp @@ -0,0 +1,368 @@ +/* +Query and display NVIDIA VDPAU capabilities, a la glxinfo +version 0.0.1 + +Copyright (c) 2008 Wladimir J. van der Laan + +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, sublicense, 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 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 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS 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. +*/ +/// TODO +/// - possible bug, querying VDP_CHROMA_TYPE_444 returns an error +/// (VDP_STATUS_INVALID_CHROMA_TYPE) is this NVIDIA or us? +/// - parse display/screen from command line +/// - list color table formats for queryOutputSurface + +#include <stdlib.h> +#include <stdio.h> +#include <vdpau/vdpau.h> +#include <vdpau/vdpau_x11.h> + +#include "VDPDeviceImpl.h" + +/******************* Base ****************/ + +void queryBaseInfo(VDPDeviceImpl *device) +{ + uint32_t api; + const char *info; + if(device->GetApiVersion(&api) != VDP_STATUS_OK || + device->GetInformationString(&info) != VDP_STATUS_OK) + { + fprintf(stderr, "Error querying API version or information\n"); + exit(-1); + } + printf("API version: %i\n", api); + printf("Information string: %s\n", info); +} + +/* Generic description structure */ +struct Desc +{ + const char *name; + uint32_t id; +}; + +/**************** Video surface ************/ +Desc chroma_types[] = { +{"420", VDP_CHROMA_TYPE_420}, +{"422", VDP_CHROMA_TYPE_422}, +{"444", VDP_CHROMA_TYPE_444}, +}; +const size_t chroma_type_count = sizeof(chroma_types)/sizeof(Desc); + +Desc ycbcr_types[] = { +{"NV12", VDP_YCBCR_FORMAT_NV12}, +{"YV12", VDP_YCBCR_FORMAT_YV12}, +{"UYVY", VDP_YCBCR_FORMAT_UYVY}, +{"YUYV", VDP_YCBCR_FORMAT_YUYV}, +{"Y8U8V8A8", VDP_YCBCR_FORMAT_Y8U8V8A8}, +{"V8U8Y8A8", VDP_YCBCR_FORMAT_V8U8Y8A8}, +}; +const size_t ycbcr_type_count = sizeof(ycbcr_types)/sizeof(Desc); + +Desc rgb_types[] = { +{"B8G8R8A8", VDP_RGBA_FORMAT_B8G8R8A8}, +{"R8G8B8A8", VDP_RGBA_FORMAT_R8G8B8A8}, +{"R10G10B10A2", VDP_RGBA_FORMAT_R10G10B10A2}, +{"B10G10R10A2", VDP_RGBA_FORMAT_B10G10R10A2}, +{"A8", VDP_RGBA_FORMAT_A8}, +}; +const size_t rgb_type_count = sizeof(rgb_types)/sizeof(Desc); + +Desc indexed_types[] = { +{"A4I4", VDP_INDEXED_FORMAT_A4I4}, +{"I4A4", VDP_INDEXED_FORMAT_I4A4}, +{"A8I8", VDP_INDEXED_FORMAT_A8I8}, +{"I8A8", VDP_INDEXED_FORMAT_I8A8}, +}; +const size_t indexed_type_count = sizeof(indexed_types)/sizeof(Desc); + +Desc color_table_formats[] = { +{"B8G8R8X8", VDP_COLOR_TABLE_FORMAT_B8G8R8X8}, +}; +const size_t color_table_format_count = sizeof(color_table_formats)/sizeof(Desc); + + +void queryVideoSurface(VDPDeviceImpl *device) +{ + VdpStatus rv; + printf("\nVideo surface:\n\n"); + printf("name width height types\n"); + printf("-------------------------------------------\n"); + for(int x=0; x<chroma_type_count; ++x) + { + VdpBool is_supported; + uint32_t max_width, max_height; + + rv = device->VideoSurfaceQueryCapabilities(device->device, chroma_types[x].id, + &is_supported, &max_width, &max_height); + if(rv == VDP_STATUS_OK && is_supported) + { + printf("%-6s %5i %5i ", chroma_types[x].name, + max_width, max_height); + /* Find out supported formats */ + for(int y=0; y<ycbcr_type_count; ++y) + { + rv = device->VideoSurfaceQueryGetPutBitsYCbCrCapabilities( + device->device, chroma_types[x].id, ycbcr_types[y].id, + &is_supported); + if(rv == VDP_STATUS_OK && is_supported) + { + printf("%s ", ycbcr_types[y].name); + } + } + printf("\n"); + } + } +} + +/***************** Output surface ****************/ +void queryOutputSurface(VDPDeviceImpl *device) +{ + VdpStatus rv; + printf("\nOutput surface:\n\n"); + printf("name width height nat types\n"); + printf("----------------------------------------------------\n"); + for(int x=0; x<rgb_type_count; ++x) + { + VdpBool is_supported, native=false; + uint32_t max_width, max_height; + + rv = device->OutputSurfaceQueryCapabilities(device->device, rgb_types[x].id, + &is_supported, &max_width, &max_height); + device->OutputSurfaceQueryGetPutBitsNativeCapabilities(device->device, rgb_types[x].id, + &native); + if(rv == VDP_STATUS_OK && is_supported) + { + printf("%-16s %5i %5i %c ", rgb_types[x].name, + max_width, max_height, native?'y':'-'); + /* Find out supported formats */ + for(int y=0; y<ycbcr_type_count; ++y) + { + rv = device->OutputSurfaceQueryPutBitsYCbCrCapabilities( + device->device, chroma_types[x].id, ycbcr_types[y].id, + &is_supported); + if(rv == VDP_STATUS_OK && is_supported) + { + printf("%s ", ycbcr_types[y].name); + } + } + printf("\n"); + } + } + // OutputSurfaceQueryPutBitsIndexedCapabilities + // rgba, idx, colortable -> supported +} + +/***************** Bitmap surface ****************/ +void queryBitmapSurface(VDPDeviceImpl *device) +{ + VdpStatus rv; + printf("\nBitmap surface:\n\n"); + printf("name width height\n"); + printf("-------------------------------------------\n"); + for(int x=0; x<rgb_type_count; ++x) + { + VdpBool is_supported; + uint32_t max_width, max_height; + + rv = device->BitmapSurfaceQueryCapabilities(device->device, rgb_types[x].id, + &is_supported, &max_width, &max_height); + if(rv == VDP_STATUS_OK && is_supported) + { + printf("%-16s %5i %5i\n", rgb_types[x].name, + max_width, max_height); + } + } +} + +/******************* Video mixer ****************/ + +Desc mixer_features[] = { +{"DEINTERLACE_TEMPORAL",VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL}, +{"DEINTERLACE_TEMPORAL_SPATIAL",VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL}, +{"INVERSE_TELECINE",VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE}, +{"NOISE_REDUCTION",VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION}, +{"SHARPNESS",VDP_VIDEO_MIXER_FEATURE_SHARPNESS}, +{"LUMA_KEY",VDP_VIDEO_MIXER_FEATURE_LUMA_KEY}, +}; +const size_t mixer_features_count = sizeof(mixer_features)/sizeof(Desc); + +Desc mixer_parameters[] = { +{"VIDEO_SURFACE_WIDTH",VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH}, +{"VIDEO_SURFACE_HEIGHT",VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT}, +{"CHROMA_TYPE",VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE}, +{"LAYERS",VDP_VIDEO_MIXER_PARAMETER_LAYERS}, +}; +const size_t mixer_parameters_count = sizeof(mixer_parameters)/sizeof(Desc); + +Desc mixer_attributes[] = { +{"BACKGROUND_COLOR",VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR}, +{"CSC_MATRIX",VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX}, +{"NOISE_REDUCTION_LEVEL",VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL}, +{"SHARPNESS_LEVEL",VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL}, +{"LUMA_KEY_MIN_LUMA",VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA}, +{"LUMA_KEY_MAX_LUMA",VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA}, +}; +const size_t mixer_attributes_count = sizeof(mixer_attributes)/sizeof(Desc); + +void queryVideoMixer(VDPDeviceImpl *device) +{ + VdpStatus rv; + printf("\nVideo mixer:\n\n"); + // Features + printf("feature name sup\n"); + printf("------------------------------------\n"); + for(int x=0; x<mixer_features_count; ++x) + { + VdpBool is_supported; + + rv = device->VideoMixerQueryFeatureSupport(device->device, mixer_features[x].id, + &is_supported); + is_supported = (rv == VDP_STATUS_OK && is_supported); + printf("%-32s %c\n", mixer_features[x].name, + is_supported?'y':'-'); + + } + printf("\n"); + // Parameters (+range) + printf("parameter name sup min max\n"); + printf("-----------------------------------------------------\n"); + for(int x=0; x<mixer_parameters_count; ++x) + { + VdpBool is_supported; + + rv = device->VideoMixerQueryParameterSupport(device->device, mixer_parameters[x].id, + &is_supported); + is_supported = (rv == VDP_STATUS_OK && is_supported); + printf("%-32s %c ", mixer_parameters[x].name, + is_supported?'y':'-'); + if(is_supported) + { + uint32_t minval, maxval; + rv = device->VideoMixerQueryParameterValueRange(device->device, mixer_parameters[x].id, + (void*)&minval, (void*)&maxval); + printf("%08x %08x", minval, maxval); + } + printf("\n"); + } + printf("\n"); + + // Attributes (+range) + printf("attribute name sup min max\n"); + printf("-----------------------------------------------------\n"); + for(int x=0; x<mixer_parameters_count; ++x) + { + VdpBool is_supported; + + rv = device->VideoMixerQueryAttributeSupport(device->device, mixer_attributes[x].id, + &is_supported); + is_supported = (rv == VDP_STATUS_OK && is_supported); + printf("%-32s %c ", mixer_attributes[x].name, + is_supported?'y':'-'); + if(is_supported) + { + uint32_t minval, maxval; + rv = device->VideoMixerQueryAttributeValueRange(device->device, mixer_parameters[x].id, + (void*)&minval, (void*)&maxval); + printf("%08x %08x", minval, maxval); + } + printf("\n"); + } + printf("\n"); +} + +/******************* Decoder ****************/ + +Desc decoder_profiles[] = { +{"MPEG1", VDP_DECODER_PROFILE_MPEG1}, +{"MPEG2_SIMPLE", VDP_DECODER_PROFILE_MPEG2_SIMPLE}, +{"MPEG2_MAIN", VDP_DECODER_PROFILE_MPEG2_MAIN}, +{"H264_BASELINE",VDP_DECODER_PROFILE_H264_BASELINE}, +{"H264_MAIN", VDP_DECODER_PROFILE_H264_MAIN}, +{"H264_HIGH", VDP_DECODER_PROFILE_H264_HIGH}, +{"VC1_SIMPLE", VDP_DECODER_PROFILE_VC1_SIMPLE}, +{"VC1_MAIN", VDP_DECODER_PROFILE_VC1_MAIN}, +{"VC1_ADVANCED", VDP_DECODER_PROFILE_VC1_ADVANCED}, +}; +const size_t decoder_profile_count = sizeof(decoder_profiles)/sizeof(Desc); + +void queryDecoderCaps(VDPDeviceImpl *device) +{ + VdpStatus rv; + printf("\nDecoder capabilities:\n\n"); + printf("name level ref width height\n"); + printf("------------------------------------\n"); + for(int x=0; x<decoder_profile_count; ++x) + { + VdpBool is_supported; + uint32_t max_level, max_references, max_width, max_height; + + rv = device->DecoderQueryCapabilities(device->device, decoder_profiles[x].id, + &is_supported, &max_level, &max_references, &max_width, &max_height); + if(rv == VDP_STATUS_OK && is_supported) + { + printf("%-16s %2i %2i %5i %5i\n", decoder_profiles[x].name, + max_level, max_references, max_width, max_height); + } + } +} + + +int main(int argc, char **argv) +{ + /* Create an X Display */ + Display *display; + int screen; + char *display_name = NULL; + if ((display=XOpenDisplay(display_name)) == NULL) + { + fprintf(stderr,"vdpinfo: cannot connect to X server %s\n", + XDisplayName(display_name)); + exit(-1); + } + screen = DefaultScreen(display); + printf("display: %s screen: %i\n", display_name, screen); + + /* Create device */ + VdpDevice device; + VdpGetProcAddress *get_proc_address; + VdpStatus rv; + rv = vdp_device_create_x11(display, screen, &device, &get_proc_address); + if(rv != VDP_STATUS_OK) + { + fprintf(stderr, "Error creating VDPAU device: %i\n", rv); /* cannot use GetErrorString here */ + exit(-1); + } + + VDPDeviceImpl *impl = new VDPDeviceImpl(device, get_proc_address); + + queryBaseInfo(impl); + queryVideoSurface(impl); + queryDecoderCaps(impl); + queryOutputSurface(impl); + queryBitmapSurface(impl); + queryVideoMixer(impl); + + printf("\n"); +} + |