IoCairoSVGSurface *IoCairoSVGSurface_rawClone(IoCairoSVGSurface *proto) { IoObject *self = IoObject_rawClonePrimitive(proto); if (SURFACE(proto)) IoObject_setDataPointer_(self, cairo_surface_reference(SURFACE(proto))); return self; }
static VAStatus intel_encoder_check_avc_parameter(VADriverContextP ctx, struct encode_state *encode_state, struct intel_encoder_context *encoder_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct object_surface *obj_surface; struct object_buffer *obj_buffer; VAEncPictureParameterBufferH264 *pic_param = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer; int i; assert(!(pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID)); if (pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID) goto error; obj_surface = SURFACE(pic_param->CurrPic.picture_id); assert(obj_surface); /* It is possible the store buffer isn't allocated yet */ if (!obj_surface) goto error; encode_state->reconstructed_object = obj_surface; obj_buffer = BUFFER(pic_param->coded_buf); assert(obj_buffer && obj_buffer->buffer_store && obj_buffer->buffer_store->bo); if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo) goto error; encode_state->coded_buf_object = obj_buffer; for (i = 0; i < 16; i++) { if (pic_param->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID || pic_param->ReferenceFrames[i].picture_id == VA_INVALID_SURFACE) break; else { obj_surface = SURFACE(pic_param->ReferenceFrames[i].picture_id); assert(obj_surface); if (!obj_surface) goto error; if (obj_surface->bo) encode_state->reference_objects[i] = obj_surface; else encode_state->reference_objects[i] = NULL; /* FIXME: Warning or Error ??? */ } } for ( ; i < 16; i++) encode_state->reference_objects[i] = NULL; return VA_STATUS_SUCCESS; error: return VA_STATUS_ERROR_INVALID_PARAMETER; }
static VAStatus lnc__MPEG4ES_process_picture_param(context_ENC_p ctx, object_buffer_p obj_buffer) { VAStatus vaStatus = VA_STATUS_SUCCESS; VAEncPictureParameterBufferMPEG4 *pBuffer; lnc_cmdbuf_p cmdbuf = ctx->obj_context->lnc_cmdbuf; IMG_BOOL bIsVOPCoded = IMG_TRUE; ASSERT(obj_buffer->type == VAEncPictureParameterBufferType); if ((obj_buffer->num_elements != 1) || (obj_buffer->size != sizeof(VAEncPictureParameterBufferMPEG4))) { return VA_STATUS_ERROR_UNKNOWN; } /* Transfer ownership of VAEncPictureParameterBufferMPEG4 data */ pBuffer = (VAEncPictureParameterBufferMPEG4 *) obj_buffer->buffer_data; obj_buffer->buffer_data = NULL; obj_buffer->size = 0; ctx->ref_surface = SURFACE(pBuffer->reference_picture); ctx->dest_surface = SURFACE(pBuffer->reconstructed_picture); ctx->coded_buf = BUFFER(pBuffer->coded_buf); ASSERT(ctx->Width == pBuffer->picture_width); ASSERT(ctx->Height == pBuffer->picture_height); if (ctx->sRCParams.RCEnable && ctx->sRCParams.FrameSkip) bIsVOPCoded = IMG_FALSE; /* save current cmdbuf write pointer for MPEG4 frameskip redo * MPEG4 picture header need re-patch, and no slice header needed * for a skipped frame */ cmdbuf->cmd_idx_saved_frameskip = cmdbuf->cmd_idx; lnc__MPEG4_prepare_vop_header((IMG_UINT32 *)(cmdbuf->header_mem_p + ctx->pic_header_ofs), bIsVOPCoded, pBuffer->vop_time_increment, /* In testbench, this should be FrameNum */ 4,/* default value is 4,search range */ pBuffer->picture_type, ctx->MPEG4_vop_time_increment_resolution/* defaule value */); lnc_cmdbuf_insert_command(cmdbuf, MTX_CMDID_DO_HEADER, 2, 1); RELOC_CMDBUF(cmdbuf->cmd_idx++, ctx->pic_header_ofs, &cmdbuf->header_mem); vaStatus = lnc_RenderPictureParameter(ctx); free(pBuffer); return vaStatus; }
static VAStatus intel_decoder_check_vc1_parameter(VADriverContextP ctx, struct decode_state *decode_state) { struct i965_driver_data *i965 = i965_driver_data(ctx); VAPictureParameterBufferVC1 *pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer; struct object_surface *obj_surface; int i = 0; if (pic_param->sequence_fields.bits.interlace == 1 && pic_param->picture_fields.bits.frame_coding_mode != 0) { /* frame-interlace or field-interlace */ return VA_STATUS_ERROR_DECODING_ERROR; } if (pic_param->picture_fields.bits.picture_type == 0 || pic_param->picture_fields.bits.picture_type == 3) { } else if (pic_param->picture_fields.bits.picture_type == 1 || pic_param->picture_fields.bits.picture_type == 4) { obj_surface = SURFACE(pic_param->forward_reference_picture); if (!obj_surface || !obj_surface->bo) decode_state->reference_objects[i++] = NULL; else decode_state->reference_objects[i++] = obj_surface; } else if (pic_param->picture_fields.bits.picture_type == 2) { obj_surface = SURFACE(pic_param->forward_reference_picture); if (!obj_surface || !obj_surface->bo) decode_state->reference_objects[i++] = NULL; else decode_state->reference_objects[i++] = obj_surface; obj_surface = SURFACE(pic_param->backward_reference_picture); if (!obj_surface || !obj_surface->bo) decode_state->reference_objects[i++] = NULL; else decode_state->reference_objects[i++] = obj_surface; } else goto error; for ( ; i < 16; i++) decode_state->reference_objects[i] = NULL; return VA_STATUS_SUCCESS; error: return VA_STATUS_ERROR_INVALID_PARAMETER; }
IoObject *IoCairoSurface_getDeviceOffset(IoCairoSurface *self, IoObject *locals, IoMessage *m) { double x = 0, y = 0; cairo_surface_get_device_offset(SURFACE(self), &x, &y); CHECK_STATUS(self); return IoSeq_newWithX_y_(IOSTATE, x, y); }
IoObject *IoCairoSurface_setFallbackResolution(IoCairoSurface *self, IoObject *locals, IoMessage *m) { double x = IoMessage_locals_doubleArgAt_(m, locals, 0); double y = IoMessage_locals_doubleArgAt_(m, locals, 1); cairo_surface_set_fallback_resolution(SURFACE(self), x, y); CHECK_STATUS(self); return self; }
IoObject *IoCairoSurface_setDeviceOffset(IoCairoSurface *self, IoObject *locals, IoMessage *m) { double x = IoMessage_locals_doubleArgAt_(m, locals, 0); double y = IoMessage_locals_doubleArgAt_(m, locals, 1); cairo_surface_set_device_offset(SURFACE(self), x, y); CHECK_STATUS(self); return self; }
IoObject *IoCairoPDFSurface_setSize(IoCairoPDFSurface *self, IoObject *locals, IoMessage *m) { double w = IoMessage_locals_doubleArgAt_(m, locals, 0); double h = IoMessage_locals_doubleArgAt_(m, locals, 1); cairo_pdf_surface_set_size(SURFACE(self), w, h); CHECK_STATUS(self); return self; }
IoObject *IoCairoSurface_createSimilar(IoCairoSurface *self, IoObject *locals, IoMessage *m) { cairo_content_t content = IoMessage_locals_intArgAt_(m, locals, 0); int w = IoMessage_locals_intArgAt_(m, locals, 1); int h = IoMessage_locals_intArgAt_(m, locals, 2); cairo_surface_t *surface = cairo_surface_create_similar(SURFACE(self), content, w, h); return IoCairoSurface_newWithRawSurface_(IOSTATE, m, surface); }
VAStatus intel_decoder_sanity_check_input(VADriverContextP ctx, VAProfile profile, struct decode_state *decode_state) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct object_surface *obj_surface; VAStatus vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; if (decode_state->current_render_target == VA_INVALID_SURFACE) goto out; obj_surface = SURFACE(decode_state->current_render_target); if (!obj_surface) goto out; decode_state->render_object = obj_surface; switch (profile) { case VAProfileMPEG2Simple: case VAProfileMPEG2Main: vaStatus = intel_decoder_check_mpeg2_parameter(ctx, decode_state); break; case VAProfileH264ConstrainedBaseline: case VAProfileH264Main: case VAProfileH264High: case VAProfileH264StereoHigh: case VAProfileH264MultiviewHigh: vaStatus = intel_decoder_check_avc_parameter(ctx, profile, decode_state); break; case VAProfileVC1Simple: case VAProfileVC1Main: case VAProfileVC1Advanced: vaStatus = intel_decoder_check_vc1_parameter(ctx, decode_state); break; case VAProfileJPEGBaseline: vaStatus = VA_STATUS_SUCCESS; break; case VAProfileVP8Version0_3: vaStatus = intel_decoder_check_vp8_parameter(ctx, decode_state); break; default: vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; break; } out: return vaStatus; }
static VAStatus intel_decoder_check_mpeg2_parameter(VADriverContextP ctx, struct decode_state *decode_state) { struct i965_driver_data *i965 = i965_driver_data(ctx); VAPictureParameterBufferMPEG2 *pic_param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer; struct object_surface *obj_surface; int i = 0; if (pic_param->picture_coding_type == MPEG_I_PICTURE) { } else if (pic_param->picture_coding_type == MPEG_P_PICTURE) { obj_surface = SURFACE(pic_param->forward_reference_picture); if (!obj_surface || !obj_surface->bo) decode_state->reference_objects[i++] = NULL; else decode_state->reference_objects[i++] = obj_surface; } else if (pic_param->picture_coding_type == MPEG_B_PICTURE) { obj_surface = SURFACE(pic_param->forward_reference_picture); if (!obj_surface || !obj_surface->bo) decode_state->reference_objects[i++] = NULL; else decode_state->reference_objects[i++] = obj_surface; obj_surface = SURFACE(pic_param->backward_reference_picture); if (!obj_surface || !obj_surface->bo) decode_state->reference_objects[i++] = NULL; else decode_state->reference_objects[i++] = obj_surface; } else goto error; for ( ; i < 16; i++) decode_state->reference_objects[i] = NULL; return VA_STATUS_SUCCESS; error: return VA_STATUS_ERROR_INVALID_PARAMETER; }
IoObject *IoCairoSurface_markDirtyRectangle(IoCairoSurface *self, IoObject *locals, IoMessage *m) { double x = IoMessage_locals_doubleArgAt_(m, locals, 0); double y = IoMessage_locals_doubleArgAt_(m, locals, 1); double w = IoMessage_locals_doubleArgAt_(m, locals, 2); double h = IoMessage_locals_doubleArgAt_(m, locals, 3); cairo_surface_mark_dirty_rectangle(SURFACE(self), x, y, w, h); CHECK_STATUS(self); return self; }
static VAStatus intel_decoder_check_vp8_parameter(VADriverContextP ctx, struct decode_state *decode_state) { struct i965_driver_data *i965 = i965_driver_data(ctx); VAPictureParameterBufferVP8 *pic_param = (VAPictureParameterBufferVP8 *)decode_state->pic_param->buffer; struct object_surface *obj_surface; int i = 0; if (pic_param->last_ref_frame != VA_INVALID_SURFACE) { obj_surface = SURFACE(pic_param->last_ref_frame); if (obj_surface && obj_surface->bo) decode_state->reference_objects[i++] = obj_surface; else decode_state->reference_objects[i++] = NULL; } if (pic_param->golden_ref_frame != VA_INVALID_SURFACE) { obj_surface = SURFACE(pic_param->golden_ref_frame); if (obj_surface && obj_surface->bo) decode_state->reference_objects[i++] = obj_surface; else decode_state->reference_objects[i++] = NULL; } if (pic_param->alt_ref_frame != VA_INVALID_SURFACE) { obj_surface = SURFACE(pic_param->alt_ref_frame); if (obj_surface && obj_surface->bo) decode_state->reference_objects[i++] = obj_surface; else decode_state->reference_objects[i++] = NULL; } for ( ; i < 16; i++) decode_state->reference_objects[i] = NULL; return VA_STATUS_SUCCESS; }
//#define DEBUG VAStatus media_sync_surface (MEDIA_DRV_CONTEXT * drv_ctx, VASurfaceID render_target) { struct object_surface *obj_surface = SURFACE (render_target); MEDIA_DRV_ASSERT (obj_surface); if (obj_surface->bo) drm_intel_bo_wait_rendering (obj_surface->bo); return VA_STATUS_SUCCESS; }
int dcTriListCollider::dSortedTriSphere(const dReal* /**v1/**/,const dReal* /**v2/**/, const dReal* triAx, CDB::TRI* T, dReal dist, dxGeom* Sphere, dxGeom* Geometry, int Flags, dContactGeom* Contacts, int skip ){ //const dReal* v1=(dReal*)T->verts[1]; //const dReal* v2=(dReal*)T->verts[2]; const dReal* SphereCenter=dGeomGetPosition(Sphere); const float SphereRadius = dGeomSphereGetRadius(Sphere); // dNormalize3(triAx); const dReal *ContactNormal=triAx;//{triAx[0],triAx[1],triAx[2]}; dVector3 ContactPos={SphereCenter[0]-triAx[0]* SphereRadius,SphereCenter[1]-triAx[1]* SphereRadius,SphereCenter[2]-triAx[2]* SphereRadius}; float ContactDepth= -dist + SphereRadius; if (ContactDepth >= 0){ Contacts->normal[0] =-ContactNormal[0]; Contacts->normal[1] =-ContactNormal[1]; Contacts->normal[2] =-ContactNormal[2]; Contacts->depth = ContactDepth; //////////////////// Contacts->pos[0]=ContactPos[0]; Contacts->pos[1]=ContactPos[1]; Contacts->pos[2]=ContactPos[2]; Contacts->g1 = Geometry; Contacts->g2 = Sphere; ((dxGeomUserData*)dGeomGetData(Sphere))->tri_material=T->material; if(dGeomGetUserData(Sphere)->callback)dGeomGetUserData(Sphere)->callback(T,Contacts); SURFACE(Contacts,0)->mode=T->material; ////////////////////////////////// return 1; } return 0; }
VAStatus rockchip_PutImage( VADriverContextP ctx, VASurfaceID surface, VAImageID image, int src_x, int src_y, unsigned int src_width, unsigned int src_height, int dest_x, int dest_y, unsigned int dest_width, unsigned int dest_height ) { INIT_DRIVER_DATA object_surface_p obj_surface = SURFACE(surface); if (!obj_surface) return VA_STATUS_ERROR_INVALID_SURFACE; object_image_p obj_image = IMAGE(image); if (!obj_image) return VA_STATUS_ERROR_INVALID_IMAGE; VAImage *src = &obj_image->image; VAImage *dst = &obj_surface->image; /** * TODO: support more format */ if (src->format.fourcc != dst->format.fourcc) { return VA_STATUS_ERROR_UNIMPLEMENTED; } void *src_buf, *dst_buf; rockchip_MapBuffer(ctx, src->buf, &src_buf); rockchip_MapBuffer(ctx, dst->buf, &dst_buf); memcpy(dst_buf, src_buf, src->data_size); rockchip_UnmapBuffer(ctx, src->buf); rockchip_UnmapBuffer(ctx, dst->buf); return VA_STATUS_SUCCESS; }
/* Set reference surface if backing store exists */ static inline int set_ref_frame( struct i965_driver_data *i965, GenFrameStore *ref_frame, VASurfaceID va_surface ) { struct object_surface *obj_surface; if (va_surface == VA_INVALID_ID) return 0; obj_surface = SURFACE(va_surface); if (!obj_surface || !obj_surface->bo) return 0; ref_frame->surface_id = va_surface; return 1; }
VAStatus rockchip_DeriveImage( VADriverContextP ctx, VASurfaceID surface, VAImage *image ) { INIT_DRIVER_DATA object_surface_p obj_surface = SURFACE(surface); if (!obj_surface) return VA_STATUS_ERROR_INVALID_SURFACE; object_image_p obj_image = IMAGE(obj_surface->image.image_id); if (!obj_image) return VA_STATUS_ERROR_INVALID_IMAGE; *image = obj_image->image; ++obj_image->ref_cnt; return VA_STATUS_SUCCESS; }
VAStatus rockchip_GetImage( VADriverContextP ctx, VASurfaceID surface, int x, int y, unsigned int width, unsigned int height, VAImageID image ) { INIT_DRIVER_DATA object_surface_p obj_surface = SURFACE(surface); if (!obj_surface) return VA_STATUS_ERROR_INVALID_SURFACE; object_image_p obj_image = IMAGE(image); if (!obj_image) return VA_STATUS_ERROR_INVALID_IMAGE; return VA_STATUS_ERROR_UNIMPLEMENTED; }
static VAStatus psb_putsurface_ctexture( VADriverContextP ctx, VASurfaceID surface, unsigned char* data, short srcx, short srcy, unsigned short srcw, unsigned short srch, short destx, short desty, unsigned short destw, unsigned short desth, unsigned int __maybe_unused flags /* de-interlacing flags */ ) { INIT_DRIVER_DATA; INIT_OUTPUT_PRIV; object_surface_p obj_surface; int offset = 0; psb_surface_p psb_surface; VAStatus vaStatus = VA_STATUS_SUCCESS; obj_surface = SURFACE(surface); CHECK_SURFACE(obj_surface); psb_surface = obj_surface->psb_surface; // psb_surface->buf.drm_buf; // psb_surface->buf.pl_flags; psb_putsurface_textureblit(ctx, data, surface, srcx, srcy, srcw, srch, destx, desty, destw, desth, 0, /* no subtitle */ obj_surface->width, obj_surface->height, psb_surface->stride, psb_surface->buf.drm_buf, psb_surface->buf.pl_flags, 1 /* need wrap dst */); psb_android_postBuffer(offset); return VA_STATUS_SUCCESS; }
void psb_RecalcAlternativeOutput(object_context_p obj_context) { psb_driver_data_p driver_data = obj_context->driver_data; object_surface_p obj_surface = obj_context->current_render_target; int angle, new_rotate, i; int old_rotate = driver_data->msvdx_rotate_want; int mode = INIT_VALUE; #ifdef TARGET_HAS_MULTIPLE_DISPLAY mode = psb_android_get_mds_mode((void*)driver_data->ws_priv); #endif if (mode != INIT_VALUE) { // clear device rotation info if (driver_data->mipi0_rotation != VA_ROTATION_NONE) { driver_data->mipi0_rotation = VA_ROTATION_NONE; driver_data->hdmi_rotation = VA_ROTATION_NONE; } // Disable msvdx rotation if // WIDI video is play and meta data rotation angle is 0 if (mode == WIDI_VIDEO_ISPLAYING) { if (driver_data->va_rotate == VA_ROTATION_NONE) driver_data->disable_msvdx_rotate = 1; else { driver_data->mipi0_rotation = 0; driver_data->hdmi_rotation = 0; driver_data->disable_msvdx_rotate = 0; } } else { if (IS_MOFD(driver_data)) driver_data->disable_msvdx_rotate = 1; else driver_data->disable_msvdx_rotate = driver_data->disable_msvdx_rotate_backup; } } else if (IS_MOFD(driver_data)) { /* Moorefield has overlay rotaion, so decoder doesn't generate rotation * output according to windows manager. It is controlled by payload info * in which HWC signal decoder to generate rotation output */ long long hwc_timestamp = 0; int index = -1; for (i = 0; i < obj_context->num_render_targets; i++) { object_surface_p obj_surface = SURFACE(obj_context->render_targets[i]); /* traverse all surfaces' share info to find out the latest transform info */ if (obj_surface && obj_surface->share_info) { if (obj_surface->share_info->hwc_timestamp > hwc_timestamp) { hwc_timestamp = obj_surface->share_info->hwc_timestamp; index = i; } } } if (index >= 0) { object_surface_p obj_surface = SURFACE(obj_context->render_targets[index]); if (obj_surface && obj_surface->share_info) { int transform = obj_surface->share_info->layer_transform; driver_data->mipi0_rotation = HAL2VAROTATION(transform); drv_debug_msg(VIDEO_DEBUG_GENERAL, "Signal from HWC to rotate %d\n", driver_data->mipi0_rotation); } } } else if (driver_data->native_window) { int display_rotate = 0; psb_android_surfaceflinger_rotate(driver_data->native_window, &display_rotate); drv_debug_msg(VIDEO_DEBUG_GENERAL, "NativeWindow(0x%x), get surface flinger rotate %d\n", driver_data->native_window, display_rotate); if (driver_data->mipi0_rotation != display_rotate) { driver_data->mipi0_rotation = display_rotate; } } else { long long hwc_timestamp = 0; int index = -1; for (i = 0; i < obj_context->num_render_targets; i++) { object_surface_p obj_surface = SURFACE(obj_context->render_targets[i]); /* traverse all surfaces' share info to find out the latest transform info */ if (obj_surface && obj_surface->share_info) { if (obj_surface->share_info->hwc_timestamp > hwc_timestamp) { hwc_timestamp = obj_surface->share_info->hwc_timestamp; index = i; } } } if (index >= 0) { object_surface_p obj_surface = SURFACE(obj_context->render_targets[index]); if (obj_surface && obj_surface->share_info) { int transform = obj_surface->share_info->layer_transform; driver_data->mipi0_rotation = HAL2VAROTATION(transform); } } } #ifdef PSBVIDEO_MRFL if ((mode == HDMI_VIDEO_ISPLAYING) && driver_data->native_window) { int display_rotate = 0; psb_android_surfaceflinger_rotate(driver_data->native_window, &display_rotate); drv_debug_msg(VIDEO_DEBUG_GENERAL, "NativeWindow(0x%x), get surface flinger rotate %d\n", driver_data->native_window, display_rotate); if (driver_data->mipi0_rotation != display_rotate && !IS_MOFD(driver_data)) { driver_data->mipi0_rotation = display_rotate; } } #endif /* calc VA rotation and WM rotation, and assign to the final rotation degree */ angle = Rotation2Angle(driver_data->va_rotate) + Rotation2Angle(driver_data->mipi0_rotation); driver_data->local_rotation = Angle2Rotation(angle); angle = Rotation2Angle(driver_data->va_rotate) + Rotation2Angle(driver_data->hdmi_rotation); driver_data->extend_rotation = Angle2Rotation(angle); /* On MOFD, no need to use meta rotation, just use rotation angle signal from HWC */ if (IS_MOFD(driver_data)) { driver_data->local_rotation = driver_data->mipi0_rotation; driver_data->extend_rotation = Rotation2Angle(driver_data->hdmi_rotation); } /* for any case that local and extened rotation are not same, fallback to GPU */ if ((driver_data->mipi1_rotation != VA_ROTATION_NONE) || ((driver_data->local_rotation != VA_ROTATION_NONE) && (driver_data->extend_rotation != VA_ROTATION_NONE) && (driver_data->local_rotation != driver_data->extend_rotation))) { new_rotate = ROTATE_VA2MSVDX(driver_data->local_rotation); if (driver_data->is_android == 0) /*fallback to texblit path*/ driver_data->output_method = PSB_PUTSURFACE_CTEXTURE; } else { if (driver_data->local_rotation == VA_ROTATION_NONE) new_rotate = driver_data->extend_rotation; else new_rotate = driver_data->local_rotation; if (driver_data->is_android == 0) { if (driver_data->output_method != PSB_PUTSURFACE_FORCE_CTEXTURE) driver_data->output_method = PSB_PUTSURFACE_COVERLAY; } } if (old_rotate != new_rotate) { drv_debug_msg(VIDEO_DEBUG_GENERAL, "MSVDX: new rotation %d desired\n", new_rotate); driver_data->msvdx_rotate_want = new_rotate; } #ifdef TARGET_HAS_MULTIPLE_DISPLAY int scaling_buffer_width = 1920, scaling_buffer_height = 1080 ; int scaling_width = 0, scaling_height = 0; int scaling_offset_x = 0, scaling_offset_y = 0; int old_bufw = 0, old_bufh = 0, old_x = 0, old_y = 0, old_w = 0, old_h = 0; int bScaleChanged = 0, size = 0; unsigned char * surface_data; int ret = psb_android_get_mds_decoder_output_resolution( (void*)driver_data->ws_priv, &scaling_width, &scaling_height, &scaling_offset_x, &scaling_offset_y, &scaling_buffer_width, &scaling_buffer_height); if ((old_bufw != scaling_buffer_width) || (old_bufh != scaling_buffer_height) || (old_x != scaling_offset_x) || (old_y != scaling_offset_y) || (old_w != scaling_width) || (old_h != scaling_height)) { bScaleChanged = 1; } old_x = scaling_offset_x; old_y = scaling_offset_y; old_w = scaling_width; old_h = scaling_height; old_bufw = scaling_buffer_width; old_bufh = scaling_buffer_height; /* turn off ved downscaling if width and height are 0. * Besides, scaling_width and scaling_height must be a multiple of 2. */ if (!ret || (!scaling_width || !scaling_height) || (scaling_width & 1) || (scaling_height & 1)) { obj_context->msvdx_scaling = 0; obj_context->scaling_width = 0; obj_context->scaling_height = 0; obj_context->scaling_offset_x= 0; obj_context->scaling_offset_y = 0; obj_context->scaling_buffer_width = 0; obj_context->scaling_buffer_height = 0; } else { obj_context->msvdx_scaling = 1; obj_context->scaling_width = scaling_width; obj_context->scaling_height = scaling_height; obj_context->scaling_offset_x= scaling_offset_x; obj_context->scaling_offset_y = scaling_offset_y; obj_context->scaling_buffer_width = scaling_buffer_width; obj_context->scaling_buffer_height = scaling_buffer_height; } if (bScaleChanged) { if ((obj_surface != NULL) && (obj_surface->out_loop_surface != NULL)) { if (psb_buffer_map(&obj_surface->out_loop_surface->buf, &surface_data)) { drv_debug_msg(VIDEO_DEBUG_ERROR, "Failed to map rotation buffer before clear it"); } else { size = obj_surface->out_loop_surface->chroma_offset; memset(surface_data, 0, size); memset(surface_data + size, 0x80, obj_surface->out_loop_surface->size - size); psb_buffer_unmap(&obj_context->current_render_target->out_loop_surface->buf); } } } #endif }
static VAStatus intel_encoder_check_yuv_surface(VADriverContextP ctx, VAProfile profile, struct encode_state *encode_state, struct intel_encoder_context *encoder_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_surface src_surface, dst_surface; struct object_surface *obj_surface; VAStatus status; VARectangle rect; /* releae the temporary surface */ if (encoder_context->is_tmp_id) { i965_DestroySurfaces(ctx, &encoder_context->input_yuv_surface, 1); encode_state->input_yuv_object = NULL; } encoder_context->is_tmp_id = 0; obj_surface = SURFACE(encode_state->current_render_target); assert(obj_surface && obj_surface->bo); if (!obj_surface || !obj_surface->bo) return VA_STATUS_ERROR_INVALID_PARAMETER; if (obj_surface->fourcc == VA_FOURCC_NV12) { unsigned int tiling = 0, swizzle = 0; dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle); if (tiling == I915_TILING_Y) { encoder_context->input_yuv_surface = encode_state->current_render_target; encode_state->input_yuv_object = obj_surface; return VA_STATUS_SUCCESS; } } rect.x = 0; rect.y = 0; rect.width = obj_surface->orig_width; rect.height = obj_surface->orig_height; src_surface.base = (struct object_base *)obj_surface; src_surface.type = I965_SURFACE_TYPE_SURFACE; src_surface.flags = I965_SURFACE_FLAG_FRAME; status = i965_CreateSurfaces(ctx, obj_surface->orig_width, obj_surface->orig_height, VA_RT_FORMAT_YUV420, 1, &encoder_context->input_yuv_surface); assert(status == VA_STATUS_SUCCESS); if (status != VA_STATUS_SUCCESS) return status; obj_surface = SURFACE(encoder_context->input_yuv_surface); encode_state->input_yuv_object = obj_surface; assert(obj_surface); i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC_NV12, SUBSAMPLE_YUV420); dst_surface.base = (struct object_base *)obj_surface; dst_surface.type = I965_SURFACE_TYPE_SURFACE; dst_surface.flags = I965_SURFACE_FLAG_FRAME; status = i965_image_processing(ctx, &src_surface, &rect, &dst_surface, &rect); assert(status == VA_STATUS_SUCCESS); encoder_context->is_tmp_id = 1; return VA_STATUS_SUCCESS; }
static VAStatus intel_encoder_check_mpeg2_parameter(VADriverContextP ctx, struct encode_state *encode_state, struct intel_encoder_context *encoder_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); VAEncPictureParameterBufferMPEG2 *pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer; struct object_surface *obj_surface; struct object_buffer *obj_buffer; int i = 0; obj_surface = SURFACE(pic_param->reconstructed_picture); assert(obj_surface); /* It is possible the store buffer isn't allocated yet */ if (!obj_surface) goto error; encode_state->reconstructed_object = obj_surface; obj_buffer = BUFFER(pic_param->coded_buf); assert(obj_buffer && obj_buffer->buffer_store && obj_buffer->buffer_store->bo); if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo) goto error; encode_state->coded_buf_object = obj_buffer; if (pic_param->picture_type == VAEncPictureTypeIntra) { } else if (pic_param->picture_type == VAEncPictureTypePredictive) { assert(pic_param->forward_reference_picture != VA_INVALID_SURFACE); obj_surface = SURFACE(pic_param->forward_reference_picture); assert(obj_surface && obj_surface->bo); if (!obj_surface || !obj_surface->bo) goto error; encode_state->reference_objects[i++] = obj_surface; } else if (pic_param->picture_type == VAEncPictureTypeBidirectional) { assert(pic_param->forward_reference_picture != VA_INVALID_SURFACE); obj_surface = SURFACE(pic_param->forward_reference_picture); assert(obj_surface && obj_surface->bo); if (!obj_surface || !obj_surface->bo) goto error; encode_state->reference_objects[i++] = obj_surface; assert(pic_param->backward_reference_picture != VA_INVALID_SURFACE); obj_surface = SURFACE(pic_param->backward_reference_picture); assert(obj_surface && obj_surface->bo); if (!obj_surface || !obj_surface->bo) goto error; encode_state->reference_objects[i++] = obj_surface; } else goto error; for ( ; i < 16; i++) encode_state->reference_objects[i] = NULL; return VA_STATUS_SUCCESS; error: return VA_STATUS_ERROR_INVALID_PARAMETER; }
IoObject *IoCairoSurface_getContent(IoCairoSurface *self, IoObject *locals, IoMessage *m) { return IONUMBER(cairo_surface_get_content(SURFACE(self))); }
static VAStatus vsp_vp8_process_picture_param( psb_driver_data_p driver_data, context_VPP_p ctx, object_buffer_p obj_buffer, VASurfaceID surface_id) { VAStatus vaStatus = VA_STATUS_SUCCESS; vsp_cmdbuf_p cmdbuf = ctx->obj_context->vsp_cmdbuf; VAEncPictureParameterBufferVP8 *va_pic = (VAEncPictureParameterBufferVP8 *) obj_buffer->buffer_data; struct VssVp8encPictureParameterBuffer *pic = (struct VssVp8encPictureParameterBuffer *)cmdbuf->pic_param_p; struct VssVp8encSequenceParameterBuffer *seq = (struct VssVp8encSequenceParameterBuffer *)cmdbuf->seq_param_p; int ref_frame_width, ref_frame_height; vp8_fw_pic_flags flags; ref_frame_width = (ctx->vp8_seq_param.frame_width + 2 * 32 + 63) & (~63); ref_frame_height = (ctx->vp8_seq_param.frame_height + 2 * 32 + 63) & (~63); //map parameters object_buffer_p pObj = BUFFER(va_pic->coded_buf); //tobe modified if (!pObj) return VA_STATUS_ERROR_UNKNOWN; object_surface_p src_surface = SURFACE(surface_id); pic->input_frame.surface_id = surface_id; pic->input_frame.irq = 1; pic->input_frame.height = ctx->vp8_seq_param.frame_height; pic->input_frame.width = ctx->vp8_seq_param.frame_width; /* NOTE: In VIED API doc, stride must be the nearest integer multiple of 32 */ /* use vaCreateSurfaceWithAttribute with VAExternalMemoryNULL to create surface*/ //pic->input_frame.stride = (ctx->frame_width + 31) & (~31); pic->input_frame.stride = ctx->obj_context->current_render_target->psb_surface->stride; pic->input_frame.format = 0; /* TODO: Specify NV12 = 0 */ pic->recon_frame.irq = 0; pic->recon_frame.width = ref_frame_width; pic->recon_frame.height = ref_frame_height; pic->version = 0; flags.value = 0; flags.bits.force_kf = va_pic->ref_flags.bits.force_kf; flags.bits.no_ref_last = va_pic->ref_flags.bits.no_ref_last; flags.bits.no_ref_gf = va_pic->ref_flags.bits.no_ref_gf; flags.bits.no_ref_arf = va_pic->ref_flags.bits.no_ref_arf; flags.bits.upd_last = va_pic->pic_flags.bits.refresh_last; flags.bits.upd_gf = va_pic->pic_flags.bits.copy_buffer_to_golden; flags.bits.upd_arf = va_pic->pic_flags.bits.copy_buffer_to_alternate; flags.bits.no_upd_last = !va_pic->pic_flags.bits.refresh_last; flags.bits.no_upd_gf = !va_pic->pic_flags.bits.refresh_golden_frame; flags.bits.no_upd_arf = !va_pic->pic_flags.bits.refresh_alternate_frame; flags.bits.upd_entropy = va_pic->pic_flags.bits.refresh_entropy_probs; if (ctx->temporal_layer_number > 1) flags.bits.upd_entropy = 0; pic->pic_flags = flags.value; pic->prev_frame_dropped = 0; /* Not yet used */ pic->cpuused = 5; pic->sharpness = va_pic->sharpness_level; pic->num_token_partitions = va_pic->pic_flags.bits.num_token_partitions; /* 2^2 = 4 partitions */ pic->encoded_frame_size = pObj->size & ~31; pic->encoded_frame_base = (uint32_t)pObj->buffer_data; { vsp_cmdbuf_reloc_pic_param(&(pic->encoded_frame_base), ctx->pic_param_offset, pObj->psb_buffer, cmdbuf->param_mem_loc, pic); } { object_surface_p cur_surf = SURFACE(surface_id); if (!cur_surf) return VA_STATUS_ERROR_UNKNOWN; vsp_cmdbuf_reloc_pic_param(&(pic->input_frame.base), 0, &(cur_surf->psb_surface->buf), cmdbuf->param_mem_loc, pic); vsp_cmdbuf_reloc_pic_param(&(pic->input_frame.base_uv), pic->input_frame.stride * ctx->obj_context->current_render_target->height, &(cur_surf->psb_surface->buf), cmdbuf->param_mem_loc, pic); } *cmdbuf->cmd_idx++ = CONTEXT_VP8_ID; *cmdbuf->cmd_idx++ = VssVp8encEncodeFrameCommand; VSP_RELOC_CMDBUF(cmdbuf->cmd_idx++, ctx->pic_param_offset, &cmdbuf->param_mem); *cmdbuf->cmd_idx++ = sizeof(struct VssVp8encPictureParameterBuffer); *cmdbuf->cmd_idx++ = 0; *cmdbuf->cmd_idx++ = 0; *cmdbuf->cmd_idx++ = wsbmKBufHandle(wsbmKBuf(pObj->psb_buffer->drm_buf)) ; *cmdbuf->cmd_idx++ = wsbmKBufHandle(wsbmKBuf((&cmdbuf->param_mem)->drm_buf)); return vaStatus; }
static VAStatus vsp_vp8_process_seqence_param( psb_driver_data_p driver_data, context_VPP_p ctx, object_buffer_p obj_buffer) { VAStatus vaStatus = VA_STATUS_SUCCESS; vsp_cmdbuf_p cmdbuf = ctx->obj_context->vsp_cmdbuf; int i; int ref_frame_width, ref_frame_height, ref_chroma_height, ref_size; VAEncSequenceParameterBufferVP8 *va_seq = (VAEncSequenceParameterBufferVP8 *) obj_buffer->buffer_data; struct VssVp8encSequenceParameterBuffer *seq = &ctx->vp8_seq_param; struct VssVp8encSequenceParameterBuffer *seq_to_firmware = (struct VssVp8encSequenceParameterBuffer *)cmdbuf->seq_param_p; struct ref_frame_surface *ref = (struct ref_frame_surface*)cmdbuf->ref_param_p; seq->frame_width = va_seq->frame_width; seq->frame_height = va_seq->frame_height; seq->rc_target_bitrate = va_seq->bits_per_second / 1000; seq->max_intra_rate = 100 * ctx->max_frame_size / (va_seq->bits_per_second / seq->frame_rate); /* FIXME: API doc says max 5000, but for current default test vector we still use 6000 */ seq->kf_mode = va_seq->kf_auto; /* AUTO */ seq->kf_max_dist = va_seq->kf_max_dist; seq->kf_min_dist = va_seq->kf_min_dist; seq->error_resilient = va_seq->error_resilient; ref_frame_width = (seq->frame_width + 2 * 32 + 63) & (~63); ref_frame_height = (seq->frame_height + 2 * 32 + 63) & (~63); ref_chroma_height = (ref_frame_height / 2 + 63) & (~63); ref_size = ref_frame_width * (ref_frame_height + ref_chroma_height); for (i = 0; i < 4; i++) { seq->ref_frame_buffers[i].surface_id = va_seq->reference_frames[i]; seq->ref_frame_buffers[i].width = ref_frame_width; seq->ref_frame_buffers[i].height = ref_frame_height; } for (i = 0; i < 4; i++) { object_surface_p ref_surf = SURFACE(va_seq->reference_frames[i]); if (!ref_surf) return VA_STATUS_ERROR_UNKNOWN; ref_surf->is_ref_surface = 2; if (ref_surf->psb_surface->size < ref_size) { /* re-alloc buffer */ ref_surf->psb_surface->size = ref_size; psb_buffer_destroy(&ref_surf->psb_surface->buf); vaStatus = psb_buffer_create(driver_data, ref_surf->psb_surface->size, psb_bt_surface, &ref_surf->psb_surface->buf); if (VA_STATUS_SUCCESS != vaStatus) return VA_STATUS_ERROR_ALLOCATION_FAILED; } vsp_cmdbuf_reloc_pic_param(&(seq->ref_frame_buffers[i].base), 0, &(ref_surf->psb_surface->buf), cmdbuf->param_mem_loc, seq); } *seq_to_firmware = *seq; vsp_cmdbuf_insert_command(cmdbuf, CONTEXT_VP8_ID, &cmdbuf->param_mem, VssVp8encSetSequenceParametersCommand, ctx->seq_param_offset, sizeof(struct VssVp8encSequenceParameterBuffer)); ctx->vp8_seq_cmd_send = 1; return vaStatus; }
static VAStatus tng__yuv_processor_execute(context_DEC_p dec_ctx, object_buffer_p obj_buffer) { /* psb_surface_p target_surface = dec_ctx->obj_context->current_render_target->psb_surface; */ context_yuv_processor_p ctx = dec_ctx->yuv_ctx; uint32_t reg_value; VAStatus vaStatus; ASSERT(obj_buffer->type == YUVProcessorSurfaceType || obj_buffer->type == VAProcPipelineParameterBufferType); ASSERT(obj_buffer->num_elements == 1); ASSERT(obj_buffer->size == sizeof(struct surface_param_s)); if ((obj_buffer->num_elements != 1) || ((obj_buffer->size != sizeof(struct surface_param_s)) && (obj_buffer->size != sizeof(VAProcPipelineParameterBuffer)))) { return VA_STATUS_ERROR_UNKNOWN; } /* yuv rotation issued from dec driver, TODO removed later */ if (obj_buffer->type == YUVProcessorSurfaceType) { surface_param_p surface_params = (surface_param_p) obj_buffer->buffer_data; ctx->display_width = surface_params->display_width; ctx->display_height = surface_params->display_height; ctx->coded_width = surface_params->coded_width; ctx->coded_height = surface_params->coded_height; ctx->src_surface = dec_ctx->obj_context->current_render_target->psb_surface; ctx->proc_param = NULL; } else if (obj_buffer->type == VAProcPipelineParameterBufferType) { VAProcPipelineParameterBuffer *vpp_params = (VAProcPipelineParameterBuffer *) obj_buffer->buffer_data; object_surface_p obj_surface = SURFACE(vpp_params->surface); psb_surface_p rotate_surface = dec_ctx->obj_context->current_render_target->psb_surface; if (obj_surface == NULL){ vaStatus = VA_STATUS_ERROR_UNKNOWN; return vaStatus; } //ctx->display_width = ((vpp_params->surface_region->width + 0xf) & ~0xf); //ctx->display_height = ((vpp_params->surface_region->height + 0x1f) & ~0x1f); ctx->display_width = ((obj_surface->width + 0xf) & ~0xf); ctx->display_height = ((obj_surface->height + 0xf) & ~0xf); ctx->coded_width = ctx->display_width; ctx->coded_height = ctx->display_height; ctx->src_surface = obj_surface->psb_surface; #ifndef BAYTRAIL dec_ctx->obj_context->msvdx_rotate = vpp_params->rotation_state; #endif SET_SURFACE_INFO_rotate(rotate_surface, dec_ctx->obj_context->msvdx_rotate); ctx->proc_param = vpp_params; obj_buffer->buffer_data = NULL; obj_buffer->size = 0; #ifdef PSBVIDEO_MSVDX_DEC_TILING object_context_p obj_context = dec_ctx->obj_context; psb_driver_data_p driver_data = obj_context->driver_data; drv_debug_msg(VIDEO_DEBUG_GENERAL, "attempt to update tile context\n"); if (GET_SURFACE_INFO_tiling(ctx->src_surface)) { drv_debug_msg(VIDEO_DEBUG_GENERAL, "update tile context\n"); unsigned long msvdx_tile = psb__tile_stride_log2_256(rotate_surface->stride); obj_context->msvdx_tile &= 0xf; /* clear rotate tile */ obj_context->msvdx_tile |= (msvdx_tile << 4); obj_context->ctp_type &= (~PSB_CTX_TILING_MASK); /* clear tile context */ obj_context->ctp_type |= ((obj_context->msvdx_tile & 0xff) << 16); psb_update_context(driver_data, obj_context->ctp_type); LOGE("update tile context, msvdx_tiled is 0x%08x", obj_context->msvdx_tile); } #endif } #ifdef ADNROID LOGV("%s, %d %d %d %d***************************************************\n", __func__, ctx->display_width, ctx->display_height, ctx->coded_width, ctx->coded_height); #endif vaStatus = VA_STATUS_SUCCESS; if (psb_context_get_next_cmdbuf(dec_ctx->obj_context)) { vaStatus = VA_STATUS_ERROR_UNKNOWN; DEBUG_FAILURE; return vaStatus; } /* ctx->begin_slice(ctx, slice_param); */ vld_dec_FE_state(dec_ctx->obj_context, NULL); tng__yuv_processor_process(dec_ctx); /* ctx->process_slice(ctx, slice_param); */ vld_dec_write_kick(dec_ctx->obj_context); dec_ctx->obj_context->video_op = psb_video_vld; dec_ctx->obj_context->flags = 0; /* ctx->end_slice(ctx); */ dec_ctx->obj_context->flags = FW_VA_RENDER_IS_FIRST_SLICE | FW_VA_RENDER_IS_LAST_SLICE | FW_INTERNAL_CONTEXT_SWITCH; if (psb_context_submit_cmdbuf(dec_ctx->obj_context)) { vaStatus = VA_STATUS_ERROR_UNKNOWN; } return vaStatus; }
IoObject *IoCairoSurface_markDirty(IoCairoSurface *self, IoObject *locals, IoMessage *m) { cairo_surface_mark_dirty(SURFACE(self)); CHECK_STATUS(self); return self; }
IoObject *IoCairoSVGSurface_restrictToVersion(IoCairoSVGSurface *self, IoObject *locals, IoMessage *m) { cairo_svg_surface_restrict_to_version(SURFACE(self), IoMessage_locals_intArgAt_(m, locals, 0)); CHECK_STATUS(self); return self; }
int dcTriListCollider::dTriSphere(const dReal* v0,const dReal* v1,const dReal* v2, Triangle* T, dxGeom* Sphere,dxGeom* Geometry, int Flags, dContactGeom* Contacts,int /**skip/**/) { const dVector3 &triSideAx0 =T->side0 ; const dVector3 &triSideAx1 =T->side1 ; const dVector3 &triAx =T->norm ; //if(!TriPlaneContainPoint(triAx,v0,SphereCenter)) return 0; const dReal radius=dGeomSphereGetRadius(Sphere); float Depth=-T->dist+radius; if(Depth<0.f) return 0; const dReal* pos=dGeomGetPosition(Sphere); dVector3 ContactNormal; if(TriContainPoint(v0,v1,v2,triAx,triSideAx0,triSideAx1,pos)) { ContactNormal[0]=triAx[0];ContactNormal[1]=triAx[1];ContactNormal[2]=triAx[2]; //dVector3 ContactPos={pos[0]-triAx[0]* radius,pos[1]-triAx[1]* radius,pos[2]-triAx[2]* radius}; } else { CDB::TRI* T_array = Level().ObjectSpace.GetStaticTris(); flags8& gl_state=gl_cl_tries_state[I-B]; if(gl_state.test(fl_engaged_s0)||gl_state.test(fl_engaged_s1)||gl_state.test(fl_engaged_s2)) return 0; if(FragmentonSphereTest(pos,radius,v0,v1,ContactNormal,Depth)) { SideToGlClTriState(T->T->verts[0],T->T->verts[1],T_array); } else if(FragmentonSphereTest(pos,radius,v1,v2,ContactNormal,Depth)) { SideToGlClTriState(T->T->verts[1],T->T->verts[2],T_array ); } else if(FragmentonSphereTest(pos,radius,v2,v0,ContactNormal,Depth)) { SideToGlClTriState(T->T->verts[2],T->T->verts[0],T_array ); } else{ if(gl_state.test(fl_engaged_v0)||gl_state.test(fl_engaged_v1)||gl_state.test(fl_engaged_v2)) return 0; if(PointSphereTest(pos,radius,v0,ContactNormal,Depth)) { VxToGlClTriState(T->T->verts[0],T_array ); } else if(PointSphereTest(pos,radius,v1,ContactNormal,Depth)) { VxToGlClTriState(T->T->verts[1],T_array ); } else if(PointSphereTest(pos,radius,v2,ContactNormal,Depth)) { VxToGlClTriState(T->T->verts[2],T_array ); } else return 0; } } Contacts->normal[0] =-ContactNormal[0]; Contacts->normal[1] =-ContactNormal[1]; Contacts->normal[2] =-ContactNormal[2]; Contacts->depth = Depth; //////////////////// Contacts->pos[0]=pos[0]-ContactNormal[0]*radius; Contacts->pos[1]=pos[1]-ContactNormal[1]*radius; Contacts->pos[2]=pos[2]-ContactNormal[2]*radius; Contacts->g1 = Geometry; Contacts->g2 = Sphere; ((dxGeomUserData*)dGeomGetData(Sphere))->tri_material=T->T->material; if(dGeomGetUserData(Sphere)->callback)dGeomGetUserData(Sphere)->callback(T->T,Contacts); SURFACE(Contacts,0)->mode=T->T->material; ////////////////////////////////// // ++OutTriCount; return 1; }