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:
null
if the macroblock was skipped- a
string
, where each letter in the string corresponds to a certain macroblock feature:'I'
for anintra
macroblock (I
,P
, andS(GMC)
frames)'a'
for macroblocks withAC Prediction
(I
frames)'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 (B
frames)'d'
for direct motion vectors (B
frames)'G'
forGlobal Motion Compensation
(S(GMC)
frames)'4'
for macroblocks with 48x8
motion vectors instead of 116x16
(P
andS(GMC)
frames)'i'
for Interlaced macroblocks (motion vectors are16x8
in this case) (P
,B
, andS(GMC)
frames)'1'
for macroblocks that change theDCT coefficients
of the first luma block'2'
for macroblocks that change theDCT coefficients
of the second luma block'3'
for macroblocks that change theDCT coefficients
of the third luma block'4'
for macroblocks that change theDCT coefficients
of the fourth luma block'5'
for macroblocks that change theDCT coefficients
of the U chroma block'6'
for macroblocks that change theDCT coefficients
of 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
:
null
if there is no motion vector delta for this macroblock- an
Array
with two numbers, the first beinghorizontal
and the second beingvertical
. - an
Array
with 4 elements (in the case where there are 4 motion vectors per macroblock). Each element is eithernull
or anArray
with two numbers, the first beinghorizontal
and the second beingvertical
.
TODO: (informative) fcode
:
fcode
is anArray
with two numbers, the first beinghorizontal
and the second beingvertical
.- This field is informative. It tells you the
fcode
that 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 instructFFglitch
on what to do when it imports motion vector values that overflow the limit defined byfcode
. Possible values are:"assert"
: exitsFFglitch
on 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
:
null
if there is no motion vector delta for this macroblock- an
Array
with two numbers, the first beinghorizontal
and the second beingvertical
. - an
Array
with 4 elements (in the case where there are 4 motion vectors per macroblock). Each element is eithernull
or anArray
with two numbers, the first beinghorizontal
and the second beingvertical
.
TODO: (informative) fcode
:
fcode
is anArray
with two numbers, the first beinghorizontal
and the second beingvertical
.- This field is informative. It tells you the
fcode
that 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 instructFFglitch
on what to do when it imports motion vector values that overflow the limit defined byfcode
. Possible values are:"assert"
: exitsFFglitch
on 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
:
null
if the macroblock was skipped.- a
string
with 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.