static ComponentResult setFrameRate(VP8EncoderGlobals glob) { dbg_printf("[vp8e - %08lx] setFrameRate \n", (UInt32) glob); ComponentResult err = noErr; Fixed frameRate; err= ICMCompressionSessionOptionsGetProperty(glob->sessionOptions, kQTPropertyClass_ICMCompressionSessionOptions, kICMCompressionSessionOptionsPropertyID_ExpectedFrameRate, sizeof(Fixed), &frameRate, NULL); if (err) goto bail; double fps = FixedToFloat(frameRate); dbg_printf("[vp8e - %08lx] Got FrameRate %f \n", (UInt32) glob,fps); if (fps == 0) return err; //use the defaults if (fps > 29.965 && fps < 29.975) // I am putting everything in this threshold as 29.97 { glob->cfg.g_timebase.num = 1001; glob->cfg.g_timebase.den = 30000; } else { //I'm using a default of a millisecond timebase, this may not be 100% accurate // however, container uses this timebase so this estimate is best. glob->cfg.g_timebase.num = 1000; glob->cfg.g_timebase.den = fps * 1000; } dbg_printf("[vp8e - %08lx] Setting g_timebase to %d/%d \n", (UInt32) glob, glob->cfg.g_timebase.num, glob->cfg.g_timebase.den); bail: return err; }
/* * Put points in feedback buffer. */ static void feedback_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; GLuint i; GLfloat invRedScale = ctx->Visual->InvRedScale; GLfloat invGreenScale = ctx->Visual->InvGreenScale; GLfloat invBlueScale = ctx->Visual->InvBlueScale; GLfloat invAlphaScale = ctx->Visual->InvAlphaScale; for (i=first;i<=last;i++) { if (VB->Unclipped[i]) { GLfloat x, y, z, w, invq; GLfloat color[4], texcoord[4]; x = VB->Win[i][0]; y = VB->Win[i][1]; z = VB->Win[i][2] / DEPTH_SCALE; w = VB->Clip[i][3]; /* convert color from integer back to a float in [0,1] */ if (ctx->Light.ShadeModel==GL_SMOOTH) { /* smooth shading - colors are in fixed point */ color[0] = FixedToFloat(VB->Color[i][0]) * invRedScale; color[1] = FixedToFloat(VB->Color[i][1]) * invGreenScale; color[2] = FixedToFloat(VB->Color[i][2]) * invBlueScale; color[3] = FixedToFloat(VB->Color[i][3]) * invAlphaScale; } else { /* flat shading - colors are integers */ color[0] = VB->Color[i][0] * invRedScale; color[1] = VB->Color[i][1] * invGreenScale; color[2] = VB->Color[i][2] * invBlueScale; color[3] = VB->Color[i][3] * invAlphaScale; } invq = 1.0F / VB->TexCoord[i][3]; texcoord[0] = VB->TexCoord[i][0] * invq; texcoord[1] = VB->TexCoord[i][1] * invq; texcoord[2] = VB->TexCoord[i][2] * invq; texcoord[3] = VB->TexCoord[i][3]; FEEDBACK_TOKEN( ctx, (GLfloat) GL_POINT_TOKEN ); gl_feedback_vertex( ctx, x, y, z, w, color, (GLfloat) VB->Index[i], texcoord ); } } }
int qtCanvas::convertToFrames(float seconds) { SCTemporalSettings temporal; SCGetInfo(impl.mSCComponent, scTemporalSettingsType, &temporal); return (int)(FixedToFloat(temporal.frameRate) * seconds); }
void P_SetSlope (secplane_t *plane, bool setCeil, int xyangi, int zangi, const DVector3 &pos) { DAngle xyang; DAngle zang; if (zangi >= 180) { zang = 179.; } else if (zangi <= 0) { zang = 1.; } else { zang = (double)zangi; } if (setCeil) { zang += 180.; } xyang = (double)xyangi; DVector3 norm; if (ib_compatflags & BCOMPATF_SETSLOPEOVERFLOW) { // We have to consider an integer multiplication overflow here. norm[0] = FixedToFloat(FloatToFixed(zang.Cos()) * FloatToFixed(xyang.Cos())); norm[1] = FixedToFloat(FloatToFixed(zang.Cos()) * FloatToFixed(xyang.Sin())); } else { norm[0] = zang.Cos() * xyang.Cos(); norm[1] = zang.Cos() * xyang.Sin(); } norm[2] = zang.Sin(); norm.MakeUnit(); double dist = -norm[0] * pos.X - norm[1] * pos.Y - norm[2] * pos.Z; plane->set(norm[0], norm[1], norm[2], dist); }
/* * Put a vertex into the feedback buffer. */ void _mesa_feedback_vertex( GLcontext *ctx, const GLfloat win[4], const GLfloat color[4], GLfloat index, const GLfloat texcoord[4] ) { #if 0 { /* snap window x, y to fractional pixel position */ const GLint snapMask = ~((FIXED_ONE / (1 << SUB_PIXEL_BITS)) - 1); GLfixed x, y; x = FloatToFixed(win[0]) & snapMask; y = FloatToFixed(win[1]) & snapMask; FEEDBACK_TOKEN(ctx, FixedToFloat(x)); FEEDBACK_TOKEN(ctx, FixedToFloat(y) ); } #else FEEDBACK_TOKEN( ctx, win[0] ); FEEDBACK_TOKEN( ctx, win[1] ); #endif if (ctx->Feedback._Mask & FB_3D) { FEEDBACK_TOKEN( ctx, win[2] ); } if (ctx->Feedback._Mask & FB_4D) { FEEDBACK_TOKEN( ctx, win[3] ); } if (ctx->Feedback._Mask & FB_INDEX) { FEEDBACK_TOKEN( ctx, (GLfloat) index ); } if (ctx->Feedback._Mask & FB_COLOR) { FEEDBACK_TOKEN( ctx, color[0] ); FEEDBACK_TOKEN( ctx, color[1] ); FEEDBACK_TOKEN( ctx, color[2] ); FEEDBACK_TOKEN( ctx, color[3] ); } if (ctx->Feedback._Mask & FB_TEXTURE) { FEEDBACK_TOKEN( ctx, texcoord[0] ); FEEDBACK_TOKEN( ctx, texcoord[1] ); FEEDBACK_TOKEN( ctx, texcoord[2] ); FEEDBACK_TOKEN( ctx, texcoord[3] ); } }
extern double ValueToFloat( ValueStruct *val) { double ret; if ( val == NULL ) { ret = 0; } else switch (ValueType(val)) { case GL_TYPE_CHAR: case GL_TYPE_VARCHAR: case GL_TYPE_TEXT: case GL_TYPE_SYMBOL: ret = atof(ValueString(val)); break; case GL_TYPE_NUMBER: ret = FixedToFloat(&ValueFixed(val)); break; case GL_TYPE_INT: ret = (double)ValueInteger(val); break; case GL_TYPE_FLOAT: ret = ValueFloat(val); break; case GL_TYPE_BOOL: ret = (double)ValueBool(val); break; case GL_TYPE_TIMESTAMP: case GL_TYPE_DATE: case GL_TYPE_TIME: ret = (double)mktime(&ValueDateTime(val)); break; default: ret = 0; } return (ret); }
static cairo_status_t _cairo_atsui_font_text_to_glyphs(void *abstract_font, const char *utf8, cairo_glyph_t **glyphs, int *num_glyphs) { cairo_atsui_font_t *font = abstract_font; size_t i; OSStatus err; ATSUTextLayout textLayout; ATSLayoutRecord *layoutRecords; ItemCount glyphCount; int charCount; UniChar *theText; cairo_status_t status; // liberal estimate of size charCount = strlen(utf8); if (charCount == 0) { *glyphs = NULL; *num_glyphs = 0; return CAIRO_STATUS_SUCCESS; } status = _cairo_utf8_to_utf16 (utf8, -1, &theText, &charCount); if (status) return status; err = ATSUCreateTextLayout(&textLayout); err = ATSUSetTextPointerLocation(textLayout, theText, 0, charCount, charCount); // Set the style for all of the text err = ATSUSetRunStyle(textLayout, font->unscaled_style, kATSUFromTextBeginning, kATSUToTextEnd); // Get the glyphs from the text layout object err = ATSUDirectGetLayoutDataArrayPtrFromTextLayout(textLayout, 0, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, (void *) &layoutRecords, &glyphCount); *num_glyphs = glyphCount - 1; *glyphs = (cairo_glyph_t *) malloc(*num_glyphs * (sizeof(cairo_glyph_t))); if (*glyphs == NULL) { return CAIRO_STATUS_NO_MEMORY; } for (i = 0; i < *num_glyphs; i++) { (*glyphs)[i].index = layoutRecords[i].glyphID; (*glyphs)[i].x = FixedToFloat(layoutRecords[i].realPos); (*glyphs)[i].y = 0; } free(theText); ATSUDirectReleaseLayoutDataArrayPtr(NULL, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, (void *) &layoutRecords); ATSUDisposeTextLayout(textLayout); return CAIRO_STATUS_SUCCESS; }
struct list_t *opengl_sc_rast_triangle_gen_pixel_info(struct opengl_pa_triangle_t *triangle, struct opengl_depth_buffer_t *db) { /* List contains info of pixels inside this triangle */ struct list_t *pxl_lst; struct opengl_sc_pixel_info_t *pxl_info; struct opengl_sc_edge_t *edge_major; struct opengl_sc_edge_t *edge_top; struct opengl_sc_edge_t *edge_bottom; struct opengl_pa_vertex_t *vtx_max; struct opengl_pa_vertex_t *vtx_mid; struct opengl_pa_vertex_t *vtx_min; struct opengl_sc_span_t *spn; pxl_lst = list_create(); spn = opengl_sc_span_create(); float one_over_area; int vtx_min_fx, vtx_min_fy; int vtx_mid_fx, vtx_mid_fy; int vtx_max_fx, vtx_max_fy; int scan_from_left_to_right; const int snapMask = ~((FIXED_ONE / (1 << SUB_PIXEL_BITS)) - 1); /* for x/y coord snapping */ const int fy0 = FloatToFixed(triangle->vtx0->pos[Y_COMP] - 0.5F) & snapMask; const int fy1 = FloatToFixed(triangle->vtx1->pos[Y_COMP] - 0.5F) & snapMask; const int fy2 = FloatToFixed(triangle->vtx2->pos[Y_COMP] - 0.5F) & snapMask; /* Find the order of vertex */ if (fy0 <= fy1) { if (fy1 <= fy2) { /* y0 < y1 < y2 */ vtx_max = triangle->vtx2; vtx_mid = triangle->vtx1; vtx_min = triangle->vtx0; vtx_max_fy = fy2; vtx_mid_fy = fy1; vtx_min_fy = fy0; } else if (fy2 <= fy0) { /* y2 < y0 < y1 */ vtx_max = triangle->vtx1; vtx_mid = triangle->vtx0; vtx_min = triangle->vtx2; vtx_max_fy = fy1; vtx_mid_fy = fy0; vtx_min_fy = fy2; } else { /* y0 < y2 < y1 */ vtx_max = triangle->vtx1; vtx_mid = triangle->vtx2; vtx_min = triangle->vtx0; vtx_max_fy = fy1; vtx_mid_fy = fy2; vtx_min_fy = fy0; } } else { if (fy0 <= fy2) { /* y1 < y0 < y2 */ vtx_max = triangle->vtx2; vtx_mid = triangle->vtx0; vtx_min = triangle->vtx1; vtx_max_fy = fy2; vtx_mid_fy = fy0; vtx_min_fy = fy1; } else if (fy2 <= fy1) { /* y2 < y1 < y0 */ vtx_max = triangle->vtx0; vtx_mid = triangle->vtx1; vtx_min = triangle->vtx2; vtx_max_fy = fy0; vtx_mid_fy = fy1; vtx_min_fy = fy2; } else { /* y1 < y2 < y0 */ vtx_max = triangle->vtx0; vtx_mid = triangle->vtx2; vtx_min = triangle->vtx1; vtx_max_fy = fy0; vtx_mid_fy = fy2; vtx_min_fy = fy1; } } vtx_min_fx = FloatToFixed(vtx_min->pos[X_COMP] + 0.5F) & snapMask; vtx_mid_fx = FloatToFixed(vtx_mid->pos[X_COMP] + 0.5F) & snapMask; vtx_max_fx = FloatToFixed(vtx_max->pos[X_COMP] + 0.5F) & snapMask; /* Create edges */ edge_major = opengl_sc_edge_create(vtx_max, vtx_min); edge_top = opengl_sc_edge_create(vtx_max, vtx_mid); edge_bottom = opengl_sc_edge_create(vtx_mid, vtx_min); /* compute deltas for each edge: vertex[upper] - vertex[lower] */ edge_major->dx = FixedToFloat(vtx_max_fx - vtx_min_fx); edge_major->dy = FixedToFloat(vtx_max_fy - vtx_min_fy); edge_top->dx = FixedToFloat(vtx_max_fx - vtx_mid_fx); edge_top->dy = FixedToFloat(vtx_max_fy - vtx_mid_fy); edge_bottom->dx = FixedToFloat(vtx_mid_fx - vtx_min_fx); edge_bottom->dy = FixedToFloat(vtx_mid_fy - vtx_min_fy); /* Compute area */ const float area = edge_major->dx * edge_bottom->dy - edge_bottom->dx * edge_major->dy; one_over_area = 1.0f / area; /* Edge setup */ edge_major->fsy = FixedCeil(vtx_min_fy); edge_major->lines = FixedToInt(FixedCeil(vtx_max_fy - edge_major->fsy)); if (edge_major->lines > 0) { edge_major->dxdy = edge_major->dx / edge_major->dy; edge_major->fdxdy = SignedFloatToFixed(edge_major->dxdy); edge_major->adjy = (float) (edge_major->fsy - vtx_min_fy); /* SCALED! */ edge_major->fx0 = vtx_min_fx; edge_major->fsx = edge_major->fx0 + (int) (edge_major->adjy * edge_major->dxdy); } else { /* Free edges */ opengl_sc_edge_free(edge_major); opengl_sc_edge_free(edge_top); opengl_sc_edge_free(edge_bottom); /* Free span*/ opengl_sc_span_free(spn); list_free(pxl_lst); /*CULLED*/ return NULL; } edge_top->fsy = FixedCeil(vtx_mid_fy); edge_top->lines = FixedToInt(FixedCeil(vtx_max_fy - edge_top->fsy)); if (edge_top->lines > 0) { edge_top->dxdy = edge_top->dx / edge_top->dy; edge_top->fdxdy = SignedFloatToFixed(edge_top->dxdy); edge_top->adjy = (float) (edge_top->fsy - vtx_mid_fy); /* SCALED! */ edge_top->fx0 = vtx_mid_fx; edge_top->fsx = edge_top->fx0 + (int) (edge_top->adjy * edge_top->dxdy); } edge_bottom->fsy = FixedCeil(vtx_min_fy); edge_bottom->lines = FixedToInt(FixedCeil(vtx_mid_fy - edge_bottom->fsy)); if (edge_bottom->lines > 0) { edge_bottom->dxdy = edge_bottom->dx / edge_bottom->dy; edge_bottom->fdxdy = SignedFloatToFixed(edge_bottom->dxdy); edge_bottom->adjy = (float) (edge_bottom->fsy - vtx_min_fy); /* SCALED! */ edge_bottom->fx0 = vtx_min_fx; edge_bottom->fsx = edge_bottom->fx0 + (int) (edge_bottom->adjy * edge_bottom->dxdy); } /* Decide scan direction */ scan_from_left_to_right = (one_over_area < 0.0F); /* Interpolate depth */ float edge_major_dz = vtx_max->pos[Z_COMP] - vtx_min->pos[Z_COMP]; float edge_bottom_dz = vtx_mid->pos[Z_COMP] - vtx_min->pos[Z_COMP]; spn->attrStepX[2] = one_over_area * (edge_major_dz * edge_bottom->dy - edge_major->dy * edge_bottom_dz); spn->attrStepY[2] = one_over_area * (edge_major->dx * edge_bottom_dz - edge_major_dz * edge_bottom->dx); spn->zStep = SignedFloatToFixed(spn->attrStepX[2]); int subTriangle; int fxLeftEdge = 0, fxRightEdge = 0; int fdxLeftEdge = 0, fdxRightEdge = 0; int fError = 0, fdError = 0; unsigned int zLeft = 0; int fdzOuter = 0, fdzInner; /* Setup order of edges */ for (subTriangle=0; subTriangle<=1; subTriangle++) { struct opengl_sc_edge_t *edge_left; struct opengl_sc_edge_t *edge_right; int setupLeft, setupRight; int lines; if (subTriangle==0) { /* bottom half */ if (scan_from_left_to_right) { edge_left = edge_major; edge_right = edge_bottom; lines = edge_right->lines; setupLeft = 1; setupRight = 1; } else { edge_left = edge_bottom; edge_right = edge_major; lines = edge_left->lines; setupLeft = 1; setupRight = 1; } } else { /* top half */ if (scan_from_left_to_right) { edge_left = edge_major; edge_right = edge_top; lines = edge_right->lines; setupLeft = 0; setupRight = 1; } else { edge_left = edge_top; edge_right = edge_major; lines = edge_left->lines; setupLeft = 1; setupRight = 0; } if (lines == 0) return NULL; } if (setupLeft && edge_left->lines > 0) { const struct opengl_pa_vertex_t *vtx_lower = edge_left->vtx1; const int fsy = edge_left->fsy; const int fsx = edge_left->fsx; /* no fractional part */ const int fx = FixedCeil(fsx); /* no fractional part */ const int adjx = (int) (fx - edge_left->fx0); /* SCALED! */ const int adjy = (int) edge_left->adjy; /* SCALED! */ int idxOuter; float dxOuter; int fdxOuter; fError = fx - fsx - FIXED_ONE; fxLeftEdge = fsx - FIXED_EPSILON; fdxLeftEdge = edge_left->fdxdy; fdxOuter = FixedFloor(fdxLeftEdge - FIXED_EPSILON); fdError = fdxOuter - fdxLeftEdge + FIXED_ONE; idxOuter = FixedToInt(fdxOuter); dxOuter = (float) idxOuter; spn->y = FixedToInt(fsy); /* Interpolate Z */ float z0 = vtx_lower->pos[Z_COMP]; float tmp = (z0 * FIXED_SCALE + spn->attrStepX[2] * adjx + spn->attrStepY[2] * adjy) + FIXED_HALF; if (tmp < MAX_GLUINT / 2) zLeft = (int) tmp; else zLeft = MAX_GLUINT / 2; fdzOuter = SignedFloatToFixed(spn->attrStepY[2] + dxOuter * spn->attrStepX[2]); } if (setupRight && edge_right->lines>0) { fxRightEdge = edge_right->fsx - FIXED_EPSILON; fdxRightEdge = edge_right->fdxdy; } if (lines==0) continue; /* Interpolate Z */ fdzInner = fdzOuter + spn->zStep; /* Rasterize setup */ while (lines > 0) { /* initialize the spn->interpolants to the leftmost value */ /* ff = fixed-pt fragment */ const int right = FixedToInt(fxRightEdge); spn->x = FixedToInt(fxLeftEdge); if (right <= spn->x) spn->end = 0; else spn->end = right - spn->x; /* Interpolate Z */ spn->z = zLeft; /* This is where we actually generate fragments */ if (spn->end > 0 && spn->y >= 0) { const int len = spn->end; int i; for (i = 0; i < len; ++i) { /* Add if pass depth test */ if(opengl_depth_buffer_test_and_set_pixel(db, spn->x, spn->y, FixedToFloat(spn->z), db->depth_func)) { pxl_info = opengl_sc_pixel_info_create(); opengl_sc_pixel_info_set_wndw_cood(pxl_info, spn->x, spn->y, spn->z); opengl_sc_pixel_info_set_brctrc_cood(pxl_info, triangle); list_add(pxl_lst, pxl_info); } spn->z += spn->zStep; spn->x++; } } /* * Advance to the next scan line. Compute the new edge coordinates, and adjust the * pixel-center x coordinate so that it stays on or inside the major edge. */ spn->y++; lines--; fxLeftEdge += fdxLeftEdge; fxRightEdge += fdxRightEdge; fError += fdError; if (fError >= 0) { zLeft += fdzOuter; fError -= FIXED_ONE; } else zLeft += fdzInner; } /*while lines>0*/ } /* Free edges */ opengl_sc_edge_free(edge_major); opengl_sc_edge_free(edge_top); opengl_sc_edge_free(edge_bottom); /* Free span*/ opengl_sc_span_free(spn); /* Return */ return pxl_lst; }
inline float Get_SpecularCoef(void) { return FixedToFloat(Ks); };
static void Quartz_MetricInfo(int c, R_GE_gcontext *gc, double* ascent, double* descent, double* width, NewDevDesc *dd) { FMetricRec myFMetric; QuartzDesc *xd = (QuartzDesc *) dd-> deviceSpecific; char testo[2]; char *ff; CGrafPtr savedPort; Rect bounds; CGPoint position; unsigned char tmp; testo[0] = c; testo[1] = '\0'; /* fprintf(stderr,"c=%c,>%s<\n",c,testo); */ GetPort(&savedPort); SetPort(GetWindowPort(xd->window)); Quartz_SetFont(gc->fontfamily, gc->fontface, gc->cex, gc->ps, dd); if(c==0){ FontMetrics(&myFMetric); *ascent = xd->yscale *floor(gc->cex * gc->ps + 0.5) * FixedToFloat(myFMetric.ascent); *descent = xd->yscale*floor(gc->cex * gc->ps + 0.5) * FixedToFloat(myFMetric.descent); } else { CGContextSaveGState( GetContext(xd) ); CGContextTranslateCTM( GetContext(xd), 0, 0 ); CGContextScaleCTM( GetContext(xd), -1, 1); CGContextRotateCTM( GetContext(xd), -1.0 * 3.1416); CGContextSetTextDrawingMode( GetContext(xd), kCGTextInvisible ); Quartz_SetFont(gc->fontfamily, gc->fontface, gc->cex, gc->ps, dd); ff = Quartz_TranslateFontFamily(gc->fontfamily, gc->fontface, xd->family); tmp = (unsigned char)c; if( (gc->fontface == 5) || (strcmp(ff,"Symbol")==0)){ if( (tmp>31) && IsThisASymbol(tmp)) testo[0] = (char)Lat2Uni[tmp-31-1]; else Quartz_SetFont(gc->fontfamily, -1, gc->cex, gc->ps, dd); } else { if(tmp>127) testo[0] = (char)Lat2Mac[tmp-127-1]; } CGContextShowTextAtPoint( GetContext(xd), 0, 0, testo, 1 ); position = CGContextGetTextPosition( GetContext(xd) ); CGContextRestoreGState( GetContext(xd) ); QDTextBounds(1,testo,&bounds); *ascent = -bounds.top; *descent = bounds.bottom; *width = bounds.right - bounds.left; *width = position.x; } SetPort(savedPort); /* fprintf(stderr,"ascent=%f, descent=%f,width=%f\n",*ascent, *descent, *width); */ return; }
Fixed jit_gen_pow_fixed(Fixed v1, Fixed v2) { return FloatToFixed( jit_gen_pow_float(FixedToFloat(v1), FixedToFloat(v2)) ); }
Fixed mod_fixed(Fixed v1, Fixed v2) { return FloatToFixed( mod_float(FixedToFloat(v1), FixedToFloat(v2)) ); }
Fixed hypot_fixed(Fixed v1, Fixed v2) { return FloatToFixed( hypot_float(FixedToFloat(v1), FixedToFloat(v2)) ); }
Fixed trunc_fixed(Fixed v) { return FloatToFixed( trunc_float(FixedToFloat(v)) ); }
Fixed jit_gen_round_fixed(Fixed v) { return FloatToFixed( jit_gen_round_float(FixedToFloat(v)) ); }
void drawPlugin(NPP instance, NPCocoaEvent* event) { if (!browserUAString) return; PluginInstance* currentInstance = (PluginInstance*)(instance->pdata); CGContextRef cgContext = event->data.draw.context; if (!cgContext) return; float windowWidth = currentInstance->window.width; float windowHeight = currentInstance->window.height; // save the cgcontext gstate CGContextSaveGState(cgContext); // we get a flipped context CGContextTranslateCTM(cgContext, 0.0, windowHeight); CGContextScaleCTM(cgContext, 1.0, -1.0); // draw a gray background for the plugin CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight)); CGContextSetGrayFillColor(cgContext, 0.5, 1.0); CGContextDrawPath(cgContext, kCGPathFill); // draw a black frame around the plugin CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight)); CGContextSetGrayStrokeColor(cgContext, 0.0, 1.0); CGContextSetLineWidth(cgContext, 6.0); CGContextStrokePath(cgContext); // draw the UA string using ATSUI CGContextSetGrayFillColor(cgContext, 0.0, 1.0); ATSUStyle atsuStyle; ATSUCreateStyle(&atsuStyle); CFIndex stringLength = CFStringGetLength(browserUAString); UniChar* unicharBuffer = (UniChar*)malloc((stringLength + 1) * sizeof(UniChar)); CFStringGetCharacters(browserUAString, CFRangeMake(0, stringLength), unicharBuffer); UniCharCount runLengths = kATSUToTextEnd; ATSUTextLayout atsuLayout; ATSUCreateTextLayoutWithTextPtr(unicharBuffer, kATSUFromTextBeginning, kATSUToTextEnd, stringLength, 1, &runLengths, &atsuStyle, &atsuLayout); ATSUAttributeTag contextTag = kATSUCGContextTag; ByteCount byteSize = sizeof(CGContextRef); ATSUAttributeValuePtr contextATSUPtr = &cgContext; ATSUSetLayoutControls(atsuLayout, 1, &contextTag, &byteSize, &contextATSUPtr); ATSUTextMeasurement lineAscent, lineDescent; ATSUGetLineControl(atsuLayout, kATSUFromTextBeginning, kATSULineAscentTag, sizeof(ATSUTextMeasurement), &lineAscent, &byteSize); ATSUGetLineControl(atsuLayout, kATSUFromTextBeginning, kATSULineDescentTag, sizeof(ATSUTextMeasurement), &lineDescent, &byteSize); float lineHeight = FixedToFloat(lineAscent) + FixedToFloat(lineDescent); ItemCount softBreakCount; ATSUBatchBreakLines(atsuLayout, kATSUFromTextBeginning, stringLength, FloatToFixed(windowWidth - 10.0), &softBreakCount); ATSUGetSoftLineBreaks(atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, 0, NULL, &softBreakCount); UniCharArrayOffset* softBreaks = (UniCharArrayOffset*)malloc(softBreakCount * sizeof(UniCharArrayOffset)); ATSUGetSoftLineBreaks(atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, softBreakCount, softBreaks, &softBreakCount); UniCharArrayOffset currentDrawOffset = kATSUFromTextBeginning; int i = 0; while (i < softBreakCount) { ATSUDrawText(atsuLayout, currentDrawOffset, softBreaks[i], FloatToFixed(5.0), FloatToFixed(windowHeight - 5.0 - (lineHeight * (i + 1.0)))); currentDrawOffset = softBreaks[i]; i++; } ATSUDrawText(atsuLayout, currentDrawOffset, kATSUToTextEnd, FloatToFixed(5.0), FloatToFixed(windowHeight - 5.0 - (lineHeight * (i + 1.0)))); free(unicharBuffer); free(softBreaks); // restore the cgcontext gstate CGContextRestoreGState(cgContext); }
static void feedback_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) { struct vertex_buffer *VB = ctx->VB; GLfloat x1, y1, z1, w1; GLfloat x2, y2, z2, w2; GLfloat tex1[4], tex2[4], invq; GLfloat invRedScale = ctx->Visual->InvRedScale; GLfloat invGreenScale = ctx->Visual->InvGreenScale; GLfloat invBlueScale = ctx->Visual->InvBlueScale; GLfloat invAlphaScale = ctx->Visual->InvAlphaScale; x1 = VB->Win[v1][0]; y1 = VB->Win[v1][1]; z1 = VB->Win[v1][2] / DEPTH_SCALE; w1 = VB->Clip[v1][3]; x2 = VB->Win[v2][0]; y2 = VB->Win[v2][1]; z2 = VB->Win[v2][2] / DEPTH_SCALE; w2 = VB->Clip[v2][3]; invq = 1.0F / VB->TexCoord[v1][3]; tex1[0] = VB->TexCoord[v1][0] * invq; tex1[1] = VB->TexCoord[v1][1] * invq; tex1[2] = VB->TexCoord[v1][2] * invq; tex1[3] = VB->TexCoord[v1][3]; invq = 1.0F / VB->TexCoord[v2][3]; tex2[0] = VB->TexCoord[v2][0] * invq; tex2[1] = VB->TexCoord[v2][1] * invq; tex2[2] = VB->TexCoord[v2][2] * invq; tex2[3] = VB->TexCoord[v2][3]; if (ctx->StippleCounter==0) { FEEDBACK_TOKEN( ctx, (GLfloat) GL_LINE_RESET_TOKEN ); } else { FEEDBACK_TOKEN( ctx, (GLfloat) GL_LINE_TOKEN ); } if (ctx->Light.ShadeModel==GL_FLAT) { GLfloat color[4]; /* convert color from integer to a float in [0,1] */ color[0] = (GLfloat) VB->Color[pv][0] * invRedScale; color[1] = (GLfloat) VB->Color[pv][1] * invGreenScale; color[2] = (GLfloat) VB->Color[pv][2] * invBlueScale; color[3] = (GLfloat) VB->Color[pv][3] * invAlphaScale; gl_feedback_vertex( ctx, x1,y1,z1,w1, color, (GLfloat) VB->Index[pv], tex1 ); gl_feedback_vertex( ctx, x2,y2,z2,w2, color, (GLfloat) VB->Index[pv], tex2 ); } else { GLfloat color[4]; /* convert color from fixed point to a float in [0,1] */ color[0] = FixedToFloat(VB->Color[v1][0]) * invRedScale; color[1] = FixedToFloat(VB->Color[v1][1]) * invGreenScale; color[2] = FixedToFloat(VB->Color[v1][2]) * invBlueScale; color[3] = FixedToFloat(VB->Color[v1][3]) * invAlphaScale; gl_feedback_vertex( ctx, x1,y1,z1,w1, color, (GLfloat) VB->Index[v1], tex1 ); /* convert color from fixed point to a float in [0,1] */ color[0] = FixedToFloat(VB->Color[v2][0]) * invRedScale; color[1] = FixedToFloat(VB->Color[v2][1]) * invGreenScale; color[2] = FixedToFloat(VB->Color[v2][2]) * invBlueScale; color[3] = FixedToFloat(VB->Color[v2][3]) * invAlphaScale; gl_feedback_vertex( ctx, x2,y2,z2,w2, color, (GLfloat) VB->Index[v2], tex2 ); } ctx->StippleCounter++; }
Fixed jit_gen_atanh_fixed(Fixed v) { return FloatToFixed( jit_gen_atanh_float(FixedToFloat(v)) ); }
/* * PsychQTGetTextureFromMovie() -- Create an OpenGL texture map from a specific videoframe from given movie object. * * win = Window pointer of onscreen window for which a OpenGL texture should be created. * moviehandle = Handle to the movie object. * checkForImage = true == Just check if new image available, false == really retrieve the image, blocking if necessary. * timeindex = When not in playback mode, this allows specification of a requested frame by presentation time. * If set to -1, or if in realtime playback mode, this parameter is ignored and the next video frame is returned. * out_texture = Pointer to the Psychtoolbox texture-record where the new texture should be stored. * presentation_timestamp = A ptr to a double variable, where the presentation timestamp of the returned frame should be stored. * * Returns true (1) on success, false (0) if no new image available, -1 if no new image available and there won't be any in future. */ int PsychQTGetTextureFromMovie(PsychWindowRecordType *win, int moviehandle, int checkForImage, double timeindex, PsychWindowRecordType *out_texture, double *presentation_timestamp) { static TimeValue myNextTimeCached = -2; static TimeValue nextFramesTimeCached = -2; TimeValue myCurrTime; TimeValue myNextTime; TimeValue nextFramesTime=0; short myFlags; OSType myTypes[1]; OSErr error = noErr; Movie theMovie; CVOpenGLTextureRef newImage = NULL; QTVisualContextRef theMoviecontext; unsigned int failcount=0; float lowerLeft[2]; float lowerRight[2]; float upperRight[2]; float upperLeft[2]; GLuint texid; Rect rect; float rate; double targetdelta, realdelta, frames; PsychRectType outRect; if (!PsychIsOnscreenWindow(win)) { PsychErrorExitMsg(PsychError_user, "Need onscreen window ptr!!!"); } // Activate OpenGL context of target window: PsychSetGLContext(win); // Explicitely disable Apple's Client storage extensions. For now they are not really useful to us. glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE); if (moviehandle < 0 || moviehandle >= PSYCH_MAX_MOVIES) { PsychErrorExitMsg(PsychError_user, "Invalid moviehandle provided."); } if ((timeindex!=-1) && (timeindex < 0 || timeindex >= 10000.0)) { PsychErrorExitMsg(PsychError_user, "Invalid timeindex provided."); } if (NULL == out_texture && !checkForImage) { PsychErrorExitMsg(PsychError_internal, "NULL-Ptr instead of out_texture ptr passed!!!"); } // Fetch references to objects we need: theMovie = movieRecordBANK[moviehandle].theMovie; theMoviecontext = movieRecordBANK[moviehandle].QTMovieContext; if (theMovie == NULL) { PsychErrorExitMsg(PsychError_user, "Invalid moviehandle provided. No movie associated with this handle."); } // Check if end of movie is reached. Rewind, if so... if (IsMovieDone(theMovie) && movieRecordBANK[moviehandle].loopflag > 0) { if (GetMovieRate(theMovie)>0) { GoToBeginningOfMovie(theMovie); } else { GoToEndOfMovie(theMovie); } } // Is movie actively playing (automatic async playback, possibly with synced sound)? // If so, then we ignore the 'timeindex' parameter, because the automatic playback // process determines which frames should be delivered to PTB when. This function will // simply wait or poll for arrival/presence of a new frame that hasn't been fetched // in previous calls. if (0 == GetMovieRate(theMovie)) { // Movie playback inactive. We are in "manual" mode: No automatic async playback, // no synced audio output. The user just wants to manually fetch movie frames into // textures for manual playback in a standard Matlab-loop. // First pass - checking for new image? if (checkForImage) { // Image for specific point in time requested? if (timeindex >= 0) { // Yes. We try to retrieve the next possible image for requested timeindex. myCurrTime = (TimeValue) ((timeindex * (double) GetMovieTimeScale(theMovie)) + 0.5f); } else { // No. We just retrieve the next frame, given the current movie time. myCurrTime = GetMovieTime(theMovie, NULL); } // Retrieve timeindex of the closest image sample after myCurrTime: myFlags = nextTimeStep + nextTimeEdgeOK; // We want the next frame in the movie's media. myTypes[0] = VisualMediaCharacteristic; // We want video samples. GetMovieNextInterestingTime(theMovie, myFlags, 1, myTypes, myCurrTime, FloatToFixed(1), &myNextTime, &nextFramesTime); error = GetMoviesError(); if (error != noErr) { PsychErrorExitMsg(PsychError_internal, "Failed to fetch texture from movie for given timeindex!"); } // Found useful event? if (myNextTime == -1) { if (PsychPrefStateGet_Verbosity() > 3) printf("PTB-WARNING: Bogus timevalue in movie track for movie %i. Trying to keep going.\n", moviehandle); // No. Just push timestamp to current time plus a little bit in the hope // this will get us unstuck: myNextTime = myCurrTime + (TimeValue) 1; nextFramesTime = (TimeValue) 0; } if (myNextTime != myNextTimeCached) { // Set movies current time to myNextTime, so the next frame will be fetched from there: SetMovieTimeValue(theMovie, myNextTime); // nextFramesTime is the timeindex to which we need to advance for retrieval of next frame: (see code below) nextFramesTime=myNextTime + nextFramesTime; if (PsychPrefStateGet_Verbosity() > 5) printf("PTB-DEBUG: Current timevalue in movie track for movie %i is %lf secs.\n", moviehandle, (double) myNextTime / (double) GetMovieTimeScale(theMovie)); if (PsychPrefStateGet_Verbosity() > 5) printf("PTB-DEBUG: Next timevalue in movie track for movie %i is %lf secs.\n", moviehandle, (double) nextFramesTime / (double) GetMovieTimeScale(theMovie)); // Cache values for 2nd pass: myNextTimeCached = myNextTime; nextFramesTimeCached = nextFramesTime; } else { // Somehow got stuck? Do nothing... if (PsychPrefStateGet_Verbosity() > 5) printf("PTB-DEBUG: Seem to be a bit stuck at timevalue [for movie %i] of %lf secs. Nudging a bit forward...\n", moviehandle, (double) myNextTime / (double) GetMovieTimeScale(theMovie)); // Nudge the timeindex a bit forware in the hope that this helps: SetMovieTimeValue(theMovie, GetMovieTime(theMovie, NULL) + 1); } } else { // This is the 2nd pass: Image fetching. Use cached values from first pass: // Caching in a static works because we're always called immediately for 2nd // pass after successfull return from 1st pass, and we're not multi-threaded, // i.e., don't need to be reentrant or thread-safe here: myNextTime = myNextTimeCached; nextFramesTime = nextFramesTimeCached; myNextTimeCached = -2; } } else { // myNextTime unavailable if in autoplayback-mode: myNextTime=-1; } // Presentation timestamp requested? if (presentation_timestamp) { // Already available? if (myNextTime==-1) { // Retrieve the exact presentation timestamp of the retrieved frame (in movietime): myFlags = nextTimeStep + nextTimeEdgeOK; // We want the next frame in the movie's media. myTypes[0] = VisualMediaCharacteristic; // We want video samples. // We search backward for the closest available image for the current time. Either we get the current time // if we happen to fetch a frame exactly when it becomes ready, or we get a bit earlier timestamp, which is // the optimal presentation timestamp for this frame: GetMovieNextInterestingTime(theMovie, myFlags, 1, myTypes, GetMovieTime(theMovie, NULL), FloatToFixed(-1), &myNextTime, NULL); } // Convert pts (in Quicktime ticks) to pts in seconds since start of movie and return it: *presentation_timestamp = (double) myNextTime / (double) GetMovieTimeScale(theMovie); } // Allow quicktime visual context task to do its internal bookkeeping and cleanup work: if (theMoviecontext) QTVisualContextTask(theMoviecontext); // Perform decompress-operation: if (checkForImage) MoviesTask(theMovie, 0); // Should we just check for new image? If so, just return availability status: if (checkForImage) { if (PSYCH_USE_QT_GWORLDS) { // We use GWorlds. In this case we either suceed immediately due to the // synchronous nature of GWorld rendering, or we fail completely at end // of non-looping movie: if (IsMovieDone(theMovie) && movieRecordBANK[moviehandle].loopflag == 0) { // No new frame available and there won't be any in the future, because this is a non-looping // movie that has reached its end. return(-1); } // Is this the special case of a movie without video, but only sound? In that case, // we always return a 'false' because there ain't no image to return. if (movieRecordBANK[moviehandle].QTMovieGWorld == NULL) return(false); // Success! return(true); } // Code which uses QTVisualContextTasks... if (QTVisualContextIsNewImageAvailable(theMoviecontext, NULL)) { // New frame ready! return(true); } else if (IsMovieDone(theMovie) && movieRecordBANK[moviehandle].loopflag == 0) { // No new frame available and there won't be any in the future, because this is a non-looping // movie that has reached its end. return(-1); } else { // No new frame available yet: return(false); } } if (!PSYCH_USE_QT_GWORLDS) { // Blocking wait-code for non-GWorld mode: // Try up to 1000 iterations for arrival of requested image data in wait-mode: failcount=0; while ((failcount < 1000) && !QTVisualContextIsNewImageAvailable(theMoviecontext, NULL)) { PsychWaitIntervalSeconds(0.005); MoviesTask(theMovie, 0); failcount++; } // No new frame available and there won't be any in the future, because this is a non-looping // movie that has reached its end. if ((failcount>=1000) && IsMovieDone(theMovie) && (movieRecordBANK[moviehandle].loopflag == 0)) { return(-1); } // Fetch new OpenGL texture with the new movie image frame: error = QTVisualContextCopyImageForTime(theMoviecontext, kCFAllocatorDefault, NULL, &newImage); if ((error!=noErr) || newImage == NULL) { PsychErrorExitMsg(PsychError_internal, "OpenGL<->Quicktime texture fetch failed!!!"); } // Disable client storage, if it was enabled: glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE); // Build a standard PTB texture record: CVOpenGLTextureGetCleanTexCoords (newImage, lowerLeft, lowerRight, upperRight, upperLeft); texid = CVOpenGLTextureGetName(newImage); // Assign texture rectangle: PsychMakeRect(outRect, upperLeft[0], upperLeft[1], lowerRight[0], lowerRight[1]); // Set texture orientation as if it were an inverted Offscreen window: Upside-down. out_texture->textureOrientation = (CVOpenGLTextureIsFlipped(newImage)) ? 3 : 4; // Assign OpenGL texture id: out_texture->textureNumber = texid; // Store special texture object as part of the PTB texture record: out_texture->targetSpecific.QuickTimeGLTexture = newImage; } else { // Synchronous texture fetch code for GWorld rendering mode: // At this point, the GWorld should contain the source image for creating a // standard OpenGL texture: // Disable client storage, if it was enabled: glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE); // Build a standard PTB texture record: // Assign texture rectangle: GetMovieBox(theMovie, &rect); // Hack: Need to extend rect by 4 pixels, because GWorlds are 4 pixels-aligned via // image row padding: rect.right = rect.right + 4; PsychMakeRect(out_texture->rect, rect.left, rect.top, rect.right, rect.bottom); // Set NULL - special texture object as part of the PTB texture record: out_texture->targetSpecific.QuickTimeGLTexture = NULL; // Set texture orientation as if it were an inverted Offscreen window: Upside-down. out_texture->textureOrientation = 3; // Setup a pointer to our GWorld as texture data pointer: out_texture->textureMemorySizeBytes = 0; // Quicktime textures are aligned on 4 Byte boundaries: out_texture->textureByteAligned = 4; // Lock GWorld: if(!LockPixels(GetGWorldPixMap(movieRecordBANK[moviehandle].QTMovieGWorld))) { // Locking surface failed! We abort. PsychErrorExitMsg(PsychError_internal, "PsychQTGetTextureFromMovie(): Locking GWorld pixmap surface failed!!!"); } // This will retrieve an OpenGL compatible pointer to the GWorlds pixel data and assign it to our texmemptr: out_texture->textureMemory = (GLuint*) GetPixBaseAddr(GetGWorldPixMap(movieRecordBANK[moviehandle].QTMovieGWorld)); // Let PsychCreateTexture() do the rest of the job of creating, setting up and // filling an OpenGL texture with GWorlds content: PsychCreateTexture(out_texture); // Undo hack from above after texture creation: Now we need the real width of the // texture for proper texture coordinate assignments in drawing code et al. rect.right = rect.right - 4; PsychMakeRect(outRect, rect.left, rect.top, rect.right, rect.bottom); // Unlock GWorld surface. We do a glFinish() before, for safety reasons... //glFinish(); UnlockPixels(GetGWorldPixMap(movieRecordBANK[moviehandle].QTMovieGWorld)); // Ready to use the texture... We're done. } // Normalize texture rectangle and assign it: PsychNormalizeRect(outRect, out_texture->rect); rate = FixedToFloat(GetMovieRate(theMovie)); // Detection of dropped frames: This is a heuristic. We'll see how well it works out... if (rate && presentation_timestamp) { // Try to check for dropped frames in playback mode: // Expected delta between successive presentation timestamps: targetdelta = 1.0f / (movieRecordBANK[moviehandle].fps * rate); // Compute real delta, given rate and playback direction: if (rate>0) { realdelta = *presentation_timestamp - movieRecordBANK[moviehandle].last_pts; if (realdelta<0) realdelta = 0; } else { realdelta = -1.0 * (*presentation_timestamp - movieRecordBANK[moviehandle].last_pts); if (realdelta<0) realdelta = 0; } frames = realdelta / targetdelta; // Dropped frames? if (frames > 1 && movieRecordBANK[moviehandle].last_pts>=0) { movieRecordBANK[moviehandle].nr_droppedframes += (int) (frames - 1 + 0.5); } movieRecordBANK[moviehandle].last_pts = *presentation_timestamp; } // Manually advance movie time, if in fetch mode: if (0 == GetMovieRate(theMovie)) { // We are in manual fetch mode: Need to manually advance movie time to next // media sample: if (nextFramesTime == myNextTime) { // Invalid value? Try to hack something that gets us unstuck: myNextTime = GetMovieTime(theMovie, NULL); nextFramesTime = myNextTime + (TimeValue) 1; } SetMovieTimeValue(theMovie, nextFramesTime); } // Check if end of movie is reached. Rewind, if so... if (IsMovieDone(theMovie) && movieRecordBANK[moviehandle].loopflag > 0) { if (GetMovieRate(theMovie)>0) { GoToBeginningOfMovie(theMovie); } else { GoToEndOfMovie(theMovie); } } return(TRUE); }
Fixed fract_fixed(Fixed v) { return FloatToFixed( fract_float(FixedToFloat(v)) ); }
extern Bool SetValueFixed( ValueStruct *val, Fixed *fval) { Bool rc; char *str; if ( val == NULL ) { fprintf(stderr,"no ValueStruct\n"); rc = FALSE; } else { ValueIsNonNil(val); switch (ValueType(val)) { case GL_TYPE_CHAR: case GL_TYPE_VARCHAR: case GL_TYPE_DBCODE: case GL_TYPE_TEXT: case GL_TYPE_SYMBOL: rc = SetValueString(val,fval->sval,NULL); break; case GL_TYPE_NUMBER: FixedRescale(&ValueFixed(val),fval); rc = TRUE; break; case GL_TYPE_INT: ValueInteger(val) = FixedToInt(fval); rc = TRUE; break; case GL_TYPE_FLOAT: ValueFloat(val) = FixedToFloat(fval); rc = TRUE; break; case GL_TYPE_TIMESTAMP: str = fval->sval; ValueDateTimeYear(val) = StrToInt(str,4); str += 4; ValueDateTimeMon(val) = StrToInt(str,2) - 1; str += 2; ValueDateTimeMDay(val) = StrToInt(str,2); str += 2; ValueDateTimeHour(val) = StrToInt(str,2); str += 2; ValueDateTimeMin(val) = StrToInt(str,2); str += 2; ValueDateTimeSec(val) = StrToInt(str,2); str += 2; rc = mktime(&ValueDateTime(val)) >= 0 ? TRUE : FALSE; break; case GL_TYPE_DATE: str = fval->sval; ValueDateTimeYear(val) = StrToInt(str,4); str += 4; ValueDateTimeMon(val) = StrToInt(str,2) - 1; str += 2; ValueDateTimeMDay(val) = StrToInt(str,2); str += 2; ValueDateTimeHour(val) = 0; ValueDateTimeMin(val) = 0; ValueDateTimeSec(val) = 0; rc = mktime(&ValueDateTime(val)) >= 0 ? TRUE : FALSE; break; case GL_TYPE_TIME: str = fval->sval; ValueDateTimeYear(val) = 0; ValueDateTimeMon(val) = 0; ValueDateTimeMDay(val) = 0; ValueDateTimeHour(val) = StrToInt(str,2); str += 2; ValueDateTimeMin(val) = StrToInt(str,2); str += 2; ValueDateTimeSec(val) = StrToInt(str,2); str += 2; rc = TRUE; break; #if 0 case GL_TYPE_BOOL: val->body.BoolData = ( *fval->sval == 0 ) ? FALSE : TRUE; rc = TRUE; break; #endif default: ValueIsNil(val); rc = FALSE; break; } } return (rc); }
Fixed jit_gen_log2_fixed(Fixed v) { return FloatToFixed( jit_gen_log2_float(FixedToFloat(v)) ); }
bool MovieWriter::getUserCompressionSettings( Format *result, ImageSourceRef imageSource ) { ComponentInstance stdCompression = 0; long scPreferences; ICMCompressionSessionOptionsRef sessionOptionsRef = NULL; ComponentResult err; startQuickTime(); err = ::OpenADefaultComponent( ::StandardCompressionType, ::StandardCompressionSubType, &stdCompression ); if( err || ( stdCompression == 0 ) ) return false; // Indicates the client is ready to use the ICM compression session API to perform compression operations // StdCompression will disable frame reordering and multi pass encoding if this flag not set because the // older sequence APIs do not support these capabilities scPreferences = scAllowEncodingWithCompressionSession; // set the preferences we want err = ::SCSetInfo( stdCompression, ::scPreferenceFlagsType, &scPreferences ); if( err ) { if( stdCompression ) ::CloseComponent( stdCompression ); return false; } // build a preview image #if defined( CINDER_MSW ) GWorldPtr previewImageGWorld = 0; PixMapHandle previewImagePixMap = 0; if( imageSource ) { previewImageGWorld = qtime::createGWorld( imageSource ); previewImagePixMap = ::GetGWorldPixMap( previewImageGWorld ); /*if( ! ::LockPixels( previewImagePixMap ) ) { if( stdCompression ) ::CloseComponent( stdCompression ); return false; }*/ ::SCSetTestImagePixMap( stdCompression, previewImagePixMap, NULL, scPreferScaling ); } #endif // display the standard compression dialog box err = ::SCRequestSequenceSettings( stdCompression ); // before we do anything else, let's free up our preview image resources #if defined( CINDER_MSW ) if( previewImagePixMap ) if( ::GetPixelsState( previewImagePixMap ) & pixelsLocked ) ::UnlockPixels( previewImagePixMap ); if( previewImageGWorld ) ::DisposeGWorld( previewImageGWorld ); #endif // now process the result if( err ) { if( stdCompression ) ::CloseComponent( stdCompression ); return false; } // pull out the codec and quality ::SCSpatialSettings spatialSettings; ::SCGetInfo( stdCompression, scSpatialSettingsType, &spatialSettings ); ::CodecType codec = spatialSettings.codecType; ::CodecQ quality = spatialSettings.spatialQuality; ::SCTemporalSettings temporalSettings; ::SCGetInfo( stdCompression, scTemporalSettingsType, &temporalSettings ); ::SCVideoMultiPassEncodingSettings multiPassSettings; ::SCGetInfo( stdCompression, scVideoMultiPassEncodingSettingsType, &multiPassSettings ); // creates a compression session options object based on configured settings err = ::SCCopyCompressionSessionOptions( stdCompression, &sessionOptionsRef ); if( stdCompression ) ::CloseComponent( stdCompression ); *result = Format( sessionOptionsRef, static_cast<uint32_t>( codec ), quality / (float)codecLosslessQuality, FixedToFloat( temporalSettings.frameRate ), multiPassSettings.allowMultiPassEncoding != 0 ); return true; }
inline float Get_DiffuseCoef(void) { return FixedToFloat(Kd); };