Condividi tramite


First Part of Macroblock Control Command Structure

The first four members of a generic macroblock control command structure are always the same. The following table describes the members of the first part of this structure.

Member Description

wMBaddress

Specifies the macroblock address of the macroblock currently being processed.

wMBtype

Specifies the type of macroblock being processed. This member contains flags that indicate whether motion compensation is used to predict the value of the macroblock and what type of residual difference data is sent.

dwMB_SNL

Contains the two fields MBskipsFollowing (in the upper 8 bits) and MBdataLocation (in the lower 24 bits).

MBskipsFollowing specifies the number of skipped macroblocks to be generated following the current macroblock.

MBdataLocation is an index into the IDCT residual difference block data buffer, indicating the location of the residual difference data for the blocks of the current macroblock.

wPatternCode

Indicates whether residual difference data is sent for each block in the macroblock.

wMBaddress

The wMBaddress structure member specifies the macroblock address of the current macroblock in raster scan order. The following table shows examples of macroblock addresses.

Macroblock Address

top-left

Zero

top-right

wPicWidthInMBminus1

lower-left

wPicHeightInMBminus1 x (wPicWidthInMBminus1+1)

lower-right

(wPicHeightInMBminus1+1) x (wPicWidthInMBminus1+1) - 1

The wPicWidthInMBminus1 and wPicHeightInMBminus1 addresses are members of the DXVA_PictureParameters structure.

wMBtype

The wMBtype structure member specifies the type of macroblock being processed. This member contains a set of bits that define the way macroblocks and motion vectors are processed. The bPic4MVallowed, bPicScanMethod, bPicBackwardPrediction, bPicStructure, and bPicScanFixed addresses are members of the DXVA_PictureParametersstructure. The bConfigHostInverseScan address is a member of the DXVA_ConfigPictureDecode structure.

Bits Description

15 to 12

MvertFieldSel_3 (bit 15, the most significant) through MvertFieldSel_0 (bit 12)

Specifies vertical field selection for corresponding motion vectors sent later in the macroblock control command, as specified in the following tables. For frame-based motion with a frame picture structure (for example, for H.261 and H.263), these bits must all be zero. The bits in MvertFieldSel_0, MvertFieldSel_1, MvertFieldSel_2, and MvertFieldSel_3 correspond to the motion_vertical_field_select[r][s] bits in Section 6.3.17.2 of MPEG-2.

11

Reserved Bit. Must be zero.

10

HostResidDiff

Specifies whether spatial-domain residual difference decoded blocks are sent, or whether transform coefficients are sent for off-host IDCT for the current macroblock. Must be zero if bConfigResidDiffHost is zero. Must be 1 if bConfigResidDiffAccelerator is zero.

9 and 8

MotionType

Specifies the motion type in the picture. For example, for frame-based motion with a frame picture structure (as in H.261), bit 9 must be 1 and bit 8 must be zero.

The use of these bits corresponds directly to the use of the frame_motion_type or field_motion_type bits in Section 6.3.17.1 and Tables 6-17 and 6-18 of the MPEG-2 video standard when these bits are present in an MPEG-2 bitstream. The use of these bits is further explained following this table.

7 and 6

MBscanMethod

Specifies the macroblock scan method. This must be equal to bPicScanMethod if bPicScanFixed is 1. If HostResidDiff is 1, this variable has no meaning and these bits should be set to zero.

If bConfigHostInverseScan is zero, MBscanMethod must be one of the following values:

  • Bit 6 is zero and bit 7 is zero for zigzag scan (MPEG-2 Figure 7-2)

  • Bit 6 is 1 and bit 7 is zero for alternate-vertical scan (MPEG-2 Figure 7-3)

  • Bit 6 is zero and bit 7 is 1 for alternate-horizontal scan (H.263 Figure I.2 Part a)

If bConfigHostInverseScan is 1, MBscanMethod must be equal to the following value:

  • Bit 6 is 1 and bit 7 is 1 for arbitrary scan with absolute coefficient address.

5

FieldResidual

Indicates whether the residual difference blocks use a field IDCT structure as specified in MPEG-2.

This flag must be 1 if bPicStructure is 1 or 2. This flag must be zero when used for MPEG-2 if the frame_pred_frame_DCT flag in the MPEG-2 syntax is 1. This flag must be equal to the dct_type element of the MPEG-2 syntax when used for MPEG-2 if dct_type is present for the macroblock.

4

H261LoopFilter

