Example #1
0
VdpStatus vdp_video_surface_destroy(VdpVideoSurface surface)
{
	video_surface_ctx_t *vs = handle_get(surface);
	if (!vs)
		return VDP_STATUS_INVALID_HANDLE;

	if (vs->decoder_private_free)
		vs->decoder_private_free(vs);
	if( cedarv_isValid(vs->dataY) )
	  cedarv_free(vs->dataY);
	if( cedarv_isValid(vs->dataU) )
	  cedarv_free(vs->dataU);
	if (cedarv_isValid(vs->dataV) )
	  cedarv_free(vs->dataV);

        cedarv_setBufferInvalid(vs->dataY);
        cedarv_setBufferInvalid(vs->dataU);
        cedarv_setBufferInvalid(vs->dataV);
        
        VDPAU_DBG("vdpau video surface=%d destroyed", surface);
        
        handle_release(surface);
        handle_destroy(surface);

	return VDP_STATUS_OK;
}
Example #2
0
VdpStatus vdp_imp_device_create_x11(Display *display,
                                    int screen,
                                    VdpDevice *device,
                                    VdpGetProcAddress **get_proc_address)
{
	if (!display || !device || !get_proc_address)
		return VDP_STATUS_INVALID_POINTER;

	device_ctx_t *dev = handle_create(sizeof(*dev), device);
	if (!dev)
		return VDP_STATUS_RESOURCES;

	dev->display = XOpenDisplay(XDisplayString(display));
	dev->screen = screen;

	if (!ve_open())
	{
		handle_destroy(*device);
		return VDP_STATUS_ERROR;
	}

	char *env_vdpau_osd = getenv("VDPAU_OSD");
	if (env_vdpau_osd && strncmp(env_vdpau_osd, "1", 1) == 0)
	{
		dev->g2d_fd = open("/dev/g2d", O_RDWR);
		if (dev->g2d_fd != -1)
			dev->osd_enabled = 1;
		else
			VDPAU_DBG("Failed to open /dev/g2d! OSD disabled.");
	}

	*get_proc_address = vdp_get_proc_address;

	return VDP_STATUS_OK;
}
Example #3
0
VdpStatus vdp_output_surface_put_bits_native(VdpOutputSurface surface, void const *const *source_data, uint32_t const *source_pitches, VdpRect const *destination_rect)
{
	output_surface_ctx_t *out = handle_get(surface);
	if (!out)
		return VDP_STATUS_INVALID_HANDLE;

	VDPAU_DBG("%s called but unimplemented!", __func__);



	return VDP_STATUS_OK;
}
Example #4
0
VdpStatus vdp_output_surface_render_bitmap_surface(VdpOutputSurface destination_surface, VdpRect const *destination_rect, VdpBitmapSurface source_surface, VdpRect const *source_rect, VdpColor const *colors, VdpOutputSurfaceRenderBlendState const *blend_state, uint32_t flags)
{
	output_surface_ctx_t *out = handle_get(destination_surface);
	if (!out)
		return VDP_STATUS_INVALID_HANDLE;

	VDPAU_DBG("%s called but unimplemented!", __func__);



	return VDP_STATUS_OK;
}
Example #5
0
VdpStatus vdp_output_surface_put_bits_y_cb_cr(VdpOutputSurface surface, VdpYCbCrFormat source_ycbcr_format, void const *const *source_data, uint32_t const *source_pitches, VdpRect const *destination_rect, VdpCSCMatrix const *csc_matrix)
{
	output_surface_ctx_t *out = handle_get(surface);
	if (!out)
		return VDP_STATUS_INVALID_HANDLE;

	VDPAU_DBG("%s called but unimplemented!", __func__);



	return VDP_STATUS_OK;
}
Example #6
0
VdpStatus vdp_output_surface_put_bits_indexed(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)
{
	output_surface_ctx_t *out = handle_get(surface);
	if (!out)
		return VDP_STATUS_INVALID_HANDLE;

	VDPAU_DBG("%s called but unimplemented!", __func__);



	return VDP_STATUS_OK;
}
Example #7
0
VdpStatus vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGetProcAddress **get_proc_address)
{
	if (!device || !get_proc_address) {
		VDPAU_DBG_ONCE("device=NULL || get_proc_address");
		return VDP_STATUS_INVALID_POINTER;
	}

	device_ctx_t *dev = handle_create(sizeof(*dev), device, htype_device);
	if (!dev)
		return VDP_STATUS_RESOURCES;

	//dev->display = XOpenDisplay(XDisplayString(display));
	dev->screen = screen;
        dev->fb_id = 0;

	if (!cedarv_open())
	{
		VDPAU_DBG_ONCE("cedarv_open failed");
		handle_destroy(*device);
		return VDP_STATUS_ERROR;
	}

	char *env_vdpau_osd = getenv("VDPAU_OSD");
	if (env_vdpau_osd && strncmp(env_vdpau_osd, "1", 1) == 0)
	{
		dev->g2d_fd = open("/dev/g2d", O_RDWR);
		if (dev->g2d_fd != -1)
			dev->osd_enabled = 1;
		else
			VDPAU_DBG("Failed to open /dev/g2d! OSD disabled.");
	}

        VDPAU_DBG("VE version 0x%04x opened", cedarv_get_version());
	*get_proc_address = &vdp_get_proc_address;
        
	return VDP_STATUS_OK;
}
Example #8
0
VdpStatus vdp_decoder_destroy(VdpDecoder decoder)
{
    VDPAU_DBG("vdpau decoder=%d destroyed", decoder);
    decoder_ctx_t *dec = handle_get(decoder);
    if (!dec)
        return VDP_STATUS_INVALID_HANDLE;

    if (dec->private_free)
        dec->private_free(dec);

    cedarv_free(dec->data);

    handle_release(decoder);
    handle_destroy(decoder);

    return VDP_STATUS_OK;
}
Example #9
0
VdpStatus vdp_decoder_create(VdpDevice device, VdpDecoderProfile profile, uint32_t width, uint32_t height, uint32_t max_references, VdpDecoder *decoder)
{
    device_ctx_t *dev = handle_get(device);
    if (!dev)
        return VDP_STATUS_INVALID_HANDLE;

    if (max_references > 16)
        return VDP_STATUS_ERROR;

    decoder_ctx_t *dec = handle_create(sizeof(*dec), decoder, htype_decoder);
    if (!dec)
        goto err_ctx;
    
    VDPAU_DBG("vdpau decoder=%d created", *decoder);

    memset(dec, 0, sizeof(*dec));
    dec->device = dev;
    dec->profile = profile;
    dec->width = width;
    dec->height = height;

    dec->data = cedarv_malloc(VBV_SIZE);
    if (! cedarv_isValid(dec->data))
        goto err_data;
    dec->data_pos = 0;

    VdpStatus ret;
    switch (profile)
    {
    case VDP_DECODER_PROFILE_MPEG1:
    case VDP_DECODER_PROFILE_MPEG2_SIMPLE:
    case VDP_DECODER_PROFILE_MPEG2_MAIN:
        ret = new_decoder_mpeg12(dec);
        break;

    case VDP_DECODER_PROFILE_H264_BASELINE:
    case VDP_DECODER_PROFILE_H264_MAIN:
    case VDP_DECODER_PROFILE_H264_HIGH:
        ret = new_decoder_h264(dec);
        break;

    case VDP_DECODER_PROFILE_MPEG4_PART2_SP:
        case VDP_DECODER_PROFILE_MPEG4_PART2_ASP:
    case VDP_DECODER_PROFILE_DIVX4_QMOBILE:
    case VDP_DECODER_PROFILE_DIVX4_MOBILE:
    case VDP_DECODER_PROFILE_DIVX4_HOME_THEATER:
    case VDP_DECODER_PROFILE_DIVX4_HD_1080P:
    case VDP_DECODER_PROFILE_DIVX5_QMOBILE:
    case VDP_DECODER_PROFILE_DIVX5_MOBILE:
    case VDP_DECODER_PROFILE_DIVX5_HOME_THEATER:
    case VDP_DECODER_PROFILE_DIVX5_HD_1080P:
        ret = new_decoder_mpeg4(dec);
        break;
    case VDP_DECODER_PROFILE_DIVX3_HD_1080P:
    case VDP_DECODER_PROFILE_DIVX3_QMOBILE:
    case VDP_DECODER_PROFILE_DIVX3_MOBILE:
    case VDP_DECODER_PROFILE_DIVX3_HOME_THEATER:
        ret = new_decoder_msmpeg4(dec);
        break;
    default:
        ret = VDP_STATUS_INVALID_DECODER_PROFILE;
        break;
    }

    if (ret != VDP_STATUS_OK)
        goto err_decoder;

    handle_release(device);
    return VDP_STATUS_OK;

err_handle:
    if (dec->private_free)
        dec->private_free(dec);
err_decoder:
    cedarv_free(dec->data);
err_data:
    handle_destroy(*decoder);
err_ctx:
    handle_release(device);
    return VDP_STATUS_RESOURCES;
}
Example #10
0
VdpStatus vdp_video_surface_create(VdpDevice device, VdpChromaType chroma_type, uint32_t width, uint32_t height, VdpVideoSurface *surface)
{
   if (!surface)
      return VDP_STATUS_INVALID_POINTER;
   
   if (!width || !height)
      return VDP_STATUS_INVALID_SIZE;
   
   device_ctx_t *dev = handle_get(device);
   if (!dev)
      return VDP_STATUS_INVALID_HANDLE;
   
   video_surface_ctx_t *vs = handle_create(sizeof(*vs), surface, htype_video);
   if (!vs)
      return VDP_STATUS_RESOURCES;
   
   VDPAU_DBG("vdpau video surface=%d created", *surface);

   vs->device = dev;
   vs->width = width;
   vs->height = height;
   vs->chroma_type = chroma_type;
   
   vs->stride_width 	= (width + 63) & ~63;
   vs->stride_height 	= (height + 63) & ~63;
   vs->plane_size 	= vs->stride_width * vs->stride_height;
   cedarv_setBufferInvalid(vs->dataY);
   cedarv_setBufferInvalid(vs->dataU);
   cedarv_setBufferInvalid(vs->dataV);
   
   switch (chroma_type)
   {
   case VDP_CHROMA_TYPE_444:
      //vs->data = cedarv_malloc(vs->plane_size * 3);
      vs->dataY = cedarv_malloc(vs->plane_size);
      vs->dataU = cedarv_malloc(vs->plane_size);
      vs->dataV = cedarv_malloc(vs->plane_size);
      if (! cedarv_isValid(vs->dataY) || ! cedarv_isValid(vs->dataU) || ! cedarv_isValid(vs->dataV))
      {
	  printf("vdpau video surface=%d create, failure\n", *surface);

	  handle_destroy(*surface);
          handle_release(device);
	  return VDP_STATUS_RESOURCES;
      }
      break;
   case VDP_CHROMA_TYPE_422:
      //vs->data = cedarv_malloc(vs->plane_size * 2);
      vs->dataY = cedarv_malloc(vs->plane_size);
      vs->dataU = cedarv_malloc(vs->plane_size/2);
      vs->dataV = cedarv_malloc(vs->plane_size/2);
      if (! cedarv_isValid(vs->dataY) || ! cedarv_isValid(vs->dataU) || ! cedarv_isValid(vs->dataV))
      {
	  printf("vdpau video surface=%d create, failure\n", *surface);

	  handle_destroy(*surface);
          handle_release(device);
	  return VDP_STATUS_RESOURCES;
      }
      break;
   case VDP_CHROMA_TYPE_420:
      //vs->data = cedarv_malloc(vs->plane_size + (vs->plane_size / 2));
      vs->dataY = cedarv_malloc(vs->plane_size);
      vs->dataU = cedarv_malloc(vs->plane_size/2);
      if (! cedarv_isValid(vs->dataY) || ! cedarv_isValid(vs->dataU))
      {
	  printf("vdpau video surface=%d create, failure\n", *surface);

	  handle_destroy(*surface);
          handle_release(device);
	  return VDP_STATUS_RESOURCES;
      }
      
      break;
   default:
      free(vs);
      handle_release(device);
      return VDP_STATUS_INVALID_CHROMA_TYPE;
   }
   handle_release(device);
   
   return VDP_STATUS_OK;
}