CN104536843A - Embedded device and method for rapidly detecting whether JPEG picture files are right or not - Google Patents

Embedded device and method for rapidly detecting whether JPEG picture files are right or not Download PDF

Info

Publication number
CN104536843A
CN104536843A CN201410798857.2A CN201410798857A CN104536843A CN 104536843 A CN104536843 A CN 104536843A CN 201410798857 A CN201410798857 A CN 201410798857A CN 104536843 A CN104536843 A CN 104536843A
Authority
CN
China
Prior art keywords
file
jpeg
marker
section
0xff
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201410798857.2A
Other languages
Chinese (zh)
Inventor
陈淮琰
钟辉
刘刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inventec Besta Xian Co Ltd
Original Assignee
Inventec Besta Xian Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inventec Besta Xian Co Ltd filed Critical Inventec Besta Xian Co Ltd
Priority to CN201410798857.2A priority Critical patent/CN104536843A/en
Publication of CN104536843A publication Critical patent/CN104536843A/en
Pending legal-status Critical Current

Links

Landscapes

  • Compression Of Band Width Or Redundancy In Fax (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention provides an embedded device and method for rapidly detecting whether JPEG picture files are right or not. The embedded device comprises an initialization unit for initializing five Marker section counters including SIO/DQT/SOF/DHT/SOS, an obtaining unit for obtaining the size of the JPEG files and reading JPEG streaming files, a scanning unit for scanning Marker sections and a processing unit, wherein the initialization unit, the obtaining unit, the scanning unit and the processing unit are sequentially connected. By means of the embedded device and method for rapidly detecting whether the JPEG picture files are right or not, whether formats of the JPEG files are right or not can be judged at an extremely-high speed, and hardware decoding or a software decoding library do not need to be modified for the JPEG files with wrong contents.

Description

The embedded equipment whether a kind of quick detection JPEG picture file is correct and method
Technical field
The present invention relates to the whether correct embedded equipment of a kind of quick detection JPEG picture file and method.
Background technology
The use of embedded equipment multimedia document, JPEG picture can be used in a lot of situation, and jpeg format is because the various versions of specifications definition, although there is minority fault-tolerant design, and the form of the special design having mistake proofing unlike PNG form so easily fault-tolerant (PNG form critical chunk (criticalchunk) have CRC (cyclic redundancy check) with judge store data block in the whether wrong generation of data).And the reason such as the storage of embedded device storage medium or network transmission, possible data content occurs to destroy or change.As erasable in iNand media storage or after reading certain number of times, its content stored may just change, although there is ECC can correct out the error in data of certain Bit by School Affairs inside NAND in Page, still cannot ensure the unchanged content of 100%.If JPEG picture content content makes a mistake, the process fault-tolerant processing to JPEG exception of decoding software or hardware can only be relied on, and different hardware decoding chip or decoding storehouse software not thorough to error handle, namely the incorrect JPEG picture of content is used to show, often because fault-tolerant processing not thorough, and there is the situation of decoding abnormal (exception).And if thorough to the process of software decoding and fault tolerance, often want a large amount of manpower of telephone expenses to carry out decoding the amendment in storehouse, and hardware amendment fault-tolerant be also need larger hardware cost of development.
Products application scene has many times user to be the jpeg format picture needing to show oneself, because it is the JPEG graph data of the independent specific use of some closed embedded device that user's jpeg file at hand has more than, so and the improper amendment of agreement voluntarily jpeg file form (as increased CRC or other check information).
Visible exist drawback and deficiency for software and hardware decoded portion to jpeg format Correctness checking, how can verify that whether the form of JPEG is correct fast, and the impact of decoding speed can be used the smaller the better on product when being JPEG and checking.
How to use minimum exploitation cost and the figure that the embedded device that can be supported in open platform well can handle the jpeg format that data content likely damages well exception can not occur.
Summary of the invention
In order to solve technical matters existing in background technology, the present invention proposes the whether correct embedded equipment of a kind of quick detection JPEG picture file and method, the speed that is exceedingly fast just can judge jpeg file, and whether form is correct, for the jpeg file that content is wrong, do not need amendment hardware decode or software decode storehouse.
Technical solution of the present invention is: the embedded equipment whether a kind of quick detection JPEG picture file correct, it is characterized in that: described embedded equipment comprise initial SIO/DQT/SOF/DHT/SOS five the Marker segment counters connected successively initialization unit, obtain jpeg file size and read jpeg stream file acquiring unit, Marker section scanning scanning element and processing unit.
The method whether quick detection JPEG picture file is correct, is characterized in that: said method comprising the steps of:
1) initialization SIO/DQT/SOF/DHT/SOS five Marker segment counters are all 0;
2) stream file opens jpeg file, and obtains jpeg file size;
3) read jpeg stream file content, and scan character by character, be i.e. Marker section scanning;
4) for after SIO, DQT, SOF, DHT, SOS, DRI, COM, APP section followed by the segment length of 2 bytes, judge whether current location can exceed step 2 after offseting the length of this record) the middle jpeg file size obtained, judge JPEG picture NG as exceeded; If do not exceeded, then backward behind Seek file Marker section length position; As not jpeg file ending place after Seek ten thousand, then judge that the character read is if not Marker segment mark 0xFF value, if not being 0xFF code value, then judges jpeg file NG;
5) add up SIO, DQT, SOF, DHT, SOS section and whether at least occurred 1 time, if there is 1 type occurrence number to be less than 1 time, be judged as jpeg file NG.
Above-mentioned steps 5) also comprise step 6 afterwards) if step 1)-step 5) JPEG picture file not being judged to NG, then JPEG picture file is OK.
Above-mentioned steps 6) specifically:
6.1) open the jpeg file of examine in the mode of stream file, scan from file beginning backward, jpeg file Maker section is all with 0xFF beginning, directly retrieves the content of 0xFF;
6.2) number of times of flag code (0xFF) SIO below (0xD8), DQT (0xDB), SOF (0xC0-0xC3,0xC5-0xCB, 0xCD-0xCF), DHT (0xC4), the crucial Maker section appearance of SOS (0xDA) is added up in scanning process, as jpeg file lacks any one Marker section in them, then direct JPEG picture file is judged as NG;
6.3) in scanning process, the Marker section having segment length information: SIO (0xD8), DQT (0xDB), SOF (0xC0-0xC3,0xC5-0xCB, 0xCD-0xCF), DHT (0xC4), SOS (0xDA), DRI (0xDD), COM (0xFE), APP (0xE0-0xEF) are made a checking calculation;
6.4) according to step 6.3) Marker segment file jpeg file reference position and coordinate their length and the total size of jpeg file to contrast, if [Maker segment file initial+Maker segment length] is greater than [the total size of jpeg file], then judge that JPEG picture file is NG; Otherwise, directly directly skip these Marker sections according to obtaining Marker segment length again, if also have data below, whether then judge that next Marker section starts is new Maker beginning label (0xFF), if character is not (0xFF) mark, then JPEG picture file is judged as NG.
6.5) scan the end of file, if file is not judged as NG by step above, then can think that jpeg file is OK.
Advantage of the present invention is: the mode scanned simply efficiently with software, the speed that is exceedingly fast just can judge jpeg file, and whether form is correct, for the jpeg file that content is wrong, amendment hardware decode or software decode storehouse is not needed (not to need the details principle that realizes understanding software and hardware decoding storehouse to understand, more without the need to revising software and hardware JPEG decoding module), with time method pure software rapid scanning JPEG before decoding, whether correctly just jpeg file form can be known fast.When after form correct judgment, call JPEG hardware decode again or software decode Ka Ku carries out graphic decoder, avoid jpeg file format error, and software and hardware decoding for abnormal form JPEG decoding and there is abnormal (Exception), and need not go to drop into a large amount of exploit person power and go to strengthen or revise software and hardware decoding module to the process of exception, and decode whole process consuming time of jpeg file is not substantially had to rate (the correct algorithm speed of this scanography form is exceedingly fast, substantially the consuming time of increase can be ignored, and implement also very simple), and then can not exception be there is in the figure that the embedded device realizing using minimum exploitation cost (cost) and can be supported in open platform well can handle the jpeg format that data content likely damages well.
Accompanying drawing explanation
Fig. 1 is structural representation of the present invention;
Fig. 2 is the inventive method process flow diagram;
Embodiment
The present invention is directed to jpeg file form, whether design is a kind of is lacked by the crucial Marker section of statistics, and judge the Marker section having large tick marks, coordinate paragraph starting position and file size to contrast the paragraph sizes of Marker segment mark, if paragraph initial+section size exceedes file size and just can judge jpeg file NG; And paragraph internal data is directly skipped, the mode of stream file Seek directly reads next paragraph initial character, judges whether containing short beginning label 0xFF, if lower short beginning is not 0xFF mark, is then directly judged as this jpeg file NG.Because jpeg file major part data are the data segments with section size, so most of Data Data does not need to read and resolve, and be to skip, so speed can be quickly, for the hardware of the limited embedded device of computing power, the inspection link of increase can't affect any speed.Because do not relate to the decoding of the view data of concrete file, so also efficiently simple and practical on codes implement.
Needing the embedded equipment of jpeg file of display terminal user oneself, special enforcement JPEG Marker paragraph statistics and inspection, and do length logic matching judgment, if there is crucial segment data be increased or reduce data, or the crucial paragraph disappearance of JPEG, or this province of data file is increased or reduces content, then can be judged NG fast.And if individual characters or content are changed (but data segment size of population does not change) in just pure data segment; this situation only can cause decoding data image out and change (as image change or mosaic etc.), but can't allow decoders decode (can not the severely subnormals such as exception occur or work as machine) out of control.So with a kind of minimum input amount, the jpeg image file judging to make mistakes of energy maximum possible, and because checking mechanism can according to there being data in the automatic hop segments of the section of short length records, so speed quickly, thus realized embedded system before use decoding library software or pure hardware decoding JPEG picture, perform jpeg image file content Correctness checking, how much consuming timely can't increase, and then the impact of speed is not had on the good experience of terminal user.
See Fig. 1, the embedded equipment whether a kind of quick detection JPEG picture file is correct,, comprise the initialization unit 1 of initialization SIO/DQT/SOF/DHT/SOS five the Marker segment counters connected successively, obtain jpeg file size and read the acquiring unit 2 of jpeg stream file, the scanning element 3 of Marker section scanning and processing unit 4.
The method whether quick detection JPEG picture file is correct, comprises the following steps:
1) initialization SIO/DQT/SOF/DHT/SOS five Marker segment counters are all 0;
2) stream file opens jpeg file, and obtains jpeg file size;
3) read jpeg stream file content, and scan character by character, be i.e. Marker section scanning;
4) for after SIO, DQT, SOF, DHT, SOS, DRI, COM, APP section followed by the segment length of 2 bytes, judge whether current location can exceed step 2 after offseting the length of this record) the middle jpeg file size obtained, judge JPEG picture NG as exceeded; If do not exceeded, then backward behind Seek file Marker section length position; Not jpeg file ending place after as complete in Seek, then judge that the character read is if not Marker segment mark 0xFF value, if not being 0xFF code value, then judges jpeg file NG;
5) add up SIO, DQT, SOF, DHT, SOS section and whether at least occurred 1 time, if there is 1 type occurrence number to be less than 1 time, be judged as jpeg file NG.
6) if step 1)-step 5) JPEG picture file is not judged to NG, then JPEG picture file is OK.
6.1) open the jpeg file of examine in the mode of stream file, scan from file beginning backward, jpeg file Maker section is all with 0xFF beginning, directly retrieves the content of 0xFF;
6.2) number of times of flag code (0xFF) SIO below (0xD8), DQT (0xDB), SOF (0xC0-0xC3,0xC5-0xCB, 0xCD-0xCF), DHT (0xC4), the crucial Maker section appearance of SOS (0xDA) is added up in scanning process, as jpeg file lacks any one Marker section in them, then direct JPEG picture file is judged as NG;
6.3) in scanning process, the Marker section having segment length information: SIO (0xD8), DQT (0xDB), SOF (0xC0-0xC3,0xC5-0xCB, 0xCD-0xCF), DHT (0xC4), SOS (0xDA), DRI (0xDD), COM (0xFE), APP (0xE0-0xEF) are made a checking calculation;
6.4) according to step 6.3) Marker segment file jpeg file reference position and coordinate their length and the total size of jpeg file to contrast, if [Maker segment file initial+Maker segment length] is greater than [the total size of jpeg file], then judge that JPEG picture file is NG; Otherwise, directly directly skip these Marker sections according to obtaining Marker segment length again, if also have data below, whether then judge that next Marker section starts is new Maker beginning label (0xFF), if character is not (0xFF) mark, then JPEG picture file is judged as NG.
6.5) scan the end of file, if file is not judged as NG by step above, then can think that jpeg file is OK.
Because lack crucial Marker section non-jpeg format can be avoided to serve as jpeg format decoded, the imperfect of the crucial Marker section of jpeg file also can be avoided and decoding makes mistakes.And because can judge (contrasting in file reference position and file size in conjunction with Marker section) having the logic rationality of Marker segment length, just can be examined out if file size or Marker segment length are tampered, at least the mistake of major part destruction length exception can be examined out.Combine again and judge whether the character having data new after length Marker section to start is new Marker section beginning label (0xFF), just can differentiate out whether current Marker section content has to be reduced or increase (because shortening and increase are easy to affect software decode storehouse or the parsing of hardware decoding to the decoding storehouse of Marker section after it), so this section all can not remain the code value of 0xFF with regard to most of situation and be checked out NG by the present invention after starting the segment length of Marker place record.Certainly, if if the Marker section content-data having length information to record just change such as partial data such as grade (and data length does not change, namely do not delete or increase data), because picture data content matrix conversion, major part also just data decode image out and former figure variant, but can avoid Marker section that the decoding of dislocation section occurs when parsing, and then avoid the dislocation of Marker section the abnormal Exception of serious decoding occurs or works as machine.
The pure software mode of visible this quick inspection JPEG, algorithm is simple, but can maximum magnitude avoid software and hardware storehouse of decoding to be that abnormal Exception occurs to there being the jpeg file of most wrong content to decode, thus increased substantially the fault-tolerant ability that embedded equipment internally holds the decoding of vicious jpeg image.

