|
@@ -24,6 +24,7 @@ extern "C"
|
|
|
#include <thread>
|
|
|
|
|
|
#include "modulecomm.h"
|
|
|
+#include "xmlparam.h"
|
|
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
#include <opencv2/core.hpp>
|
|
@@ -57,6 +58,7 @@ int gnoutsize = 0;
|
|
|
static char * gstrwidth ="1280";
|
|
|
static char * gstrheight = "720";
|
|
|
int gnwidth,gnheight;
|
|
|
+int gnframerate = 4000000;
|
|
|
|
|
|
void * gpaout;
|
|
|
|
|
@@ -103,8 +105,8 @@ static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt,
|
|
|
std::cout<<"time: "<<std::chrono::system_clock::now().time_since_epoch().count()/1000000<<std::endl;
|
|
|
printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size);
|
|
|
iv::modulecomm::ModuleSendMsg(gpaout,(char *)pkt->data,pkt->size);
|
|
|
- gFile.write((char *)pkt->data,pkt->size);
|
|
|
- gFile.flush();
|
|
|
+// gFile.write((char *)pkt->data,pkt->size);
|
|
|
+// gFile.flush();
|
|
|
// fwrite(pkt->data, 1, pkt->size, outfile);
|
|
|
av_packet_unref(pkt);
|
|
|
}
|
|
@@ -182,10 +184,10 @@ void ThreadEnc()
|
|
|
|
|
|
|
|
|
/* put sample parameters */
|
|
|
- c->bit_rate = 4000000;
|
|
|
+ c->bit_rate = gnframerate;
|
|
|
/* resolution must be a multiple of two */
|
|
|
- c->width = 1280;
|
|
|
- c->height = 720;
|
|
|
+ c->width = gnwidth;
|
|
|
+ c->height = gnheight;
|
|
|
/* frames per second */
|
|
|
|
|
|
c->time_base = (AVRational){1, 30};
|
|
@@ -271,7 +273,7 @@ void ThreadEnc()
|
|
|
if (ret < 0)
|
|
|
exit(1);
|
|
|
|
|
|
- yuvI420ToNV12(strbuf,1280,720,strbufnv12);
|
|
|
+ yuvI420ToNV12(strbuf,gnwidth,gnheight,strbufnv12);
|
|
|
memcpy(frame->data[0],strbufnv12,gnwidth*gnheight);
|
|
|
memcpy(frame->data[1],strbufnv12 + gnwidth*gnheight,gnwidth*gnheight*1/2);
|
|
|
// memcpy(frame->data[2],strbuf+gnwidth*gnheight+gnwidth*gnheight/4,gnwidth*gnheight/4);
|
|
@@ -343,16 +345,33 @@ int main(int argc, char *argv[])
|
|
|
{
|
|
|
QCoreApplication a(argc, argv);
|
|
|
|
|
|
+ QString strpath = QCoreApplication::applicationDirPath();
|
|
|
+// QString apppath = strpath;
|
|
|
+ if(argc < 2)
|
|
|
+ strpath = strpath + "/driver_h264_enc.xml";
|
|
|
+ else
|
|
|
+ strpath = argv[1];
|
|
|
+ std::cout<<strpath.toStdString()<<std::endl;
|
|
|
+
|
|
|
gFile.setFileName("/home/yuchuli/test1.mp4");
|
|
|
gFile.open(QIODevice::ReadWrite);
|
|
|
|
|
|
+ iv::xmlparam::Xmlparam xp(strpath.toStdString());
|
|
|
+
|
|
|
+ std::string strpicname = xp.GetParam("picname",std::string("image00"));
|
|
|
+ std::string strh264name = xp.GetParam("h264name",std::string("h264front"));
|
|
|
+
|
|
|
+ std::string strwidth = xp.GetParam("width",std::string("1920"));
|
|
|
+ std::string strheight = xp.GetParam("height",std::string("1080"));
|
|
|
+ gnframerate = xp.GetParam("framerate",4000000);
|
|
|
+
|
|
|
gstrbuffer = new char[30000000];
|
|
|
gstrout = new char[10000000];
|
|
|
- gnwidth = atoi(gstrwidth);
|
|
|
- gnheight = atoi(gstrheight);
|
|
|
+ gnwidth = atoi(strwidth.data());
|
|
|
+ gnheight = atoi(strheight.data());
|
|
|
|
|
|
- void * pa = iv::modulecomm::RegisterRecv("picfront",Listenpic);
|
|
|
- gpaout = iv::modulecomm::RegisterSend("h264front",1000000,1);
|
|
|
+ void * pa = iv::modulecomm::RegisterRecv(strpicname.data(),Listenpic);
|
|
|
+ gpaout = iv::modulecomm::RegisterSend(strh264name.data(),1000000,1);
|
|
|
std::thread * pthreadenc = new std::thread(ThreadEnc);
|
|
|
return a.exec();
|
|
|
}
|