Specifies whether the H.261 loop filter (Section 3.2.3 of H.261) is active for the current macroblock prediction. The H.261 loop filter is a separable ¼, ½, ¼ filter applied both horizontally and vertically to all six blocks in an H.261 macroblock, except at block edges where one of the taps would fall outside the block. In such cases, the filter is changed to have coefficients 0, 1, 0. Full arithmetic precision is retained with rounding to 8-bit integers at the output of the 2-D filter process (half-integer or higher values being rounded up).

3

Motion4MV

Indicates that forward motion uses a distinct motion vector for each of the four luminance blocks in the macroblock, as used in H.263 Annexes F and J. Motion4MV must be zero if MotionForward is zero or if bPic4MVallowed is zero.

2

MotionBackward

This variable is used as specified for the corresponding macroblock_motion_backward parameter in MPEG-2. If the bPicBackwardPrediction member of the DXVA_PictureParameters structure is zero, MotionBackward must be zero.

1

MotionForward

This variable is used as specified for the corresponding macroblock_motion_forward in MPEG-2. The use of this bit is further explained in the text following this table.

0

IntraMacroblock

Indicates that the macroblock is coded as intra and that no motion vectors are used for the current macroblock.

This variable corresponds to the macroblock_intra variable in MPEG-2. The use of this bit is further explained in the text following this table.

When macroblocks are predictively coded, they have associated motion vector values. The values are generated based on whether macroblocks are used for field-coded or frame-coded pictures. It is important for any implementation to properly account for every utilized macroblock type (especially for field-structured pictures or dual-prime motion).

The following two tables in this section indicate valid combinations of IntraMacroblock, MotionForward, MotionBackward, MotionType, MvertFieldSel, and MVector for frame-coded and field-coded pictures. MVector contains the horizontal and vertical components of a motion vector. The remaining variables and flags specify motion vector operation. This is determined according to the type of macroblock processed and whether macroblocks are being used for frame-coded or field-coded pictures.

The values shown in the following tables (in this section) occur for the following conditions:

  • H261LoopFilter, Motion4MV, and bPicOBMC are zero.

  • PicCurrentField flag is zero unless bPicStructure is 2 (bottom field). In this case, PicCurrentField is 1.

MVector is a member of the DXVA_MBctrl_P_HostResidDiff_1 and DXVA_MBctrl_P_OffHostIDCT_1 structures. The IntraMacroblock, MotionForward, MotionBackward, MotionType, MvertFieldSel, H261LoopFilter, and Motion4MV flags and variables are bitfields contained in the wMBtype member of the DXVA_MBctrl_P_HostResidDiff_1 and DXVA_MBctrl_P_OffHostIDCT_1 structures. bPicOBMC is a member of the DXVA_PictureParameters structure. The PicCurrentField flag is derived from the bPicStructure member of DXVA_PictureParameters.

The following considerations apply when reviewing the following tables in this section:

  • In a number of places, the MPEG-2 variable name PMV is used to indicate the value of a motion vector. This notation is used to distinguish between the PMV variable as defined in MPEG-2, which is in frame coordinates, and a motion vector that may be in field coordinates (in other words, at half-vertical resolution). In all cases, PMV refers to the value of PMV after it has been updated by the current motion vector value (as specified in MPEG-2 video Section 7.6.3.1).

  • The definitions of vector'[2][0] and vector'[3][0] are found in MPEG-2 Section 7.6.3.6. The left-shift operation shown indicates that the vertical component is modified to frame coordinates.

  • In both "no motion" cases (0,0,0), the macroblock parameters emulate a forward prediction macroblock (0,1,0) with a zero-valued motion vector. (See also MPEG-2 Section 7.6.3.5.)

  • The values shown for MotionType in single quotes are binary representations (the first number is for bit 9 and the second is for bit 8).

  • The left-shift operator in the first table applies only to the second value shown.

Frame-Structured Pictures

The following table shows the valid combinations of element settings for frame-structured pictures (when the bPicStructure member of the DXVA_PictureParameters structure is equal to 3).

IntraMacroblock, MotionForward, MotionBackward MotionType(meaning depends on picture type) MVector[0]MvertFieldSel_0 (1st, dir1) MVector[1]MvertFieldSel_1 (1st, dir2) MVector[2]MvertFieldSel_2 (2nd, dir1) MVector[3]MvertFieldSel_3 (2nd, dir2)

1,0,0 (intra)

'00' (intra)

-

-

-

-

-

-

-

-

0,0,0 (no motion)

'10' (no motion)

0

-

-

-

-

-

-

-

0,1,0

'10' (frame MC)

