Changeset 218

Show
Ignore:
Timestamp:
12/30/06 18:32:53 (2 years ago)
Author:
dconrad
Message:

Move the codec fourccs that we define to its own header so it can be shared between c, c++, and rez. Also clean up the Matroska selection of codec-specific extras to the ASBD and sample description.

Files:

Legend:

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

    r163 r218  
    438438        return noErr; 
    439439} 
     440 
     441ComponentResult MkvFinishSampleDescription(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir) 
     442{ 
     443        switch ((*desc)->dataFormat) { 
     444                case kH264CodecType: 
     445                        return DescExt_H264(tr_entry, desc, dir); 
     446                         
     447                case kAudioFormatXiphVorbis: 
     448                        return DescExt_XiphVorbis(tr_entry, desc, dir); 
     449                         
     450                case kAudioFormatXiphFLAC: 
     451                        return DescExt_XiphFLAC(tr_entry, desc, dir); 
     452                         
     453                case kSubFormatVobSub: 
     454                        return DescExt_VobSub(tr_entry, desc, dir); 
     455                         
     456                case kVideoFormatReal5: 
     457                case kVideoFormatRealG2: 
     458                case kVideoFormatReal8: 
     459                case kVideoFormatReal9: 
     460                        return DescExt_Real(tr_entry, desc, dir); 
     461                         
     462                case kMPEG4VisualCodecType: 
     463                        return DescExt_mp4v(tr_entry, desc, dir); 
     464        } 
     465        return noErr; 
     466} 
     467 
     468ComponentResult MkvFinishASBD(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd) 
     469{ 
     470        switch (asbd->mFormatID) { 
     471                case kAudioFormatMPEG4AAC: 
     472                        return ASBDExt_AAC(tr_entry, asbd); 
     473                         
     474                case kAudioFormatAC3: 
     475                        return ASBDExt_AC3(tr_entry, asbd); 
     476                         
     477                case kAudioFormatLinearPCM: 
     478                        return ASBDExt_LPCM(tr_entry, asbd); 
     479        } 
     480        return noErr; 
     481} 
     482 
    440483 
    441484short GetTrackLanguage(KaxTrackEntry *tr_entry) { 
  • trunk/MatroskaCodecIDs.h

    r163 r218  
    3030#include <matroska/KaxTracks.h> 
    3131#include <matroska/KaxTrackEntryData.h> 
     32#include "CodecIDs.h" 
     33 
    3234using namespace libmatroska; 
    33  
    34  
    35 // Description Extensions 
    36 enum { 
    37     kCookieTypeOggSerialNo = 'oCtN' 
    38 }; 
    39  
    40 // format specific cookie types 
    41 enum { 
    42     kCookieTypeVorbisHeader = 'vCtH', 
    43     kCookieTypeVorbisComments = 'vCt#', 
    44     kCookieTypeVorbisCodebooks = 'vCtC', 
    45         kCookieTypeVorbisFirstPageNo = 'vCtN' 
    46 }; 
    47  
    48 enum { 
    49     kCookieTypeSpeexHeader = 'sCtH', 
    50     kCookieTypeSpeexComments = 'sCt#', 
    51     kCookieTypeSpeexExtraHeader = 'sCtX' 
    52 }; 
    53  
    54 enum { 
    55     kCookieTypeTheoraHeader = 'tCtH', 
    56     kCookieTypeTheoraComments = 'tCt#', 
    57     kCookieTypeTheoraCodebooks = 'tCtC' 
    58 }; 
    59  
    60 enum { 
    61     kCookieTypeFLACStreaminfo = 'fCtS', 
    62     kCookieTypeFLACMetadata = 'fCtM' 
    63 }; 
    64  
    65 enum { 
    66         kSampleDescriptionExtensionTheora = 'XdxT', 
    67         kSampleDescriptionExtensionVobSubIdx = '.IDX', 
    68         kSampleDescriptionExtensionReal = 'RVex', 
    69 }; 
    70  
    71  
    72 enum { 
    73         // unofficial QuickTime FourCCs 
    74     kAudioFormatXiphVorbis                  = 'XiVs', 
    75     kAudioFormatXiphSpeex                   = 'XiSp', 
    76     kAudioFormatXiphFLAC                    = 'XiFL', 
    77     kVideoFormatXiphTheora                  = 'XiTh', 
    78         kAudioFormatAC3MS                       = 0x6D732000, 
    79         kVideoFormatMSMPEG4v3                   = 'MP43', 
    80          
    81         kSubFormatUTF8                          = 'SRT ', 
    82         kSubFormatSSA                           = 'SSA ', 
    83         kSubFormatASS                           = 'ASS ', 
    84         kSubFormatUSF                           = 'USF ', 
    85         kSubFormatVobSub                        = 'SPU ', 
    86          
    87         // the following 4CCs don't have decoder support yet 
    88         kMPEG1VisualCodecType                   = 'mp1v', 
    89         kMPEG2VisualCodecType                   = 'mp2v', 
    90         kAudioFormatDTS                         = 'DTS ',  
    91         kAudioFormatTTA                         = 'TTA1', 
    92         kAudioFormatWavepack                    = 'WVPK', 
    93         kVideoFormatReal5                       = 'RV10', 
    94         kVideoFormatRealG2                      = 'RV20', 
    95         kVideoFormatReal8                       = 'RV30', 
    96         kVideoFormatReal9                       = 'RV40', 
    97         kAudioFormatReal1                       = '14_4', 
    98         kAudioFormatReal2                       = '28_8', 
    99         kAudioFormatRealCook                    = 'COOK', 
    100         kAudioFormatRealSipro                   = 'SIPR', 
    101         kAudioFormatRealLossless                = 'RALF', 
    102         kAudioFormatRealAtrac3                  = 'ATRC' 
    103 }; 
    104  
    10535 
    10636 
     
    11545 
    11646 
    117 // these functions modify the AudioStreamBasicDescription properly for the audio format 
    118 ComponentResult ASBDExt_AC3(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd); 
    119 ComponentResult ASBDExt_LPCM(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd); 
    120 ComponentResult ASBDExt_AAC(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd); 
    121  
    122  
    123 struct ASBDExtensionFunc { 
    124         OSType cType; 
    125         ComponentResult (*finishASBD) (KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd); 
    126 }; 
    127  
    128 const struct ASBDExtensionFunc kMatroskaASBDExtensionFuncs[] = { 
    129         { kAudioFormatMPEG4AAC, ASBDExt_AAC }, 
    130         { kAudioFormatAC3, ASBDExt_AC3 }, 
    131         { kAudioFormatLinearPCM, ASBDExt_LPCM } 
    132 }; 
    133  
    134  
    13547typedef enum { 
    13648        kToKaxTrackEntry, 
     
    13850} DescExtDirection; 
    13951 
    140 // these functions set/read extensions to the ImageDescription/SoundDescription 
    141 ComponentResult DescExt_H264(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
    142 ComponentResult DescExt_XiphVorbis(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
    143 ComponentResult DescExt_XiphFLAC(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
    144 ComponentResult DescExt_VobSub(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
    145 ComponentResult DescExt_Real(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
    146 ComponentResult DescExt_mp4v(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
    147  
    148  
    149 struct CodecDescExtFunc { 
    150         OSType cType; 
    151         ComponentResult (*descExtension) (KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
    152 }; 
    153  
    154 const struct CodecDescExtFunc kMatroskaSampleDescExtFuncs[] = { 
    155         { kH264CodecType, DescExt_H264 }, 
    156         { kAudioFormatXiphVorbis, DescExt_XiphVorbis }, 
    157         { kAudioFormatXiphFLAC, DescExt_XiphFLAC }, 
    158         { kSubFormatVobSub, DescExt_VobSub }, 
    159         { kVideoFormatReal5, DescExt_Real }, 
    160         { kVideoFormatRealG2, DescExt_Real }, 
    161         { kVideoFormatReal8, DescExt_Real }, 
    162         { kVideoFormatReal9, DescExt_Real }, 
    163         { kMPEG4VisualCodecType, DescExt_mp4v }, 
    164 }; 
    165  
    166  
     52ComponentResult MkvFinishSampleDescription(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 
     53ComponentResult MkvFinishASBD(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd); 
    16754short GetTrackLanguage(KaxTrackEntry *tr_entry); 
    16855FourCharCode GetFourCC(KaxTrackEntry *tr_entry); 
  • trunk/MkvMovieSetup.cpp

    r217 r218  
    501501        asbd.mChannelsPerFrame = uint32(*numChannels); 
    502502         
    503         for (int i = 0; i < sizeof(kMatroskaASBDExtensionFuncs) / sizeof(struct ASBDExtensionFunc); i++) { 
    504                 if (asbd.mFormatID == kMatroskaASBDExtensionFuncs[i].cType) { 
    505                         kMatroskaASBDExtensionFuncs[i].finishASBD(tr_entry, &asbd); 
    506                         break; 
    507                 } 
    508         } 
     503        MkvFinishASBD(tr_entry, &asbd); 
    509504         
    510505        // get more info about the codec 
     
    817812#endif 
    818813        } else { 
    819                 for (int i = 0; i < sizeof(kMatroskaSampleDescExtFuncs) / sizeof(struct CodecDescExtFunc); i++) { 
    820                         if ((*desc)->dataFormat == kMatroskaSampleDescExtFuncs[i].cType) { 
    821                                 kMatroskaSampleDescExtFuncs[i].descExtension(tr_entry, desc, kToSampleDescription); 
    822                                 break; 
    823                         } 
    824                 } 
    825         } 
    826 
     814                MkvFinishSampleDescription(tr_entry, desc, kToSampleDescription); 
     815        } 
     816
  • trunk/SubImport.h

    r158 r218  
    1212 
    1313#include <QuickTime/QuickTime.h> 
    14  
    15 #define kSubFormatUTF8 'SRT ' 
     14#include "CodecIDs.h" 
    1615 
    1716#ifdef __cplusplus 
  • trunk/TextSubCodec.h

    r143 r218  
    77 * 
    88 */ 
    9  
    10  
    11 #define kPlainTextSub           'SRT ' 
     9#include "CodecIDs.h" 
    1210 
    1311#define kTextSubCodecFormatName "Text Subtitle" 
  • trunk/TextSubCodec.r

    r143 r218  
    9090resource 'thng' (kTextSubCodecResource) { 
    9191        decompressorComponentType,                              // Type                  
    92         kPlainTextSub,                                                        // SubType 
     92        kSubFormatUTF8,                                                       // SubType 
    9393        kManufacturer,                                                  // Manufacturer 
    9494                                                                                        // - use componentHasMultiplePlatforms 
  • trunk/VobSubCodec.c

    r166 r218  
    418418    Handle descExtension = NewHandle(0); 
    419419     
    420     err = GetImageDescriptionExtension(imageDescription, &descExtension, kIDXExtension, 1); 
     420    err = GetImageDescriptionExtension(imageDescription, &descExtension, kSampleDescriptionExtensionVobSubIdx, 1); 
    421421     
    422422    char *string = (char *) *descExtension; 
  • trunk/VobSubCodec.h

    r141 r218  
    77 * 
    88 */ 
     9#include "CodecIDs.h" 
    910 
    1011// The high word is the codecInterfaceVersion 
    1112#define kVobSubCodecVersion             (0x00020001) 
    12  
    13 #define kVobSubCodec            'SPU ' 
    14 #define kIDXExtension           '.IDX' 
    1513 
    1614#define kVobSubCodecFormatName  "VobSub" 
  • trunk/VobSubCodec.r

    r141 r218  
    9191resource 'thng' (kVobSubCodecResource) { 
    9292        decompressorComponentType,                              // Type                  
    93         kVobSubCodec,                                                 // SubType 
     93        kSubFormatVobSub,                                                     // SubType 
    9494        kManufacturer,                                                  // Manufacturer 
    9595                                                                                        // - use componentHasMultiplePlatforms