Changeset 158

Show
Ignore:
Timestamp:
10/13/06 19:07:19 (2 years ago)
Author:
dconrad
Message:

Load external SubRip? (.srt) files. Closes #39

Files:

Legend:

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

    r138 r158  
    3737#include "MatroskaImport.h" 
    3838#include "MkvImportPrivate.h" 
     39#include "SubImport.h" 
    3940 
    4041#pragma mark- Component Dispatch 
     
    138139                                                        inFlags, 
    139140                                                        outFlags); 
    140  
     141        if (err) goto bail; 
     142         
     143        LoadExternalSubtitles(&theFileFSRef, theMovie); 
     144         
    141145bail: 
    142146        if (store->filename) 
  • trunk/MkvMovieSetup.cpp

    r156 r158  
    2626#include "MkvImportPrivate.h" 
    2727#include "MkvMovieSetup.h" 
     28#include "SubImport.h" 
    2829#include <QuickTime/QuickTime.h> 
    2930#include <AudioToolbox/AudioToolbox.h> 
     
    541542        ComponentResult err = noErr; 
    542543        Fixed trackWidth, trackHeight; 
    543         Fixed horizontalOffset, verticalOffset; 
    544544        Rect movieBox; 
    545545        MediaHandler mh; 
     
    575575                (*imgDesc)->height = height; 
    576576                 
     577                mkvTrack->theTrack = NewMovieTrack(theMovie, trackWidth, trackHeight, kNoVolume); 
     578                if (mkvTrack->theTrack == NULL) { 
     579                        err = GetMoviesError(); 
     580                        goto bail; 
     581                } 
     582                 
     583                mkvTrack->theMedia = NewTrackMedia(mkvTrack->theTrack, VideoMediaType, GetMovieTimeScale(theMovie), dataRef, dataRefType); 
     584                if (mkvTrack->theMedia == NULL) { 
     585                        err = GetMoviesError(); 
     586                        goto bail; 
     587                } 
     588                 
     589                // finally, say that we're transparent 
     590                mh = GetMediaHandler(mkvTrack->theMedia); 
     591                MediaSetGraphicsMode(mh, graphicsModePreWhiteAlpha, NULL); 
     592                 
    577593        } else if ((*imgDesc)->cType == kSubFormatUTF8) { 
    578                 (*imgDesc)->width = FixedToInt(trackWidth); 
    579                 (*imgDesc)->height = FixedToInt(trackHeight); 
     594                mkvTrack->theTrack = CreatePlaintextSubTrack(theMovie, imgDesc, GetMovieTimeScale(theMovie), dataRef, dataRefType); 
     595                if (mkvTrack->theTrack == NULL) { 
     596                        err = GetMoviesError(); 
     597                        goto bail; 
     598                } 
     599                 
     600                mkvTrack->theMedia = GetTrackMedia(mkvTrack->theTrack); 
    580601                 
    581602        } else { 
     
    584605        } 
    585606         
    586         mkvTrack->theTrack = NewMovieTrack(theMovie, trackWidth, trackHeight, kNoVolume); 
    587         if (mkvTrack->theTrack == NULL) { 
    588                 err = GetMoviesError(); 
    589                 goto bail; 
    590         } 
    591          
    592         mkvTrack->theMedia = NewTrackMedia(mkvTrack->theTrack, VideoMediaType,  
    593                                                                            GetMovieTimeScale(theMovie), dataRef, dataRefType); 
    594         if (mkvTrack->theMedia == NULL) { 
    595                 err = GetMoviesError(); 
    596                 goto bail; 
    597         } 
    598          
    599607        // this sets up anything else needed in the description for the specific codec. 
    600608        FinishSampleDescription(tr_entry, (SampleDescriptionHandle) imgDesc); 
    601          
    602         // finally, say that we're transparent 
    603         mh = GetMediaHandler(mkvTrack->theMedia); 
    604         MediaSetGraphicsMode(mh, graphicsModePreWhiteAlpha, NULL); 
    605609         
    606610        // and save our sample description 
  • trunk/Perian.xcodeproj/project.pbxproj

    r143 r158  
    161161                61CB120D0ACE0F8D007994BD /* MatroskaCodecIDs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 61D691500AC8E382000EFC7D /* MatroskaCodecIDs.cpp */; }; 
    162162                61CB12260ACE1074007994BD /* MatroskaImport.r in Rez */ = {isa = PBXBuildFile; fileRef = 61D691590AC8E382000EFC7D /* MatroskaImport.r */; }; 
     163                61D514DE0ADF3DBA00A671E1 /* SubImport.c in Sources */ = {isa = PBXBuildFile; fileRef = 61D514DD0ADF3DBA00A671E1 /* SubImport.c */; }; 
     164                61D517730AE0402E00A671E1 /* CommonUtils.c in Sources */ = {isa = PBXBuildFile; fileRef = 61D517720AE0402E00A671E1 /* CommonUtils.c */; }; 
    163165                8F483B550A642644002CCA73 /* libavformat.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F483B540A642644002CCA73 /* libavformat.a */; }; 
    164166                8F483B5E0A6426C1002CCA73 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F483B5D0A6426C1002CCA73 /* AudioToolbox.framework */; }; 
     
    340342                61CB11CA0ACDF50F007994BD /* KaxTrackVideo.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = KaxTrackVideo.cpp; path = libmatroska/src/KaxTrackVideo.cpp; sourceTree = "<group>"; }; 
    341343                61CB11CB0ACDF50F007994BD /* KaxVersion.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = KaxVersion.cpp; path = libmatroska/src/KaxVersion.cpp; sourceTree = "<group>"; }; 
     344                61D514DC0ADF3DBA00A671E1 /* SubImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubImport.h; sourceTree = "<group>"; }; 
     345                61D514DD0ADF3DBA00A671E1 /* SubImport.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SubImport.c; sourceTree = "<group>"; }; 
     346                61D517710AE0402E00A671E1 /* CommonUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonUtils.h; sourceTree = "<group>"; }; 
     347                61D517720AE0402E00A671E1 /* CommonUtils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonUtils.c; sourceTree = "<group>"; }; 
    342348                61D6914E0AC8E382000EFC7D /* DataHandlerCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DataHandlerCallback.cpp; sourceTree = "<group>"; }; 
    343349                61D6914F0AC8E382000EFC7D /* DataHandlerCallback.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DataHandlerCallback.h; sourceTree = "<group>"; }; 
     
    422428                        isa = PBXGroup; 
    423429                        children = ( 
     430                                61CB11020ACDF37C007994BD /* libebml */, 
     431                                61CB11720ACDF4BB007994BD /* libmatroska */, 
    424432                                8F483B5D0A6426C1002CCA73 /* AudioToolbox.framework */, 
    425433                                1156DBD80A3CE9F500963B0E /* libz.dylib */, 
     
    468476                                113F58980A6B091600509987 /* Codecprintf.h */, 
    469477                                113F58990A6B091600509987 /* Codecprintf.c */, 
     478                                61D517710AE0402E00A671E1 /* CommonUtils.h */, 
     479                                61D517720AE0402E00A671E1 /* CommonUtils.c */, 
    470480                        ); 
    471481                        name = Source; 
     
    491501                                6123D6230AD0A3FE003EDE52 /* VobSubCodec.h */, 
    492502                                6123D6250AD0A3FF003EDE52 /* VobSubCodecDispatch.h */, 
     503                                61D514DC0ADF3DBA00A671E1 /* SubImport.h */, 
     504                                61D514DD0ADF3DBA00A671E1 /* SubImport.c */, 
    493505                        ); 
    494506                        name = Subtitles; 
     
    609621                        isa = PBXGroup; 
    610622                        children = ( 
    611                                 61CB11020ACDF37C007994BD /* libebml */, 
    612                                 61CB11720ACDF4BB007994BD /* libmatroska */, 
    613623                                61D6916B0AC8E3A3000EFC7D /* Import */, 
    614624                                61D6916C0AC8E3C5000EFC7D /* Export */, 
     
    880890                                6123D6260AD0A3FF003EDE52 /* VobSubCodec.c in Sources */, 
    881891                                613CD51E0AD1FB650098A825 /* TextSubCodec.c in Sources */, 
     892                                61D514DE0ADF3DBA00A671E1 /* SubImport.c in Sources */, 
     893                                61D517730AE0402E00A671E1 /* CommonUtils.c in Sources */, 
    882894                        ); 
    883895                        runOnlyForDeploymentPostprocessing = 0; 
  • trunk/ff_MovieImport.c

    r154 r158  
    2727#include "Codecprintf.h" 
    2828#include "riff.h" 
     29#include "SubImport.h" 
    2930 
    3031/* This one is a little big in ffmpeg and private anyway */ 
     
    340341        Handle dataRef = NULL; 
    341342        OSType dataRefType; 
     343        FSRef theFileFSRef; 
    342344         
    343345        *outFlags = 0; 
     
    348350        result = MovieImportDataRef(storage->ci, dataRef, dataRefType, theMovie, targetTrack, usedTrack, atTime, addedDuration, 
    349351                                                                inFlags, outFlags); 
     352        require_noerr(result, bail); 
     353         
     354        result = FSpMakeFSRef(theFile, &theFileFSRef); 
     355        require_noerr(result, bail); 
     356         
     357        LoadExternalSubtitles(&theFileFSRef, theMovie); 
     358         
    350359bail: 
    351360                if(dataRef)