Embodiment
In order to make object of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated, for convenience of explanation, only show the part relevant to the embodiment of the present invention.Should be appreciated that the specific embodiment that this place is described, only for explaining the present invention, not in order to limit the present invention.
The present invention proposes a kind of inter-frame prediction method of new P frame.The method is by determining the relation of current reference frame and current encoded frame, zooms out respectively or the mode that furthers is carried out upper and lower sampling processing according to camera lens, improved the similarity of current reference frame and coded frame, thereby reached the compression effectiveness of optimization current encoded frame.In the time of low frame per second, the shot change between frame and frame is larger, now adopts frame Forecasting Methodology of the present invention, and the lifting of compression performance will be more remarkable.
Embodiment 1, referring to Fig. 1, the method is mainly used in the prediction of P frame, is specially:
Step 101: the relation of determining the first reference frame and current encoded frame; Namely determine i reference frame refiwith the relation of current encoded frame frame, select different P frame Forecasting Methodologies; If furthering, camera lens performs step 102; If zooming out, camera lens performs step 103; If do not exist camera lens further or zoom out, the first reference frame is that current reference frame performs step 104;
If (camera lens draws in) enters step 102;
Else if (camera lens pushes away far) enters step 103;
Else curr_refi=refi, enter 104;
Namely i reference frame ref of the first reference frame described hereini; Curr_refifor the current reference frame after upgrading;
Step 102: the first reference frame is processed if camera lens furthers, obtained the second reference frame, and current reference frame is set to the second reference frame; Enter step 104;
This step method is specially: to reficarry out up-sampling, obtain new reference frame the second reference frame refi'; Curr_refi=refi';
Step 103: if camera lens zooms out, the first reference frame is processed, obtained the 4th reference frame, and current reference frame is set to the 4th reference frame; Enter step 104;
This step method is specially: to reficarry out down-sampling, obtain new reference frame the 4th reference frame refi" ', curr_refi=refi" ';
Step 104: adopt current reference frame to carry out inter prediction to current encoded frame.
The method is by determining the relation of current reference frame and current encoded frame, zooms out respectively or the mode that furthers is carried out upper and lower sampling processing according to camera lens, improved the similarity of current reference frame and coded frame, thereby reached the compression effectiveness of optimization current encoded frame.In the time of low frame per second, the shot change between frame and frame is larger, now adopts frame Forecasting Methodology of the present invention, and the lifting of compression performance will be more remarkable.
Embodiment 2, referring to Fig. 2, the method for the present invention is mainly used in the prediction of P frame, is specially:
Step 201: the relation of determining the first reference frame and current encoded frame; If furthering, camera lens performs step 202; If zooming out, camera lens performs step 203; If do not exist camera lens further or zoom out, the first reference frame is that current reference frame performs step 204;
If (camera lens draws in) enters step 202;
Else if (camera lens pushes away far) enters step 203;
Else curr_refi=refi, enter 204;
Namely i reference frame ref of the first reference frame described hereini; Curr_refifor the current reference frame after upgrading;
Step 202: the first reference frame is processed if camera lens furthers, obtained the second reference frame, and the second reference frame is processed, obtain the 3rd reference frame; Current encoded frame is set to the 3rd reference frame;
This step is specially:
Step 2021: to the first reference frame reficarry out up-sampling, obtain new reference frame the second reference frame refi';
Step 2022: to the second reference frame refi' carry out boundary pixel deletion, obtain the 3rd reference frame refi"; Thereby make the 3rd reference frame refi" with the first reference frame refithere is identical resolution.(the second reference frame has different resolution from the 3rd reference frame, and the 3rd reference frame carries out after boundary pixel is deleted obtaining to the second reference frame herein)
To the second reference frame refi' carry out boundary pixel delet method and be:
The 3rd reference frame refi" (m, n)=refi' (m+d_heifht', n+d_width')
Wherein o_width, o_height are reficolumns and line number, m_width', m_height' are refi' columns and line number, m, n are line label and the row label of reference frame pixel;
d_width'=(m_width'-o_width)/2,
d_height'=(m_height'-o_height)/2
Step 2023:curr_refi=refi"
Step 203: if camera lens zooms out, the first reference frame is processed, obtained the 4th reference frame, and the 4th reference frame is processed, obtain the 5th reference frame; And current reference frame is set to the 5th reference frame.
This step implementation method is specially:
Step 2031: to the first reference frame reficarry out down-sampling, obtain new reference frame the 4th reference frame refi" ';
Step 2032: to the 4th reference frame refi" ' carry out boundary pixel is filled expansion, obtains the 5th reference frame refi" ", thus make the 5th reference frame refi" ' with the first reference frame refithere is identical resolution;
To the 4th reference frame refi" ' carry out boundary pixel is filled extended method:
Row are filled:
Row is filled:
Wherein o_width, o_height are reficolumns and line number, m_width " ', m_height " ' is refi" ' columns and line number, m, n are line label and the row label of reference frame pixel;
d_width″′=(o_width-m_width″′)/2,
d_height″′=(o_height-m_height″′)/2
Step 2033:curr_refi=refi" "
Step 204: adopt current reference frame to carry out inter prediction to current encoded frame.
The method is by determining the relation of current reference frame and current encoded frame, the mode zooming out according to camera lens respectively or further is carried out upper and lower sampling processing, and further the second reference frame is carried out to pixel deletion, the 4th reference frame has been carried out to pixel-expansion, make current reference frame there is identical resolution with the first reference frame, avoid redistributing of internal memory, be convenient to the compatibility of code.Thereby further improve the similarity of current reference frame and coded frame, reached the compression effectiveness of optimizing current encoded frame.In the time of low frame per second, the shot change between frame and frame is larger, now adopts frame Forecasting Methodology of the present invention, and the lifting of compression performance will be more remarkable.
Embodiment 3, the present invention also provides a kind of inter prediction device of P frame corresponding to embodiment 1, and referring to Fig. 3, this device comprises:
Judging unit 301, for determining the relation of the first reference frame and current encoded frame;
The camera lens unit 302 that furthers, for the first reference frame being processed, obtain the second reference frame in the time that camera lens furthers, and current reference frame is set to the second reference frame;
Camera lens extension unit 303, for the first reference frame being processed, obtain the 4th reference frame in the time zooming out for camera lens, and current reference frame is set to the 4th reference frame;
Predicting unit 304, for adopting current reference frame to carry out inter prediction to current encoded frame.
Wherein camera lens furthers unit for the first reference frame is processed, and obtains the second reference frame and is specially: the first reference frame is carried out to up-sampling, obtain the second reference frame.
Corresponding to embodiment 2, the described camera lens unit that furthers is further used for obtaining, after described the second reference frame, further the second reference frame being processed, and obtains the 3rd reference frame, and current reference frame is set to the 3rd reference frame.
Wherein camera lens furthers unit for the second reference frame is processed, and obtains the 3rd reference frame and is specially:
The second reference frame is carried out to boundary pixel deletion, obtain the 3rd reference frame, make the 3rd reference frame there is identical resolution with the first reference frame;
Wherein, describedly the second reference frame carried out to boundary pixel delet method be specially:
refi″(m,n)=refi'(m+d_heifht',n+d_width')
Wherein refi' be the second reference frame, refi' ' be the 3rd reference frame, o_width, o_height are refithe columns of current reference frame and line number, m_width', m_height' are refi' columns and line number, m, n are line label and the row label of reference frame pixel;
d_width'=(m_width'-o_width)/2,
d_height'=(m_height'-o_height)/2
Wherein, described camera lens extension unit, for the first reference frame is processed, obtains the 4th reference frame and is specially: the first reference frame is carried out to down-sampling, obtain the 4th reference frame.
Corresponding to embodiment 2, described camera lens extension unit is further used for obtaining, after the 4th described reference frame, further the 4th reference frame being processed, and obtains the 5th reference frame; Accordingly, current reference frame is set to the 5th reference frame;
Wherein, described camera lens extension unit is for processing the 4th reference frame, obtaining the 5th reference frame is specially: the 4th reference frame is carried out to boundary pixel and fill expansion, obtain the 5th reference frame, make the 5th reference frame have identical resolution with the first reference frame;
This is specially wherein the 4th reference frame to be carried out to boundary pixel filling expansion:
Row are filled:
Row is filled:
Wherein refi" ' be the 4th reference frame, o_width, o_height are refithe columns of current reference frame and line number, m_width " ', m_height " ' is refi" columns of the ' the four reference frame and line number, m, n are line label and the row label of reference frame pixel;
d_width″′=(o_width-m_width″′)/2,
d_height″′=(o_height-m_height″′)/2
Those having ordinary skill in the art will appreciate that, the all or part of step realizing in above-described embodiment method can complete by program command related hardware, described program can be stored in a computer read/write memory medium, and described storage medium can be ROM, RAM, disk, CD etc.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any amendments of doing within the spirit and principles in the present invention, be equal to and replace and improvement etc., within all should being included in protection scope of the present invention.