mkvparser sample: clang-formatify

Exception asterisk placement, which was left as before to match the rest of
libwebm.

Change-Id: I3947acc936cca68df72a5bcd8dec17ed40658ba6
This commit is contained in:
Tom Finegan
2014-01-23 10:38:20 -08:00
parent 327e8ab617
commit 71a097fb12

View File

@@ -19,10 +19,8 @@
#pragma warning(disable:4996) #pragma warning(disable:4996)
#endif #endif
static const wchar_t* utf8towcs(const char* str) static const wchar_t* utf8towcs(const char* str) {
{ if (str == NULL) return NULL;
if (str == NULL)
return NULL;
// TODO: this probably requires that the locale be // TODO: this probably requires that the locale be
// configured somehow: // configured somehow:
@@ -40,11 +38,8 @@ static const wchar_t* utf8towcs(const char* str)
return val; return val;
} }
int main(int argc, char* argv[]) {
int main(int argc, char* argv[]) if (argc == 1) {
{
if (argc == 1)
{
printf("\t\t\tMkv Parser Sample Application\n"); printf("\t\t\tMkv Parser Sample Application\n");
printf("\t\t\tUsage: \n"); printf("\t\t\tUsage: \n");
printf("\t\t\t ./sample [input file] \n"); printf("\t\t\t ./sample [input file] \n");
@@ -56,8 +51,7 @@ int main(int argc, char* argv[])
MkvReader reader; MkvReader reader;
if (reader.Open(argv[1])) if (reader.Open(argv[1])) {
{
printf("\n Filename is invalid or error while opening.\n"); printf("\n Filename is invalid or error while opening.\n");
return -1; return -1;
} }
@@ -84,8 +78,7 @@ int main(int argc, char* argv[])
seg_t* pSegment_; seg_t* pSegment_;
long long ret = seg_t::CreateInstance(&reader, pos, pSegment_); long long ret = seg_t::CreateInstance(&reader, pos, pSegment_);
if (ret) if (ret) {
{
printf("\n Segment::CreateInstance() failed."); printf("\n Segment::CreateInstance() failed.");
return -1; return -1;
} }
@@ -93,8 +86,7 @@ int main(int argc, char* argv[])
const std::auto_ptr<seg_t> pSegment(pSegment_); const std::auto_ptr<seg_t> pSegment(pSegment_);
ret = pSegment->Load(); ret = pSegment->Load();
if (ret < 0) if (ret < 0) {
{
printf("\n Segment::Load() failed."); printf("\n Segment::Load() failed.");
return -1; return -1;
} }
@@ -123,25 +115,21 @@ int main(int argc, char* argv[])
if (pTitle == NULL) if (pTitle == NULL)
printf("\t\tTrack Name\t\t: NULL\n"); printf("\t\tTrack Name\t\t: NULL\n");
else else {
{
printf("\t\tTrack Name\t\t: %ls\n", pTitle); printf("\t\tTrack Name\t\t: %ls\n", pTitle);
delete[] pTitle; delete[] pTitle;
} }
if (pMuxingApp == NULL) if (pMuxingApp == NULL)
printf("\t\tMuxing App\t\t: NULL\n"); printf("\t\tMuxing App\t\t: NULL\n");
else else {
{
printf("\t\tMuxing App\t\t: %ls\n", pMuxingApp); printf("\t\tMuxing App\t\t: %ls\n", pMuxingApp);
delete[] pMuxingApp; delete[] pMuxingApp;
} }
if (pWritingApp == NULL) if (pWritingApp == NULL)
printf("\t\tWriting App\t\t: NULL\n"); printf("\t\tWriting App\t\t: NULL\n");
else else {
{
printf("\t\tWriting App\t\t: %ls\n", pWritingApp); printf("\t\tWriting App\t\t: %ls\n", pWritingApp);
delete[] pWritingApp; delete[] pWritingApp;
} }
@@ -159,12 +147,10 @@ int main(int argc, char* argv[])
printf("\n\t\t\t Track Info\n"); printf("\n\t\t\t Track Info\n");
while (i != j) while (i != j) {
{
const Track* const pTrack = pTracks->GetTrackByIndex(i++); const Track* const pTrack = pTracks->GetTrackByIndex(i++);
if (pTrack == NULL) if (pTrack == NULL) continue;
continue;
const long trackType = pTrack->GetType(); const long trackType = pTrack->GetType();
const long trackNumber = pTrack->GetNumber(); const long trackNumber = pTrack->GetNumber();
@@ -177,8 +163,7 @@ int main(int argc, char* argv[])
if (pTrackName == NULL) if (pTrackName == NULL)
printf("\t\tTrack Name\t\t: NULL\n"); printf("\t\tTrack Name\t\t: NULL\n");
else else {
{
printf("\t\tTrack Name\t\t: %ls \n", pTrackName); printf("\t\tTrack Name\t\t: %ls \n", pTrackName);
delete[] pTrackName; delete[] pTrackName;
} }
@@ -195,14 +180,12 @@ int main(int argc, char* argv[])
if (pCodecName == NULL) if (pCodecName == NULL)
printf("\t\tCodec Name\t\t: NULL\n"); printf("\t\tCodec Name\t\t: NULL\n");
else else {
{
printf("\t\tCodec Name\t\t: %ls\n", pCodecName); printf("\t\tCodec Name\t\t: %ls\n", pCodecName);
delete[] pCodecName; delete[] pCodecName;
} }
if (trackType == mkvparser::Track::kVideo) if (trackType == mkvparser::Track::kVideo) {
{
const VideoTrack* const pVideoTrack = const VideoTrack* const pVideoTrack =
static_cast<const VideoTrack* >(pTrack); static_cast<const VideoTrack* >(pTrack);
@@ -216,8 +199,7 @@ int main(int argc, char* argv[])
printf("\t\tVideo Rate\t\t: %f\n", rate); printf("\t\tVideo Rate\t\t: %f\n", rate);
} }
if (trackType == mkvparser::Track::kAudio) if (trackType == mkvparser::Track::kAudio) {
{
const AudioTrack* const pAudioTrack = const AudioTrack* const pAudioTrack =
static_cast<const AudioTrack* >(pTrack); static_cast<const AudioTrack* >(pTrack);
@@ -243,16 +225,14 @@ int main(int argc, char* argv[])
printf("\t\tCluster Count\t: %ld\n\n", clusterCount); printf("\t\tCluster Count\t: %ld\n\n", clusterCount);
if (clusterCount == 0) if (clusterCount == 0) {
{
printf("\t\tSegment has no clusters.\n"); printf("\t\tSegment has no clusters.\n");
return -1; return -1;
} }
const mkvparser::Cluster* pCluster = pSegment->GetFirst(); const mkvparser::Cluster* pCluster = pSegment->GetFirst();
while ((pCluster != NULL) && !pCluster->EOS()) while ((pCluster != NULL) && !pCluster->EOS()) {
{
const long long timeCode = pCluster->GetTimeCode(); const long long timeCode = pCluster->GetTimeCode();
printf("\t\tCluster Time Code\t: %lld\n", timeCode); printf("\t\tCluster Time Code\t: %lld\n", timeCode);
@@ -270,8 +250,7 @@ int main(int argc, char* argv[])
return -1; return -1;
} }
while ((pBlockEntry != NULL) && !pBlockEntry->EOS()) while ((pBlockEntry != NULL) && !pBlockEntry->EOS()) {
{
const Block* const pBlock = pBlockEntry->GetBlock(); const Block* const pBlock = pBlockEntry->GetBlock();
const long long trackNum = pBlock->GetTrackNumber(); const long long trackNum = pBlock->GetTrackNumber();
const unsigned long tn = static_cast<unsigned long>(trackNum); const unsigned long tn = static_cast<unsigned long>(trackNum);
@@ -279,8 +258,7 @@ int main(int argc, char* argv[])
if (pTrack == NULL) if (pTrack == NULL)
printf("\t\t\tBlock\t\t:UNKNOWN TRACK TYPE\n"); printf("\t\t\tBlock\t\t:UNKNOWN TRACK TYPE\n");
else else {
{
const long long trackType = pTrack->GetType(); const long long trackType = pTrack->GetType();
const int frameCount = pBlock->GetFrameCount(); const int frameCount = pBlock->GetFrameCount();
const long long time_ns = pBlock->GetTime(pCluster); const long long time_ns = pBlock->GetTime(pCluster);
@@ -288,11 +266,9 @@ int main(int argc, char* argv[])
printf("\t\t\tBlock\t\t:%s,%s,%15lld,%lld\n", printf("\t\t\tBlock\t\t:%s,%s,%15lld,%lld\n",
(trackType == mkvparser::Track::kVideo) ? "V" : "A", (trackType == mkvparser::Track::kVideo) ? "V" : "A",
pBlock->IsKey() ? "I" : "P", pBlock->IsKey() ? "I" : "P", time_ns, discard_padding);
time_ns, discard_padding);
for (int i = 0; i < frameCount; ++i) for (int i = 0; i < frameCount; ++i) {
{
const Block::Frame &theFrame = pBlock->GetFrame(i); const Block::Frame &theFrame = pBlock->GetFrame(i);
const long size = theFrame.len; const long size = theFrame.len;
const long long offset = theFrame.pos; const long long offset = theFrame.pos;
@@ -302,8 +278,7 @@ int main(int argc, char* argv[])
status = pCluster->GetNext(pBlockEntry, pBlockEntry); status = pCluster->GetNext(pBlockEntry, pBlockEntry);
if (status < 0) if (status < 0) {
{
printf("\t\t\tError parsing next block of cluster\n"); printf("\t\t\tError parsing next block of cluster\n");
fflush(stdout); fflush(stdout);
return -1; return -1;