H 264AVC code tracing REPORT Group 1 no

  • Slides: 25
Download presentation
H. 264/AVC code tracing REPORT Group 1. no 1 942015 Tsao

H. 264/AVC code tracing REPORT Group 1. no 1 942015 Tsao

Overview 1. encode_one_frame 2. encode_enhancement_layer encode_one_frame Main encode_one_redundant_frame Encode_enhancement_layer

Overview 1. encode_one_frame 2. encode_enhancement_layer encode_one_frame Main encode_one_redundant_frame Encode_enhancement_layer

encode_one_frame START initialization FIELD_CODING YES 依之前選擇FIELD_CODING 與 ADAPTIVE_CODING的取向, store_picture_in_dpb (decode picture buffer) or replace_top_pic_with_frame

encode_one_frame START initialization FIELD_CODING YES 依之前選擇FIELD_CODING 與 ADAPTIVE_CODING的取向, store_picture_in_dpb (decode picture buffer) or replace_top_pic_with_frame Field picture編碼 NO writeout picture Frame picture編碼 ADAPTIVE_CODING NO 收尾 YES Field picture編碼 比較Field picture 與Frame picture 那一個效果好, 並更新context return

encode_one_frame initialization START TIMER 1. start time ms 2. start time s put_buffer_frame() 把指標指向frame

encode_one_frame initialization START TIMER 1. start time ms 2. start time s put_buffer_frame() 把指標指向frame structure, 但注意其中 不該包含field結構 init_frame() 初始化一個new frame 的參數 Calculate. Frame. Number() 計算img-> & input-> 的 absolute frame number Read. One. Frame() 利用buf 2 img() 從file裡讀取一個frame Padd. Auto. Crop. Borders() 填補picture的邊界, 因為 其邊界不見得一定為 macroblock/macroblock pair size的倍數 設定direct mode與 deblocking filter的參數 有input->sp 2_frame_indicator YES sp 2_frame_indicator=1 read_SP_coefficients( ) 讀取SP frames的係數 NO sp 2_frame_indicator=0 initialization 結束

encode_one_frame START initialization FIELD_CODING YES 依之前選擇FIELD_CODING 與 ADAPTIVE_CODING的取向, store_picture_in_dpb (decode picture buffer) or replace_top_pic_with_frame

encode_one_frame START initialization FIELD_CODING YES 依之前選擇FIELD_CODING 與 ADAPTIVE_CODING的取向, store_picture_in_dpb (decode picture buffer) or replace_top_pic_with_frame Field picture編碼 NO writeout picture Frame picture編碼 ADAPTIVE_CODING NO 收尾 YES Field picture編碼 比較Field picture 與Frame picture 那一個效果好, 並更新context return

encode_one_frame : Field Encoding START if ( input->RCEnable ) generic_RC->Field. Control=1 img->field_picture = 1

encode_one_frame : Field Encoding START if ( input->RCEnable ) generic_RC->Field. Control=1 img->field_picture = 1 field_picture (top_pic, bottom_pic) 利用top與bottom field, encode a field picture img->fld_flag = 1 field encoding完成, set flag Field Encoding 結束

encode_one_frame : NOT Field Encoding update. QP() 以rc mode決定update. QP的type 會影響each frame的quantization parameter START

encode_one_frame : NOT Field Encoding update. QP() 以rc mode決定update. QP的type 會影響each frame的quantization parameter START if ( input->RCEnable ) generic_RC->Field. Control=0 frame_picture () encode a frame picture if if (input->Mb. Interlace) mb_adaptive = 1 else img->field_picture = 0 encode a frame picture if else if(input->RCEnable) 依input->RDPicture. Decision可能執行 copy_rc_jvt( quadratic_RC_init, quadratic_RC ) 與copy_rc_generic( generic_RC_init, generic_RC ) to copy jvt(joint video team) rate control objects rc_init_pict() initialize one picture rd. Picture. Coding() 對同一個picture在不同狀態下, 執行multipass encoding output_SP_coefficients( ) 如果是SP slice的話, output 其coefficients if (input->Mb. Interlace) mb_adaptive = 0 如果待會要進行 field code, 要把MB level field/frame coding flag turn off NOT Field Encoding 結束

encode_one_frame : Adaptive Encoding START if ( input->RCEnable ) generic_RC->Field. Control=1 img->write_macroblock = 0

encode_one_frame : Adaptive Encoding START if ( input->RCEnable ) generic_RC->Field. Control=1 img->write_macroblock = 0 img->bot_MB = 0 encode field, img->field_picture = 1 update_field_frame_contexts (img->fld_flag) 決定要set的是frame context or field context field_picture () encode a field picture if (input-> RCEnable) 以fld_flag決定 generic_RC->Field. Frame 0 or 1 dis_fld dis_frm Adaptive Encoding結束 picture_structure_decision() 傳入frame_pic, top_pic, bottom_pic 呼叫decide_fld_frame() 決定fld_flag 0 or 1

encode_one_frame START initialization FIELD_CODING YES 依之前選擇FIELD_CODING 與 ADAPTIVE_CODING的取向, store_picture_in_dpb (decode picture buffer) or replace_top_pic_with_frame

encode_one_frame START initialization FIELD_CODING YES 依之前選擇FIELD_CODING 與 ADAPTIVE_CODING的取向, store_picture_in_dpb (decode picture buffer) or replace_top_pic_with_frame Field picture編碼 NO writeout picture Frame picture編碼 ADAPTIVE_CODING NO 收尾 YES Field picture編碼 比較Field picture 與Frame picture 那一個效果好, 並更新context return

