当前位置:网站首页>Frame coding of h264 -- dialysis (I frame +p frame +b frame coding) principle and process
Frame coding of h264 -- dialysis (I frame +p frame +b frame coding) principle and process
2022-07-22 11:44:00 【The procedural ape will point north】
Video is beneficial ⽤⼈ The principle of eye vision persistence , By playing ⼀ Series of Graphs ⽚, send ⼈ Ophthalmic production ⽣ The feeling of movement . Simply transmit video paintings ⾯, Video volume ⾮ often ⼤, To the existing ⽹ Network and storage are unacceptable . In order to make the video easy to transmit and store ,⼈ We found that the video has ⼤ Measure repeated information , If the duplicate message is removed from the sender , At the receiving end , So you ⼤⼤ Reduces the amount of video data ⽂ Pieces of , So there is H.264 Video compression standard .
Definition
stay H.264 In the compression standard I frame 、P frame 、B frame ⽤ Yu Biao ⽰ Transmitted video painting ⾯. In video compression , Each frame represents a still image . In the actual video compression coding , Various algorithms will be adopted to reduce the capacity of data , among IPB Frame is the most common algorithm .
I‑frame (Intra-coded picture): That is, a complete picture
P‑frame (Predicted picture): The area different from the previous picture
B‑frame (Bidirectional predicted picture): The difference area from the front and back pictures
I frame
I frame ⼜ It is called intra coding frame , Also known as full frame compression coding frame , yes ⼀ Kind of ⾃ Unique with all information ⽴ frame ,⽆ You need to refer to other images ⽴ Into the ⾏ decode , It can be simply understood as ⼀ Zhang static painting ⾯. The... In the video sequence ⼀ Every frame is always I frame , Because it's a keyframe .I Frames are usually each GOP(MPEG A video compression technology used ) The first frame of , After moderate compression , As a reference point for random access , It can be used as a still image .
Now there is a film as follows :
The film totals 20 Pictures make up , Every complete picture we can call I frame . If each JPEG The size of the picture is 100KB, Then transmitting two pictures is 100 * 20 = 2000KB
You know, this film is less than a few seconds 2M 了 , If it takes a few hours, it's ok , So there is an algorithm for video compression
I Frame features :
1. It's a full frame compressed encoded frame . It takes the whole frame of image information JPEG Compression coding and transmission ;
2. Use only when decoding I The frame data can reconstruct the whole image ;
3.I The frame describes the background of the image and details of the moving subject ;
4.I Frame is generated without reference to other pictures ;
5.I Frames are P The frame and B Frame reference frame ( Its quality directly affects the quality of subsequent frames in the same group );
6.I Frames are frame groups GOP The base frame of ( First frame ), Only one in a group I frame ;
7.I Frames don't need to consider motion vectors ;
8.I The frame takes up a large amount of information .
P frame
P frame ⼜ It is called inter prediction coding frame , Also known as forward prediction coding frame , Before reference ⾯ Of I Frame can enter ⾏ code . surface ⽰ Is the current frame drawing ⾯ With the former ⼀ frame ( front ⼀ The frame may be I Frames can also be P frame ) The difference between . Decoding requires ⽤ Previously cached paintings ⾯ Superimpose the differences defined in this frame ,⽣ Become the final painting ⾯.
And I Frame phase ⽐,P Frames usually occupy ⽤ Fewer data bits , But I don't ⾜ yes , because P Frame before ⾯ Of P and I The reference frame has complex patience , So for transmission errors ⾮ Chang Mingan . Usually, the time redundancy information of the previous encoded frames in the image sequence is fully removed to compress the encoded image with the amount of transmitted data , Also known as prediction frame . Through observation , We can see that , In fact, there are only some subtle differences between each frame , As shown in the figure below 6 frame
When the first frame is transmitted , In fact, we only need to transmit part of the second frame , Then the other end carries out image algorithm to combine
In this way , When transmitting the second frame , Not the original 1/10, Only need to transmit the first frame 100KB, The subsequent ones are transmitted in this way , This kind of transmission only part of the picture , Namely P Frames . Finally, the size of the whole film is 100KB + 10KB * 19 = 290 KB, Much smaller than before .
P Frame features :
1.P Frames are I The frame is separated by 1~2 Frame encoding frame ;
2.P The frame is transmitted with motion compensation I or P Frame difference and motion vector ( Prediction error );
3. When decoding, you have to decode I Only when the predicted value in the frame is summed with the prediction error can the complete P Frame image ;
4.P The frame belongs to the inter frame coding of forward prediction . It only refers to the one closest to it in front of it I The frame or P frame ;
5.P The frame can be behind it P Frame reference frame , It can also be before and after B Frame reference frame ;
6. because P Frames are reference frames , It can cause the spread of decoding errors ;
7. Because it's a differential transmission ,P The frame compression ratio is high .
B frame
B frame ⼜ It is called bidirectional prediction coding frame , Also known as bidirectional prediction interpolation coding frame , That is to say B A frame records the difference between this frame and the preceding and following frames . That is to say, to decode B frame , Not only to get the previous cache drawing ⾯, And the picture after decoding ⾯, By drawing before and after ⾯ The final picture is obtained by superposition with the data of this frame ⾯.B Frame compression rate ⾼, However, the requirements for decoding performance are relatively ⾼. Consider the encoded frame in front of the source image sequence , The time redundancy information between the encoded frames behind the source image sequence is also considered , To compress the encoded image of the transmitted data , Also known as bidirectional prediction frame .B The frame is actually the difference between the two pictures before and after . If you understand P The frame and I frame , It's easy to understand .
B Frame ratio P Frame smaller , More space saving
Suppose there are three pictures , Here's the picture :
After coding , It's going to be like this :
B Frame features
1.B The frame is from the front I or P The frame and the following P Frame to predict ;
2.B The frame transmits it with the preceding I or P The frame and the following P Prediction errors between frames and motion vectors ;
3.B The frame is a bidirectional predictive coding frame ;
4.B The frame compression ratio is the highest , Because it only reflects the change of motion subject between C reference frames , The prediction is more accurate ;
5.B Frame is not a reference frame , It doesn't cause the spread of decoding errors .
I frame 、B frame 、P The basic process of frame coding :
I The basic process of frame coding is :
(1) Intra prediction , Determine the intra prediction mode used .
(2) Subtract the predicted value from the pixel value , Get the residuals .
(3) Transform and quantify the residuals .
(4) Variable length coding and arithmetic coding .
(5) Reconstruct the image and filter it , The obtained image is used as the reference frame of other frames .
P The frame and B The basic process of frame coding is :
(1) Do motion estimation , Calculate the rate distortion function using the inter frame coding mode ( section ) value .P Frame refers only to the previous frame ,B The frame can refer to the following frame .
(2) Intra prediction , Select the intra mode with the lowest value of rate distortion function and compare it with the inter mode , Determine which encoding mode to use .
(3) Calculate the difference between the actual value and the predicted value .
(4) Transform and quantify the residuals .
(5) Entropy coding , If it's interframe coding mode , Coded motion vector
title 【 One click access to 】Android Necessary for audio and video engineers 《 A complete set of audio and video introduction to proficiency manual 》
【 Poke me for free 】Android Necessary for audio and video engineers 《 A complete set of audio and video introduction to proficiency manual 》
Summary
I Frame only need to consider this frame ;P The frame record is with the previous ⼀ The difference between frames ;B The frame records the front ⼀ Frame and after ⼀ The difference between frames , Can save more space , video ⽂ Pieces of ⼩ 了 , But relatively speaking, when decoding ⽐ a ⿇ Bother . Because in decoding , It's not just about ⽤ Previously cached paintings ⾯,⽽ And you should know ⼀ individual I perhaps P Paintings ⾯, For no ⽀ a B Frame decoding player is easy to get stuck .
边栏推荐
- LeetCode刷题--点滴记录020
- 文件夹下搜索匹配文件或目录 glob()
- Viewport scaling method to solve the self adaptation of mobile terminal
- tsconfig. Role of JSON file
- 基于JSP+Servlet+MySQL+Bootstrap+CSS的图书管理系统
- 请求转发和请求重定向的区别
- Leetcode skimming -- bit by bit record 019
- How to solve cross domain problems
- es6 的 class 与 es5 的语法对比
- MySQL插入数据insert ignore和replace into
猜你喜欢
即看即用 && 其他操作(Other Operations) && Pytorch官方文档总结 && 笔记 (八)
I wipe the "hidden rules" in the interview of those testers. Don't step on the pit
【如何优化她】教你如何定位不合理的SQL?并优化她~~~
底线
MySQL prefix index
Search for matching files or directories under folders glob ()
Light up through UDP
【毕设项目推荐】学长做过的那些有趣的毕设项目 - 毕设项目分享 (单片机 嵌入式 物联网 stm32)
Basic configuration of BGP
grafana 监控 node
随机推荐
删除文件夹中的相邻但名称不同的文件 && 适应于神经网络训练时的标签名称和图像名称相对应的情况
LeetCode刷题--点滴记录020
J9 number theory: what is Dao? What is the origin of Dao
How to solve cross domain problems
OpenOffice startup and auto startup settings
Automatic shutdown code
即看即用 && 其他操作(Other Operations) && Pytorch官方文档总结 && 笔记 (八)
_TensorBase(45个张量基础后置函数总结) && Pytorch官方文件 && NOTEBOOK(NINE)
The difference between request forwarding and request redirection
论文分享目标检测、图像分割、监督学习等
Classic interview questions of interface testing: what is the difference between session, cookie and token?
The world's first large aerospace model came out, and Wenxin supplemented the picture of Fuchun Mountain Residence, which is the perseverance of Baidu Pratt Whitney AI
Leetcode skimming -- bit by bit record 019
ADVANCE. AI: at present, there are few Chinese enterprises entering Latin America, which is worth exploring
Memorize these interview questions, and you will be half successful in any technical aspect
Sentinel vs Hystrix 对比,你怎么选?
viewport缩放方法,解决移动端自适配
Viewport scaling method to solve the self adaptation of mobile terminal
Search for matching files or directories under folders glob ()
基于SSM+MySQL+Bootstrap的在线教育课程课堂管理系统