Commit 24f27633 authored by Clement Guedez's avatar Clement Guedez

avoid variable already defined in Intel MSDK

parent eaf11d86
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
#include <memory> #include <memory>
#define BUFFER_SIZE 32768 #define ENC_BUFFER_SIZE 32768
#define GOT_A_NAL_CROSS_BUFFER BUFFER_SIZE + 1 #define GOT_A_NAL_CROSS_BUFFER ENC_BUFFER_SIZE+1
#define GOT_A_NAL_INCLUDE_A_BUFFER BUFFER_SIZE + 2 #define GOT_A_NAL_INCLUDE_A_BUFFER ENC_BUFFER_SIZE+2
#define NO_MORE_BUFFER_TO_READ BUFFER_SIZE + 3 #define NO_MORE_BUFFER_TO_READ ENC_BUFFER_SIZE+3
namespace VideoStitch { namespace VideoStitch {
namespace Output { namespace Output {
......
...@@ -18,10 +18,10 @@ FILE *MockEncoder::fp_send; ...@@ -18,10 +18,10 @@ FILE *MockEncoder::fp_send;
MockEncoder::MockEncoder() { MockEncoder::MockEncoder() {
fp_send = fopen("C:\\Users\\nlz\\Videos\\edhec.h264", "rb"); fp_send = fopen("C:\\Users\\nlz\\Videos\\edhec.h264", "rb");
nalhead_pos = 0; nalhead_pos = 0;
m_nFileBufSize = BUFFER_SIZE; m_nFileBufSize = ENC_BUFFER_SIZE;
m_pFileBuf = (unsigned char *)malloc(BUFFER_SIZE); m_pFileBuf = (unsigned char *)malloc(ENC_BUFFER_SIZE);
m_pFileBuf_tmp = (unsigned char *)malloc(BUFFER_SIZE); m_pFileBuf_tmp = (unsigned char *)malloc(ENC_BUFFER_SIZE);
std::memset(m_pFileBuf, 0, BUFFER_SIZE); std::memset(m_pFileBuf, 0, ENC_BUFFER_SIZE);
read_buffer(m_pFileBuf, m_nFileBufSize); read_buffer(m_pFileBuf, m_nFileBufSize);
} }
...@@ -122,7 +122,7 @@ int MockEncoder::read_buffer(uint8_t *buf, int buf_size) { ...@@ -122,7 +122,7 @@ int MockEncoder::read_buffer(uint8_t *buf, int buf_size) {
int MockEncoder::readFirstNaluFromBuf(NaluUnit &nalu) { int MockEncoder::readFirstNaluFromBuf(NaluUnit &nalu) {
unsigned int naltail_pos; unsigned int naltail_pos;
std::memset(m_pFileBuf_tmp, 0, BUFFER_SIZE); std::memset(m_pFileBuf_tmp, 0, ENC_BUFFER_SIZE);
while (nalhead_pos < m_nFileBufSize) { while (nalhead_pos < m_nFileBufSize) {
// search for nal header // search for nal header
if (m_pFileBuf[nalhead_pos++] == 0x00 && m_pFileBuf[nalhead_pos++] == 0x00) { if (m_pFileBuf[nalhead_pos++] == 0x00 && m_pFileBuf[nalhead_pos++] == 0x00) {
...@@ -171,7 +171,7 @@ int MockEncoder::readOneNaluFromBuf(NaluUnit &nalu, int (*read_buffer)(uint8_t * ...@@ -171,7 +171,7 @@ int MockEncoder::readOneNaluFromBuf(NaluUnit &nalu, int (*read_buffer)(uint8_t *
unsigned int naltail_pos = nalhead_pos; unsigned int naltail_pos = nalhead_pos;
int ret; int ret;
int nalustart; int nalustart;
std::memset(m_pFileBuf_tmp, 0, BUFFER_SIZE); std::memset(m_pFileBuf_tmp, 0, ENC_BUFFER_SIZE);
nalu.size = 0; nalu.size = 0;
for (;;) { for (;;) {
if (nalhead_pos == NO_MORE_BUFFER_TO_READ) return FALSE; if (nalhead_pos == NO_MORE_BUFFER_TO_READ) return FALSE;
...@@ -197,7 +197,7 @@ int MockEncoder::readOneNaluFromBuf(NaluUnit &nalu, int (*read_buffer)(uint8_t * ...@@ -197,7 +197,7 @@ int MockEncoder::readOneNaluFromBuf(NaluUnit &nalu, int (*read_buffer)(uint8_t *
// again to get the rest part of this nal // again to get the rest part of this nal
if (nalhead_pos == GOT_A_NAL_CROSS_BUFFER || nalhead_pos == GOT_A_NAL_INCLUDE_A_BUFFER) { if (nalhead_pos == GOT_A_NAL_CROSS_BUFFER || nalhead_pos == GOT_A_NAL_INCLUDE_A_BUFFER) {
nalu.size = nalu.size + naltail_pos - nalustart; nalu.size = nalu.size + naltail_pos - nalustart;
if (nalu.size > BUFFER_SIZE) { if (nalu.size > ENC_BUFFER_SIZE) {
m_pFileBuf_tmp_old = m_pFileBuf_tmp; //// save pointer in case realloc fails m_pFileBuf_tmp_old = m_pFileBuf_tmp; //// save pointer in case realloc fails
if ((m_pFileBuf_tmp = (unsigned char *)realloc(m_pFileBuf_tmp, nalu.size)) == NULL) { if ((m_pFileBuf_tmp = (unsigned char *)realloc(m_pFileBuf_tmp, nalu.size)) == NULL) {
free(m_pFileBuf_tmp_old); // free original block free(m_pFileBuf_tmp_old); // free original block
...@@ -226,10 +226,10 @@ int MockEncoder::readOneNaluFromBuf(NaluUnit &nalu, int (*read_buffer)(uint8_t * ...@@ -226,10 +226,10 @@ int MockEncoder::readOneNaluFromBuf(NaluUnit &nalu, int (*read_buffer)(uint8_t *
if (naltail_pos >= m_nFileBufSize && nalhead_pos != GOT_A_NAL_CROSS_BUFFER && if (naltail_pos >= m_nFileBufSize && nalhead_pos != GOT_A_NAL_CROSS_BUFFER &&
nalhead_pos != GOT_A_NAL_INCLUDE_A_BUFFER) { nalhead_pos != GOT_A_NAL_INCLUDE_A_BUFFER) {
nalu.size = BUFFER_SIZE - nalhead_pos; nalu.size = ENC_BUFFER_SIZE - nalhead_pos;
nalu.type = m_pFileBuf[nalhead_pos] & 0x1f; nalu.type = m_pFileBuf[nalhead_pos] & 0x1f;
std::memcpy(m_pFileBuf_tmp, m_pFileBuf + nalhead_pos, nalu.size); std::memcpy(m_pFileBuf_tmp, m_pFileBuf + nalhead_pos, nalu.size);
if ((ret = read_buffer(m_pFileBuf, m_nFileBufSize)) < BUFFER_SIZE) { if ((ret = read_buffer(m_pFileBuf, m_nFileBufSize)) < ENC_BUFFER_SIZE) {
std::memcpy(m_pFileBuf_tmp + nalu.size, m_pFileBuf, ret); std::memcpy(m_pFileBuf_tmp + nalu.size, m_pFileBuf, ret);
nalu.size = nalu.size + ret; nalu.size = nalu.size + ret;
nalu.data = m_pFileBuf_tmp; nalu.data = m_pFileBuf_tmp;
...@@ -241,7 +241,7 @@ int MockEncoder::readOneNaluFromBuf(NaluUnit &nalu, int (*read_buffer)(uint8_t * ...@@ -241,7 +241,7 @@ int MockEncoder::readOneNaluFromBuf(NaluUnit &nalu, int (*read_buffer)(uint8_t *
continue; continue;
} }
if (nalhead_pos == GOT_A_NAL_CROSS_BUFFER || nalhead_pos == GOT_A_NAL_INCLUDE_A_BUFFER) { if (nalhead_pos == GOT_A_NAL_CROSS_BUFFER || nalhead_pos == GOT_A_NAL_INCLUDE_A_BUFFER) {
nalu.size = BUFFER_SIZE + nalu.size; nalu.size = ENC_BUFFER_SIZE + nalu.size;
m_pFileBuf_tmp_old = m_pFileBuf_tmp; //// save pointer in case realloc fails m_pFileBuf_tmp_old = m_pFileBuf_tmp; //// save pointer in case realloc fails
if ((m_pFileBuf_tmp = (unsigned char *)realloc(m_pFileBuf_tmp, nalu.size)) == NULL) { if ((m_pFileBuf_tmp = (unsigned char *)realloc(m_pFileBuf_tmp, nalu.size)) == NULL) {
...@@ -249,9 +249,9 @@ int MockEncoder::readOneNaluFromBuf(NaluUnit &nalu, int (*read_buffer)(uint8_t * ...@@ -249,9 +249,9 @@ int MockEncoder::readOneNaluFromBuf(NaluUnit &nalu, int (*read_buffer)(uint8_t *
return FALSE; return FALSE;
} }
std::memcpy(m_pFileBuf_tmp + nalu.size - BUFFER_SIZE, m_pFileBuf, BUFFER_SIZE); std::memcpy(m_pFileBuf_tmp + nalu.size - ENC_BUFFER_SIZE, m_pFileBuf, ENC_BUFFER_SIZE);
if ((ret = read_buffer(m_pFileBuf, m_nFileBufSize)) < BUFFER_SIZE) { if ((ret = read_buffer(m_pFileBuf, m_nFileBufSize)) < ENC_BUFFER_SIZE) {
std::memcpy(m_pFileBuf_tmp + nalu.size, m_pFileBuf, ret); std::memcpy(m_pFileBuf_tmp + nalu.size, m_pFileBuf, ret);
nalu.size = nalu.size + ret; nalu.size = nalu.size + ret;
nalu.data = m_pFileBuf_tmp; nalu.data = m_pFileBuf_tmp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment