Changeset 1243
- Timestamp:
- 01/09/10 03:35:20 (8 months ago)
- Files:
-
- 1 modified
-
trunk/MatroskaImportPrivate.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/MatroskaImportPrivate.cpp
r1240 r1243 235 235 ComponentResult MatroskaImport::ReadTracks(KaxTracks &trackEntries) 236 236 { 237 Track firstVideoTrack = NULL; short firstVideoTrackLang = 0; 238 Track firstAudioTrack = NULL; short firstAudioTrackLang = 0; 239 Track firstSubtitleTrack = NULL; short firstSubtitleTrackLang = 0; 237 Track firstVideoTrack = NULL; short firstVideoTrackLang = 0; bool videoEnabled = false; 238 Track firstAudioTrack = NULL; short firstAudioTrackLang = 0; bool audioEnabled = false; 239 Track firstSubtitleTrack = NULL; short firstSubtitleTrackLang = 0; bool subtitleEnabled = false; 240 240 ComponentResult err = noErr; 241 bool foundAnEnabledTrack = false;242 241 243 242 if (seenTracks) … … 262 261 mkvTrack.type = uint8(type); 263 262 mkvTrack.defaultDuration = uint32(defaultDuration) / float(timecodeScale) + .5; 263 mkvTrack.isEnabled = uint8(enabled); 264 mkvTrack.usesLacing = uint8(lacing); 264 265 265 266 KaxTrackLanguage & trackLang = GetChild<KaxTrackLanguage>(track); … … 273 274 err = AddVideoTrack(track, mkvTrack); 274 275 if (err) return err; 276 277 if (mkvTrack.isEnabled) 278 videoEnabled = true; 275 279 276 280 if (firstVideoTrack && qtLang != firstVideoTrackLang) … … 287 291 if (err) return err; 288 292 293 if (mkvTrack.isEnabled) 294 audioEnabled = true; 295 289 296 if (firstAudioTrack && qtLang != firstAudioTrackLang) 290 297 SetTrackAlternate(firstAudioTrack, mkvTrack.theTrack); … … 300 307 if (err) return err; 301 308 if (mkvTrack.theTrack == NULL) continue; 309 310 if (mkvTrack.isEnabled) 311 subtitleEnabled = true; 302 312 303 313 if (firstSubtitleTrack && qtLang != firstSubtitleTrackLang) … … 317 327 continue; 318 328 } 319 320 mkvTrack.isEnabled = uint8(enabled);321 mkvTrack.usesLacing = uint8(lacing);322 329 323 330 if (encodings) { … … 362 369 for (int i = 0; i < tracks.size(); i++) { 363 370 SetTrackEnabled(tracks[i].theTrack, tracks[i].isEnabled); 364 if (tracks[i].isEnabled)365 foundAnEnabledTrack = true;366 371 } 367 372 // ffmpeg used to write a TrackDefault of 0 for all tracks 368 373 // ensure that at least one track of each media type is enabled, if none were originally 369 374 // this picks the first track, which may not be the best, but the situation is quite rare anyway 370 if (!foundAnEnabledTrack) { 371 if (firstVideoTrack) 372 SetTrackEnabled(firstVideoTrack, 1); 373 if (firstAudioTrack) 374 SetTrackEnabled(firstAudioTrack, 1); 375 if (firstSubtitleTrack) 376 SetTrackEnabled(firstSubtitleTrack, 1); 377 } 375 // FIXME properly choose tracks based on forced/default/language flags, and consider turning auto-alternates back on 376 if (!videoEnabled && firstVideoTrack) 377 SetTrackEnabled(firstVideoTrack, 1); 378 if (!audioEnabled && firstAudioTrack) 379 SetTrackEnabled(firstAudioTrack, 1); 380 if (!subtitleEnabled && firstSubtitleTrack) 381 SetTrackEnabled(firstSubtitleTrack, 1); 378 382 379 383 seenTracks = true;
