COMMON: FORMATS: Implement vmhd atom parsing for QuickTime movies

This commit implements vmhd (Video Media Information Header) atom parsing for QuickTime movies.
It contains information about the video track's graphics mode and opcolor.
This commit is contained in:
Krish 2024-06-18 19:13:53 +05:30 committed by Eugene Sandulenko
parent fc34902998
commit d704b8e959
2 changed files with 29 additions and 1 deletions

View File

@ -164,7 +164,7 @@ void QuickTimeParser::initParseTable() {
{ &QuickTimeParser::readDefault, MKTAG('u', 'd', 't', 'a') },
{ &QuickTimeParser::readCTYP, MKTAG('c', 't', 'y', 'p') },
{ &QuickTimeParser::readNAVG, MKTAG('N', 'A', 'V', 'G') },
{ &QuickTimeParser::readLeaf, MKTAG('v', 'm', 'h', 'd') },
{ &QuickTimeParser::readVMHD, MKTAG('v', 'm', 'h', 'd') },
{ &QuickTimeParser::readCMOV, MKTAG('c', 'm', 'o', 'v') },
{ &QuickTimeParser::readWAVE, MKTAG('w', 'a', 'v', 'e') },
{ &QuickTimeParser::readESDS, MKTAG('e', 's', 'd', 's') },
@ -667,6 +667,16 @@ int QuickTimeParser::readSTTS(Atom atom) {
return 0;
}
int QuickTimeParser::readVMHD(Atom atom) {
Track *track = _tracks.back();
_fd->readUint32BE(); // version + flags
track->graphicsMode = (GraphicsMode)_fd->readUint16BE();
_fd->readMultipleBE(track->opcolor);
return 0;
}
int QuickTimeParser::readSTCO(Atom atom) {
Track *track = _tracks.back();
@ -1037,6 +1047,8 @@ QuickTimeParser::Track::Track() {
mediaDuration = 0;
nlvlFrom = -1;
nlvlTo = -1;
graphicsMode = GraphicsMode::COPY;
opcolor[0] = opcolor[1] = opcolor[2] = 0;
}
QuickTimeParser::Track::~Track() {

View File

@ -144,6 +144,18 @@ protected:
CODEC_TYPE_MIDI
};
enum class GraphicsMode {
COPY = 0x0, // Directly copy the source image over the destination.
DITHER_COPY = 0x40, // Dither the image (if needed), otherwise copy.
BLEND = 0x20, // Blend source and destination pixel colors using opcolor values.
TRANSPARENT = 0x24, // Replace destination with source if not equal to opcolor.
STRAIGHT_ALPHA = 0x100, // Blend source and destination pixels, with the proportion controlled by the alpha channel.
PREMUL_WHITE_ALPHA = 0x101, // Blend after removing pre-multiplied white from the source.
PREMUL_BLACK_ALPHA = 0x102, // Blend after removing pre-multiplied black from the source.
STRAIGHT_ALPHA_BLEND = 0x104, // Similar to straight alpha, but the alpha for each channel is combined with the corresponding opcolor channel.
COMPOSITION = 0x103 // Render offscreen and then dither-copy to the main screen (tracks only).
};
struct PanoramaNode {
uint32 nodeID;
uint32 timestamp;
@ -195,6 +207,9 @@ protected:
int16 nlvlTo;
PanoramaInformation panoInfo;
GraphicsMode graphicsMode; // Transfer mode
uint16 opcolor[3]; // RGB values used in the transfer mode specified by graphicsMode.
};
enum class MovieType {
@ -277,6 +292,7 @@ private:
int readSTSS(Atom atom);
int readSTSZ(Atom atom);
int readSTTS(Atom atom);
int readVMHD(Atom atom);
int readCMOV(Atom atom);
int readWAVE(Atom atom);
int readESDS(Atom atom);