H.264/AVC Reference Software Group 3 11 簡嘉宏 9762530 2009/05/22.

Slides:



Advertisements
Similar presentations
H.264 Intra Frame Coder System Design Özgür Taşdizen Microelectronics Program at Sabanci University 4/8/2005.
Advertisements

Basics of MPEG Picture sizes: up to 4095 x 4095 Most algorithms are for the CCIR 601 format for video frames Y-Cb-Cr color space NTSC: 525 lines per frame.
2004 NTU CSIE 1 Ch.6 H.264/AVC Part2 (pp.200~222) Chun-Wei Hsieh.
Technion - IIT Dept. of Electrical Engineering Signal and Image Processing lab Transrating and Transcoding of Coded Video Signals David Malah Ran Bar-Sella.
MPEG-4 Objective Standardize algorithms for audiovisual coding in multimedia applications allowing for Interactivity High compression Scalability of audio.
A Highly Parallel Framework for HEVC Coding Unit Partitioning Tree Decision on Many-core Processors Chenggang Yan, Yongdong Zhang, Jizheng Xu, Feng Dai,
An Early Block Type Decision Method for Intra Prediction in H.264/AVC Jungho Do, Sangkwon Na and Chong-Min Kyung VLSI Systems Lab. Korea Advanced Institute.
H.264/AVC Baseline Profile Decoder Complexity Analysis Michael Horowitz, Anthony Joch, Faouzi Kossentini, and Antti Hallapuro IEEE TRANSACTIONS ON CIRCUITS.
1 Adaptive slice-level parallelism for H.264/AVC encoding using pre macroblock mode selection Bongsoo Jung, Byeungwoo Jeon Journal of Visual Communication.
Fast Mode Decision for Multiview Video Coding Liquan Shen, Tao Yan, Zhi Liu, Zhaoyang Zhang, Ping An, Lei Yang ICIP
CABAC Based Bit Estimation for Fast H.264 RD Optimization Decision
Highly Parallel Rate-Distortion Optimized Intra-Mode Decision on Multicore Graphics Processors Ngai-Man Cheung, Oscar C. Au, Senior Member, IEEE, Man-Cheung.
Ch. 6- H.264/AVC Part I (pp.160~199) Sheng-kai Lin
FAST MACROBLOCK MODE SELECTION BASED ON MOTION CONTENT CLASSIFICATION IN H.264/AVC Ming Yang, Wensheng Wang ICIP 2004.
Outline Introduction Introduction Fast Inter Prediction Mode Decision for H.264 – –Pre-encoding An Efficient Inter Mode Decision Approach for H.264 Video.
Efficient multi-frame motion estimation algorithms for MPEG-4 AVC/JVTH.264 Mei-Juan Chen, Yi-Yen Chiang, Hung- Ju Li and Ming-Chieh Chi ISCAS 2004.
Overview of the H.264/AVC Video Coding Standard
Low-complexity mode decision for MVC Liquan Shen, Zhi Liu, Ping An, Ran Ma and Zhaoyang Zhang CSVT
Context-Based Adaptive Binary Arithmetic Coding in the H.264/AVC Video Compression Standard Detlev Marpe, Heiko Schwarz, and Thomas Wiegand IEEE Transactions.
1 Single Reference Frame Multiple Current Macroblocks Scheme for Multiple Reference IEEE TRANSACTIONS ON CIRCUITS AND SYSTEMS FOR VIDEO TECHNOLOGY Tung-Chien.
Video Compression Bee Fong. Lossy Compression  Inter Frame Compression Compression among frames Compression among frames  Intra Frame Compression Compression.
Analysis, Fast Algorithm, and VLSI Architecture Design for H
H.264 / MPEG-4 Part 10 Nimrod Peleg March 2003.
Fast Mode Decision And Motion Estimation For JVT/H.264 Pen Yin, Hye – Yeon Cheong Tourapis, Alexis Michael Tourapis and Jill Boyce IEEE ICIP 2003 Sep.
CS :: Fall 2003 MPEG-1 Video (Part 1) Ketan Mayer-Patel.
2015/6/271 Intra-Prediction in H.264(JM82) Student : 林鴻志 Advisor : 杭學鳴 教授.
1 An Efficient Mode Decision Algorithm for H.264/AVC Encoding Optimization IEEE TRANSACTION ON MULTIMEDIA Hanli Wang, Student Member, IEEE, Sam Kwong,
BY AMRUTA KULKARNI STUDENT ID : UNDER SUPERVISION OF DR. K.R. RAO Complexity Reduction Algorithm for Intra Mode Selection in H.264/AVC Video.
BY AMRUTA KULKARNI STUDENT ID : UNDER SUPERVISION OF DR. K.R. RAO Complexity Reduction Algorithm for Intra Mode Selection in H.264/AVC Video.
Optimizing Baseline Profile in H
A Nonlinear Loop Filter for Quantization Noise Removal in Hybrid Video Compression Onur G. Guleryuz DoCoMo USA Labs
H.264/AVC.
1 Image and Video Compression: An Overview Jayanta Mukhopadhyay Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur,
Image and Video Compression
EE 5359 H.264 to VC 1 Transcoding Vidhya Vijayakumar Multimedia Processing Lab MSEE, University of Arlington Guided.
1 Efficient Reference Frame Selector for H.264 Tien-Ying Kuo, Hsin-Ju Lu IEEE CSVT 2008.
Windows Media Video 9 Tarun Bhatia Multimedia Processing Lab University Of Texas at Arlington 11/05/04.
Adaptive Multi-path Prediction for Error Resilient H.264 Coding Xiaosong Zhou, C.-C. Jay Kuo University of Southern California Multimedia Signal Processing.
Codec structuretMyn1 Codec structure In an MPEG system, the DCT and motion- compensated interframe prediction are combined. The coder subtracts the motion-compensated.
June, 1999 An Introduction to MPEG School of Computer Science, University of Central Florida, VLSI and M-5 Research Group Tao.
2 3 Be introduced in H.264 FRExt profile, but most H.264 profiles do not support it. Do not need motion estimation operation.
- By Naveen Siddaraju - Under the guidance of Dr K R Rao Study and comparison between H.264.
Rate-distortion Optimized Mode Selection Based on Multi-channel Realizations Markus Gärtner Davide Bertozzi Classroom Presentation 13 th March 2001.
Figure 1.a AVS China encoder [3] Video Bit stream.
Guillaume Laroche, Joel Jung, Beatrice Pesquet-Popescu CSVT
MPEG-4: Multimedia Coding Standard Supporting Mobile Multimedia System -MPEG-4 Natural Video Coding April, 2001.
Fast motion estimation and mode decision for H.264 video coding in packet loss environment Li Liu, Xinhua Zhuang Computer Science Department, University.
Vamsi Krishna Vegunta University of Texas, Arlington
Block-based coding Multimedia Systems and Standards S2 IF Telkom University.
Video Compression and Standards
MPEG CODING PROCESS. Contents  What is MPEG Encoding?  Why MPEG Encoding?  Types of frames in MPEG 1  Layer of MPEG1 Video  MPEG 1 Intra frame Encoding.
Outline  Introduction  Observations and analysis  Proposed algorithm  Experimental results 2.
Introduction to MPEG Video Coding Dr. S. M. N. Arosha Senanayake, Senior Member/IEEE Associate Professor in Artificial Intelligence Room No: M2.06
CS 多媒體編碼技術導論 P ROJECT II H.264 C ODE T RACING x264_macroblock_write_cabac 朱逸樵.
X264 Code Tracing 陳俊達. Outlines x264_macroblock_cache_load x264_ratecontrol_mb x264_macroblock_cache_save x264_cabac_mb_skip macroblock.c/315.
Fine-granular Motion Matching for Inter-view Motion Skip Mode in Multi-view Video Coding Haitao Yanh, Yilin Chang, Junyan Huo CSVT.
Fast disparity motion estimation in MVC based on range prediction Xiao Zhong Xu, Yun He ICIP 2008.
Computational Controlled Mode Selection for H.264/AVC June Computational Controlled Mode Selection for H.264/AVC Ariel Kit & Amir Nusboim Supervised.
Perceptually-Driven Video Coding with the Daala Video Codec
Present by 楊信弘 Advisor: 鄭芳炫
Video-in-Video Insertion into a Pre-encoded Bit-stream
Supplement, Chapters 6 MC Course, 2009.
Study and Optimization of the Deblocking Filter in H
ENEE 631 Project Video Codec and Shot Segmentation
Transformations.
Optimizing Baseline Profile in H
H.264 code tracing Group 徐君潔.
Bongsoo Jung, Byeungwoo Jeon
MPEG-1 MPEG is short for the ‘Moving Picture Experts Group‘.
MPEG-1 MPEG is short for the ‘Moving Picture Experts Group‘.
Presentation transcript:

