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