Changeset 901

Show
Ignore:
Timestamp:
05/24/08 16:53:25 (3 months ago)
Author:
astrange
Message:

Allow subtitle tracks without any video tracks, fix up tracking and scaleX/Y to better match VSFilter, and cache more stuff for font lookups.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Subtitles/SubATSUIRenderer.m

    r874 r901  
    288288 
    289289static NSMutableDictionary *fontIDCache = nil; 
     290static ATSUFontID fontCount=-1, *fontIDs = NULL; 
    290291 
    291292static void CleanupFontIDCache() __attribute__((destructor)); 
     
    294295        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    295296        if (fontIDCache) [fontIDCache release]; 
     297        if (fontIDs) free(fontIDs); 
    296298        fontIDCache = nil; 
     299        fontIDs = NULL; 
    297300        [pool release]; 
    298301} 
     
    316319        if (font == kATSUInvalidFontID) font = ATSFontFindFromName((CFStringRef)name, kATSOptionFlagsDefault); // for bugs in ATS under 10.4 
    317320        if (font == kATSUInvalidFontID) { // try a case-insensitive search 
    318                 ItemCount fontCount; 
    319                 ATSUFontCount(&fontCount); 
    320                  
    321                 ATSUFontID fontIDs[fontCount]; 
    322                 ItemCount arraySize = fontCount; 
    323                 ATSUGetFontIDs(fontIDs, arraySize, &fontCount); 
    324                  
    325                 // I do not want to call ATSUFindFontName twice  
    326                 // so I make the buffer large enough. 
     321                if (fontCount == -1) { 
     322                        ATSUFontCount(&fontCount); 
     323                        fontIDs = malloc(sizeof(ATSUFontID[fontCount])); 
     324                        ATSUGetFontIDs(fontIDs, fontCount, &fontCount); 
     325                } 
     326                                 
    327327                ByteCount len; 
    328328                ItemCount x, index; 
     
    368368        ATSUSetAttributes(style, sizeof(tags) / sizeof(ATSUAttributeTag), tags, sizes, vals); 
    369369         
    370         if (s->tracking) { 
     370        if (s->tracking > 0) { // bug in VSFilter: negative tracking in style lines is ignored 
    371371                Fixed tracking = FloatToFixed(s->tracking); 
    372372                 
     
    495495                case tag_fscx: 
    496496                        fv(); 
    497                         fval /= 100.; 
    498                         mat = CGAffineTransformMakeScale(fval, spanEx->scaleY); 
    499                         spanEx->scaleX = fval; 
     497                        spanEx->scaleX = fval / 100.; 
     498                        mat = CGAffineTransformMakeScale(spanEx->scaleX, spanEx->scaleY); 
    500499                        SetATSUStyleOther(spanEx->style, kATSUFontMatrixTag, sizeof(CGAffineTransform), &mat); 
    501500                        break; 
    502501                case tag_fscy: 
    503502                        fv(); 
    504                         fval /= 100.; 
    505                         mat = CGAffineTransformMakeScale(spanEx->scaleX, fval); 
    506                         spanEx->scaleY = fval; 
     503                        spanEx->scaleY = fval / 100.; 
     504                        mat = CGAffineTransformMakeScale(spanEx->scaleX, spanEx->scaleY); 
    507505                        SetATSUStyleOther(spanEx->style, kATSUFontMatrixTag, sizeof(CGAffineTransform), &mat); 
    508506                        break; 
  • trunk/Subtitles/SubImport.mm

    r873 r901  
    9999        (*imgDesc)->depth = 32; 
    100100        (*imgDesc)->clutID = -1; 
     101         
     102        if (!trackWidth || !trackHeight) {trackWidth = IntToFixed(640); trackHeight = IntToFixed(480);} 
    101103         
    102104        if (imageExtension) AddImageDescriptionExtension(imgDesc, imageExtension, subType);