Changeset 165

Show
Ignore:
Timestamp:
10/18/06 20:23:00 (2 years ago)
Author:
astrange
Message:

Update ffmpeg configure script. (it's temporarily broken on x86/Development anyway)
Replace Quartz text rendering with ATSUI.
Unicode now works; outlines and antialiasing don't anymore.
Soft line breaks yet to be done.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/TextSubCodec.c

    r149 r165  
    2424        CGColorSpaceRef         colorSpace; 
    2525         
     26        ATSUStyle                               textStyle; 
     27        ATSUTextLayout                  textLayout; 
    2628        //Ptr                     textBuffer; 
    2729} TextSubGlobalsRecord, *TextSubGlobals; 
     
    115117                        CGColorSpaceRelease(glob->colorSpace); 
    116118                } 
    117  
     119                if (glob->textStyle) { 
     120                        ATSUDisposeStyle(glob->textStyle); 
     121                } 
     122                if (glob->textLayout) { 
     123                        ATSUDisposeTextLayout(glob->textLayout); 
     124                } 
    118125                DisposePtr((Ptr)glob); 
    119126        } 
     
    217224        if (glob->colorSpace == NULL) 
    218225                glob->colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 
    219  
     226         
    220227        return noErr; 
    221228} 
     
    273280                                                                                   kCGImageAlphaPremultipliedFirst); 
    274281         
     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         
    275302        // ultra basic support for multiple lines; relies on \n deliminator 
    276303        int lineStarts[10] = {0}; 
     
    278305         
    279306        // QuickTime doesn't like it if we complain too much 
    280     if (c == NULL
     307    if (!c || !glob->textStyle
    281308                return noErr; 
    282309 
     
    298325                numLines = 9; 
    299326 
     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 
    300332        CGContextClearRect(c, CGRectMake(0, 0, myDrp->width, myDrp->height)); 
    301333         
    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  
    307334        int drawnLines = 0; 
    308335        for (i = numLines - 1; i >= 0; i--) { 
     
    311338                if (sublen == 0) 
    312339                        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                } 
    321352        } 
    322353         
  • trunk/createStaticLibs.sh

    r160 r165  
    3535        cd "$BUILDDIR" 
    3636        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 $generalConfigureOptions 
     37                "$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 
    3838        else 
    3939                "$SRCROOT/ffmpeg/configure" --enable-pp --enable-gpl --enable-memalign-hack $extraConfigureOptions $generalConfigureOptions 
     
    5757                "$SRCROOT/ffmpeg/configure" --enable-pp --enable-gpl $extraConfigureOptions $generalConfigureOptions 
    5858        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 $generalConfigureOptions 
     59                "$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 
    6060        fi 
    6161        make -C libavutil   depend