From 4ea8fe03276ccaf21f58024c087cb84e01f4947f Mon Sep 17 00:00:00 2001 From: Oswald de Bruin Date: Tue, 18 Jun 2013 10:29:27 +0200 Subject: [PATCH] Added new functions to OGG --- lib/theora.cpp | 29 +++++++++++++++++++++++++++++ lib/theora.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/lib/theora.cpp b/lib/theora.cpp index 8170a22c..0399f0ee 100644 --- a/lib/theora.cpp +++ b/lib/theora.cpp @@ -34,6 +34,21 @@ namespace theora{ return ntohl(result); } + uint32_t header::getInt24(size_t index){ + /*if (index + 3 >= datasize){ + if ( !reserve(index, 0, 4)){ + return 0; + } + setInt32(0, index); + }*/ + uint32_t result = 0; + //memcpy(((char*) &result)+1, data + index, 3); + result += data[index] << 16; + result += data[index+1] << 8; + result += data[index+2]; + return result; + } + uint16_t header::getInt16(size_t index){ /*if (index + 3 >= datasize){ if ( !reserve(index, 0, 4)){ @@ -109,6 +124,20 @@ namespace theora{ } return 0; } + + long unsigned int header::getPICH(){ + if (getHeaderType() == 0){ + return getInt24(17); + } + return 0; + } + + long unsigned int header::getPICW(){ + if (getHeaderType() == 0){ + return getInt24(14); + } + return 0; + } long unsigned int header::getFRD(){ if (getHeaderType() == 0){ diff --git a/lib/theora.h b/lib/theora.h index 825d8fde..99a7b6cc 100644 --- a/lib/theora.h +++ b/lib/theora.h @@ -8,10 +8,13 @@ namespace theora{ bool read(char* newData, unsigned int length); int getHeaderType(); char getKFGShift(); + long unsigned int getPICH();//movie height + long unsigned int getPICW();//movie width long unsigned int getFRN();//frame rate numerator long unsigned int getFRD();//frame rate denominator protected: uint32_t getInt32(size_t index); + uint32_t getInt24(size_t index); uint16_t getInt16(size_t index); private: char* data;