|
From: Yoda-JM <yo...@us...> - 2010-04-11 16:11:23
|
Module: performous
Branch: master
Commit: fb9e7003f267d24275b8dcfcbdfac9bf111ce87a
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun Apr 11 18:11:06 2010 +0200
Added US Singstar video support
---
tools/ipu_conv.cpp | 73 ++++++++++++++++++++++++++-----------------------
tools/ipuconv.hh | 2 +-
tools/ss_extract.cpp | 14 +++++++---
3 files changed, 50 insertions(+), 39 deletions(-)
diff --git a/tools/ipu_conv.cpp b/tools/ipu_conv.cpp
index ecb504b..c71a23c 100644
--- a/tools/ipu_conv.cpp
+++ b/tools/ipu_conv.cpp
@@ -2,7 +2,7 @@
#include <iostream>
#include <stdexcept>
-IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename): infile(indata), outfile(outfilename.c_str()) {
+IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename, bool pal): infile(indata), outfile(outfilename.c_str()) {
int sizex;
int sizey;
int frames;
@@ -45,7 +45,7 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
for (frame=0;frame<frames;frame++){
if (frame % 100 == 0) std::cout << "Frame: " << frame << "/" << frames << "\r" << std::flush;
flag = infile.get(8);
-
+
if (flag & 32) {
fprintf (stderr,"Intra VLC format not supported\n");
exit(1);
@@ -59,8 +59,12 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
// 2 4:3
// 3 16:9
// 4 2.21:1
-
- outfile.putbits(0x3,4); // Framerate 3 25 fps
+
+ if(pal) {
+ outfile.putbits(0x3,4); // Framerate 3 25 fps
+ } else {
+ outfile.putbits(0x4,4); // Framerate 4 29.97 fps
+ }
outfile.putbits(0x30d4,18); // Bitrate ($3FFFF=Variabel)
outfile.putbits(1,1); // Marker, soll immer 1 sein
@@ -68,10 +72,10 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
outfile.putbits(0,1); // Constrained Parameter Flag
outfile.putbits(0,1); // Intra Matrix Standard
outfile.putbits(0,1); // Non-Intra Matrix Standard
-// outfile.putbits(0x2cee100,32);
-
+ //outfile.putbits(0x2cee100,32);
+
if (!(flag & 128)) {
- // Sequence Extension
+ // Sequence Extension
outfile.putbits(0x1b5,32);
outfile.putbits(0x1,4); // Start Code Identifier
outfile.putbits(0x4,4); // Main Profil
@@ -86,23 +90,24 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
outfile.putbits(0x0,1); // Low Delay
outfile.putbits(0x0,2); // Framerate Extension Numerator
outfile.putbits(0x0,5); // Framerate Extension Denominator
-// outfile.putbits(0x148a0001,32);
-// outfile.putbits(0,16);
-
-/* // Sequence Display Extension
- * outfile.putbits(0x1b5,32);
- * outfile.putbits(0x2,4); // Start Code Identifier
- * outfile.putbits(0x1,3); // Video Format 1 PAL
- * outfile.putbits(0x0,1); // Bit Color
- *
-// outfile.putbits(0x23050504,32);
- *
- * outfile.putbits(sizex,14); // Display Breite
- * outfile.putbits(1,1); // Marker
- * outfile.putbits(sizey,14); // Display Höhe
- * outfile.putbits(0,3);
- */
- }
+ //outfile.putbits(0x148a0001,32);
+ //outfile.putbits(0,16);
+
+ // Sequence Display Extension
+ /*
+ outfile.putbits(0x1b5,32);
+ outfile.putbits(0x2,4); // Start Code Identifier
+ outfile.putbits(0x1,3); // Video Format 1 PAL
+ outfile.putbits(0x0,1); // Bit Color
+
+ outfile.putbits(0x23050504,32);
+
+ outfile.putbits(sizex,14); // Display Breite
+ outfile.putbits(1,1); // Marker
+ outfile.putbits(sizey,14); // Display Höhe
+ outfile.putbits(0,3);
+ */
+ }
}
// Write GOP Header
@@ -115,7 +120,7 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
outfile.putbits(frame%25,6); // Frames
outfile.putbits(1,1); // Closed GOP
outfile.putbits(0,6);
-
+
// Write Picture Header
outfile.putbits(0x100,32);
outfile.putbits(0x0,10); // Temporal Reference
@@ -123,7 +128,7 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
outfile.putbits(0xffff,16); // VBV Delay
outfile.putbits(0,3);
// outfile.putbits(0xffff8,32);
-
+
// Write Picture Coding Extension
if (!(flag & 128)) {
outfile.putbits(0x1b5,32);
@@ -150,7 +155,7 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
quant = 1;
for(mb=0;mb<(sizex/16)*(sizey/16);mb++) {
if (mb>0 && !infile.get(1)) throw std::runtime_error("MBA_Incr wrong in IPU");
- // Save position (in IPU) of Macroblock
+ // Save position (in IPU) of Macroblock
infile.getpos(&MBData[mb].Byte,&MBData[mb].Bit);
if (infile.get(1)) intraquant = 0;
@@ -168,7 +173,7 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
if ( (size = infile.get_dcs_y())) {
diff = infile.get(size);
if (!(diff & (1 << (size - 1)))) diff = (-1 << size) | (diff + 1);
- dct_dc_y += diff;
+ dct_dc_y += diff;
}
if (block==0) MBData[mb].dct_dc_y = dct_dc_y;
} else {
@@ -192,7 +197,7 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
}
infile.getpos(&FrameByte,&FrameBit); // Position speichern
-
+
// Write Macroblocks
dct_dc_y = 0;
dct_dc_cb = 0;
@@ -200,10 +205,10 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
quant = 1;
for(mb=0;mb<(sizex/16)*(sizey/16);mb++) {
mb_source = (mb % (sizex / 16)) * (sizey / 16)+ mb / (sizex / 16); // Singstar
-// mb_source = mb; // Other IPUs
-
+ // mb_source = mb; // Other IPUs
+
outfile.putbits(1,1); // MBA_Incr=1
-
+
infile.setpos(MBData[mb_source].Byte,MBData[mb_source].Bit);
if (infile.get(1)) intraquant = 0;
@@ -214,7 +219,7 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
if (mb == 0 || (MBData[mb_source].quant != quant)) outfile.putbits(1,2);
else outfile.putbits(1,1);
-
+
if (flag & 4) outfile.putbits(infile.get(1),1);
if (intraquant) quant = infile.get(5);
@@ -281,7 +286,7 @@ IPUConv::IPUConv(std::vector<char> const& indata, std::string const& outfilename
outfile.putbuf();
infile.setpos(FrameByte,FrameBit);
-
+
// Jump to End of Frame
if (!infile.next_start_code()) throw std::runtime_error("End of Stream");
if (infile.get(32) != 0x000001b0) throw std::runtime_error("No 1b0");
diff --git a/tools/ipuconv.hh b/tools/ipuconv.hh
index 596e3f3..da11a45 100644
--- a/tools/ipuconv.hh
+++ b/tools/ipuconv.hh
@@ -15,6 +15,6 @@ class IPUConv {
outBitFile outfile;
int vlc(int write);
public:
- IPUConv(std::vector<char> const& indata, std::string const& outfilename);
+ IPUConv(std::vector<char> const& indata, std::string const& outfilename, bool pal = true);
};
diff --git a/tools/ss_extract.cpp b/tools/ss_extract.cpp
index 524cdad..21ce01b 100644
--- a/tools/ss_extract.cpp
+++ b/tools/ss_extract.cpp
@@ -184,8 +184,14 @@ void video_us(Song& song, PakFile const& iavFile, PakFile const& indFile, fs::pa
switch(frame%5) {
case 0:
// first 4 bytes are packet length
- iavFile.get(data, iav_offset + 4, size - 4);
- ipudata.insert(ipudata.end(), data.begin(), data.end());
+ iavFile.get(data, iav_offset, size);
+ {
+ unsigned int opaque_footer_size = 3 * sizeof(int);
+ unsigned int chunk1 = getLE32(&data[0]);
+ ipudata.insert(ipudata.end(), data.begin() + 4, data.begin() + chunk1 - opaque_footer_size);
+ unsigned int chunk2 = getLE32(&data[chunk1]);
+ ipudata.insert(ipudata.end(), data.begin() + chunk1 + 4, data.begin() + chunk1 + chunk2 - opaque_footer_size);
+ }
iav_offset += size;
break;
case 1:
@@ -193,13 +199,13 @@ void video_us(Song& song, PakFile const& iavFile, PakFile const& indFile, fs::pa
case 3:
case 4:
// audio
- iav_offset = size;
+ iav_offset += size;
break;
}
frame++;
}
- IPUConv(ipudata, (outPath / "video.mpg").string());
+ IPUConv(ipudata, (outPath / "video.mpg").string(), false);
song.video = outPath / "video.mpg";
}
|