Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, is not intended to limit the present invention.
The embodiment of the present invention is obtained the document location of initial ranging by the time to be searched, and according to the timestamp corresponding with this document position, timestamp and the position relationship between the time to be searched that the last time obtains, to this document position proofreading and correct, until satisfy default condition, make be reduced search time, the precision of search is improved.
The embodiment of the present invention provides a kind of code stream geographic search method, and described method comprises the steps:
Obtain the preliminary election document location corresponding with the time to be searched and the timestamp corresponding with described preliminary election document location;
When the absolute value of the difference of described timestamp and described time to be searched during greater than default error amount, further according to the number of times of the timestamp that obtains, described timestamp and the last timestamp that obtains and the position relationship of described time to be searched, described preliminary election document location is carried out correction calculation, obtaining new document location, and the number of times proofreaied and correct of record;
When and described number of corrections not identical with described preliminary election document location do not have to surpass default number of times when described new document location, upgrading described preliminary election document location was described new document location;
Obtain the timestamp corresponding with described new document location, whether rejudge the absolute value of difference of described timestamp and described time to be searched greater than default error amount, until satisfy default condition, withdraw from this search.
The embodiment of the present invention also provides a kind of code stream geographic search device, and described device comprises:
Acquiring unit is used for obtaining the preliminary election document location corresponding with the time to be searched and the timestamp corresponding with described preliminary election document location;
Correcting unit, be used for when the absolute value of the difference of described timestamp and described time to be searched during greater than the error amount preset, further according to the number of times of the timestamp that obtains, described timestamp and the last timestamp that obtains and the position relationship of described time to be searched, described preliminary election document location is carried out correction calculation, obtaining new document location, and the number of times proofreaied and correct of record;
Updating block, when not having to surpass default number of times for and described number of corrections not identical with described preliminary election document location when described new document location, upgrading described preliminary election document location is described new document location; And
Timestamp obtains and judging unit, be used for obtaining the timestamp corresponding with described new document location, and the absolute value of difference that rejudges described timestamp and described time to be searched until satisfy default condition, withdraws from this search whether greater than default error amount.
The embodiment of the present invention also provides a kind of player that comprises above-mentioned code stream geographic search device.
the embodiment of the present invention is obtained the document location of initial ranging by the time to be searched, and according to the timestamp corresponding with this document position, the timestamp that last time obtains and the position relationship between the time to be searched, this document location that searches is proofreaied and correct, until satisfy default condition, solved when utilizing existing code stream geographic search method to carry out geographic search to the code stream without concordance list, search time is long, the low problem of document location precision that searches, reduced search time used when fixed point is play, improved the precision of fixing a point to play required document location.
Below in conjunction with specific embodiment, specific implementation of the present invention is described in detail:
Embodiment one:
Fig. 2 shows the realization flow of the code stream geographic search method that first embodiment of the invention provides, and details are as follows:
In step S201, obtain the preliminary election document location corresponding with the time to be searched and the timestamp corresponding with this preliminary election document location.
In specific implementation process, utilize always size of known time to be searched, code stream T.T. and code stream, calculate preliminary election document location corresponding to time to be searched according to formula (1):
Pos=Tseek*Stotal/Ttotal;(1)
In formula (1), Tseek is the time to be searched, and Ttotal is code stream T.T., is also video code flow T.T., and Stotal is always size of code stream, is also always size of video code flow, the preliminary election document location that Pos obtains for estimation.
Further, code stream jumps to the Pos place, this document position that obtains, and finds near the timestamp in this document position, and the number of times of this code stream redirect equates with the number of times of acquisition time stamp.
In step S202, when the absolute value of the difference of this timestamp and this time to be searched during greater than the error amount preset, further according to number of times, this timestamp and the last timestamp that obtains of the timestamp that obtains and the position relationship of this time to be searched, this preliminary election document location is carried out correction calculation, obtaining new document location, and the number of times proofreaied and correct of record.
Wherein, this step S202 specifically comprises the following steps:
During greater than default error amount, continue to judge whether the number of times of the timestamp that obtains is 1 when the absolute value of the difference of judgement this timestamp and this time to be searched;
Greater than 1, and this timestamp utilizes linearity correction to calculate and obtains new document location when being positioned at the both sides of time to be searched with the last timestamp that obtains when this number of times;
When this number of times is 1, perhaps when this timestamp is positioned at the homonymy of time to be searched with the last timestamp that obtains, utilizes gamma correction to calculate and obtain new document location;
The number of times that record is proofreaied and correct.
Wherein, the both sides that this timestamp and the last timestamp that obtains are positioned at this time to be searched refer to this timestamp and the last timestamp that obtains one of them less than time to be searched or one of them greater than the time to be searched, and the homonymy that this timestamp and the last timestamp that obtains are positioned at the time to be searched refer to this timestamp and the last timestamp that obtains simultaneously greater than or simultaneously less than the time to be searched.
Shown in the following formula of this gamma correction formula (2):
Pos_new=Tseek*Pos/Tfound;(2)
Wherein, Pos_new is new document location, and Tseek is the time to be searched, and Pos for this ASCII stream file ASCII position that searches, is also the preliminary election document location, and Tfound is the timestamp corresponding with Pos.
Shown in the following formula of this linear correction equation (3):
Pos_new=((Tseek-Tfound)*Pos_old+(Tfound_old-Tseek)*Pos)/(Tfound_old-Tfound).(3)
Wherein, Pos_new is new document location, and Tseek is the time to be searched, Pos is the document location of this search, is also the preliminary election document location, and Tfound is the timestamp corresponding with Pos, Pos_old is the document location of last search, and Tfound_old is the timestamp corresponding with Pos_old.
In embodiments of the present invention, when the absolute value of the difference of this time stamp T found and this time T seek to be searched is less than or equal to default error amount, withdraw from search, the preliminary election document location Pos that obtain this moment is the ASCII stream file ASCII position corresponding with the time to be searched that utilizes this code stream geographic search method to obtain, thereby from this document position broadcast code flow file, to realize the synchronous broadcast of audio frequency and video.
In step S203, when and this number of corrections not identical with this preliminary election document location do not have to surpass default number of times when this new document location, more this preliminary election document location was this new document location.
In specific implementation process, when this new document location Pos_new is identical with this preliminary election document location Pos, withdraw from search; And when not identical, continue to judge whether this number of corrections surpasses default number of times, when this number of corrections has surpassed default number of times, also withdraw from search, otherwise more this preliminary election document location is this new document location, simultaneously, the document location that also last time is obtained is updated to the preliminary election document location, is specially Pos_old=Pos; Pos=Pos_new, herein, "=" expression assignment, in search procedure, the requirement that can consider search time and search precision presets error amount and the number of corrections of above-mentioned timestamp.
In step S204, obtain the timestamp corresponding with this new document location, whether rejudge the absolute value of difference of this timestamp and this time to be searched greater than default error amount, until satisfy the condition of presetting, withdraw from this search.
Wherein, this default condition refers to the absolute value of this timestamp and the difference of this time to be searched less than default error amount, and perhaps this new document location is identical with this preliminary election document location, and perhaps this number of corrections is over the number of times of presetting.
In specific implementation process, when obtaining the timestamp corresponding with this new document location, Tfound_old=Tfound ("=" expression assignment,), whether repeat to judge the absolute value of this timestamp and the difference of this time to be searched greater than the error amount of presetting, particularly, after obtaining the timestamp corresponding with this new document location, return to execution in step S202, withdraw from this search until satisfy condition.
in embodiments of the present invention, at first this code stream geographic search method utilizes the document location that simply calculates initial ranging, then according to the timestamp that finds in this document position, to this document position carrying out gamma correction, and when surrounding target time time that occurs finding shakes (this timestamp that finds is distributed in time both sides to be searched with the last timestamp that finds), think that gamma correction can't further play a role, adopt in this case the method for linearity correction to adjust document location, thereby reduced the consuming time of pinpoint broadcast, improved the precision that pinpoint is play.
Embodiment two:
Fig. 3 shows the realization flow of the code stream geographic search method that second embodiment of the invention provides, the process that realizes to illustrate this code stream geographic search method, and details are as follows:
In step S301, obtain the preliminary election document location corresponding with the time to be searched.
In step S302, this code stream is jumped to this position, record the number of times of this redirect, and obtain the timestamp corresponding with this preliminary election document location.
In specific implementation process, utilize always size of time to be searched, code stream T.T. and code stream, calculate preliminary election document location corresponding to time to be searched according to above-mentioned formula (1).
Further, jump to the Pos place, this document position that obtains, record the times N of this redirect or the number of times that record obtains the timestamp corresponding with document location, both are worth equally herein, find near the time stamp T found this document position.
In step S303, whether judge the absolute value of difference of this timestamp and this time to be searched greater than the error amount of presetting, no, execution in step S311 is, execution in step S304.
In specific implementation process, compare Tfound and Tseek, if both poor absolute values are when being less than or equal to default error amount, such as 2s, withdraw from search, thereby the preliminary election document location Pos that this obtains is the accurate ASCII stream file ASCII position that searches, otherwise continues to carry out subsequent step, wherein should set according to actual needs by default error amount.
In step S304, judge whether the number of times of this redirect is 1, be, execution in step S305; No, execution in step S306.
In specific implementation process, when the number of hops of record is 1, also during i.e. redirect for the first time, directly execution in step S305, if greater than 1 time, go to execution in step S306.
In step S305, utilize the gamma correction formula to obtain new document location.
This gamma correction formula is as shown in above-mentioned formula (2).
In step S306, judge whether this timestamp and the last timestamp that obtains are positioned at the homonymy of time to be searched, are, return to step S305, no, execution in step S307.
Wherein, the not homonymy (both sides) that is positioned at time T seek to be searched as this time stamp T found and the last time stamp T found_old that obtains refer to this timestamp and the last timestamp that obtains one of them less than the time to be searched or one of them is greater than the time to be searched, i.e. (Tfound<Tseek<Tfound_old) or (Tfound_old<Tseek<Tfound), utilize linear formula to proofread and correct this moment, obtain new document location Pos_new, and preservation Tfound, Pos are Tfound_old, Pos_old;
The homonymy that is positioned at the time to be searched when this timestamp and the last timestamp that obtains refer to this timestamp and the last timestamp that obtains simultaneously greater than or simultaneously less than time to be searched, i.e. (Tfound<Tseek﹠amp; ﹠amp; Tfound_old<Tseek) or (Tseek<Tfound_old﹠amp; ﹠amp; Tseek<Tfound), utilize the gamma correction formula to proofread and correct this moment recomputate new document location Pos_new, and preservation Tfound, Pos is Tfound_old, Pos_old.
In step S307, utilize linear correction equation to upgrade this position, and execution in step S208.
This linear correction equation such as above-mentioned formula (3) institute.
In step S308, judge whether this new document location is identical with the preliminary election document location, is, execution in step S311, no, execution in step S309.
In specific implementation process, judge whether Pos_new equates with Pos, if equate, withdraw from this search procedure, otherwise continue execution in step S309.
In step S309, judge whether this number of corrections surpasses default number of times, be that execution in step S311, no, execution in step S310.
Particularly, when the Pos_new that obtains is not identical with Pos, further judge this number of corrections, namely whether cycle index surpasses default number of times, such as default number of times is 30 times.
In step S310, upgrading the preliminary election document location is new document location, and returns to step S302.
Specifically the content of renewal is, Pos_old=Pos; Pos=Pos_new, thus after execution in step S302, obtain the time stamp T found corresponding with this new document location, be also Tfound_old=Tfound, continue to carry out subsequent step, withdraw from this search until satisfy condition, herein, "=" expression assignment.
In step S311, withdraw from search.
In embodiments of the present invention, take without the rmvb video code flow of concordance list as example, the searching method that the existing searching method of mentioning in the contrast background technology and the embodiment of the present invention are mentioned, come by experiment advantage more of the present invention, wherein, the method, the absolute value of setting time to be searched and the difference of the timestamp that obtains is no more than default error range 2s, and default number of corrections is 30 times.Concrete outcome such as following table one are depicted as the Search Results of prior art scheme or searching method, and following table two is depicted as the result of the geographic search method search of embodiment of the present invention proposition.
Table one
Table two
From error result, the search plan that the embodiment of the present invention proposes, Search Results (shown in table one) is all in the error range of setting, and the error of prior art scheme has 19 times to have surpassed error range, and search precision can't ensure; Consuming time from number of corrections and search, the search plan (shown in table two) that the embodiment of the present invention proposes, number of corrections is few, searches for consuming time short, the number of corrections of prior art scheme has and has all reached the upper limit of setting for 19 times, and searching for consuming time is approximately 5 times of search plan of the present invention.Compare with the technical scheme of existing searching method, the code stream geographic search method search that the embodiment of the present invention proposes is consuming time obviously to be reduced, and search precision significantly improves.
In embodiments of the present invention, this code stream geographic search method can be applied in the geographic search of all digital code streams without concordance list (as music, video etc.), the convergence computing that constantly approaches has been carried out in linearity correction when utilizing the concussion of the gamma correction of time feedbacking and time of occurrence to document location, the file redirect by less number of times obtains accurate search time.Simultaneously, in the method, can consider the requirement of searching for consuming time and search precision, error range and the number of corrections upper limit are set.Can find out from experimental result, the scheme search that the embodiment of the present invention proposes is consuming time obviously to be reduced, and search precision significantly improves, and has the characteristics simple, that system overhead is lower.
One of ordinary skill in the art will appreciate that all or part of step that realizes in above-described embodiment method is to come the relevant hardware of instruction to complete by program, the program of being somebody's turn to do can be stored in a computer read/write memory medium, the storage medium that is somebody's turn to do is as ROM/RAM, disk, CD etc.
Embodiment three:
Fig. 4 shows the structure of the code stream geographic search device that third embodiment of the invention provides, and for convenience of explanation, only shows the part relevant to the embodiment of the present invention.
This code stream geographic search device can be used for player, it can be also the software unit that runs in player, also can be used as independently, suspension member is integrated in player or runs in the application system of player, this code stream geographic search device comprises that acquiring unit 41, correcting unit 42, updating block 43 and timestamp obtain and judge 44, wherein:
Acquiring unit 41 is used for obtaining the preliminary election document location corresponding with the time to be searched and the timestamp corresponding with this preliminary election document location.
In embodiments of the present invention, utilize always size of known time to be searched, code stream T.T. and code stream, calculate preliminary election document location corresponding to time to be searched according to above-mentioned formula (1), and further, code stream jumps to this document position that obtains, find near the timestamp in this document position, the number of times of this code stream redirect equates with the number of times of acquisition time stamp.
Correcting unit 42 is used for when the absolute value of this timestamp and the difference of this time to be searched during greater than the error amount preset, further according to number of times, this timestamp and the last timestamp that obtains of the timestamp that obtains and the position relationship of this time to be searched, this preliminary election document location is carried out correction calculation, obtaining new document location, and the number of times proofreaied and correct of record.
Wherein, this correcting unit 42 specifically comprises number of times judging unit 421, linearity correction unit 422, non-linear correction unit 423 and number of corrections record cell 424, as shown in Figure 5, and wherein:
Number of times judging unit 421 is used for when the absolute value of this timestamp of judgement and the difference of this time to be searched during greater than default error amount, and continuation judges whether the number of times of the timestamp that obtains is 1;
Linearity correction unit 422 be used for when these number of times judging unit 421 Output rusults be no, and this timestamp utilizes linearity correction to calculate and obtains new document location when being positioned at the both sides of time to be searched with the last timestamp that obtains;
It is yes that non-linear correction unit 423 is used for working as these number of times judging unit 421 Output rusults, perhaps when this timestamp is positioned at the homonymy of time to be searched with the last timestamp that obtains, utilizes gamma correction to calculate and obtains new document location; And
Number of corrections record cell 424 is used for the number of times that record is proofreaied and correct.
Wherein, the both sides that this timestamp and the last timestamp that obtains are positioned at the time to be searched refer to this timestamp and the last timestamp that obtains one of them less than time to be searched or one of them greater than the time to be searched, and the homonymy that this timestamp and the last timestamp that obtains are positioned at the time to be searched refer to this timestamp and the last timestamp that obtains simultaneously greater than or simultaneously less than the time to be searched.
This gamma correction formula is as shown in above-mentioned formula (2), also namely:
Pos_new=Tseek*Pos/Tfound;(2)
Wherein, Pos_new is new document location, and Tseek is the time to be searched, and Pos for this ASCII stream file ASCII position that searches, is also the preliminary election document location, and Tfound is the timestamp corresponding with Pos.
This linear correction equation is as shown in above-mentioned formula (3), also namely:
Pos_new=((Tseek-Tfound)*Pos_old+(Tfound_old-Tseek)*Pos)/(Tfound_old-Tfound).(3)
Wherein, Pos_new is new document location, and Tseek is the time to be searched, Pos is the document location of this search, Tfound is the timestamp corresponding with Pos, and Pos_old is the document location of last search, and Tfound_old is the timestamp corresponding with Pos_old.
In embodiments of the present invention, when the absolute value of the difference of this time stamp T found and this time T seek to be searched is less than or equal to default error amount, withdraw from search, the preliminary election document location Pos that obtain this moment is the ASCII stream file ASCII position corresponding with the time to be searched that utilizes this code stream geographic search method to obtain, thereby from this document position broadcast code flow file, to realize the synchronous broadcast of audio frequency and video.
Updating block 43 be used for not identical with this preliminary election document location when this new document location and this number of corrections when not having over the number of times preset, upgrading this preliminary election document location is this new document location.
In specific implementation process, when this new document location Pos_new is identical with this preliminary election document location Pos, withdraw from search; And when not identical, continue to judge whether this number of corrections surpasses default number of times, when this number of corrections has surpassed default number of times, also withdraw from search, otherwise more this preliminary election document location is this new document location, simultaneously, the document location that also last time is obtained is updated to the preliminary election document location, is specially Pos_old=Pos; Pos=Pos_new, herein, "=" expression assignment, in search procedure, the requirement that can consider search time and search precision presets error amount and the number of corrections of above-mentioned timestamp.
Timestamp obtains and judging unit 44 is used for obtaining the timestamp corresponding with this new document location, and whether the absolute value that rejudges this timestamp and the difference of this time to be searched until satisfy the condition preset, withdraws from this search greater than default error amount.
Wherein, this default condition refers to the absolute value of this timestamp and the difference of this time to be searched less than default error amount, and perhaps this new document location is identical with this preliminary election document location, and perhaps this number of corrections is over the number of times of presetting.And when obtaining the timestamp corresponding with this new document location, Tfound_old=Tfound, repeat to judge that whether the absolute value of this timestamp and the difference of this time to be searched is greater than the error amount of presetting, particularly, after obtaining the timestamp corresponding with this new document location, whether rejudge the absolute value of difference of this timestamp and this time to be searched less than the error amount of presetting, withdraw from this search until satisfy condition.
In embodiments of the present invention, this code stream geographic search device also comprises:
Timestamp number of times acquiring unit is used for the number of times that record obtains the timestamp corresponding with document location.
This timestamp number of times acquiring unit is used in judgement when the absolute value of this timestamp and the difference of this time to be searched during greater than the error amount preset, record obtains the number of times of the timestamp corresponding with document location, thereby further selects the preliminary election document location is carried out linearity or gamma correction calculating.
In embodiments of the present invention, a kind of code stream geographic search device that comprises that acquiring unit, correcting unit, updating block and timestamp obtain and judge is provided, by constantly the document location that searches being proofreaied and correct, until satisfy default condition, finally can get the ASCII stream file ASCII position that effectively have degree of precision corresponding with the time to be searched.
the embodiment of the present invention is by obtaining the preliminary election document location corresponding with the time to be searched and the timestamp corresponding with it, when the absolute value of the difference of this timestamp and this time to be searched during greater than the error amount preset, this preliminary election document location is carried out correction calculation, to obtain new document location, and the number of times of record correction, when and this number of corrections not identical with this preliminary election document location do not have to surpass default number of times when this new document location, upgrading this preliminary election document location is this new document location, and obtain the timestamp corresponding with this new document location, whether rejudge the absolute value of difference of this timestamp and this time to be searched greater than the error amount of presetting, until satisfy default condition, withdraw from this search, realized when the code stream without concordance list is carried out geographic search, shorten search time, the purpose that the document location precision that searches improves.
The above is only preferred embodiment of the present invention, not in order to limiting the present invention, all any modifications of doing within the spirit and principles in the present invention, is equal to and replaces and improvement etc., within all should being included in protection scope of the present invention.