|
@@ -76,6 +76,43 @@
|
|
|
|
|
|
using namespace std;
|
|
using namespace std;
|
|
|
|
|
|
|
|
+
|
|
|
|
+bool gbNewData = false;
|
|
|
|
+#include <QWaitCondition>
|
|
|
|
+#include <QMutex>
|
|
|
|
+
|
|
|
|
+QWaitCondition gwc;
|
|
|
|
+QMutex gWaitMutex;
|
|
|
|
+int gndatasize = 0;
|
|
|
|
+
|
|
|
|
+char * gstrbuffer;
|
|
|
|
+QMutex gMutexLock;
|
|
|
|
+
|
|
|
|
+bool gbNewOut = false;
|
|
|
|
+QWaitCondition gwcout;
|
|
|
|
+char * gstrout;
|
|
|
|
+QMutex gWaitMutexout;
|
|
|
|
+QMutex gMutexout;
|
|
|
|
+int gnoutsize = 0;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void read_grpc_frame(NvBuffer * buffer)
|
|
|
|
+{
|
|
|
|
+ while(gbNewData == false)
|
|
|
|
+ {
|
|
|
|
+ gWaitMutex.lock();
|
|
|
|
+ gwc.wait(&gWaitMutex,10);
|
|
|
|
+ gWaitMutex.unlock();
|
|
|
|
+ }
|
|
|
|
+ std::cout<<"grpc data. "<<std::endl;
|
|
|
|
+ gMutexLock.lock();
|
|
|
|
+ memcpy((char *) buffer->planes[0].data,gstrbuffer,gndatasize);
|
|
|
|
+ buffer->planes[0].bytesused = gndatasize;
|
|
|
|
+ gbNewData = false;
|
|
|
|
+ gMutexLock.unlock();
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Read the input NAL unit for h264/H265/Mpeg2/Mpeg4 decoder.
|
|
* Read the input NAL unit for h264/H265/Mpeg2/Mpeg4 decoder.
|
|
*
|
|
*
|
|
@@ -185,13 +222,17 @@ read_decoder_input_nalu(ifstream * stream, NvBuffer * buffer,
|
|
static int
|
|
static int
|
|
read_decoder_input_chunk(ifstream * stream, NvBuffer * buffer)
|
|
read_decoder_input_chunk(ifstream * stream, NvBuffer * buffer)
|
|
{
|
|
{
|
|
|
|
+ read_grpc_frame(buffer);
|
|
|
|
+ return 0;
|
|
/* Length is the size of the buffer in bytes */
|
|
/* Length is the size of the buffer in bytes */
|
|
streamsize bytes_to_read = MIN(CHUNK_SIZE, buffer->planes[0].length);
|
|
streamsize bytes_to_read = MIN(CHUNK_SIZE, buffer->planes[0].length);
|
|
|
|
|
|
stream->read((char *) buffer->planes[0].data, bytes_to_read);
|
|
stream->read((char *) buffer->planes[0].data, bytes_to_read);
|
|
|
|
+ std::cout<<"read chunk size: "<<bytes_to_read<<std::endl;
|
|
/* NOTE: It is necessary to set bytesused properly, so that decoder knows how
|
|
/* NOTE: It is necessary to set bytesused properly, so that decoder knows how
|
|
many bytes in the buffer are valid. */
|
|
many bytes in the buffer are valid. */
|
|
- buffer->planes[0].bytesused = stream->gcount();
|
|
|
|
|
|
+ buffer->planes[0].bytesused = stream->gcount();\
|
|
|
|
+ std::cout<<"read: "<<buffer->planes[0].bytesused<<std::endl;
|
|
if(buffer->planes[0].bytesused == 0)
|
|
if(buffer->planes[0].bytesused == 0)
|
|
{
|
|
{
|
|
stream->clear();
|
|
stream->clear();
|
|
@@ -927,6 +968,7 @@ static void *decoder_pollthread_fcn(void *arg)
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#include <chrono>
|
|
/**
|
|
/**
|
|
* Decoder capture thread loop function.
|
|
* Decoder capture thread loop function.
|
|
*
|
|
*
|
|
@@ -991,6 +1033,8 @@ dec_capture_loop_fcn(void *arg)
|
|
/* Decoder capture loop */
|
|
/* Decoder capture loop */
|
|
while (1)
|
|
while (1)
|
|
{
|
|
{
|
|
|
|
+// std::cout<<"start "<<std::chrono::system_clock::now().time_since_epoch().count()/1000000<<std::endl;
|
|
|
|
+
|
|
struct v4l2_buffer v4l2_buf;
|
|
struct v4l2_buffer v4l2_buf;
|
|
struct v4l2_plane planes[MAX_PLANES];
|
|
struct v4l2_plane planes[MAX_PLANES];
|
|
|
|
|
|
@@ -1103,7 +1147,11 @@ dec_capture_loop_fcn(void *arg)
|
|
if(ctx->capture_plane_mem_type == V4L2_MEMORY_DMABUF)
|
|
if(ctx->capture_plane_mem_type == V4L2_MEMORY_DMABUF)
|
|
dec_buffer->planes[0].fd = ctx->dmabuff_fd[v4l2_buf.index];
|
|
dec_buffer->planes[0].fd = ctx->dmabuff_fd[v4l2_buf.index];
|
|
/* Perform Blocklinear to PitchLinear conversion. */
|
|
/* Perform Blocklinear to PitchLinear conversion. */
|
|
|
|
+// std::cout<<"before "<<std::chrono::system_clock::now().time_since_epoch().count()/1000000<<std::endl;
|
|
|
|
+
|
|
ret = NvBufferTransform(dec_buffer->planes[0].fd, ctx->dst_dma_fd, &transform_params);
|
|
ret = NvBufferTransform(dec_buffer->planes[0].fd, ctx->dst_dma_fd, &transform_params);
|
|
|
|
+ // std::cout<<"after "<<std::chrono::system_clock::now().time_since_epoch().count()/1000000<<std::endl;
|
|
|
|
+
|
|
if (ret == -1)
|
|
if (ret == -1)
|
|
{
|
|
{
|
|
cerr << "Transform failed" << endl;
|
|
cerr << "Transform failed" << endl;
|
|
@@ -1122,10 +1170,20 @@ dec_capture_loop_fcn(void *arg)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ static int a = 1;
|
|
|
|
+ if(a > -1)
|
|
|
|
+ {
|
|
if (!ctx->stats && !ctx->disable_rendering)
|
|
if (!ctx->stats && !ctx->disable_rendering)
|
|
{
|
|
{
|
|
ctx->renderer->render(ctx->dst_dma_fd);
|
|
ctx->renderer->render(ctx->dst_dma_fd);
|
|
}
|
|
}
|
|
|
|
+ a = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ a++;
|
|
|
|
+
|
|
|
|
+// std::cout<<"after2 "<<std::chrono::system_clock::now().time_since_epoch().count()/1000000<<std::endl;
|
|
|
|
+
|
|
|
|
|
|
/* If not writing to file, Queue the buffer back once it has been used. */
|
|
/* If not writing to file, Queue the buffer back once it has been used. */
|
|
if(ctx->capture_plane_mem_type == V4L2_MEMORY_DMABUF)
|
|
if(ctx->capture_plane_mem_type == V4L2_MEMORY_DMABUF)
|
|
@@ -1551,6 +1609,7 @@ check_capture_buffers:
|
|
return eos;
|
|
return eos;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#include <chrono>
|
|
/**
|
|
/**
|
|
* Decode processing function for blocking mode.
|
|
* Decode processing function for blocking mode.
|
|
*
|
|
*
|
|
@@ -1586,7 +1645,10 @@ static bool decoder_proc_blocking(context_t &ctx, bool eos, uint32_t current_fil
|
|
/* dequeue a buffer for output plane. */
|
|
/* dequeue a buffer for output plane. */
|
|
if(allow_DQ)
|
|
if(allow_DQ)
|
|
{
|
|
{
|
|
|
|
+ std::cout<<"dq "<<std::chrono::system_clock::now().time_since_epoch().count()/1000000<< std::endl;
|
|
ret = ctx.dec->output_plane.dqBuffer(v4l2_buf, &buffer, NULL, -1);
|
|
ret = ctx.dec->output_plane.dqBuffer(v4l2_buf, &buffer, NULL, -1);
|
|
|
|
+ std::cout<<"out dq "<<std::chrono::system_clock::now().time_since_epoch().count()/1000000<< std::endl;
|
|
|
|
+
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
{
|
|
{
|
|
cerr << "Error DQing buffer at output plane" << endl;
|
|
cerr << "Error DQing buffer at output plane" << endl;
|
|
@@ -2139,48 +2201,60 @@ cleanup:
|
|
return -error;
|
|
return -error;
|
|
}
|
|
}
|
|
|
|
|
|
-/**
|
|
|
|
- * Start of video Decode application.
|
|
|
|
- *
|
|
|
|
- * @param argc : Argument Count
|
|
|
|
- * @param argv : Argument Vector
|
|
|
|
- */
|
|
|
|
-int
|
|
|
|
-main(int argc, char *argv[])
|
|
|
|
|
|
+
|
|
|
|
+void StartDecode()
|
|
{
|
|
{
|
|
- /* create decoder context. */
|
|
|
|
context_t ctx;
|
|
context_t ctx;
|
|
- int ret = 0;
|
|
|
|
- /* save decode iterator number */
|
|
|
|
- int iterator_num = 0;
|
|
|
|
-
|
|
|
|
int targc = 3;
|
|
int targc = 3;
|
|
char * targv[3];
|
|
char * targv[3];
|
|
targv[0] = "videoc_encode";
|
|
targv[0] = "videoc_encode";
|
|
targv[1] = "H264";
|
|
targv[1] = "H264";
|
|
targv[2] = "/home/nvidia/testh264.mp4";
|
|
targv[2] = "/home/nvidia/testh264.mp4";
|
|
-// targv[2] = strwidth;
|
|
|
|
-// targv[3] = strheight;
|
|
|
|
-
|
|
|
|
-// targv[5] = "/home/nvidia/testh264.mp4";
|
|
|
|
-
|
|
|
|
- do
|
|
|
|
- {
|
|
|
|
- /* Invoke video decode function. */
|
|
|
|
- ret = decode_proc(ctx,targc,targv);
|
|
|
|
- // ret = decode_proc(ctx, argc, argv);
|
|
|
|
- iterator_num++;
|
|
|
|
- } while((ctx.stress_test != iterator_num) && ret == 0);
|
|
|
|
-
|
|
|
|
- /* Report application run status on exit. */
|
|
|
|
- if (ret)
|
|
|
|
- {
|
|
|
|
- cout << "App run failed" << endl;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- cout << "App run was successful" << endl;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return ret;
|
|
|
|
|
|
+ int ret = decode_proc(ctx,targc,targv);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Start of video Decode application.
|
|
|
|
+ *
|
|
|
|
+ * @param argc : Argument Count
|
|
|
|
+ * @param argv : Argument Vector
|
|
|
|
+ */
|
|
|
|
+//int
|
|
|
|
+//main(int argc, char *argv[])
|
|
|
|
+//{
|
|
|
|
+// /* create decoder context. */
|
|
|
|
+// context_t ctx;
|
|
|
|
+// int ret = 0;
|
|
|
|
+// /* save decode iterator number */
|
|
|
|
+// int iterator_num = 0;
|
|
|
|
+
|
|
|
|
+// int targc = 3;
|
|
|
|
+// char * targv[3];
|
|
|
|
+// targv[0] = "videoc_encode";
|
|
|
|
+// targv[1] = "H264";
|
|
|
|
+// targv[2] = "/home/nvidia/testh264.mp4";
|
|
|
|
+//// targv[2] = strwidth;
|
|
|
|
+//// targv[3] = strheight;
|
|
|
|
+
|
|
|
|
+//// targv[5] = "/home/nvidia/testh264.mp4";
|
|
|
|
+
|
|
|
|
+// do
|
|
|
|
+// {
|
|
|
|
+// /* Invoke video decode function. */
|
|
|
|
+// ret = decode_proc(ctx,targc,targv);
|
|
|
|
+// // ret = decode_proc(ctx, argc, argv);
|
|
|
|
+// iterator_num++;
|
|
|
|
+// } while((ctx.stress_test != iterator_num) && ret == 0);
|
|
|
|
+
|
|
|
|
+// /* Report application run status on exit. */
|
|
|
|
+// if (ret)
|
|
|
|
+// {
|
|
|
|
+// cout << "App run failed" << endl;
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// {
|
|
|
|
+// cout << "App run was successful" << endl;
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// return ret;
|
|
|
|
+//}
|