Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOOLS: Restore support for DXA compression type 12 #68

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
TOOLS: Allow selecting the compression type in encode_dxa
  • Loading branch information
ccawley2011 committed Apr 4, 2023
commit d215dfe923d1696758357c3b7804b3e3a064ab37
26 changes: 19 additions & 7 deletions encode_dxa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class DxaEncoder {
int _width, _height, _framerate, _framecount, _workheight;
uint8 *_prevframe, *_prevpalette;
ScaleMode _scaleMode;
byte _compType;

byte *_codeBuf, *_dataBuf, *_motBuf, *_maskBuf;
void grabBlock(byte *frame, int x, int y, int blockw, int blockh, byte *block);
Expand All @@ -62,14 +63,14 @@ class DxaEncoder {
uLong m13encode(byte *frame, byte *outbuf);

public:
DxaEncoder(Tool &tool, Common::Filename filename, int width, int height, int framerate, ScaleMode scaleMode);
DxaEncoder(Tool &tool, Common::Filename filename, int width, int height, int framerate, ScaleMode scaleMode, byte compType);
~DxaEncoder();
void writeHeader();
void writeNULL();
void writeFrame(uint8 *frame, uint8 *palette);
};

DxaEncoder::DxaEncoder(Tool &tool, Common::Filename filename, int width, int height, int framerate, ScaleMode scaleMode) {
DxaEncoder::DxaEncoder(Tool &tool, Common::Filename filename, int width, int height, int framerate, ScaleMode scaleMode, byte compType) {
_dxa.open(filename, "wb");
_width = width;
_height = height;
Expand All @@ -79,6 +80,7 @@ DxaEncoder::DxaEncoder(Tool &tool, Common::Filename filename, int width, int hei
_prevpalette = new uint8[768];
_scaleMode = scaleMode;
_workheight = _scaleMode == S_NONE ? _height : _height / 2;
_compType = compType;

_codeBuf = new byte[_width * _height / 16];
_dataBuf = new byte[_width * _height];
Expand Down Expand Up @@ -145,7 +147,7 @@ void DxaEncoder::writeFrame(byte *frame, byte *palette) {
if (_framecount == 0)
compType = 2;
else
compType = 13;
compType = _compType;

switch (compType) {

Expand Down Expand Up @@ -536,7 +538,7 @@ uLong DxaEncoder::m13encode(byte *frame, byte *outbuf) {
return outb - outbuf;
}

EncodeDXA::EncodeDXA(const std::string &name) : CompressionTool(name, TOOLTYPE_COMPRESSION) {
EncodeDXA::EncodeDXA(const std::string &name) : CompressionTool(name, TOOLTYPE_COMPRESSION), _compType(13) {

ToolInput input;
input.format = "*.*";
Expand All @@ -548,6 +550,16 @@ EncodeDXA::EncodeDXA(const std::string &name) : CompressionTool(name, TOOLTYPE_C
"Output will be two files, one with .dxa extension and the other depending on the used audio codec.";
}

void EncodeDXA::parseExtraArguments() {
if (!_arguments.empty()) {
if (_arguments.front() == "-c") {
_arguments.pop_front();
_compType = atoi(_arguments.front().c_str());
_arguments.pop_front();
}
}
}

void EncodeDXA::execute() {
int width, height, framerate, frames;
ScaleMode scaleMode;
Expand All @@ -570,12 +582,12 @@ void EncodeDXA::execute() {
// read some data from the Bink or Smacker file.
readVideoInfo(&inpath, width, height, framerate, frames, scaleMode);

print("Width = %d, Height = %d, Framerate = %d, Frames = %d",
width, height, framerate, frames);
print("Width = %d, Height = %d, Framerate = %d, Frames = %d, Compression type = %d",
width, height, framerate, frames, _compType);

// create the encoder object
outpath.setExtension(".dxa");
DxaEncoder dxe(*this, outpath, width, height, framerate, scaleMode);
DxaEncoder dxe(*this, outpath, width, height, framerate, scaleMode, _compType);

// No sound block
dxe.writeNULL();
Expand Down
2 changes: 2 additions & 0 deletions encode_dxa.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ class EncodeDXA : public CompressionTool {
public:
EncodeDXA(const std::string &name = "encode_dxa");

virtual void parseExtraArguments();
virtual void execute();


protected:
byte _compType;

void convertWAV(const Common::Filename *inpath, const Common::Filename* outpath);
void readVideoInfo(Common::Filename *filename, int &width, int &height, int &framerate, int &frames, ScaleMode &scaleMode);
Expand Down