//--------------------------------------------------------------------------- bool File_DolbyE::Synchronize() { //Synchronizing while (Buffer_Offset+32<=Buffer_Size) { if ((CC2(Buffer+Buffer_Offset_Temp)&0xFFFE)==0x078E) //16-bit { BitDepth=16; ScrambledBitStream=(CC2(Buffer+Buffer_Offset)&0x0001)?true:false; break; //while() } if ((CC3(Buffer+Buffer_Offset)&0xFFFFE0)==0x0788E0) //20-bit { BitDepth=20; ScrambledBitStream=(CC3(Buffer+Buffer_Offset)&0x000010)?true:false; break; //while() } if ((CC3(Buffer+Buffer_Offset)&0xFFFFFE)==0x07888E) //24-bit { BitDepth=24; ScrambledBitStream=(CC3(Buffer+Buffer_Offset)&0x000001)?true:false; break; //while() } Buffer_Offset++; } //Parsing last bytes if needed if (Buffer_Offset+8>Buffer_Size) return false; //Synched return true; }
//--------------------------------------------------------------------------- bool File_Adts::Synchronize() { //Tags bool Tag_Found; if (!File__Tags_Helper::Synchronize(Tag_Found)) return false; if (Tag_Found) return true; //Synchronizing while (Buffer_Offset+6<=Buffer_Size) { while (Buffer_Offset+6<=Buffer_Size && (CC2(Buffer+Buffer_Offset)&0xFFF6)!=0xFFF0) Buffer_Offset++; if (Buffer_Offset+6<=Buffer_Size)//Testing if size is coherant { //Testing next start, to be sure int16u aac_frame_length=(CC3(Buffer+Buffer_Offset+3)>>5)&0x1FFF; if (IsSub && Buffer_Offset+aac_frame_length==Buffer_Size) break; if (File_Offset+Buffer_Offset+aac_frame_length!=File_Size-File_EndTagSize) { if (Buffer_Offset+aac_frame_length+2>Buffer_Size) return false; //Need more data //Testing if (aac_frame_length<=7 || (CC2(Buffer+Buffer_Offset+aac_frame_length)&0xFFF6)!=0xFFF0) Buffer_Offset++; else { //Testing next start, to be sure int16u aac_frame_length2=(CC3(Buffer+Buffer_Offset+aac_frame_length+3)>>5)&0x1FFF; if (File_Offset+Buffer_Offset+aac_frame_length+aac_frame_length2!=File_Size-File_EndTagSize) { if (Buffer_Offset+aac_frame_length+aac_frame_length2+2>Buffer_Size) return false; //Need more data //Testing if (aac_frame_length<=7 || (CC2(Buffer+Buffer_Offset+aac_frame_length+aac_frame_length2)&0xFFF6)!=0xFFF0) Buffer_Offset++; else break; //while() } else break; //while() } } else break; //while() }
//--------------------------------------------------------------------------- bool File_Ogg::Synchronize() { //Look for first Sync word if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Synchronize() has already parsed first bytes Buffer_Offset_Temp=Buffer_Offset; while (Buffer_Offset_Temp+4<=Buffer_Size && CC4(Buffer+Buffer_Offset_Temp)!=Ogg::OggS) Buffer_Offset_Temp++; //Not synched case if (!Synched && Buffer_Offset_Temp+4>Buffer_Size) { if (Buffer_Offset_Temp+3==Buffer_Size) { if (CC3(Buffer+Buffer_Offset_Temp)!=CC3("Ogg")) { Buffer_Offset_Temp++; if (CC2(Buffer+Buffer_Offset_Temp)!=CC2("Og")) { Buffer_Offset_Temp++; if (CC1(Buffer+Buffer_Offset_Temp)!=CC1("O")) Buffer_Offset_Temp++; } } } Buffer_Offset=Buffer_Offset_Temp; Buffer_Offset_Temp=0; return false; } //Must wait more data? if (Buffer_Offset_Temp+4>Buffer_Size) return false; //Error in stream? if (Buffer_Offset_Temp-Buffer_Offset>0) { if (Synched) Trusted_IsNot("Sync error"); else Info("Synchronization"); } //OK, we continue Buffer_Offset=Buffer_Offset_Temp; Buffer_Offset_Temp=0; Synched=true; return true; }
//--------------------------------------------------------------------------- bool File_Dirac::Synchronize() { //Synchronizing while (Buffer_Offset+5<=Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x42424344) //"BBCD" Buffer_Offset++; if (Buffer_Offset+5>Buffer_Size) { //Parsing last bytes if (Buffer_Offset+4==Buffer_Size) { if (CC4(Buffer+Buffer_Offset)!=0x42424344) { Buffer_Offset++; if (CC3(Buffer+Buffer_Offset)!=0x424243) { Buffer_Offset++; if (CC2(Buffer+Buffer_Offset)!=0x4242) { Buffer_Offset++; if (CC1(Buffer+Buffer_Offset)!=0x42) Buffer_Offset++; } } } } return false; } //Synched is OK Synched=true; return true; }
//--------------------------------------------------------------------------- void File_AvsV::Data_Parse() { //Parsing switch (Element_Code) { case 0xB0: video_sequence_start(); break; case 0xB1: video_sequence_end(); break; case 0xB2: user_data_start(); break; case 0xB5: extension_start(); break; case 0xB3: case 0xB6: picture_start(); break; case 0xB7: video_edit(); break; case 0xB4: case 0xB8: reserved(); break; default: if (Element_Code>=0x00 && Element_Code<=0xAF) slice(); else if (Element_Code==0xE0 && Element_Size>=2 && CC2(Buffer+Buffer_Offset)==0x0000) { Trusted=0; //This is surely an extract from MPEG-TS Trusted_IsNot("Unattended element"); } else Trusted_IsNot("Unattended element"); } if (File_Offset+Buffer_Offset+Element_Size==File_Size && Frame_Count>0 && Count_Get(Stream_Video)==0) //Finalize frames in case of there are less than Frame_Count_Valid frames { //No need of more Accept("AVS Video"); Finish("AVS Video"); } }
//--------------------------------------------------------------------------- bool File_Wvpk::Synchronize() { //Specific case if (FromMKV) return true; //Tags bool Tag_Found; if (!File__Tags_Helper::Synchronize(Tag_Found)) return false; if (Tag_Found) return true; //Synchronizing while (Buffer_Offset+8<=Buffer_Size) { while (Buffer_Offset+8<=Buffer_Size && CC4(Buffer+Buffer_Offset)!=CC4("wvpk")) { Buffer_Offset++; } if (Buffer_Offset+8<=Buffer_Size)//Testing if size is coherant { //Testing next start, to be sure size_t Size=LittleEndian2int32u(Buffer+Buffer_Offset+4)+8; if (Buffer_Offset+Size+8>Buffer_Size) return false; //Need more data //Testing if (CC4(Buffer+Buffer_Offset+Size)!=CC4("wvpk")) Buffer_Offset++; else break; //while() } } //Parsing last bytes if needed if (Buffer_Offset+8>Buffer_Size) { if (Buffer_Offset+7==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x7776706B) //"wvpk" Buffer_Offset++; if (Buffer_Offset+6==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x7776706B) //"wvpk" Buffer_Offset++; if (Buffer_Offset+5==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x7776706B) //"wvpk" Buffer_Offset++; if (Buffer_Offset+4==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x7776706B) //"wvpk" Buffer_Offset++; if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x777670) //"wv" Buffer_Offset++; if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x7776) //"wv" Buffer_Offset++; if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x77) //"w" Buffer_Offset++; return false; } //Synched is OK return true; }
//--------------------------------------------------------------------------- bool File_Dirac::Synchronize() { //Synchronizing while(Buffer_Offset+4<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x42 || Buffer[Buffer_Offset+1]!=0x42 || Buffer[Buffer_Offset+2]!=0x43 || Buffer[Buffer_Offset+3]!=0x44)) //"BBCD" { Buffer_Offset+=2; while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x42) Buffer_Offset+=2; if (Buffer_Offset>=Buffer_Size || Buffer[Buffer_Offset-1]==0x42) Buffer_Offset--; } //Parsing last bytes if needed if (Buffer_Offset+4>Buffer_Size) { if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x424243) //"BBC" Buffer_Offset++; if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x4242) //"BB" Buffer_Offset++; if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x42) //"B" Buffer_Offset++; return false; } //Synched is OK return true; }
//--------------------------------------------------------------------------- void File_Aac::Read_Buffer_Continue () { //Tags if (File_Offset==0) { if (!Skip_ID3v2()) return; } //Parsing headers if (Buffer_Size<=8) ES(); //AAC in ES (.MP4) else if (CC4(Buffer)==CC4("ADIF")) ADIF(); //ADIF header else if ((CC2(Buffer+Buffer_Offset)&0xFFF6)==0xFFF0) ADTS(); //ADTS header (12 bits + ID + 2 bits) else if (CC3(Buffer)==CC3("AAC")) AAC(); //AAC header //No need of more File_Offset=File_Size; //Tags #if defined(MEDIAINFO_ID3_YES) /* File_Id3 Id3; if (Id3.Open(CompleteFileName)<0) Id3.Open(Buffer, Id3v2_Size); Merge(Id3); */ #endif //ID3 }
//--------------------------------------------------------------------------- bool File_Jpeg::FileHeader_Begin() { //Element_Size if (Buffer_Size<3) return false; //Must wait for more data if (Buffer[2]!=0xFF || (CC2(Buffer)!=Elements::SOI && CC2(Buffer)!=Elements::SOC)) { Reject("JPEG"); return false; } Accept(); //All should be OK... return true; }
//--------------------------------------------------------------------------- bool File_Ogg::Synchronize() { //Synchronizing while (Buffer_Offset+4<=Buffer_Size) { while(Buffer_Offset+4<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x4F || Buffer[Buffer_Offset+1]!=0x67 || Buffer[Buffer_Offset+2]!=0x67 || Buffer[Buffer_Offset+3]!=0x53)) //"OggS" { Buffer_Offset+=1+2; while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x67) Buffer_Offset+=2; if (Buffer_Offset>=Buffer_Size || Buffer[Buffer_Offset-1]==0x67) Buffer_Offset--; Buffer_Offset--; } if (Buffer_Offset+4<=Buffer_Size) //Testing if size is coherant { //Retrieving some info if (Buffer_Offset+27>Buffer_Size) return false; //Need more data int8u page_segments=CC1(Buffer+Buffer_Offset+26); if (Buffer_Offset+27+page_segments>Buffer_Size) return false; //Need more data size_t Size=0; for (int8u Pos=0; Pos<page_segments; Pos++) Size+=CC1(Buffer+Buffer_Offset+27+Pos); //Testing if (Buffer_Offset+27+page_segments+Size+4>Buffer_Size) return false; //Need more data if (CC4(Buffer+Buffer_Offset+27+page_segments+Size)!=0x4F676753) //"OggS" Buffer_Offset++; else break; } } //Parsing last bytes if needed if (Buffer_Offset+4>Buffer_Size) { if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x4F6767) //"Ogg" Buffer_Offset++; if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x4F67) //"Og" Buffer_Offset++; if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x4F) //"O" Buffer_Offset++; return false; } //Synched is OK return true; }
//--------------------------------------------------------------------------- bool File_Jpeg::FileHeader_Begin() { if (Buffer_Size<2) return false; if (CC2(Buffer)!=0xFFD8) //SOI { Finished(); return false; } return true; }
//--------------------------------------------------------------------------- void File_7z::Read_Buffer_Continue() { //Integrity if (Buffer_Size<=6) return; //Header if (CC2(Buffer)!=CC2("7z") || CC4(Buffer+2)!=0xBCAF271C) { File_Offset=File_Size; return; } //Filling Stream_Prepare(Stream_General); Fill("Format", "7Z"); //No need of more File_Offset=File_Size; }
//--------------------------------------------------------------------------- bool File_Latm::Synchronize() { //Synchronizing while (Buffer_Offset+2<=Buffer_Size && (CC2(Buffer+Buffer_Offset)&0xFFE0)!=0x56E0) Buffer_Offset++; if (Buffer_Offset+2>=Buffer_Size) return false; //Synched is OK return true; }
//--------------------------------------------------------------------------- bool File_Latm::Synched_Test() { //Must have enough buffer for having header if (Buffer_Offset+2>Buffer_Size) return false; //Quick test of synchro if ((CC2(Buffer+Buffer_Offset)&0xFFE0)!=0x56E0) Synched=false; //We continue return true; }
//--------------------------------------------------------------------------- bool File_Wvpk::FileHeader_Begin() { //Element_Size if (Buffer_Size<2) return false; //Must wait for more data if (CC2(Buffer)==0x4D5A) //"MZ" { File__Tags_Helper::Reject("WavPack"); return false; //Executable with WavPack data are currently not well supported --> It is preferable to set them as executable } //All should be OK... return true; }
//--------------------------------------------------------------------------- bool File_Gzip::FileHeader_Begin() { //Element_Size if (Buffer_Size<2) return false; //Must wait for more data if (CC2(Buffer)!=0x1F8B) { Reject("Gzip"); return false; } //All should be OK... return true; }
//--------------------------------------------------------------------------- bool File_Mz::FileHeader_Begin() { //Element_Size if (Buffer_Size<2) return false; //Must wait for more data if (CC2(Buffer)!=0x4D5A) //"MZ" { Reject("MZ"); return false; } //All should be OK... return true; }
//--------------------------------------------------------------------------- bool File_Ico::FileHeader_Begin() { //Element_Size if (Buffer_Size<4) return false; //Must wait for more data if (CC2(Buffer) || (LittleEndian2int16u(Buffer+2)!=1 && LittleEndian2int16u(Buffer+2)!=2)) { Reject("ICO"); return false; } //All should be OK... return true; }
//--------------------------------------------------------------------------- bool File_Dirac::Synchronize() { //Synchronizing while (Buffer_Offset+5<=Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x42424344) //"BBCD" Buffer_Offset++; if (Buffer_Offset+5>Buffer_Size) { //Parsing last bytes if (Buffer_Offset+4==Buffer_Size) { if (CC4(Buffer+Buffer_Offset)!=0x42424344) { Buffer_Offset++; if (CC3(Buffer+Buffer_Offset)!=0x424243) { Buffer_Offset++; if (CC2(Buffer+Buffer_Offset)!=0x4242) { Buffer_Offset++; if (CC1(Buffer+Buffer_Offset)!=0x42) Buffer_Offset++; } } } } return false; } //Synched is OK Synched=true; if (Streams.empty()) { //Count of a Packets Frame_Count=0; //Temp Dirac_base_video_format((int32u)-1, frame_width, frame_height, chroma_format, source_sampling, clean_width, clean_height, clean_left_offset, clean_top_offset, frame_rate, pixel_aspect_ratio); //Default stream values Streams.resize(0x100); Streams[0x00].Searching_Payload=true; //Sequence header } return true; }
//--------------------------------------------------------------------------- void File_DolbyE::Header_Parse() { //Filling if (IsSub) Header_Fill_Size(Buffer_Size-Buffer_Offset); else { //Looking for synchro //Synchronizing Buffer_Offset_Temp=Buffer_Offset+3; if (BitDepth==16) while (Buffer_Offset_Temp+2<=Buffer_Size) { if ((CC2(Buffer+Buffer_Offset_Temp)&0xFFFE)==0x078E) //16-bit break; //while() Buffer_Offset_Temp++; } if (BitDepth==20) while (Buffer_Offset_Temp+3<=Buffer_Size) { if ((CC3(Buffer+Buffer_Offset_Temp)&0xFFFFE0)==0x0788E0) //20-bit break; //while() Buffer_Offset_Temp++; } if (BitDepth==24) while (Buffer_Offset_Temp+3<=Buffer_Size) { if ((CC3(Buffer+Buffer_Offset_Temp)&0xFFFFFE)==0x07888E) //24-bit break; //while() Buffer_Offset_Temp++; } if (Buffer_Offset_Temp+(BitDepth>16?3:2)>Buffer_Size) { if (File_Offset+Buffer_Size==File_Size) Buffer_Offset_Temp=Buffer_Size; else { Element_WaitForMoreData(); return; } } Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset); } Header_Fill_Code(0, "Frame"); }
//--------------------------------------------------------------------------- bool File_DolbyE::Synched_Test() { //Must have enough buffer for having header if (Buffer_Offset+32>Buffer_Size) return false; //Quick test of synchro switch (BitDepth) { case 16 : if ((CC2(Buffer+Buffer_Offset)&0xFFFE )!=0x078E ) {Synched=false; return true;} break; case 20 : if ((CC3(Buffer+Buffer_Offset)&0xFFFFE0)!=0x0788E0) {Synched=false; return true;} break; case 24 : if ((CC3(Buffer+Buffer_Offset)&0xFFFFFE)!=0x07888E) {Synched=false; return true;} break; default : ; } //We continue return true; }
//--------------------------------------------------------------------------- bool File_Latm::Header_Begin() { //Must have enough buffer for having header if (Buffer_Offset+4>Buffer_Size) return false; //Quick test of synchro if (Synched && (CC2(Buffer+Buffer_Offset)&0xFFE0)!=0x56E0) { Trusted_IsNot("LATM, Synchronisation lost"); Synched=false; } //Synchro if (!Synched && !Synchronize()) return false; //All should be OK... return true; }
//--------------------------------------------------------------------------- bool File_Cdxa::FileHeader_Begin() { //Element_Size if (Buffer_Size<0x28) return false; //Must wait for more data if ( CC4(Buffer+0x00)!=0x52494646 //"RIFF" || LittleEndian2int32u(Buffer+0x04)!=LittleEndian2int32u(Buffer+0x28)+0x24 //Sizes of chunks || CC4(Buffer+0x08)!=0x43445841 //"CDXA" || CC4(Buffer+0x0C)!=0x666D7420 //"fmt " || LittleEndian2int32u(Buffer+0x10)!=0x10 || CC2(Buffer+0x1A)!=0x5841 //"XA" || CC4(Buffer+0x24)!=0x64617461) //"data" { Reject("CDXA"); return false; } //All should be OK... return true; }
//--------------------------------------------------------------------------- bool File_Jpeg::Header_Parser_Fill_Size() { //Look for next Sync word if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Header_Parse_Fill_Size() has already parsed first frames Buffer_Offset_Temp=Buffer_Offset; while (Buffer_Offset_Temp+2<=Buffer_Size && CC2(Buffer+Buffer_Offset_Temp)!=Elements::EOI) Buffer_Offset_Temp++; //Must wait more data? if (Buffer_Offset_Temp+2>Buffer_Size) { if (/*FrameIsAlwaysComplete ||*/ File_Offset+Buffer_Size>=File_Size) Buffer_Offset_Temp=Buffer_Size; //We are sure that the next bytes are a start else return false; } //OK, we continue Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset); Buffer_Offset_Temp=0; return true; }
//--------------------------------------------------------------------------- bool File_DvbSubtitle::Synched_Test() { if (MustFindDvbHeader) { //Must have enough buffer for having header if (Buffer_Offset+1>Buffer_Size) return false; if (CC2(Buffer+Buffer_Offset)!=0x2000) { Synched=false; return true; } //Displaying it Element_Size=2; Skip_B1( "data_identifier"); Get_B1 (subtitle_stream_id, "subtitle_stream_id"); Buffer_Offset+=2; MustFindDvbHeader=false; } //Must have enough buffer for having header if (Buffer_Offset+1>Buffer_Size) return false; //Quick test of synchro if (Buffer[Buffer_Offset]!=0x0F && Buffer[Buffer_Offset]!=0xFF) { Synched=false; return true; } //We continue return true; }
//--------------------------------------------------------------------------- bool File_Dirac::Synchronize() { //Synchronizing while (Buffer_Offset+5<=Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x42424344) //"BBCD" Buffer_Offset++; //Parsing last bytes if needed if (Buffer_Offset+5>Buffer_Size) { if (Buffer_Offset+4==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x42424344) //"BBCD" Buffer_Offset++; if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x424243) //"BBC" Buffer_Offset++; if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x4242) //"BB" Buffer_Offset++; if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x42) //"B" Buffer_Offset++; return false; } //Synched is OK return true; }
char * mnote_pentax_entry_get_value (MnotePentaxEntry *entry, char *val, unsigned int maxlen) { ExifLong vl; ExifShort vs, vs2; int i = 0, j = 0; if (!entry) return (NULL); memset (val, 0, maxlen); maxlen--; switch (entry->tag) { case MNOTE_PENTAX_TAG_MODE: case MNOTE_PENTAX_TAG_QUALITY: case MNOTE_PENTAX_TAG_FOCUS: case MNOTE_PENTAX_TAG_FLASH: case MNOTE_PENTAX_TAG_WHITE_BALANCE: case MNOTE_PENTAX_TAG_SHARPNESS: case MNOTE_PENTAX_TAG_CONTRAST: case MNOTE_PENTAX_TAG_SATURATION: case MNOTE_PENTAX_TAG_ISO_SPEED: case MNOTE_PENTAX_TAG_COLOR: case MNOTE_PENTAX2_TAG_MODE: case MNOTE_PENTAX2_TAG_QUALITY: case MNOTE_PENTAX2_TAG_FLASH_MODE: case MNOTE_PENTAX2_TAG_FOCUS_MODE: case MNOTE_PENTAX2_TAG_AFPOINT_SELECTED: case MNOTE_PENTAX2_TAG_AUTO_AFPOINT: case MNOTE_PENTAX2_TAG_WHITE_BALANCE: case MNOTE_PENTAX2_TAG_PICTURE_MODE: case MNOTE_PENTAX2_TAG_IMAGE_SIZE: case MNOTE_CASIO2_TAG_BESTSHOT_MODE: CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); CC2 (entry->components, 1, 2, val, maxlen); if (entry->components == 1) { vs = exif_get_short (entry->data, entry->order); /* search the tag */ for (i = 0; (items[i].tag && items[i].tag != entry->tag); i++); if (!items[i].tag) { snprintf (val, maxlen, _("Internal error (unknown value %i)"), vs); break; } /* find the value */ for (j = 0; items[i].elem[j].string && (items[i].elem[j].index < vs); j++); if (items[i].elem[j].index != vs) { snprintf (val, maxlen, _("Internal error (unknown value %i)"), vs); break; } strncpy (val, _(items[i].elem[j].string), maxlen); } else { /* Two-component values */ CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); CC2 (entry->components, 1, 2, val, maxlen); vs = exif_get_short (entry->data, entry->order); vs2 = exif_get_short (entry->data+2, entry->order) << 16; /* search the tag */ for (i = 0; (items2[i].tag && items2[i].tag != entry->tag); i++); if (!items2[i].tag) { snprintf (val, maxlen, _("Internal error (unknown value %i %i)"), vs, vs2); break; } /* find the value */ for (j = 0; items2[i].elem[j].string && ((items2[i].elem[j].index2 < vs2) || ((items2[i].elem[j].index2 == vs2) && (items2[i].elem[j].index1 < vs))); j++); if ((items2[i].elem[j].index1 != vs) || (items2[i].elem[j].index2 != vs2)) { snprintf (val, maxlen, _("Internal error (unknown value %i %i)"), vs, vs2); break; } strncpy (val, _(items2[i].elem[j].string), maxlen); } break; case MNOTE_PENTAX_TAG_ZOOM: CF (entry->format, EXIF_FORMAT_LONG, val, maxlen); CC (entry->components, 1, val, maxlen); vl = exif_get_long (entry->data, entry->order); snprintf (val, maxlen, "%li", (long int) vl); break; case MNOTE_PENTAX_TAG_PRINTIM: CF (entry->format, EXIF_FORMAT_UNDEFINED, val, maxlen); CC (entry->components, 124, val, maxlen); snprintf (val, maxlen, _("%i bytes unknown data"), entry->size); break; case MNOTE_PENTAX_TAG_TZ_CITY: case MNOTE_PENTAX_TAG_TZ_DST: CF (entry->format, EXIF_FORMAT_UNDEFINED, val, maxlen); CC (entry->components, 4, val, maxlen); strncpy (val, (char*)entry->data, MIN(maxlen, entry->size)); break; case MNOTE_PENTAX2_TAG_DATE: CF (entry->format, EXIF_FORMAT_UNDEFINED, val, maxlen); CC (entry->components, 4, val, maxlen); /* Note: format is UNDEFINED, not SHORT -> order is fixed: MOTOROLA */ vs = exif_get_short (entry->data, EXIF_BYTE_ORDER_MOTOROLA); snprintf (val, maxlen, "%i:%02i:%02i", vs, entry->data[2], entry->data[3]); break; case MNOTE_PENTAX2_TAG_TIME: CF (entry->format, EXIF_FORMAT_UNDEFINED, val, maxlen); CC2 (entry->components, 3, 4, val, maxlen); snprintf (val, maxlen, "%02i:%02i:%02i", entry->data[0], entry->data[1], entry->data[2]); break; default: switch (entry->format) { case EXIF_FORMAT_ASCII: strncpy (val, (char *)entry->data, MIN(maxlen, entry->size)); break; case EXIF_FORMAT_SHORT: { const unsigned char *data = entry->data; size_t k, len = strlen(val); for(k=0; k<entry->components; k++) { vs = exif_get_short (data, entry->order); snprintf (val+len, maxlen-len, "%i ", vs); len = strlen(val); data += 2; } } break; case EXIF_FORMAT_LONG: { const unsigned char *data = entry->data; size_t k, len = strlen(val); for(k=0; k<entry->components; k++) { vl = exif_get_long (data, entry->order); snprintf (val+len, maxlen-len, "%li", (long int) vl); len = strlen(val); data += 4; } } break; case EXIF_FORMAT_UNDEFINED: default: snprintf (val, maxlen, _("%i bytes unknown data"), entry->size); break; } break; } return (val); }
line_t *get_line(zfp *fp, line_t *in) { line_t *l = in; if (!l) { l = (line_t *)malloc(sizeof(*l)); l->str = NULL; l->len = 0; } do { size_t pos = 0, len; int no_nl = 1; do { if (l->len-pos < BLKSZ) { l->len = BLKSZ+pos; if (NULL == (l->str = realloc(l->str, l->len))) { if (!in) free_line(l); return NULL; } } if (NULL == zfgets(&l->str[pos], BLKSZ, fp)) { if (!in) free_line(l); return NULL; } len = strlen(&l->str[pos]); if (l->str[pos+len-1] == '\n') { l->str[pos+len-1] = 0; len--; no_nl = 0; } pos += len; } while (no_nl); l->len = pos; } while (l->str[0] == '#'); if (l->len == 0) { /* Blank line indicates block termination */ l->assign = 0; l->value = NULL; l->type = XX; return l; } if (l->len < 3 || (l->str[2] != '=' && l->str[2] != ':')) { fprintf(stderr, "Malformed line '%s'\n", l->str); if (!in) free_line(l); return NULL; } /* If we allocated this line ourselves, give back any extra memory */ if (!in) { l->str = realloc(l->str, l->len+1); } l->type = CC2(l->str[0], l->str[1]); l->assign = l->str[2]; l->value = l->str+3; return l; }
//--------------------------------------------------------------------------- bool File_Dts::Synchronize() { //Synchronizing while (Buffer_Offset+6<=Buffer_Size && !(BigEndian2int16u (Buffer+Buffer_Offset+0)==0x7FFE && BigEndian2int16u (Buffer+Buffer_Offset+2)==0x8001) //16 bits and big endian bitstream && !(LittleEndian2int16u(Buffer+Buffer_Offset+0)==0x7FFE && LittleEndian2int16u(Buffer+Buffer_Offset+2)==0x8001) //16 bits and little endian bitstream && !(BigEndian2int16u (Buffer+Buffer_Offset+0)==0x1FFF && BigEndian2int16u (Buffer+Buffer_Offset+2)==0xE800 && (BigEndian2int16u (Buffer+Buffer_Offset+4)&0xFFF0)==0x07F0) //14 bits and big endian bitstream && !(LittleEndian2int16u(Buffer+Buffer_Offset+0)==0x1FFF && LittleEndian2int16u(Buffer+Buffer_Offset+2)==0xE800 && (LittleEndian2int16u(Buffer+Buffer_Offset+4)&0xFFF0)==0x07F0) //14 bits and little endian bitstream ) Buffer_Offset++; if (Buffer_Offset+6>Buffer_Size) { //Parsing last bytes if (Buffer_Offset+6==Buffer_Size) { if (CC4(Buffer+Buffer_Offset)!=0x7FFE8001) //For 6 bytes instead of 4 (14 bits) { Buffer_Offset++; if (CC4(Buffer+Buffer_Offset)!=0x7FFE8001) //For 6 bytes instead of 4 (14 bits) { Buffer_Offset++; if (CC4(Buffer+Buffer_Offset)!=0x7FFE8001) { Buffer_Offset++; if (CC3(Buffer+Buffer_Offset)!=0x7FFE80) { Buffer_Offset++; if (CC2(Buffer+Buffer_Offset)!=0x7FFE) { Buffer_Offset++; if (CC1(Buffer+Buffer_Offset)!=0x7F) Buffer_Offset++; } } } } } } //Delay if (Frame_Count==0) Delay+=Buffer_Offset; return false; } //Configuring and Delay if (Frame_Count==0) { if (0) ; else if (BigEndian2int16u (Buffer+Buffer_Offset)==0x7FFE) //16 bits and big endian bitstream { } else if (LittleEndian2int16u(Buffer+Buffer_Offset)==0x7FFE) //16 bits and little endian bitstream { BigEndian=false; } else if (BigEndian2int16u (Buffer+Buffer_Offset)==0x1FFF) //14 bits and big endian bitstream { Word=false; } else if (LittleEndian2int16u(Buffer+Buffer_Offset)==0x1FFF) //14 bits and little endian bitstream { Word=false; BigEndian=false; } SyncCode=CC4(Buffer+Buffer_Offset); //14-bits and Little endian are not yet supported if (!Word || !BigEndian) { Finnished(); return false; } //Delay Delay+=Buffer_Offset; } //Synched is OK Synched=true; return true; }
#include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> #include "tg_gio.h" #include "tg_index_common.h" #include "hache_table.h" #include "baf.h" #include "zfio.h" #define CC2(a,b) ((((unsigned char)a)<<8) | ((unsigned char)b)) enum line_type { XX=0, /* Blank line */ CO=CC2('C','O'), /* Contig */ LN=CC2('L','N'), /* Length */ SO=CC2('S','O'), /* DNA Source */ ST=CC2('S','T'), /* Source type */ SI=CC2('S','I'), /* Insert size mean */ SS=CC2('S','S'), /* Insert size standard deviation */ SV=CC2('S','V'), /* vector */ RD=CC2('R','D'), /* Reading */ SQ=CC2('S','Q'), /* Sequence */ FQ=CC2('F','Q'), /* Fastq quality */ AP=CC2('A','P'), /* Contig position */ QL=CC2('Q','L'), /* Left quality clip */ QR=CC2('Q','R'), /* Right quality clip */ TN=CC2('T','N'), /* Template name */ DR=CC2('D','R'), /* Direction, 1=>uncomp, -1=>complemented */ PR=CC2('P','R'), /* Primer type */