vlVdpVideoMixer *vmixer = NULL;
VdpStatus ret;
struct pipe_screen *screen;
- uint32_t max_2d_texture_level;
unsigned max_size, i;
vlVdpDevice *dev = vlGetDataHTAB(device);
DeviceReference(&vmixer->device, dev);
- pipe_mutex_lock(dev->mutex);
+ mtx_lock(&dev->mutex);
- vl_compositor_init_state(&vmixer->cstate, dev->context);
+ 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))
- vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc, 1.0f, 0.0f);
+ 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) {
goto no_params;
}
- max_2d_texture_level = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
- max_size = pow(2, max_2d_texture_level-1);
+ 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);
}
vmixer->luma_key.luma_min = 1.0f;
vmixer->luma_key.luma_max = 0.0f;
- pipe_mutex_unlock(dev->mutex);
+ mtx_unlock(&dev->mutex);
return VDP_STATUS_OK;
vlRemoveDataHTAB(*mixer);
no_handle:
+err_csc_matrix:
vl_compositor_cleanup_state(&vmixer->cstate);
- pipe_mutex_unlock(dev->mutex);
+no_compositor_state:
+ mtx_unlock(&dev->mutex);
DeviceReference(&vmixer->device, NULL);
FREE(vmixer);
return ret;
if (!vmixer)
return VDP_STATUS_INVALID_HANDLE;
- pipe_mutex_lock(vmixer->device->mutex);
-
- vlVdpResolveDelayedRendering(vmixer->device, NULL, NULL);
+ mtx_lock(&vmixer->device->mutex);
vlRemoveDataHTAB(mixer);
vl_bicubic_filter_cleanup(vmixer->bicubic.filter);
FREE(vmixer->bicubic.filter);
}
- pipe_mutex_unlock(vmixer->device->mutex);
+ mtx_unlock(&vmixer->device->mutex);
DeviceReference(&vmixer->device, NULL);
FREE(vmixer);
struct pipe_video_buffer *video_buffer;
struct pipe_sampler_view *sampler_view, sv_templ;
struct pipe_surface *surface, surf_templ;
- struct pipe_context *pipe;
+ struct pipe_context *pipe = NULL;
struct pipe_resource res_tmpl, *res;
vlVdpVideoMixer *vmixer;
if (vmixer->video_width > video_buffer->width ||
vmixer->video_height > video_buffer->height ||
- vmixer->chroma_format != video_buffer->chroma_format)
+ 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_HANDLE;
}
- pipe_mutex_lock(vmixer->device->mutex);
- vlVdpResolveDelayedRendering(vmixer->device, NULL, NULL);
+ mtx_lock(&vmixer->device->mutex);
vl_compositor_clear_layers(&vmixer->cstate);
break;
default:
- pipe_mutex_unlock(vmixer->device->mutex);
+ mtx_unlock(&vmixer->device->mutex);
return VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE;
}
for (i = 0; i < layer_count; ++i) {
vlVdpOutputSurface *src = vlGetDataHTAB(layers->source_surface);
if (!src) {
- pipe_mutex_unlock(vmixer->device->mutex);
+ mtx_unlock(&vmixer->device->mutex);
return VDP_STATUS_INVALID_HANDLE;
}
++layers;
}
- if (!vmixer->noise_reduction.filter && !vmixer->sharpness.filter && !vmixer->bicubic.filter)
- vlVdpSave4DelayedRendering(vmixer->device, destination_surface, &vmixer->cstate);
- else {
- vl_compositor_render(&vmixer->cstate, compositor, surface, &dirty_area, true);
+ 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);
+ 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);
+ vl_median_filter_render(vmixer->noise_reduction.filter,
+ sampler_view, surface_temp);
- pipe_sampler_view_reference(&sampler_view, NULL);
- pipe_surface_reference(&surface, NULL);
+ pipe_sampler_view_reference(&sampler_view, NULL);
+ pipe_surface_reference(&surface, NULL);
- sampler_view = sampler_view_temp;
- surface = surface_temp;
- }
+ 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);
+ 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);
+ vl_matrix_filter_render(vmixer->sharpness.filter,
+ sampler_view, surface_temp);
- pipe_sampler_view_reference(&sampler_view, NULL);
- pipe_surface_reference(&surface, NULL);
+ pipe_sampler_view_reference(&sampler_view, NULL);
+ pipe_surface_reference(&surface, NULL);
- sampler_view = sampler_view_temp;
- surface = surface_temp;
- }
+ 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 (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);
- }
+ if(surface != dst->surface) {
+ pipe_sampler_view_reference(&sampler_view, NULL);
+ pipe_surface_reference(&surface, NULL);
}
- pipe_mutex_unlock(vmixer->device->mutex);
+ mtx_unlock(&vmixer->device->mutex);
return VDP_STATUS_OK;
}
if (!vmixer)
return VDP_STATUS_INVALID_HANDLE;
- pipe_mutex_lock(vmixer->device->mutex);
+ 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_LUMA_KEY:
vmixer->luma_key.enabled = feature_enables[i];
if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
- vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
- vmixer->luma_key.luma_min, vmixer->luma_key.luma_max);
+ 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:
break;
default:
- pipe_mutex_unlock(vmixer->device->mutex);
+ mtx_unlock(&vmixer->device->mutex);
return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
}
}
- pipe_mutex_unlock(vmixer->device->mutex);
+ mtx_unlock(&vmixer->device->mutex);
return VDP_STATUS_OK;
}
if (!vmixer)
return VDP_STATUS_INVALID_HANDLE;
- pipe_mutex_lock(vmixer->device->mutex);
+ mtx_lock(&vmixer->device->mutex);
for (i = 0; i < attribute_count; ++i) {
switch (attributes[i]) {
case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
else
memcpy(vmixer->csc, vdp_csc, sizeof(vl_csc_matrix));
if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
- vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
- vmixer->luma_key.luma_min, vmixer->luma_key.luma_max);
+ 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:
}
vmixer->luma_key.luma_min = val;
if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
- vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
- vmixer->luma_key.luma_min, vmixer->luma_key.luma_max);
+ 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:
}
vmixer->luma_key.luma_max = val;
if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
- vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
- vmixer->luma_key.luma_min, vmixer->luma_key.luma_max);
+ 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:
goto fail;
}
}
- pipe_mutex_unlock(vmixer->device->mutex);
+ mtx_unlock(&vmixer->device->mutex);
return VDP_STATUS_OK;
fail:
- pipe_mutex_unlock(vmixer->device->mutex);
+ mtx_unlock(&vmixer->device->mutex);
return ret;
}
if (!vmixer)
return VDP_STATUS_INVALID_HANDLE;
- pipe_mutex_lock(vmixer->device->mutex);
+ mtx_lock(&vmixer->device->mutex);
for (i = 0; i < attribute_count; ++i) {
switch (attributes[i]) {
case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
*(uint8_t*)attribute_values[i] = vmixer->skip_chroma_deint;
break;
default:
- pipe_mutex_unlock(vmixer->device->mutex);
+ mtx_unlock(&vmixer->device->mutex);
return VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE;
}
}
- pipe_mutex_unlock(vmixer->device->mutex);
+ mtx_unlock(&vmixer->device->mutex);
return VDP_STATUS_OK;
}