H.264/AVC Reference Software Group 3 11 簡嘉宏 /05/22

Over View Encode_one_macrob lock_high (2) Compute_mode_RD_cost PartitionMotionSearch submacroblock_mode_decision (2) Rdcost_for_macroblocks SetModesAndRefframeForBlock s store_macroblock_parameters init_enc_mb_params Get_Direct_Motion_Vectors BlockMotionSearch RDCost_for_8x8blocks IntraChromaPrediction set_stored_macroblock_paramet ers Encode_one_ma croblock

Call Graph Encode_one_macrob lock_high (2) Compute_mode_RD_cost PartitionMotionSearch submacroblock_mode_decision (2) Rdcost_for_macroblocks SetModesAndRefframeForBlock s store_macroblock_parameters RDCost_for_8x8blocks IntraChromaPrediction Encode_one_ma croblock Mode Decision for a macroblock Mode Decision for an 8x8 sub-macroblock Precompute all new chroma intra prediction modes RD decision process

Call Graph Encode_one_macrob lock_high (2) Compute_mode_RD_cost PartitionMotionSearch submacroblock_mode_decision (2) Rdcost_for_macroblocks SetModesAndRefframeForBlock s store_macroblock_parameters RDCost_for_8x8blocks IntraChromaPrediction Encode_one_ma croblock Mode Decision for a macroblock Mode Decision for an 8x8 sub-macroblock Precompute all new chroma intra prediction modes RD decision process

