No.3 encode_one_slice() DeblockMb()

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
User-Defined Functions Like short programs Can operate on their own data Can receive data from callers and return data to callers.
What is shape function ? shape function is a function that will give the displacements inside an element if its displacement at all the node locations.
1 A HIGH THROUGHPUT PIPELINED ARCHITECTURE FOR H.264/AVC DEBLOCKING FILTER Kefalas Nikolaos, Theodoridis George VLSI Design Lab. Electrical & Computer.
CS110 Programming Language I
Lecture # 21 Chapter 6 Uptill 6.4. Type System A type system is a collection of rules for assigning type expressions to the various parts of the program.
Overview of the H. 264/AVC video coding standard.
H.264/AVC Baseline Profile Decoder Complexity Analysis Michael Horowitz, Anthony Joch, Faouzi Kossentini, and Antti Hallapuro IEEE TRANSACTIONS ON CIRCUITS.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
General Computer Science for Engineers CISC 106 Lecture 20 Dr. John Cavazos Computer and Information Sciences 04/08/2009.
CS 117 Spring 2002 Review for Exam 2 March 6, 2002 open book, 1 page of notes.
Loops Chapter 4. It repeats a set of statements while a condition is true. while (condition) { execute these statements; } “while” structures.
The If/Else Statement, Boolean Flags, and Menus Page 180
Adaptive Deblocking Filter in H.264 Ehsan Maani Course Project:
‘C’ LANGUAGE PRESENTATION.  C language was introduced by Dennis Ritchie..  It is a programming language, which can make a interaction between user and.
Unit 5 – “Watch Out!”. Introduction New Topics Case Structures New Functions Less? Comparison Function Ultrasonic Sensor.
Windows Media Video 9 Tarun Bhatia Multimedia Processing Lab University Of Texas at Arlington 11/05/04.
Stack. Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations on the data.
Chapter 5 Functions For All Subtasks. Void functions Do not return a value. Keyword void is used as the return type in the function prototype to show.
Loops and Iteration for Statements, while Statements and do-while Statements.
More arrays Primitive vs. reference parameters. Arrays as parameters to functions.
Current Assignments Homework 3 is due tonight. Iteration and basic functions. Exam 1 on Monday.
Codec structuretMyn1 Codec structure In an MPEG system, the DCT and motion- compensated interframe prediction are combined. The coder subtracts the motion-compensated.
PHY281Flow ControlSlide 1 Decisions In this section we will learn how to make decisions in a Java program  if Statements  if... else Statements  Comparison.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 7 Clicker Questions September 22, 2009.
ECE122 Feb. 22, Any question on Vehicle sample code?
CS – 1P Using Electronic Voting System (EVS) questioning in the Instructional Design for CS-1P.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
AP Computer Science edition Review 1 ArrayListsWhile loopsString MethodsMethodsErrors
Java Basics Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
CPSC1301 Computer Science 1 Chapter 8 Introduction to Processing Digital Sounds part 3.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Conditionals-part21 Conditionals – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
Exceptions Chapter 16 This chapter explains: What as exception is Why they are useful Java exception facilities.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Video Compression—From Concepts to the H.264/AVC Standard
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
Control Flow Graphs : The if Statement 1 if (x < y) { y = 0; x = x + 1; } else { x = y; } x >= yx < y x = y y = 0 x = x + 1 if (x < y) { y = 0;
AP Java Ch. 4 Review Question 1  Java methods can return only primitive types (int, double, boolean, etc).
Intro-Sound-Mod10-part31 Introduction to Processing Digital Sounds part 3 while loop, tracing, for loop, parameters Barb Ericson Georgia Institute of Technology.
Introduction to MPEG Video Coding Dr. S. M. N. Arosha Senanayake, Senior Member/IEEE Associate Professor in Artificial Intelligence Room No: M2.06
Introduction to Methods ISYS 350. Methods Methods can be used to break a complex program into small, manageable pieces – This approach is known as divide.
Learning Javascript From Mr Saem
X264 Code Tracing 陳俊達. Outlines x264_macroblock_cache_load x264_ratecontrol_mb x264_macroblock_cache_save x264_cabac_mb_skip macroblock.c/315.
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
H.264/AVC Reference Software Group 3 11 簡嘉宏 /05/22.
1 Dr. Chow-Sing LinRecursion - CH 10 Problem Solving and Program Design in C Chapter 9 Recursion Chow-Sing Lin.
X.264 Code Tracing Group 薛伊倩 張書瑜 游智詮 邱漢坤 王芳瑜 張宇蓓 廖航緯.
C++ Lesson 1.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Yanal Alahmad Java Workshop Yanal Alahmad
Yanal Alahmad Java Workshop Yanal Alahmad
H.264/AVC code tracing REPORT Group 1. no Tsao.
Chapter 5: Loops and Files.
null, true, and false are also reserved.
Stack Memory 2 (also called Call Stack)
Supplement, Chapters 6 MC Course, 2009.
An Introduction to Java – Part I, language basics
ENEE 631 Project Video Codec and Shot Segmentation
Introduction to Processing Digital Sounds part 3
Selection Statements.
Code Refresher Test #1 Topics:
H.264 code tracing Group 徐君潔.
Introduction to Computer Science
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
Introduction to Programming
CSS161: Fundamentals of Computing
Presentation transcript:

No.3 encode_one_slice() DeblockMb() Relation of Functions Encode_one_slice() Code_a_picture() DeblockFrame() DeblockMb()

H.264 Code Tracing encode_one_slice() No.3 9762642 陳則伊

Introduction-caller and main function “slice.c” Caller: code_a_picture() Main function of encode_one_slice(): Encode a slice group Execute PAFF / MBAFF mode

Introduction-input and output int SliceGroupId Picture *pic int TotalCodedMBs Output: int NumberOfCodedMBs

Local Variables Boolean end_of_slice = FALSE; Boolean recode_macroblock; int len; //# of bits of header used in a slice int NumberOfCodedMBs = 0; //return int CurrentMbAddr; double FrameRDCost = DBL_MAX; double FieldRDCost = DBL_MAX;

Initializations CurrentMbAddr = FmoGetFirstMacroblockInSlice (SliceGroupId); init_slice (CurrentMbAddr); SetLagrangianMultipliers(); len = start_slice ();

Main function code(1) Loop over MBs in a slice while (end_of_slice == FALSE) { -Encode by PAFF mode -Encode by MBAFF mode } terminate_slice(……); return NumberOfCodedMBs;

Main function code(2) Calculate the quantization offset parameters if (img->AdaptiveRounding && input->AdaptRndPeriod && (img->current_mb_nr % input->AdaptRndPeriod == 0)) { CalculateOffsetParam(); if(input->Transform8x8Mode) CalculateOffset8Param(); }

Main function code(3)-PAFF Use PAFF mode if (!img->MbaffFrameFlag) { recode_macroblock = FALSE; rdopt = &rddata_top_frame_mb; start_macroblock (CurrentMbAddr, FALSE); encode_one_macroblock (); write_one_macroblock (1); terminate_macroblock (&end_of_slice, &recode_macroblock); ……

Main function code(4)-PAFF If MB don’t need to be recoded …… if (recode_macroblock == FALSE) { CurrentMbAddr = FmoGetNextMBNr (CurrentMbAddr); if (CurrentMbAddr == -1) // end of slice end_of_slice = TRUE; NumberOfCodedMBs++; proceed2nextMacroblock (); }

Main function code(5)-PAFF If MB need to be recoded …… else{ img->current_mb_nr = FmoGetPreviousMBNr(img->current_mb_nr); if(img->current_mb_nr == -1 ) error (errortext, 300); } } // end of PAFF mode

Main function code(6)-MBAFF Check whether it is frame mode else{ //Use MBAFF mode if (input->MbInterlace == ADAPTIVE_CODING || input->MbInterlace == FRAME_MB_PAIR_CODING) { -Encode top MB as frame MB -Encode bottom MB as frame MB } ……

Main function code(7)-MBAFF Encode top MB as frame MB Set top MB coded as frame MB recode_macroblock = FALSE; img->field_mode = 0; // MB coded as frame img->top_field = 0; // Set top field to 0 Rate control img->write_macroblock = 0; img->bot_MB = 0; Encode one MB start_macroblock (CurrentMbAddr, FALSE); rdopt = &rddata_top_frame_mb; // store data in top frame MB encode_one_macroblock (); // code the MB as frame MB FrameRDCost = rdopt->min_rdcost;

Main function code(8)-MBAFF Encode bottom MB as frame MB Set bottom MB coded as frame MB img->field_mode = 0; // MB coded as frame MB Rate control img->bot_MB = 1; Encode one MB start_macroblock (CurrentMbAddr+1, FALSE); rdopt = &rddata_bot_frame_mb; // store data in bottom frame MB encode_one_macroblock (); // code the MB as frame MB FrameRDCost += rdopt->min_rdcost;

Main function code(9)-MBAFF Check whether it is field mode if ((input->MbInterlace == ADAPTIVE_CODING) || (input->MbInterlace == FIELD_CODING)) { -Encode top MB as field MB -Encode bottom MB as field MB }

Main function code(10)-MBAFF Encode top MB as field MB Set top MB coded as field MB img->field_mode = 1; // MB coded as field img->top_field = 1; // Set top field to 1 Rate control img->bot_MB = 0; Encode one MB start_macroblock (CurrentMbAddr, TRUE); rdopt = &rddata_top_field_mb; // store data in top field MB encode_one_macroblock (); // code the MB as field MB FieldRDCost = rdopt->min_rdcost;

Main function code(11)-MBAFF Encode bottom MB as field MB Set bottom MB coded as field MB img->top_field = 0; // Set top field to 0 Rate control img->bot_MB = 1; Encode one MB start_macroblock (CurrentMbAddr+1, TRUE); rdopt = &rddata_bot_field_mb; // store data in bottom field MB encode_one_macroblock (); // code the MB as field MB FieldRDCost += rdopt->min_rdcost;

Main function code(12)- MBAFF Decide between frame/field MB pair if ( ((input->MbInterlace == ADAPTIVE_CODING) && (FrameRDCost < FieldRDCost)) || input->MbInterlace == FRAME_MB_PAIR_CODING ) { img->field_mode = 0; //Frame MB MBPairIsField = 0; } else { img->field_mode = 1; //Field MB MBPairIsField = 1; }

Main function code(13)- MBAFF if (recode_macroblock == FALSE) { CurrentMbAddr = FmoGetNextMBNr (CurrentMbAddr); if (CurrentMbAddr == -1) // end of slice end_of_slice = TRUE; NumberOfCodedMBs++; proceed2nextMacroblock (); write_one_macroblock (0); //wrt bot MB to bitstream terminate_macroblock (&end_of_slice, &recode_macroblock); }

Main function code(14)- MBAFF else { img->current_mb_nr = FmoGetPreviousMBNr(img->current_mb_nr); if(img->current_mb_nr == -1 ) error (errortext, 300); } //End of MBAFF mode

Main function code(15)- End of encoding a Slice Group while (end_of_slice == FALSE) { -Encode by PAFF mode -Encode by MBAFF mode } terminate_slice ( (NumberOfCodedMBs+TotalCodedMBs >= (int)img->PicSizeInMbs) ); return NumberOfCodedMBs;

H.264 Code Tracing DeblockMb() No.3 9762642 陳則伊

Introduction-caller and goal “loopFilter.c” Caller: DeblockFrame() Goal: Deblocking filter for one MB No filter beyond picture boundary Compute strength values for one stripe in a MB Filters luma/chroma block edge for frame or field coded pictures

Introduction-input and output ImageParameters *img imgpel **imgY imgpel ***imgUV int MbQAddr //index of MB in a frame Output: void

Local Variables int EdgeCondition; int dir, edge; byte Strength[16]; int mb_x, mb_y; int filterNon8x8LumaEdgesFlag[4] = {1,1,1,1}; int filterLeftMbEdgeFlag; int filterTopMbEdgeFlag; int fieldModeMbFlag; int mvlimit = 4; int i, StrengthSum; Macroblock *MbQ; int edge_cr;

Main function code(1) img->DeblockCall = 1; get_mb_pos (MbQAddr, &mb_x, &mb_y, IS_LUMA); filterLeftMbEdgeFlag = (mb_x != 0); filterTopMbEdgeFlag = (mb_y != 0); MbQ = &(img->mb_data[MbQAddr]) ; // current Mb filterNon8x8LumaEdgesFlag[1] = filterNon8x8LumaEdgesFlag[3] = !(MbQ->luma_transform_size_8x8_flag);

Main function code(2) if (img->MbaffFrameFlag && mb_y == MB_BLOCK_SIZE && MbQ->mb_field) filterTopMbEdgeFlag = 0; fieldModeMbFlag = (img->structure!=FRAME) || (img->MbaffFrameFlag && MbQ->mb_field); if (fieldModeMbFlag) mvlimit = 2;

Main function code(3) if (MbQ->LFDisableIdc==1) { //return, if filter is disabled img->DeblockCall = 0; return; } if (MbQ->LFDisableIdc==2){ // don't filter at slice boundaries filterLeftMbEdgeFlag = MbQ->mbAvailA; filterTopMbEdgeFlag = (img->MbaffFrameFlag && !MbQ->mb_field && (MbQAddr & 0x01)) ? 1 : MbQ->mbAvailB; img->current_mb_nr = MbQAddr; CheckAvailabilityOfNeighbors();

Main function code(4) for( dir = 0 ; dir < 2 ; dir++ ) // 0=vertical edges; 1=horizontal { EdgeCondition = (dir && filterTopMbEdgeFlag) || (!dir && filterLeftMbEdgeFlag); for( edge=0; edge<4 ; edge++ ) // first 4 vertical strips of 16 pel { // then 4 horizontal if( edge || EdgeCondition ) edge_cr = chroma_edge[dir][edge][img->yuv_format]; GetStrength(Strength, img, MbQAddr, dir, edge << 2, mvlimit); StrengthSum = Strength[0]; ……

Main function code(5) for (i = 0; i < MB_BLOCK_SIZE; i++) { if (StrengthSum) break; StrengthSum += Strength[i]; } if( StrengthSum ) { // only if one of the 16 Strength bytes is != 0 if (filterNon8x8LumaEdgesFlag[edge]) EdgeLoopLuma( imgY, Strength, img, MbQAddr, MbQ->LFAlphaC0Offset, MbQ->LFBetaOffset, dir, edge << 2, img->width) ; if( (imgUV != NULL) && (edge_cr >= 0)) { EdgeLoopChroma( imgUV[0], Strength, img, MbQAddr, MbQ->LFAlphaC0Offset, MbQ->LFBetaOffset, dir, edge_cr, img->width_cr, 0) ; EdgeLoopChroma( imgUV[1], Strength, img, MbQAddr, MbQ->LFAlphaC0Offset, MbQ->LFBetaOffset, dir, edge_cr, img->width_cr, 1) ;

Main function code(6) if (dir && !edge && !MbQ->mb_field && mixedModeEdgeFlag) { // extra horizontal edge between a frame macroblock pair and a field img->DeblockCall = 2; GetStrength(Strength, img, MbQAddr, dir, MB_BLOCK_SIZE, mvlimit); ……

Main function code(7) if (filterNon8x8LumaEdgesFlag[edge]) EdgeLoopLuma( imgY, Strength, img, MbQAddr, MbQ->LFAlphaC0Offset, MbQ->LFBetaOffset, dir, 16, img->width) ; if( (imgUV != NULL) && (edge_cr >= 0)) { EdgeLoopChroma( imgUV[0], Strength, img, MbQAddr, MbQ->LFAlphaC0Offset, MbQ->LFBetaOffset, dir, MB_BLOCK_SIZE, img->width_cr, 0) ; EdgeLoopChroma( imgUV[1], Strength, img, MbQAddr, MbQ->LFAlphaC0Offset, MbQ->LFBetaOffset, dir, MB_BLOCK_SIZE, img->width_cr, 1) ; } img->DeblockCall = 1; } //end edge } //end loop dir img->DeblockCall = 0;