(It haven't been finished yet.)
Binary Exif;
ByteOrder=LSB;
BitOrder=MSB;
StartMetadataKey APP1_Markeer(offset=2, size=2);
checkKey(APP1_Markeer)=0xFFE1;
MetadataKey APP1(start, offset=2, size=10);
MetadataKey IFD_Offset(APP1, offset=4, size=4);
MetadataKey CountOfTag(APP1, offset=getNumber(IFD_Offset), size=2);
MetadataKey FirstTagID(CountOfTag, offset=0, size=2);
TagID=FirstTagID;
count=getNumber(CountOfTag);
while(count>0)
{
MetadataKey Type(TagID, offset=0, size=2);
MetadataKey ValueOffset(TagID, offset=6, size=4);
if(getValue(TagID)==0x010E)
{
if(getValue(Type)==2) {SetTag Image_description(getStringByLink(APP1, offset=getNumber(ValueOffset)));}
if(getValue(Type)==5) {SetTag Image_description(getStringByLink(TagID, offset=getNumber(ValueOffset), size=8));}
if(getValue(Type)==1 || (getValue(Type)==3) || (getValue(Type)==4)) {SetTag Image_description(getString(ValueOffset));}
}
if(getValue(TagID)==0x010F)
{
if(getValue(Type)==2) {SetTag Make(getStringByLink(APP1, offset=getNumber(ValueOffset)));}
if(getValue(Type)==5) {SetTag Make(getStringByLink(TagID, offset=getNumber(ValueOffset), size=8));}
if(getValue(Type)==1 || (getValue(Type)==3) || (getValue(Type)==4)) {SetTag Make(getString(ValueOffset));}
}
if(getValue(TagID)==0x0110)
{
if(getValue(Type)==2) {SetTag Model(getStringByLink(APP1, offset=getNumber(ValueOffset)));}
if(getValue(Type)==5) {SetTag Model(getStringByLink(TagID, offset=getNumber(ValueOffset), size=8));}
if(getValue(Type)==1 || (getValue(Type)==3) || (getValue(Type)==4)) {SetTag Model(getString(ValueOffset));}
}
if(getValue(TagID)==0x0112)
{
if(getValue(Type)==2) {SetTag Orientation(getStringByLink(APP1, offset=getNumber(ValueOffset)));}
if(getValue(Type)==5) {SetTag Orientation(getNumberByLink(TagID, offset=getNumber(ValueOffset), size=8));}
if(getValue(Type)==1 || (getValue(Type)==3) || (getValue(Type)==4)) {SetTag Orientation(getNumber(ValueOffset));}
}
if(getValue(TagID)==0x011A)
{
if(getValue(Type)==2) {SetTag XResolution(getStringByLink(APP1, offset=getNumber(ValueOffset)));}
if(getValue(Type)==5) {SetTag XResolution(getNumberByLink(TagID, offset=getNumber(ValueOffset), size=8));}
if(getValue(Type)==1 || (getValue(Type)==3) || (getValue(Type)==4)) {SetTag XResolution(getNumber(ValueOffset));}
}
if(getValue(TagID)==0x011B)
{
if(getValue(Type)==2) {SetTag YResolution(getStringByLink(APP1, offset=getNumber(ValueOffset)));}
if(getValue(Type)==5) {SetTag YResolution(getNumberByLink(TagID, offset=getNumber(ValueOffset), size=8));}
if(getValue(Type)==1 || (getValue(Type)==3) || (getValue(Type)==4)) {SetTag YResolution(getNumber(ValueOffset));}
}
if(getValue(TagID)==0x0132)
{
if(getValue(Type)==2) {SetTag DateTime(getStringByLink(APP1, offset=getNumber(ValueOffset)));}
if(getValue(Type)==5) {SetTag DateTime(getStringByLink(TagID, offset=getNumber(ValueOffset), size=8));}
if(getValue(Type)==1 || (getValue(Type)==3) || (getValue(Type)==4)) {SetTag DateTime(getString(ValueOffset));}
}
count-=1;
shift(TagID,10);
}
Is generated parser
#include "MetadataKey.h"
#include "Tag.h"
#include "MetadataFunc.h"
#include
#include
int main(){
std::ifstream is;
int DefaultByteOrder=ByteOrderLSB;
int DefaultBitOrder=BitOrderMSB;
MetadataKey APP1;
MetadataKey CountOfTag;
MetadataKey FirstTagID;
MetadataKey IFD_Offset;
MetadataKey TagID;
MetadataKey Type;
MetadataKey ValueOffset;
int count;
std::vector
is.open ("test.mp3", std::ifstream::in | std::ifstream::binary);
if (is.good()) {
MetadataKey APP1_Markeer(is);
APP1_Markeer.setOffset(2);
APP1_Markeer.setSize(2);
if(!checkKey(APP1_Markeer,0xFFE1)) return -1;
APP1.setStream(is);
APP1.setOffset(2);
APP1.setSize(10);
IFD_Offset.setStream(is);
IFD_Offset.setBaseKey(APP1);
IFD_Offset.setOffset(4);
IFD_Offset.setSize(4);
CountOfTag.setStream(is);
CountOfTag.setBaseKey(APP1);
CountOfTag.setOffset(IFD_Offset.getNumber(DefaultByteOrder));
CountOfTag.setSize(2);
FirstTagID.setStream(is);
FirstTagID.setBaseKey(CountOfTag);
FirstTagID.setOffset(0);
FirstTagID.setSize(2);
TagID=FirstTagID;
count=CountOfTag.getNumber(DefaultByteOrder);
while(count>0){
Type.setStream(is);
Type.setBaseKey(TagID);
Type.setOffset(0);
Type.setSize(2);
ValueOffset.setStream(is);
ValueOffset.setBaseKey(TagID);
ValueOffset.setOffset(6);
ValueOffset.setSize(4);
if(TagID.getValue()==0x010E){
if(Type.getValue()==2){
Tag t0;
t0.setName("Image_description" );
t0.setValue(getCString(APP1,ValueOffset.getNumber(DefaultByteOrder)));
TagArray.push_back(t0);
}
if(Type.getValue()==5){
Tag t1;
t1.setName("Image_description" );
t1.setValue(getStringByLink(TagID,ValueOffset.getNumber(DefaultByteOrder),8));
TagArray.push_back(t1);
}
if(Type.getValue()==1||(Type.getValue()==3)||(Type.getValue()==4)){
Tag t2;
t2.setName("Image_description" );
t2.setValue(ValueOffset.getString());
TagArray.push_back(t2);
}
}
if(TagID.getValue()==0x010F){
if(Type.getValue()==2){
Tag t3;
t3.setName("Make" );
t3.setValue(getCString(APP1,ValueOffset.getNumber(DefaultByteOrder)));
TagArray.push_back(t3);
}
if(Type.getValue()==5){
Tag t4;
t4.setName("Make" );
t4.setValue(getStringByLink(TagID,ValueOffset.getNumber(DefaultByteOrder),8));
TagArray.push_back(t4);
}
if(Type.getValue()==1||(Type.getValue()==3)||(Type.getValue()==4)){
Tag t5;
t5.setName("Make" );
t5.setValue(ValueOffset.getString());
TagArray.push_back(t5);
}
}
if(TagID.getValue()==0x0110){
if(Type.getValue()==2){
Tag t6;
t6.setName("Model" );
t6.setValue(getCString(APP1,ValueOffset.getNumber(DefaultByteOrder)));
TagArray.push_back(t6);
}
if(Type.getValue()==5){
Tag t7;
t7.setName("Model" );
t7.setValue(getStringByLink(TagID,ValueOffset.getNumber(DefaultByteOrder),8));
TagArray.push_back(t7);
}
if(Type.getValue()==1||(Type.getValue()==3)||(Type.getValue()==4)){
Tag t8;
t8.setName("Model" );
t8.setValue(ValueOffset.getString());
TagArray.push_back(t8);
}
}
if(TagID.getValue()==0x0112){
if(Type.getValue()==2){
Tag t9;
t9.setName("Orientation" );
t9.setValue(getCString(APP1,ValueOffset.getNumber(DefaultByteOrder)));
TagArray.push_back(t9);
}
if(Type.getValue()==5){
Tag t10;
t10.setName("Orientation" );
t10.setValue(getNumberByLink(DefaultByteOrder, TagID,ValueOffset.getNumber(DefaultByteOrder),8));
TagArray.push_back(t10);
}
if(Type.getValue()==1||(Type.getValue()==3)||(Type.getValue()==4)){
Tag t11;
t11.setName("Orientation" );
t11.setValue(ValueOffset.getNumber(DefaultByteOrder));
TagArray.push_back(t11);
}
}
if(TagID.getValue()==0x011A){
if(Type.getValue()==2){
Tag t12;
t12.setName("XResolution" );
t12.setValue(getCString(APP1,ValueOffset.getNumber(DefaultByteOrder)));
TagArray.push_back(t12);
}
if(Type.getValue()==5){
Tag t13;
t13.setName("XResolution" );
t13.setValue(getNumberByLink(DefaultByteOrder, TagID,ValueOffset.getNumber(DefaultByteOrder),8));
TagArray.push_back(t13);
}
if(Type.getValue()==1||(Type.getValue()==3)||(Type.getValue()==4)){
Tag t14;
t14.setName("XResolution" );
t14.setValue(ValueOffset.getNumber(DefaultByteOrder));
TagArray.push_back(t14);
}
}
if(TagID.getValue()==0x011B){
if(Type.getValue()==2){
Tag t15;
t15.setName("YResolution" );
t15.setValue(getCString(APP1,ValueOffset.getNumber(DefaultByteOrder)));
TagArray.push_back(t15);
}
if(Type.getValue()==5){
Tag t16;
t16.setName("YResolution" );
t16.setValue(getNumberByLink(DefaultByteOrder, TagID,ValueOffset.getNumber(DefaultByteOrder),8));
TagArray.push_back(t16);
}
if(Type.getValue()==1||(Type.getValue()==3)||(Type.getValue()==4)){
Tag t17;
t17.setName("YResolution" );
t17.setValue(ValueOffset.getNumber(DefaultByteOrder));
TagArray.push_back(t17);
}
}
if(TagID.getValue()==0x0132){
if(Type.getValue()==2){
Tag t18;
t18.setName("DateTime" );
t18.setValue(getCString(APP1,ValueOffset.getNumber(DefaultByteOrder)));
TagArray.push_back(t18);
}
if(Type.getValue()==5){
Tag t19;
t19.setName("DateTime" );
t19.setValue(getStringByLink(TagID,ValueOffset.getNumber(DefaultByteOrder),8));
TagArray.push_back(t19);
}
if(Type.getValue()==1||(Type.getValue()==3)||(Type.getValue()==4)){
Tag t20;
t20.setName("DateTime" );
t20.setValue(ValueOffset.getString());
TagArray.push_back(t20);
}
}
count-=1;
TagID.setOffset(10+TagID.getSize());
}
}
return 0;
}
Комментариев нет:
Отправить комментарий