Skip to content

Commit

Permalink
Debugging and fixes for Shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
arekinath committed Nov 28, 2018
1 parent 9f86920 commit 07c045c
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 11 deletions.
30 changes: 27 additions & 3 deletions src/vdpau_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ destroy_dead_va_buffers(
if (obj_context->dead_buffers_count < 1)
return;

return;

ASSERT(obj_context->dead_buffers);
for (i = 0; i < obj_context->dead_buffers_count; i++) {
obj_buffer = VDPAU_BUFFER(obj_context->dead_buffers[i]);
Expand Down Expand Up @@ -96,6 +98,7 @@ destroy_va_buffer(
{
if (!obj_buffer)
return;
D(bug("destroying va buffer %x\n", obj_buffer->base.id));

if (obj_buffer->buffer_data) {
free(obj_buffer->buffer_data);
Expand Down Expand Up @@ -142,8 +145,8 @@ vdpau_CreateBuffer(
{
VDPAU_DRIVER_DATA_INIT;

if (buf_id)
*buf_id = VA_INVALID_BUFFER;
/*if (buf_id)
*buf_id = VA_INVALID_BUFFER;*/

/* Validate type */
switch (type) {
Expand All @@ -165,9 +168,25 @@ vdpau_CreateBuffer(
if (!obj_buffer)
return VA_STATUS_ERROR_ALLOCATION_FAILED;

switch (type) {
case VAPictureParameterBufferType:
obj_buffer->typestr = "VAPictureParameterBufferType"; break;
case VAIQMatrixBufferType:
obj_buffer->typestr = "VAIQMatrixBufferType"; break;
case VASliceParameterBufferType:
obj_buffer->typestr = "VASliceParameterBufferType"; break;
case VASliceDataBufferType:
obj_buffer->typestr = "VASliceDataBufferType"; break;
case VABitPlaneBufferType:
obj_buffer->typestr = "VABitPlaneBufferType"; break;
case VAImageBufferType:
obj_buffer->typestr = "VAImageBufferType"; break;
}

if (data)
memcpy(obj_buffer->buffer_data, data, obj_buffer->buffer_size);

D(bug("allocated buffer id %x (%s)\n", obj_buffer->base.id, obj_buffer->typestr));
if (buf_id)
*buf_id = obj_buffer->base.id;

Expand All @@ -185,6 +204,7 @@ vdpau_DestroyBuffer(

object_buffer_p obj_buffer = VDPAU_BUFFER(buffer_id);

D(bug("destroy req for buffer id %x\n", buffer_id));
if (obj_buffer && !obj_buffer->delayed_destroy)
destroy_va_buffer(driver_data, obj_buffer);

Expand Down Expand Up @@ -223,8 +243,12 @@ vdpau_MapBuffer(
VDPAU_DRIVER_DATA_INIT;

object_buffer_p obj_buffer = VDPAU_BUFFER(buf_id);
if (!obj_buffer)
if (!obj_buffer) {
D(bug("tried to map invalid buffer id %x\n", buf_id));
return VA_STATUS_ERROR_INVALID_BUFFER;
}

D(bug("map buffer id %x\n", buf_id));

if (pbuf)
*pbuf = obj_buffer->buffer_data;
Expand Down
2 changes: 2 additions & 0 deletions src/vdpau_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct object_buffer {
struct object_base base;
VAContextID va_context;
VABufferType type;
const char * typestr;
struct object_buffer *next_pre_slice_params;
void *buffer_data;
unsigned int buffer_size;
unsigned int max_num_elements;
Expand Down
38 changes: 33 additions & 5 deletions src/vdpau_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,13 @@ translate_VASliceDataBuffer(
)
{
if (obj_context->vdp_codec == VDP_CODEC_H264) {
/* Queue up any slicedata that arrive before sliceparams */
if (obj_context->last_slice_params_count == 0) {
obj_buffer->next_pre_slice_params = obj_context->last_slice_data;
obj_context->last_slice_data = obj_buffer;
return 1;
}
D(bug("start h264 data buffer (slices = %d)\n", obj_context->last_slice_params_count));
/* Check we have the start code */
/* XXX: check for other codecs too? */
/* XXX: this assumes we get SliceParams before SliceData */
Expand All @@ -472,6 +479,7 @@ translate_VASliceDataBuffer(
for (i = 0; i < obj_context->last_slice_params_count; i++) {
VASliceParameterBufferH264 * const slice_param = &slice_params[i];
uint8_t *buf = (uint8_t *)obj_buffer->buffer_data + slice_param->slice_data_offset;
D(bug("h264 slice at +0x%x (%u long) (#%d)\n", slice_param->slice_data_offset, slice_param->slice_data_size, i));
if (memcmp(buf, start_code_prefix, sizeof(start_code_prefix)) != 0) {
if (append_VdpBitstreamBuffer(obj_context,
start_code_prefix,
Expand All @@ -483,6 +491,7 @@ translate_VASliceDataBuffer(
slice_param->slice_data_size) < 0)
return 0;
}
D(bug("h264 data buffer done\n"));
return 1;
}

Expand Down Expand Up @@ -902,6 +911,19 @@ translate_VASliceParameterBufferH264(
pic_info->num_ref_idx_l1_active_minus1 = slice_param->num_ref_idx_l1_active_minus1;
obj_context->last_slice_params = obj_buffer->buffer_data;
obj_context->last_slice_params_count = obj_buffer->num_elements;

if (obj_context->last_slice_data) {
object_buffer_p sdata_buffer = obj_context->last_slice_data, sdata_next = NULL;
while (sdata_buffer != NULL) {
if (!translate_VASliceDataBuffer(driver_data, obj_context, sdata_buffer))
return 0;
sdata_next = sdata_buffer->next_pre_slice_params;
sdata_buffer->next_pre_slice_params = NULL;
sdata_buffer = sdata_next;
}
obj_context->last_slice_data = NULL;
}

return 1;
}

Expand Down Expand Up @@ -1209,27 +1231,29 @@ vdpau_RenderPicture(
/* Translate buffers */
for (i = 0; i < num_buffers; i++) {
object_buffer_p obj_buffer = VDPAU_BUFFER(buffers[i]);
D(bug("try translate buffer %x (type = %d/%s)\n", buffers[i], obj_buffer->type, obj_buffer->typestr));
if (!translate_buffer(driver_data, obj_context, obj_buffer))
return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE;
D(bug("translated buffer %x\n", buffers[i]));
/* Release any buffer that is not VASliceDataBuffer */
/* VASliceParameterBuffer is also needed to check for start_codes */
switch (obj_buffer->type) {
case VASliceParameterBufferType:
case VASliceDataBufferType:
schedule_destroy_va_buffer(driver_data, obj_buffer);
//schedule_destroy_va_buffer(driver_data, obj_buffer);
break;
case VAPictureParameterBufferType:
/* Preserve VAPictureParameterBufferMPEG4 */
if (obj_context->vdp_codec == VDP_CODEC_MPEG4) {
schedule_destroy_va_buffer(driver_data, obj_buffer);
//schedule_destroy_va_buffer(driver_data, obj_buffer);
break;
}
/* fall-through */
default:
destroy_va_buffer(driver_data, obj_buffer);
//destroy_va_buffer(driver_data, obj_buffer);
break;
}
buffers[i] = VA_INVALID_BUFFER;
//buffers[i] = VA_INVALID_BUFFER;
}

return VA_STATUS_SUCCESS;
Expand Down Expand Up @@ -1277,13 +1301,16 @@ vdpau_EndPicture(
dump_VdpBitstreamBuffer(&obj_context->vdp_bitstream_buffers[i]);
}

D(bug("rendering to surface %x\n", obj_context->current_render_target));

VAStatus va_status;
VdpStatus vdp_status;
vdp_status = ensure_decoder_with_max_refs(
driver_data,
obj_context,
get_num_ref_frames(obj_context)
);
D(bug("vdp_status after ensure = %d\n", vdp_status));
if (vdp_status == VDP_STATUS_OK)
vdp_status = vdpau_decoder_render(
driver_data,
Expand All @@ -1294,9 +1321,10 @@ vdpau_EndPicture(
obj_context->vdp_bitstream_buffers
);
va_status = vdpau_get_VAStatus(vdp_status);
D(bug("vdp_status after render = %d\n", vdp_status));

/* XXX: assume we are done with rendering right away */
obj_context->current_render_target = VA_INVALID_SURFACE;
//obj_context->current_render_target = VA_INVALID_SURFACE;

/* Release pending buffers */
destroy_dead_va_buffers(driver_data, obj_context);
Expand Down
2 changes: 1 addition & 1 deletion src/vdpau_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#define VDPAU_MAX_DISPLAY_ATTRIBUTES 6
#define VDPAU_MAX_OUTPUT_SURFACES 2
#define VDPAU_STR_DRIVER_VENDOR "Splitted-Desktop Systems"
#define VDPAU_STR_DRIVER_NAME "VDPAU backend for VA-API"
#define VDPAU_STR_DRIVER_NAME "VDPAU backend for VA-API (arekinath)"

/* Check we have MPEG-4 support in VDPAU and the necessary VAAPI extensions */
#define USE_VDPAU_MPEG4 \
Expand Down
1 change: 1 addition & 0 deletions src/vdpau_mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "sysdeps.h"
#include "vdpau_mixer.h"
#include "vdpau_video.h"
#include "debug.h"
#include <math.h>

#define VDPAU_MAX_VIDEO_MIXER_PARAMS 4
Expand Down
1 change: 1 addition & 0 deletions src/vdpau_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ vdpau_CreateSurfaces(
}

int va_surface = object_heap_allocate(&driver_data->surface_heap);
D(bug("created %dx%d surface at id %x, vdp handle %x\n", width, height, va_surface, vdp_surface));
object_surface_p obj_surface = VDPAU_SURFACE(va_surface);
if (!obj_surface) {
va_status = VA_STATUS_ERROR_ALLOCATION_FAILED;
Expand Down
1 change: 1 addition & 0 deletions src/vdpau_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct object_context {
void *last_pic_param;
void *last_slice_params;
unsigned int last_slice_params_count;
struct object_buffer *last_slice_data;
VdpCodec vdp_codec;
VdpDecoderProfile vdp_profile;
VdpDecoder vdp_decoder;
Expand Down
9 changes: 7 additions & 2 deletions src/vdpau_video_x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ render_surface(
src_rect.y0 = source_rect->y;
src_rect.x1 = source_rect->x + source_rect->width;
src_rect.y1 = source_rect->y + source_rect->height;
ensure_bounds(&src_rect, obj_surface->width, obj_surface->height);
ensure_bounds(&src_rect, obj_surface->width, obj_surface->height);

VdpRect dst_rect;
dst_rect.x0 = target_rect->x;
Expand Down Expand Up @@ -785,6 +785,9 @@ vdpau_PutSurface(
{
VDPAU_DRIVER_DATA_INIT;

VAStatus ret;

D(bug("putsurface(%x, (%d,%d+%dx%d=>%d,%d+%dx%d))\n", surface, srcx, srcy, srcw, srch, destx, desty, destw, desth));
vdpau_set_display_type(driver_data, VA_DISPLAY_X11);

/* XXX: no clip rects supported */
Expand All @@ -805,5 +808,7 @@ vdpau_PutSurface(
dst_rect.y = desty;
dst_rect.width = destw;
dst_rect.height = desth;
return put_surface(driver_data, surface, xid, w, h, &src_rect, &dst_rect, flags);
ret = put_surface(driver_data, surface, xid, w, h, &src_rect, &dst_rect, flags);

return ret;
}

0 comments on commit 07c045c

Please sign in to comment.