Changeset 165
- Timestamp:
- 10/18/06 20:23:00 (2 years ago)
- Files:
-
- trunk/TextSubCodec.c (modified) (7 diffs)
- trunk/createStaticLibs.sh (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/TextSubCodec.c
r149 r165 24 24 CGColorSpaceRef colorSpace; 25 25 26 ATSUStyle textStyle; 27 ATSUTextLayout textLayout; 26 28 //Ptr textBuffer; 27 29 } TextSubGlobalsRecord, *TextSubGlobals; … … 115 117 CGColorSpaceRelease(glob->colorSpace); 116 118 } 117 119 if (glob->textStyle) { 120 ATSUDisposeStyle(glob->textStyle); 121 } 122 if (glob->textLayout) { 123 ATSUDisposeTextLayout(glob->textLayout); 124 } 118 125 DisposePtr((Ptr)glob); 119 126 } … … 217 224 if (glob->colorSpace == NULL) 218 225 glob->colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 219 226 220 227 return noErr; 221 228 } … … 273 280 kCGImageAlphaPremultipliedFirst); 274 281 282 if (!glob->textStyle) { //TODO: set language region based on track language... does that even matter? 283 ATSUAttributeTag tags[] = {kATSUSizeTag, kATSURGBAlphaColorTag, kATSUStyleRenderingOptionsTag, kATSUFontTag}; 284 ByteCount sizes[] = {sizeof(Fixed), sizeof(ATSURGBAlphaColor), sizeof(ATSStyleRenderingOptions), sizeof(ATSUFontID)}; 285 Fixed size = X2Fix(sqrt(myDrp->width*myDrp->width+myDrp->height*myDrp->height)*.04); ATSURGBAlphaColor yellow = {1,1,0,1}; 286 Boolean trueval = TRUE; ATSUFontID fid; ATSStyleRenderingOptions rend = kATSStyleApplyAntiAliasing; 287 ATSUAttributeValuePtr vals[] = {&size,&yellow,&rend,&fid}; 288 ATSUCreateStyle(&glob->textStyle); 289 ATSUFindFontFromName("Helvetica Neue Condensed Bold",strlen("Helvetica Neue Condensed Bold"),kFontFullName,kFontNoPlatform,kFontNoScript,kFontNoLanguage,&fid); 290 ATSUSetAttributes(glob->textStyle,4, tags, sizes, vals); 291 } 292 293 if (!glob->textLayout) { 294 ATSUAttributeTag tags[] = {kATSULineFlushFactorTag, kATSULineWidthTag}; 295 ByteCount sizes[] = {sizeof(Fract),sizeof(ATSUTextMeasurement)}; 296 Fract lf = kATSUCenterAlignment; ATSUTextMeasurement w = Long2Fix(myDrp->width); 297 ATSUAttributeValuePtr vals[] = {&lf, &w}; 298 ATSUCreateTextLayout(&glob->textLayout); 299 ATSUSetLayoutControls(glob->textLayout, 2, tags, sizes, vals); 300 } 301 275 302 // ultra basic support for multiple lines; relies on \n deliminator 276 303 int lineStarts[10] = {0}; … … 278 305 279 306 // QuickTime doesn't like it if we complain too much 280 if ( c == NULL)307 if (!c || !glob->textStyle) 281 308 return noErr; 282 309 … … 298 325 numLines = 9; 299 326 327 ATSUAttributeTag cgc[] = {kATSUCGContextTag}; 328 ByteCount cgc_s[] = {sizeof(CGContextRef)}; 329 ATSUAttributeValuePtr cgc_v[] = {&c}; 330 ATSUSetLayoutControls(glob->textLayout, 1, cgc, cgc_s, cgc_v); 331 300 332 CGContextClearRect(c, CGRectMake(0, 0, myDrp->width, myDrp->height)); 301 333 302 // hardcoded subtitle font+size...303 CGContextSelectFont(c, "HelveticaNeue-CondensedBold", 30, kCGEncodingMacRoman);304 CGContextSetRGBFillColor(c, 1, 1, .1, 1);305 CGContextSetRGBStrokeColor(c, 0, 0, 0, 1);306 307 334 int drawnLines = 0; 308 335 for (i = numLines - 1; i >= 0; i--) { … … 311 338 if (sublen == 0) 312 339 continue; 313 314 CGContextSetTextDrawingMode(c, kCGTextInvisible); 315 CGContextSetTextPosition(c, 0, 0); 316 CGContextShowText(c, sub, sublen); 317 CGPoint endPos = CGContextGetTextPosition(c); 318 319 CGContextSetTextDrawingMode(c, kCGTextFillStroke); 320 CGContextShowTextAtPoint(c, (myDrp->width - endPos.x) / 2, 20 + 37 * drawnLines++, sub, sublen); 340 else { 341 CFStringRef cstr = CFStringCreateWithCString(NULL, sub, kCFStringEncodingUTF8); 342 sublen = CFStringGetLength(cstr); 343 UniChar uc[sublen]; 344 CFStringGetCharacters(cstr, CFRangeMake(0, sublen), uc); 345 ATSUSetTextPointerLocation(glob->textLayout,uc,kATSUFromTextBeginning, kATSUToTextEnd,sublen); 346 ATSUSetRunStyle(glob->textLayout,glob->textStyle,kATSUFromTextBeginning,kATSUToTextEnd); 347 ATSUSetTransientFontMatching(glob->textLayout,TRUE); 348 ATSUDrawText(glob->textLayout, kATSUFromTextBeginning, kATSUToTextEnd, Long2Fix(0), Long2Fix(20 + 28 * drawnLines)); 349 CFRelease(cstr); 350 drawnLines++; 351 } 321 352 } 322 353 trunk/createStaticLibs.sh
r160 r165 35 35 cd "$BUILDDIR" 36 36 if [ `arch` != i386 ] ; then 37 "$SRCROOT/ffmpeg/configure" --cross-compile -- cpu=x86 --enable-pp --enable-gpl --extra-ldflags='-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk' --extra-cflags='-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk' $extraConfigureOptions $generalConfigureOptions37 "$SRCROOT/ffmpeg/configure" --cross-compile --arch=x86 --enable-pp --enable-gpl --extra-ldflags='-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk' --extra-cflags='-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk' $extraConfigureOptions $generalConfigureOptions 38 38 else 39 39 "$SRCROOT/ffmpeg/configure" --enable-pp --enable-gpl --enable-memalign-hack $extraConfigureOptions $generalConfigureOptions … … 57 57 "$SRCROOT/ffmpeg/configure" --enable-pp --enable-gpl $extraConfigureOptions $generalConfigureOptions 58 58 else 59 "$SRCROOT/ffmpeg/configure" --enable-pp --enable-gpl -- cpu=ppc --extra-ldflags='-arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk' --extra-cflags='-arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk' $extraConfigureOptions $generalConfigureOptions59 "$SRCROOT/ffmpeg/configure" --enable-pp --enable-gpl --arch=ppc --extra-ldflags='-arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk' --extra-cflags='-arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk' $extraConfigureOptions $generalConfigureOptions 60 60 fi 61 61 make -C libavutil depend
