diff --git a/avc/avcinfo.cpp b/avc/avcinfo.cpp index d0467ea..bfae3a4 100644 --- a/avc/avcinfo.cpp +++ b/avc/avcinfo.cpp @@ -117,6 +117,31 @@ void SpsInfo::parse(BinaryReader &reader, uint32 maxSize) cropping.setBottom(bitReader.readUnsignedExpGolombCodedBits()); } + // calculate actual picture size + if(!cropping.isNull()) { + // determine cropping scale + ugolomb croppingScaleX, croppingScaleY; + switch(chromaFormatIndication) { + case 1: // 4:2:0 + croppingScaleX = 2; + croppingScaleY = frameMbsOnly ? 2 : 4; + break; + case 2: // 4:2:2 + croppingScaleX = 2; + croppingScaleY = 2 - frameMbsOnly; + break; + default: // case 0: monochrome, case 3: 4:4:4 + croppingScaleX = 1; + croppingScaleY = 2 - frameMbsOnly; + break; + } + pictureSize.setWidth(mbSize.width() * 16 - croppingScaleX * (cropping.left() + cropping.right())); + pictureSize.setHeight((2 - frameMbsOnly) * mbSize.height() * 16 - croppingScaleY * (cropping.top() + cropping.bottom())); + } else { + pictureSize.setWidth(mbSize.width() * 16); + pictureSize.setHeight((2 - frameMbsOnly) * mbSize.height() * 16); + } + // read VUI (video usability information) if((vuiPresent = bitReader.readBit())) { if((bitReader.readBit())) { // PAR present flag @@ -166,6 +191,7 @@ void SpsInfo::parse(BinaryReader &reader, uint32 maxSize) pictureStructPresent = bitReader.readBit(); + // TODO: investigate error (truncated data) when parsing mtx-test-data/mkv/attachment-without-fileuid.mkv if(bitReader.readBit()) { // bitstream restriction flag bitReader.skipBits(1); // motion vectors over pic boundries flag bitReader.readUnsignedExpGolombCodedBits(); // max bytes per pic denom @@ -177,30 +203,6 @@ void SpsInfo::parse(BinaryReader &reader, uint32 maxSize) } } - // calculate actual picture size - if(!cropping.isNull()) { - // determine cropping scale - ugolomb croppingScaleX, croppingScaleY; - switch(chromaFormatIndication) { - case 1: // 4:2:0 - croppingScaleX = 2; - croppingScaleY = frameMbsOnly ? 2 : 4; - break; - case 2: // 4:2:2 - croppingScaleX = 2; - croppingScaleY = 2 - frameMbsOnly; - break; - default: // case 0: monochrome, case 3: 4:4:4 - croppingScaleX = 1; - croppingScaleY = 2 - frameMbsOnly; - break; - } - pictureSize.setWidth(mbSize.width() * 16 - croppingScaleX * (cropping.left() + cropping.right())); - pictureSize.setHeight((2 - frameMbsOnly) * mbSize.height() * 16 - croppingScaleY * (cropping.top() + cropping.bottom())); - } else { - pictureSize.setWidth(mbSize.width() * 16); - pictureSize.setHeight((2 - frameMbsOnly) * mbSize.height() * 16); - } } catch(...) { catchIoFailure(); throw TruncatedDataException(); diff --git a/matroska/matroskatrack.cpp b/matroska/matroskatrack.cpp index ddad146..3321f3e 100644 --- a/matroska/matroskatrack.cpp +++ b/matroska/matroskatrack.cpp @@ -201,7 +201,7 @@ void MatroskaTrack::internalParseHeader() { static const string context("parsing header of Matroska track"); try { - m_trackElement->parse(); + m_trackElement->parse(); } catch(const Failure &) { addNotification(NotificationType::Critical, "Unable to parse track element.", context); throw;