Skip to content

Commit

Permalink
Merge pull request IntelRealSense#9 from IntelRealSense/mchanan_compr…
Browse files Browse the repository at this point in the history
…esstion-flag

add compresstion flag -DCOMPRESSION=ON
  • Loading branch information
mchanan authored Dec 23, 2019
2 parents 23b5aa3 + c3579d1 commit c2356ea
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/ethernet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ target_link_libraries(${PROJECT_NAME}
${ZLIB_LIBRARIES}
)

if(COMPRESSION)
add_definitions(-DCOMPRESSION)
endif()

target_include_directories(${PROJECT_NAME} PUBLIC "rtsp_client/*.h")

target_include_directories(${PROJECT_NAME} PUBLIC ${LIVE}/groupsock/include ${LIVE}/liveMedia/include ${LIVE}/UsageEnvironment/include ${LIVE}/BasicUsageEnvironment/include inc)
Expand Down
6 changes: 6 additions & 0 deletions src/ethernet/ethernet-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ void sig_handler(int signo)
rs2::ethernet_device::ethernet_device()
{
dev = rs2_create_software_device(NULL);
#ifdef COMPRESSION
idecomress = decompressFrameFactory::create(zipMethod::gzip);
#endif
}

rs2::ethernet_device::ethernet_device(std::string url) : ethernet_device()
Expand Down Expand Up @@ -168,13 +170,17 @@ void rs2::ethernet_device::pull_from_queue(int stream_index)
//const std::lock_guard<std::mutex> lock(mtx);
Frame* frame = frame_queues[stream_index].front();
frame_queues[stream_index].pop();
#ifdef COMPRESSION
if (stream_index == 0) {
// depth
idecomress->decompressFrame((unsigned char *)frame->m_buffer, frame->m_size, (unsigned char*)(last_frame[stream_index].pixels));
} else {
// other -> color
#endif
memcpy(last_frame[stream_index].pixels, frame->m_buffer, frame->m_size);
#ifdef COMPRESSION
}
#endif
// delete frame;
last_frame[stream_index].timestamp = frame->m_timestamp.tv_sec;
last_frame[stream_index].frame_number++;
Expand Down
4 changes: 4 additions & 0 deletions tools/rs-server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ find_package(ZLIB REQUIRED)

target_link_libraries(rs-server ${DEPENDENCIES} realsense2 ${ZLIB_LIBRARIES})

if(COMPRESSION)
add_definitions(-DCOMPRESSION)
endif()

set_target_properties (rs-server PROPERTIES
FOLDER Tools
)
Expand Down
15 changes: 6 additions & 9 deletions tools/rs-server/RsSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ void RsDeviceSource::doGetNextFrame()
void RsDeviceSource::deliverRSFrame()
{
*/
#ifdef COMPRESSION
IcompressFrame* iCompress = compressFrameFactory::create(zipMethod::gzip);
#endif
if (!isCurrentlyAwaitingData())
{
envir() << "isCurrentlyAwaitingData returned false"<<fParams.sensorID<<"\n";
Expand All @@ -127,21 +129,16 @@ void RsDeviceSource::deliverRSFrame()
gettimeofday(&fPresentationTime, NULL); // If you have a more accurate time - e.g., from an encoder - then use that instead.
//// memmove(fTo, frame.get_data(), fFrameSize);
//// unsigned char b[640*480*2];
#ifdef COMPRESSION
if(fParams.sensorID == 0)
{
#if 0
unsigned char compressedBuf[fFrameSize];
// memset(fbuf, 0, fFrameSize);
unsigned int newSize = iCompress->compressFrame(fbuf, fFrameSize, compressedBuf);
envir() << "Compression income " << fFrameSize << ", outcome " << newSize << "\n";
// memmove(fTo, compressedBuf, fFrameSize);
memmove(fTo, compressedBuf, newSize + sizeof(unsigned int));
#else
iCompress->compressFrame(fbuf, fFrameSize, fTo);
#endif
} else {
#endif
memmove(fTo, fbuf, 640*480*2);
#ifdef COMPRESSION
}
#endif
// After delivering the data, inform the reader that it is now available:
FramedSource::afterGetting(this);
}
Expand Down

0 comments on commit c2356ea

Please sign in to comment.