//--------------------------------------------------------------------------- void File_Exr::Header_Parse() { //Header if (CC4(Buffer+Buffer_Offset)==0x762F3101) //"v/1"+1 { //Filling Header_Fill_Code(0, "File header"); Header_Fill_Size(12); return; } //Image data if (name_End==0) { //Filling Header_Fill_Code(0, "Image data"); Header_Fill_Size(ImageData_End-(File_Offset+Buffer_Offset)); return; } int32u size; Get_String(name_End, name, "name"); Element_Offset++; //Null byte Get_String(type_End, type, "type"); Element_Offset++; //Null byte Get_L4 (size, "size"); //Filling Header_Fill_Code(0, Ztring().From_Local(name.c_str())); Header_Fill_Size(name_End+1+type_End+1+4+size); }
//--------------------------------------------------------------------------- void File_Pdf::xref() { //Parsing Element_Begin1("Cross-Reference Table"); Element_Begin1("Cross-Reference Section"); string FirstLine; Skip_String(SizeOfLine(), "Object name"); Element_Begin1("Cross-Reference SubSection"); Get_String(SizeOfLine(), FirstLine, "Header"); size_t FirstLine_Space=FirstLine.find(' '); int32u Base=atoi((const char*)FirstLine.c_str()); int32u Count=0; if (FirstLine_Space!=string::npos) Count=atoi((const char*)FirstLine.c_str()+FirstLine_Space+1); if (0x10000+20*Count>Buffer_Size && File_Offset+Buffer_Size<File_Size) { // We wait for more data Buffer_Offset=0; Element_Offset=0; Element_DoNotShow(); Element_End0(); Element_End0(); Element_End0(); Element_WaitForMoreData(); return; } while (Element_Offset<Element_Size && (Buffer[Buffer_Offset+(size_t)Element_Offset]=='\r' || Buffer[Buffer_Offset+(size_t)Element_Offset]=='\n')) Element_Offset++; const int8u* Buffer_Temp=Buffer+Buffer_Offset+(size_t)Element_Offset+17; for (int32u Pos=0; Pos<Count; ++Pos) { if (*Buffer_Temp=='n') { int32u Offset=(int32u)atoi((const char*)(Buffer_Temp-17)); Objects[Base+Pos].Offset=Offset; //Offsets[Offset]=Base+Pos; Offsets.push_back(Offset); } Buffer_Temp+=20; if (Pos>100) Element_Offset+=20; else { Skip_String(18, "Entry"); Param_Info1(Base+Pos); Element_Offset+=2; //Skipping spaces at end and line return } } Element_End0(); Element_End0(); Element_End0(); if (File_Offset+Buffer_Offset>Offsets_Max) Offsets_Max=(int32u)(File_Offset+Buffer_Offset); }
//--------------------------------------------------------------------------- void File_Pdf::startxref() { //We need to find the exact begin Buffer_Offset=Buffer_Size-1; while (Buffer_Offset && (Buffer[Buffer_Offset]=='\r' || Buffer[Buffer_Offset]=='\n')) Buffer_Offset--; Buffer_Offset-=5; // "%%EOF" while (Buffer_Offset && (Buffer[Buffer_Offset]=='\r' || Buffer[Buffer_Offset]=='\n')) Buffer_Offset--; while (Buffer_Offset && Buffer[Buffer_Offset]>='0' && Buffer[Buffer_Offset]<='9') // Value Buffer_Offset--; while (Buffer_Offset && (Buffer[Buffer_Offset]=='\r' || Buffer[Buffer_Offset]=='\n')) Buffer_Offset--; Buffer_Offset-=8; //Parsing Element_Begin1("Cross-Reference Table Offset"); string xrefOffsetS; Skip_String(SizeOfLine(), "Object name"); Get_String (SizeOfLine(), xrefOffsetS, "xref Offset"); while (Buffer_Offset<Buffer_Size && (Buffer[Buffer_Offset]=='\r' || Buffer[Buffer_Offset]=='\n')) ++Buffer_Offset; int32u xref_Offset=atoi(xrefOffsetS.c_str()); Element_End0(); //Going to xref if (xref_Offset>Offsets_Max) Offsets_Max=xref_Offset; GoTo (xref_Offset); State=State_Parsing_xref; }
//--------------------------------------------------------------------------- void Riff_AVI__Tdat_tc_O::Read_Internal () { //Integrity if (Global->iXML) throw exception_valid("2 tc_O chunks"); //Reading Read_Internal_ReadAllInBuffer(); //Parsing Ztring Value; bool IsOk=true; for (Chunk.Content.Buffer_Offset=0; Chunk.Content.Buffer_Offset<Chunk.Content.Size; Chunk.Content.Buffer_Offset++) if (Chunk.Content.Buffer[Chunk.Content.Buffer_Offset]!=0x00 && Chunk.Content.Buffer[Chunk.Content.Buffer_Offset]!=':' && Chunk.Content.Buffer[Chunk.Content.Buffer_Offset]!=';' && (Chunk.Content.Buffer[Chunk.Content.Buffer_Offset]<'0' || Chunk.Content.Buffer[Chunk.Content.Buffer_Offset]>'9')) { IsOk=false; break; } Chunk.Content.Buffer_Offset=0; if (IsOk) Get_String(Chunk.Content.Size, Value); else for (Chunk.Content.Buffer_Offset=0; Chunk.Content.Buffer_Offset<Chunk.Content.Size; Chunk.Content.Buffer_Offset++) Value+=Ztring().From_CC1(Chunk.Content.Buffer+Chunk.Content.Buffer_Offset); //Filling Global->Tdat->Strings["tc_o"]=Value; }
/* =begin --- OCISvcCtx#passwordChange(username, old_password, new_password [, mode]) :username the username. :old_password old password of the user. :new_password new password of the user. :mode ((|OCI_DEFAULT|)) or ((|OCI_AUTH|)). Default value is ((|OCI_DEFAULT|)). For most cases, use default value. If you want to know detail, see "Oracle Call Interface Programmer's Guide". correspond native OCI function: ((|OCIPasswordChange|)) =end */ static VALUE oci8_password_change(int argc, VALUE *argv, VALUE self) { VALUE vusername, vopasswd, vnpasswd, vmode; oci8_handle_t *h; oci8_string_t username, opasswd, npasswd; ub4 mode; sword rv; rb_scan_args(argc, argv, "31", &vusername, &vopasswd, &vnpasswd, &vmode); Get_Handle(self, h); /* 0 */ Get_String(vusername, username); /* 1 */ Get_String(vopasswd, opasswd); /* 2 */ Get_String(vnpasswd, npasswd); /* 3 */ Get_Int_With_Default(argc, 4, vmode, mode, OCI_DEFAULT); /* 4 */ rv = OCIPasswordChange(h->hp, h->errhp, username.ptr, username.len, opasswd.ptr, opasswd.len, npasswd.ptr, npasswd.len, mode); if (rv != OCI_SUCCESS) { oci8_raise(h->errhp, rv, NULL); } return self; }
//--------------------------------------------------------------------------- void File_Exr::Header_Parse() { //Image data if (name_End==0) { //Filling Header_Fill_Code(0, "Image data"); Header_Fill_Size(ImageData_End-(File_Offset+Buffer_Offset)); return; } int32u size; Get_String(name_End, name, "name"); Element_Offset++; //Null byte Get_String(type_End, type, "type"); Element_Offset++; //Null byte Get_L4 (size, "size"); //Filling Header_Fill_Code(0, Ztring().From_ISO_8859_1(name.c_str())); Header_Fill_Size(name_End+1+type_End+1+4+size); }
/* =begin --- OCIStmt#bindByName(name, type [, length [, mode]]) define the datatype of the bind variable by name. :name the name of the bind variable including colon. :type the type of the bind variable. ((|String|)), ((|Fixnum|)), ((|Integer|)), ((|Float|)), ((|Time|)), ((<OraDate>)), ((<OraNumber>)), or ((|OCI_TYPECODE_RAW|)) :length When the 2nd argument is * ((|String|)) or ((|OCI_TYPECODE_RAW|)), the max length of fetched data. * otherwise, its value is ignored. :mode ((|OCI_DEFAULT|)), or ((|OCI_DATA_AT_EXEC|)). But now available value is ((|OCI_DEFAULT|)) only. Default value is ((|OCI_DEFAULT|)) :return value newly created ((<bind handle|OCIBind>)) for example stmt = env.alloc(OCIStmt) stmt.prepare("SELECT * FROM EMP WHERE ename = :ENAME AND sal > :SAL AND hiredate >= :HIREDATE") b_ename = stmt.bindByName(":ENAME", String, 10) b_sal = stmt.bindByName(":SAL", Fixnum) b_hiredate = stmt.bindByName(":HIREDATE", OraDate) correspond native OCI function: ((|OCIBindByName|)) =end */ static VALUE oci8_bind_by_name(int argc, VALUE *argv, VALUE self) { VALUE vplaceholder; VALUE vtype; VALUE vlength; VALUE vmode; oci8_handle_t *h; oci8_string_t placeholder; oci8_bind_handle_t *bh; ub2 dty; ub4 mode; dvoid *indp; ub2 *rlenp; dvoid *valuep; OCIBind *bindhp = NULL; sword status; VALUE hash; VALUE obj; rb_scan_args(argc, argv, "22", &vplaceholder, &vtype, &vlength, &vmode); Get_Handle(self, h); /* 0 */ Get_String(vplaceholder, placeholder); /* 1 */ check_bind_type(OCI_HTYPE_BIND, h, vtype, vlength, &bh, &dty); /* 2, 3 */ Get_Int_With_Default(argc, 4, vmode, mode, OCI_DEFAULT); /* 4 */ if (mode & OCI_DATA_AT_EXEC) { indp = NULL; rlenp = NULL; } else { indp = &(bh->ind); rlenp = (bh->bind_type == BIND_STRING) ? NULL : &bh->rlen; } valuep = &bh->value; status = OCIBindByName(h->hp, &bindhp, h->errhp, placeholder.ptr, placeholder.len, valuep, bh->value_sz, dty, indp, rlenp, 0, 0, 0, mode); if (status != OCI_SUCCESS) { oci8_unlink((oci8_handle_t *)bh); bh->type = 0; oci8_raise(h->errhp, status, h->hp); } bh->type = OCI_HTYPE_BIND; bh->hp = bindhp; bh->errhp = h->errhp; obj = bh->self; hash = rb_ivar_get(self, oci8_id_bind_hash); if (hash == Qnil) { hash = rb_hash_new(); rb_ivar_set(self, oci8_id_bind_hash, hash); } rb_hash_aset(hash, vplaceholder, obj); return obj; }
//--------------------------------------------------------------------------- void File_Pdf::Data_Parse() { Element_Name("Object"); string Line; Get_String(SizeOfLine(), Line, "Header"); size_t Space_Pos=Line.find(' '); int32u ObjectNumber=Ztring().From_UTF8(Line.substr(0, Space_Pos)).To_int32u(); Element_Info1(ObjectNumber); objects::iterator Object=Objects.find(ObjectNumber); if (Object==Objects.end()) Skip_XX(Element_Size-Element_Offset, "Data"); else switch(Object->second.Type) { case Type_Root : Object_Root(); break; case Type_Info : Object_Info(); break; case Type_Metadata : Object_Metadata(); break; default : Skip_XX(Element_Size-Element_Offset, "Data"); } for (;;) { if (Objects_Current==Objects.end()) break; Objects_Current->second.BottomPos++; if (Objects_Current->second.BottomPos>=Objects_Current->second.Bottoms.size()) { if (Objects_Current->first==(int32u)-1) { //No more to parse Objects_Current=Objects.end(); Objects.clear(); Finish(); break; } Objects_Current=Objects.find(Objects_Current->second.TopObject); continue; } Objects_Current=Objects.find(Objects_Current->second.Bottoms[Objects_Current->second.BottomPos]); GoTo(Objects_Current->second.Offset); break; } }
/* =begin --- OCIServer#attach(dbname [, mode]) attach to the database. :dbname the name of database. :mode ((|OCI_DEFAULT|)) or ((|OCI_CPOOL|))(Oracle 9i). Default value is ((|OCI_DEFAULT|)). This ruby module doesn't support the connection pooling provided by OCI, so ((|OCI_CPOOL|)) is invalid value for now. correspond native OCI function: ((|OCIServerAttach|)) =end */ static VALUE oci8_server_attach(int argc, VALUE *argv, VALUE self) { VALUE vdbname, vmode; oci8_handle_t *h; oci8_string_t d; ub4 mode; sword rv; rb_scan_args(argc, argv, "11", &vdbname, &vmode); Get_Handle(self, h); /* 0 */ Get_String(vdbname, d); /* 1 */ Get_Int_With_Default(argc, 2, vmode, mode, OCI_DEFAULT); /* 2 */ rv = OCIServerAttach(h->hp, h->errhp, d.ptr, d.len, mode); if (rv != OCI_SUCCESS) oci8_raise(h->errhp, rv, NULL); return self; }
/* =begin --- OCIStmt#prepare(stmt [, language [, mode]]) set and prepare SQL statement. :stmt SQL or PL/SQL statement :language ((|OCI_NTV_SYNTAX|)), ((|OCI_V7_SYNTAX|)), or ((|OCI_V8_SYNTAX|)). Default value is ((|OCI_NTV_SYNTAX|)) :mode ((|OCI_DEFAULT|)) or ((|OCI_NO_SHARING|)). Default value is ((|OCI_DEFAULT|)). ((|OCI_NO_SHARING|)) disables ((<Shared Data Mode>)) for this statement. correspond native OCI function: ((|OCIStmtPrepare|)) =end */ static VALUE oci8_stmt_prepare(int argc, VALUE *argv, VALUE self) { VALUE vsql, vlanguage, vmode; oci8_handle_t *h; oci8_string_t s; ub4 language; ub4 mode; sword rv; VALUE ary; VALUE hash; int i; rb_scan_args(argc, argv, "12", &vsql, &vlanguage, &vmode); Get_Handle(self, h); /* 0 */ Get_String(vsql, s); /* 1 */ Get_Int_With_Default(argc, 2, vlanguage, language, OCI_NTV_SYNTAX); /* 2 */ Get_Int_With_Default(argc, 3, vmode, mode, OCI_DEFAULT); /* 3 */ /* when a new statement is prepared, OCI implicitly free the previous * statement's define and bind handles. * But ruby's object don't know it. So free these handles in advance. */ /* free define handles */ ary = rb_ivar_get(self, oci8_id_define_array); if (ary != Qnil) { for (i = 0;i < RARRAY_LEN(ary);i++) { if (RARRAY_PTR(ary)[i] != Qnil) oci8_handle_free(RARRAY_PTR(ary)[i]); } rb_ivar_set(self, oci8_id_define_array, Qnil); } /* free bind handles */ hash = rb_ivar_get(self, oci8_id_bind_hash); if (hash != Qnil) { rb_iterate(oci8_each_value, hash, oci8_handle_free, Qnil); rb_ivar_set(self, oci8_id_bind_hash, Qnil); } rv = OCIStmtPrepare(h->hp, h->errhp, s.ptr, s.len, language, mode); if (IS_OCI_ERROR(rv)) { oci8_raise(h->errhp, rv, h->hp); } return self; }
/* THIS WILL BE DELETED IN FUTURE RELEASE. */ static VALUE oci8_describe_any(VALUE self, VALUE vdsc, VALUE vname, VALUE vtype) { oci8_handle_t *h; oci8_handle_t *dsch; oci8_string_t name; ub1 type; sword rv; Get_Handle(self, h); /* 0 */ Check_Handle(vdsc, OCIDescribe, dsch); /* 1 */ Get_String(vname, name); /* 2 */ type = FIX2INT(vtype); /* 3 */ rv = OCIDescribeAny(h->hp, h->errhp, name.ptr, name.len, OCI_OTYPE_NAME, OCI_DEFAULT, type, dsch->hp); if (rv != OCI_SUCCESS) { oci8_raise(h->errhp, rv, NULL); } return self; }
//--------------------------------------------------------------------------- void File_ApeTag::Header_Parse() { //Testing if begin or end of tags if (CC8(Buffer+Buffer_Offset)==0x4150455441474558LL) //"APETAGEX" { //Filling Header_Fill_Code((int64u)-1, "File Footer"); Header_Fill_Size(0x20); return; } //Parsing Ztring Value; int32u Flags, Length; Get_L4 (Length, "Length"); Get_L4 (Flags, "Flags"); Skip_Flags(Flags, 0, "Read Only"); Skip_Flags(Flags, 1, "Binary"); Skip_Flags(Flags, 2, "Locator of external stored information"); Skip_Flags(Flags, 29, "Is the header"); Skip_Flags(Flags, 30, "Contains a footer"); Skip_Flags(Flags, 31, "Contains a header"); size_t Pos=(size_t)Element_Offset; for (; Pos<Element_Size; Pos++) if (Buffer[Buffer_Offset+Pos]==0x00) break; if (Pos==Element_Size) { Element_WaitForMoreData(); return; } Get_String(Pos-Element_Offset, Key, "Key"); Skip_L1( "0x00"); //Filling Header_Fill_Code(0, Key.c_str()); Header_Fill_Size(Element_Offset+Length); }
//--------------------------------------------------------------------------- void File_Nut::FileHeader_Parse() { //Parsing Element_Begin("Nut header", 25); std::string file_id_string; Get_String(25, file_id_string, "file_id_string"); Element_End(); FILLING_BEGIN(); //Integrity if (file_id_string!="nut/multimedia container") { Finished(); return; } //Filling Stream_Prepare(Stream_General); Fill(Stream_General, 0, General_Format, "Nut"); Finished(); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Pdf::FileHeader_Parse() { string PdfHeader; Get_String(SizeOfLine(), PdfHeader, "Header"); for (;;) { int64u CommentSize=SizeOfLine(); if (Buffer_Offset+Element_Offset>=Buffer_Size) { Element_WaitForMoreData(); return; } if (Buffer[Buffer_Offset+Element_Offset]!='%') break; Skip_String(CommentSize, "Comment"); } //Filling Fill(Stream_General, 0, General_Format_Version, PdfHeader.substr(5)); GoToFromEnd(9+2+10+2+5+2); // "startxref" + EOL + 10max digits + EOL + "%%EOF" + EOL State=State_Parsing_startxref; }
//--------------------------------------------------------------------------- void File_Nut::FileHeader_Parse() { //Parsing Element_Begin1("Nut header"); std::string file_id_string; int8u file_id_string_zero; Get_String(24, file_id_string, "file_id_string"); Get_B1 (file_id_string_zero, "file_id_string zero"); Element_End0(); FILLING_BEGIN(); //Integrity if (file_id_string!="nut/multimedia container" || file_id_string_zero) { Reject("Nut"); return; } //Filling Accept("Nut"); Fill(Stream_General, 0, General_Format, "Nut"); FILLING_END(); }
//--------------------------------------------------------------------------- void File_Scc::Data_Parse() { while (Element_Offset<Element_Size && (Buffer[Buffer_Offset+(size_t)Element_Offset]==0x0D || Buffer[Buffer_Offset+(size_t)Element_Offset]==0x0A)) Element_Offset++; if (Element_Offset==Element_Size) return; //Parsing string TimeStamp; Get_String(11, TimeStamp, "TimeStamp"); Parser->FrameInfo.DTS=Scc_str2timecode(TimeStamp.c_str()); while (Element_Offset+5<=Element_Size) { int8u Buffer_Temp[2]; Buffer_Temp[0]=(Buffer[Buffer_Offset+(size_t)Element_Offset+1]-(Buffer[Buffer_Offset+(size_t)Element_Offset+1]>='a'?('a'-10):'0'))<<4 | (Buffer[Buffer_Offset+(size_t)Element_Offset+2]-(Buffer[Buffer_Offset+(size_t)Element_Offset+2]>='a'?('a'-10):'0')); Buffer_Temp[1]=(Buffer[Buffer_Offset+(size_t)Element_Offset+3]-(Buffer[Buffer_Offset+(size_t)Element_Offset+3]>='a'?('a'-10):'0'))<<4 | (Buffer[Buffer_Offset+(size_t)Element_Offset+4]-(Buffer[Buffer_Offset+(size_t)Element_Offset+4]>='a'?('a'-10):'0')); Open_Buffer_Continue(Parser, Buffer_Temp, 2); Element_Offset+=5; if (Parser->FrameInfo.DTS!=(int64u)-1) Parser->FrameInfo.DTS+=33333333; } }
//--------------------------------------------------------------------------- bool File_Pdf::Get_Next(string &Key, Ztring &Value) { Key.clear(); Value.clear(); string Line; //Removig end of lines while (Element_Offset<Element_Size && (Buffer[Buffer_Offset+(size_t)Element_Offset]=='\r' || Buffer[Buffer_Offset+(size_t)Element_Offset]=='\n' || Buffer[Buffer_Offset+(size_t)Element_Offset]==' ')) Element_Offset++; //End if (Element_Offset>=Element_Size) return true; //Testing Catalog Peek_String (2, Line); if (Line=="<<") { Element_Offset+=2; Catalog_Level++; return true; } else if (Line==">>") { Element_Offset+=2; Catalog_Level--; return true; } //Getting a complete line Peek_String (SizeOfLine(), Line); //Testing Catalog size_t Catalog_End=Line.find(">>"); if (Catalog_End!=String::npos) Line.resize(Catalog_End); //Testing stream if (Line=="stream") { Skip_String(Line.size(), "Stream, Header"); Key=Line; return false; } if (Line=="endstream") { Skip_String(Line.size(), "Stream, Footer"); Key=Line; return false; } //Testing object if (Line=="endobj") { Skip_String(Line.size(), "Footer"); Key=Line; return false; } //Base int64u Line_Base=Element_Offset; //Testing next key size_t Line_End=0; size_t Line_Begin=Line_End; // Key-Value if (Line_Begin<Line.size() && Line[Line_Begin]=='/') { Line_End= Line_Begin+1; size_t HasParenthesis=0; size_t HasBracket=0; size_t HasSpace=0; size_t HasValue=0; for (;;) { if (Line_End==Line.size()) break; if (!HasParenthesis && !HasBracket && HasValue && Line[Line_End]=='<' && Line_End+1<Line.size() && Line[Line_End+1]=='<') break; if (!HasParenthesis && !HasBracket && HasValue && Line[Line_End]=='/') break; else if (!HasValue && Line[Line_End]=='/') ++HasValue; else if (!HasValue && HasSpace) ++HasValue; if (Line[Line_End]==' ') ++HasSpace; if (Line[Line_End]=='(') ++HasParenthesis; if (HasParenthesis && Line[Line_End]==')') --HasParenthesis; if (Line[Line_End]=='[') ++HasBracket; if (HasBracket && Line[Line_End]==']') --HasBracket; ++Line_End; } while(Line_End && Line[Line_End-1]==' ') Line_End--; //Removing trailing spaces Element_Offset=Line_Base+Line_Begin; string KeyValue; Get_String(Line_End-Line_Begin, KeyValue, "Key-Value"); size_t Key_Max=KeyValue.find_first_of(" ("); if (Key_Max==string::npos) Key_Max=KeyValue.size(); Key=KeyValue.substr(1, Key_Max-1); size_t Value_Min=Key_Max; while (Value_Min<KeyValue.size() && KeyValue[Value_Min]==' ') ++Value_Min; if (Value_Min<KeyValue.size() && KeyValue[Value_Min]=='(') { ++Value_Min; size_t Value_Max=KeyValue.find(')', Value_Min); if (Value_Max!=string::npos) { //TODO Value.From_UTF8(KeyValue.c_str()+Value_Min, Value_Max-Value_Min); } else Value.From_UTF8(KeyValue.c_str()+Value_Min); } else Value.From_UTF8(KeyValue.c_str()+Value_Min); return false; } return false; }
void File_Exr::channels() { //Parsing std::vector<Exr_channel> ChannelList; while (Element_Offset+1<Element_Size) { Element_Begin1("channel"); //Name size_t name_Size=0; while (Element_Offset+name_Size<Element_Size) { if (!Buffer[Buffer_Offset+(size_t)Element_Offset+name_Size]) break; name_Size++; } name_End++; Exr_channel Channel; Get_String(name_Size, Channel.name, "name"); Element_Info1(Channel.name); Element_Offset++; //Null byte Skip_L4( "pixel type"); Skip_L1( "pLinear"); Skip_B3( "reserved"); Get_L4 (Channel.xSampling, "xSampling"); Get_L4 (Channel.ySampling, "ySampling"); ChannelList.push_back(Channel); Element_End0(); } //Color space /* TODO: not finished bool HasAlpha=false; string ColorSpace, ChromaSubsampling; if (!ChannelList.empty() && ChannelList[0].name=="A") { HasAlpha=true; ChannelList.erase(ChannelList.begin()); } if (ChannelList.size()==1 && ChannelList[0].name=="Y") { ColorSpace="Y"; } else if (ChannelList.size()==3 && ChannelList[0].name=="V" && ChannelList[1].name=="U" && ChannelList[2].name=="Y") { ColorSpace="YUV"; //Chroma subsampling if (ChannelList[2].xSampling==1 && ChannelList[2].xSampling==1 && ChannelList[0].xSampling==ChannelList[1].xSampling && ChannelList[0].ySampling==ChannelList[1].ySampling) { switch (ChannelList[0].xSampling) { case 1 : switch (ChannelList[0].ySampling) { case 1 : ChromaSubsampling="4:4:4"; break; default: ; } break; case 2 : switch (ChannelList[0].ySampling) { case 1 : ChromaSubsampling="4:2:2"; break; case 2 : ChromaSubsampling="4:2:0"; break; default: ; } break; case 4 : switch (ChannelList[0].ySampling) { case 1 : ChromaSubsampling="4:1:1"; break; case 2 : ChromaSubsampling="4:1:0"; break; default: ; } break; default: ; } } } else if (ChannelList.size()==3 && ChannelList[0].name=="B" && ChannelList[1].name=="G" && ChannelList[2].name=="R") { ColorSpace="RGB"; } else { //TODO } if (!ColorSpace.empty()) { if (HasAlpha) ColorSpace+='A'; Fill(StreamKind_Last, 0, "ColorSpace", ColorSpace); } if (!ChromaSubsampling.empty()) Fill(StreamKind_Last, 0, "ChromaSubsampling", ChromaSubsampling); */ }
//--------------------------------------------------------------------------- void File_Cdp::ccsvcinfo_section() { //Parsing int8u svc_count; Element_Begin1("ccsvcinfo_section"); Skip_B1( "ccsvcinfo_id"); BS_Begin(); Skip_SB( "reserved"); Skip_SB( "svc_info_start"); Skip_SB( "svc_info_change"); Skip_SB( "svc_info_complete"); Get_S1 (4, svc_count, "svc_count"); BS_End(); for (int8u Pos=0; Pos<svc_count; Pos++) { Element_Begin1("svc"); bool csn_size; BS_Begin(); Skip_SB( "reserved"); Get_SB ( csn_size, "csn_size"); if (csn_size) { Skip_SB( "reserved"); Skip_S1(5, "caption_service_number"); } else Skip_S1(6, "caption_service_number"); BS_End(); //svc_data_byte - caption_service_descriptor Element_Begin1("service"); string language; int8u caption_service_number=0; bool digital_cc, line21_field=false; Get_String(3, language, "language"); BS_Begin(); Get_SB (digital_cc, "digital_cc"); Skip_SB( "reserved"); if (digital_cc) //line21 Get_S1 (6, caption_service_number, "caption_service_number"); else { Skip_S1(5, "reserved"); Get_SB ( line21_field, "line21_field"); //Coherency test if (line21_field && svc_count==1) line21_field=false; // Wrong info in the descriptor? } Skip_SB( "easy_reader"); Skip_SB( "wide_aspect_ratio"); Skip_S2(14, "reserved"); BS_End(); Element_End0(); Element_End0(); FILLING_BEGIN(); #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) if (digital_cc) { #if defined(MEDIAINFO_EIA708_YES) ServiceDescriptors->ServiceDescriptors708[caption_service_number].language=language; #endif } else { #if defined(MEDIAINFO_EIA708_YES) ServiceDescriptors->ServiceDescriptors608[line21_field?1:0].language=language; #endif } #endif //Stream creation int8u Parser_Pos; if (digital_cc) //line21 Parser_Pos = 2; else Parser_Pos= (line21_field ? 1 : 0); //cc_type 2 and 3 are for the same text if (Streams[Parser_Pos]==NULL) CreateStream(Parser_Pos); FILLING_END(); } Element_End0(); }
string Period (void) { return (Get_String (period)); }
string Name (void) { return (Get_String (name)); }
//--------------------------------------------------------------------------- void File_Dpx::GenericSectionHeader_Dpx() { Element_Name("Generic section header"); //Parsing Element_Begin1("File information"); std::string Version, CreationDate, Creator, Project, Copyright; int32u Size_Header, Size_Total, Size_Generic, Size_Industry, Size_User; Skip_String(4, "Magic number"); Get_X4 (Size_Header, "Offset to image data"); Get_String(8, Version, "Version number of header format"); Get_X4 (Size_Total, "Total image file size"); Skip_B4( "Ditto Key"); Get_X4 (Size_Generic, "Generic section header length"); Get_X4 (Size_Industry, "Industry specific header length"); Get_X4 (Size_User, "User-defined header length"); Skip_UTF8 (100, "FileName"); Get_String (24, CreationDate, "Creation Date"); Get_String (100, Creator, "Creator"); Get_String (200, Project, "Project"); Get_String (200, Copyright, "Right to use or copyright statement"); Skip_B4( "Encryption key"); Skip_XX(104, "Reserved for future use"); Element_End0(); Element_Begin1("Image information"); int32u Width, Height, PAR_H, PAR_V; int16u ImageElements; Info_B2(ImageOrientation, "Image orientation");Param_Info1(DPX_Orientation[ImageOrientation]); Get_X2 (ImageElements, "Number of image elements"); if (ImageElements>8) ImageElements=8; Get_X4 (Width, "Pixels per line"); Get_X4 (Height, "Lines per image element"); for(int16u ImageElement=0; ImageElement<ImageElements; ImageElement++) GenericSectionHeader_Dpx_ImageElement(); if (ImageElements!=8) Skip_XX((8-ImageElements)*72, "Padding"); Skip_XX(52, "Reserved for future use"); Element_End0(); Element_Begin1("Image source information"); Skip_B4( "X Offset"); Skip_B4( "Y Offset"); Skip_BF4( "X center"); Skip_BF4( "Y center"); Skip_B4( "X original size"); Skip_B4( "Y original size"); Skip_UTF8(100, "Source image filename"); Skip_UTF8(24, "Source image date/time"); Skip_UTF8(32, "Input device name"); Skip_UTF8(32, "Input device serial number"); Element_Begin1("Border validity"); Skip_B2( "XL border"); Skip_B2( "XR border"); Skip_B2( "YT border"); Skip_B2( "YB border"); Element_End0(); Get_X4 (PAR_H, "Pixel ratio : horizontal"); Get_X4 (PAR_V, "Pixel ratio : vertical"); Element_Begin1("Additional source image information"); Skip_BF4( "X scanned size"); Skip_BF4( "Y scanned size"); Skip_XX(20, "Reserved for future use"); Element_End0(); FILLING_BEGIN(); //Coherency tests if (File_Offset+Buffer_Offset+Size_Total!=Config->File_Current_Size) Size_Total=(int32u)(Config->File_Current_Size-(File_Offset+Buffer_Offset)); //The total size is bigger than the real size if (Size_Generic==(int32u)-1) Size_Generic=(int32u)Element_Size; if (Size_Industry==(int32u)-1) Size_Industry=0; if (Size_User==(int32u)-1) Size_User=0; if (Size_Generic+Size_Industry+Size_User>Size_Header || Size_Header>Size_Total) { Reject(); return; } //Filling sizes Sizes.push_back(Size_Header); Sizes.push_back(Size_Industry); Sizes.push_back(Size_User); Sizes.push_back(Size_Header-(Size_Generic+Size_Industry+Size_User)); //Size of padding Sizes.push_back(Size_Total-Size_Header); //Size of image //Filling meta if (Frame_Count==0) { Fill(Stream_General, 0, General_Encoded_Date, CreationDate); //ToDo: transform it in UTC Fill(StreamKind_Last, StreamPos_Last, "Encoded_Date", CreationDate); //ToDo: transform it in UTC Fill(Stream_General, 0, General_Encoded_Library, Creator); Fill(StreamKind_Last, StreamPos_Last, "Encoded_Library", Creator); Fill(Stream_General, 0, "Project", Project); //ToDo: map to a MediaInfo field (which one?) Fill(Stream_General, 0, General_Copyright, Copyright); Fill(StreamKind_Last, StreamPos_Last, "Format", "DPX"); if (Version.size()>2 && Version[0]=='V' && Version[1]>='0' && Version[2]<='9') Version.insert(1, "ersion "); Fill(StreamKind_Last, StreamPos_Last, "Format_Version", Version); Fill(Stream_General, 0, General_Format_Version, Version); Fill(StreamKind_Last, StreamPos_Last, "Width", Width); Fill(StreamKind_Last, StreamPos_Last, "Height", Height); if (PAR_V && PAR_H!=(int32u)-1 && PAR_V!=(int32u)-1) Fill(StreamKind_Last, StreamPos_Last, "PixelAspectRatio", ((float)PAR_H)/PAR_V); else Fill(StreamKind_Last, StreamPos_Last, "PixelAspectRatio", (float)1, 3); } FILLING_END(); }
//--------------------------------------------------------------------------- void File_Dpx::GenericSectionHeader_Cineon() { Element_Name("Generic section header"); //Parsing Element_Begin1("File information"); Ztring CreationDate, CreationTime; string Version; int32u Size_Header, Size_Total, Size_Generic, Size_Industry, Size_User; Skip_B4( "Magic number"); Get_X4 (Size_Header, "Offset to image data"); Get_X4 (Size_Generic, "Generic section header length"); Get_X4 (Size_Industry, "Industry specific header length"); Get_X4 (Size_User, "User-defined header length"); Get_X4 (Size_Total, "Total image file size"); Get_String(8, Version, "Version number of header format"); Skip_UTF8 (100, "FileName"); Get_UTF8 (12, CreationDate, "Creation Date"); Get_UTF8 (12, CreationTime, "Creation Time"); Skip_XX(36, "Reserved for future use"); Element_End0(); Element_Begin1("Image information"); int8u ImageElements; Info_B1(ImageOrientation, "Image orientation"); Param_Info1(DPX_Orientation[ImageOrientation>8?8:ImageOrientation]); Get_B1 (ImageElements, "Number of image elements"); Skip_B2( "Unused"); if (ImageElements>8) ImageElements=8; for(int8u ImageElement=0; ImageElement<ImageElements; ImageElement++) GenericSectionHeader_Cineon_ImageElement(); if (ImageElements!=8) Skip_XX((8-ImageElements)*28, "Padding"); Skip_BF4( "White point - x"); Skip_BF4( "White point - y"); Skip_BF4( "Red primary chromaticity - x"); Skip_BF4( "Red primary chromaticity - u"); Skip_BF4( "Green primary chromaticity - x"); Skip_BF4( "Green primary chromaticity - y"); Skip_BF4( "Blue primary chromaticity - x"); Skip_BF4( "Blue primary chromaticity - y"); Skip_UTF8(200, "Label text"); Skip_XX(28, "Reserved for future use"); Element_End0(); Element_Begin1("Image Data Format Information"); Skip_B1( "Data interleave"); Skip_B1( "Packing"); Skip_B1( "Data signed or unsigned"); Skip_B1( "Image sense"); Skip_B4( "End of line padding"); Skip_B4( "End of channel padding"); Skip_XX(20, "Reserved for future use"); Element_Begin1("Image Origination Information"); Skip_B4( "X offset"); Skip_B4( "Y offset"); Skip_UTF8 (100, "FileName"); Get_UTF8 (12, CreationDate, "Creation Date"); Get_UTF8 (12, CreationTime, "Creation Time"); Skip_UTF8(64, "Input device"); Skip_UTF8(32, "Input device model number"); Skip_UTF8(32, "Input device serial number"); Skip_BF4( "X input device pitch"); Skip_BF4( "Y input device pitch"); Skip_BF4( "Image gamma of capture device"); Skip_XX(40, "Reserved for future use"); Element_End0(); FILLING_BEGIN(); //Coherency tests if (File_Offset+Buffer_Offset+Size_Total>=Config->File_Current_Size) Size_Total=(int32u)(Config->File_Current_Size-(File_Offset+Buffer_Offset)); //The total size is bigger than the real size if (Size_Generic+Size_Industry+Size_User>Size_Header || Size_Header>Size_Total) { Reject(); return; } //Filling sizes Sizes.push_back(Size_Header); Sizes.push_back(Size_Industry); Sizes.push_back(Size_User); Sizes.push_back(Size_Header-(Size_Generic+Size_Industry+Size_User)); //Size of padding Sizes.push_back(Size_Total-Size_Header); //Size of image //Filling meta if (Frame_Count==0) { Fill(Stream_General, 0, General_Encoded_Date, CreationDate+__T(' ')+CreationTime); //ToDo: transform it in UTC Fill(StreamKind_Last, StreamPos_Last, "Encoded_Date", CreationDate+__T(' ')+CreationTime); //ToDo: transform it in UTC Fill(StreamKind_Last, StreamPos_Last, "Format", "Cineom"); if (Version.size()>2 && Version[0]=='V' && Version[1]>='0' && Version[2]<='9') Version.insert(1, "ersion "); Fill(StreamKind_Last, StreamPos_Last, "Format_Version", Version); Fill(Stream_General, 0, General_Format_Version, Version); } FILLING_END(); }
string Detectors (void) { return (Get_String (detectors)); }
void cfu_sim_parser(char *filename) { int i; char core_name[128]; multi_sim_arg.boot.share_mode = Get_Value(filename, "BOOT_OPTION", "SHARE_MODE", 0); //CFU_SHM_NAME if (Get_String(filename, "BOOT_OPTION", "CFU_SHM_NAME") != NULL) { strcpy((char *)multi_sim_arg.boot.cfu_shm_name, Get_String(filename, "BOOT_OPTION", "CFU_SHM_NAME")); } //SOC_SHM_NAME if (Get_String(filename, "BOOT_OPTION", "CORE_SHM_NAME") != NULL) { strcpy((char *)multi_sim_arg.boot.core_shm_name, Get_String(filename, "BOOT_OPTION", "CORE_SHM_NAME")); } if (Get_String(filename, "BOOT_OPTION", "M2_SHM_NAME") != NULL) { strcpy((char *)multi_sim_arg.boot.m2_shm_name, Get_String(filename, "BOOT_OPTION", "M2_SHM_NAME")); } if (Get_String(filename, "BOOT_OPTION", "DDR_SHM_NAME") != NULL) { strcpy((char *)multi_sim_arg.boot.ddr_shm_name, Get_String(filename, "BOOT_OPTION", "DDR_SHM_NAME")); } if (Get_String(filename, "BOOT_OPTION", "SYSDMA_SHM_NAME") != NULL) { strcpy((char *)multi_sim_arg.boot.sysdma_shm_name, Get_String(filename, "BOOT_OPTION", "SYSDMA_SHM_NAME")); } for (i = 0; i< DSPNUM; i++) { sprintf(core_name, "CORE%d", i); multi_sim_arg.pacdsp[i].core_base = Get_Value(filename, core_name, "BASE", 0); //M1 multi_sim_arg.pacdsp[i].m1_mem.dmem_m1_offset = Get_Value(filename, core_name, "M1_MEM_OFFSET", 0); multi_sim_arg.pacdsp[i].m1_mem.dmem_m1_size = Get_Value(filename, core_name, "M1_MEM_SIZE", 0); multi_sim_arg.pacdsp[i].m1_mem.m1_rd_delay = Get_Value(filename, core_name, "M1_MEM_RD_DELAY", 0); multi_sim_arg.pacdsp[i].m1_mem.m1_wr_delay = Get_Value(filename, core_name, "M1_MEM_WR_DELAY", 0); //Res1 multi_sim_arg.pacdsp[i].res1.res1_offset = Get_Value(filename, core_name, "RES1_OFFSET", 0); multi_sim_arg.pacdsp[i].res1.res1_size = Get_Value(filename, core_name, "RES1_SIZE", 0); //L1 multi_sim_arg.pacdsp[i].l1_cache.l1_cache_type = Get_Value(filename, core_name, "L1_CACHE_LINE_TYPE", 0); multi_sim_arg.pacdsp[i].l1_cache.l1_cache_size = Get_Value(filename, core_name, "L1_CACHE_SIZE", 0); multi_sim_arg.pacdsp[i].l1_cache.l1_cache_line_size = Get_Value(filename, core_name, "L1_CACHE_LINE_SIZE", 0); multi_sim_arg.pacdsp[i].l1_cache.l1_rd_delay = Get_Value(filename, core_name, "L1_CACHE_LINE_RD_DELAY", 0); //CORE BIU multi_sim_arg.pacdsp[i].biu.biu_offset = Get_Value(filename, core_name, "BIU_OFFSET", 0); multi_sim_arg.pacdsp[i].biu.biu_size = Get_Value(filename, core_name, "BIU_SIZE", 0); multi_sim_arg.pacdsp[i].biu.biu_rd_delay = Get_Value(filename, core_name, "BIU_RD_DELAY", 0); multi_sim_arg.pacdsp[i].biu.biu_wr_delay = Get_Value(filename, core_name, "BIU_WR_DELAY", 0); //CORE ICU multi_sim_arg.pacdsp[i].icu.icu_offset = Get_Value(filename, core_name, "ICU_OFFSET", 0); multi_sim_arg.pacdsp[i].icu.icu_size = Get_Value(filename, core_name, "ICU_SIZE", 0); multi_sim_arg.pacdsp[i].icu.icu_rd_delay = Get_Value(filename, core_name, "ICU_RD_DELAY", 0); multi_sim_arg.pacdsp[i].icu.icu_wr_delay = Get_Value(filename, core_name, "ICU_WR_DELAY", 0); //CORE DMU multi_sim_arg.pacdsp[i].dmu.dmu_offset = Get_Value(filename, core_name, "DMU_OFFSET", 0); multi_sim_arg.pacdsp[i].dmu.dmu_size = Get_Value(filename, core_name, "DMU_SIZE", 0); multi_sim_arg.pacdsp[i].dmu.dmu_rd_delay = Get_Value(filename, core_name, "DMU_RD_DELAY", 0); multi_sim_arg.pacdsp[i].dmu.dmu_wr_delay = Get_Value(filename, core_name, "DMU_WR_DELAY", 0); //CORE DMA multi_sim_arg.pacdsp[i].dma.dma_offset = Get_Value(filename, core_name, "DMA_OFFSET", 0); multi_sim_arg.pacdsp[i].dma.dma_size = Get_Value(filename, core_name, "DMA_SIZE", 0); multi_sim_arg.pacdsp[i].dma.dma_rd_delay = Get_Value(filename, core_name, "DMA_RD_DELAY", 0); multi_sim_arg.pacdsp[i].dma.dma_wr_delay = Get_Value(filename, core_name, "DMA_WR_DELAY", 0); //CORE Res2 multi_sim_arg.pacdsp[i].res2.res2_offset = Get_Value(filename, core_name, "RES2_OFFSET", 0); multi_sim_arg.pacdsp[i].res2.res2_size = Get_Value(filename, core_name, "RES2_SIZE", 0); } //M2 multi_sim_arg.m2_mem.dmem_m2_base = Get_Value(filename, "M2_MEM", "BASE", 0); multi_sim_arg.m2_mem.dmem_m2_size = Get_Value(filename, "M2_MEM", "SIZE", 0); multi_sim_arg.m2_mem.m2_rd_delay = Get_Value(filename, "M2_MEM", "RD_DELAY", 0); multi_sim_arg.m2_mem.m2_wr_delay = Get_Value(filename, "M2_MEM", "WR_DELAY", 0); //L2 multi_sim_arg.l2_cache.l2_cache_type = Get_Value(filename, "L2_CACHE", "L2_CACHE_LINE_TYPE", 0); multi_sim_arg.l2_cache.l2_cache_size = Get_Value(filename, "L2_CACHE", "L2_CACHE_SIZE", 0); multi_sim_arg.l2_cache.l2_cache_line_size = Get_Value(filename, "L2_CACHE", "L2_CACHE_LINE_SIZE", 0); multi_sim_arg.l2_cache.l2_rd_delay = Get_Value(filename, "L2_CACHE", "L2_CACHE_LINE_RD_DELAY", 0); //L2 ICU multi_sim_arg.l2_icu.l2_icu_base = Get_Value(filename, "L2_ICU", "BASE", 0); multi_sim_arg.l2_icu.l2_icu_size = Get_Value(filename, "L2_ICU", "SIZE", 0); multi_sim_arg.l2_icu.l2_icu_rd_delay = Get_Value(filename, "L2_ICU", "RD_DELAY", 0); multi_sim_arg.l2_icu.l2_icu_wr_delay = Get_Value(filename, "L2_ICU", "WR_DELAY", 0); //M2 DMU multi_sim_arg.m2_dmu.m2_dmu_base = Get_Value(filename, "M2_DMU", "BASE", 0); multi_sim_arg.m2_dmu.m2_dmu_size = Get_Value(filename, "M2_DMU", "SIZE", 0); multi_sim_arg.m2_dmu.m2_dmu_rd_delay = Get_Value(filename, "M2_DMU", "RD_DELAY", 0); multi_sim_arg.m2_dmu.m2_dmu_wr_delay = Get_Value(filename, "M2_DMU", "WR_DELAY", 0); //M2 DMA multi_sim_arg.m2_dma.m2_dma_base = Get_Value(filename, "M2_DMA", "BASE", 0); multi_sim_arg.m2_dma.m2_dma_size = Get_Value(filename, "M2_DMA", "SIZE", 0); multi_sim_arg.m2_dma.m2_dma_rd_delay = Get_Value(filename, "M2_DMA", "RD_DELAY", 0); multi_sim_arg.m2_dma.m2_dma_wr_delay = Get_Value(filename, "M2_DMA", "WR_DELAY", 0); //SEM multi_sim_arg.sem.sem_base = Get_Value(filename, "SEMAPHORE", "BASE", 0); multi_sim_arg.sem.sem_size = Get_Value(filename, "SEMAPHORE", "SIZE", 0); multi_sim_arg.sem.sem_rd_delay = Get_Value(filename, "SEMAPHORE", "RD_DELAY", 0); multi_sim_arg.sem.sem_wr_delay = Get_Value(filename, "SEMAPHORE", "WR_DELAY", 0); //C2CC multi_sim_arg.c2cc.c2cc_base = Get_Value(filename, "C2CC_INTERFACE", "BASE", 0); multi_sim_arg.c2cc.c2cc_size = Get_Value(filename, "C2CC_INTERFACE", "SIZE", 0); multi_sim_arg.c2cc.c2cc_rd_delay = Get_Value(filename, "C2CC_INTERFACE", "RD_DELAY", 0); multi_sim_arg.c2cc.c2cc_wr_delay = Get_Value(filename, "C2CC_INTERFACE", "WR_DELAY", 0); //DDR multi_sim_arg.ddr_mem.ddr_memory_base = Get_Value(filename, "DDR", "BASE", 0); multi_sim_arg.ddr_mem.ddr_memory_size = Get_Value(filename, "DDR", "SIZE", 0); multi_sim_arg.ddr_mem.ddr_shm_base = Get_Value(filename, "DDR", "DDR_SHM_BASE", 0); multi_sim_arg.ddr_mem.ddr_shm_size = Get_Value(filename, "DDR", "DDR_SHM_SIZE", 0); multi_sim_arg.ddr_mem.ddr_rd_delay = Get_Value(filename, "DDR", "RD_DELAY", 0); multi_sim_arg.ddr_mem.ddr_wr_delay = Get_Value(filename, "DDR", "WR_DELAY", 0); //BIU multi_sim_arg.biu.biu_rd_delay = Get_Value(filename, "BIU", "RD_DELAY", 0); multi_sim_arg.biu.biu_wr_delay = Get_Value(filename, "BIU", "WR_DELAY", 0); //SYS_DMA multi_sim_arg.sys_dma.sys_dma_base = Get_Value(filename, "SYS_DMA", "BASE", 0); multi_sim_arg.sys_dma.sys_dma_size = Get_Value(filename, "SYS_DMA", "SIZE", 0); multi_sim_arg.sys_dma.sys_dma_rd_delay = Get_Value(filename, "SYS_DMA", "RD_DELAY", 0); multi_sim_arg.sys_dma.sys_dma_wr_delay = Get_Value(filename, "SYS_DMA", "WR_DELAY", 0); //OTHER multi_sim_arg.other.sim_time_unit = Get_Value(filename, "OTHER", "SIM_TIME_UNIT", 0); }