Changeset 1186

Show
Ignore:
Timestamp:
10/25/09 19:51:15 (5 months ago)
Author:
astrange
Message:

Improve transparent subtitle hack.
- Add QT 7 Player exporting.
- Limit it to Front Row again on 10.5.
- Use the same code style as other app-specific hacks.
- Fix up the rendered image to look better with 1-bit alpha.

Files:

Legend:

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

    r1185 r1186  
    310310}; 
    311311 
    312 static const CFStringRef defaultTransparentSubtitleList[] = { 
     312static const CFStringRef defaultTransparentSubtitleList_10_6[] = { 
    313313        CFSTR("CoreMediaAuthoringSourcePropertyHelper"), 
     314        CFSTR("Front Row"), 
     315        CFSTR("QTPlayerHelper") 
     316}; 
     317 
     318static const CFStringRef defaultTransparentSubtitleList_10_5[] = { 
    314319        CFSTR("Front Row") 
    315320}; 
     
    410415         
    411416        if(forced == -1) 
    412                 forced = isApplicationNameInList(CFSTR("TransparentModeSubtitleAppList"), 
    413                                                                                  defaultTransparentSubtitleList, 
    414                                                                                  sizeof(defaultTransparentSubtitleList)/sizeof(defaultTransparentSubtitleList[0])); 
     417        { 
     418                long minorVersion; 
     419                Gestalt(gestaltSystemVersionMinor, &minorVersion); 
     420                 
     421                if (minorVersion == 5) 
     422                        forced = isApplicationNameInList(CFSTR("TransparentModeSubtitleAppList"), 
     423                                                                                         defaultTransparentSubtitleList_10_5, 
     424                                                                                         sizeof(defaultTransparentSubtitleList_10_5)/sizeof(defaultTransparentSubtitleList_10_5[0])); 
     425                else if (minorVersion == 6) 
     426                        forced = isApplicationNameInList(CFSTR("TransparentModeSubtitleAppList"), 
     427                                                                                         defaultTransparentSubtitleList_10_6, 
     428                                                                                         sizeof(defaultTransparentSubtitleList_10_6)/sizeof(defaultTransparentSubtitleList_10_6[0])); 
     429                else 
     430                        forced = 0; 
     431        } 
     432 
    415433        return forced; 
    416434} 
  • trunk/Subtitles/SubImport.mm

    r1185 r1186  
    8181} 
    8282 
    83 //Use ugly transparency ("transparent" blend mode) for files imported in Front Row 
    84 //At the moment it doesn't support graphicsModePreBlackAlpha 
    85 static bool ShouldEngageFrontRowHack(void) 
    86 { 
    87         long minorVersion; 
    88         Gestalt(gestaltSystemVersionMinor, &minorVersion); 
    89          
    90         bool systemVersionCheck = minorVersion >= 5; 
    91         bool appNameCheck = IsTransparentSubtitleHackEnabled(); 
    92          
    93         return systemVersionCheck && appNameCheck; 
    94 } 
    95  
    9683Track CreatePlaintextSubTrack(Movie theMovie, ImageDescriptionHandle imgDesc,  
    9784                              TimeScale timescale, Handle dataRef, OSType dataRefType, FourCharCode subType, Handle imageExtension, Rect movieBox) 
     
    125112                        MediaHandler mh = GetMediaHandler(theMedia); 
    126113                         
    127                         if (ShouldEngageFrontRowHack()) { 
     114                        if (IsTransparentSubtitleHackEnabled()) { 
    128115                                RGBColor blendColor = {0x0000, 0x0000, 0x0000}; 
    129116                                MediaSetGraphicsMode(mh, transparent, &blendColor); 
  • trunk/TextSubCodec.c

    r1175 r1186  
    3131#include "PerianResourceIDs.h" 
    3232#include "SubATSUIRenderer.h" 
     33#include "CommonUtils.h" 
    3334 
    3435// Data structures 
     
    332333         
    333334        SubRenderPacket(glob->ssa,c,buf,myDrp->width,myDrp->height); 
     335         
     336        if (IsTransparentSubtitleHackEnabled()) { 
     337                // Map 8-bit alpha (graphicsModePreBlendAlpha) to 1-bit alpha (transparent) 
     338                // Pretty much this is just mapping all opaque black to (1,1,1,255) 
     339                // Leaves ugly borders where AAing turned into opaque colors, but that's harder to deal with 
     340                Ptr p = drp->baseAddr; 
     341                int y, x; 
     342                UInt32 alphaMask = EndianU32_BtoN((myDrp->pixelFormat == k32ARGBPixelFormat) ? 0xFF000000 : 0xFF), 
     343                       replacement = EndianU32_BtoN((myDrp->pixelFormat == k32ARGBPixelFormat) ? 0xFF010101 : 0x010101FF); 
     344 
     345                for (y = 0; y < myDrp->height; y++) { 
     346                        UInt32 *p32 = (UInt32*)p; 
     347                        for (x = 0; x < myDrp->width; x++) { 
     348                                UInt32 px = *p32; 
     349                                 
     350                                // if px is black, and opaque (alpha == 255) 
     351                                if (!(px & ~alphaMask) && (px & alphaMask == alphaMask)) { 
     352                                        // then set it to not-quite-black so it'll show up 
     353                                        *p32 = replacement; 
     354                                } 
     355                                 
     356                                p32++; 
     357                        } 
     358                         
     359                        p += drp->rowBytes; 
     360                } 
     361        } 
    334362                 
    335363        CFRelease(buf);