Claims (4)

1. detect fast the whether correct embedded equipment of JPEG picture file, it is characterized in that: described embedded equipment comprise initialization SIO/DQT/SOF/DHT/SOS five the Marker segment counters connected successively initialization unit, obtain jpeg file size and read the acquiring unit of jpeg stream file, the scanning element of Marker section scanning and processing unit.
2. detect the whether correct method of JPEG picture file fast, it is characterized in that: said method comprising the steps of:
1) initialization SIO/DQT/SOF/DHT/SOS five Marker segment counters are all 0;
2) stream file opens jpeg file, and obtains jpeg file size;
3) read jpeg stream file content, and scan character by character, be i.e. Marker section scanning;
4) for after SIO, DQT, SOF, DHT, SOS, DRI, COM, APP section followed by the segment length of 2 bytes, judge whether current location can exceed step 2 after offseting the length of this record) the middle jpeg file size obtained, judge JPEG picture NG as exceeded; If do not exceeded, then backward behind Seek file Marker section length position; As not jpeg file ending place after Seek ten thousand, then judge that the character read is if not Marker segment mark 0xFF value, if not being 0xFF code value, then judges jpeg file NG;
5) add up SIO, DQT, SOF, DHT, SOS section and whether at least occurred 1 time, if there is 1 type occurrence number to be less than 1 time, be judged as jpeg file NG.
3. the method that whether quick detection JPEG picture file according to claim 2 is correct, it is characterized in that: described step 5) also comprise step 6 afterwards) if step 1)-step 5) JPEG picture file not being judged to NG, then JPEG picture file is OK.
4. the method that whether quick detection JPEG picture file according to claim 3 is correct, is characterized in that: described step 6) specifically:
6.1) open the jpeg file of examine in the mode of stream file, scan from file beginning backward, jpeg file Maker section is all with 0xFF beginning, directly retrieves the content of 0xFF;
6.2) number of times of flag code (0xFF) SIO below (0xD8), DQT (0xDB), SOF (0xC0-0xC3,0xC5-0xCB, 0xCD-0xCF), DHT (0xC4), the crucial Maker section appearance of SOS (0xDA) is added up in scanning process, as jpeg file lacks any one Marker section in them, then direct JPEG picture file is judged as NG;
6.3) in scanning process, the Marker section having segment length information: SIO (0xD8), DQT (0xDB), SOF (0xC0-0xC3,0xC5-0xCB, 0xCD-0xCF), DHT (0xC4), SOS (0xDA), DRI (0xDD), COM (0xFE), APP (0xE0-0xEF) are made a checking calculation;
6.4) according to step 6.3) Marker segment file jpeg file reference position and coordinate their length and the total size of jpeg file to contrast, if [Maker segment file initial+Maker segment length] is greater than [the total size of jpeg file], then judge that JPEG picture file is NG; Otherwise, directly directly skip these Marker sections according to obtaining Marker segment length again, if also have data below, whether then judge that next Marker section starts is new Maker beginning label (0xFF), if character is not (0xFF) mark, then JPEG picture file is judged as NG;
6.5) scan the end of file, if file is not judged as NG by step above, then can think that jpeg file is OK.
CN201410798857.2A 2014-12-18 2014-12-18 Embedded device and method for rapidly detecting whether JPEG picture files are right or not Pending CN104536843A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410798857.2A CN104536843A (en) 2014-12-18 2014-12-18 Embedded device and method for rapidly detecting whether JPEG picture files are right or not

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410798857.2A CN104536843A (en) 2014-12-18 2014-12-18 Embedded device and method for rapidly detecting whether JPEG picture files are right or not

