MPEG-4 features
The following features are supported for MPEG-4:
Info
The "info" feature for MPEG-4 exports some information about the
picture type and the macroblock types. This feature is purely
informative, no changes here will be applied back when transplicating.
TODO: string:
Picture type. This can either be:
"I"forI-frames"P"forP-frames"B"forB-frames"S"forS(GMC)-frames
TODO: boolean:
- true for interlaced frame (note: I have never seen a file that has this set to true)
- false for non-interlaced frame
TODO: string: (optional when interlaced is true)
- top for top field.
- bottom for bottom field;
TODO:
nullif the macroblock was skipped- a
string, where each letter in the string corresponds to a certain macroblock feature:'I'for anintramacroblock (I,P, andS(GMC)frames)'a'for macroblocks withAC Prediction(Iframes)'q'for macroblocks that change thequantization scale(I,P,B, andS(GMC)frames)'f'for forward motion vectors (P,B, andS(GMC)frames)'b'for backward motion vectors (Bframes)'d'for direct motion vectors (Bframes)'G'forGlobal Motion Compensation(S(GMC)frames)'4'for macroblocks with 48x8motion vectors instead of 116x16(PandS(GMC)frames)'i'for Interlaced macroblocks (motion vectors are16x8in this case) (P,B, andS(GMC)frames)'1'for macroblocks that change theDCT coefficientsof the first luma block'2'for macroblocks that change theDCT coefficientsof the second luma block'3'for macroblocks that change theDCT coefficientsof the third luma block'4'for macroblocks that change theDCT coefficientsof the fourth luma block'5'for macroblocks that change theDCT coefficientsof the U chroma block'6'for macroblocks that change theDCT coefficientsof the V chroma block
Motion vectors
The "mv" feature for MPEG-4 exports the motion vectors that are
encoded in the bitstream.
There may be "forward" and "backward" motion vectors.
TODO: MV:
nullif there is no motion vector delta for this macroblock- an
Arraywith two numbers, the first beinghorizontaland the second beingvertical. - an
Arraywith 4 elements (in the case where there are 4 motion vectors per macroblock). Each element is eithernullor anArraywith two numbers, the first beinghorizontaland the second beingvertical.
TODO: (informative) fcode:
fcodeis anArraywith two numbers, the first beinghorizontaland the second beingvertical.- This field is informative. It tells you the
fcodethat was encoded for this frame. This can be used to calculate the minimum and maximum values allowed for the motion vectors. - For
MPEG-4, the motion vector range is calculated by:const min_val = -(1<<(4 + fcode)); const max_val = (1<<(4 + fcode))-1;
TODO: string:
- The
"overflow"field will instructFFglitchon what to do when it imports motion vector values that overflow the limit defined byfcode. Possible values are:"assert": exitsFFglitchon overflow."truncate": truncates motion vector values within range (I suggest using this one)."ignore": does nothing (allows overflow)."warn": warns once, but then ignores.
Motion vectors (delta only)
The "mv_delta" feature for MPEG-4 is similar to the "mv" feature,
but the motion vectors are expressed as a delta value from the
previous motion vector.
There may be "forward" and "backward" motion vectors.
TODO: MV_delta:
nullif there is no motion vector delta for this macroblock- an
Arraywith two numbers, the first beinghorizontaland the second beingvertical. - an
Arraywith 4 elements (in the case where there are 4 motion vectors per macroblock). Each element is eithernullor anArraywith two numbers, the first beinghorizontaland the second beingvertical.
TODO: (informative) fcode:
fcodeis anArraywith two numbers, the first beinghorizontaland the second beingvertical.- This field is informative. It tells you the
fcodethat was encoded for this frame. This can be used to calculate the minimum and maximum values allowed for the motion vectors. - For
MPEG-4, the motion vector range is calculated by:const min_val = -(1<<(4 + fcode)); const max_val = (1<<(4 + fcode))-1;
TODO: string:
- The
"overflow"field will instructFFglitchon what to do when it imports motion vector values that overflow the limit defined byfcode. Possible values are:"assert": exitsFFglitchon overflow."truncate": truncates motion vector values within range (I suggest using this one)."ignore": does nothing (allows overflow)."warn": warns once, but then ignores.
Macroblock
The "mb" feature for MPEG-4 exports the bytestream of each
macroblock as a string value.
Macroblocks are mostly self-sufficient, so it might be possible to reorder them and still have a valid bitstream.
TODO: macroblock:
nullif the macroblock was skipped.- a
stringwith the hexadecimal representation of the bytestream for this macroblock
TODO: (informative) number:
- the size in bits of the macroblock. This is used by FFglitch to properly align the bitstream when transplicating. Do not change these values.
Global motion compensation
The "gmc" feature for MPEG-4 exports the Global Motion Compensation
parameters for a frame.
gmc is an Array with up to 3 elements, each being an Array with 2
numbers each.
I don’t remember how the gmc calculation is done.
I’ll document this later if anyone reeeeally wants it.