encode_one_frame: output START field mode img->fld_flag frame mode frame_mod_buffer() 設定frame mode buffer field_mod_buffer() 設定field

encode_one_frame: output START field mode img->fld_flag frame mode frame_mod_buffer() 設定frame mode buffer field_mod_buffer() 設定field mode buffer writeout picture() 根據rd_pass的值 write out a picture writeout picture() 輸入top_pic, bottom_pic 輸出buffer內的 encoded picture free_slice_list() 把buffer清空 if(input->RCEnable) rc_update_pict_frame() 更新rate control 參數 END

encode_one_frame START initialization FIELD_CODING YES 依之前選擇FIELD_CODING 與 ADAPTIVE_CODING的取向, store_picture_in_dpb (decode picture buffer) or replace_top_pic_with_frame

encode_one_frame START initialization FIELD_CODING YES 依之前選擇FIELD_CODING 與 ADAPTIVE_CODING的取向, store_picture_in_dpb (decode picture buffer) or replace_top_pic_with_frame Field picture編碼 NO writeout picture Frame picture編碼 ADAPTIVE_CODING NO 收尾 YES Field picture編碼 比較Field picture 與Frame picture 那一個效果好, 並更新context return

encode_one_frame: 收尾 1 如果是frame_coding Update. Decoders() 模擬packet loss的狀態 Update. Pixel. Map() find_snr () Calculate

encode_one_frame: 收尾 1 如果是frame_coding Update. Decoders() 模擬packet loss的狀態 Update. Pixel. Map() find_snr () Calculate PSNR for Y, U and V. redundant pictures save reconstruction to calculate SNR and replace reference picture stop 2 timers

encode_one_frame: 收尾 2 如果是adaptive_coding store_picture_in_dpb() store bottom field in decoded picture buffer free_storable_picture() 將picture清掉

encode_one_frame: 收尾 2 如果是adaptive_coding store_picture_in_dpb() store bottom field in decoded picture buffer free_storable_picture() 將picture清掉 或replace_top_pic_with_frame () replace top pic with frame free_storable_picture() 將picture清掉 else store_picture_in_dpb (frame 或 bottom pics, 端看rd_pass) free_storable_picture() Report( I_SLICE or SP_SLICE or B_SLICE ) Update. RCModel

Overview 1. encode_one_frame 2. encode_enhancement_layer encode_one_frame Main encode_one_redundant_frame Encode_enhancement_layer

Overview 1. encode_one_frame 2. encode_enhancement_layer encode_one_frame Main encode_one_redundant_frame Encode_enhancement_layer

encode_enhancement_layer-功能 • 以Hierarchical. Coding決定 1. encoding order 2. 自訂的encoding order • order決定完成, Encoding B

encode_enhancement_layer-功能 • 以Hierarchical. Coding決定 1. encoding order 2. 自訂的encoding order • order決定完成, Encoding B frames

encode_enhancement_layerhierarchical. Coding(1) create_hierarchy() 1.

encode_enhancement_layerhierarchical. Coding(1) create_hierarchy() 1.

encode_enhancement_layerhierarchical. Coding(2)

encode_enhancement_layerhierarchical. Coding(2)

encode_enhancement_layerhierarchical. Coding(3) User decides.

encode_enhancement_layerhierarchical. Coding(3) User decides.

encode_enhancement_layer. Code Structure if(input->Hierarchical. Coding) set the parameter delta_pic_order_cnt[0] encode_one_frame() else set the parameter

encode_enhancement_layer. Code Structure if(input->Hierarchical. Coding) set the parameter delta_pic_order_cnt[0] encode_one_frame() else set the parameter delta_pic_order_cnt[0] encode_one_frame()

encode_enhancement_layerimportant variables IMG_NUMBER: #define IMG_NUMBER (img->number start_frame_no_in_this_IGOP) <global. h> img->number: current image number to

encode_enhancement_layerimportant variables IMG_NUMBER: #define IMG_NUMBER (img->number start_frame_no_in_this_IGOP) <global. h> img->number: current image number to be encoded input->sucessive_Bframe: number of B frame will be used

input->BRef. Pictures: B coded reference pictures replace P pictures (0: not used, 1: used)

input->BRef. Pictures: B coded reference pictures replace P pictures (0: not used, 1: used) input->Num. Frames. In. ELSub. Seq number of frames in the Enhanced Scalability Layer. 0 (default) means that no Enhancement Layer is used.

encode_enhancement_layersetting values • img->frame_num 該frame的編號 • img->nal_reference_idc 標示其會不會被refernce到 • img->bottompoc pic order count of

encode_enhancement_layersetting values • img->frame_num 該frame的編號 • img->nal_reference_idc 標示其會不會被refernce到 • img->bottompoc pic order count of bottom field of a frame • img->b_frame_to_code 被encode的b frame編號 • img->b_interval

setting values • NALU_PRIORITY_HIGH

setting values • NALU_PRIORITY_HIGH

encode_enhancement_layer-example

encode_enhancement_layer-example

encode_enhancement_layer-other ordering principle 對每一個intra_period, 通知client decoder去 清空buffer

encode_enhancement_layer-other ordering principle 對每一個intra_period, 通知client decoder去 清空buffer