aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/vdpau
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/vdpau')
-rw-r--r--src/gallium/state_trackers/vdpau/Makefile.sources13
-rw-r--r--src/gallium/state_trackers/vdpau/bitmap.c209
-rw-r--r--src/gallium/state_trackers/vdpau/decode.c684
-rw-r--r--src/gallium/state_trackers/vdpau/device.c327
-rw-r--r--src/gallium/state_trackers/vdpau/ftab.c139
-rw-r--r--src/gallium/state_trackers/vdpau/htab.c89
-rw-r--r--src/gallium/state_trackers/vdpau/meson.build39
-rw-r--r--src/gallium/state_trackers/vdpau/mixer.c1028
-rw-r--r--src/gallium/state_trackers/vdpau/output.c828
-rw-r--r--src/gallium/state_trackers/vdpau/preemption.c48
-rw-r--r--src/gallium/state_trackers/vdpau/presentation.c384
-rw-r--r--src/gallium/state_trackers/vdpau/query.c622
-rw-r--r--src/gallium/state_trackers/vdpau/surface.c554
-rw-r--r--src/gallium/state_trackers/vdpau/vdpau_private.h586
14 files changed, 0 insertions, 5550 deletions
diff --git a/src/gallium/state_trackers/vdpau/Makefile.sources b/src/gallium/state_trackers/vdpau/Makefile.sources
deleted file mode 100644
index dfe0bcd043f..00000000000
--- a/src/gallium/state_trackers/vdpau/Makefile.sources
+++ /dev/null
@@ -1,13 +0,0 @@
-C_SOURCES := \
- bitmap.c \
- decode.c \
- device.c \
- ftab.c \
- htab.c \
- mixer.c \
- output.c \
- preemption.c \
- presentation.c \
- query.c \
- surface.c \
- vdpau_private.h
diff --git a/src/gallium/state_trackers/vdpau/bitmap.c b/src/gallium/state_trackers/vdpau/bitmap.c
deleted file mode 100644
index 643be75e618..00000000000
--- a/src/gallium/state_trackers/vdpau/bitmap.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Thomas Balling Sørensen.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include <vdpau/vdpau.h>
-
-#include "util/u_memory.h"
-#include "util/u_sampler.h"
-
-#include "vdpau_private.h"
-
-/**
- * Create a VdpBitmapSurface.
- */
-VdpStatus
-vlVdpBitmapSurfaceCreate(VdpDevice device,
- VdpRGBAFormat rgba_format,
- uint32_t width, uint32_t height,
- VdpBool frequently_accessed,
- VdpBitmapSurface *surface)
-{
- struct pipe_context *pipe;
- struct pipe_resource res_tmpl, *res;
- struct pipe_sampler_view sv_templ;
- VdpStatus ret;
-
- vlVdpBitmapSurface *vlsurface = NULL;
-
- if (!(width && height))
- return VDP_STATUS_INVALID_SIZE;
-
- vlVdpDevice *dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pipe = dev->context;
- if (!pipe)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (!surface)
- return VDP_STATUS_INVALID_POINTER;
-
- vlsurface = CALLOC(1, sizeof(vlVdpBitmapSurface));
- if (!vlsurface)
- return VDP_STATUS_RESOURCES;
-
- DeviceReference(&vlsurface->device, dev);
-
- memset(&res_tmpl, 0, sizeof(res_tmpl));
- res_tmpl.target = PIPE_TEXTURE_2D;
- res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
- res_tmpl.width0 = width;
- res_tmpl.height0 = height;
- res_tmpl.depth0 = 1;
- res_tmpl.array_size = 1;
- res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
- res_tmpl.usage = frequently_accessed ? PIPE_USAGE_DYNAMIC : PIPE_USAGE_DEFAULT;
-
- mtx_lock(&dev->mutex);
-
- if (!CheckSurfaceParams(pipe->screen, &res_tmpl)) {
- ret = VDP_STATUS_RESOURCES;
- goto err_unlock;
- }
-
- res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
- if (!res) {
- ret = VDP_STATUS_RESOURCES;
- goto err_unlock;
- }
-
- vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
- vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ);
-
- pipe_resource_reference(&res, NULL);
-
- if (!vlsurface->sampler_view) {
- ret = VDP_STATUS_RESOURCES;
- goto err_unlock;
- }
-
- mtx_unlock(&dev->mutex);
-
- *surface = vlAddDataHTAB(vlsurface);
- if (*surface == 0) {
- mtx_lock(&dev->mutex);
- ret = VDP_STATUS_ERROR;
- goto err_sampler;
- }
-
- return VDP_STATUS_OK;
-
-err_sampler:
- pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
-err_unlock:
- mtx_unlock(&dev->mutex);
- DeviceReference(&vlsurface->device, NULL);
- FREE(vlsurface);
- return ret;
-}
-
-/**
- * Destroy a VdpBitmapSurface.
- */
-VdpStatus
-vlVdpBitmapSurfaceDestroy(VdpBitmapSurface surface)
-{
- vlVdpBitmapSurface *vlsurface;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&vlsurface->device->mutex);
- pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
- mtx_unlock(&vlsurface->device->mutex);
-
- vlRemoveDataHTAB(surface);
- DeviceReference(&vlsurface->device, NULL);
- FREE(vlsurface);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Retrieve the parameters used to create a VdpBitmapSurface.
- */
-VdpStatus
-vlVdpBitmapSurfaceGetParameters(VdpBitmapSurface surface,
- VdpRGBAFormat *rgba_format,
- uint32_t *width, uint32_t *height,
- VdpBool *frequently_accessed)
-{
- vlVdpBitmapSurface *vlsurface;
- struct pipe_resource *res;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (!(rgba_format && width && height && frequently_accessed))
- return VDP_STATUS_INVALID_POINTER;
-
- res = vlsurface->sampler_view->texture;
- *rgba_format = PipeToFormatRGBA(res->format);
- *width = res->width0;
- *height = res->height0;
- *frequently_accessed = res->usage == PIPE_USAGE_DYNAMIC;
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Copy image data from application memory in the surface's native format to
- * a VdpBitmapSurface.
- */
-VdpStatus
-vlVdpBitmapSurfacePutBitsNative(VdpBitmapSurface surface,
- void const *const *source_data,
- uint32_t const *source_pitches,
- VdpRect const *destination_rect)
-{
- vlVdpBitmapSurface *vlsurface;
- struct pipe_box dst_box;
- struct pipe_context *pipe;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (!(source_data && source_pitches))
- return VDP_STATUS_INVALID_POINTER;
-
- pipe = vlsurface->device->context;
-
- mtx_lock(&vlsurface->device->mutex);
-
- dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
- pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
- PIPE_TRANSFER_WRITE, &dst_box, *source_data,
- *source_pitches, 0);
-
- mtx_unlock(&vlsurface->device->mutex);
-
- return VDP_STATUS_OK;
-}
diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
deleted file mode 100644
index 8d3c58714a8..00000000000
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ /dev/null
@@ -1,684 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Thomas Balling Sørensen.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include "util/u_memory.h"
-#include "util/u_math.h"
-#include "util/u_debug.h"
-#include "util/u_video.h"
-
-#include "vl/vl_vlc.h"
-
-#include "vdpau_private.h"
-
-/**
- * Create a VdpDecoder.
- */
-VdpStatus
-vlVdpDecoderCreate(VdpDevice device,
- VdpDecoderProfile profile,
- uint32_t width, uint32_t height,
- uint32_t max_references,
- VdpDecoder *decoder)
-{
- struct pipe_video_codec templat = {};
- struct pipe_context *pipe;
- struct pipe_screen *screen;
- vlVdpDevice *dev;
- vlVdpDecoder *vldecoder;
- VdpStatus ret;
- bool supported;
- uint32_t maxwidth, maxheight;
-
- if (!decoder)
- return VDP_STATUS_INVALID_POINTER;
- *decoder = 0;
-
- if (!(width && height))
- return VDP_STATUS_INVALID_VALUE;
-
- templat.profile = ProfileToPipe(profile);
- if (templat.profile == PIPE_VIDEO_PROFILE_UNKNOWN)
- return VDP_STATUS_INVALID_DECODER_PROFILE;
-
- dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pipe = dev->context;
- screen = dev->vscreen->pscreen;
-
- mtx_lock(&dev->mutex);
-
- supported = screen->get_video_param
- (
- screen,
- templat.profile,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_SUPPORTED
- );
- if (!supported) {
- mtx_unlock(&dev->mutex);
- return VDP_STATUS_INVALID_DECODER_PROFILE;
- }
-
- maxwidth = screen->get_video_param
- (
- screen,
- templat.profile,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_MAX_WIDTH
- );
- maxheight = screen->get_video_param
- (
- screen,
- templat.profile,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_MAX_HEIGHT
- );
- if (width > maxwidth || height > maxheight) {
- mtx_unlock(&dev->mutex);
- return VDP_STATUS_INVALID_SIZE;
- }
-
- vldecoder = CALLOC(1,sizeof(vlVdpDecoder));
- if (!vldecoder) {
- mtx_unlock(&dev->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- DeviceReference(&vldecoder->device, dev);
-
- templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
- templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
- templat.width = width;
- templat.height = height;
- templat.max_references = max_references;
-
- if (u_reduce_video_profile(templat.profile) ==
- PIPE_VIDEO_FORMAT_MPEG4_AVC)
- templat.level = u_get_h264_level(templat.width, templat.height,
- &templat.max_references);
-
- vldecoder->decoder = pipe->create_video_codec(pipe, &templat);
-
- if (!vldecoder->decoder) {
- ret = VDP_STATUS_ERROR;
- goto error_decoder;
- }
-
- *decoder = vlAddDataHTAB(vldecoder);
- if (*decoder == 0) {
- ret = VDP_STATUS_ERROR;
- goto error_handle;
- }
-
- (void) mtx_init(&vldecoder->mutex, mtx_plain);
- mtx_unlock(&dev->mutex);
-
- return VDP_STATUS_OK;
-
-error_handle:
- vldecoder->decoder->destroy(vldecoder->decoder);
-
-error_decoder:
- mtx_unlock(&dev->mutex);
- DeviceReference(&vldecoder->device, NULL);
- FREE(vldecoder);
- return ret;
-}
-
-/**
- * Destroy a VdpDecoder.
- */
-VdpStatus
-vlVdpDecoderDestroy(VdpDecoder decoder)
-{
- vlVdpDecoder *vldecoder;
-
- vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
- if (!vldecoder)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&vldecoder->mutex);
- vldecoder->decoder->destroy(vldecoder->decoder);
- mtx_unlock(&vldecoder->mutex);
- mtx_destroy(&vldecoder->mutex);
-
- vlRemoveDataHTAB(decoder);
- DeviceReference(&vldecoder->device, NULL);
- FREE(vldecoder);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Retrieve the parameters used to create a VdpDecoder.
- */
-VdpStatus
-vlVdpDecoderGetParameters(VdpDecoder decoder,
- VdpDecoderProfile *profile,
- uint32_t *width,
- uint32_t *height)
-{
- vlVdpDecoder *vldecoder;
-
- vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
- if (!vldecoder)
- return VDP_STATUS_INVALID_HANDLE;
-
- *profile = PipeToProfile(vldecoder->decoder->profile);
- *width = vldecoder->decoder->width;
- *height = vldecoder->decoder->height;
-
- return VDP_STATUS_OK;
-}
-
-static VdpStatus
-vlVdpGetReferenceFrame(VdpVideoSurface handle, struct pipe_video_buffer **ref_frame)
-{
- vlVdpSurface *surface;
-
- /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */
- if (handle == VDP_INVALID_HANDLE) {
- *ref_frame = NULL;
- return VDP_STATUS_OK;
- }
-
- surface = vlGetDataHTAB(handle);
- if (!surface)
- return VDP_STATUS_INVALID_HANDLE;
-
- *ref_frame = surface->video_buffer;
- if (!*ref_frame)
- return VDP_STATUS_INVALID_HANDLE;
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Decode a mpeg 1/2 video.
- */
-static VdpStatus
-vlVdpDecoderRenderMpeg12(struct pipe_mpeg12_picture_desc *picture,
- VdpPictureInfoMPEG1Or2 *picture_info)
-{
- VdpStatus r;
-
- VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG12\n");
-
- r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]);
- if (r != VDP_STATUS_OK)
- return r;
-
- r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]);
- if (r != VDP_STATUS_OK)
- return r;
-
- picture->picture_coding_type = picture_info->picture_coding_type;
- picture->picture_structure = picture_info->picture_structure;
- picture->frame_pred_frame_dct = picture_info->frame_pred_frame_dct;
- picture->q_scale_type = picture_info->q_scale_type;
- picture->alternate_scan = picture_info->alternate_scan;
- picture->intra_vlc_format = picture_info->intra_vlc_format;
- picture->concealment_motion_vectors = picture_info->concealment_motion_vectors;
- picture->intra_dc_precision = picture_info->intra_dc_precision;
- picture->f_code[0][0] = picture_info->f_code[0][0] - 1;
- picture->f_code[0][1] = picture_info->f_code[0][1] - 1;
- picture->f_code[1][0] = picture_info->f_code[1][0] - 1;
- picture->f_code[1][1] = picture_info->f_code[1][1] - 1;
- picture->num_slices = picture_info->slice_count;
- picture->top_field_first = picture_info->top_field_first;
- picture->full_pel_forward_vector = picture_info->full_pel_forward_vector;
- picture->full_pel_backward_vector = picture_info->full_pel_backward_vector;
- picture->intra_matrix = picture_info->intra_quantizer_matrix;
- picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix;
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Decode a mpeg 4 video.
- */
-static VdpStatus
-vlVdpDecoderRenderMpeg4(struct pipe_mpeg4_picture_desc *picture,
- VdpPictureInfoMPEG4Part2 *picture_info)
-{
- VdpStatus r;
- unsigned i;
-
- VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG4\n");
-
- r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]);
- if (r != VDP_STATUS_OK)
- return r;
-
- r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]);
- if (r != VDP_STATUS_OK)
- return r;
-
- for (i = 0; i < 2; ++i) {
- picture->trd[i] = picture_info->trd[i];
- picture->trb[i] = picture_info->trb[i];
- }
- picture->vop_time_increment_resolution = picture_info->vop_time_increment_resolution;
- picture->vop_coding_type = picture_info->vop_coding_type;
- picture->vop_fcode_forward = picture_info->vop_fcode_forward;
- picture->vop_fcode_backward = picture_info->vop_fcode_backward;
- picture->resync_marker_disable = picture_info->resync_marker_disable;
- picture->interlaced = picture_info->interlaced;
- picture->quant_type = picture_info->quant_type;
- picture->quarter_sample = picture_info->quarter_sample;
- picture->short_video_header = picture_info->short_video_header;
- picture->rounding_control = picture_info->rounding_control;
- picture->alternate_vertical_scan_flag = picture_info->alternate_vertical_scan_flag;
- picture->top_field_first = picture_info->top_field_first;
- picture->intra_matrix = picture_info->intra_quantizer_matrix;
- picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix;
-
- return VDP_STATUS_OK;
-}
-
-static VdpStatus
-vlVdpDecoderRenderVC1(struct pipe_vc1_picture_desc *picture,
- VdpPictureInfoVC1 *picture_info)
-{
- VdpStatus r;
-
- VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding VC-1\n");
-
- r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]);
- if (r != VDP_STATUS_OK)
- return r;
-
- r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]);
- if (r != VDP_STATUS_OK)
- return r;
-
- picture->slice_count = picture_info->slice_count;
- picture->picture_type = picture_info->picture_type;
- picture->frame_coding_mode = picture_info->frame_coding_mode;
- picture->postprocflag = picture_info->postprocflag;
- picture->pulldown = picture_info->pulldown;
- picture->interlace = picture_info->interlace;
- picture->tfcntrflag = picture_info->tfcntrflag;
- picture->finterpflag = picture_info->finterpflag;
- picture->psf = picture_info->psf;
- picture->dquant = picture_info->dquant;
- picture->panscan_flag = picture_info->panscan_flag;
- picture->refdist_flag = picture_info->refdist_flag;
- picture->quantizer = picture_info->quantizer;
- picture->extended_mv = picture_info->extended_mv;
- picture->extended_dmv = picture_info->extended_dmv;
- picture->overlap = picture_info->overlap;
- picture->vstransform = picture_info->vstransform;
- picture->loopfilter = picture_info->loopfilter;
- picture->fastuvmc = picture_info->fastuvmc;
- picture->range_mapy_flag = picture_info->range_mapy_flag;
- picture->range_mapy = picture_info->range_mapy;
- picture->range_mapuv_flag = picture_info->range_mapuv_flag;
- picture->range_mapuv = picture_info->range_mapuv;
- picture->multires = picture_info->multires;
- picture->syncmarker = picture_info->syncmarker;
- picture->rangered = picture_info->rangered;
- picture->maxbframes = picture_info->maxbframes;
- picture->deblockEnable = picture_info->deblockEnable;
- picture->pquant = picture_info->pquant;
-
- return VDP_STATUS_OK;
-}
-
-static VdpStatus
-vlVdpDecoderRenderH264(struct pipe_h264_picture_desc *picture,
- VdpPictureInfoH264 *picture_info)
-{
- unsigned i;
-
- VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding H264\n");
-
- picture->pps->sps->mb_adaptive_frame_field_flag = picture_info->mb_adaptive_frame_field_flag;
- picture->pps->sps->frame_mbs_only_flag = picture_info->frame_mbs_only_flag;
- picture->pps->sps->log2_max_frame_num_minus4 = picture_info->log2_max_frame_num_minus4;
- picture->pps->sps->pic_order_cnt_type = picture_info->pic_order_cnt_type;
- picture->pps->sps->log2_max_pic_order_cnt_lsb_minus4 = picture_info->log2_max_pic_order_cnt_lsb_minus4;
- picture->pps->sps->delta_pic_order_always_zero_flag = picture_info->delta_pic_order_always_zero_flag;
- picture->pps->sps->direct_8x8_inference_flag = picture_info->direct_8x8_inference_flag;
-
- picture->pps->transform_8x8_mode_flag = picture_info->transform_8x8_mode_flag;
- picture->pps->chroma_qp_index_offset = picture_info->chroma_qp_index_offset;
- picture->pps->second_chroma_qp_index_offset = picture_info->second_chroma_qp_index_offset;
- picture->pps->pic_init_qp_minus26 = picture_info->pic_init_qp_minus26;
- picture->pps->entropy_coding_mode_flag = picture_info->entropy_coding_mode_flag;
- picture->pps->deblocking_filter_control_present_flag = picture_info->deblocking_filter_control_present_flag;
- picture->pps->redundant_pic_cnt_present_flag = picture_info->redundant_pic_cnt_present_flag;
- picture->pps->constrained_intra_pred_flag = picture_info->constrained_intra_pred_flag;
- picture->pps->weighted_pred_flag = picture_info->weighted_pred_flag;
- picture->pps->weighted_bipred_idc = picture_info->weighted_bipred_idc;
- picture->pps->bottom_field_pic_order_in_frame_present_flag = picture_info->pic_order_present_flag;
- memcpy(picture->pps->ScalingList4x4, picture_info->scaling_lists_4x4, 6*16);
- memcpy(picture->pps->ScalingList8x8, picture_info->scaling_lists_8x8, 2*64);
-
- picture->slice_count = picture_info->slice_count;
- picture->field_order_cnt[0] = picture_info->field_order_cnt[0];
- picture->field_order_cnt[1] = picture_info->field_order_cnt[1];
- picture->is_reference = picture_info->is_reference;
- picture->frame_num = picture_info->frame_num;
- picture->field_pic_flag = picture_info->field_pic_flag;
- picture->bottom_field_flag = picture_info->bottom_field_flag;
- picture->num_ref_frames = picture_info->num_ref_frames;
-
- picture->num_ref_idx_l0_active_minus1 = picture_info->num_ref_idx_l0_active_minus1;
- picture->num_ref_idx_l1_active_minus1 = picture_info->num_ref_idx_l1_active_minus1;
-
- for (i = 0; i < 16; ++i) {
- VdpStatus ret = vlVdpGetReferenceFrame
- (
- picture_info->referenceFrames[i].surface,
- &picture->ref[i]
- );
- if (ret != VDP_STATUS_OK)
- return ret;
-
- picture->is_long_term[i] = picture_info->referenceFrames[i].is_long_term;
- picture->top_is_reference[i] = picture_info->referenceFrames[i].top_is_reference;
- picture->bottom_is_reference[i] = picture_info->referenceFrames[i].bottom_is_reference;
- picture->field_order_cnt_list[i][0] = picture_info->referenceFrames[i].field_order_cnt[0];
- picture->field_order_cnt_list[i][1] = picture_info->referenceFrames[i].field_order_cnt[1];
- picture->frame_num_list[i] = picture_info->referenceFrames[i].frame_idx;
- }
-
- return VDP_STATUS_OK;
-}
-
-static VdpStatus
-vlVdpDecoderRenderH265(struct pipe_h265_picture_desc *picture,
- VdpPictureInfoHEVC *picture_info)
-{
- unsigned i;
-
- picture->pps->sps->chroma_format_idc = picture_info->chroma_format_idc;
- picture->pps->sps->separate_colour_plane_flag = picture_info->separate_colour_plane_flag;
- picture->pps->sps->pic_width_in_luma_samples = picture_info->pic_width_in_luma_samples;
- picture->pps->sps->pic_height_in_luma_samples = picture_info->pic_height_in_luma_samples;
- picture->pps->sps->bit_depth_luma_minus8 = picture_info->bit_depth_luma_minus8;
- picture->pps->sps->bit_depth_chroma_minus8 = picture_info->bit_depth_chroma_minus8;
- picture->pps->sps->log2_max_pic_order_cnt_lsb_minus4 = picture_info->log2_max_pic_order_cnt_lsb_minus4;
- picture->pps->sps->sps_max_dec_pic_buffering_minus1 = picture_info->sps_max_dec_pic_buffering_minus1;
- picture->pps->sps->log2_min_luma_coding_block_size_minus3 = picture_info->log2_min_luma_coding_block_size_minus3;
- picture->pps->sps->log2_diff_max_min_luma_coding_block_size = picture_info->log2_diff_max_min_luma_coding_block_size;
- picture->pps->sps->log2_min_transform_block_size_minus2 = picture_info->log2_min_transform_block_size_minus2;
- picture->pps->sps->log2_diff_max_min_transform_block_size = picture_info->log2_diff_max_min_transform_block_size;
- picture->pps->sps->max_transform_hierarchy_depth_inter = picture_info->max_transform_hierarchy_depth_inter;
- picture->pps->sps->max_transform_hierarchy_depth_intra = picture_info->max_transform_hierarchy_depth_intra;
- picture->pps->sps->scaling_list_enabled_flag = picture_info->scaling_list_enabled_flag;
- memcpy(picture->pps->sps->ScalingList4x4, picture_info->ScalingList4x4, 6*16);
- memcpy(picture->pps->sps->ScalingList8x8, picture_info->ScalingList8x8, 6*64);
- memcpy(picture->pps->sps->ScalingList16x16, picture_info->ScalingList16x16, 6*64);
- memcpy(picture->pps->sps->ScalingList32x32, picture_info->ScalingList32x32, 2*64);
- memcpy(picture->pps->sps->ScalingListDCCoeff16x16, picture_info->ScalingListDCCoeff16x16, 6);
- memcpy(picture->pps->sps->ScalingListDCCoeff32x32, picture_info->ScalingListDCCoeff32x32, 2);
- picture->pps->sps->amp_enabled_flag = picture_info->amp_enabled_flag;
- picture->pps->sps->sample_adaptive_offset_enabled_flag = picture_info->sample_adaptive_offset_enabled_flag;
- picture->pps->sps->pcm_enabled_flag = picture_info->pcm_enabled_flag;
- picture->pps->sps->pcm_sample_bit_depth_luma_minus1 = picture_info->pcm_sample_bit_depth_luma_minus1;
- picture->pps->sps->pcm_sample_bit_depth_chroma_minus1 = picture_info->pcm_sample_bit_depth_chroma_minus1;
- picture->pps->sps->log2_min_pcm_luma_coding_block_size_minus3 = picture_info->log2_min_pcm_luma_coding_block_size_minus3;
- picture->pps->sps->log2_diff_max_min_pcm_luma_coding_block_size = picture_info->log2_diff_max_min_pcm_luma_coding_block_size;
- picture->pps->sps->pcm_loop_filter_disabled_flag = picture_info->pcm_loop_filter_disabled_flag;
- picture->pps->sps->num_short_term_ref_pic_sets = picture_info->num_short_term_ref_pic_sets;
- picture->pps->sps->long_term_ref_pics_present_flag = picture_info->long_term_ref_pics_present_flag;
- picture->pps->sps->num_long_term_ref_pics_sps = picture_info->num_long_term_ref_pics_sps;
- picture->pps->sps->sps_temporal_mvp_enabled_flag = picture_info->sps_temporal_mvp_enabled_flag;
- picture->pps->sps->strong_intra_smoothing_enabled_flag = picture_info->strong_intra_smoothing_enabled_flag;
-
- picture->pps->dependent_slice_segments_enabled_flag = picture_info->dependent_slice_segments_enabled_flag;
- picture->pps->output_flag_present_flag = picture_info->output_flag_present_flag;
- picture->pps->num_extra_slice_header_bits = picture_info->num_extra_slice_header_bits;
- picture->pps->sign_data_hiding_enabled_flag = picture_info->sign_data_hiding_enabled_flag;
- picture->pps->cabac_init_present_flag = picture_info->cabac_init_present_flag;
- picture->pps->num_ref_idx_l0_default_active_minus1 = picture_info->num_ref_idx_l0_default_active_minus1;
- picture->pps->num_ref_idx_l1_default_active_minus1 = picture_info->num_ref_idx_l1_default_active_minus1;
- picture->pps->init_qp_minus26 = picture_info->init_qp_minus26;
- picture->pps->constrained_intra_pred_flag = picture_info->constrained_intra_pred_flag;
- picture->pps->transform_skip_enabled_flag = picture_info->transform_skip_enabled_flag;
- picture->pps->cu_qp_delta_enabled_flag = picture_info->cu_qp_delta_enabled_flag;
- picture->pps->diff_cu_qp_delta_depth = picture_info->diff_cu_qp_delta_depth;
- picture->pps->pps_cb_qp_offset = picture_info->pps_cb_qp_offset;
- picture->pps->pps_cr_qp_offset = picture_info->pps_cr_qp_offset;
- picture->pps->pps_slice_chroma_qp_offsets_present_flag = picture_info->pps_slice_chroma_qp_offsets_present_flag;
- picture->pps->weighted_pred_flag = picture_info->weighted_pred_flag;
- picture->pps->weighted_bipred_flag = picture_info->weighted_bipred_flag;
- picture->pps->transquant_bypass_enabled_flag = picture_info->transquant_bypass_enabled_flag;
- picture->pps->tiles_enabled_flag = picture_info->tiles_enabled_flag;
- picture->pps->entropy_coding_sync_enabled_flag = picture_info->entropy_coding_sync_enabled_flag;
- picture->pps->num_tile_columns_minus1 = picture_info->num_tile_columns_minus1;
- picture->pps->num_tile_rows_minus1 = picture_info->num_tile_rows_minus1;
- picture->pps->uniform_spacing_flag = picture_info->uniform_spacing_flag;
- memcpy(picture->pps->column_width_minus1, picture_info->column_width_minus1, 20 * 2);
- memcpy(picture->pps->row_height_minus1, picture_info->row_height_minus1, 22 * 2);
- picture->pps->loop_filter_across_tiles_enabled_flag = picture_info->loop_filter_across_tiles_enabled_flag;
- picture->pps->pps_loop_filter_across_slices_enabled_flag = picture_info->pps_loop_filter_across_slices_enabled_flag;
- picture->pps->deblocking_filter_control_present_flag = picture_info->deblocking_filter_control_present_flag;
- picture->pps->deblocking_filter_override_enabled_flag = picture_info->deblocking_filter_override_enabled_flag;
- picture->pps->pps_deblocking_filter_disabled_flag = picture_info->pps_deblocking_filter_disabled_flag;
- picture->pps->pps_beta_offset_div2 = picture_info->pps_beta_offset_div2;
- picture->pps->pps_tc_offset_div2 = picture_info->pps_tc_offset_div2;
- picture->pps->lists_modification_present_flag = picture_info->lists_modification_present_flag;
- picture->pps->log2_parallel_merge_level_minus2 = picture_info->log2_parallel_merge_level_minus2;
- picture->pps->slice_segment_header_extension_present_flag = picture_info->slice_segment_header_extension_present_flag;
-
- picture->IDRPicFlag = picture_info->IDRPicFlag;
- picture->RAPPicFlag = picture_info->RAPPicFlag;
- picture->CurrRpsIdx = picture_info->CurrRpsIdx;
- picture->NumPocTotalCurr = picture_info->NumPocTotalCurr;
- picture->NumDeltaPocsOfRefRpsIdx = picture_info->NumDeltaPocsOfRefRpsIdx;
- picture->NumShortTermPictureSliceHeaderBits = picture_info->NumShortTermPictureSliceHeaderBits;
- picture->NumLongTermPictureSliceHeaderBits = picture_info->NumLongTermPictureSliceHeaderBits;
- picture->CurrPicOrderCntVal = picture_info->CurrPicOrderCntVal;
-
- for (i = 0; i < 16; ++i) {
- VdpStatus ret = vlVdpGetReferenceFrame
- (
- picture_info->RefPics[i],
- &picture->ref[i]
- );
- if (ret != VDP_STATUS_OK)
- return ret;
-
- picture->PicOrderCntVal[i] = picture_info->PicOrderCntVal[i];
- picture->IsLongTerm[i] = picture_info->IsLongTerm[i];
- }
-
- picture->NumPocStCurrBefore = picture_info->NumPocStCurrBefore;
- picture->NumPocStCurrAfter = picture_info->NumPocStCurrAfter;
- picture->NumPocLtCurr = picture_info->NumPocLtCurr;
- memcpy(picture->RefPicSetStCurrBefore, picture_info->RefPicSetStCurrBefore, 8);
- memcpy(picture->RefPicSetStCurrAfter, picture_info->RefPicSetStCurrAfter, 8);
- memcpy(picture->RefPicSetLtCurr, picture_info->RefPicSetLtCurr, 8);
- picture->UseRefPicList = false;
-
- return VDP_STATUS_OK;
-}
-
-static void
-vlVdpDecoderFixVC1Startcode(uint32_t *num_buffers, const void *buffers[], unsigned sizes[])
-{
- static const uint8_t vc1_startcode[] = { 0x00, 0x00, 0x01, 0x0D };
- struct vl_vlc vlc = {};
- unsigned i;
-
- /* search the first 64 bytes for a startcode */
- vl_vlc_init(&vlc, *num_buffers, buffers, sizes);
- while (vl_vlc_search_byte(&vlc, 64*8, 0x00) && vl_vlc_bits_left(&vlc) >= 32) {
- uint32_t value = vl_vlc_peekbits(&vlc, 32);
- if (value == 0x0000010D ||
- value == 0x0000010C ||
- value == 0x0000010B)
- return;
- vl_vlc_eatbits(&vlc, 8);
- }
-
- /* none found, ok add one manually */
- VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Manually adding VC-1 startcode\n");
- for (i = *num_buffers; i > 0; --i) {
- buffers[i] = buffers[i - 1];
- sizes[i] = sizes[i - 1];
- }
- ++(*num_buffers);
- buffers[0] = vc1_startcode;
- sizes[0] = 4;
-}
-
-/**
- * Decode a compressed field/frame and render the result into a VdpVideoSurface.
- */
-VdpStatus
-vlVdpDecoderRender(VdpDecoder decoder,
- VdpVideoSurface target,
- VdpPictureInfo const *picture_info,
- uint32_t bitstream_buffer_count,
- VdpBitstreamBuffer const *bitstream_buffers)
-{
- const void * buffers[bitstream_buffer_count + 1];
- unsigned sizes[bitstream_buffer_count + 1];
- vlVdpDecoder *vldecoder;
- vlVdpSurface *vlsurf;
- VdpStatus ret;
- struct pipe_screen *screen;
- struct pipe_video_codec *dec;
- bool buffer_support[2];
- unsigned i;
- struct pipe_h264_sps sps_h264 = {};
- struct pipe_h264_pps pps_h264 = { &sps_h264 };
- struct pipe_h265_sps sps_h265 = {};
- struct pipe_h265_pps pps_h265 = { &sps_h265 };
- union {
- struct pipe_picture_desc base;
- struct pipe_mpeg12_picture_desc mpeg12;
- struct pipe_mpeg4_picture_desc mpeg4;
- struct pipe_vc1_picture_desc vc1;
- struct pipe_h264_picture_desc h264;
- struct pipe_h265_picture_desc h265;
- } desc;
-
- if (!(picture_info && bitstream_buffers))
- return VDP_STATUS_INVALID_POINTER;
-
- vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
- if (!vldecoder)
- return VDP_STATUS_INVALID_HANDLE;
- dec = vldecoder->decoder;
- screen = dec->context->screen;
-
- vlsurf = (vlVdpSurface *)vlGetDataHTAB(target);
- if (!vlsurf)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (vlsurf->device != vldecoder->device)
- return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
-
- if (vlsurf->video_buffer != NULL &&
- pipe_format_to_chroma_format(vlsurf->video_buffer->buffer_format) != dec->chroma_format)
- // TODO: Recreate decoder with correct chroma
- return VDP_STATUS_INVALID_CHROMA_TYPE;
-
- buffer_support[0] = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE);
- buffer_support[1] = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_SUPPORTS_INTERLACED);
-
- if (vlsurf->video_buffer == NULL ||
- !screen->is_video_format_supported(screen, vlsurf->video_buffer->buffer_format,
- dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM) ||
- !buffer_support[vlsurf->video_buffer->interlaced]) {
-
- mtx_lock(&vlsurf->device->mutex);
-
- /* destroy the old one */
- if (vlsurf->video_buffer)
- vlsurf->video_buffer->destroy(vlsurf->video_buffer);
-
- /* set the buffer format to the prefered one */
- vlsurf->templat.buffer_format = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_PREFERED_FORMAT);
-
- /* also set interlacing to decoders preferences */
- vlsurf->templat.interlaced = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_PREFERS_INTERLACED);
-
- /* and recreate the video buffer */
- vlsurf->video_buffer = dec->context->create_video_buffer(dec->context, &vlsurf->templat);
-
- /* still no luck? get me out of here... */
- if (!vlsurf->video_buffer) {
- mtx_unlock(&vlsurf->device->mutex);
- return VDP_STATUS_NO_IMPLEMENTATION;
- }
- vlVdpVideoSurfaceClear(vlsurf);
- mtx_unlock(&vlsurf->device->mutex);
- }
-
- for (i = 0; i < bitstream_buffer_count; ++i) {
- buffers[i] = bitstream_buffers[i].bitstream;
- sizes[i] = bitstream_buffers[i].bitstream_bytes;
- }
-
- memset(&desc, 0, sizeof(desc));
- desc.base.profile = dec->profile;
- switch (u_reduce_video_profile(dec->profile)) {
- case PIPE_VIDEO_FORMAT_MPEG12:
- ret = vlVdpDecoderRenderMpeg12(&desc.mpeg12, (VdpPictureInfoMPEG1Or2 *)picture_info);
- break;
- case PIPE_VIDEO_FORMAT_MPEG4:
- ret = vlVdpDecoderRenderMpeg4(&desc.mpeg4, (VdpPictureInfoMPEG4Part2 *)picture_info);
- break;
- case PIPE_VIDEO_FORMAT_VC1:
- if (dec->profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED)
- vlVdpDecoderFixVC1Startcode(&bitstream_buffer_count, buffers, sizes);
- ret = vlVdpDecoderRenderVC1(&desc.vc1, (VdpPictureInfoVC1 *)picture_info);
- break;
- case PIPE_VIDEO_FORMAT_MPEG4_AVC:
- desc.h264.pps = &pps_h264;
- ret = vlVdpDecoderRenderH264(&desc.h264, (VdpPictureInfoH264 *)picture_info);
- break;
- case PIPE_VIDEO_FORMAT_HEVC:
- desc.h265.pps = &pps_h265;
- ret = vlVdpDecoderRenderH265(&desc.h265, (VdpPictureInfoHEVC *)picture_info);
- break;
- default:
- return VDP_STATUS_INVALID_DECODER_PROFILE;
- }
-
- if (ret != VDP_STATUS_OK)
- return ret;
-
- mtx_lock(&vldecoder->mutex);
- dec->begin_frame(dec, vlsurf->video_buffer, &desc.base);
- dec->decode_bitstream(dec, vlsurf->video_buffer, &desc.base, bitstream_buffer_count, buffers, sizes);
- dec->end_frame(dec, vlsurf->video_buffer, &desc.base);
- mtx_unlock(&vldecoder->mutex);
- return ret;
-}
diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c
deleted file mode 100644
index 5df30ea3c08..00000000000
--- a/src/gallium/state_trackers/vdpau/device.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Younes Manton og Thomas Balling Sørensen.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include "pipe/p_compiler.h"
-
-#include "util/u_memory.h"
-#include "util/u_debug.h"
-#include "util/format/u_format.h"
-#include "util/u_sampler.h"
-
-#include "vdpau_private.h"
-
-/**
- * Create a VdpDevice object for use with X11.
- */
-PUBLIC VdpStatus
-vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device,
- VdpGetProcAddress **get_proc_address)
-{
- struct pipe_screen *pscreen;
- struct pipe_resource *res, res_tmpl;
- struct pipe_sampler_view sv_tmpl;
- vlVdpDevice *dev = NULL;
- VdpStatus ret;
-
- if (!(display && device && get_proc_address))
- return VDP_STATUS_INVALID_POINTER;
-
- if (!vlCreateHTAB()) {
- ret = VDP_STATUS_RESOURCES;
- goto no_htab;
- }
-
- dev = CALLOC(1, sizeof(vlVdpDevice));
- if (!dev) {
- ret = VDP_STATUS_RESOURCES;
- goto no_dev;
- }
-
- pipe_reference_init(&dev->reference, 1);
-
- dev->vscreen = vl_dri3_screen_create(display, screen);
- if (!dev->vscreen)
- dev->vscreen = vl_dri2_screen_create(display, screen);
- if (!dev->vscreen) {
- ret = VDP_STATUS_RESOURCES;
- goto no_vscreen;
- }
-
- pscreen = dev->vscreen->pscreen;
- dev->context = pipe_create_multimedia_context(pscreen);
- if (!dev->context) {
- ret = VDP_STATUS_RESOURCES;
- goto no_context;
- }
-
- if (!pscreen->get_param(pscreen, PIPE_CAP_NPOT_TEXTURES)) {
- ret = VDP_STATUS_NO_IMPLEMENTATION;
- goto no_context;
- }
-
- memset(&res_tmpl, 0, sizeof(res_tmpl));
-
- res_tmpl.target = PIPE_TEXTURE_2D;
- res_tmpl.format = PIPE_FORMAT_R8G8B8A8_UNORM;
- res_tmpl.width0 = 1;
- res_tmpl.height0 = 1;
- res_tmpl.depth0 = 1;
- res_tmpl.array_size = 1;
- res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
- res_tmpl.usage = PIPE_USAGE_DEFAULT;
-
- if (!CheckSurfaceParams(pscreen, &res_tmpl)) {
- ret = VDP_STATUS_NO_IMPLEMENTATION;
- goto no_resource;
- }
-
- res = pscreen->resource_create(pscreen, &res_tmpl);
- if (!res) {
- ret = VDP_STATUS_RESOURCES;
- goto no_resource;
- }
-
- memset(&sv_tmpl, 0, sizeof(sv_tmpl));
- u_sampler_view_default_template(&sv_tmpl, res, res->format);
-
- sv_tmpl.swizzle_r = PIPE_SWIZZLE_1;
- sv_tmpl.swizzle_g = PIPE_SWIZZLE_1;
- sv_tmpl.swizzle_b = PIPE_SWIZZLE_1;
- sv_tmpl.swizzle_a = PIPE_SWIZZLE_1;
-
- dev->dummy_sv = dev->context->create_sampler_view(dev->context, res, &sv_tmpl);
- pipe_resource_reference(&res, NULL);
- if (!dev->dummy_sv) {
- ret = VDP_STATUS_RESOURCES;
- goto no_resource;
- }
-
- *device = vlAddDataHTAB(dev);
- if (*device == 0) {
- ret = VDP_STATUS_ERROR;
- goto no_handle;
- }
-
- if (!vl_compositor_init(&dev->compositor, dev->context)) {
- ret = VDP_STATUS_ERROR;
- goto no_compositor;
- }
-
- (void) mtx_init(&dev->mutex, mtx_plain);
-
- *get_proc_address = &vlVdpGetProcAddress;
-
- return VDP_STATUS_OK;
-
-no_compositor:
- vlRemoveDataHTAB(*device);
-no_handle:
- pipe_sampler_view_reference(&dev->dummy_sv, NULL);
-no_resource:
- dev->context->destroy(dev->context);
-no_context:
- dev->vscreen->destroy(dev->vscreen);
-no_vscreen:
- FREE(dev);
-no_dev:
- vlDestroyHTAB();
-no_htab:
- return ret;
-}
-
-/**
- * Create a VdpPresentationQueueTarget for use with X11.
- */
-VdpStatus
-vlVdpPresentationQueueTargetCreateX11(VdpDevice device, Drawable drawable,
- VdpPresentationQueueTarget *target)
-{
- vlVdpPresentationQueueTarget *pqt;
- VdpStatus ret;
-
- if (!drawable)
- return VDP_STATUS_INVALID_HANDLE;
-
- vlVdpDevice *dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pqt = CALLOC(1, sizeof(vlVdpPresentationQueue));
- if (!pqt)
- return VDP_STATUS_RESOURCES;
-
- DeviceReference(&pqt->device, dev);
- pqt->drawable = drawable;
-
- *target = vlAddDataHTAB(pqt);
- if (*target == 0) {
- ret = VDP_STATUS_ERROR;
- goto no_handle;
- }
-
- return VDP_STATUS_OK;
-
-no_handle:
- FREE(pqt);
- return ret;
-}
-
-/**
- * Destroy a VdpPresentationQueueTarget.
- */
-VdpStatus
-vlVdpPresentationQueueTargetDestroy(VdpPresentationQueueTarget presentation_queue_target)
-{
- vlVdpPresentationQueueTarget *pqt;
-
- pqt = vlGetDataHTAB(presentation_queue_target);
- if (!pqt)
- return VDP_STATUS_INVALID_HANDLE;
-
- vlRemoveDataHTAB(presentation_queue_target);
- DeviceReference(&pqt->device, NULL);
- FREE(pqt);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Destroy a VdpDevice.
- */
-VdpStatus
-vlVdpDeviceDestroy(VdpDevice device)
-{
- vlVdpDevice *dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- vlRemoveDataHTAB(device);
- DeviceReference(&dev, NULL);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Free a VdpDevice.
- */
-void
-vlVdpDeviceFree(vlVdpDevice *dev)
-{
- mtx_destroy(&dev->mutex);
- vl_compositor_cleanup(&dev->compositor);
- pipe_sampler_view_reference(&dev->dummy_sv, NULL);
- dev->context->destroy(dev->context);
- dev->vscreen->destroy(dev->vscreen);
- FREE(dev);
- vlDestroyHTAB();
-}
-
-/**
- * Retrieve a VDPAU function pointer.
- */
-VdpStatus
-vlVdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **function_pointer)
-{
- vlVdpDevice *dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (!function_pointer)
- return VDP_STATUS_INVALID_POINTER;
-
- if (!vlGetFuncFTAB(function_id, function_pointer))
- return VDP_STATUS_INVALID_FUNC_ID;
-
- VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Got proc address %p for id %d\n", *function_pointer, function_id);
-
- return VDP_STATUS_OK;
-}
-
-#define _ERROR_TYPE(TYPE,STRING) case TYPE: return STRING;
-
-/**
- * Retrieve a string describing an error code.
- */
-char const *
-vlVdpGetErrorString (VdpStatus status)
-{
- switch (status) {
- _ERROR_TYPE(VDP_STATUS_OK,"The operation completed successfully; no error.");
- _ERROR_TYPE(VDP_STATUS_NO_IMPLEMENTATION,"No backend implementation could be loaded.");
- _ERROR_TYPE(VDP_STATUS_DISPLAY_PREEMPTED,"The display was preempted, or a fatal error occurred. The application must re-initialize VDPAU.");
- _ERROR_TYPE(VDP_STATUS_INVALID_HANDLE,"An invalid handle value was provided. Either the handle does not exist at all, or refers to an object of an incorrect type.");
- _ERROR_TYPE(VDP_STATUS_INVALID_POINTER,"An invalid pointer was provided. Typically, this means that a NULL pointer was provided for an 'output' parameter.");
- _ERROR_TYPE(VDP_STATUS_INVALID_CHROMA_TYPE,"An invalid/unsupported VdpChromaType value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_Y_CB_CR_FORMAT,"An invalid/unsupported VdpYCbCrFormat value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_RGBA_FORMAT,"An invalid/unsupported VdpRGBAFormat value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_INDEXED_FORMAT,"An invalid/unsupported VdpIndexedFormat value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_COLOR_STANDARD,"An invalid/unsupported VdpColorStandard value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_COLOR_TABLE_FORMAT,"An invalid/unsupported VdpColorTableFormat value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_BLEND_FACTOR,"An invalid/unsupported VdpOutputSurfaceRenderBlendFactor value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_BLEND_EQUATION,"An invalid/unsupported VdpOutputSurfaceRenderBlendEquation value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_FLAG,"An invalid/unsupported flag value/combination was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_DECODER_PROFILE,"An invalid/unsupported VdpDecoderProfile value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE,"An invalid/unsupported VdpVideoMixerFeature value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER,"An invalid/unsupported VdpVideoMixerParameter value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE,"An invalid/unsupported VdpVideoMixerAttribute value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE,"An invalid/unsupported VdpVideoMixerPictureStructure value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_FUNC_ID,"An invalid/unsupported VdpFuncId value was supplied.");
- _ERROR_TYPE(VDP_STATUS_INVALID_SIZE,"The size of a supplied object does not match the object it is being used with.\
- For example, a VdpVideoMixer is configured to process VdpVideoSurface objects of a specific size.\
- If presented with a VdpVideoSurface of a different size, this error will be raised.");
- _ERROR_TYPE(VDP_STATUS_INVALID_VALUE,"An invalid/unsupported value was supplied.\
- This is a catch-all error code for values of type other than those with a specific error code.");
- _ERROR_TYPE(VDP_STATUS_INVALID_STRUCT_VERSION,"An invalid/unsupported structure version was specified in a versioned structure. \
- This implies that the implementation is older than the header file the application was built against.");
- _ERROR_TYPE(VDP_STATUS_RESOURCES,"The system does not have enough resources to complete the requested operation at this time.");
- _ERROR_TYPE(VDP_STATUS_HANDLE_DEVICE_MISMATCH,"The set of handles supplied are not all related to the same VdpDevice.When performing operations \
- that operate on multiple surfaces, such as VdpOutputSurfaceRenderOutputSurface or VdpVideoMixerRender, \
- all supplied surfaces must have been created within the context of the same VdpDevice object. \
- This error is raised if they were not.");
- _ERROR_TYPE(VDP_STATUS_ERROR,"A catch-all error, used when no other error code applies.");
- default: return "Unknown Error";
- }
-}
-
-void
-vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res)
-{
- const struct util_format_description *desc;
-
- memset(templ, 0, sizeof(*templ));
- u_sampler_view_default_template(templ, res, res->format);
-
- desc = util_format_description(res->format);
- if (desc->swizzle[0] == PIPE_SWIZZLE_0)
- templ->swizzle_r = PIPE_SWIZZLE_1;
- if (desc->swizzle[1] == PIPE_SWIZZLE_0)
- templ->swizzle_g = PIPE_SWIZZLE_1;
- if (desc->swizzle[2] == PIPE_SWIZZLE_0)
- templ->swizzle_b = PIPE_SWIZZLE_1;
- if (desc->swizzle[3] == PIPE_SWIZZLE_0)
- templ->swizzle_a = PIPE_SWIZZLE_1;
-}
diff --git a/src/gallium/state_trackers/vdpau/ftab.c b/src/gallium/state_trackers/vdpau/ftab.c
deleted file mode 100644
index 31786229bc5..00000000000
--- a/src/gallium/state_trackers/vdpau/ftab.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Younes Manton & Thomas Balling Sørensen.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include <assert.h>
-
-#include "util/u_memory.h"
-
-#include "vdpau_private.h"
-
-static void* ftab[67] =
-{
- &vlVdpGetErrorString, /* VDP_FUNC_ID_GET_ERROR_STRING */
- &vlVdpGetProcAddress, /* VDP_FUNC_ID_GET_PROC_ADDRESS */
- &vlVdpGetApiVersion, /* VDP_FUNC_ID_GET_API_VERSION */
- NULL, /* DUMMY */
- &vlVdpGetInformationString, /* VDP_FUNC_ID_GET_INFORMATION_STRING */
- &vlVdpDeviceDestroy, /* VDP_FUNC_ID_DEVICE_DESTROY */
- &vlVdpGenerateCSCMatrix, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */
- &vlVdpVideoSurfaceQueryCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES */
- &vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES */
- &vlVdpVideoSurfaceCreate, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */
- &vlVdpVideoSurfaceDestroy, /* VDP_FUNC_ID_VIDEO_SURFACE_DESTROY */
- &vlVdpVideoSurfaceGetParameters, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS */
- &vlVdpVideoSurfaceGetBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR */
- &vlVdpVideoSurfacePutBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR */
- &vlVdpOutputSurfaceQueryCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES */
- &vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_GET_PUT_BITS_NATIVE_CAPABILITIES */
- &vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES */
- &vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES */
- &vlVdpOutputSurfaceCreate, /* VDP_FUNC_ID_OUTPUT_SURFACE_CREATE */
- &vlVdpOutputSurfaceDestroy, /* VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY */
- &vlVdpOutputSurfaceGetParameters, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS */
- &vlVdpOutputSurfaceGetBitsNative, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE */
- &vlVdpOutputSurfacePutBitsNative, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE */
- &vlVdpOutputSurfacePutBitsIndexed, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED */
- &vlVdpOutputSurfacePutBitsYCbCr, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR */
- &vlVdpBitmapSurfaceQueryCapabilities, /* VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES */
- &vlVdpBitmapSurfaceCreate, /* VDP_FUNC_ID_BITMAP_SURFACE_CREATE */
- &vlVdpBitmapSurfaceDestroy, /* VDP_FUNC_ID_BITMAP_SURFACE_DESTROY */
- &vlVdpBitmapSurfaceGetParameters, /* VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS */
- &vlVdpBitmapSurfacePutBitsNative, /* VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE */
- NULL, /* DUMMY */
- NULL, /* DUMMY */
- NULL, /* DUMMY */
- &vlVdpOutputSurfaceRenderOutputSurface, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE */
- &vlVdpOutputSurfaceRenderBitmapSurface, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE */
- NULL, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_VIDEO_SURFACE_LUMA */
- &vlVdpDecoderQueryCapabilities, /* VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES */
- &vlVdpDecoderCreate, /* VDP_FUNC_ID_DECODER_CREATE */
- &vlVdpDecoderDestroy, /* VDP_FUNC_ID_DECODER_DESTROY */
- &vlVdpDecoderGetParameters, /* VDP_FUNC_ID_DECODER_GET_PARAMETERS */
- &vlVdpDecoderRender, /* VDP_FUNC_ID_DECODER_RENDER */
- &vlVdpVideoMixerQueryFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT */
- &vlVdpVideoMixerQueryParameterSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT */
- &vlVdpVideoMixerQueryAttributeSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT */
- &vlVdpVideoMixerQueryParameterValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_VALUE_RANGE */
- &vlVdpVideoMixerQueryAttributeValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_VALUE_RANGE */
- &vlVdpVideoMixerCreate, /* VDP_FUNC_ID_VIDEO_MIXER_CREATE */
- &vlVdpVideoMixerSetFeatureEnables, /* VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES */
- &vlVdpVideoMixerSetAttributeValues, /* VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES */
- &vlVdpVideoMixerGetFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT */
- &vlVdpVideoMixerGetFeatureEnables, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES */
- &vlVdpVideoMixerGetParameterValues, /* VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES */
- &vlVdpVideoMixerGetAttributeValues, /* VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES */
- &vlVdpVideoMixerDestroy, /* VDP_FUNC_ID_VIDEO_MIXER_DESTROY */
- &vlVdpVideoMixerRender, /* VDP_FUNC_ID_VIDEO_MIXER_RENDER */
- &vlVdpPresentationQueueTargetDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY */
- &vlVdpPresentationQueueCreate, /* VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE */
- &vlVdpPresentationQueueDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY */
- &vlVdpPresentationQueueSetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR */
- &vlVdpPresentationQueueGetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR */
- NULL, /* DUMMY */
- NULL, /* DUMMY */
- &vlVdpPresentationQueueGetTime, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME */
- &vlVdpPresentationQueueDisplay, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY */
- &vlVdpPresentationQueueBlockUntilSurfaceIdle, /* VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE */
- &vlVdpPresentationQueueQuerySurfaceStatus, /* VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS */
- &vlVdpPreemptionCallbackRegister /* VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER */
-};
-
-static void* ftab_winsys[1] =
-{
- &vlVdpPresentationQueueTargetCreateX11 /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */
-};
-
-static void* ftab_driver[4] =
-{
- &vlVdpVideoSurfaceGallium, /* VDP_FUNC_ID_SURFACE_GALLIUM */
- &vlVdpOutputSurfaceGallium, /* VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM */
- &vlVdpVideoSurfaceDMABuf, /* VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF */
- &vlVdpOutputSurfaceDMABuf /* VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF */
-};
-
-boolean vlGetFuncFTAB(VdpFuncId function_id, void **func)
-{
- assert(func);
- *func = NULL;
-
- if (function_id < VDP_FUNC_ID_BASE_WINSYS) {
- if (function_id < ARRAY_SIZE(ftab))
- *func = ftab[function_id];
-
- } else if (function_id < VDP_FUNC_ID_BASE_DRIVER) {
- function_id -= VDP_FUNC_ID_BASE_WINSYS;
- if (function_id < ARRAY_SIZE(ftab_winsys))
- *func = ftab_winsys[function_id];
-
- } else {
- function_id -= VDP_FUNC_ID_BASE_DRIVER;
- if (function_id < ARRAY_SIZE(ftab_driver))
- *func = ftab_driver[function_id];
- }
-
- return *func != NULL;
-}
diff --git a/src/gallium/state_trackers/vdpau/htab.c b/src/gallium/state_trackers/vdpau/htab.c
deleted file mode 100644
index f596b2d571f..00000000000
--- a/src/gallium/state_trackers/vdpau/htab.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Younes Manton.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include "util/u_handle_table.h"
-#include "os/os_thread.h"
-#include "vdpau_private.h"
-
-static struct handle_table *htab = NULL;
-static mtx_t htab_lock = _MTX_INITIALIZER_NP;
-
-boolean vlCreateHTAB(void)
-{
- boolean ret;
-
- /* Make sure handle table handles match VDPAU handles. */
- assert(sizeof(unsigned) <= sizeof(vlHandle));
- mtx_lock(&htab_lock);
- if (!htab)
- htab = handle_table_create();
- ret = htab != NULL;
- mtx_unlock(&htab_lock);
- return ret;
-}
-
-void vlDestroyHTAB(void)
-{
- mtx_lock(&htab_lock);
- if (htab && !handle_table_get_first_handle(htab)) {
- handle_table_destroy(htab);
- htab = NULL;
- }
- mtx_unlock(&htab_lock);
-}
-
-vlHandle vlAddDataHTAB(void *data)
-{
- vlHandle handle = 0;
-
- assert(data);
- mtx_lock(&htab_lock);
- if (htab)
- handle = handle_table_add(htab, data);
- mtx_unlock(&htab_lock);
- return handle;
-}
-
-void* vlGetDataHTAB(vlHandle handle)
-{
- void *data = NULL;
-
- assert(handle);
- mtx_lock(&htab_lock);
- if (htab)
- data = handle_table_get(htab, handle);
- mtx_unlock(&htab_lock);
- return data;
-}
-
-void vlRemoveDataHTAB(vlHandle handle)
-{
- mtx_lock(&htab_lock);
- if (htab)
- handle_table_remove(htab, handle);
- mtx_unlock(&htab_lock);
-}
diff --git a/src/gallium/state_trackers/vdpau/meson.build b/src/gallium/state_trackers/vdpau/meson.build
deleted file mode 100644
index 28c4e9cab76..00000000000
--- a/src/gallium/state_trackers/vdpau/meson.build
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright © 2017, 2019 Intel Corproration
-
-# 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.
-
-VDPAU_MAJOR = 1
-VDPAU_MINOR = 0
-
-libvdpau_st = static_library(
- 'vdpau_st',
- files(
- 'bitmap.c', 'decode.c', 'device.c', 'ftab.c', 'htab.c', 'mixer.c',
- 'output.c', 'preemption.c', 'presentation.c', 'query.c', 'surface.c',
- ),
- c_args : [
- c_vis_args,
- '-DVER_MAJOR=@0@'.format(VDPAU_MAJOR),
- '-DVER_MINOR=@0@'.format(VDPAU_MINOR),
- ],
- include_directories : [
- inc_include, inc_src, inc_util, inc_gallium, inc_gallium_aux,
- ],
- dependencies : [dep_vdpau, dep_xcb, dep_x11_xcb, dep_xcb_dri2, dep_libdrm],
-)
diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
deleted file mode 100644
index 2e2bd20ef39..00000000000
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ /dev/null
@@ -1,1028 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Thomas Balling Sørensen.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include <vdpau/vdpau.h>
-
-#include "util/u_memory.h"
-#include "util/u_debug.h"
-
-#include "vl/vl_csc.h"
-
-#include "vdpau_private.h"
-
-/**
- * Create a VdpVideoMixer.
- */
-VdpStatus
-vlVdpVideoMixerCreate(VdpDevice device,
- uint32_t feature_count,
- VdpVideoMixerFeature const *features,
- uint32_t parameter_count,
- VdpVideoMixerParameter const *parameters,
- void const *const *parameter_values,
- VdpVideoMixer *mixer)
-{
- vlVdpVideoMixer *vmixer = NULL;
- VdpStatus ret;
- struct pipe_screen *screen;
- unsigned max_size, i;
-
- vlVdpDevice *dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
- screen = dev->vscreen->pscreen;
-
- vmixer = CALLOC(1, sizeof(vlVdpVideoMixer));
- if (!vmixer)
- return VDP_STATUS_RESOURCES;
-
- DeviceReference(&vmixer->device, dev);
-
- mtx_lock(&dev->mutex);
-
- if (!vl_compositor_init_state(&vmixer->cstate, dev->context)) {
- ret = VDP_STATUS_ERROR;
- goto no_compositor_state;
- }
-
- vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &vmixer->csc);
- if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE)) {
- if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc, 1.0f, 0.0f)) {
- ret = VDP_STATUS_ERROR;
- goto err_csc_matrix;
- }
- }
-
- *mixer = vlAddDataHTAB(vmixer);
- if (*mixer == 0) {
- ret = VDP_STATUS_ERROR;
- goto no_handle;
- }
-
- ret = VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
- for (i = 0; i < feature_count; ++i) {
- switch (features[i]) {
- /* they are valid, but we doesn't support them */
- case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
- case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
- vmixer->deint.supported = true;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
- vmixer->sharpness.supported = true;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
- vmixer->noise_reduction.supported = true;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
- vmixer->luma_key.supported = true;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
- vmixer->bicubic.supported = true;
- break;
- default: goto no_params;
- }
- }
-
- vmixer->chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
- ret = VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER;
- for (i = 0; i < parameter_count; ++i) {
- switch (parameters[i]) {
- case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH:
- vmixer->video_width = *(uint32_t*)parameter_values[i];
- break;
- case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT:
- vmixer->video_height = *(uint32_t*)parameter_values[i];
- break;
- case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE:
- vmixer->chroma_format = ChromaToPipe(*(VdpChromaType*)parameter_values[i]);
- break;
- case VDP_VIDEO_MIXER_PARAMETER_LAYERS:
- vmixer->max_layers = *(uint32_t*)parameter_values[i];
- break;
- default: goto no_params;
- }
- }
- ret = VDP_STATUS_INVALID_VALUE;
- if (vmixer->max_layers > 4) {
- VDPAU_MSG(VDPAU_WARN, "[VDPAU] Max layers > 4 not supported\n", vmixer->max_layers);
- goto no_params;
- }
-
- max_size = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_SIZE);
- if (vmixer->video_width < 48 || vmixer->video_width > max_size) {
- VDPAU_MSG(VDPAU_WARN, "[VDPAU] 48 < %u < %u not valid for width\n",
- vmixer->video_width, max_size);
- goto no_params;
- }
- if (vmixer->video_height < 48 || vmixer->video_height > max_size) {
- VDPAU_MSG(VDPAU_WARN, "[VDPAU] 48 < %u < %u not valid for height\n",
- vmixer->video_height, max_size);
- goto no_params;
- }
- vmixer->luma_key.luma_min = 1.0f;
- vmixer->luma_key.luma_max = 0.0f;
- mtx_unlock(&dev->mutex);
-
- return VDP_STATUS_OK;
-
-no_params:
- vlRemoveDataHTAB(*mixer);
-
-no_handle:
-err_csc_matrix:
- vl_compositor_cleanup_state(&vmixer->cstate);
-no_compositor_state:
- mtx_unlock(&dev->mutex);
- DeviceReference(&vmixer->device, NULL);
- FREE(vmixer);
- return ret;
-}
-
-/**
- * Destroy a VdpVideoMixer.
- */
-VdpStatus
-vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
-{
- vlVdpVideoMixer *vmixer;
-
- vmixer = vlGetDataHTAB(mixer);
- if (!vmixer)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&vmixer->device->mutex);
-
- vlRemoveDataHTAB(mixer);
-
- vl_compositor_cleanup_state(&vmixer->cstate);
-
- if (vmixer->deint.filter) {
- vl_deint_filter_cleanup(vmixer->deint.filter);
- FREE(vmixer->deint.filter);
- }
-
- if (vmixer->noise_reduction.filter) {
- vl_median_filter_cleanup(vmixer->noise_reduction.filter);
- FREE(vmixer->noise_reduction.filter);
- }
-
- if (vmixer->sharpness.filter) {
- vl_matrix_filter_cleanup(vmixer->sharpness.filter);
- FREE(vmixer->sharpness.filter);
- }
-
- if (vmixer->bicubic.filter) {
- vl_bicubic_filter_cleanup(vmixer->bicubic.filter);
- FREE(vmixer->bicubic.filter);
- }
- mtx_unlock(&vmixer->device->mutex);
- DeviceReference(&vmixer->device, NULL);
-
- FREE(vmixer);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Perform a video post-processing and compositing operation.
- */
-VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
- VdpOutputSurface background_surface,
- VdpRect const *background_source_rect,
- VdpVideoMixerPictureStructure current_picture_structure,
- uint32_t video_surface_past_count,
- VdpVideoSurface const *video_surface_past,
- VdpVideoSurface video_surface_current,
- uint32_t video_surface_future_count,
- VdpVideoSurface const *video_surface_future,
- VdpRect const *video_source_rect,
- VdpOutputSurface destination_surface,
- VdpRect const *destination_rect,
- VdpRect const *destination_video_rect,
- uint32_t layer_count,
- VdpLayer const *layers)
-{
- enum vl_compositor_deinterlace deinterlace;
- struct u_rect rect, clip, *prect, dirty_area;
- unsigned i, layer = 0;
- struct pipe_video_buffer *video_buffer;
- struct pipe_sampler_view *sampler_view, sv_templ;
- struct pipe_surface *surface, surf_templ;
- struct pipe_context *pipe = NULL;
- struct pipe_resource res_tmpl, *res;
-
- vlVdpVideoMixer *vmixer;
- vlVdpSurface *surf;
- vlVdpOutputSurface *dst, *bg = NULL;
-
- struct vl_compositor *compositor;
-
- vmixer = vlGetDataHTAB(mixer);
- if (!vmixer)
- return VDP_STATUS_INVALID_HANDLE;
-
- compositor = &vmixer->device->compositor;
-
- surf = vlGetDataHTAB(video_surface_current);
- if (!surf)
- return VDP_STATUS_INVALID_HANDLE;
- video_buffer = surf->video_buffer;
-
- if (surf->device != vmixer->device)
- return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
-
- if (vmixer->video_width > video_buffer->width ||
- vmixer->video_height > video_buffer->height ||
- vmixer->chroma_format != pipe_format_to_chroma_format(video_buffer->buffer_format))
- return VDP_STATUS_INVALID_SIZE;
-
- if (layer_count > vmixer->max_layers)
- return VDP_STATUS_INVALID_VALUE;
-
- dst = vlGetDataHTAB(destination_surface);
- if (!dst)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (background_surface != VDP_INVALID_HANDLE) {
- bg = vlGetDataHTAB(background_surface);
- if (!bg)
- return VDP_STATUS_INVALID_HANDLE;
- }
-
- mtx_lock(&vmixer->device->mutex);
-
- vl_compositor_clear_layers(&vmixer->cstate);
-
- if (bg)
- vl_compositor_set_rgba_layer(&vmixer->cstate, compositor, layer++, bg->sampler_view,
- RectToPipe(background_source_rect, &rect), NULL, NULL);
-
- switch (current_picture_structure) {
- case VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD:
- deinterlace = VL_COMPOSITOR_BOB_TOP;
- break;
-
- case VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD:
- deinterlace = VL_COMPOSITOR_BOB_BOTTOM;
- break;
-
- case VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME:
- deinterlace = VL_COMPOSITOR_WEAVE;
- break;
-
- default:
- mtx_unlock(&vmixer->device->mutex);
- return VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE;
- }
-
- if (deinterlace != VL_COMPOSITOR_WEAVE && vmixer->deint.enabled &&
- video_surface_past_count > 1 && video_surface_future_count > 0) {
- vlVdpSurface *prevprev = vlGetDataHTAB(video_surface_past[1]);
- vlVdpSurface *prev = vlGetDataHTAB(video_surface_past[0]);
- vlVdpSurface *next = vlGetDataHTAB(video_surface_future[0]);
- if (prevprev && prev && next &&
- vl_deint_filter_check_buffers(vmixer->deint.filter,
- prevprev->video_buffer, prev->video_buffer, surf->video_buffer, next->video_buffer)) {
- vl_deint_filter_render(vmixer->deint.filter, prevprev->video_buffer,
- prev->video_buffer, surf->video_buffer,
- next->video_buffer,
- deinterlace == VL_COMPOSITOR_BOB_BOTTOM);
- deinterlace = VL_COMPOSITOR_WEAVE;
- video_buffer = vmixer->deint.filter->video_buffer;
- }
- }
-
- prect = RectToPipe(video_source_rect, &rect);
- if (!prect) {
- rect.x0 = 0;
- rect.y0 = 0;
- rect.x1 = surf->templat.width;
- rect.y1 = surf->templat.height;
- prect = &rect;
- }
- vl_compositor_set_buffer_layer(&vmixer->cstate, compositor, layer, video_buffer, prect, NULL, deinterlace);
-
- if (vmixer->bicubic.filter || vmixer->sharpness.filter || vmixer->noise_reduction.filter) {
- pipe = vmixer->device->context;
- memset(&res_tmpl, 0, sizeof(res_tmpl));
-
- res_tmpl.target = PIPE_TEXTURE_2D;
- res_tmpl.format = dst->sampler_view->format;
- res_tmpl.depth0 = 1;
- res_tmpl.array_size = 1;
- res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
- res_tmpl.usage = PIPE_USAGE_DEFAULT;
-
- if (!vmixer->bicubic.filter) {
- res_tmpl.width0 = dst->surface->width;
- res_tmpl.height0 = dst->surface->height;
- } else {
- res_tmpl.width0 = surf->templat.width;
- res_tmpl.height0 = surf->templat.height;
- }
-
- res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
-
- vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
- sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ);
-
- memset(&surf_templ, 0, sizeof(surf_templ));
- surf_templ.format = res->format;
- surface = pipe->create_surface(pipe, res, &surf_templ);
-
- vl_compositor_reset_dirty_area(&dirty_area);
- pipe_resource_reference(&res, NULL);
- } else {
- surface = dst->surface;
- sampler_view = dst->sampler_view;
- dirty_area = dst->dirty_area;
- }
-
- if (!vmixer->bicubic.filter) {
- vl_compositor_set_layer_dst_area(&vmixer->cstate, layer++, RectToPipe(destination_video_rect, &rect));
- vl_compositor_set_dst_clip(&vmixer->cstate, RectToPipe(destination_rect, &clip));
- }
-
- for (i = 0; i < layer_count; ++i) {
- vlVdpOutputSurface *src = vlGetDataHTAB(layers->source_surface);
- if (!src) {
- mtx_unlock(&vmixer->device->mutex);
- return VDP_STATUS_INVALID_HANDLE;
- }
-
- assert(layers->struct_version == VDP_LAYER_VERSION);
-
- vl_compositor_set_rgba_layer(&vmixer->cstate, compositor, layer, src->sampler_view,
- RectToPipe(layers->source_rect, &rect), NULL, NULL);
- vl_compositor_set_layer_dst_area(&vmixer->cstate, layer++, RectToPipe(layers->destination_rect, &rect));
-
- ++layers;
- }
-
- vl_compositor_render(&vmixer->cstate, compositor, surface, &dirty_area, true);
-
- if (vmixer->noise_reduction.filter) {
- if (!vmixer->sharpness.filter && !vmixer->bicubic.filter) {
- vl_median_filter_render(vmixer->noise_reduction.filter,
- sampler_view, dst->surface);
- } else {
- res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
- struct pipe_sampler_view *sampler_view_temp = pipe->create_sampler_view(pipe, res, &sv_templ);
- struct pipe_surface *surface_temp = pipe->create_surface(pipe, res, &surf_templ);
- pipe_resource_reference(&res, NULL);
-
- vl_median_filter_render(vmixer->noise_reduction.filter,
- sampler_view, surface_temp);
-
- pipe_sampler_view_reference(&sampler_view, NULL);
- pipe_surface_reference(&surface, NULL);
-
- sampler_view = sampler_view_temp;
- surface = surface_temp;
- }
- }
-
- if (vmixer->sharpness.filter) {
- if (!vmixer->bicubic.filter) {
- vl_matrix_filter_render(vmixer->sharpness.filter,
- sampler_view, dst->surface);
- } else {
- res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
- struct pipe_sampler_view *sampler_view_temp = pipe->create_sampler_view(pipe, res, &sv_templ);
- struct pipe_surface *surface_temp = pipe->create_surface(pipe, res, &surf_templ);
- pipe_resource_reference(&res, NULL);
-
- vl_matrix_filter_render(vmixer->sharpness.filter,
- sampler_view, surface_temp);
-
- pipe_sampler_view_reference(&sampler_view, NULL);
- pipe_surface_reference(&surface, NULL);
-
- sampler_view = sampler_view_temp;
- surface = surface_temp;
- }
- }
-
- if (vmixer->bicubic.filter)
- vl_bicubic_filter_render(vmixer->bicubic.filter,
- sampler_view, dst->surface,
- RectToPipe(destination_video_rect, &rect),
- RectToPipe(destination_rect, &clip));
-
- if(surface != dst->surface) {
- pipe_sampler_view_reference(&sampler_view, NULL);
- pipe_surface_reference(&surface, NULL);
- }
- mtx_unlock(&vmixer->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-static void
-vlVdpVideoMixerUpdateDeinterlaceFilter(vlVdpVideoMixer *vmixer)
-{
- struct pipe_context *pipe = vmixer->device->context;
- assert(vmixer);
-
- /* remove existing filter */
- if (vmixer->deint.filter) {
- vl_deint_filter_cleanup(vmixer->deint.filter);
- FREE(vmixer->deint.filter);
- vmixer->deint.filter = NULL;
- }
-
- /* create a new filter if requested */
- if (vmixer->deint.enabled && vmixer->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
- vmixer->deint.filter = MALLOC(sizeof(struct vl_deint_filter));
- vmixer->deint.enabled = vl_deint_filter_init(vmixer->deint.filter, pipe,
- vmixer->video_width, vmixer->video_height,
- vmixer->skip_chroma_deint, vmixer->deint.spatial);
- if (!vmixer->deint.enabled) {
- FREE(vmixer->deint.filter);
- }
- }
-}
-
-/**
- * Update the noise reduction setting
- */
-static void
-vlVdpVideoMixerUpdateNoiseReductionFilter(vlVdpVideoMixer *vmixer)
-{
- assert(vmixer);
-
- /* if present remove the old filter first */
- if (vmixer->noise_reduction.filter) {
- vl_median_filter_cleanup(vmixer->noise_reduction.filter);
- FREE(vmixer->noise_reduction.filter);
- vmixer->noise_reduction.filter = NULL;
- }
-
- /* and create a new filter as needed */
- if (vmixer->noise_reduction. enabled && vmixer->noise_reduction.level > 0) {
- vmixer->noise_reduction.filter = MALLOC(sizeof(struct vl_median_filter));
- vl_median_filter_init(vmixer->noise_reduction.filter, vmixer->device->context,
- vmixer->video_width, vmixer->video_height,
- vmixer->noise_reduction.level + 1,
- VL_MEDIAN_FILTER_CROSS);
- }
-}
-
-static void
-vlVdpVideoMixerUpdateSharpnessFilter(vlVdpVideoMixer *vmixer)
-{
- assert(vmixer);
-
- /* if present remove the old filter first */
- if (vmixer->sharpness.filter) {
- vl_matrix_filter_cleanup(vmixer->sharpness.filter);
- FREE(vmixer->sharpness.filter);
- vmixer->sharpness.filter = NULL;
- }
-
- /* and create a new filter as needed */
- if (vmixer->sharpness.enabled && vmixer->sharpness.value != 0.0f) {
- float matrix[9];
- unsigned i;
-
- if (vmixer->sharpness.value > 0.0f) {
- matrix[0] = -1.0f; matrix[1] = -1.0f; matrix[2] = -1.0f;
- matrix[3] = -1.0f; matrix[4] = 8.0f; matrix[5] = -1.0f;
- matrix[6] = -1.0f; matrix[7] = -1.0f; matrix[8] = -1.0f;
-
- for (i = 0; i < 9; ++i)
- matrix[i] *= vmixer->sharpness.value;
-
- matrix[4] += 1.0f;
-
- } else {
- matrix[0] = 1.0f; matrix[1] = 2.0f; matrix[2] = 1.0f;
- matrix[3] = 2.0f; matrix[4] = 4.0f; matrix[5] = 2.0f;
- matrix[6] = 1.0f; matrix[7] = 2.0f; matrix[8] = 1.0f;
-
- for (i = 0; i < 9; ++i)
- matrix[i] *= fabsf(vmixer->sharpness.value) / 16.0f;
-
- matrix[4] += 1.0f - fabsf(vmixer->sharpness.value);
- }
-
- vmixer->sharpness.filter = MALLOC(sizeof(struct vl_matrix_filter));
- vl_matrix_filter_init(vmixer->sharpness.filter, vmixer->device->context,
- vmixer->video_width, vmixer->video_height,
- 3, 3, matrix);
- }
-}
-
-/**
- * Update the bicubic filter
- */
-static void
-vlVdpVideoMixerUpdateBicubicFilter(vlVdpVideoMixer *vmixer)
-{
- assert(vmixer);
-
- /* if present remove the old filter first */
- if (vmixer->bicubic.filter) {
- vl_bicubic_filter_cleanup(vmixer->bicubic.filter);
- FREE(vmixer->bicubic.filter);
- vmixer->bicubic.filter = NULL;
- }
- /* and create a new filter as needed */
- if (vmixer->bicubic.enabled) {
- vmixer->bicubic.filter = MALLOC(sizeof(struct vl_bicubic_filter));
- vl_bicubic_filter_init(vmixer->bicubic.filter, vmixer->device->context,
- vmixer->video_width, vmixer->video_height);
- }
-}
-
-/**
- * Retrieve whether features were requested at creation time.
- */
-VdpStatus
-vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,
- uint32_t feature_count,
- VdpVideoMixerFeature const *features,
- VdpBool *feature_supports)
-{
- vlVdpVideoMixer *vmixer;
- unsigned i;
-
- if (!(features && feature_supports))
- return VDP_STATUS_INVALID_POINTER;
-
- vmixer = vlGetDataHTAB(mixer);
- if (!vmixer)
- return VDP_STATUS_INVALID_HANDLE;
-
- for (i = 0; i < feature_count; ++i) {
- switch (features[i]) {
- /* they are valid, but we doesn't support them */
- case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
- case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
- feature_supports[i] = false;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
- feature_supports[i] = vmixer->deint.supported;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
- feature_supports[i] = vmixer->sharpness.supported;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
- feature_supports[i] = vmixer->noise_reduction.supported;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
- feature_supports[i] = vmixer->luma_key.supported;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
- feature_supports[i] = vmixer->bicubic.supported;
- break;
-
- default:
- return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
- }
- }
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Enable or disable features.
- */
-VdpStatus
-vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
- uint32_t feature_count,
- VdpVideoMixerFeature const *features,
- VdpBool const *feature_enables)
-{
- vlVdpVideoMixer *vmixer;
- unsigned i;
-
- if (!(features && feature_enables))
- return VDP_STATUS_INVALID_POINTER;
-
- vmixer = vlGetDataHTAB(mixer);
- if (!vmixer)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&vmixer->device->mutex);
- for (i = 0; i < feature_count; ++i) {
- switch (features[i]) {
- /* they are valid, but we doesn't support them */
- case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
- case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
- vmixer->deint.enabled = feature_enables[i];
- vlVdpVideoMixerUpdateDeinterlaceFilter(vmixer);
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
- vmixer->sharpness.enabled = feature_enables[i];
- vlVdpVideoMixerUpdateSharpnessFilter(vmixer);
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
- vmixer->noise_reduction.enabled = feature_enables[i];
- vlVdpVideoMixerUpdateNoiseReductionFilter(vmixer);
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
- vmixer->luma_key.enabled = feature_enables[i];
- if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
- if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
- vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) {
- mtx_unlock(&vmixer->device->mutex);
- return VDP_STATUS_ERROR;
- }
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
- vmixer->bicubic.enabled = feature_enables[i];
- vlVdpVideoMixerUpdateBicubicFilter(vmixer);
- break;
-
- default:
- mtx_unlock(&vmixer->device->mutex);
- return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
- }
- }
- mtx_unlock(&vmixer->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Retrieve whether features are enabled.
- */
-VdpStatus
-vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer,
- uint32_t feature_count,
- VdpVideoMixerFeature const *features,
- VdpBool *feature_enables)
-{
- vlVdpVideoMixer *vmixer;
- unsigned i;
-
- if (!(features && feature_enables))
- return VDP_STATUS_INVALID_POINTER;
-
- vmixer = vlGetDataHTAB(mixer);
- if (!vmixer)
- return VDP_STATUS_INVALID_HANDLE;
-
- for (i = 0; i < feature_count; ++i) {
- switch (features[i]) {
- /* they are valid, but we doesn't support them */
- case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
- case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
- case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
- feature_enables[i] = vmixer->sharpness.enabled;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
- feature_enables[i] = vmixer->noise_reduction.enabled;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
- feature_enables[i] = vmixer->luma_key.enabled;
- break;
-
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
- feature_enables[i] = vmixer->bicubic.enabled;
- break;
-
- default:
- return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
- }
- }
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Set attribute values.
- */
-VdpStatus
-vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
- uint32_t attribute_count,
- VdpVideoMixerAttribute const *attributes,
- void const *const *attribute_values)
-{
- const VdpColor *background_color;
- union pipe_color_union color;
- const float *vdp_csc;
- float val;
- unsigned i;
- VdpStatus ret;
-
- if (!(attributes && attribute_values))
- return VDP_STATUS_INVALID_POINTER;
-
- vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
- if (!vmixer)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&vmixer->device->mutex);
- for (i = 0; i < attribute_count; ++i) {
- switch (attributes[i]) {
- case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
- background_color = attribute_values[i];
- color.f[0] = background_color->red;
- color.f[1] = background_color->green;
- color.f[2] = background_color->blue;
- color.f[3] = background_color->alpha;
- vl_compositor_set_clear_color(&vmixer->cstate, &color);
- break;
- case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX:
- vdp_csc = attribute_values[i];
- vmixer->custom_csc = !!vdp_csc;
- if (!vdp_csc)
- vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, 1, &vmixer->csc);
- else
- memcpy(vmixer->csc, vdp_csc, sizeof(vl_csc_matrix));
- if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
- if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
- vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) {
- ret = VDP_STATUS_ERROR;
- goto fail;
- }
- break;
-
- case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
-
- val = *(float*)attribute_values[i];
- if (val < 0.0f || val > 1.0f) {
- ret = VDP_STATUS_INVALID_VALUE;
- goto fail;
- }
-
- vmixer->noise_reduction.level = val * 10;
- vlVdpVideoMixerUpdateNoiseReductionFilter(vmixer);
- break;
-
- case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA:
- val = *(float*)attribute_values[i];
- if (val < 0.0f || val > 1.0f) {
- ret = VDP_STATUS_INVALID_VALUE;
- goto fail;
- }
- vmixer->luma_key.luma_min = val;
- if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
- if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
- vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) {
- ret = VDP_STATUS_ERROR;
- goto fail;
- }
- break;
-
- case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA:
- val = *(float*)attribute_values[i];
- if (val < 0.0f || val > 1.0f) {
- ret = VDP_STATUS_INVALID_VALUE;
- goto fail;
- }
- vmixer->luma_key.luma_max = val;
- if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
- if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
- vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) {
- ret = VDP_STATUS_ERROR;
- goto fail;
- }
- break;
-
- case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL:
-
- val = *(float*)attribute_values[i];
- if (val < -1.0f || val > 1.0f) {
- ret = VDP_STATUS_INVALID_VALUE;
- goto fail;
- }
-
- vmixer->sharpness.value = val;
- vlVdpVideoMixerUpdateSharpnessFilter(vmixer);
- break;
-
- case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE:
- if (*(uint8_t*)attribute_values[i] > 1) {
- ret = VDP_STATUS_INVALID_VALUE;
- goto fail;
- }
- vmixer->skip_chroma_deint = *(uint8_t*)attribute_values[i];
- vlVdpVideoMixerUpdateDeinterlaceFilter(vmixer);
- break;
- default:
- ret = VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE;
- goto fail;
- }
- }
- mtx_unlock(&vmixer->device->mutex);
-
- return VDP_STATUS_OK;
-fail:
- mtx_unlock(&vmixer->device->mutex);
- return ret;
-}
-
-/**
- * Retrieve parameter values given at creation time.
- */
-VdpStatus
-vlVdpVideoMixerGetParameterValues(VdpVideoMixer mixer,
- uint32_t parameter_count,
- VdpVideoMixerParameter const *parameters,
- void *const *parameter_values)
-{
- vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
- unsigned i;
- if (!vmixer)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (!parameter_count)
- return VDP_STATUS_OK;
- if (!(parameters && parameter_values))
- return VDP_STATUS_INVALID_POINTER;
- for (i = 0; i < parameter_count; ++i) {
- switch (parameters[i]) {
- case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH:
- *(uint32_t*)parameter_values[i] = vmixer->video_width;
- break;
- case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT:
- *(uint32_t*)parameter_values[i] = vmixer->video_height;
- break;
- case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE:
- *(VdpChromaType*)parameter_values[i] = PipeToChroma(vmixer->chroma_format);
- break;
- case VDP_VIDEO_MIXER_PARAMETER_LAYERS:
- *(uint32_t*)parameter_values[i] = vmixer->max_layers;
- break;
- default:
- return VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER;
- }
- }
- return VDP_STATUS_OK;
-}
-
-/**
- * Retrieve current attribute values.
- */
-VdpStatus
-vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer,
- uint32_t attribute_count,
- VdpVideoMixerAttribute const *attributes,
- void *const *attribute_values)
-{
- unsigned i;
- VdpCSCMatrix **vdp_csc;
-
- if (!(attributes && attribute_values))
- return VDP_STATUS_INVALID_POINTER;
-
- vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
- if (!vmixer)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&vmixer->device->mutex);
- for (i = 0; i < attribute_count; ++i) {
- switch (attributes[i]) {
- case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
- vl_compositor_get_clear_color(&vmixer->cstate, attribute_values[i]);
- break;
- case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX:
- vdp_csc = attribute_values[i];
- if (!vmixer->custom_csc) {
- *vdp_csc = NULL;
- break;
- }
- memcpy(*vdp_csc, vmixer->csc, sizeof(float)*12);
- break;
-
- case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
- *(float*)attribute_values[i] = (float)vmixer->noise_reduction.level / 10.0f;
- break;
-
- case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA:
- *(float*)attribute_values[i] = vmixer->luma_key.luma_min;
- break;
- case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA:
- *(float*)attribute_values[i] = vmixer->luma_key.luma_max;
- break;
- case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL:
- *(float*)attribute_values[i] = vmixer->sharpness.value;
- break;
- case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE:
- *(uint8_t*)attribute_values[i] = vmixer->skip_chroma_deint;
- break;
- default:
- mtx_unlock(&vmixer->device->mutex);
- return VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE;
- }
- }
- mtx_unlock(&vmixer->device->mutex);
- return VDP_STATUS_OK;
-}
-
-/**
- * Generate a color space conversion matrix.
- */
-VdpStatus
-vlVdpGenerateCSCMatrix(VdpProcamp *procamp,
- VdpColorStandard standard,
- VdpCSCMatrix *csc_matrix)
-{
- enum VL_CSC_COLOR_STANDARD vl_std;
- struct vl_procamp camp;
-
- if (!csc_matrix)
- return VDP_STATUS_INVALID_POINTER;
-
- switch (standard) {
- case VDP_COLOR_STANDARD_ITUR_BT_601: vl_std = VL_CSC_COLOR_STANDARD_BT_601; break;
- case VDP_COLOR_STANDARD_ITUR_BT_709: vl_std = VL_CSC_COLOR_STANDARD_BT_709; break;
- case VDP_COLOR_STANDARD_SMPTE_240M: vl_std = VL_CSC_COLOR_STANDARD_SMPTE_240M; break;
- default: return VDP_STATUS_INVALID_COLOR_STANDARD;
- }
-
- if (procamp) {
- if (procamp->struct_version > VDP_PROCAMP_VERSION)
- return VDP_STATUS_INVALID_STRUCT_VERSION;
- camp.brightness = procamp->brightness;
- camp.contrast = procamp->contrast;
- camp.saturation = procamp->saturation;
- camp.hue = procamp->hue;
- }
-
- vl_csc_get_matrix(vl_std, procamp ? &camp : NULL, true, csc_matrix);
- return VDP_STATUS_OK;
-}
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
deleted file mode 100644
index ac8fc550bc7..00000000000
--- a/src/gallium/state_trackers/vdpau/output.c
+++ /dev/null
@@ -1,828 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Thomas Balling Sørensen.
- * Copyright 2011 Christian König.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include <vdpau/vdpau.h>
-
-#include "util/u_debug.h"
-#include "util/u_memory.h"
-#include "util/u_sampler.h"
-#include "util/format/u_format.h"
-#include "util/u_surface.h"
-
-#include "vl/vl_csc.h"
-
-#include "state_tracker/drm_driver.h"
-
-#include "vdpau_private.h"
-
-/**
- * Create a VdpOutputSurface.
- */
-VdpStatus
-vlVdpOutputSurfaceCreate(VdpDevice device,
- VdpRGBAFormat rgba_format,
- uint32_t width, uint32_t height,
- VdpOutputSurface *surface)
-{
- struct pipe_context *pipe;
- struct pipe_resource res_tmpl, *res;
- struct pipe_sampler_view sv_templ;
- struct pipe_surface surf_templ;
-
- vlVdpOutputSurface *vlsurface = NULL;
-
- if (!(width && height))
- return VDP_STATUS_INVALID_SIZE;
-
- vlVdpDevice *dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pipe = dev->context;
- if (!pipe)
- return VDP_STATUS_INVALID_HANDLE;
-
- vlsurface = CALLOC(1, sizeof(vlVdpOutputSurface));
- if (!vlsurface)
- return VDP_STATUS_RESOURCES;
-
- DeviceReference(&vlsurface->device, dev);
-
- memset(&res_tmpl, 0, sizeof(res_tmpl));
-
- /*
- * The output won't look correctly when this buffer is send to X,
- * if the VDPAU RGB component order doesn't match the X11 one so
- * we only allow the X11 format
- */
- vlsurface->send_to_X = dev->vscreen->color_depth == 24 &&
- rgba_format == VDP_RGBA_FORMAT_B8G8R8A8;
-
- res_tmpl.target = PIPE_TEXTURE_2D;
- res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
- res_tmpl.width0 = width;
- res_tmpl.height0 = height;
- res_tmpl.depth0 = 1;
- res_tmpl.array_size = 1;
- res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_SHARED | PIPE_BIND_SCANOUT;
- res_tmpl.usage = PIPE_USAGE_DEFAULT;
-
- mtx_lock(&dev->mutex);
-
- if (!CheckSurfaceParams(pipe->screen, &res_tmpl))
- goto err_unlock;
-
- res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
- if (!res)
- goto err_unlock;
-
- vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
- vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ);
- if (!vlsurface->sampler_view)
- goto err_resource;
-
- memset(&surf_templ, 0, sizeof(surf_templ));
- surf_templ.format = res->format;
- vlsurface->surface = pipe->create_surface(pipe, res, &surf_templ);
- if (!vlsurface->surface)
- goto err_resource;
-
- *surface = vlAddDataHTAB(vlsurface);
- if (*surface == 0)
- goto err_resource;
-
- pipe_resource_reference(&res, NULL);
-
- if (!vl_compositor_init_state(&vlsurface->cstate, pipe))
- goto err_resource;
-
- vl_compositor_reset_dirty_area(&vlsurface->dirty_area);
- mtx_unlock(&dev->mutex);
-
- return VDP_STATUS_OK;
-
-err_resource:
- pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
- pipe_surface_reference(&vlsurface->surface, NULL);
- pipe_resource_reference(&res, NULL);
-err_unlock:
- mtx_unlock(&dev->mutex);
- DeviceReference(&vlsurface->device, NULL);
- FREE(vlsurface);
- return VDP_STATUS_ERROR;
-}
-
-/**
- * Destroy a VdpOutputSurface.
- */
-VdpStatus
-vlVdpOutputSurfaceDestroy(VdpOutputSurface surface)
-{
- vlVdpOutputSurface *vlsurface;
- struct pipe_context *pipe;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- pipe = vlsurface->device->context;
-
- mtx_lock(&vlsurface->device->mutex);
-
- pipe_surface_reference(&vlsurface->surface, NULL);
- pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
- pipe->screen->fence_reference(pipe->screen, &vlsurface->fence, NULL);
- vl_compositor_cleanup_state(&vlsurface->cstate);
- mtx_unlock(&vlsurface->device->mutex);
-
- vlRemoveDataHTAB(surface);
- DeviceReference(&vlsurface->device, NULL);
- FREE(vlsurface);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Retrieve the parameters used to create a VdpOutputSurface.
- */
-VdpStatus
-vlVdpOutputSurfaceGetParameters(VdpOutputSurface surface,
- VdpRGBAFormat *rgba_format,
- uint32_t *width, uint32_t *height)
-{
- vlVdpOutputSurface *vlsurface;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- *rgba_format = PipeToFormatRGBA(vlsurface->sampler_view->texture->format);
- *width = vlsurface->sampler_view->texture->width0;
- *height = vlsurface->sampler_view->texture->height0;
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Copy image data from a VdpOutputSurface to application memory in the
- * surface's native format.
- */
-VdpStatus
-vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
- VdpRect const *source_rect,
- void *const *destination_data,
- uint32_t const *destination_pitches)
-{
- vlVdpOutputSurface *vlsurface;
- struct pipe_context *pipe;
- struct pipe_resource *res;
- struct pipe_box box;
- struct pipe_transfer *transfer;
- uint8_t *map;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- pipe = vlsurface->device->context;
- if (!pipe)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (!destination_data || !destination_pitches)
- return VDP_STATUS_INVALID_POINTER;
-
- mtx_lock(&vlsurface->device->mutex);
-
- res = vlsurface->sampler_view->texture;
- box = RectToPipeBox(source_rect, res);
- map = pipe->transfer_map(pipe, res, 0, PIPE_TRANSFER_READ, &box, &transfer);
- if (!map) {
- mtx_unlock(&vlsurface->device->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- util_copy_rect(*destination_data, res->format, *destination_pitches, 0, 0,
- box.width, box.height, map, transfer->stride, 0, 0);
-
- pipe_transfer_unmap(pipe, transfer);
- mtx_unlock(&vlsurface->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Copy image data from application memory in the surface's native format to
- * a VdpOutputSurface.
- */
-VdpStatus
-vlVdpOutputSurfacePutBitsNative(VdpOutputSurface surface,
- void const *const *source_data,
- uint32_t const *source_pitches,
- VdpRect const *destination_rect)
-{
- vlVdpOutputSurface *vlsurface;
- struct pipe_box dst_box;
- struct pipe_context *pipe;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- pipe = vlsurface->device->context;
- if (!pipe)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (!source_data || !source_pitches)
- return VDP_STATUS_INVALID_POINTER;
-
- mtx_lock(&vlsurface->device->mutex);
-
- dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
-
- /* Check for a no-op. (application bug?) */
- if (!dst_box.width || !dst_box.height) {
- mtx_unlock(&vlsurface->device->mutex);
- return VDP_STATUS_OK;
- }
-
- pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
- PIPE_TRANSFER_WRITE, &dst_box, *source_data,
- *source_pitches, 0);
- mtx_unlock(&vlsurface->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Copy image data from application memory in a specific indexed format to
- * a VdpOutputSurface.
- */
-VdpStatus
-vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
- VdpIndexedFormat source_indexed_format,
- void const *const *source_data,
- uint32_t const *source_pitch,
- VdpRect const *destination_rect,
- VdpColorTableFormat color_table_format,
- void const *color_table)
-{
- vlVdpOutputSurface *vlsurface;
- struct pipe_context *context;
- struct vl_compositor *compositor;
- struct vl_compositor_state *cstate;
-
- enum pipe_format index_format;
- enum pipe_format colortbl_format;
-
- struct pipe_resource *res, res_tmpl;
- struct pipe_sampler_view sv_tmpl;
- struct pipe_sampler_view *sv_idx = NULL, *sv_tbl = NULL;
-
- struct pipe_box box;
- struct u_rect dst_rect;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- context = vlsurface->device->context;
- compositor = &vlsurface->device->compositor;
- cstate = &vlsurface->cstate;
-
- index_format = FormatIndexedToPipe(source_indexed_format);
- if (index_format == PIPE_FORMAT_NONE)
- return VDP_STATUS_INVALID_INDEXED_FORMAT;
-
- if (!source_data || !source_pitch)
- return VDP_STATUS_INVALID_POINTER;
-
- colortbl_format = FormatColorTableToPipe(color_table_format);
- if (colortbl_format == PIPE_FORMAT_NONE)
- return VDP_STATUS_INVALID_COLOR_TABLE_FORMAT;
-
- if (!color_table)
- return VDP_STATUS_INVALID_POINTER;
-
- memset(&res_tmpl, 0, sizeof(res_tmpl));
- res_tmpl.target = PIPE_TEXTURE_2D;
- res_tmpl.format = index_format;
-
- if (destination_rect) {
- res_tmpl.width0 = abs(destination_rect->x0-destination_rect->x1);
- res_tmpl.height0 = abs(destination_rect->y0-destination_rect->y1);
- } else {
- res_tmpl.width0 = vlsurface->surface->texture->width0;
- res_tmpl.height0 = vlsurface->surface->texture->height0;
- }
- res_tmpl.depth0 = 1;
- res_tmpl.array_size = 1;
- res_tmpl.usage = PIPE_USAGE_STAGING;
- res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
-
- mtx_lock(&vlsurface->device->mutex);
-
- if (!CheckSurfaceParams(context->screen, &res_tmpl))
- goto error_resource;
-
- res = context->screen->resource_create(context->screen, &res_tmpl);
- if (!res)
- goto error_resource;
-
- box.x = box.y = box.z = 0;
- box.width = res->width0;
- box.height = res->height0;
- box.depth = res->depth0;
-
- context->texture_subdata(context, res, 0, PIPE_TRANSFER_WRITE, &box,
- source_data[0], source_pitch[0],
- source_pitch[0] * res->height0);
-
- memset(&sv_tmpl, 0, sizeof(sv_tmpl));
- u_sampler_view_default_template(&sv_tmpl, res, res->format);
-
- sv_idx = context->create_sampler_view(context, res, &sv_tmpl);
- pipe_resource_reference(&res, NULL);
-
- if (!sv_idx)
- goto error_resource;
-
- memset(&res_tmpl, 0, sizeof(res_tmpl));
- res_tmpl.target = PIPE_TEXTURE_1D;
- res_tmpl.format = colortbl_format;
- res_tmpl.width0 = 1 << util_format_get_component_bits(
- index_format, UTIL_FORMAT_COLORSPACE_RGB, 0);
- res_tmpl.height0 = 1;
- res_tmpl.depth0 = 1;
- res_tmpl.array_size = 1;
- res_tmpl.usage = PIPE_USAGE_STAGING;
- res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
-
- res = context->screen->resource_create(context->screen, &res_tmpl);
- if (!res)
- goto error_resource;
-
- box.x = box.y = box.z = 0;
- box.width = res->width0;
- box.height = res->height0;
- box.depth = res->depth0;
-
- context->texture_subdata(context, res, 0, PIPE_TRANSFER_WRITE, &box, color_table,
- util_format_get_stride(colortbl_format, res->width0), 0);
-
- memset(&sv_tmpl, 0, sizeof(sv_tmpl));
- u_sampler_view_default_template(&sv_tmpl, res, res->format);
-
- sv_tbl = context->create_sampler_view(context, res, &sv_tmpl);
- pipe_resource_reference(&res, NULL);
-
- if (!sv_tbl)
- goto error_resource;
-
- vl_compositor_clear_layers(cstate);
- vl_compositor_set_palette_layer(cstate, compositor, 0, sv_idx, sv_tbl, NULL, NULL, false);
- vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
- vl_compositor_render(cstate, compositor, vlsurface->surface, &vlsurface->dirty_area, false);
-
- pipe_sampler_view_reference(&sv_idx, NULL);
- pipe_sampler_view_reference(&sv_tbl, NULL);
- mtx_unlock(&vlsurface->device->mutex);
-
- return VDP_STATUS_OK;
-
-error_resource:
- pipe_sampler_view_reference(&sv_idx, NULL);
- pipe_sampler_view_reference(&sv_tbl, NULL);
- mtx_unlock(&vlsurface->device->mutex);
- return VDP_STATUS_RESOURCES;
-}
-
-/**
- * Copy image data from application memory in a specific YCbCr format to
- * a VdpOutputSurface.
- */
-VdpStatus
-vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
- VdpYCbCrFormat source_ycbcr_format,
- void const *const *source_data,
- uint32_t const *source_pitches,
- VdpRect const *destination_rect,
- VdpCSCMatrix const *csc_matrix)
-{
- vlVdpOutputSurface *vlsurface;
- struct vl_compositor *compositor;
- struct vl_compositor_state *cstate;
-
- struct pipe_context *pipe;
- enum pipe_format format;
- struct pipe_video_buffer vtmpl, *vbuffer;
- struct u_rect dst_rect;
- struct pipe_sampler_view **sampler_views;
-
- unsigned i;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
-
- pipe = vlsurface->device->context;
- compositor = &vlsurface->device->compositor;
- cstate = &vlsurface->cstate;
-
- format = FormatYCBCRToPipe(source_ycbcr_format);
- if (format == PIPE_FORMAT_NONE)
- return VDP_STATUS_INVALID_Y_CB_CR_FORMAT;
-
- if (!source_data || !source_pitches)
- return VDP_STATUS_INVALID_POINTER;
-
- mtx_lock(&vlsurface->device->mutex);
- memset(&vtmpl, 0, sizeof(vtmpl));
- vtmpl.buffer_format = format;
-
- if (destination_rect) {
- vtmpl.width = abs(destination_rect->x0-destination_rect->x1);
- vtmpl.height = abs(destination_rect->y0-destination_rect->y1);
- } else {
- vtmpl.width = vlsurface->surface->texture->width0;
- vtmpl.height = vlsurface->surface->texture->height0;
- }
-
- vbuffer = pipe->create_video_buffer(pipe, &vtmpl);
- if (!vbuffer) {
- mtx_unlock(&vlsurface->device->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- sampler_views = vbuffer->get_sampler_view_planes(vbuffer);
- if (!sampler_views) {
- vbuffer->destroy(vbuffer);
- mtx_unlock(&vlsurface->device->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- for (i = 0; i < 3; ++i) {
- struct pipe_sampler_view *sv = sampler_views[i];
- if (!sv) continue;
-
- struct pipe_box dst_box = {
- 0, 0, 0,
- sv->texture->width0, sv->texture->height0, 1
- };
-
- pipe->texture_subdata(pipe, sv->texture, 0, PIPE_TRANSFER_WRITE, &dst_box,
- source_data[i], source_pitches[i], 0);
- }
-
- if (!csc_matrix) {
- vl_csc_matrix csc;
- vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, 1, &csc);
- if (!vl_compositor_set_csc_matrix(cstate, (const vl_csc_matrix*)&csc, 1.0f, 0.0f))
- goto err_csc_matrix;
- } else {
- if (!vl_compositor_set_csc_matrix(cstate, csc_matrix, 1.0f, 0.0f))
- goto err_csc_matrix;
- }
-
- vl_compositor_clear_layers(cstate);
- vl_compositor_set_buffer_layer(cstate, compositor, 0, vbuffer, NULL, NULL, VL_COMPOSITOR_WEAVE);
- vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
- vl_compositor_render(cstate, compositor, vlsurface->surface, &vlsurface->dirty_area, false);
-
- vbuffer->destroy(vbuffer);
- mtx_unlock(&vlsurface->device->mutex);
-
- return VDP_STATUS_OK;
-err_csc_matrix:
- vbuffer->destroy(vbuffer);
- mtx_unlock(&vlsurface->device->mutex);
- return VDP_STATUS_ERROR;
-}
-
-static unsigned
-BlendFactorToPipe(VdpOutputSurfaceRenderBlendFactor factor)
-{
- switch (factor) {
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ZERO:
- return PIPE_BLENDFACTOR_ZERO;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE:
- return PIPE_BLENDFACTOR_ONE;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_COLOR:
- return PIPE_BLENDFACTOR_SRC_COLOR;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_COLOR:
- return PIPE_BLENDFACTOR_INV_SRC_COLOR;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_ALPHA:
- return PIPE_BLENDFACTOR_SRC_ALPHA;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA:
- return PIPE_BLENDFACTOR_INV_SRC_ALPHA;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_DST_ALPHA:
- return PIPE_BLENDFACTOR_DST_ALPHA;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_DST_ALPHA:
- return PIPE_BLENDFACTOR_INV_DST_ALPHA;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_DST_COLOR:
- return PIPE_BLENDFACTOR_DST_COLOR;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_DST_COLOR:
- return PIPE_BLENDFACTOR_INV_DST_COLOR;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_ALPHA_SATURATE:
- return PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_CONSTANT_COLOR:
- return PIPE_BLENDFACTOR_CONST_COLOR;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR:
- return PIPE_BLENDFACTOR_INV_CONST_COLOR;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_CONSTANT_ALPHA:
- return PIPE_BLENDFACTOR_CONST_ALPHA;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA:
- return PIPE_BLENDFACTOR_INV_CONST_ALPHA;
- default:
- assert(0);
- return PIPE_BLENDFACTOR_ONE;
- }
-}
-
-static unsigned
-BlendEquationToPipe(VdpOutputSurfaceRenderBlendEquation equation)
-{
- switch (equation) {
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_SUBTRACT:
- return PIPE_BLEND_SUBTRACT;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_REVERSE_SUBTRACT:
- return PIPE_BLEND_REVERSE_SUBTRACT;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD:
- return PIPE_BLEND_ADD;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_MIN:
- return PIPE_BLEND_MIN;
- case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_MAX:
- return PIPE_BLEND_MAX;
- default:
- assert(0);
- return PIPE_BLEND_ADD;
- }
-}
-
-static void *
-BlenderToPipe(struct pipe_context *context,
- VdpOutputSurfaceRenderBlendState const *blend_state)
-{
- struct pipe_blend_state blend;
-
- memset(&blend, 0, sizeof blend);
- blend.independent_blend_enable = 0;
-
- if (blend_state) {
- blend.rt[0].blend_enable = 1;
- blend.rt[0].rgb_src_factor = BlendFactorToPipe(blend_state->blend_factor_source_color);
- blend.rt[0].rgb_dst_factor = BlendFactorToPipe(blend_state->blend_factor_destination_color);
- blend.rt[0].alpha_src_factor = BlendFactorToPipe(blend_state->blend_factor_source_alpha);
- blend.rt[0].alpha_dst_factor = BlendFactorToPipe(blend_state->blend_factor_destination_alpha);
- blend.rt[0].rgb_func = BlendEquationToPipe(blend_state->blend_equation_color);
- blend.rt[0].alpha_func = BlendEquationToPipe(blend_state->blend_equation_alpha);
- } else {
- blend.rt[0].blend_enable = 0;
- }
-
- blend.logicop_enable = 0;
- blend.logicop_func = PIPE_LOGICOP_CLEAR;
- blend.rt[0].colormask = PIPE_MASK_RGBA;
- blend.dither = 0;
-
- return context->create_blend_state(context, &blend);
-}
-
-static struct vertex4f *
-ColorsToPipe(VdpColor const *colors, uint32_t flags, struct vertex4f result[4])
-{
- unsigned i;
- struct vertex4f *dst = result;
-
- if (!colors)
- return NULL;
-
- for (i = 0; i < 4; ++i) {
- dst->x = colors->red;
- dst->y = colors->green;
- dst->z = colors->blue;
- dst->w = colors->alpha;
-
- ++dst;
- if (flags & VDP_OUTPUT_SURFACE_RENDER_COLOR_PER_VERTEX)
- ++colors;
- }
- return result;
-}
-
-/**
- * Composite a sub-rectangle of a VdpOutputSurface into a sub-rectangle of
- * another VdpOutputSurface; Output Surface object VdpOutputSurface.
- */
-VdpStatus
-vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
- VdpRect const *destination_rect,
- VdpOutputSurface source_surface,
- VdpRect const *source_rect,
- VdpColor const *colors,
- VdpOutputSurfaceRenderBlendState const *blend_state,
- uint32_t flags)
-{
- vlVdpOutputSurface *dst_vlsurface;
-
- struct pipe_context *context;
- struct pipe_sampler_view *src_sv;
- struct vl_compositor *compositor;
- struct vl_compositor_state *cstate;
-
- struct u_rect src_rect, dst_rect;
-
- struct vertex4f vlcolors[4];
- void *blend;
-
- dst_vlsurface = vlGetDataHTAB(destination_surface);
- if (!dst_vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (source_surface == VDP_INVALID_HANDLE) {
- src_sv = dst_vlsurface->device->dummy_sv;
-
- } else {
- vlVdpOutputSurface *src_vlsurface = vlGetDataHTAB(source_surface);
- if (!src_vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (dst_vlsurface->device != src_vlsurface->device)
- return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
-
- src_sv = src_vlsurface->sampler_view;
- }
-
- mtx_lock(&dst_vlsurface->device->mutex);
-
- context = dst_vlsurface->device->context;
- compositor = &dst_vlsurface->device->compositor;
- cstate = &dst_vlsurface->cstate;
-
- blend = BlenderToPipe(context, blend_state);
-
- vl_compositor_clear_layers(cstate);
- vl_compositor_set_layer_blend(cstate, 0, blend, false);
- vl_compositor_set_rgba_layer(cstate, compositor, 0, src_sv,
- RectToPipe(source_rect, &src_rect), NULL,
- ColorsToPipe(colors, flags, vlcolors));
- STATIC_ASSERT(VL_COMPOSITOR_ROTATE_0 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_0);
- STATIC_ASSERT(VL_COMPOSITOR_ROTATE_90 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_90);
- STATIC_ASSERT(VL_COMPOSITOR_ROTATE_180 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_180);
- STATIC_ASSERT(VL_COMPOSITOR_ROTATE_270 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_270);
- vl_compositor_set_layer_rotation(cstate, 0, flags & 3);
- vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
- vl_compositor_render(cstate, compositor, dst_vlsurface->surface, &dst_vlsurface->dirty_area, false);
-
- context->delete_blend_state(context, blend);
- mtx_unlock(&dst_vlsurface->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Composite a sub-rectangle of a VdpBitmapSurface into a sub-rectangle of
- * a VdpOutputSurface; Output Surface object VdpOutputSurface.
- */
-VdpStatus
-vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface,
- VdpRect const *destination_rect,
- VdpBitmapSurface source_surface,
- VdpRect const *source_rect,
- VdpColor const *colors,
- VdpOutputSurfaceRenderBlendState const *blend_state,
- uint32_t flags)
-{
- vlVdpOutputSurface *dst_vlsurface;
-
- struct pipe_context *context;
- struct pipe_sampler_view *src_sv;
- struct vl_compositor *compositor;
- struct vl_compositor_state *cstate;
-
- struct u_rect src_rect, dst_rect;
-
- struct vertex4f vlcolors[4];
- void *blend;
-
- dst_vlsurface = vlGetDataHTAB(destination_surface);
- if (!dst_vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (source_surface == VDP_INVALID_HANDLE) {
- src_sv = dst_vlsurface->device->dummy_sv;
-
- } else {
- vlVdpBitmapSurface *src_vlsurface = vlGetDataHTAB(source_surface);
- if (!src_vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (dst_vlsurface->device != src_vlsurface->device)
- return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
-
- src_sv = src_vlsurface->sampler_view;
- }
-
- context = dst_vlsurface->device->context;
- compositor = &dst_vlsurface->device->compositor;
- cstate = &dst_vlsurface->cstate;
-
- mtx_lock(&dst_vlsurface->device->mutex);
-
- blend = BlenderToPipe(context, blend_state);
-
- vl_compositor_clear_layers(cstate);
- vl_compositor_set_layer_blend(cstate, 0, blend, false);
- vl_compositor_set_rgba_layer(cstate, compositor, 0, src_sv,
- RectToPipe(source_rect, &src_rect), NULL,
- ColorsToPipe(colors, flags, vlcolors));
- vl_compositor_set_layer_rotation(cstate, 0, flags & 3);
- vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
- vl_compositor_render(cstate, compositor, dst_vlsurface->surface, &dst_vlsurface->dirty_area, false);
-
- context->delete_blend_state(context, blend);
- mtx_unlock(&dst_vlsurface->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-struct pipe_resource *vlVdpOutputSurfaceGallium(VdpOutputSurface surface)
-{
- vlVdpOutputSurface *vlsurface;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface || !vlsurface->surface)
- return NULL;
-
- mtx_lock(&vlsurface->device->mutex);
- vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
- mtx_unlock(&vlsurface->device->mutex);
-
- return vlsurface->surface->texture;
-}
-
-VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface,
- struct VdpSurfaceDMABufDesc *result)
-{
- vlVdpOutputSurface *vlsurface;
- struct pipe_screen *pscreen;
- struct winsys_handle whandle;
-
- memset(result, 0, sizeof(*result));
- result->handle = -1;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface || !vlsurface->surface)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&vlsurface->device->mutex);
- vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
-
- memset(&whandle, 0, sizeof(struct winsys_handle));
- whandle.type = WINSYS_HANDLE_TYPE_FD;
-
- pscreen = vlsurface->surface->texture->screen;
- if (!pscreen->resource_get_handle(pscreen, vlsurface->device->context,
- vlsurface->surface->texture, &whandle,
- PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)) {
- mtx_unlock(&vlsurface->device->mutex);
- return VDP_STATUS_NO_IMPLEMENTATION;
- }
-
- mtx_unlock(&vlsurface->device->mutex);
-
- result->handle = whandle.handle;
- result->width = vlsurface->surface->width;
- result->height = vlsurface->surface->height;
- result->offset = whandle.offset;
- result->stride = whandle.stride;
- result->format = PipeToFormatRGBA(vlsurface->surface->format);
-
- return VDP_STATUS_OK;
-}
diff --git a/src/gallium/state_trackers/vdpau/preemption.c b/src/gallium/state_trackers/vdpau/preemption.c
deleted file mode 100644
index 6d376acd339..00000000000
--- a/src/gallium/state_trackers/vdpau/preemption.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Thomas Balling Sørensen.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include <vdpau/vdpau.h>
-#include "vdpau_private.h"
-
-/**
- * A callback to notify the client application that a device's display has
- * been preempted.
- */
-void vlVdpPreemptionCallback(VdpDevice device, void *context)
-{
- /* TODO: Implement preemption */
-}
-
-/**
- * Configure the display preemption callback.
- */
-VdpStatus vlVdpPreemptionCallbackRegister(VdpDevice device,
- VdpPreemptionCallback callback,
- void *context)
-{
- return VDP_STATUS_OK;
-}
diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c
deleted file mode 100644
index 54f15ff34b1..00000000000
--- a/src/gallium/state_trackers/vdpau/presentation.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Thomas Balling Sørensen.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include <stdio.h>
-#include <vdpau/vdpau.h>
-
-#include "util/u_debug.h"
-#include "util/u_memory.h"
-
-#include "vdpau_private.h"
-
-/**
- * Create a VdpPresentationQueue.
- */
-VdpStatus
-vlVdpPresentationQueueCreate(VdpDevice device,
- VdpPresentationQueueTarget presentation_queue_target,
- VdpPresentationQueue *presentation_queue)
-{
- vlVdpPresentationQueue *pq = NULL;
- VdpStatus ret;
-
- if (!presentation_queue)
- return VDP_STATUS_INVALID_POINTER;
-
- vlVdpDevice *dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- vlVdpPresentationQueueTarget *pqt = vlGetDataHTAB(presentation_queue_target);
- if (!pqt)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (dev != pqt->device)
- return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
-
- pq = CALLOC(1, sizeof(vlVdpPresentationQueue));
- if (!pq)
- return VDP_STATUS_RESOURCES;
-
- DeviceReference(&pq->device, dev);
- pq->drawable = pqt->drawable;
-
- mtx_lock(&dev->mutex);
- if (!vl_compositor_init_state(&pq->cstate, dev->context)) {
- mtx_unlock(&dev->mutex);
- ret = VDP_STATUS_ERROR;
- goto no_compositor;
- }
- mtx_unlock(&dev->mutex);
-
- *presentation_queue = vlAddDataHTAB(pq);
- if (*presentation_queue == 0) {
- ret = VDP_STATUS_ERROR;
- goto no_handle;
- }
-
- return VDP_STATUS_OK;
-
-no_handle:
-no_compositor:
- DeviceReference(&pq->device, NULL);
- FREE(pq);
- return ret;
-}
-
-/**
- * Destroy a VdpPresentationQueue.
- */
-VdpStatus
-vlVdpPresentationQueueDestroy(VdpPresentationQueue presentation_queue)
-{
- vlVdpPresentationQueue *pq;
-
- pq = vlGetDataHTAB(presentation_queue);
- if (!pq)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&pq->device->mutex);
- vl_compositor_cleanup_state(&pq->cstate);
- mtx_unlock(&pq->device->mutex);
-
- vlRemoveDataHTAB(presentation_queue);
- DeviceReference(&pq->device, NULL);
- FREE(pq);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Configure the background color setting.
- */
-VdpStatus
-vlVdpPresentationQueueSetBackgroundColor(VdpPresentationQueue presentation_queue,
- VdpColor *const background_color)
-{
- vlVdpPresentationQueue *pq;
- union pipe_color_union color;
-
- if (!background_color)
- return VDP_STATUS_INVALID_POINTER;
-
- pq = vlGetDataHTAB(presentation_queue);
- if (!pq)
- return VDP_STATUS_INVALID_HANDLE;
-
- color.f[0] = background_color->red;
- color.f[1] = background_color->green;
- color.f[2] = background_color->blue;
- color.f[3] = background_color->alpha;
-
- mtx_lock(&pq->device->mutex);
- vl_compositor_set_clear_color(&pq->cstate, &color);
- mtx_unlock(&pq->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Retrieve the current background color setting.
- */
-VdpStatus
-vlVdpPresentationQueueGetBackgroundColor(VdpPresentationQueue presentation_queue,
- VdpColor *const background_color)
-{
- vlVdpPresentationQueue *pq;
- union pipe_color_union color;
-
- if (!background_color)
- return VDP_STATUS_INVALID_POINTER;
-
- pq = vlGetDataHTAB(presentation_queue);
- if (!pq)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&pq->device->mutex);
- vl_compositor_get_clear_color(&pq->cstate, &color);
- mtx_unlock(&pq->device->mutex);
-
- background_color->red = color.f[0];
- background_color->green = color.f[1];
- background_color->blue = color.f[2];
- background_color->alpha = color.f[3];
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Retrieve the presentation queue's "current" time.
- */
-VdpStatus
-vlVdpPresentationQueueGetTime(VdpPresentationQueue presentation_queue,
- VdpTime *current_time)
-{
- vlVdpPresentationQueue *pq;
-
- if (!current_time)
- return VDP_STATUS_INVALID_POINTER;
-
- pq = vlGetDataHTAB(presentation_queue);
- if (!pq)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&pq->device->mutex);
- *current_time = pq->device->vscreen->get_timestamp(pq->device->vscreen,
- (void *)pq->drawable);
- mtx_unlock(&pq->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Enter a surface into the presentation queue.
- */
-VdpStatus
-vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue,
- VdpOutputSurface surface,
- uint32_t clip_width,
- uint32_t clip_height,
- VdpTime earliest_presentation_time)
-{
- static int dump_window = -1;
-
- vlVdpPresentationQueue *pq;
- vlVdpOutputSurface *surf;
-
- struct pipe_context *pipe;
- struct pipe_resource *tex;
- struct pipe_surface surf_templ, *surf_draw = NULL;
- struct u_rect src_rect, dst_clip, *dirty_area;
-
- struct vl_compositor *compositor;
- struct vl_compositor_state *cstate;
- struct vl_screen *vscreen;
-
- pq = vlGetDataHTAB(presentation_queue);
- if (!pq)
- return VDP_STATUS_INVALID_HANDLE;
-
- surf = vlGetDataHTAB(surface);
- if (!surf)
- return VDP_STATUS_INVALID_HANDLE;
-
- pipe = pq->device->context;
- compositor = &pq->device->compositor;
- cstate = &pq->cstate;
- vscreen = pq->device->vscreen;
-
- mtx_lock(&pq->device->mutex);
- if (vscreen->set_back_texture_from_output && surf->send_to_X)
- vscreen->set_back_texture_from_output(vscreen, surf->surface->texture, clip_width, clip_height);
- tex = vscreen->texture_from_drawable(vscreen, (void *)pq->drawable);
- if (!tex) {
- mtx_unlock(&pq->device->mutex);
- return VDP_STATUS_INVALID_HANDLE;
- }
-
- if (!vscreen->set_back_texture_from_output || !surf->send_to_X) {
- dirty_area = vscreen->get_dirty_area(vscreen);
-
- memset(&surf_templ, 0, sizeof(surf_templ));
- surf_templ.format = tex->format;
- surf_draw = pipe->create_surface(pipe, tex, &surf_templ);
-
- dst_clip.x0 = 0;
- dst_clip.y0 = 0;
- dst_clip.x1 = clip_width ? clip_width : surf_draw->width;
- dst_clip.y1 = clip_height ? clip_height : surf_draw->height;
-
- src_rect.x0 = 0;
- src_rect.y0 = 0;
- src_rect.x1 = surf_draw->width;
- src_rect.y1 = surf_draw->height;
-
- vl_compositor_clear_layers(cstate);
- vl_compositor_set_rgba_layer(cstate, compositor, 0, surf->sampler_view, &src_rect, NULL, NULL);
- vl_compositor_set_dst_clip(cstate, &dst_clip);
- vl_compositor_render(cstate, compositor, surf_draw, dirty_area, true);
- }
-
- vscreen->set_next_timestamp(vscreen, earliest_presentation_time);
-
- // flush before calling flush_frontbuffer so that rendering is flushed
- // to back buffer so the texture can be copied in flush_frontbuffer
- pipe->screen->fence_reference(pipe->screen, &surf->fence, NULL);
- pipe->flush(pipe, &surf->fence, 0);
- pipe->screen->flush_frontbuffer(pipe->screen, tex, 0, 0,
- vscreen->get_private(vscreen), NULL);
-
- pq->last_surf = surf;
-
- if (dump_window == -1) {
- dump_window = debug_get_num_option("VDPAU_DUMP", 0);
- }
-
- if (dump_window) {
- static unsigned int framenum = 0;
- char cmd[256];
-
- if (framenum) {
- sprintf(cmd, "xwd -id %d -silent -out vdpau_frame_%08d.xwd", (int)pq->drawable, framenum);
- if (system(cmd) != 0)
- VDPAU_MSG(VDPAU_ERR, "[VDPAU] Dumping surface %d failed.\n", surface);
- }
- framenum++;
- }
-
- if (!vscreen->set_back_texture_from_output || !surf->send_to_X) {
- pipe_resource_reference(&tex, NULL);
- pipe_surface_reference(&surf_draw, NULL);
- }
- mtx_unlock(&pq->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Wait for a surface to finish being displayed.
- */
-VdpStatus
-vlVdpPresentationQueueBlockUntilSurfaceIdle(VdpPresentationQueue presentation_queue,
- VdpOutputSurface surface,
- VdpTime *first_presentation_time)
-{
- vlVdpPresentationQueue *pq;
- vlVdpOutputSurface *surf;
- struct pipe_screen *screen;
-
- if (!first_presentation_time)
- return VDP_STATUS_INVALID_POINTER;
-
- pq = vlGetDataHTAB(presentation_queue);
- if (!pq)
- return VDP_STATUS_INVALID_HANDLE;
-
- surf = vlGetDataHTAB(surface);
- if (!surf)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&pq->device->mutex);
- if (surf->fence) {
- screen = pq->device->vscreen->pscreen;
- screen->fence_finish(screen, NULL, surf->fence, PIPE_TIMEOUT_INFINITE);
- screen->fence_reference(screen, &surf->fence, NULL);
- }
- mtx_unlock(&pq->device->mutex);
-
- return vlVdpPresentationQueueGetTime(presentation_queue, first_presentation_time);
-}
-
-/**
- * Poll the current queue status of a surface.
- */
-VdpStatus
-vlVdpPresentationQueueQuerySurfaceStatus(VdpPresentationQueue presentation_queue,
- VdpOutputSurface surface,
- VdpPresentationQueueStatus *status,
- VdpTime *first_presentation_time)
-{
- vlVdpPresentationQueue *pq;
- vlVdpOutputSurface *surf;
- struct pipe_screen *screen;
-
- if (!(status && first_presentation_time))
- return VDP_STATUS_INVALID_POINTER;
-
- pq = vlGetDataHTAB(presentation_queue);
- if (!pq)
- return VDP_STATUS_INVALID_HANDLE;
-
- surf = vlGetDataHTAB(surface);
- if (!surf)
- return VDP_STATUS_INVALID_HANDLE;
-
- *first_presentation_time = 0;
-
- if (!surf->fence) {
- if (pq->last_surf == surf)
- *status = VDP_PRESENTATION_QUEUE_STATUS_VISIBLE;
- else
- *status = VDP_PRESENTATION_QUEUE_STATUS_IDLE;
- } else {
- mtx_lock(&pq->device->mutex);
- screen = pq->device->vscreen->pscreen;
- if (screen->fence_finish(screen, NULL, surf->fence, 0)) {
- screen->fence_reference(screen, &surf->fence, NULL);
- *status = VDP_PRESENTATION_QUEUE_STATUS_VISIBLE;
- mtx_unlock(&pq->device->mutex);
-
- // We actually need to query the timestamp of the last VSYNC event from the hardware
- vlVdpPresentationQueueGetTime(presentation_queue, first_presentation_time);
- *first_presentation_time += 1;
- } else {
- *status = VDP_PRESENTATION_QUEUE_STATUS_QUEUED;
- mtx_unlock(&pq->device->mutex);
- }
- }
-
- return VDP_STATUS_OK;
-}
diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c
deleted file mode 100644
index 701d9f220c4..00000000000
--- a/src/gallium/state_trackers/vdpau/query.c
+++ /dev/null
@@ -1,622 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Younes Manton.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <math.h>
-
-#include "vdpau_private.h"
-#include "pipe/p_screen.h"
-#include "pipe/p_defines.h"
-#include "util/u_debug.h"
-
-/**
- * Retrieve the VDPAU version implemented by the backend.
- */
-VdpStatus
-vlVdpGetApiVersion(uint32_t *api_version)
-{
- if (!api_version)
- return VDP_STATUS_INVALID_POINTER;
-
- *api_version = 1;
- return VDP_STATUS_OK;
-}
-
-/**
- * Retrieve an implementation-specific string description of the implementation.
- * This typically includes detailed version information.
- */
-VdpStatus
-vlVdpGetInformationString(char const **information_string)
-{
- if (!information_string)
- return VDP_STATUS_INVALID_POINTER;
-
- *information_string = INFORMATION_STRING;
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's VdpVideoSurface capabilities.
- */
-VdpStatus
-vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
- VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
-{
- vlVdpDevice *dev;
- struct pipe_screen *pscreen;
- uint32_t max_2d_texture_size;
-
- if (!(is_supported && max_width && max_height))
- return VDP_STATUS_INVALID_POINTER;
-
- dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pscreen = dev->vscreen->pscreen;
- if (!pscreen)
- return VDP_STATUS_RESOURCES;
-
- mtx_lock(&dev->mutex);
-
- /* XXX: Current limits */
- *is_supported = true;
- max_2d_texture_size = pscreen->get_param(pscreen, PIPE_CAP_MAX_TEXTURE_2D_SIZE);
- mtx_unlock(&dev->mutex);
- if (!max_2d_texture_size)
- return VDP_STATUS_RESOURCES;
-
- *max_width = *max_height = max_2d_texture_size;
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's VdpVideoSurface GetBits/PutBits capabilities.
- */
-VdpStatus
-vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
- VdpYCbCrFormat bits_ycbcr_format,
- VdpBool *is_supported)
-{
- vlVdpDevice *dev;
- struct pipe_screen *pscreen;
-
- if (!is_supported)
- return VDP_STATUS_INVALID_POINTER;
-
- dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pscreen = dev->vscreen->pscreen;
- if (!pscreen)
- return VDP_STATUS_RESOURCES;
-
- mtx_lock(&dev->mutex);
-
- switch(bits_ycbcr_format) {
- case VDP_YCBCR_FORMAT_NV12:
- *is_supported = surface_chroma_type == VDP_CHROMA_TYPE_420;
- break;
-
- case VDP_YCBCR_FORMAT_YV12:
- *is_supported = surface_chroma_type == VDP_CHROMA_TYPE_420;
-
- /* We can convert YV12 to NV12 on the fly! */
- if (*is_supported &&
- pscreen->is_video_format_supported(pscreen,
- PIPE_FORMAT_NV12,
- PIPE_VIDEO_PROFILE_UNKNOWN,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) {
- mtx_unlock(&dev->mutex);
- return VDP_STATUS_OK;
- }
- break;
-
- case VDP_YCBCR_FORMAT_UYVY:
- case VDP_YCBCR_FORMAT_YUYV:
- *is_supported = surface_chroma_type == VDP_CHROMA_TYPE_422;
- break;
-
- case VDP_YCBCR_FORMAT_Y8U8V8A8:
- case VDP_YCBCR_FORMAT_V8U8Y8A8:
- *is_supported = surface_chroma_type == VDP_CHROMA_TYPE_444;
- break;
-
- default:
- *is_supported = false;
- break;
- }
-
- if (*is_supported &&
- !pscreen->is_video_format_supported(pscreen,
- FormatYCBCRToPipe(bits_ycbcr_format),
- PIPE_VIDEO_PROFILE_UNKNOWN,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) {
- *is_supported = false;
- }
- mtx_unlock(&dev->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's VdpDecoder capabilities.
- */
-VdpStatus
-vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile,
- VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks,
- uint32_t *max_width, uint32_t *max_height)
-{
- vlVdpDevice *dev;
- struct pipe_screen *pscreen;
- enum pipe_video_profile p_profile;
-
- if (!(is_supported && max_level && max_macroblocks && max_width && max_height))
- return VDP_STATUS_INVALID_POINTER;
-
- dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pscreen = dev->vscreen->pscreen;
- if (!pscreen)
- return VDP_STATUS_RESOURCES;
-
- p_profile = ProfileToPipe(profile);
- if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) {
- *is_supported = false;
- return VDP_STATUS_OK;
- }
-
- mtx_lock(&dev->mutex);
- *is_supported = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_SUPPORTED);
- if (*is_supported) {
- *max_width = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_MAX_WIDTH);
- *max_height = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_MAX_HEIGHT);
- *max_level = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_MAX_LEVEL);
- *max_macroblocks = (*max_width/16)*(*max_height/16);
- } else {
- *max_width = 0;
- *max_height = 0;
- *max_level = 0;
- *max_macroblocks = 0;
- }
- mtx_unlock(&dev->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's VdpOutputSurface capabilities.
- */
-VdpStatus
-vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
- VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
-{
- vlVdpDevice *dev;
- struct pipe_screen *pscreen;
- enum pipe_format format;
-
- dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pscreen = dev->vscreen->pscreen;
- if (!pscreen)
- return VDP_STATUS_RESOURCES;
-
- format = VdpFormatRGBAToPipe(surface_rgba_format);
- if (format == PIPE_FORMAT_NONE || format == PIPE_FORMAT_A8_UNORM)
- return VDP_STATUS_INVALID_RGBA_FORMAT;
-
- if (!(is_supported && max_width && max_height))
- return VDP_STATUS_INVALID_POINTER;
-
- mtx_lock(&dev->mutex);
- *is_supported = pscreen->is_format_supported
- (
- pscreen, format, PIPE_TEXTURE_2D, 1, 1,
- PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET
- );
- if (*is_supported) {
- uint32_t max_2d_texture_size = pscreen->get_param(
- pscreen, PIPE_CAP_MAX_TEXTURE_2D_SIZE);
-
- if (!max_2d_texture_size) {
- mtx_unlock(&dev->mutex);
- return VDP_STATUS_ERROR;
- }
-
- *max_width = *max_height = max_2d_texture_size;
- } else {
- *max_width = 0;
- *max_height = 0;
- }
- mtx_unlock(&dev->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's capability to perform a PutBits operation using
- * application data matching the surface's format.
- */
-VdpStatus
-vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
- VdpBool *is_supported)
-{
- vlVdpDevice *dev;
- struct pipe_screen *pscreen;
- enum pipe_format format;
-
- dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pscreen = dev->vscreen->pscreen;
- if (!pscreen)
- return VDP_STATUS_ERROR;
-
- format = VdpFormatRGBAToPipe(surface_rgba_format);
- if (format == PIPE_FORMAT_NONE || format == PIPE_FORMAT_A8_UNORM)
- return VDP_STATUS_INVALID_RGBA_FORMAT;
-
- if (!is_supported)
- return VDP_STATUS_INVALID_POINTER;
-
- mtx_lock(&dev->mutex);
- *is_supported = pscreen->is_format_supported
- (
- pscreen, format, PIPE_TEXTURE_2D, 1, 1,
- PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET
- );
- mtx_unlock(&dev->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's capability to perform a PutBits operation using
- * application data in a specific indexed format.
- */
-VdpStatus
-vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device,
- VdpRGBAFormat surface_rgba_format,
- VdpIndexedFormat bits_indexed_format,
- VdpColorTableFormat color_table_format,
- VdpBool *is_supported)
-{
- vlVdpDevice *dev;
- struct pipe_screen *pscreen;
- enum pipe_format rgba_format, index_format, colortbl_format;
-
- dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pscreen = dev->vscreen->pscreen;
- if (!pscreen)
- return VDP_STATUS_ERROR;
-
- rgba_format = VdpFormatRGBAToPipe(surface_rgba_format);
- if (rgba_format == PIPE_FORMAT_NONE || rgba_format == PIPE_FORMAT_A8_UNORM)
- return VDP_STATUS_INVALID_RGBA_FORMAT;
-
- index_format = FormatIndexedToPipe(bits_indexed_format);
- if (index_format == PIPE_FORMAT_NONE)
- return VDP_STATUS_INVALID_INDEXED_FORMAT;
-
- colortbl_format = FormatColorTableToPipe(color_table_format);
- if (colortbl_format == PIPE_FORMAT_NONE)
- return VDP_STATUS_INVALID_COLOR_TABLE_FORMAT;
-
- if (!is_supported)
- return VDP_STATUS_INVALID_POINTER;
-
- mtx_lock(&dev->mutex);
- *is_supported = pscreen->is_format_supported
- (
- pscreen, rgba_format, PIPE_TEXTURE_2D, 1, 1,
- PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET
- );
-
- *is_supported &= pscreen->is_format_supported
- (
- pscreen, index_format, PIPE_TEXTURE_2D, 1, 1,
- PIPE_BIND_SAMPLER_VIEW
- );
-
- *is_supported &= pscreen->is_format_supported
- (
- pscreen, colortbl_format, PIPE_TEXTURE_1D, 1, 1,
- PIPE_BIND_SAMPLER_VIEW
- );
- mtx_unlock(&dev->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's capability to perform a PutBits operation using
- * application data in a specific YCbCr/YUB format.
- */
-VdpStatus
-vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
- VdpYCbCrFormat bits_ycbcr_format,
- VdpBool *is_supported)
-{
- vlVdpDevice *dev;
- struct pipe_screen *pscreen;
- enum pipe_format rgba_format, ycbcr_format;
-
- dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pscreen = dev->vscreen->pscreen;
- if (!pscreen)
- return VDP_STATUS_ERROR;
-
- rgba_format = VdpFormatRGBAToPipe(surface_rgba_format);
- if (rgba_format == PIPE_FORMAT_NONE || rgba_format == PIPE_FORMAT_A8_UNORM)
- return VDP_STATUS_INVALID_RGBA_FORMAT;
-
- ycbcr_format = FormatYCBCRToPipe(bits_ycbcr_format);
- if (ycbcr_format == PIPE_FORMAT_NONE)
- return VDP_STATUS_INVALID_INDEXED_FORMAT;
-
- if (!is_supported)
- return VDP_STATUS_INVALID_POINTER;
-
- mtx_lock(&dev->mutex);
- *is_supported = pscreen->is_format_supported
- (
- pscreen, rgba_format, PIPE_TEXTURE_2D, 1, 1,
- PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET
- );
-
- *is_supported &= pscreen->is_video_format_supported
- (
- pscreen, ycbcr_format,
- PIPE_VIDEO_PROFILE_UNKNOWN,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM
- );
- mtx_unlock(&dev->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's VdpBitmapSurface capabilities.
- */
-VdpStatus
-vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
- VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
-{
- vlVdpDevice *dev;
- struct pipe_screen *pscreen;
- enum pipe_format format;
-
- dev = vlGetDataHTAB(device);
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
-
- pscreen = dev->vscreen->pscreen;
- if (!pscreen)
- return VDP_STATUS_RESOURCES;
-
- format = VdpFormatRGBAToPipe(surface_rgba_format);
- if (format == PIPE_FORMAT_NONE)
- return VDP_STATUS_INVALID_RGBA_FORMAT;
-
- if (!(is_supported && max_width && max_height))
- return VDP_STATUS_INVALID_POINTER;
-
- mtx_lock(&dev->mutex);
- *is_supported = pscreen->is_format_supported
- (
- pscreen, format, PIPE_TEXTURE_2D, 1, 1,
- PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET
- );
- if (*is_supported) {
- uint32_t max_2d_texture_size = pscreen->get_param(
- pscreen, PIPE_CAP_MAX_TEXTURE_2D_SIZE);
-
- if (!max_2d_texture_size) {
- mtx_unlock(&dev->mutex);
- return VDP_STATUS_ERROR;
- }
-
- *max_width = *max_height = max_2d_texture_size;
- } else {
- *max_width = 0;
- *max_height = 0;
- }
- mtx_unlock(&dev->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's support for a specific feature.
- */
-VdpStatus
-vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature,
- VdpBool *is_supported)
-{
- if (!is_supported)
- return VDP_STATUS_INVALID_POINTER;
-
- switch (feature) {
- case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
- case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
- case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
- case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
- case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
- *is_supported = VDP_TRUE;
- break;
- default:
- *is_supported = VDP_FALSE;
- break;
- }
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's support for a specific parameter.
- */
-VdpStatus
-vlVdpVideoMixerQueryParameterSupport(VdpDevice device, VdpVideoMixerParameter parameter,
- VdpBool *is_supported)
-{
- if (!is_supported)
- return VDP_STATUS_INVALID_POINTER;
-
- switch (parameter) {
- case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH:
- case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT:
- case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE:
- case VDP_VIDEO_MIXER_PARAMETER_LAYERS:
- *is_supported = VDP_TRUE;
- break;
- default:
- *is_supported = VDP_FALSE;
- break;
- }
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's supported for a specific parameter.
- */
-VdpStatus
-vlVdpVideoMixerQueryParameterValueRange(VdpDevice device, VdpVideoMixerParameter parameter,
- void *min_value, void *max_value)
-{
- vlVdpDevice *dev = vlGetDataHTAB(device);
- struct pipe_screen *screen;
-
- if (!dev)
- return VDP_STATUS_INVALID_HANDLE;
- if (!(min_value && max_value))
- return VDP_STATUS_INVALID_POINTER;
-
- mtx_lock(&dev->mutex);
- screen = dev->vscreen->pscreen;
- switch (parameter) {
- case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH:
- *(uint32_t*)min_value = 48;
- *(uint32_t*)max_value = screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_MAX_WIDTH);
- break;
- case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT:
- *(uint32_t*)min_value = 48;
- *(uint32_t*)max_value = screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_MAX_HEIGHT);
- break;
-
- case VDP_VIDEO_MIXER_PARAMETER_LAYERS:
- *(uint32_t*)min_value = 0;
- *(uint32_t*)max_value = 4;
- break;
-
- case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE:
- default:
- mtx_unlock(&dev->mutex);
- return VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER;
- }
- mtx_unlock(&dev->mutex);
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's support for a specific attribute.
- */
-VdpStatus
-vlVdpVideoMixerQueryAttributeSupport(VdpDevice device, VdpVideoMixerAttribute attribute,
- VdpBool *is_supported)
-{
- if (!is_supported)
- return VDP_STATUS_INVALID_POINTER;
-
- switch (attribute) {
- case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
- case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX:
- case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
- case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL:
- case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA:
- case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA:
- case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE:
- *is_supported = VDP_TRUE;
- break;
- default:
- *is_supported = VDP_FALSE;
- }
- return VDP_STATUS_OK;
-}
-
-/**
- * Query the implementation's supported for a specific attribute.
- */
-VdpStatus
-vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device, VdpVideoMixerAttribute attribute,
- void *min_value, void *max_value)
-{
- if (!(min_value && max_value))
- return VDP_STATUS_INVALID_POINTER;
-
- switch (attribute) {
- case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
- case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA:
- case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA:
- *(float*)min_value = 0.0f;
- *(float*)max_value = 1.0f;
- break;
- case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL:
- *(float*)min_value = -1.0f;
- *(float*)max_value = 1.0f;
- break;
- case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE:
- *(uint8_t*)min_value = 0;
- *(uint8_t*)max_value = 1;
- break;
- case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
- case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX:
- default:
- return VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE;
- }
- return VDP_STATUS_OK;
-}
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
deleted file mode 100644
index 4158e6bcfe6..00000000000
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Thomas Balling Sørensen.
- * Copyright 2011 Christian König.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#include <assert.h>
-
-#include "pipe/p_state.h"
-
-#include "util/u_memory.h"
-#include "util/u_debug.h"
-#include "util/u_rect.h"
-#include "util/u_surface.h"
-#include "util/u_video.h"
-#include "vl/vl_defines.h"
-
-#include "state_tracker/drm_driver.h"
-
-#include "vdpau_private.h"
-
-enum getbits_conversion {
- CONVERSION_NONE,
- CONVERSION_NV12_TO_YV12,
- CONVERSION_YV12_TO_NV12,
- CONVERSION_SWAP_YUYV_UYVY,
-};
-
-/**
- * Create a VdpVideoSurface.
- */
-VdpStatus
-vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type,
- uint32_t width, uint32_t height,
- VdpVideoSurface *surface)
-{
- struct pipe_context *pipe;
- vlVdpSurface *p_surf;
- VdpStatus ret;
-
- if (!(width && height)) {
- ret = VDP_STATUS_INVALID_SIZE;
- goto inv_size;
- }
-
- p_surf = CALLOC(1, sizeof(vlVdpSurface));
- if (!p_surf) {
- ret = VDP_STATUS_RESOURCES;
- goto no_res;
- }
-
- vlVdpDevice *dev = vlGetDataHTAB(device);
- if (!dev) {
- ret = VDP_STATUS_INVALID_HANDLE;
- goto inv_device;
- }
-
- DeviceReference(&p_surf->device, dev);
- pipe = dev->context;
-
- mtx_lock(&dev->mutex);
- memset(&p_surf->templat, 0, sizeof(p_surf->templat));
- /* TODO: buffer_format should be selected to match chroma_type */
- p_surf->templat.buffer_format = pipe->screen->get_video_param
- (
- pipe->screen,
- PIPE_VIDEO_PROFILE_UNKNOWN,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_PREFERED_FORMAT
- );
- p_surf->templat.width = width;
- p_surf->templat.height = height;
- p_surf->templat.interlaced = pipe->screen->get_video_param
- (
- pipe->screen,
- PIPE_VIDEO_PROFILE_UNKNOWN,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_PREFERS_INTERLACED
- );
- if (p_surf->templat.buffer_format != PIPE_FORMAT_NONE)
- p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
-
- /* do not mandate early allocation of a video buffer */
- vlVdpVideoSurfaceClear(p_surf);
- mtx_unlock(&dev->mutex);
-
- *surface = vlAddDataHTAB(p_surf);
- if (*surface == 0) {
- ret = VDP_STATUS_ERROR;
- goto no_handle;
- }
-
- return VDP_STATUS_OK;
-
-no_handle:
- p_surf->video_buffer->destroy(p_surf->video_buffer);
-
-inv_device:
- DeviceReference(&p_surf->device, NULL);
- FREE(p_surf);
-
-no_res:
-inv_size:
- return ret;
-}
-
-/**
- * Destroy a VdpVideoSurface.
- */
-VdpStatus
-vlVdpVideoSurfaceDestroy(VdpVideoSurface surface)
-{
- vlVdpSurface *p_surf;
-
- p_surf = (vlVdpSurface *)vlGetDataHTAB((vlHandle)surface);
- if (!p_surf)
- return VDP_STATUS_INVALID_HANDLE;
-
- mtx_lock(&p_surf->device->mutex);
- if (p_surf->video_buffer)
- p_surf->video_buffer->destroy(p_surf->video_buffer);
- mtx_unlock(&p_surf->device->mutex);
-
- vlRemoveDataHTAB(surface);
- DeviceReference(&p_surf->device, NULL);
- FREE(p_surf);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Retrieve the parameters used to create a VdpVideoSurface.
- */
-VdpStatus
-vlVdpVideoSurfaceGetParameters(VdpVideoSurface surface,
- VdpChromaType *chroma_type,
- uint32_t *width, uint32_t *height)
-{
- if (!(width && height && chroma_type))
- return VDP_STATUS_INVALID_POINTER;
-
- vlVdpSurface *p_surf = vlGetDataHTAB(surface);
- if (!p_surf)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (p_surf->video_buffer) {
- *width = p_surf->video_buffer->width;
- *height = p_surf->video_buffer->height;
- *chroma_type = PipeToChroma(pipe_format_to_chroma_format(p_surf->video_buffer->buffer_format));
- } else {
- *width = p_surf->templat.width;
- *height = p_surf->templat.height;
- *chroma_type = PipeToChroma(pipe_format_to_chroma_format(p_surf->templat.buffer_format));
- }
-
- return VDP_STATUS_OK;
-}
-
-static void
-vlVdpVideoSurfaceSize(vlVdpSurface *p_surf, int component,
- unsigned *width, unsigned *height)
-{
- *width = p_surf->templat.width;
- *height = p_surf->templat.height;
-
- vl_video_buffer_adjust_size(width, height, component,
- pipe_format_to_chroma_format(p_surf->templat.buffer_format),
- p_surf->templat.interlaced);
-}
-
-/**
- * Copy image data from a VdpVideoSurface to application memory in a specified
- * YCbCr format.
- */
-VdpStatus
-vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
- VdpYCbCrFormat destination_ycbcr_format,
- void *const *destination_data,
- uint32_t const *destination_pitches)
-{
- vlVdpSurface *vlsurface;
- struct pipe_context *pipe;
- enum pipe_format format, buffer_format;
- struct pipe_sampler_view **sampler_views;
- enum getbits_conversion conversion = CONVERSION_NONE;
- unsigned i, j;
-
- vlsurface = vlGetDataHTAB(surface);
- if (!vlsurface)
- return VDP_STATUS_INVALID_HANDLE;
-
- pipe = vlsurface->device->context;
- if (!pipe)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (!destination_data || !destination_pitches)
- return VDP_STATUS_INVALID_POINTER;
-
- format = FormatYCBCRToPipe(destination_ycbcr_format);
- if (format == PIPE_FORMAT_NONE)
- return VDP_STATUS_INVALID_Y_CB_CR_FORMAT;
-
- if (vlsurface->video_buffer == NULL)
- return VDP_STATUS_INVALID_VALUE;
-
- buffer_format = vlsurface->video_buffer->buffer_format;
- if (format != buffer_format) {
- if (format == PIPE_FORMAT_YV12 && buffer_format == PIPE_FORMAT_NV12)
- conversion = CONVERSION_NV12_TO_YV12;
- else if (format == PIPE_FORMAT_NV12 && buffer_format == PIPE_FORMAT_YV12)
- conversion = CONVERSION_YV12_TO_NV12;
- else if ((format == PIPE_FORMAT_YUYV && buffer_format == PIPE_FORMAT_UYVY) ||
- (format == PIPE_FORMAT_UYVY && buffer_format == PIPE_FORMAT_YUYV))
- conversion = CONVERSION_SWAP_YUYV_UYVY;
- else
- return VDP_STATUS_NO_IMPLEMENTATION;
- }
-
- mtx_lock(&vlsurface->device->mutex);
- sampler_views = vlsurface->video_buffer->get_sampler_view_planes(vlsurface->video_buffer);
- if (!sampler_views) {
- mtx_unlock(&vlsurface->device->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- for (i = 0; i < 3; ++i) {
- unsigned width, height;
- struct pipe_sampler_view *sv = sampler_views[i];
- if (!sv) continue;
-
- vlVdpVideoSurfaceSize(vlsurface, i, &width, &height);
-
- for (j = 0; j < sv->texture->array_size; ++j) {
- struct pipe_box box = {
- 0, 0, j,
- width, height, 1
- };
- struct pipe_transfer *transfer;
- uint8_t *map;
-
- map = pipe->transfer_map(pipe, sv->texture, 0,
- PIPE_TRANSFER_READ, &box, &transfer);
- if (!map) {
- mtx_unlock(&vlsurface->device->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- if (conversion == CONVERSION_NV12_TO_YV12 && i == 1) {
- u_copy_nv12_to_yv12(destination_data, destination_pitches,
- i, j, transfer->stride, sv->texture->array_size,
- map, box.width, box.height);
- } else if (conversion == CONVERSION_YV12_TO_NV12 && i > 0) {
- u_copy_yv12_to_nv12(destination_data, destination_pitches,
- i, j, transfer->stride, sv->texture->array_size,
- map, box.width, box.height);
- } else if (conversion == CONVERSION_SWAP_YUYV_UYVY) {
- u_copy_swap422_packed(destination_data, destination_pitches,
- i, j, transfer->stride, sv->texture->array_size,
- map, box.width, box.height);
- } else {
- util_copy_rect(destination_data[i] + destination_pitches[i] * j, sv->texture->format,
- destination_pitches[i] * sv->texture->array_size, 0, 0,
- box.width, box.height, map, transfer->stride, 0, 0);
- }
-
- pipe_transfer_unmap(pipe, transfer);
- }
- }
- mtx_unlock(&vlsurface->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Copy image data from application memory in a specific YCbCr format to
- * a VdpVideoSurface.
- */
-VdpStatus
-vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
- VdpYCbCrFormat source_ycbcr_format,
- void const *const *source_data,
- uint32_t const *source_pitches)
-{
- enum pipe_format pformat = FormatYCBCRToPipe(source_ycbcr_format);
- enum getbits_conversion conversion = CONVERSION_NONE;
- struct pipe_context *pipe;
- struct pipe_sampler_view **sampler_views;
- unsigned i, j;
- unsigned usage = PIPE_TRANSFER_WRITE;
-
- vlVdpSurface *p_surf = vlGetDataHTAB(surface);
- if (!p_surf)
- return VDP_STATUS_INVALID_HANDLE;
-
- pipe = p_surf->device->context;
- if (!pipe)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (!source_data || !source_pitches)
- return VDP_STATUS_INVALID_POINTER;
-
- mtx_lock(&p_surf->device->mutex);
-
- if (p_surf->video_buffer == NULL ||
- ((pformat != p_surf->video_buffer->buffer_format))) {
- enum pipe_format nformat = pformat;
- struct pipe_screen *screen = pipe->screen;
-
- /* Determine the most suitable format for the new surface */
- if (!screen->is_video_format_supported(screen, nformat,
- PIPE_VIDEO_PROFILE_UNKNOWN,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) {
- nformat = screen->get_video_param(screen,
- PIPE_VIDEO_PROFILE_UNKNOWN,
- PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
- PIPE_VIDEO_CAP_PREFERED_FORMAT);
- if (nformat == PIPE_FORMAT_NONE) {
- mtx_unlock(&p_surf->device->mutex);
- return VDP_STATUS_NO_IMPLEMENTATION;
- }
- }
-
- if (p_surf->video_buffer == NULL ||
- nformat != p_surf->video_buffer->buffer_format) {
- /* destroy the old one */
- if (p_surf->video_buffer)
- p_surf->video_buffer->destroy(p_surf->video_buffer);
-
- /* adjust the template parameters */
- p_surf->templat.buffer_format = nformat;
- if (nformat == PIPE_FORMAT_YUYV || nformat == PIPE_FORMAT_UYVY)
- p_surf->templat.interlaced = false;
-
- /* and try to create the video buffer with the new format */
- p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
-
- /* stil no luck? ok forget it we don't support it */
- if (!p_surf->video_buffer) {
- mtx_unlock(&p_surf->device->mutex);
- return VDP_STATUS_NO_IMPLEMENTATION;
- }
- vlVdpVideoSurfaceClear(p_surf);
- }
- }
-
- if (pformat != p_surf->video_buffer->buffer_format) {
- if (pformat == PIPE_FORMAT_YV12 &&
- p_surf->video_buffer->buffer_format == PIPE_FORMAT_NV12)
- conversion = CONVERSION_YV12_TO_NV12;
- else {
- mtx_unlock(&p_surf->device->mutex);
- return VDP_STATUS_NO_IMPLEMENTATION;
- }
- }
-
- sampler_views = p_surf->video_buffer->get_sampler_view_planes(p_surf->video_buffer);
- if (!sampler_views) {
- mtx_unlock(&p_surf->device->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- for (i = 0; i < 3; ++i) {
- unsigned width, height;
- struct pipe_sampler_view *sv = sampler_views[i];
- struct pipe_resource *tex;
- if (!sv || !source_pitches[i]) continue;
-
- tex = sv->texture;
- vlVdpVideoSurfaceSize(p_surf, i, &width, &height);
-
- for (j = 0; j < tex->array_size; ++j) {
- struct pipe_box dst_box = {
- 0, 0, j,
- width, height, 1
- };
-
- if (conversion == CONVERSION_YV12_TO_NV12 && i == 1) {
- struct pipe_transfer *transfer;
- uint8_t *map;
-
- map = pipe->transfer_map(pipe, tex, 0, usage,
- &dst_box, &transfer);
- if (!map) {
- mtx_unlock(&p_surf->device->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- u_copy_nv12_from_yv12(source_data, source_pitches,
- i, j, transfer->stride, tex->array_size,
- map, dst_box.width, dst_box.height);
-
- pipe_transfer_unmap(pipe, transfer);
- } else {
- pipe->texture_subdata(pipe, tex, 0,
- PIPE_TRANSFER_WRITE, &dst_box,
- source_data[i] + source_pitches[i] * j,
- source_pitches[i] * tex->array_size,
- 0);
- }
- /*
- * This surface has already been synced
- * by the first map.
- */
- usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
- }
- }
- mtx_unlock(&p_surf->device->mutex);
-
- return VDP_STATUS_OK;
-}
-
-/**
- * Helper function to initially clear the VideoSurface after (re-)creation
- */
-void
-vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf)
-{
- struct pipe_context *pipe = vlsurf->device->context;
- struct pipe_surface **surfaces;
- unsigned i;
-
- if (!vlsurf->video_buffer)
- return;
-
- surfaces = vlsurf->video_buffer->get_surfaces(vlsurf->video_buffer);
- for (i = 0; i < VL_MAX_SURFACES; ++i) {
- union pipe_color_union c = {};
-
- if (!surfaces[i])
- continue;
-
- if (i > !!vlsurf->templat.interlaced)
- c.f[0] = c.f[1] = c.f[2] = c.f[3] = 0.5f;
-
- pipe->clear_render_target(pipe, surfaces[i], &c, 0, 0,
- surfaces[i]->width, surfaces[i]->height, false);
- }
- pipe->flush(pipe, NULL, 0);
-}
-
-/**
- * Interop to mesa state tracker
- */
-struct pipe_video_buffer *vlVdpVideoSurfaceGallium(VdpVideoSurface surface)
-{
- vlVdpSurface *p_surf = vlGetDataHTAB(surface);
- if (!p_surf)
- return NULL;
-
- mtx_lock(&p_surf->device->mutex);
- if (p_surf->video_buffer == NULL) {
- struct pipe_context *pipe = p_surf->device->context;
-
- /* try to create a video buffer if we don't already have one */
- p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
- }
- mtx_unlock(&p_surf->device->mutex);
-
- return p_surf->video_buffer;
-}
-
-VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
- VdpVideoSurfacePlane plane,
- struct VdpSurfaceDMABufDesc *result)
-{
- vlVdpSurface *p_surf = vlGetDataHTAB(surface);
-
- struct pipe_screen *pscreen;
- struct winsys_handle whandle;
-
- struct pipe_surface *surf;
-
- if (!p_surf)
- return VDP_STATUS_INVALID_HANDLE;
-
- if (plane > 3)
- return VDP_STATUS_INVALID_VALUE;
-
- if (!result)
- return VDP_STATUS_INVALID_POINTER;
-
- memset(result, 0, sizeof(*result));
- result->handle = -1;
-
- mtx_lock(&p_surf->device->mutex);
- if (p_surf->video_buffer == NULL) {
- struct pipe_context *pipe = p_surf->device->context;
-
- /* try to create a video buffer if we don't already have one */
- p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
- }
-
- /* Check if surface match interop requirements */
- if (p_surf->video_buffer == NULL || !p_surf->video_buffer->interlaced ||
- p_surf->video_buffer->buffer_format != PIPE_FORMAT_NV12) {
- mtx_unlock(&p_surf->device->mutex);
- return VDP_STATUS_NO_IMPLEMENTATION;
- }
-
- surf = p_surf->video_buffer->get_surfaces(p_surf->video_buffer)[plane];
- if (!surf) {
- mtx_unlock(&p_surf->device->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- memset(&whandle, 0, sizeof(struct winsys_handle));
- whandle.type = WINSYS_HANDLE_TYPE_FD;
- whandle.layer = surf->u.tex.first_layer;
-
- pscreen = surf->texture->screen;
- if (!pscreen->resource_get_handle(pscreen, p_surf->device->context,
- surf->texture, &whandle,
- PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)) {
- mtx_unlock(&p_surf->device->mutex);
- return VDP_STATUS_NO_IMPLEMENTATION;
- }
-
- mtx_unlock(&p_surf->device->mutex);
-
- result->handle = whandle.handle;
- result->width = surf->width;
- result->height = surf->height;
- result->offset = whandle.offset;
- result->stride = whandle.stride;
-
- if (surf->format == PIPE_FORMAT_R8_UNORM)
- result->format = VDP_RGBA_FORMAT_R8;
- else
- result->format = VDP_RGBA_FORMAT_R8G8;
-
- return VDP_STATUS_OK;
-}
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
deleted file mode 100644
index 80bb5aee0fe..00000000000
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ /dev/null
@@ -1,586 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Younes Manton & Thomas Balling Sørensen.
- * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef VDPAU_PRIVATE_H
-#define VDPAU_PRIVATE_H
-
-#include <assert.h>
-
-#include <vdpau/vdpau.h>
-#include <vdpau/vdpau_x11.h>
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_video_codec.h"
-
-#include "state_tracker/vdpau_interop.h"
-#include "state_tracker/vdpau_dmabuf.h"
-#include "state_tracker/vdpau_funcs.h"
-
-#include "util/u_debug.h"
-#include "util/u_rect.h"
-#include "os/os_thread.h"
-
-#include "vl/vl_video_buffer.h"
-#include "vl/vl_bicubic_filter.h"
-#include "vl/vl_compositor.h"
-#include "vl/vl_csc.h"
-#include "vl/vl_deint_filter.h"
-#include "vl/vl_matrix_filter.h"
-#include "vl/vl_median_filter.h"
-#include "vl/vl_winsys.h"
-
-/* Full VDPAU API documentation available at :
- * ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html */
-
-#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
-#define QUOTEME(x) #x
-#define TOSTRING(x) QUOTEME(x)
-#define INFORMATION_STRING TOSTRING(INFORMATION)
-
-static inline enum pipe_video_chroma_format
-ChromaToPipe(VdpChromaType vdpau_type)
-{
- switch (vdpau_type) {
- case VDP_CHROMA_TYPE_420:
- return PIPE_VIDEO_CHROMA_FORMAT_420;
- case VDP_CHROMA_TYPE_422:
- return PIPE_VIDEO_CHROMA_FORMAT_422;
- case VDP_CHROMA_TYPE_444:
- return PIPE_VIDEO_CHROMA_FORMAT_444;
- default:
- assert(0);
- }
-
- return -1;
-}
-
-static inline VdpChromaType
-PipeToChroma(enum pipe_video_chroma_format pipe_type)
-{
- switch (pipe_type) {
- case PIPE_VIDEO_CHROMA_FORMAT_420:
- return VDP_CHROMA_TYPE_420;
- case PIPE_VIDEO_CHROMA_FORMAT_422:
- return VDP_CHROMA_TYPE_422;
- case PIPE_VIDEO_CHROMA_FORMAT_444:
- return VDP_CHROMA_TYPE_444;
- default:
- assert(0);
- }
-
- return -1;
-}
-
-static inline enum pipe_video_chroma_format
-FormatYCBCRToPipeChroma(VdpYCbCrFormat vdpau_format)
-{
- switch (vdpau_format) {
- case VDP_YCBCR_FORMAT_NV12:
- return PIPE_VIDEO_CHROMA_FORMAT_420;
- case VDP_YCBCR_FORMAT_YV12:
- return PIPE_VIDEO_CHROMA_FORMAT_420;
- case VDP_YCBCR_FORMAT_UYVY:
- return PIPE_VIDEO_CHROMA_FORMAT_422;
- case VDP_YCBCR_FORMAT_YUYV:
- return PIPE_VIDEO_CHROMA_FORMAT_422;
- case VDP_YCBCR_FORMAT_Y8U8V8A8:
- return PIPE_VIDEO_CHROMA_FORMAT_444;
- case VDP_YCBCR_FORMAT_V8U8Y8A8:
- return PIPE_VIDEO_CHROMA_FORMAT_444;
- default:
- assert(0);
- }
-
- return PIPE_FORMAT_NONE;
-}
-
-static inline enum pipe_format
-FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format)
-{
- switch (vdpau_format) {
- case VDP_YCBCR_FORMAT_NV12:
- return PIPE_FORMAT_NV12;
- case VDP_YCBCR_FORMAT_YV12:
- return PIPE_FORMAT_YV12;
- case VDP_YCBCR_FORMAT_UYVY:
- return PIPE_FORMAT_UYVY;
- case VDP_YCBCR_FORMAT_YUYV:
- return PIPE_FORMAT_YUYV;
- case VDP_YCBCR_FORMAT_Y8U8V8A8:
- return PIPE_FORMAT_R8G8B8A8_UNORM;
- case VDP_YCBCR_FORMAT_V8U8Y8A8:
- return PIPE_FORMAT_B8G8R8A8_UNORM;
-#ifdef VDP_YCBCR_FORMAT_P010
- case VDP_YCBCR_FORMAT_P010:
- return PIPE_FORMAT_P010;
-#endif
-#ifdef VDP_YCBCR_FORMAT_P016
- case VDP_YCBCR_FORMAT_P016:
- return PIPE_FORMAT_P016;
-#endif
- default:
- /* NOTE: Can't be "unreachable", as it's quite reachable. */
- assert(!"unexpected VdpYCbCrFormat");
- /* fallthrough */
-#ifdef VDP_YCBCR_FORMAT_Y_UV_444
- case VDP_YCBCR_FORMAT_Y_UV_444:
-#endif
-#ifdef VDP_YCBCR_FORMAT_Y_U_V_444
- case VDP_YCBCR_FORMAT_Y_U_V_444:
-#endif
-#ifdef VDP_YCBCR_FORMAT_Y_U_V_444_16
- case VDP_YCBCR_FORMAT_Y_U_V_444_16:
-#endif
- return PIPE_FORMAT_NONE;
- }
-
-}
-
-static inline VdpYCbCrFormat
-PipeToFormatYCBCR(enum pipe_format p_format)
-{
- switch (p_format) {
- case PIPE_FORMAT_NV12:
- return VDP_YCBCR_FORMAT_NV12;
- case PIPE_FORMAT_YV12:
- return VDP_YCBCR_FORMAT_YV12;
- case PIPE_FORMAT_UYVY:
- return VDP_YCBCR_FORMAT_UYVY;
- case PIPE_FORMAT_YUYV:
- return VDP_YCBCR_FORMAT_YUYV;
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- return VDP_YCBCR_FORMAT_Y8U8V8A8;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- return VDP_YCBCR_FORMAT_V8U8Y8A8;
- default:
- assert(0);
- }
-
- return -1;
-}
-
-static inline VdpRGBAFormat
-PipeToFormatRGBA(enum pipe_format p_format)
-{
- switch (p_format) {
- case PIPE_FORMAT_A8_UNORM:
- return VDP_RGBA_FORMAT_A8;
- case PIPE_FORMAT_B10G10R10A2_UNORM:
- return VDP_RGBA_FORMAT_B10G10R10A2;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- return VDP_RGBA_FORMAT_B8G8R8A8;
- case PIPE_FORMAT_R10G10B10A2_UNORM:
- return VDP_RGBA_FORMAT_R10G10B10A2;
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- return VDP_RGBA_FORMAT_R8G8B8A8;
- default:
- assert(0);
- }
-
- return -1;
-}
-
-static inline enum pipe_format
-FormatIndexedToPipe(VdpRGBAFormat vdpau_format)
-{
- switch (vdpau_format) {
- case VDP_INDEXED_FORMAT_A4I4:
- return PIPE_FORMAT_R4A4_UNORM;
- case VDP_INDEXED_FORMAT_I4A4:
- return PIPE_FORMAT_A4R4_UNORM;
- case VDP_INDEXED_FORMAT_A8I8:
- return PIPE_FORMAT_A8R8_UNORM;
- case VDP_INDEXED_FORMAT_I8A8:
- return PIPE_FORMAT_R8A8_UNORM;
- default:
- assert(0);
- }
-
- return PIPE_FORMAT_NONE;
-}
-
-static inline enum pipe_format
-FormatColorTableToPipe(VdpColorTableFormat vdpau_format)
-{
- switch(vdpau_format) {
- case VDP_COLOR_TABLE_FORMAT_B8G8R8X8:
- return PIPE_FORMAT_B8G8R8X8_UNORM;
- default:
- assert(0);
- }
-
- return PIPE_FORMAT_NONE;
-}
-
-static inline enum pipe_video_profile
-ProfileToPipe(VdpDecoderProfile vdpau_profile)
-{
- switch (vdpau_profile) {
- case VDP_DECODER_PROFILE_MPEG1:
- return PIPE_VIDEO_PROFILE_MPEG1;
- case VDP_DECODER_PROFILE_MPEG2_SIMPLE:
- return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;
- case VDP_DECODER_PROFILE_MPEG2_MAIN:
- return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
- case VDP_DECODER_PROFILE_H264_BASELINE:
- return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
- case VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE:
- return PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE;
- case VDP_DECODER_PROFILE_H264_MAIN:
- return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
- case VDP_DECODER_PROFILE_H264_HIGH:
- return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
- case VDP_DECODER_PROFILE_MPEG4_PART2_SP:
- return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE;
- case VDP_DECODER_PROFILE_MPEG4_PART2_ASP:
- return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE;
- case VDP_DECODER_PROFILE_VC1_SIMPLE:
- return PIPE_VIDEO_PROFILE_VC1_SIMPLE;
- case VDP_DECODER_PROFILE_VC1_MAIN:
- return PIPE_VIDEO_PROFILE_VC1_MAIN;
- case VDP_DECODER_PROFILE_VC1_ADVANCED:
- return PIPE_VIDEO_PROFILE_VC1_ADVANCED;
- case VDP_DECODER_PROFILE_HEVC_MAIN:
- return PIPE_VIDEO_PROFILE_HEVC_MAIN;
- case VDP_DECODER_PROFILE_HEVC_MAIN_10:
- return PIPE_VIDEO_PROFILE_HEVC_MAIN_10;
- case VDP_DECODER_PROFILE_HEVC_MAIN_STILL:
- return PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL;
- case VDP_DECODER_PROFILE_HEVC_MAIN_12:
- return PIPE_VIDEO_PROFILE_HEVC_MAIN_12;
- case VDP_DECODER_PROFILE_HEVC_MAIN_444:
- return PIPE_VIDEO_PROFILE_HEVC_MAIN_444;
- default:
- return PIPE_VIDEO_PROFILE_UNKNOWN;
- }
-}
-
-static inline VdpDecoderProfile
-PipeToProfile(enum pipe_video_profile p_profile)
-{
- switch (p_profile) {
- case PIPE_VIDEO_PROFILE_MPEG1:
- return VDP_DECODER_PROFILE_MPEG1;
- case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
- return VDP_DECODER_PROFILE_MPEG2_SIMPLE;
- case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
- return VDP_DECODER_PROFILE_MPEG2_MAIN;
- case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
- return VDP_DECODER_PROFILE_H264_BASELINE;
- case PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE:
- return VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE;
- case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
- return VDP_DECODER_PROFILE_H264_MAIN;
- case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
- return VDP_DECODER_PROFILE_H264_HIGH;
- case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:
- return VDP_DECODER_PROFILE_MPEG4_PART2_SP;
- case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
- return VDP_DECODER_PROFILE_MPEG4_PART2_ASP;
- case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
- return VDP_DECODER_PROFILE_VC1_SIMPLE;
- case PIPE_VIDEO_PROFILE_VC1_MAIN:
- return VDP_DECODER_PROFILE_VC1_MAIN;
- case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
- return VDP_DECODER_PROFILE_VC1_ADVANCED;
- case PIPE_VIDEO_PROFILE_HEVC_MAIN:
- return VDP_DECODER_PROFILE_HEVC_MAIN;
- case PIPE_VIDEO_PROFILE_HEVC_MAIN_10:
- return VDP_DECODER_PROFILE_HEVC_MAIN_10;
- case PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL:
- return VDP_DECODER_PROFILE_HEVC_MAIN_STILL;
- case PIPE_VIDEO_PROFILE_HEVC_MAIN_12:
- return VDP_DECODER_PROFILE_HEVC_MAIN_12;
- case PIPE_VIDEO_PROFILE_HEVC_MAIN_444:
- return VDP_DECODER_PROFILE_HEVC_MAIN_444;
- default:
- assert(0);
- return -1;
- }
-}
-
-static inline struct u_rect *
-RectToPipe(const VdpRect *src, struct u_rect *dst)
-{
- if (src) {
- dst->x0 = src->x0;
- dst->y0 = src->y0;
- dst->x1 = src->x1;
- dst->y1 = src->y1;
- return dst;
- }
- return NULL;
-}
-
-static inline struct pipe_box
-RectToPipeBox(const VdpRect *rect, struct pipe_resource *res)
-{
- struct pipe_box box;
-
- box.x = 0;
- box.y = 0;
- box.z = 0;
- box.width = res->width0;
- box.height = res->height0;
- box.depth = 1;
-
- if (rect) {
- box.x = MIN2(rect->x0, rect->x1);
- box.y = MIN2(rect->y0, rect->y1);
- box.width = abs(rect->x1 - rect->x0);
- box.height = abs(rect->y1 - rect->y0);
- }
-
- return box;
-}
-
-static inline bool
-CheckSurfaceParams(struct pipe_screen *screen,
- const struct pipe_resource *templ)
-{
- return screen->is_format_supported(screen, templ->format, templ->target,
- templ->nr_samples,
- templ->nr_storage_samples, templ->bind);
-}
-
-typedef struct
-{
- struct pipe_reference reference;
- struct vl_screen *vscreen;
- struct pipe_context *context;
- struct vl_compositor compositor;
- struct pipe_sampler_view *dummy_sv;
- mtx_t mutex;
-} vlVdpDevice;
-
-typedef struct
-{
- vlVdpDevice *device;
- struct vl_compositor_state cstate;
-
- struct {
- bool supported, enabled;
- float luma_min, luma_max;
- } luma_key;
-
- struct {
- bool supported, enabled, spatial;
- struct vl_deint_filter *filter;
- } deint;
-
- struct {
- bool supported, enabled;
- struct vl_bicubic_filter *filter;
- } bicubic;
-
- struct {
- bool supported, enabled;
- unsigned level;
- struct vl_median_filter *filter;
- } noise_reduction;
-
- struct {
- bool supported, enabled;
- float value;
- struct vl_matrix_filter *filter;
- } sharpness;
-
- unsigned video_width, video_height;
- enum pipe_video_chroma_format chroma_format;
- unsigned max_layers, skip_chroma_deint;
-
- bool custom_csc;
- vl_csc_matrix csc;
-} vlVdpVideoMixer;
-
-typedef struct
-{
- vlVdpDevice *device;
- struct pipe_video_buffer templat, *video_buffer;
-} vlVdpSurface;
-
-typedef struct
-{
- vlVdpDevice *device;
- struct pipe_sampler_view *sampler_view;
-} vlVdpBitmapSurface;
-
-typedef uint64_t vlVdpTime;
-
-typedef struct
-{
- vlVdpDevice *device;
- struct pipe_surface *surface;
- struct pipe_sampler_view *sampler_view;
- struct pipe_fence_handle *fence;
- struct vl_compositor_state cstate;
- struct u_rect dirty_area;
- bool send_to_X;
-} vlVdpOutputSurface;
-
-typedef struct
-{
- vlVdpDevice *device;
- Drawable drawable;
-} vlVdpPresentationQueueTarget;
-
-typedef struct
-{
- vlVdpDevice *device;
- Drawable drawable;
- struct vl_compositor_state cstate;
- vlVdpOutputSurface *last_surf;
-} vlVdpPresentationQueue;
-
-typedef struct
-{
- vlVdpDevice *device;
- mtx_t mutex;
- struct pipe_video_codec *decoder;
-} vlVdpDecoder;
-
-typedef uint32_t vlHandle;
-
-boolean vlCreateHTAB(void);
-void vlDestroyHTAB(void);
-vlHandle vlAddDataHTAB(void *data);
-void* vlGetDataHTAB(vlHandle handle);
-void vlRemoveDataHTAB(vlHandle handle);
-
-boolean vlGetFuncFTAB(VdpFuncId function_id, void **func);
-
-/* Public functions */
-VdpDeviceCreateX11 vdp_imp_device_create_x11;
-
-void vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res);
-
-/* Internal function pointers */
-VdpGetErrorString vlVdpGetErrorString;
-VdpDeviceDestroy vlVdpDeviceDestroy;
-void vlVdpDeviceFree(vlVdpDevice *dev);
-VdpGetProcAddress vlVdpGetProcAddress;
-VdpGetApiVersion vlVdpGetApiVersion;
-VdpGetInformationString vlVdpGetInformationString;
-VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities;
-VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities;
-VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities;
-VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities;
-VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities;
-VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities;
-VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities;
-VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities;
-VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport;
-VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport;
-VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange;
-VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport;
-VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange;
-VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate;
-VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;
-VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;
-VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;
-VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;
-void vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf);
-VdpDecoderCreate vlVdpDecoderCreate;
-VdpDecoderDestroy vlVdpDecoderDestroy;
-VdpDecoderGetParameters vlVdpDecoderGetParameters;
-VdpDecoderRender vlVdpDecoderRender;
-VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate;
-VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy;
-VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters;
-VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative;
-VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative;
-VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed;
-VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr;
-VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface;
-VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface;
-VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate;
-VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy;
-VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters;
-VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative;
-VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy;
-VdpPresentationQueueCreate vlVdpPresentationQueueCreate;
-VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy;
-VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor;
-VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor;
-VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime;
-VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay;
-VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle;
-VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus;
-VdpPreemptionCallback vlVdpPreemptionCallback;
-VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister;
-VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables;
-VdpVideoMixerCreate vlVdpVideoMixerCreate;
-VdpVideoMixerRender vlVdpVideoMixerRender;
-VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues;
-VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport;
-VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables;
-VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues;
-VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues;
-VdpVideoMixerDestroy vlVdpVideoMixerDestroy;
-VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;
-/* Winsys specific internal function pointers */
-VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
-
-
-/* interop to mesa state tracker */
-VdpVideoSurfaceGallium vlVdpVideoSurfaceGallium;
-VdpOutputSurfaceGallium vlVdpOutputSurfaceGallium;
-VdpVideoSurfaceDMABuf vlVdpVideoSurfaceDMABuf;
-VdpOutputSurfaceDMABuf vlVdpOutputSurfaceDMABuf;
-
-#define VDPAU_OUT 0
-#define VDPAU_ERR 1
-#define VDPAU_WARN 2
-#define VDPAU_TRACE 3
-
-static inline void VDPAU_MSG(unsigned int level, const char *fmt, ...)
-{
- static int debug_level = -1;
-
- if (debug_level == -1) {
- debug_level = MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);
- }
-
- if (level <= debug_level) {
- va_list ap;
- va_start(ap, fmt);
- _debug_vprintf(fmt, ap);
- va_end(ap);
- }
-}
-
-static inline void
-DeviceReference(vlVdpDevice **ptr, vlVdpDevice *dev)
-{
- vlVdpDevice *old_dev = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &dev->reference))
- vlVdpDeviceFree(old_dev);
- *ptr = dev;
-}
-
-#endif /* VDPAU_PRIVATE_H */