Summary of the invention
The embodiment of the invention provides a kind of method for estimating, device and multimedia processor, in order to reduce taking of the required capacity register of estimation.
For solving the problems of the technologies described above, the embodiment of the invention provides following technical scheme:
A kind of method for estimating, the system of described estimation comprises buffer, search matching unit and data updating unit, it is characterized in that described method comprises:
According to the data of the current macro of preserving in the described buffer and the data of current macro search window, when current macro being searched for coupling by described search matching unit, described data updating unit obtain described next macro block search window last row macro block data and store in the described buffer, described next macro block and current macro are arranged in the same delegation of present frame;
Wherein: described current macro search window or next macro block search window comprise the capable w row of a h macro block, described h and w are respectively the odd number more than or equal to 3, and the data of the capable w-1 row of the back h macro block in the data of the data of described last row macro block and current macro search window are formed the data of next macro block search window; Wherein:
Described buffer comprises w+1 second memory space, and the data of described current macro search window are kept on described w+1 second memory space of the w in second memory space, and each second memory space is used to preserve the data of the capable 1 row macro block of h;
There is one second memory space of the data that are not used to preserve the current macro search window in described w+1 second memory space in the data of last row macro block of described next macro block search window.
Described buffer comprises two first memory spaces, and wherein: the data of described current macro and the data of next macro block are kept at respectively on one of them first memory space.
When described current macro was first macro block of every row in the present frame, described method also comprised:
The data of described first macro block are saved on first memory space of buffer;
The data of each row macro block of described first macro block search window are saved in respectively on described w second memory space; And
According to the data of the current macro of preserving in described first memory space, and the data of the search window of preserving in individual second memory space of described w, current macro is searched for coupling.
A kind of movement estimation apparatus comprises:
Internal memory is used to store the data of each the row macro block of present frame that carries out estimation and the data of each row macro block of reference frame;
Buffer is used for the required data of cache search coupling;
The search matching unit is used for the data of the current macro of preserving according to buffer and the data of current macro search window, and current macro is searched for coupling;
Data updating unit, be used for when current macro is carried out estimation, obtain described next macro block search window last row macro block data and be saved in the described buffer, described next macro block and current macro are arranged in the same delegation of present frame, wherein:
Described search window comprises the capable w row of a h macro block, and described h and w are respectively the odd number more than or equal to 3, and described buffer comprises one first memory space and w second memory space, wherein:
Described first memory space is used to preserve the data of a macro block or the data of current macro;
The data that are used to preserve search window in described w second memory space, each second memory space are used for preserving the data of 1 row macro block of search window.
Further, if described current macro is first macro block of each row in the present frame, then in the data of described current macro search window of preserving in according to buffer and the data of current macro, current macro is searched for before the coupling, described method also comprises:
Obtain the data of described first macro block and be saved in two first memory spaces one, and the data of each row macro block that obtain the search window of described first macro block, and be kept on described w+1 second memory space of the w in second memory space.
Preferable, described w+1 the second memory space sequential addressing, in the capable w row of the h of first macro block search window of each row of the described present frame macro block, the data of the macro block since first row to the w row are kept on first to w individual second memory space according to the correspondence that puts in order of column.
A kind of movement estimation apparatus comprises the internal memory of the data that are used to store each row data of macro block of present frame of carrying out estimation and each row macro block of reference frame; Also comprise:
Buffer is used for the required data of cache search coupling;
Data updating unit, the Data Update that is used for a last macro block that buffer is preserved is the data of current macro, a described current macro and a last macro block are arranged in the same delegation of present frame; And be the data of last row macro block of current macro search window with the Data Update of a last macro block search window first row macro block in the buffer;
The search matching unit is used for the data according to described current macro, and the data of described search window, and current macro is searched for coupling wherein:
Described current macro search window or next macro block search window comprise the capable w row of a h macro block, described h and w are respectively the odd number more than or equal to 3, the data of the capable w-1 row of the back h macro block in the data of the data of described last row macro block and current macro search window are formed the data of next macro block search window, wherein:
Described buffer comprises w+1 second memory space, and the data of described current macro search window are kept on described w+1 second memory space of the w in second memory space, and each second memory space is used to preserve the data of the capable 1 row macro block of h;
There is one second memory space of the data that are not used to preserve the current macro search window in described w+1 second memory space in the data of last row macro block of described next macro block search window.
Described data updating unit also is used for: when being first macro block of each row of present frame as if described current macro, the then data of the current macro search window of preserving in according to buffer at described search matching unit and the data of current macro, current macro is searched for before the coupling, obtain the data of described first macro block and be saved in two first memory spaces one, and the data of each row macro block that obtain the search window of described first macro block, and be kept on described w+1 second memory space of the w in second memory space.
Preferable, described device also comprises:
First register is used to preserve the mode bit of described search matching unit;
Second register is used to preserve the mode bit of described data updating unit;
Synchronous control unit, be used for by described first register and second register, search matching unit and data updating unit are carried out Synchronization Control, wherein: it is idle condition that described search matching unit is finished after the search coupling of current macro the state position in described first register, after described data updating unit is finished next macro block and searched for the storage of coupling desired data is idle condition with the state position in described second register, described search matching unit of synchronous triggering and data updating unit when described synchronous control unit all is changed to idle condition at the mode bit of first register and second register.
Because in the technical scheme that the embodiment of the invention provides, when the data space of search window is set, for the data of each the row macro block in the data of search window are provided with independently memory space, and when the data of the search window of the coupling of new search more, only upgrade the data of a row macro block that changes after search window moves, thereby the data of search window have been compressed to minimum to taking of capacity register, reduced the volume of buffer, and because a wherein columns certificate is only upgraded in Data Update operation each time, thereby guaranteed the operation estimation performance;
Further in the another kind of execution mode that the embodiment of the invention provides, utilize the redundant storage space to realize in the search coupling, finishing the Data Update operation, thereby on the basis that increases very little memory space cost, further improved the performance of estimation.
Embodiment
As shown in Figure 2, be that unit is divided into that C is capable, the L row with the macro block with each two field picture, every frame comprises C * L macro block, and search window comprises the capable w row of h macro block, and wherein h and w are the odd number more than or equal to 3.Search window as shown in Figure 3 moves schematic diagram, solid line represents that coordinate is [1 in the present frame, the position view of search window in reference frame when macro block 1] is current macro, dotted line represents that coordinate is [1 in the present frame, the position view of search window in reference frame when macro block 2] is current macro, if with the data definition of each the row macro block in the search window is a data block, can see, search window moves order with behavior and whenever moves once, in the data of the search window of adjacent two macro blocks, the data of last row macro block of search window after moving are different with the data that move the preceding search window first row macro block, the data of other row macro block are identical, if therefore be the data that unit upgrades search window with the data block, for adjacent two macro blocks with delegation, each only need be on the data basis of last macro block search window, last row that first row of the data of last macro block search window are updated to the data of back one macro block search window can form the data of the search window of next macro block.
Based on above-mentioned analysis, in first kind of better embodiment that the embodiment of the invention provides, the buffer of cache search coupling desired data need comprise:
First memory space is used to store the data of the current macro of searching for coupling, and size is set to store the data volume of a macro block;
W second memory space is used to store the data of the search window of current macro, wherein, the data of the row macro block in the memory search window respectively on each second memory space, size is set to store the data volume of h * 1 macro block.
Design according to the buffer memory space in this first kind of execution mode, estimation with delegation's macro block is an example, when first macro block is current macro, obtain the data of this first macro block and preserve first memory space from internal memory, obtain this first macro block search window data and be saved in w second memory space, first macro block is searched for coupling, after the search coupling finishes, with second macro block is current macro, with the Data Update in first memory space is the data of second macro block, and the data in one of them second memory space are upgraded, the data block that shifts out search window is updated to the data block that moves into search window, promptly on second memory space of correspondence, with the Data Update of the first row macro block of first macro block search window is the data of last row macro block of second macro block search window, searches for coupling then, and the like, after the search coupling of this last macro block of row finishes, continue the search coupling of each macro block of next line.
For further improving the speed of estimation, the embodiment of the invention also provides second kind of better embodiment, and in this second kind of execution mode, the buffer of buffer memory estimation desired data need comprise:
Two first memory spaces, the size setting of each first memory space can be stored the data volume of a macro block;
W+1 second memory space, the size of each second memory space are set to the data volume of the data block of the row macro block in can the memory search window.
Design according to the buffer memory space in this second kind of execution mode, first memory space and second memory space have a redundant storage space respectively, utilize the redundant storage space when current macro is searched for coupling, to finish renewal operation with delegation's next macro block search coupling desired data.Specifically with a behavior example, for first macro block, obtain the data of this first macro block and preserve one of them first memory space from internal memory, obtain this first macro block search window data and be saved in w second memory space, when starting current macro search coupling, carry out second Data Update operation that macro block search coupling is required, Data Update operation specifically comprises: obtain the data of second macro block and be saved in another first memory space from internal memory, the data of last row macro block after search window moved are saved on w one second memory space beyond second memory space, and the data of the back w-1 row macro block of the data of the data of this last row macro block and first macro block search window are formed the data of the search window of second macro block.After the Data Update of the search of first macro block coupling and second macro block is all finished, start the search coupling of second macro block and the renewal operation of the 3rd macro block search coupling desired data simultaneously, and the like, search coupling until this last macro block of row finishes, carry out the search coupling of next line macro block in the present frame again, in this course, the redundant storage space is dynamic change, can carry out sequential addressing to first memory space and second memory space respectively, to make things convenient for the addressing control of the memory space in the data updating process.
According to second kind of better embodiment, those skilled in the art as can be known, when current macro is searched for coupling, upgrade the data of search window, between twice search coupling, upgrade the data of current macro, so only need one first memory space just passable.
Need to prove, when needs are expanded reference frame, position according to macro block, the data that comprise the relevant macro block from the reference frame that internal memory obtains in the data of search window, the data that also may comprise the edged macro block of generation, the generation method of the data of concrete extended method and edged macro block is known for those skilled in the art, no longer describes in detail here.
Clearer for the purpose, technical scheme and the beneficial effect that make the embodiment of the invention, further describe the present invention with specific embodiment.In the following description, the reference frame of present frame all is meant and has carried out the reference frame after the border extension, in the description process, has saved the description of relevant edged operation.
Read order with behavior among the embodiment provided by the invention each macro block in the present frame is carried out estimation, promptly the first row macro block is searched for coupling from present frame, and redirect is searched for coupling to the macro block of each row successively then.Corresponding each need search for the current macro of coupling, the search window that needs is for being the piece of a h * w size at center with the current macro position in reference frame.For example the upper left shaded block of Fig. 2 is represented when h=w=3, and current macro [0,0] is searched for the expanded search window in coupling time, the expanded search window when upper right shaded block represents that current macro [1, L-2] searched for coupling.
As shown in Figure 4, the method for estimating schematic flow sheet of first kind of memory space design of this employing mainly comprises the steps:
Step S401, search window size h * w as required is identified for storing the memory space that carries out the estimation desired data and comprises:
One first memory space n
0, being used to store the data of the current macro of searching for coupling, the size of first memory space can be stored the data of a macro block;
W the second memory space m
0To m
W-1, the row macro block on each second memory space in the difference memory search window, size can be stored the data of h * 1 macro block;
Step S402, on buffer, dispose one first memory space and w second memory space respectively;
As shown in Figure 5, n
0Size be set to 1 macro block, the size of each second memory space is set to h * 1 macro block, adopting size in the embodiment of the invention is 16 * 16 macro block, the size of each piece also can also be 8 * 8,4 * 4 etc.
The embodiment of the invention is the memory space addressing that makes things convenient in the data updating process, further the address information with w second memory space of the data of search window is expressed as a circular linked list, with w the second memory space number consecutively is 0~w-1, in this circular linked list, the circulation storage mode is adopted in the storage of data block.Owing to adopt continuation address on this circular linked list structure, can realize the circulation memory function by modular arithmetic, the numbering i of second memory space is on the buffer in this circular linked list:
i=jmod(w)(1)
Wherein j is the row coordinate of each macro block in reference frame in the data block that needs visit.
The data space of step S403, initialization search window;
First macro block of each row is searched for before the coupling, all needed the data of memory space storage are carried out initialization, specifically comprise: the data that read first macro block from internal memory are saved in the first memory space n
0In, each the data block correspondence in the data of the search window of first macro block is saved in m
0To m
W-1Amount in w second memory space;
Step S404, current macro is searched for coupling;
Step S405, judge whether current macro is last macro block of current line,, otherwise return the search coupling that step S404 proceeds the next macro block of current line after going to data in the step S409 updated stored space if then go to step S406;
Data in the updated stored space specifically comprise: read the data of next macro block and be saved in the first memory space n from reference frame
0In, get the data block that next size is 1 * h with the behavior sequential read, put into the remaining m of circular linked list
0In individual second memory space, form the data of the search window of next macro block with data blocks stored on w-1 second memory space of back;
Step S406, judge whether current macro is last macro block of present frame, if execution in step S407 then, otherwise execution in step S408 continues the search coupling of each macro block of next line;
The estimation of step S407, end present frame.
Among the embodiment provided by the invention, can judge last macro block of current line or present frame according to the coordinate of current macro.Present embodiment is not the execution sequence that strictness defines step S405~S406 yet, and those skilled in the art can adjust fully flexibly.
As shown in Figure 6, according to second kind of memory space design, second kind of method for estimating that the embodiment of the invention provides mainly comprises the steps:
Step S601, search window size h * w as required is identified for storing the memory space of searching for the coupling desired data, comprising:
Two first memory spaces, the size of each first memory space can be stored the data of a macro block;
The data of w+1 second memory space, the size of each the second memory space row macro block in can the memory search window, the i.e. data volume of h * 1 macro block;
Step S602 on buffer, disposes two first memory spaces and w+1 second memory space respectively;
As shown in Figure 7, the size of each first memory space is set to 1 macro block, one of them n
0Be used to preserve the data of current macro, another n
1Be used to preserve the data of adjacent next macro block, perhaps n
1Be used to preserve the data of current macro, n
0Be used to preserve the data of adjacent next macro block; In this w+1 second memory space, wherein w second memory space is used for preserving the data of the search window of current macro, the result of search coupling finds best match block from the data of search window, one second remaining memory space is used for preserving newly-increased in a next macro block search window data block.The employing size is 16 * 16 macro block in the embodiment of the invention, and those skilled in the art can implement technical scheme provided by the invention when the size of piece is 8 * 8,4 * 4 grades as can be known equally.
The embodiment of the invention is the memory space addressing that makes things convenient in the memory space data updating process, further the address information of w+1 second memory space of the data of search window is expressed as a circular linked list as shown in Figure 8, with w+1 the second memory space number consecutively is 0~w, in this circular linked list, the circulation storage mode is adopted in the storage of data block.Owing to adopt continuation address on this circular linked list structure, can realize the circulation memory function by modular arithmetic, the numbering i of second memory space is on the buffer in this circular linked list:
i=jmod(w+1)(2)
Wherein j is the row coordinate of each macro block in reference frame in the data block that needs visit, each current macro is searched for data occupancy w second memory space wherein of the search window of coupling, the data of the row macro block that search window increased when remaining another one second memory space was used for depositing in advance and is used for next macro block and searches for coupling.
First memory space also can adopt similar fashion, and those skilled in the art can conveniently realize, be not described in detail here.
The data space of step S603, initialization search window;
First macro block of each row is searched for before the coupling, all needed the data of memory space storage are carried out initialization, specifically comprise: the data that read first macro block from internal memory are saved in the first memory space n
0In, with each the data block m in the data of the search window of first macro block
0To m
W-1Amounting to w correspondence is saved in second memory space;
Step S6041-S6042, startup search matching unit are searched for coupling to current macro, read the data of next macro block and are saved in the first memory space n from reference frame simultaneously
1In, get the data block that next size is h * 1 with the behavior sequential read, put into the remaining m of circular linked list
wIn individual second memory space, form the data of the search window of next macro block with data blocks stored on front w-1 second memory space;
Step S605, judge that whether current macro is last macro block of current line, if then go to step S606, otherwise returns step S6041 and S6042;
Step S606, judge whether current macro is last macro block of present frame, if execution in step S607 then, otherwise execution in step S608 proceeds the search coupling of each macro block of next line;
The estimation of step S607, end present frame.
As Fig. 9 and shown in Figure 10, a kind of movement estimation apparatus for the embodiment of the invention provides comprises:
Internal memory 901 is used to store the data of each row macro block of present frame of searching for coupling and the data of each row macro block of reference frame;
Buffer 902 is used for the data that cache search mates needs;
Search matching unit 903 is used for according to the buffer data in buffer current macro being searched for coupling;
Data updating unit 904 is used for the data in search matching process renewal buffer.
Referring to shown in Figure 9, buffer 902 connects search matching unit 903 and data updating unit 904 respectively by data wire, connects by system bus between internal memory 901, search matching unit 903 and the data updating unit 904; In this by way of example, data updating unit 904 takies system bus bandwidth during from internal memory 901 reading of data;
Referring to shown in Figure 10, buffer 902 connects search matching unit 903 and data updating unit 904 respectively by data wire, search matching unit 903 connects internal memory 901 by independent bus line, and internal memory 901, search matching unit 903 also are connected by system bus respectively with data updating unit 904; In this by way of example, data updating unit 904 utilizes independent bus line to carry out transfer of data during from internal memory 901 reading of data, does not need to take system bus bandwidth;
According to two kinds of estimation modes that the embodiment of the invention provides, buffer 902 correspondences can be provided with first memory space and second memory space of varying number, cooperate the search coupling of finishing each macro block between search matching unit 903 and the data updating unit 904.
Wherein: when adopting first kind of method for estimating, the memory space that is provided with on the buffer 902 specifically comprises:
One first memory space n
0, being used to store the data of the current macro of searching for coupling, the size of first memory space can be stored the data of a macro block;
W the second memory space m
0To m
W-1, the row macro block on each second memory space in the difference memory search window, size can be stored the data of h * 1 macro block;
Search matching unit 903 is finished current macro search coupling back trigger data updating block 904 and is carried out the Data Update operation, and data updating unit 904 is finished Data Update operation back and triggered search matching unit 903 and search for coupling.
Still referring to as Fig. 9 and shown in Figure 10, can also utilize the independently cooperation between synchronous control unit 905, first register 9061 and second register, 9062 coordination search matching units 903 and the data updating unit 904, first register 9061 is used to preserve the mode bit of search matching unit 903, second register 9062 is used to preserve the mode bit of data updating unit 904, and concrete operation principle is:
Synchronous control unit 905 trigger data updating blocks 904 carry out Data Update operation, and second register 9062 are changed to busy, for example use 1 bit, and it is busy to put 1 o'clock sign, and it is idle to put 0 o'clock sign, and monitors second register 9062;
Data updating unit 904 is changed to the free time with second register 9062 after finishing Data Update;
Synchronous control unit 905 monitors after second register 9062 is changed to the free time, trigger 903 pairs of current macro of search matching unit and search for coupling, and be changed to first register 9061 busy, equally for example use 1 bit, it is busy to put 1 o'clock sign, it is idle to put 0 o'clock sign, and monitors first register 9061;
Search for and after matching unit 903 is finished the search coupling of current macro first register 9061 is changed to the free time;
Synchronous control unit 905 monitors after first register 9061 is changed to the free time, and trigger data updating block 904 carries out the Data Update operation once more, and the like, up to the search coupling of finishing all macro blocks.
When adopting second kind of method for estimating, the memory space that is provided with on the buffer 902 specifically comprises:
Two first memory spaces, the size of each first memory space can be stored the data of a macro block;
The data volume of the data of w+1 second memory space, the size of each the second memory space row macro block in can the memory search window, the i.e. data volume of h * 1 macro block;
Coordinate to finish the search coupling of current macro and the Data Update of next macro block between search matching unit 903 and the data updating unit 904, preferable, still utilize the independently cooperation between synchronous control unit 905, first register 9061 and second register, 9062 coordination search matching units 903 and the data updating unit 904, first register 9061 is used to preserve the mode bit of search matching unit 903, second register 9062 is used to preserve the mode bit of data updating unit 904, and concrete operation principle is:
Synchronous control unit 905 triggers search matching unit 903 and searches for coupling, and trigger data updating block 904 carries out the Data Update operation simultaneously, and all is changed to first register 9061 and second register 9062 busy;
Search for and after matching unit 903 is finished the search coupling of current macro first register 9061 is changed to the free time, data updating unit 904 is changed to the free time with second register 9062 after finishing Data Update;
Synchronous control unit 905 monitors after first register 9061 and second register 9062 all be changed to the free time, triggers search matching unit 903 and data updating unit 904 once more simultaneously, and the like, up to the search coupling of finishing all macro blocks.
Because in the data updating process, the data of search window comprise the real data in the reference frame, may also comprise the data of edged macro block, therefore, data updating unit 904 further comprises:
The data read subelement is used for reading the data of search window reference frame macro block and being saved in the first corresponding memory space from internal memory;
Edged is handled subelement, is used for generating the data of the data edged macro block of search window, and is saved in the first corresponding memory space.
To those skilled in the art, can in coded system or multimedia system, realize the relevant control of estimation fully according to the disclosed content of the embodiment of the invention, and it is apparent, the function of synchronous control unit 905 can be born by search matching unit 903 or data updating unit 904, is perhaps born by the processor in coded system or the multimedia system.
The technical scheme that provides according to the embodiment of the invention, when the data space of search window is set, for the data of each the row macro block in the data of search window are provided with independently memory space, and when the data of the search window of upgrading estimation, only upgrade the data of a row macro block that changes after search window moves, thereby the data of search window have been compressed to minimum to taking of capacity register, reduced the volume of buffer, and because the wherein data of a row macro block are only upgraded in Data Update operation each time, thereby guaranteed the operation estimation performance;
Further in the another kind of execution mode that the embodiment of the invention provides, utilize the redundant storage space to realize in the search coupling, finishing the Data Update operation, thereby on the basis that increases very little memory space, the performance of estimation is further improved.
In the embodiment of the invention, preferable, when the search matching unit that provides when the embodiment of the invention is used for coded system or multimedia processing system, the function of data updating unit and search matching unit can be born by the processor in coded system or the multimedia processing system, can save the area of hardware cell in whole coded system or the multimedia processing system like this.But preferable, buffer is the Cache module, and data updating unit adopts DMA, is independent of the processor in the system, can reduce taking of system processor resource, further promotes the coding efficiency of whole system.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification interior.