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:
71
sample.cpp
71
sample.cpp
@@ -19,10 +19,8 @@
|
||||
#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:
|
||||
@@ -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,25 +115,21 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
if (pMuxingApp == NULL)
|
||||
printf("\t\tMuxing App\t\t: NULL\n");
|
||||
else
|
||||
{
|
||||
else {
|
||||
printf("\t\tMuxing App\t\t: %ls\n", 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;
|
||||
}
|
||||
@@ -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,8 +163,7 @@ 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;
|
||||
}
|
||||
@@ -195,14 +180,12 @@ 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;
|
||||
}
|
||||
|
||||
if (trackType == mkvparser::Track::kVideo)
|
||||
{
|
||||
if (trackType == mkvparser::Track::kVideo) {
|
||||
const VideoTrack* const pVideoTrack =
|
||||
static_cast<const VideoTrack* >(pTrack);
|
||||
|
||||
@@ -216,8 +199,7 @@ int main(int argc, char* argv[])
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -270,8 +250,7 @@ int main(int argc, char* argv[])
|
||||
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,11 +266,9 @@ 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)
|
||||
{
|
||||
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;
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user