From 23dbf72563398a3c610f4148d63cf09c5233c002 Mon Sep 17 00:00:00 2001 From: kazars24 Date: Wed, 20 Apr 2022 14:39:34 +0300 Subject: [PATCH] Change main.cpp and zh264encoder.cpp --- main.cpp | 16 ++++++++++++---- zh264encoder.cpp | 8 ++++---- 2 files changed, 16 insertions(+), 8 deletions(-) mode change 100644 => 100755 main.cpp mode change 100644 => 100755 zh264encoder.cpp diff --git a/main.cpp b/main.cpp old mode 100644 new mode 100755 index fd5eb8a..c31c9f2 --- a/main.cpp +++ b/main.cpp @@ -6,6 +6,7 @@ #include "zoptions.h" #include +#include #include #include @@ -21,9 +22,9 @@ struct Region { struct UserData { ZH264Encoder *encoder; ZPath output; + int framecount; float baseqp; ZList regions; - zu64 framecount; }; bool brear = false; @@ -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); @@ -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){ @@ -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 optdef = { + { OPT_FC, 'c', ZOptions::INTEGER }, { OPT_QP, 'q', ZOptions::STRING }, { OPT_FPS, 'F', ZOptions::STRING }, }; @@ -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()); @@ -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; diff --git a/zh264encoder.cpp b/zh264encoder.cpp old mode 100644 new mode 100755 index 3ac0475..1abc461 --- a/zh264encoder.cpp +++ b/zh264encoder.cpp @@ -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){