2006-02-23 02:44:48 +01:00
// Copyright (c) 2004-2006, Rodrigo Braz Monteiro, Mike Matsnev
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
2009-07-29 07:43:02 +02:00
// Aegisub Project http://www.aegisub.org/
2006-02-23 02:44:48 +01:00
//
2009-07-29 07:43:02 +02:00
// $Id$
/// @file mkv_wrap.cpp
/// @brief High-level interface for obtaining various data from Matroska files
/// @ingroup video_input
///
2006-02-23 02:44:48 +01:00
///////////
// Headers
2009-01-04 07:31:48 +01:00
# include "config.h"
2009-09-10 15:06:40 +02:00
# ifndef AGI_PRE
2006-02-26 03:52:29 +01:00
# include <errno.h>
2007-08-31 16:11:35 +02:00
# include <stdint.h>
2009-09-10 15:06:40 +02:00
# include <algorithm>
2006-12-26 02:08:46 +01:00
# include <wx/filename.h>
2009-09-10 15:06:40 +02:00
# include <wx/tokenzr.h>
2009-09-11 00:48:29 +02:00
# include <wx/choicdlg.h> // Keep this last so wxUSE_CHOICEDLG is set.
2009-09-10 15:06:40 +02:00
# endif
2006-12-17 06:32:18 +01:00
# include "ass_file.h"
# include "ass_time.h"
2009-09-10 15:06:40 +02:00
# include "dialog_progress.h"
# include "mkv_wrap.h"
2006-02-23 02:44:48 +01:00
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2006-02-25 21:48:32 +01:00
MatroskaWrapper MatroskaWrapper : : wrapper ;
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2006-02-23 02:44:48 +01:00
# define CACHESIZE 65536
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Constructor
///
2006-02-23 02:44:48 +01:00
MatroskaWrapper : : MatroskaWrapper ( ) {
file = NULL ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Destructor
///
2006-02-23 02:44:48 +01:00
MatroskaWrapper : : ~ MatroskaWrapper ( ) {
Close ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Open file
/// @param filename
/// @param parse
///
2006-12-17 06:32:18 +01:00
void MatroskaWrapper : : Open ( wxString filename , bool parse ) {
2006-02-23 02:44:48 +01:00
// Make sure it's closed first
Close ( ) ;
// Open
char err [ 2048 ] ;
input = new MkvStdIO ( filename ) ;
if ( input - > fp ) {
file = mkv_Open ( input , err , sizeof ( err ) ) ;
// Failed parsing
if ( ! file ) {
delete input ;
throw wxString ( _T ( " MatroskaParser error: " ) + wxString ( err , wxConvUTF8 ) ) . c_str ( ) ;
}
2006-12-17 06:32:18 +01:00
// Parse
if ( parse ) Parse ( ) ;
2006-02-23 02:44:48 +01:00
}
// Failed opening
else {
delete input ;
throw _T ( " Unable to open Matroska file for parsing. " ) ;
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Close file
/// @return
///
2006-02-23 02:44:48 +01:00
void MatroskaWrapper : : Close ( ) {
if ( file ) {
mkv_Close ( file ) ;
file = NULL ;
fclose ( input - > fp ) ;
delete input ;
}
2007-01-02 21:07:52 +01:00
keyFrames . Clear ( ) ;
timecodes . clear ( ) ;
2006-02-23 02:44:48 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Return keyframes
/// @return
///
2006-02-23 02:44:48 +01:00
wxArrayInt MatroskaWrapper : : GetKeyFrames ( ) {
return keyFrames ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Comparison operator
/// @param t1
/// @param t2
/// @return
///
2006-02-23 02:44:48 +01:00
bool operator < ( MkvFrame & t1 , MkvFrame & t2 ) {
return t1 . time < t2 . time ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Actually parse
///
2006-02-23 02:44:48 +01:00
void MatroskaWrapper : : Parse ( ) {
// Clear keyframes and timecodes
keyFrames . Clear ( ) ;
2006-02-25 21:48:32 +01:00
bytePos . Clear ( ) ;
2006-02-23 02:44:48 +01:00
timecodes . clear ( ) ;
2007-01-02 21:07:52 +01:00
frames . clear ( ) ;
rawFrames . clear ( ) ;
bytePos . Clear ( ) ;
2006-02-23 02:44:48 +01:00
// Get info
int tracks = mkv_GetNumTracks ( file ) ;
TrackInfo * trackInfo ;
SegmentInfo * segInfo = mkv_GetFileInfo ( file ) ;
// Parse tracks
for ( int track = 0 ; track < tracks ; track + + ) {
trackInfo = mkv_GetTrackInfo ( file , track ) ;
// Video track
if ( trackInfo - > Type = = 1 ) {
// Variables
ulonglong startTime , endTime , filePos ;
unsigned int rt , frameSize , frameFlags ;
2007-01-24 04:54:32 +01:00
//CompressedStream *cs = NULL;
2006-02-23 02:44:48 +01:00
// Timecode scale
2007-08-29 15:36:30 +02:00
longlong timecodeScale = mkv_TruncFloat ( trackInfo - > TimecodeScale ) * segInfo - > TimecodeScale ;
2006-02-23 02:44:48 +01:00
// Mask other tracks away
mkv_SetTrackMask ( file , ~ ( 1 < < track ) ) ;
2006-02-23 03:18:32 +01:00
// Progress bar
2007-04-04 22:42:44 +02:00
int totalTime = int ( double ( segInfo - > Duration ) / timecodeScale ) ;
2006-02-23 03:18:32 +01:00
volatile bool canceled = false ;
DialogProgress * progress = new DialogProgress ( NULL , _ ( " Parsing Matroska " ) , & canceled , _ ( " Reading keyframe and timecode data from Matroska file. " ) , 0 , totalTime ) ;
progress - > Show ( ) ;
progress - > SetProgress ( 0 , 1 ) ;
2006-02-23 02:44:48 +01:00
// Read frames
2007-10-28 00:19:49 +02:00
register int frameN = 0 ;
2006-02-23 02:44:48 +01:00
while ( mkv_ReadFrame ( file , 0 , & rt , & startTime , & endTime , & filePos , & frameSize , & frameFlags ) = = 0 ) {
2006-02-23 03:18:32 +01:00
// Read value
2006-02-23 20:26:14 +01:00
double curTime = double ( startTime ) / 1000000.0 ;
2006-02-25 21:48:32 +01:00
frames . push_back ( MkvFrame ( ( frameFlags & FRAME_KF ) ! = 0 , curTime , filePos ) ) ;
2006-02-23 20:26:14 +01:00
frameN + + ;
2006-02-23 03:18:32 +01:00
// Cancelled?
if ( canceled ) {
Close ( ) ;
throw _T ( " Canceled " ) ;
}
2007-10-28 00:19:49 +02:00
// Identical to (frameN % 2048) == 0,
// but much faster.
if ( ( frameN & ( 2048 - 1 ) ) = = 0 )
// Update progress
progress - > SetProgress ( int ( curTime ) , totalTime ) ;
2006-02-23 02:44:48 +01:00
}
2006-02-23 03:18:32 +01:00
// Clean up progress
if ( ! canceled ) progress - > Destroy ( ) ;
2006-02-23 02:44:48 +01:00
break ;
}
}
2006-03-01 04:17:31 +01:00
// Copy raw
for ( std : : list < MkvFrame > : : iterator cur = frames . begin ( ) ; cur ! = frames . end ( ) ; cur + + ) {
rawFrames . push_back ( * cur ) ;
}
2006-12-20 01:31:52 +01:00
bool sortFirst = true ;
if ( sortFirst ) {
// Process timecodes and keyframes
frames . sort ( ) ;
MkvFrame curFrame ( false , 0 , 0 ) ;
int i = 0 ;
for ( std : : list < MkvFrame > : : iterator cur = frames . begin ( ) ; cur ! = frames . end ( ) ; cur + + ) {
curFrame = * cur ;
if ( curFrame . isKey ) keyFrames . Add ( i ) ;
bytePos . Add ( curFrame . filePos ) ;
timecodes . push_back ( curFrame . time ) ;
i + + ;
}
}
else {
// Process keyframes
MkvFrame curFrame ( false , 0 , 0 ) ;
int i = 0 ;
for ( std : : list < MkvFrame > : : iterator cur = frames . begin ( ) ; cur ! = frames . end ( ) ; cur + + ) {
curFrame = * cur ;
if ( curFrame . isKey ) keyFrames . Add ( i ) ;
bytePos . Add ( curFrame . filePos ) ;
i + + ;
}
// Process timecodes
frames . sort ( ) ;
for ( std : : list < MkvFrame > : : iterator cur = frames . begin ( ) ; cur ! = frames . end ( ) ; cur + + ) {
curFrame = * cur ;
timecodes . push_back ( curFrame . time ) ;
}
2006-02-23 02:44:48 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Set target to timecodes
/// @param target
/// @return
///
2006-02-23 02:44:48 +01:00
void MatroskaWrapper : : SetToTimecodes ( FrameRate & target ) {
// Enough frames?
int frames = timecodes . size ( ) ;
if ( frames < = 1 ) return ;
// Sort
//std::sort<std::vector<double>::iterator>(timecodes.begin(),timecodes.end());
// Check if it's CFR
2008-01-16 03:46:36 +01:00
/*
2006-02-23 02:44:48 +01:00
bool isCFR = true ;
2007-10-22 22:10:35 +02:00
double estimateCFR = timecodes . back ( ) / ( timecodes . size ( ) - 1 ) ;
2007-01-01 04:29:20 +01:00
double t1 , t2 ;
for ( int i = 1 ; i < frames ; i + + ) {
t1 = timecodes [ i ] ;
t2 = timecodes [ i - 1 ] ;
2007-10-22 22:10:35 +02:00
int delta = abs ( int ( t1 - t2 - estimateCFR ) ) ;
if ( delta > 2 ) {
2006-02-23 02:44:48 +01:00
isCFR = false ;
break ;
}
}
2008-01-16 03:46:36 +01:00
*/
bool isCFR = false ;
double estimateCFR = 0 ;
2006-02-23 02:44:48 +01:00
// Constant framerate
if ( isCFR ) {
2007-10-22 22:10:35 +02:00
estimateCFR = 1 / estimateCFR * 1000.0 ;
if ( fabs ( estimateCFR - 24000.0 / 1001.0 ) < 0.02 ) estimateCFR = 24000.0 / 1001.0 ;
if ( fabs ( estimateCFR - 30000.0 / 1001.0 ) < 0.02 ) estimateCFR = 30000.0 / 1001.0 ;
2006-02-23 02:44:48 +01:00
target . SetCFR ( estimateCFR ) ;
}
// Variable framerate
else {
std : : vector < int > times ;
for ( int i = 0 ; i < frames ; i + + ) times . push_back ( int ( timecodes [ i ] + 0.5 ) ) ;
target . SetVFR ( times ) ;
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get subtitles
/// @param target
///
2006-12-17 06:32:18 +01:00
void MatroskaWrapper : : GetSubtitles ( AssFile * target ) {
// Get info
int tracks = mkv_GetNumTracks ( file ) ;
TrackInfo * trackInfo ;
2007-01-24 04:54:32 +01:00
//SegmentInfo *segInfo = mkv_GetFileInfo(file);
2006-12-17 06:32:18 +01:00
wxArrayInt tracksFound ;
wxArrayString tracksNames ;
int trackToRead = - 1 ;
// Haali's library variables
ulonglong startTime , endTime , filePos ;
unsigned int rt , frameSize , frameFlags ;
2007-01-24 04:54:32 +01:00
//CompressedStream *cs = NULL;
2006-12-17 06:32:18 +01:00
// Find tracks
for ( int track = 0 ; track < tracks ; track + + ) {
trackInfo = mkv_GetTrackInfo ( file , track ) ;
// Subtitle track
if ( trackInfo - > Type = = 0x11 ) {
wxString CodecID = wxString ( trackInfo - > CodecID , * wxConvCurrent ) ;
wxString TrackName = wxString ( trackInfo - > Name , * wxConvCurrent ) ;
wxString TrackLanguage = wxString ( trackInfo - > Language , * wxConvCurrent ) ;
// Known subtitle format
if ( CodecID = = _T ( " S_TEXT/SSA " ) | | CodecID = = _T ( " S_TEXT/ASS " ) | | CodecID = = _T ( " S_TEXT/UTF8 " ) ) {
tracksFound . Add ( track ) ;
tracksNames . Add ( wxString : : Format ( _T ( " %i ( " ) , track ) + CodecID + _T ( " " ) + TrackLanguage + _T ( " ): " ) + TrackName ) ;
}
}
}
// No tracks found
if ( tracksFound . Count ( ) = = 0 ) {
target - > LoadDefault ( true ) ;
Close ( ) ;
2007-07-18 15:46:38 +02:00
throw _T ( " File has no recognised subtitle tracks. " ) ;
2006-12-17 06:32:18 +01:00
}
// Only one track found
else if ( tracksFound . Count ( ) = = 1 ) {
trackToRead = tracksFound [ 0 ] ;
}
// Pick a track
else {
int choice = wxGetSingleChoiceIndex ( _T ( " Choose which track to read: " ) , _T ( " Multiple subtitle tracks found " ) , tracksNames ) ;
if ( choice = = - 1 ) {
target - > LoadDefault ( true ) ;
Close ( ) ;
throw _T ( " Canceled. " ) ;
}
trackToRead = tracksFound [ choice ] ;
}
// Picked track
if ( trackToRead ! = - 1 ) {
// Get codec type (0 = ASS/SSA, 1 = SRT)
trackInfo = mkv_GetTrackInfo ( file , trackToRead ) ;
wxString CodecID = wxString ( trackInfo - > CodecID , * wxConvCurrent ) ;
int codecType = 0 ;
if ( CodecID = = _T ( " S_TEXT/UTF8 " ) ) codecType = 1 ;
// Read private data if it's ASS/SSA
if ( codecType = = 0 ) {
// Read raw data
trackInfo = mkv_GetTrackInfo ( file , trackToRead ) ;
unsigned int privSize = trackInfo - > CodecPrivateSize ;
char * privData = new char [ privSize + 1 ] ;
memcpy ( privData , trackInfo - > CodecPrivate , privSize ) ;
privData [ privSize ] = 0 ;
wxString privString ( privData , wxConvUTF8 ) ;
2009-05-14 20:28:57 +02:00
delete [ ] privData ;
2006-12-17 06:32:18 +01:00
// Load into file
wxString group = _T ( " [Script Info] " ) ;
int lasttime = 0 ;
2007-04-08 23:20:32 +02:00
int version = 1 ;
if ( CodecID = = _T ( " S_TEXT/SSA " ) ) version = 0 ;
2006-12-17 06:32:18 +01:00
wxStringTokenizer token ( privString , _T ( " \r \n " ) , wxTOKEN_STRTOK ) ;
while ( token . HasMoreTokens ( ) ) {
wxString next = token . GetNextToken ( ) ;
if ( next [ 0 ] = = _T ( ' [ ' ) ) group = next ;
2007-01-08 02:00:44 +01:00
lasttime = target - > AddLine ( next , group , lasttime , version , & group ) ;
2006-12-17 06:32:18 +01:00
}
// Insert "[Events]"
2007-01-08 02:00:44 +01:00
//target->AddLine(_T(""),group,lasttime,version,&group);
//target->AddLine(_T("[Events]"),group,lasttime,version,&group);
//target->AddLine(_T("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"),group,lasttime,version,&group);
2006-12-17 06:32:18 +01:00
}
// Load default if it's SRT
else {
target - > LoadDefault ( false ) ;
}
// Read timecode scale
SegmentInfo * segInfo = mkv_GetFileInfo ( file ) ;
2007-08-29 15:36:30 +02:00
longlong timecodeScale = mkv_TruncFloat ( trackInfo - > TimecodeScale ) * segInfo - > TimecodeScale ;
2006-12-17 06:32:18 +01:00
// Prepare STD vector to get lines inserted
std : : vector < wxString > subList ;
long int order = - 1 ;
// Progress bar
2007-04-04 22:42:44 +02:00
int totalTime = int ( double ( segInfo - > Duration ) / timecodeScale ) ;
2006-12-17 06:32:18 +01:00
volatile bool canceled = false ;
DialogProgress * progress = new DialogProgress ( NULL , _ ( " Parsing Matroska " ) , & canceled , _ ( " Reading subtitles from Matroska file. " ) , 0 , totalTime ) ;
progress - > Show ( ) ;
progress - > SetProgress ( 0 , 1 ) ;
// Load blocks
mkv_SetTrackMask ( file , ~ ( 1 < < trackToRead ) ) ;
while ( mkv_ReadFrame ( file , 0 , & rt , & startTime , & endTime , & filePos , & frameSize , & frameFlags ) = = 0 ) {
// Canceled
if ( canceled ) {
target - > LoadDefault ( true ) ;
Close ( ) ;
throw _T ( " Canceled " ) ;
}
// Read to temp
char * tmp = new char [ frameSize + 1 ] ;
fseek ( input - > fp , filePos , SEEK_SET ) ;
fread ( tmp , 1 , frameSize , input - > fp ) ;
tmp [ frameSize ] = 0 ;
wxString blockString ( tmp , wxConvUTF8 ) ;
2009-05-14 20:28:57 +02:00
delete [ ] tmp ;
2006-12-17 06:32:18 +01:00
// Get start and end times
2007-08-29 15:36:30 +02:00
//longlong timecodeScaleLow = timecodeScale / 100;
longlong timecodeScaleLow = 1000000 ;
2006-12-17 06:32:18 +01:00
AssTime subStart , subEnd ;
subStart . SetMS ( startTime / timecodeScaleLow ) ;
subEnd . SetMS ( endTime / timecodeScaleLow ) ;
//wxLogMessage(subStart.GetASSFormated() + _T("-") + subEnd.GetASSFormated() + _T(": ") + blockString);
// Process SSA/ASS
if ( codecType = = 0 ) {
// Get order number
int pos = blockString . Find ( _T ( " , " ) ) ;
wxString orderString = blockString . Left ( pos ) ;
orderString . ToLong ( & order ) ;
blockString = blockString . Mid ( pos + 1 ) ;
// Get layer number
pos = blockString . Find ( _T ( " , " ) ) ;
long int layer = 0 ;
if ( pos ) {
wxString layerString = blockString . Left ( pos ) ;
layerString . ToLong ( & layer ) ;
blockString = blockString . Mid ( pos + 1 ) ;
}
// Assemble final
blockString = wxString : : Format ( _T ( " Dialogue: %i, " ) , layer ) + subStart . GetASSFormated ( ) + _T ( " , " ) + subEnd . GetASSFormated ( ) + _T ( " , " ) + blockString ;
}
// Process SRT
else {
blockString = wxString ( _T ( " Dialogue: 0, " ) ) + subStart . GetASSFormated ( ) + _T ( " , " ) + subEnd . GetASSFormated ( ) + _T ( " ,Default,,0000,0000,0000,, " ) + blockString ;
blockString . Replace ( _T ( " \r \n " ) , _T ( " \\ N " ) ) ;
blockString . Replace ( _T ( " \r " ) , _T ( " \\ N " ) ) ;
blockString . Replace ( _T ( " \n " ) , _T ( " \\ N " ) ) ;
order + + ;
}
// Insert into vector
2007-01-24 04:54:32 +01:00
if ( subList . size ( ) = = ( unsigned int ) order ) subList . push_back ( blockString ) ;
2006-12-17 06:32:18 +01:00
else {
if ( ( signed ) ( subList . size ( ) ) < order + 1 ) subList . resize ( order + 1 ) ;
subList [ order ] = blockString ;
}
// Update progress bar
2007-04-04 22:42:44 +02:00
progress - > SetProgress ( int ( double ( startTime ) / 1000000.0 ) , totalTime ) ;
2006-12-17 06:32:18 +01:00
}
// Insert into file
wxString group = _T ( " [Events] " ) ;
int lasttime = 0 ;
2007-01-08 02:00:44 +01:00
int version = ( CodecID = = _T ( " S_TEXT/SSA " ) ) ;
2006-12-17 06:32:18 +01:00
for ( unsigned int i = 0 ; i < subList . size ( ) ; i + + ) {
2007-01-08 02:00:44 +01:00
lasttime = target - > AddLine ( subList [ i ] , group , lasttime , version , & group ) ;
2006-12-17 06:32:18 +01:00
}
// Close progress bar
if ( ! canceled ) progress - > Destroy ( ) ;
}
// No track to load
else {
target - > LoadDefault ( true ) ;
}
}
2006-02-23 02:44:48 +01:00
////////////////////////////// LOTS OF HAALI C CODE DOWN HERE ///////////////////////////////////////
2007-11-13 21:28:09 +01:00
# ifdef __VISUALC__
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2007-11-13 21:28:09 +01:00
# define std_fread fread
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2007-11-13 21:28:09 +01:00
# define std_fseek _fseeki64
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2007-11-13 21:28:09 +01:00
# define std_ftell _ftelli64
# else
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2007-11-13 21:28:09 +01:00
# define std_fread fread
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2008-01-05 01:02:06 +01:00
# define std_fseek fseeko
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2008-01-05 01:02:06 +01:00
# define std_ftell ftello
2007-11-13 21:28:09 +01:00
# endif
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief STDIO class
/// @param _st
/// @param pos
/// @param buffer
/// @param count
/// @return
///
2006-02-23 02:44:48 +01:00
int StdIoRead ( InputStream * _st , ulonglong pos , void * buffer , int count ) {
MkvStdIO * st = ( MkvStdIO * ) _st ;
size_t rd ;
2007-11-13 21:28:09 +01:00
if ( std_fseek ( st - > fp , pos , SEEK_SET ) ) {
2006-02-23 02:44:48 +01:00
st - > error = errno ;
return - 1 ;
}
2007-11-13 21:28:09 +01:00
rd = std_fread ( buffer , 1 , count , st - > fp ) ;
2006-02-23 02:44:48 +01:00
if ( rd = = 0 ) {
if ( feof ( st - > fp ) )
return 0 ;
st - > error = errno ;
return - 1 ;
}
return rd ;
}
/* scan for a signature sig(big-endian) starting at file position pos
* return position of the first byte of signature or - 1 if error / not found
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief */
/// @param _st
/// @param start
/// @param signature
/// @return
///
2006-02-23 02:44:48 +01:00
longlong StdIoScan ( InputStream * _st , ulonglong start , unsigned signature ) {
MkvStdIO * st = ( MkvStdIO * ) _st ;
int c ;
unsigned cmp = 0 ;
FILE * fp = st - > fp ;
2007-11-13 21:28:09 +01:00
if ( std_fseek ( fp , start , SEEK_SET ) )
2006-02-23 02:44:48 +01:00
return - 1 ;
while ( ( c = getc ( fp ) ) ! = EOF ) {
cmp = ( ( cmp < < 8 ) | c ) & 0xffffffff ;
if ( cmp = = signature )
2007-11-13 21:28:09 +01:00
return std_ftell ( fp ) - 4 ;
2006-02-23 02:44:48 +01:00
}
return - 1 ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief This is used to limit readahead.
/// @param _st
/// @return Cache size
///
2006-02-23 02:44:48 +01:00
unsigned StdIoGetCacheSize ( InputStream * _st ) {
return CACHESIZE ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get last error message
/// @param _st
/// @return Last error message
///
2006-02-23 02:44:48 +01:00
const char * StdIoGetLastError ( InputStream * _st ) {
MkvStdIO * st = ( MkvStdIO * ) _st ;
return strerror ( st - > error ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Memory allocation, this is done via stdlib
/// @param _st
/// @param size
/// @return
///
2006-02-23 02:44:48 +01:00
void * StdIoMalloc ( InputStream * _st , size_t size ) {
return malloc ( size ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief DOCME
/// @param _st
/// @param mem
/// @param size
/// @return
///
2006-02-23 02:44:48 +01:00
void * StdIoRealloc ( InputStream * _st , void * mem , size_t size ) {
return realloc ( mem , size ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief DOCME
/// @param _st
/// @param mem
///
2006-02-23 02:44:48 +01:00
void StdIoFree ( InputStream * _st , void * mem ) {
free ( mem ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief DOCME
/// @param _st
/// @param cur
/// @param max
/// @return
///
2006-02-23 02:44:48 +01:00
int StdIoProgress ( InputStream * _st , ulonglong cur , ulonglong max ) {
return 1 ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief DOCME
/// @param _st
/// @return
///
2009-05-02 21:40:55 +02:00
longlong StdIoGetFileSize ( InputStream * _st ) {
MkvStdIO * st = ( MkvStdIO * ) _st ;
longlong epos = 0 ;
2009-05-02 22:06:06 +02:00
longlong cpos = std_ftell ( st - > fp ) ;
std_fseek ( st - > fp , 0 , SEEK_END ) ;
epos = std_ftell ( st - > fp ) ;
std_fseek ( st - > fp , cpos , SEEK_SET ) ;
2009-05-02 21:40:55 +02:00
return epos ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief DOCME
/// @param filename
///
2006-02-23 02:44:48 +01:00
MkvStdIO : : MkvStdIO ( wxString filename ) {
read = StdIoRead ;
scan = StdIoScan ;
getcachesize = StdIoGetCacheSize ;
geterror = StdIoGetLastError ;
memalloc = StdIoMalloc ;
memrealloc = StdIoRealloc ;
memfree = StdIoFree ;
progress = StdIoProgress ;
2009-05-02 21:40:55 +02:00
getfilesize = StdIoGetFileSize ;
2006-12-26 02:08:46 +01:00
wxFileName fname ( filename ) ;
fp = fopen ( fname . GetShortPath ( ) . mb_str ( wxConvUTF8 ) , " rb " ) ;
2006-02-23 02:44:48 +01:00
if ( fp ) {
setvbuf ( fp , NULL , _IOFBF , CACHESIZE ) ;
}
}
2009-07-29 07:43:02 +02:00
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00