Publications (1)

Publication Number Publication Date
CN104536843A true CN104536843A (en) 2015-04-22

Family

ID=52852374

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410798857.2A Pending CN104536843A (en) 2014-12-18 2014-12-18 Embedded device and method for rapidly detecting whether JPEG picture files are right or not

Country Status (1)

Country Link
CN (1) CN104536843A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107193838A (en) * 2016-03-15 2017-09-22 四川效率源信息安全技术股份有限公司 A kind of whether normal method of Automated inspection JPEG picture

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1916958A (en) * 2006-07-20 2007-02-21 中山大学 Method of detecting distorts of JPEG image
US20090201999A1 (en) * 2008-01-30 2009-08-13 Core Logic, Inc. Complementing Bitstream Error and Decoding
CN102156842A (en) * 2010-02-11 2011-08-17 腾讯科技(深圳)有限公司 File encryption protection method and device
CN102855602A (en) * 2011-06-28 2013-01-02 阿里巴巴集团控股有限公司 Picture processing method and picture processing device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1916958A (en) * 2006-07-20 2007-02-21 中山大学 Method of detecting distorts of JPEG image
US20090201999A1 (en) * 2008-01-30 2009-08-13 Core Logic, Inc. Complementing Bitstream Error and Decoding
CN102156842A (en) * 2010-02-11 2011-08-17 腾讯科技(深圳)有限公司 File encryption protection method and device
CN102855602A (en) * 2011-06-28 2013-01-02 阿里巴巴集团控股有限公司 Picture processing method and picture processing device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107193838A (en) * 2016-03-15 2017-09-22 四川效率源信息安全技术股份有限公司 A kind of whether normal method of Automated inspection JPEG picture

