MPEG-2 features
The following features are supported for MPEG-2:
- Info
- Quantized DCT coefficients
- Quantized DCT coefficients (with DC delta)
- Quantized DCT coefficients (DC only)
- Quantized DCT coefficients (DC delta only)
- Motion vectors
- Motion vectors (delta only)
- Quantization scale
- Macroblock
Info
The "info" feature for MPEG-2 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
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, andBframes)'q'for macroblocks that change thequantization scale(I,P, andBframes)'c'for macroblocks that change theDCT coefficients(PandBframes)'f'for forward motion vectors (PandBframes)'b'for backward motion vectors (Bframes)
Quantized DCT coefficients
The "q_dct" feature for MPEG-2 exports the quantized coefficients of
the DCT transform that are encoded in the bitstream.
TODO: number:
- The
DCcoefficient for this block.
TODO: number:
- An
ACcoefficient for this block (from 1 to 63), in thezig-zagscan order.
TODO: (informative) number:
- The count of
verticalblocks per macroblock for each component.
TODO: (informative) number:
- The count of
horizontalblocks per macroblock for each component.
TODO: (informative) number:
- The index for the
Quantization Tablefor each plane, as defined in the"dqt"feature.
Quantized DCT coefficients (with DC delta)
The "q_dct_delta" feature for MPEG-2 is similar to the "q_dct" feature,
but the DC coefficient is expressed as a delta value from the previous
DC coefficient.
Note that the previous DC coefficient is not necessarily the one from
the block immediately to the left since there might be multiple blocks
inside a macroblock, which will be encoded in a raster scan order (left
to right, top to bottom) per-macroblock.
TODO: number:
- The
DCcoefficient delta for this block.
TODO: number:
- An
ACcoefficient for this block (from 1 to 63), in thezig-zagscan order.
TODO: (informative) number:
- The count of
verticalblocks per macroblock for each component.
TODO: (informative) number:
- The count of
horizontalblocks per macroblock for each component.
TODO: (informative) number:
- The index for the
Quantization Tablefor each plane, as defined in the"dqt"feature.
Quantized DCT coefficients (DC only)
The "q_dc" feature for MPEG-2 is similar to the "q_dct" feature,
but only the DC coefficients are available.
TODO: number:
- The
DCcoefficient for this block.
TODO: (informative) number:
- The count of
verticalblocks per macroblock for each component.
TODO: (informative) number:
- The count of
horizontalblocks per macroblock for each component.
TODO: (informative) number:
- The index for the
Quantization Tablefor each plane, as defined in the"dqt"feature.
Quantized DCT coefficients (DC delta only)
The "q_dc_delta" feature for MPEG-2 is similar to the "q_dc" feature,
but the DC coefficient is expressed as a delta value from the previous
DC coefficient.
TODO: number:
- The
DCcoefficient delta for this block.
TODO: (informative) number:
- The count of
verticalblocks per macroblock for each component.
TODO: (informative) number:
- The count of
horizontalblocks per macroblock for each component.
TODO: (informative) number:
- The index for the
Quantization Tablefor each plane, as defined in the"dqt"feature.
Motion vectors
The "mv" feature for MPEG-2 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 for this macroblock- an
Arraywith 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-2, the motion vector range is calculated by:const min_val = -(1<<(3 + fcode)); const max_val = (1<<(3 + 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-2 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.
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-2, the motion vector range is calculated by:const min_val = -(1<<(3 + fcode)); const max_val = (1<<(3 + 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.
Quantization scale
The "qscale" feature for MPEG-2 exports the quantization scale value
for slices/macroblocks.
TODO
NOTE: this feature is not very thread-friendly in its current state in FFglitch. It will change in the future.
Macroblock
The "mb" feature for MPEG-2 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.