JM14 decoder

http://users.ecel.ufl.edu/~zhifeng/personal/study/Project_Notes.htm#JM14.0:

-------------------------encoder-----------------------------------------

encoder architecture

encoding:
main()-->encode_one_frame()-->frame_picture()--code_a_picture(frame)-->encode_one_slice()-->start_macroblock()/encode_one_macroblock()
void (*encode_one_macroblock) (Macroblock *currMB)==>void encode_one_macroblock_high (Macroblock *currMB);
compute_mode_RD_cost(mode, currMB, enc_mb, &min_rdcost, &min_dcost, &min_rate, i16mode, bslice, &inter_skip);
packetization:
main()-->encode_one_frame()-->writeout_picture()-->writeUnit()
save decoded picture buffer (DPB):
main()-->encode_one_frame()-->store_picture_in_dpb(enc_frame_picture[0])-->insert_picture_in_dpb(dpb.fs[dpb.used_size],p)
in dump_dpb(), we may set DUMP_DPB = 1 to get debug information!
write test_rec.yuv:
main()-->flush_dpb()-->output_one_frame_from_dpb()-->write_stored_frame(dpb.fs[pos], p_dec)-->write_picture(fs->frame, p_out, FRAME)-->write_out_picture(p, p_out)
-->img2buf (p->imgY, buf, p->size_x, p->size_y, symbol_size_in_bytes, crop_left, crop_right, crop_top, crop_bottom)
-->write(p_out, buf, (p->size_y-crop_bottom-crop_top)*(p->size_x-crop_right-crop_left)*symbol_size_in_bytes)

在JM14.0中有两个结构体比较重要:ImageParametersStorablePicture

    在global.h中定义: ImageParameters用于保存程序运算过程的图像参数

        1)imgpel mpr [MAX_PLANE][16][16];    用于保存预测的像素值

        2)int m7 [MAX_PLANE][16][16];    用于保存residue data的处理过程临时数据(注释写的有问题“the diff pixel values between the original macroblock/block and its prediction”)

        3)int ****cofAC; / int ***cofDC;    用于保存经过transform和quantization以后的宏块系数

        4)Slice *currentSlice;

            DataPartition *partArr;

                 Bitstream *bitstream;

                      byte *streamBuffer;    用于保存最终的编码结果,输出到test.264

    在mbuffer.h中定义:StorablePicture用于保存图像处理的结果

        imgpel ** imgY; / imgpel *** imgUV;    用于保存重构图像的像素值,输出到test_rec.yuv

        imgpel ** p_curr_img; ??

        short **** mv;    用于保存motion vector的值

这两个结构体各定义了一个全局变量用来保存图像的处理结果:

    在lencod.c中定义:ImageParameters images, *img = &images;

    在image.c中定义:StorablePicture *enc_picture;(其实还定义了StorablePicture **enc_frame_picture;但是enc_frame_picture[i]取决于rd_pass变量对i有不同的取值,在实验中只用到enc_frame_picture[0])

在zhifeng.c和zhifeng.h两个文件中用到img->mpr,enc_picture->imgY/enc_picture->imgUV和enc_picture->mv来得到所有像素的motion vector和residue data。

---------------------------------------------------

me_fullfast.c中的FastFullPelBlockMotionSearch()函数中:
mcost = block_sad[pos_00[list][ref]] + MV_COST_SMP (lambda_factor, 0, 0, pred_mv[0], pred_mv[1]);
是在根据RDOptimization做rate distortion optimazatin。虽然这里RateControlEnable=0,但是对于每p帧中任一宏块都有7中预测模式,理论上用4×4的block得到的distortion最小,但是rate最大,这条语句就是做两者的balance。
RateControlEnable的设置是对整个video sequence做的。
用-d "*.cfg"不用-f "*.cfg"!!!(-f好像是组合参数,lencod -f "encoder_baseline.cfg"对于没有修改的JM中的lencod运行出错)
可以用Bit_Buffer来计算每一帧的大小,但是好像不能计算slice的大小。
image.c:Bit_Buffer[total_frame_buffer] = (int) (stats->bit_ctr - stats->bit_ctr_n);
original图像:
/ buf = malloc (xs*ys * symbol_size_in_bytes)
image.c-->ReadOneFrame()-->
/ read(p_in, buf, bytes_y)

但是buf的值在ReadOneFrame()最后被释放:free (buf);
通过imgY_org_frm保存的是16位,高8位为0x00:
buf2img(imgY_org_frm_JV[0], buf, xs, ys, symbol_size_in_bytes);
buf2img(imgUV_org_frm[0], buf, xs_cr, ys_cr, symbol_size_in_bytes);
buf2img(imgUV_org_frm[1], buf, xs_cr, ys_cr, symbol_size_in_bytes);
重要参数:
stats->bit_ctr_parametersets_n:SPS和PPS的位数
start_sequence()-->stats->bit_ctr_parametersets_n = len;
encode_one_frame()-->stats->bit_ctr_parametersets_n=0;
stats->bit_ctr_n: 当前处理的帧之前的所有位数
encode_one_frame()-->stats->bit_ctr_n = stats->bit_ctr;
stats->bit_ctr: 在ReportFirstframe()中清零!
ReportFirstframe()-->stats->bit_ctr = 0;
ok:
output:
.cfg
ReportFrameStats = 0 # (0:Disable Frame Statistics 1: Enable)
DisplayEncParams = 0 # (0:Disable Display of Encoder Params 1: Enable)
Verbose = 1 # level of display verboseness (0:short, 1:normal, 2:detailed)
in dump_dpb(), we may set DUMP_DPB = 1 to get debug information!
全局变量:
frame_pic
defined in global.h: Picture **frame_pic;
*img:
defined in lencod.c: ImageParameters images, *img = &images;
referenced in global.h: extern ImageParameters *img;
difference between JM13 and JM14:
there is no LoopFilterDisable in JM14, but deblocking filter!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值