submacroblock_mode_decision Location: lencod\src\Mode_decision.c Brief: Mode Decision for an 8x8 sub-macroblock Arguments: – RD_PARAMS enc_mb// MB Level parameters, include MD/ME // lambda, best reference and mcost – RD_8x8DATA *dataTr//8x8 sub-macroblock data – Macroblock *currMB// 目前 Macroblock 的 pointer – int*** cofACtr//8x8macroblock coefficients – int *have_direct// 統計 direct mode submacroblock 的數目 – short bslice// 是否是 Bslice 編碼 – int block// 目前編碼的 block – int *cost_direct// 目前編碼的 macroblock 的 direct mode 的最 // 小 cost – int *cost// 目前編碼的 macroblock 的最小 cost – int *cost8x8_direct// 累計 8x8 direct mode 的最小 cost – int transform8x8// 是否使用 8x8size transform mode

Work Flow  Loop over possible coding modes for 8x8 sub-partition Modes: direct 8x8, inter 8x8, inter 8x4, inter 4x8, inter 4x4  Direct Mode  GetDirectCost8x8, DirectCost4x4  Compute cost and best reference  Not Direct Mode  Motion estimation for all reference frames  Get cost and reference frame for LIST0 prediction, and store  If bslice, compute LIST1 prediction  RDCost_for_8x8blocks  若此 loop 產生出最小的 cost 或 rdcost, 則更新各項參數  Loop 結束, 更新各項參數  儲存 motion data, motion vector, reference frame

Loop  Direct mode  Not Direct mode  RDCost_for_8x8blocks  若此 loop 產生出最小的 cost 或 rdcost, 則更新各項參數 //===== LOOP OVER POSSIBLE CODING MODES FOR 8x8 SUB-PARTITION ===== for (min_cost8x8=INT_MAX, min_rdcost=1e30, index=(bslice?0:1); index<maxindex; index++) { mode = b8_mode_table[index]; *cost = 0; if (enc_mb.valid[mode] && (transform8x8 == 0 || mode != 0 || (mode == 0 && active_sps->direct_8x8_inference_flag))) {…… const int b8_mode_table[6] = {0, 4, 5, 6, 7}; Mode #Mode Name 0Direct 8x8 4Inter 8x8 5Inter 8x4 6Inter 4x8 7Inter 4x4

