Summary of the invention
For solving the problems of the technologies described above, the invention provides a kind of text code method and text code device, the success rate that the text of video is encoded can be improved.
The invention provides a kind of text code method, comprising:
At least two kinds of default text code modes are adopted to carry out precoding to the text of video respectively;
Choose a kind of text code mode that success rate in pre-encoding results is the highest;
The highest text code mode of described success rate is adopted to carry out text code to the text of described video;
Wherein, the text code mode that the described success rate of described employing is the highest carries out text code to described video, comprising:
Judge to adopt the highest text code mode of described success rate to the coding progress of the precoding that the text of described video carries out;
If described precoding progress is the coding carried out the whole text of described video, then adopt the pre-encoding results that text code mode that described success rate is the highest is corresponding;
If the coding that described precoding progress is carried out the text of X% before described video, then the text of the highest text code mode of described success rate to rear (100-X) % of described video is adopted to encode; X is positive number; Or adopt the whole text of the highest text code mode of described success rate to described video to carry out output encoder result after recompile.
Wherein, described default text code mode comprises: comprise double-byte encodings transformat UTF8, double-byte encodings transformat UTF16 or Chinese Internal Code Specification GBK.
Wherein, the described text to video carries out text code and comprises and carry out text code to the captioned test of video or parameter text.
Correspondingly, the present invention also provides a kind of text code device, comprising:
Precoding module, carries out precoding to the text of video respectively for adopting at least two kinds of default text code modes;
Coding mode selection module, a kind of text code mode that in the pre-encoding results that at least two kinds of default text code modes adopted for choosing described precoding module obtain, success rate is the highest;
Coding module, carries out text code for adopting the highest text code mode of the success rate of described coding mode selection model choice to the text of described video;
Judge module, for judging the coding progress of described precoding module to the precoding that the text of described video carries out;
If the precoding progress of described precoding module is the coding carried out the whole text of described video, then described coding module directly exports the pre-encoding results of described precoding module;
If the coding that the precoding progress of described precoding module is carried out the text of X% before described video, then described coding module adopts the text of the highest text code mode of described success rate to rear (100-X) % of described video to encode; X is positive number; Or described coding module adopts the whole text of the highest text code mode of described success rate to described video to carry out output encoder result after recompile.
Wherein, described device also comprises:
Coded system presetting module, for presetting at least two kinds of text code modes, described default text code mode comprises: comprise double-byte encodings transformat UTF8, double-byte encodings transformat UTF16 or Chinese Internal Code Specification GBK.
Wherein, described precoding module and coding module carry out text code to the text of video and comprise and carry out text code to the captioned test of video or parameter text.
Implement text code method provided by the invention and text code device, first adopt at least two kinds of text code modes to carry out precoding to the text of video, then select the coded system that in coding result, success rate is the highest to carry out text code to the text of video.So, improve the success rate of the text of video being carried out to text code.
Embodiment
For solving the problems of the technologies described above, the invention provides a kind of text code method and text code device, the success rate that the text of video is encoded can be improved.
See Fig. 1, it is the schematic flow sheet of a kind of text code embodiment of the method one provided by the invention.
The text code method that the present embodiment one provides, comprising:
Step 100, adopts at least two kinds of default text code modes to carry out precoding to the text of video respectively;
Step 101, chooses a kind of text code mode that success rate in pre-encoding results is the highest;
Step 102, adopts the highest text code mode of described success rate to carry out text code to the text of described video.
Text code method provided by the invention, at least two kinds of default text code modes are adopted to carry out precoding to the text of video respectively, then a kind of text code mode being chosen to power the highest carries out text code to the text of video, improves the success rate of the text of video being carried out to text code.
It should be noted that, described default text code mode comprises: comprise double-byte encodings transformat UTF8, double-byte encodings transformat UTF16 or Chinese Internal Code Specification GBK.
Wherein, UTF8(Unicode Translation Format 8) be UNICODE(ten thousand country code) the elongated character code of one, created in 1992 by Ken Thompson.UTF8 1 to 6 byte code UNICODE characters.Being used in can same page display simplified Chinese character traditional font and other Languages on webpage.UTF8 coding can by mask bit and shifting function fast reading and writing.During character string comparison strcmp () and wcscmp () return results identical, therefore make sequence become and be more prone to.
UTF16(Unicode Translation Format 16) be UNICODE(ten thousand country code) another occupation mode.
UTF16 is compared with UTF8, difference is that its most of character all stores with the byte of regular length (2 byte), but UTF16 cannot be compatible with ASCII(American Standard Code for Information Interchange, ASCII(American Standard Code for information interchange)) coding.That give tacit consent in c# is exactly UTF16, so be adopt the modes such as byte, stream to go process when process c# character string.
It should be noted that in addition, a video has multiple text message, such as captioned test or parameter text, then the described text to video carries out text code and comprises and carry out text code to the captioned test of video or parameter text.
See Fig. 2, it is the schematic flow sheet of a kind of text code embodiment of the method two provided by the invention.
The present embodiment two will describe in text code method provided by the invention the implementation procedure adopting the highest text code mode of described success rate described video to be carried out to text code, comprising:
Step 200, judges to adopt the highest text code mode of described success rate to the coding progress of the precoding that the text of described video carries out;
Step 201, if described precoding progress is the coding carried out the whole text of described video, then directly exports the pre-encoding results that the highest text code mode of employing success rate is corresponding;
Step 202, if the coding that described precoding progress is carried out the text of X% before described video, then adopts the text of the highest text code mode of described success rate to rear (100-X) % of described video to encode; X is positive number.
Step 203, if the coding that described precoding progress is carried out the text of X% before described video, adopts the whole text of the highest text code mode of described success rate to described video to carry out output encoder result after recompile.
Particularly, to carry out text code to the captioned test of video, UTF8 is adopted to carry out precoding success 15 captions; UTF16 is adopted to carry out precoding success 10 captions; GBK is adopted to carry out precoding success 5 captions; So choose the text code mode of UTF8 as this video; If the progress of precoding is encoded to the whole captioned test of video, then directly export this 15 captions; If precoding progress is 20 to 20%(and X value before video) captioned test carry out precoding, the captioned test so adopting UTF8 to continue rear 80% is encoded, and exports together with the captions of 15 before; Or adopt UTF8 again to encode to whole captioned test, output edit result.
See Fig. 3, it is the structural representation of a kind of text code device embodiment one provided by the invention.
A kind of text code device that the embodiment of the present invention one provides, comprising:
Precoding module 10, carries out precoding to the text of video respectively for adopting at least two kinds of default text code modes;
Coding mode selection module 11, a kind of text code mode that in the pre-encoding results that at least two kinds of default text code modes adopted for choosing described precoding module obtain, success rate is the highest;
Coding module 12, carries out text code for adopting the highest text code mode of the success rate of described coding mode selection model choice to the text of described video.
Wherein, the text of described precoding module 10 and coding module 12 pairs of videos carries out text code and comprises and carry out text code to the captioned test of video or parameter text.
Text code device provided by the invention, at least two kinds of default text code modes are adopted to carry out precoding to the text of video respectively, then a kind of text code mode being chosen to power the highest carries out text code to the text of video, improves the success rate of the text of video being carried out to text code.
See Fig. 4, it is the structural representation of a kind of text code device embodiment two provided by the invention.
A kind of text code device that the embodiment of the present invention two provides, except comprising the modules of embodiment one, also comprises:
Coded system presetting module 13, for presetting at least two kinds of text code modes, described default text code mode comprises: comprise double-byte encodings transformat UTF8, double-byte encodings transformat UTF16 or Chinese Internal Code Specification GBK.
See Fig. 5, it is the structural representation of a kind of text code device embodiment three provided by the invention.
A kind of text code device that the embodiment of the present invention three provides, except comprising the modules of embodiment two, also comprises:
Judge module 14, for judging the coding progress of described precoding module 10 to the precoding that the text of described video carries out;
If the precoding progress of described precoding module 10 is the codings carried out the whole text of described video, then described coding module 12 directly exports the pre-encoding results of described precoding module 10;
If the coding that the precoding progress of described precoding module 10 is carried out the text of X% before described video, then output encoder result after described coding module 12 adopts the text of the highest text code mode of described success rate to rear (100-X) % of described video to encode; X is positive number;
Or described coding module 12 adopts the whole text of the highest text code mode of described success rate to described video to carry out output encoder result after recompile.
Implement text code method provided by the invention and text code device, first adopt at least two kinds of text code modes to carry out precoding to the text of video, then select the coded system that in coding result, success rate is the highest to carry out text code to the text of video.So, improve the success rate of the text of video being carried out to text code.
One of ordinary skill in the art will appreciate that all or part of flow process realized in above-described embodiment method, that the hardware that can carry out instruction relevant by computer program has come, described program can be stored in a computer read/write memory medium, this program, when performing, can comprise the flow process of the embodiment as above-mentioned each side method.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (Random Access Memory, RAM) etc.
Above content is in conjunction with concrete preferred implementation further description made for the present invention, can not assert that specific embodiment of the invention is confined to these explanations.For general technical staff of the technical field of the invention, without departing from the inventive concept of the premise, some simple deduction or replace can also be made, all should be considered as belonging to protection scope of the present invention.