mpeg1/2 预测

预测基本概念
预测值p, 实际值a, 残差值d=a-p。
编码端和解码端使用相同的预测方法,意味着两者的p相同,
编码端只需传输d,解码端收到后,就可以重建实际值a=p+d。
o帧内预测(h263+才有)
图像相邻块间差别不大,称作空间冗余。
o帧间预测
运动估计是寻找当前编码块在参考帧中的最佳对应块,并计算出位移矢量。
”最佳“是指差值的无穷范数最小。
运动补偿描述如何得到当前帧的估计值。
根据预测方式的不同,把帧分为
I帧 --不使用预测信息。
P帧 --参考该帧之前的帧(I,P)来预测。
B帧 --参考该帧之前的和之后的帧(I,P,B都可以),两个方向来预测。
例如,用数字表示播放顺序,h264有这样的编解码顺序:
 I1 P5 B3 B2 B4 P9 B7 B6 B8
表示
第5帧P5根基第1帧I1来预测;
B3根据I1和P5来预测;
B2和B4都根据I1,P5,B3来预测。
P9参考P5。称作hierarchical B frame struture。

mpeg1video的预测(ffmpeg早期版本)
mpeg1只有I帧和P帧,mb_intra表示宏块是否是Intra的。
ff_MPV_encode_picture(pkt)-->encode_picture(number)-->
 estimate_motion(s, mb_x, mb_y, &motion_x, &motion_y)//估计运动矢量
 sub_pictrues(new_picture, last_picture); //计算差值
 dct_quantise //变换和量化
 mpeg1_encode_mb(block, motion_x, motion_y); //熵编码
 MPV_decode_mb(block); //供给下一帧参考

o estimate_motion:ME_FULL-->full_motion_search-->
 dmin = pix_abs16x16_c(new_picture, last_picture)
 halfpel_motion_search(&mx, &my, dmin);//半像素估计

mpeg2video的预测(ffmpeg当前版本,包含mpeg1video)
B帧是在mpeg2时才加进来的。注意motion_x/y的单位是半像素。
o ff_MPV_encode_picture--> encode_picture(number)-->
ff_init_me
estimate_motion_thread()-->ff_estimate_b_frame_motion(mb_x, mb_y)-->
 estimate_motion_b-->
  ff_epzs_motion_search-->cmp_simple-->cmp_inline:212-->sad16_sse2/pix_abs16_c
  sub_motion_search= qpel_motion_search
estimate_qp
ff_mpeg1_encode_picture_header(number)
encode_thread-->encode_mb_hq-->encode_mb,ff_MPV_decode_mb


o encode_mb_internal-->
 ff_MPV_motion(dest, ref_picture=last/next_picture.f->data);//dest=data+hqpel运动补偿
 pdsp.diff_pixels//计算差值
 dct_quantize//变换和量化
 ff_mpeg1_encode_mb(block, motion_x, motion_y)//熵编码

你可能感兴趣的:(Codec)