Direct Mode if (mode==0) { //--- Direct Mode --- if (!input->rdopt ) { direct4x4_tmp = 0; direct8x8_tmp = 0; direct4x4_tmp = GetDirectCost8x8 ( block, &direct8x8_tmp); if ((direct4x4_tmp==INT_MAX)||(*cost_direct==INT_MAX)) { *cost_direct = INT_MAX; if (transform8x8) *cost8x8_direct = INT_MAX; } else { *cost_direct += direct4x4_tmp; if (transform8x8) *cost8x8_direct += direct8x8_tmp; } (*have_direct) ++; block_x = img->block_x+(block&1)*2; block_y = img->block_y+(block&2); best_ref[LIST_0] = direct_ref_idx[LIST_0][block_y][block_x]; best_ref[LIST_1] = direct_ref_idx[LIST_1][block_y][block_x]; best_pdir = direct_pdir[block_y][block_x]; } // if (mode==0) if (transform8x8) { switch(input->Transform8x8Mode) { case 1: // Mixture of 8x8 & 4x4 transform if((direct8x8_tmp < direct4x4_tmp) || !(enc_mb.valid[5] && enc_mb.valid[6] && enc_mb.valid[7])) *cost = direct8x8_tmp; else *cost = direct4x4_tmp; break; case 2: // 8x8 Transform only *cost = direct8x8_tmp; break; default: // 4x4 Transform only *cost = direct4x4_tmp; break; } if (input->Transform8x8Mode==2) *cost = INT_MAX; } else { *cost = direct4x4_tmp; }

Not Direct Mode  Inter mode  Motion estimation for all reference frames  Get cost and reference frame for LIST0 prediction, and store  If bslice, compute LIST1 prediction //--- get cost and reference frame for LIST 0 prediction --- bmcost[LIST_0] = INT_MAX; list_prediction_cost(LIST_0, block, mode, enc_mb, bmcost, best_ref); //store LIST 0 reference index for every block block_x = img->block_x+(block&1)*2; block_y = img->block_y+(block&2); for (j = block_y; j< block_y + 2; j++) { for (i = block_x; i < block_x + 2; i++) { enc_picture->ref_idx [LIST_0][j][i] = best_ref[LIST_0]; enc_picture->ref_pic_id[LIST_0][j][i] = enc_picture->ref_pic_num[enc_mb.list_offset[LIST_0]][(short)best_ref[LIST_0]]; } if (bslice) { //--- get cost and reference frame for LIST 1 prediction --- bmcost[LIST_1] = INT_MAX; bmcost[BI_PRED] = INT_MAX; list_prediction_cost(LIST_1, block, mode, enc_mb, bmcost, best_ref); // Compute bipredictive cost between best list 0 and best list 1 references list_prediction_cost(BI_PRED, block, mode, enc_mb, bmcost, best_ref); …. } // if (bslice)  Get cost and reference frame for LIST1 prediction  Compute bipredictive cost between best list 0 and best list 1 references  Get prediction direction  Store backward reference index for every block

RDCost_for_8x8blocks  Loop over possible coding modes for 8x8 sub-partition Modes: direct 8x8, inter 8x8, inter 8x4, inter 4x8, inter 4x4  Direct Mode  GetDirectCost8x8, DirectCost4x4  Compute cost and best reference  Not Direct Mode  Motion estimation for all reference frames  Get cost and reference frame for LIST0 prediction, and store  If bslice, compute LIST1 prediction  RDCost_for_8x8blocks  若此 loop 產生出最小的 cost 或 rdcost, 則更新各項參數  Loop 結束, 更新各項參數  儲存 motion data, motion vector, reference frame RDO – Rate-distortion optimization If Enable RDO Compute RD cost Else Compute weighted cost if (input->rdopt) { //--- get and check rate-distortion cost --- rdcost = RDCost_for_8x8blocks (&cnt_nonz, &curr_cbp_blk, enc_mb.lambda_md, block, mode, best_pdir, best_ref[LIST_0], best_ref[LIST_1]); } else { if (*cost!=INT_MAX) *cost += (REF_COST (enc_mb.lambda_mf[Q_PEL], B8Mode2Value (mode, best_pdir), enc_mb.list_offset[(best_pdir<1?LIST_0:LIST_1)]) - 1); }

Loop 結束  Store coefficients  Store reconstruction and prediction  Set cbp and count of nonzero coefficients  Save motion data for 8x8 partition for transform size 8x8  Set motion vectors and reference frames (prediction)  Set the coding state after current block if (!transform8x8) { … } else { //======= save motion data for 8x8 partition for transform size 8x8 ======== StoreNewMotionVectorsBlock8x8(0, block, dataTr->part8x8mode[block], dataTr->part8x8fwref[block], dataTr- >part8x8bwref[block], dataTr->part8x8pdir[block], bslice); } //===== set motion vectors and reference frames (prediction) ===== SetRefAndMotionVectors (block, dataTr->part8x8mode[block], dataTr->part8x8pdir[block], dataTr->part8x8fwref[block], dataTr->part8x8bwref[block]);

Call Graph Encode_one_macrob lock_high (2) Compute_mode_RD_cost PartitionMotionSearch submacroblock_mode_decision (2) Rdcost_for_macroblocks SetModesAndRefframeForBlock s store_macroblock_parameters RDCost_for_8x8blocks IntraChromaPrediction Encode_one_ma croblock Mode Decision for a macroblock Mode Decision for an 8x8 sub-macroblock Precompute all new chroma intra prediction modes RD decision process

IntraChromaPrediction  Location: lencod\src\Macroblock.c  Brief: Intra prediction of the chrominance layers of one macroblock  Arguments:  int *mb_up// 上方的 macroblock  int *mb_left// 左方的 macroblock  int *mb_up_left// 左上方的 macroblock

Work Flow 取得上方, 左方以及左上方的 macroblock 的 address 計算所有 chroma intra prediction mode – DC prediction – Vertical prediction – Horizontal prediction – Plane prediction Loop 所有的 prediction mode, 計算出具有最小 SAD 的 prediction mode 設定 macroblock 的 chroma intra prediction mode

Work Flow 取得上方, 左方以及左上方的 macroblock 的 address 計算所有 chroma intra prediction mode – DC prediction – Vertical prediction – Horizontal prediction – Plane prediction Loop 所有的 prediction mode, 計算出具有最小 SAD 的 prediction mode 設定 macroblock 的 chroma intra prediction mode

Macroblock Address  取得上方, 左方以及左上方的 macroblock 的 address for (i=0;i<cr_MB_y+1;i++) getNeighbour(mb_nr, -1, i-1, IS_CHROMA, &left[i]); getNeighbour(mb_nr, 0, -1, IS_CHROMA, &up); mb_available_up = up.available; mb_available_up_left = left[0].available; mb_available_left[0] = mb_available_left[1] = left[1].available; if(input->UseConstrainedIntraPred) { mb_available_up = up.available ? img->intra_block[up.mb_addr] : 0; for (i=0, mb_available_left[0]=1; i >1);i++) mb_available_left[0] &= left[i+1].available ? img->intra_block[left[i+1].mb_addr]: 0; for (i=(cr_MB_y>>1), mb_available_left[1]=1; i<cr_MB_y;i++) mb_available_left[1] &= left[i+1].available ? img->intra_block[left[i+1].mb_addr]: 0; mb_available_up_left = left[0].available ? img->intra_block[left[0].mb_addr]: 0; } if (mb_up) *mb_up = mb_available_up; if (mb_left) *mb_left = mb_available_left[0] && mb_available_left[1]; if (mb_up_left) *mb_up_left = mb_available_up_left;

Work Flow 取得上方, 左方以及左上方的 macroblock 的 address 計算所有 chroma intra prediction mode – DC prediction – Vertical prediction – Horizontal prediction – Plane prediction Loop 所有的 prediction mode, 計算出具有最小 SAD 的 prediction mode 設定 macroblock 的 chroma intra prediction mode

DC Prediction  Get prediction value //===== get prediction value ===== switch (block_pos[yuv][b8][b4]) { case 0: //===== TOP LEFT ===== if (mb_available_up) for (i=blk_x;i<(blk_x+4);i++) s0 += image[up.pos_y][up.pos_x + i]; if (mb_available_left[0]) for (i=blk_y;i<(blk_y+4);i++) s2 += image[left[i].pos_y][left[i].pos_x]; if (mb_available_up && mb_available_left[0]) s = (s0+s2+4) >> 3; else if (mb_available_up) s = (s0 +2) >> 2; else if (mb_available_left[0]) s = (s2 +2) >> 2; break; case 1: //===== TOP RIGHT ===== if (mb_available_up) for (i=blk_x;i<(blk_x+4);i++) s1 += image[up.pos_y][up.pos_x + i]; else if (mb_available_left[0]) for (i=blk_y;i<(blk_y+4);i++) s2 += image[left[i].pos_y][left[i].pos_x]; if (mb_available_up) s = (s1 +2) >> 2; else if (mb_available_left[0]) s = (s2 +2) >> 2; break; case 2: //===== BOTTOM LEFT ===== … case 3: //===== BOTTOM RIGHT ===== … }

Vertical Prediction // vertical prediction if (mb_available_up) { memcpy(hline,&image[up.pos_y][up.pos_x], cr_MB_x * sizeof(imgpel)); for (j=0; j<cr_MB_y; j++) memcpy(img->mprr_c[uv][VERT_PRED_8][j], hline, cr_MB_x * sizeof(imgpel)); }

Horizontal Prediction // horizontal prediction if (mb_available_left[0] && mb_available_left[1]) { for (i=0; i<cr_MB_y; i++) vline[i] = image[left[i+1].pos_y][left[i+1].pos_x]; for (i=0; i<cr_MB_x; i++) for (j=0; j<cr_MB_y; j++) img->mprr_c[uv][HOR_PRED_8][j][i] = vline[j]; }

Plane Prediction // plane prediction if (mb_available_left[0] && mb_available_left[1] && mb_available_up && mb_available_up_left) { ih = (cr_MB_x>>1)*(hline[cr_MB_x-1] - image[left[0].pos_y][left[0].pos_x]); for (i=0;i >1)-1;i++) ih += (i+1)*(hline[(cr_MB_x>>1)+i] - hline[(cr_MB_x>>1)-2-i]); iv = (cr_MB_y>>1)*(vline[cr_MB_y-1] - image[left[0].pos_y][left[0].pos_x]); for (i=0;i >1)-1;i++) iv += (i+1)*(vline[(cr_MB_y>>1)+i] - vline[(cr_MB_y>>1)-2-i]); ib= ((cr_MB_x == 8?17:5)*ih+2*cr_MB_x)>>(cr_MB_x == 8?5:6); ic= ((cr_MB_y == 8?17:5)*iv+2*cr_MB_y)>>(cr_MB_y == 8?5:6); iaa=16*(hline[cr_MB_x-1]+vline[cr_MB_y-1]); for (j=0; j<cr_MB_y; j++) for (i=0; i<cr_MB_x; i++) img->mprr_c[uv][PLANE_8][j][i]= iClip3(0, img->max_imgpel_value_uv, (iaa+(i-(cr_MB_x>>1)+1)*ib+(j-(cr_MB_y>>1)+1)*ic+16)>>5); }

Work Flow 取得上方, 左方以及左上方的 macroblock 的 address 計算所有 chroma intra prediction mode – DC prediction – Vertical prediction – Horizontal prediction – Plane prediction Loop 所有的 prediction mode, 計算出具有最小 SAD 的 prediction mode 設定 macroblock 的 chroma intra prediction mode

最小 SAD 的 Prediction Mode  設定 chroma intra prediction mode for (mode=DC_PRED_8; mode<=PLANE_8; mode++){ …… cost = 0; for (uv=0; uv<2; uv++) { image = imgUV_org[uv]; for (block_y=0; block_y<cr_MB_y; block_y+=4) for (block_x=0; block_x<cr_MB_x; block_x+=4) { for (k=0,j=block_y; j<block_y+4; j++) { for (i=block_x; i<block_x+4; i++,k++) diff[k] = image[left[j].pos_y][left[j].pos_x+i] - img->mprr_c[uv][mode][j][i]; } cost += distortion4x4(diff); } if (cost < min_cost) { best_mode = mode; min_cost = cost; } currMB->c_ipred_mode = best_mode;

Call Graph Encode_one_macrob lock_high (2) Compute_mode_RD_cost PartitionMotionSearch submacroblock_mode_decision (2) Rdcost_for_macroblocks SetModesAndRefframeForBlock s store_macroblock_parameters RDCost_for_8x8blocks IntraChromaPrediction Encode_one_ma croblock Mode Decision for a macroblock Mode Decision for an 8x8 sub-macroblock Precompute all new chroma intra prediction modes RD decision process

compute_mode_RD_cost  Location: lencod\src\Mode_decision.c  Brief: RD decision process  Arguments:  int mode  Macroblock *currMB// pointer to current MB  RD_PARAMS enc_mb  double *min_rdcost// pointer to minimum RD cost  double *min_rate// pointer to minimum rate  int i16mode  short bslice // 是否是 Bslice 編碼  short *inter_skip

Work Flow  Set Modes and Reference frame For Blocks  Encode with coefficients  While 1 loop  Go through transform modes  Try mb_types 1, 2, 3 with 8x8 transform  Try DIRECT-MODE with 8x8 transform  Try mb_type P8x8 for mode 4 with 4x4/ 8x8 transform  Encode with no coefficients

Work Flow  Set Modes and Reference frame For Blocks  Encode with coefficients  While 1 loop  Go through transform modes  Try mb_types 1, 2, 3 with 8x8 transform  Try DIRECT-MODE with 8x8 transform  Try mb_type P8x8 for mode 4 with 4x4/ 8x8 transform  Encode with no coefficients SetModesAndRefframeForBlocks (mode);

Work Flow  Set Modes and Reference frame For Blocks  Encode with coefficients  While 1 loop  Go through transform modes  Try mb_types 1, 2, 3 with 8x8 transform  Try DIRECT-MODE with 8x8 transform  Try mb_type P8x8 for mode 4 with 4x4/ 8x8 transform  Encode with no coefficients img->NoResidueDirect = 0;

while 1 loop  RDCost_for_macroblocks  Rate control  store_macroblock_parameters if (RDCost_for_macroblocks (enc_mb.lambda_md, mode, min_rdcost, min_rate, i16mode)) { //Rate control if (input->RCEnable) { if(mode == P8x8) rc_store_diff(img->opix_x,img->opix_y, currMB->luma_transform_size_8x8_flag == 1 ? tr8x8.mpr8x8 : tr4x4.mpr8x8); else rc_store_diff(img->opix_x, img->opix_y, pred); } store_macroblock_parameters (mode); … }

Go through transform modes // Go through transform modes. if (input->Transform8x8Mode==1){ //=========== try mb_types 1,2,3 with 8x8 transform =========== if ((mode >= 1 && mode luma_transform_size_8x8_flag == 0) { //try with 8x8 transform size currMB->luma_transform_size_8x8_flag = 1; continue; } //=========== try DIRECT-MODE with 8x8 transform =========== else if (mode == 0 && bslice && active_sps->direct_8x8_inference_flag && currMB->luma_transform_size_8x8_flag == 0){ //try with 8x8 transform size currMB->luma_transform_size_8x8_flag = 1; continue; } //=========== try mb_type P8x8 for mode 4 with 4x4/8x8 transform =========== else if ((mode == P8x8) && (enc_mb.valid[4]) && (currMB->luma_transform_size_8x8_flag == 0)) { currMB->luma_transform_size_8x8_flag = 1; //check 8x8 partition for transform size 8x8 continue; } else { currMB->luma_transform_size_8x8_flag = 0; break; } else break; }

Encode with no coefficients  Currently only for direct  NoResidueDirect = 1 if ( bslice && mode == 0 && (*inter_skip == 0) && enc_mb.valid[mode] && currMB->cbp && (currMB->cbp&15) != 15 && !input->nobskip) { img->NoResidueDirect = 1; if (RDCost_for_macroblocks (enc_mb.lambda_md, mode, min_rdcost, min_rate, i16mode)) { //Rate control if (input->RCEnable) rc_store_diff(img->opix_x,img->opix_y,pred); store_macroblock_parameters (mode); }

Thank you