PMV[0][0]

-

-

-

-

-

-

-

0,0,1

'10' (frame MC)

-

-

PMV[0][1]

-

-

-

-

-

0,1,1

'10' (frame MC)

PMV[0][0]

-

PMV[0][1]

-

-

-

-

-

0,1,0

'01' (field MC)

PMV[0][0]

sel[0][0]

-

-

PMV[1][0]

sel[1][0]

-

-

0,0,1

'01' (field MC)

-

-

PMV[0][1]

sel[0][1]

-

-

PMV[1][1]

sel[1][1]

0,1,1

'01' (field MC)

PMV[0][0]

sel[0][0]

PMV[0][1]

sel[0][1]

PMV[1][0]

sel[1][0]

PMV[1][1]

sel[1][1]

0,1,0

'11' (dual-prime)

PMV[0][0]

0 (top)

vector'[2][0][0],

vector'[2][0][1]<<1

1 (bottom)

PMV[0][0]

1

vector'[3][0][0],

vector'[3][0][1]<<1

0

Field-Structured Pictures

The following table shows the valid combinations of element settings for field-structured pictures (when the bPicStructure member of the DXVA_PictureParameters structure is equal to 1 or 2).

IntraMacroblock, MotionForward, MotionBackward MotionType (meaning depends on picture type) MVector[0]MvertFieldSel_0 (1st, dir1) MVector[1]MvertFieldSel_1 (1st, dir2) MVector[2]MvertFieldSel_2 (2nd, dir1) MVector[3]MvertFieldSel_3(2nd, dir2)

1,0,0 (intra)

'00' (intra)

-

-

-

-

-

-

-

-

0,0,0 (no motion)

'01' (no motion)

0

PicCurrentField

-

-

-

-

-

-

0,1,0

'01' (field MC)

PMV[0][0]

sel[0][0]

-

-

-

-

-

-

0,0,1

'01' (field MC)

-

-

PMV[0][1]

sel[0][1]

-

-

-

-

0,1,1

'01' (field MC)

PMV[0][0]

sel[0][0]

PMV[0][1]

sel[0][1]

-

-

-

-

0,1,0

'10' (16x8 MC)

PMV[0][0]

sel[0][0]

-

-

PMV[1][0]

sel[1][0]

-

-

0,0,1

'10' (16x8 MC)

-

-

PMV[0][1]

sel[0][1]

-

-

PMV[1][1]

sel[1][1]

0,1,1

'10' (16x8 MC)

PMV[0][0]

sel[0][0]

PMV[0][1]

sel[0][1]

PMV[1][0]

sel[1][0]

PMV[1][1]

sel[1][1]

0,1,0

'11' (dual-prime)

PMV[0][0]

PicCurrentField

vector'[2][0]

PicCurrentField

-

-

-

-

Additional Valid Element Settings for Field and Frame Pictures

The remaining allowed cases for frame-structured and field-structured pictures are as follows.

Values Description

H261LoopFilter = 1

bPicOBMC = 0

Motion4MV = 0

Indicates that one forward-motion vector is sent in MVector[0] and that the H.261 loop filter is active for the forward prediction in the macroblock.

MotionForward must be 1 in this case, and IntraMacroblock and MotionBackward must both be zero.

bPicOBMC = 0

Motion4MV = 1

Indicates that four forward-motion vectors are sent in MVector[0] through MVector[3]. MotionForward must be 1 in this case, and IntraMacroblock must be zero.

If MotionBackward is 1, a fifth motion vector is sent for backward prediction in MVector[4].

bPicOBMC = 1

Motion4MV = 0

Indicates that 10 forward-motion vectors are sent in MVector[0] through MVector[9] for specification of OBMC motion, and that the values of the first four such motion vectors are all equal.

If MotionBackward is 1, an eleventh motion vector is sent for backward prediction in MVector[10].

bPicOBMC = 1

Motion4MV = 1

Indicates that 10 forward-motion vectors are sent in MVector[0] through MVector[9] for specification of OBMC motion, and that the values of the first four such motion vectors may differ from each other.

If MotionBackward is 1, an eleventh motion vector is sent for backward prediction in MVector[10].

Note   The average operator is mathematically identical ((s1+s2+1)>>1) for MPEG-1, MPEG-2 half-sample prediction filtering, bidirectional averaging, and dual prime same-opposite parity combining. The H.263 bidirectional averaging operator does not add the offset of +1 prior to right-shifting. The bBidirectionalAveragingMode member of DXVA_PictureParameters determines which of these methods is used.