Changeset 141

Show
Ignore:
Timestamp:
10/01/06 23:41:16 (2 years ago)
Author:
dconrad
Message:

Support for uncompressed VobSub? subtitles in Matroska

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/MatroskaCodecIDs.cpp

    r119 r141  
    204204} 
    205205 
     206// VobSub stores the .idx file in the codec private, pass it as an .IDX extension 
     207ComponentResult DescExt_VobSub(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir) 
     208{ 
     209        if (!tr_entry || !desc) return paramErr; 
     210        ImageDescriptionHandle imgDesc = (ImageDescriptionHandle) desc; 
     211         
     212        if (dir == kToSampleDescription) { 
     213                KaxCodecPrivate *codecPrivate = FindChild<KaxCodecPrivate>(*tr_entry); 
     214                if (codecPrivate == NULL) 
     215                        return invalidAtomErr; 
     216                 
     217                Handle imgDescExt = NewHandle(codecPrivate->GetSize()); 
     218                memcpy(*imgDescExt, codecPrivate->GetBuffer(), codecPrivate->GetSize()); 
     219                 
     220                AddImageDescriptionExtension(imgDesc, imgDescExt, '.IDX'); 
     221                 
     222                DisposeHandle((Handle) imgDescExt); 
     223        } 
     224        return noErr; 
     225} 
     226 
    206227ComponentResult ASBDExt_AC3(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd) 
    207228{ 
  • trunk/MatroskaCodecIDs.h

    r119 r141  
    158158#if 0 
    159159        { kBMPCodecType, "S_IMAGE/BMP" }, 
    160         { kSubFormatUTF8, "S_TEXT/UTF8" }, 
    161160        { kSubFormatSSA, "S_TEXT/SSA" }, 
    162161        { kSubFormatASS, "S_TEXT/ASS" }, 
    163162        { kSubFormatUSF, "S_TEXT/USF" }, 
    164         { kSubFormatVobSub, "S_TEXT/VOBSUB" }, 
    165163#endif 
     164        { kSubFormatUTF8, "S_TEXT/UTF8" }, 
     165        { kSubFormatVobSub, "S_VOBSUB" }, 
    166166}; 
    167167 
     
    204204ComponentResult DescExt_XiphVorbis(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
    205205ComponentResult DescExt_XiphFLAC(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
     206ComponentResult DescExt_VobSub(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
    206207 
    207208struct CodecDescExtFunc { 
     
    213214        { kH264CodecType, DescExt_H264 }, 
    214215        { kAudioFormatXiphVorbis, DescExt_XiphVorbis }, 
    215         { kAudioFormatXiphFLAC, DescExt_XiphFLAC } 
     216        { kAudioFormatXiphFLAC, DescExt_XiphFLAC }, 
     217        { kSubFormatVobSub, DescExt_VobSub } 
    216218}; 
    217219 
  • trunk/MkvImportPrivate.cpp

    r138 r141  
    523523                                MkvTrackPtr mkvTrack = &priv->segments[i].tracks[j]; 
    524524                                 
    525                                 if (mkvTrack->theTrack) { 
     525                                if (mkvTrack->theTrack && mkvTrack->trackType != track_subtitle) { 
    526526                                        if (mkvTrack->trackType == track_video) { 
    527527                                                err = AddSampleTableToMedia(mkvTrack->theMedia, 
     
    624624        } 
    625625         
     626        // subtitle tracks usually have gaps, so we need to add it to the track regardless 
     627        if (mkvTrack->trackType == track_subtitle) 
     628                addToTrack = true; 
     629         
    626630        if (addToTrack) { 
    627631                if (mkvTrack->trackType == track_video) { 
  • trunk/MkvMovieSetup.cpp

    r119 r141  
    4747#include <matroska/KaxTrackAudio.h> 
    4848#include <matroska/KaxTrackVideo.h> 
     49#include <matroska/KaxContentEncoding.h> 
    4950 
    5051using namespace std; 
     
    530531{ 
    531532        ComponentResult err = noErr; 
    532          
     533        Fixed trackWidth, trackHeight; 
     534        Fixed horizontalOffset, verticalOffset; 
     535        Rect movieBox; 
     536        MediaHandler mh; 
     537        ImageDescriptionHandle imgDesc = (ImageDescriptionHandle) NewHandleClear(sizeof(ImageDescription)); 
     538         
     539        // we assume that a video track has already been created, so we can set the subtitle track 
     540        // to have the same dimensions as it. Note that this doesn't work so well with multiple 
     541        // video tracks with different dimensions; but QuickTime doesn't expect that; how should we handle them? 
     542        GetMovieBox(theMovie, &movieBox); 
     543        trackWidth = IntToFixed(movieBox.right - movieBox.left); 
     544        trackHeight = IntToFixed(movieBox.bottom - movieBox.top); 
     545         
     546        (*imgDesc)->idSize = sizeof(ImageDescription); 
     547        (*imgDesc)->cType = GetFourCC(tr_entry); 
     548        (*imgDesc)->frameCount = 1; 
     549        (*imgDesc)->depth = 32; 
     550        (*imgDesc)->clutID = -1; 
     551         
     552        if ((*imgDesc)->cType == kSubFormatVobSub) { 
     553                int width, height; 
     554                 
     555                // bitmap width & height is in the codec private in text format 
     556                KaxCodecPrivate *idxFile = FindChild<KaxCodecPrivate>(*tr_entry); 
     557                string idxFileStr((char *)idxFile->GetBuffer(), idxFile->GetSize()); 
     558                string::size_type loc = idxFileStr.find("size:", 0); 
     559                if (loc == string::npos) { 
     560                        // we can't continue without bitmap width/height 
     561                        err = invalidTrack; 
     562                        goto bail; 
     563                } 
     564                sscanf(&idxFileStr.c_str()[loc], "size: %dx%d", &width, &height); 
     565                (*imgDesc)->width = width; 
     566                (*imgDesc)->height = height; 
     567                 
     568        } else if ((*imgDesc)->cType == kSubFormatUTF8) { 
     569                (*imgDesc)->width = FixedToInt(trackWidth); 
     570                (*imgDesc)->height = FixedToInt(trackWidth); 
     571                 
     572        } else { 
     573                err = invalidTrack; 
     574                goto bail; 
     575        } 
     576         
     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,  
     584                                                                           GetMovieTimeScale(theMovie), dataRef, dataRefType); 
     585        if (mkvTrack->theMedia == NULL) { 
     586                err = GetMoviesError(); 
     587                goto bail; 
     588        } 
     589         
     590        // this sets up anything else needed in the description for the specific codec. 
     591        FinishSampleDescription(tr_entry, (SampleDescriptionHandle) imgDesc); 
     592         
     593        // finally, say that we're transparent 
     594        mh = GetMediaHandler(mkvTrack->theMedia); 
     595        MediaSetGraphicsMode(mh, graphicsModePreWhiteAlpha, NULL); 
     596         
     597        // and save our sample description 
     598        mkvTrack->sampleHdl = (SampleDescriptionHandle) imgDesc; 
     599 
     600bail: 
     601        if (err) DisposeHandle((Handle) imgDesc); 
    533602        return err; 
    534603} 
     
    539608        if (tr_codec == NULL) 
    540609                return 0; 
     610         
     611        // how should we handle compressed tracks? 
     612        KaxContentEncodings *contentEncs = FindChild<KaxContentEncodings>(*tr_entry); 
     613        if (contentEncs) { 
     614                return 'COMP'; 
     615        } 
    541616         
    542617        string codecString(*tr_codec); 
  • trunk/Perian.xcodeproj/project.pbxproj

    r140 r141  
    5252                11C85FE60A64314500DF3D73 /* FFusionCodec.r in Rez */ = {isa = PBXBuildFile; fileRef = F560DF0203D622D001ABA332 /* FFusionCodec.r */; }; 
    5353                11C85FE70A64315500DF3D73 /* Perian-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 11A709DA0A3CFCB6002058D4 /* Perian-Info.plist */; }; 
     54                6123D6260AD0A3FF003EDE52 /* VobSubCodec.c in Sources */ = {isa = PBXBuildFile; fileRef = 6123D6220AD0A3FE003EDE52 /* VobSubCodec.c */; }; 
     55                6123D6270AD0A3FF003EDE52 /* VobSubCodec.r in Rez */ = {isa = PBXBuildFile; fileRef = 6123D6240AD0A3FE003EDE52 /* VobSubCodec.r */; }; 
    5456                61CB11200ACDF3A2007994BD /* Debug.h in Headers */ = {isa = PBXBuildFile; fileRef = 61CB11070ACDF3A2007994BD /* Debug.h */; }; 
    5557                61CB11210ACDF3A2007994BD /* EbmlBinary.h in Headers */ = {isa = PBXBuildFile; fileRef = 61CB11080ACDF3A2007994BD /* EbmlBinary.h */; }; 
     
    229231                11D4EFA20A3CE8C10066D45F /* libavutil.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavutil.a; path = build/Universal/libavutil.a; sourceTree = "<group>"; }; 
    230232                11D4EFA30A3CE8C10066D45F /* libpostproc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpostproc.a; path = build/Universal/libpostproc.a; sourceTree = "<group>"; }; 
     233                6123D6220AD0A3FE003EDE52 /* VobSubCodec.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = VobSubCodec.c; sourceTree = "<group>"; }; 
     234                6123D6230AD0A3FE003EDE52 /* VobSubCodec.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = VobSubCodec.h; sourceTree = "<group>"; }; 
     235                6123D6240AD0A3FE003EDE52 /* VobSubCodec.r */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.rez; path = VobSubCodec.r; sourceTree = "<group>"; }; 
     236                6123D6250AD0A3FF003EDE52 /* VobSubCodecDispatch.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = VobSubCodecDispatch.h; sourceTree = "<group>"; }; 
    231237                61CB10FF0ACDF350007994BD /* libebml.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libebml.a; sourceTree = BUILT_PRODUCTS_DIR; }; 
    232238                61CB11070ACDF3A2007994BD /* Debug.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Debug.h; path = libebml/ebml/Debug.h; sourceTree = "<group>"; }; 
     
    425431                        isa = PBXGroup; 
    426432                        children = ( 
     433                                6123D6240AD0A3FE003EDE52 /* VobSubCodec.r */, 
    427434                                61D691590AC8E382000EFC7D /* MatroskaImport.r */, 
    428435                                61D691540AC8E382000EFC7D /* MatroskaExport.r */, 
     
    441448                        children = ( 
    442449                                61D691460AC8E333000EFC7D /* Matroska */, 
     450                                6123D61D0AD0A052003EDE52 /* Subtitles */, 
    443451                                11C85ED30A641E6400DF3D73 /* ff_dataref.c */, 
    444452                                8F483BBC0A642B3D002CCA73 /* ff_MovieImportDispatch.h */, 
     
    465473                        ); 
    466474                        name = Products; 
     475                        sourceTree = "<group>"; 
     476                }; 
     477                6123D61D0AD0A052003EDE52 /* Subtitles */ = { 
     478                        isa = PBXGroup; 
     479                        children = ( 
     480                                6123D6220AD0A3FE003EDE52 /* VobSubCodec.c */, 
     481                                6123D6230AD0A3FE003EDE52 /* VobSubCodec.h */, 
     482                                6123D6250AD0A3FF003EDE52 /* VobSubCodecDispatch.h */, 
     483                        ); 
     484                        name = Subtitles; 
    467485                        sourceTree = "<group>"; 
    468486                }; 
     
    799817                                11C85FE60A64314500DF3D73 /* FFusionCodec.r in Rez */, 
    800818                                61CB12260ACE1074007994BD /* MatroskaImport.r in Rez */, 
     819                                6123D6270AD0A3FF003EDE52 /* VobSubCodec.r in Rez */, 
    801820                        ); 
    802821                        runOnlyForDeploymentPostprocessing = 0; 
     
    848867                                61CB120C0ACE0F8A007994BD /* DataHandlerCallback.cpp in Sources */, 
    849868                                61CB120D0ACE0F8D007994BD /* MatroskaCodecIDs.cpp in Sources */, 
     869                                6123D6260AD0A3FF003EDE52 /* VobSubCodec.c in Sources */, 
    850870                        ); 
    851871                        runOnlyForDeploymentPostprocessing = 0; 
  • trunk/exportedSymbols

    r23 r141  
    11_FFusionCodecComponentDispatch 
    22_FFAvi_MovieImportComponentDispatch 
     3_MatroskaImportComponentDispatch 
     4_VobSubCodecComponentDispatch