Fixed aspect ratios in MP4.

This commit is contained in:
Thulinma 2015-09-29 14:39:59 +02:00
parent 94dafb7888
commit adc34a0ac9
2 changed files with 22 additions and 24 deletions

View file

@ -1934,8 +1934,8 @@ namespace MP4 {
initialize(); initialize();
setTrackID(trackId); setTrackID(trackId);
setDuration(duration); setDuration(duration);
setWidth(width << 16); setWidth(width);
setHeight(height << 16); setHeight(height);
} }
TKHD::TKHD(DTSC::Track & track, bool fragmented) { TKHD::TKHD(DTSC::Track & track, bool fragmented) {
@ -1946,8 +1946,8 @@ namespace MP4 {
setDuration(track.lastms - track.firstms); setDuration(track.lastms - track.firstms);
} }
if (track.type == "video") { if (track.type == "video") {
setWidth(track.width << 16); setWidth(track.width);
setHeight(track.height << 16); setHeight(track.height);
} }
} }
@ -2102,35 +2102,35 @@ namespace MP4 {
return getInt32(offset + index * 4); return getInt32(offset + index * 4);
} }
void TKHD::setWidth(uint32_t newWidth) { void TKHD::setWidth(double newWidth) {
if (getVersion() == 0) { if (getVersion() == 0) {
setInt32(newWidth, 76); setInt32(newWidth * 65536.0, 76);
} else { } else {
setInt32(newWidth, 88); setInt32(newWidth * 65536.0, 88);
} }
} }
uint32_t TKHD::getWidth() { double TKHD::getWidth() {
if (getVersion() == 0) { if (getVersion() == 0) {
return getInt32(76); return getInt32(76) / 65536.0;
} else { } else {
return getInt32(88); return getInt32(88) / 65536.0;
} }
} }
void TKHD::setHeight(uint32_t newHeight) { void TKHD::setHeight(double newHeight) {
if (getVersion() == 0) { if (getVersion() == 0) {
setInt32(newHeight, 80); setInt32(newHeight * 65536.0, 80);
} else { } else {
setInt32(newHeight, 92); setInt32(newHeight * 65536.0, 92);
} }
} }
uint32_t TKHD::getHeight() { double TKHD::getHeight() {
if (getVersion() == 0) { if (getVersion() == 0) {
return getInt32(80); return getInt32(80) / 65536.0;
} else { } else {
return getInt32(92); return getInt32(92) / 65536.0;
} }
} }
@ -2153,8 +2153,8 @@ namespace MP4 {
} }
} }
r << std::endl; r << std::endl;
r << std::string(indent + 1, ' ') << "Width: " << (getWidth() >> 16) << "." << (getWidth() & 0xFFFF) << std::endl; r << std::string(indent + 1, ' ') << "Width: " << getWidth() << std::endl;
r << std::string(indent + 1, ' ') << "Height: " << (getHeight() >> 16) << "." << (getHeight() & 0xFFFF) << std::endl; r << std::string(indent + 1, ' ') << "Height: " << getHeight() << std::endl;
return r.str(); return r.str();
} }
@ -2738,8 +2738,6 @@ namespace MP4 {
avccBox.setPayload(track.init); avccBox.setPayload(track.init);
setCLAP(avccBox); setCLAP(avccBox);
} }
MP4::PASP paspBox;
setPASP(paspBox);
} }
void VisualSampleEntry::initialize(){ void VisualSampleEntry::initialize(){

View file

@ -443,10 +443,10 @@ namespace MP4 {
void setMatrix(int32_t newMatrix, size_t index); void setMatrix(int32_t newMatrix, size_t index);
int32_t getMatrix(size_t index); int32_t getMatrix(size_t index);
void setWidth(uint32_t newWidth); void setWidth(double newWidth);
uint32_t getWidth(); double getWidth();
void setHeight(uint32_t newHeight); void setHeight(double newHeight);
uint32_t getHeight(); double getHeight();
std::string toPrettyString(uint32_t indent = 0); std::string toPrettyString(uint32_t indent = 0);
protected: protected:
void initialize(); void initialize();