Skip to content
New issue

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

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

Already on GitHub? # to your account

Change main.cpp and zh264encoder.cpp #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 12 additions & 4 deletions main.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "zoptions.h"

#include <string>
#include <iostream>

#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
Expand All @@ -21,9 +22,9 @@ struct Region {
struct UserData {
ZH264Encoder *encoder;
ZPath output;
int framecount;
float baseqp;
ZList<Region> regions;
zu64 framecount;
};

bool brear = false;
Expand Down Expand Up @@ -53,7 +54,7 @@ void decoderCallback(zu32 num, AVFrame *frame, AVPacket *pkt, const ZH264Decoder
LOG("Output Setup: " << encoder->outputSetup(frame->width, frame->height, decode->getFPS()));
encoder->infmt = decode->context->pix_fmt;

userdata->framecount = 0;
//userdata->framecount = 120;

// Set up regions in macroblocks
zu32 xblocks = frame->width / 16 + (frame->width % 16 ? 1 : 0);
Expand Down Expand Up @@ -82,9 +83,9 @@ void decoderCallback(zu32 num, AVFrame *frame, AVPacket *pkt, const ZH264Decoder

encoder->encode(frame->data, frame->linesize);

//userdata->framecount = decode->getFrameCount();
//userdata->framecount = 120;

if(num % 10 == 0){
if(num % 1 == 0){
RLOG("\r" << "Update: " << num << "/" << userdata->framecount);
}
if(num == userdata->framecount){
Expand All @@ -96,9 +97,11 @@ void decoderCallback(zu32 num, AVFrame *frame, AVPacket *pkt, const ZH264Decoder
}
}

#define OPT_FC "framecount"
#define OPT_QP "quanta"
#define OPT_FPS "fps"
const ZArray<ZOptions::OptDef> optdef = {
{ OPT_FC, 'c', ZOptions::INTEGER },
{ OPT_QP, 'q', ZOptions::STRING },
{ OPT_FPS, 'F', ZOptions::STRING },
};
Expand Down Expand Up @@ -129,6 +132,10 @@ int main(int argc, char **argv){
ZPath input = args[0];
ZPath output = args[1];

int framecount = 0;
if(options.getOpts().contains(OPT_FC))
framecount = stoi(options.getOpts()[OPT_FC].str());

float baseqp = 0;
if(options.getOpts().contains(OPT_QP))
baseqp = stof(options.getOpts()[OPT_QP].str());
Expand Down Expand Up @@ -164,6 +171,7 @@ int main(int argc, char **argv){
ZH264Encoder encoder;
userdata.output = output;
userdata.encoder = &encoder;
userdata.framecount = framecount;
userdata.baseqp = baseqp;
userdata.regions = regions;

Expand Down
8 changes: 4 additions & 4 deletions zh264encoder.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ bool ZH264Encoder::outputSetup(zu64 width, zu64 height, zu32 fps){
}

bool ZH264Encoder::validSettings(){
if(inwidth > 0 && inheight > 0 &&
outwidth > 0 && outheight > 0 && outfps > 0)
return true;
return false;
if(inwidth < 0 || inheight < 0 ||
outwidth < 0 || outheight < 0 || outfps < 0)
return false;
return true;
}

bool ZH264Encoder::open(ZPath path){
Expand Down