Similar Documents

Publication Publication Date Title
CN102937926B (en) Method and device for recovering deleted sqlite files on mobile terminal
CN103778030B (en) Daily record subsystem wiring method, error tracking method and processor
CN105045676A (en) Device and method for recovering lost data based on SQLite database
CN105095168A (en) Automatic generation method and device for contract files
CN109271315B (en) Script code detection method, script code detection device, computer equipment and storage medium
CN111061770A (en) BOM model matching device and method, electronic equipment and storage medium
CN110377885B (en) Method, device, equipment and computer storage medium for converting PDF file
US11580200B2 (en) Code identification
CN103957340A (en) Data transmission system based on color dynamic image
Aronson et al. Towards an engineering approach to file carver construction
CN106407038A (en) Fragmented file data recovery method
CN113055455A (en) File uploading method and equipment
CN109597566B (en) Data reading and storing method and device
CN103997406A (en) Two-dimensional code-based identity authentication method and apparatus
CN113687976A (en) Coding and decoding method and device for DNA information storage
CN104536843A (en) Embedded device and method for rapidly detecting whether JPEG picture files are right or not
CN104615948A (en) Method for automatically recognizing file completeness and restoring
CN102855602B (en) Picture processing method and picture processing device
CN114388053B (en) SSD data testing method and device, storage medium and testing equipment
WO2018077059A1 (en) Barcode identification method and apparatus
CN102341784B (en) Method for quick map recovery in case of error in moca
CN111639475B (en) Product code generation method and device and electronic equipment
CN104202056B (en) The method and Quick Response Code device of a kind of two-dimentional code error-correcting decoding
CN109635524B (en) Audio digital watermark embedding method and terminal equipment
CN107705340A (en) A kind of method and device of image decoding

Legal Events

Date Code Title Description
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20150422