CompressionFactory.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #include "CompressionFactory.h"
5 #include "JpegCompression.h"
6 #include "Lz4Compression.h"
7 #include "RvlCompression.h"
8 
9 std::shared_ptr<ICompression> CompressionFactory::getObject(int t_width, int t_height, rs2_format t_format, rs2_stream t_streamType, int t_bpp)
10 {
11  ZipMethod zipMeth;
12  if(t_streamType == RS2_STREAM_COLOR || t_streamType == RS2_STREAM_INFRARED)
13  {
14  zipMeth = ZipMethod::jpeg;
15  }
16  else if(t_streamType == RS2_STREAM_DEPTH)
17  {
18  zipMeth = ZipMethod::lz;
19  }
20  if(!isCompressionSupported(t_format, t_streamType))
21  {
22  return nullptr;
23  }
24 
25  switch(zipMeth)
26  {
27  case ZipMethod::rvl:
28  return std::make_shared<RvlCompression>(t_width, t_height, t_format, t_bpp);
29  break;
30  case ZipMethod::jpeg:
31  return std::make_shared<JpegCompression>(t_width, t_height, t_format, t_bpp);
32  break;
33  case ZipMethod::lz:
34  return std::make_shared<Lz4Compression>(t_width, t_height, t_format, t_bpp);
35  break;
36  default:
37  ERR << "unknown zip method";
38  return nullptr;
39  }
40 }
41 
43 {
44  static bool m_isEnabled = true;
45  return m_isEnabled;
46 }
47 
49 {
50  if(getIsEnabled() == 0)
51  {
52  return false;
53  }
54 
55  if((t_streamType == RS2_STREAM_COLOR || t_streamType == RS2_STREAM_INFRARED) && (t_format != RS2_FORMAT_BGR8 && t_format != RS2_FORMAT_RGB8 && t_format != RS2_FORMAT_Y8 && t_format != RS2_FORMAT_YUYV && t_format != RS2_FORMAT_UYVY))
56  {
57  return false;
58  }
59  return true;
60 }
JpegCompression.h
rvl
@ rvl
Definition: CompressionFactory.h:12
RvlCompression.h
jpeg
@ jpeg
Definition: CompressionFactory.h:13
ERR
#define ERR
Definition: NetdevLog.h:9
Lz4Compression.h
RS2_FORMAT_RGB8
@ RS2_FORMAT_RGB8
Definition: rs_sensor.h:66
RS2_STREAM_COLOR
@ RS2_STREAM_COLOR
Definition: rs_sensor.h:46
CompressionFactory::getIsEnabled
static bool & getIsEnabled()
Definition: CompressionFactory.cpp:42
RS2_FORMAT_YUYV
@ RS2_FORMAT_YUYV
Definition: rs_sensor.h:65
rs2_format
rs2_format
A stream's format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:59
ZipMethod
ZipMethod
Definition: CompressionFactory.h:9
RS2_STREAM_DEPTH
@ RS2_STREAM_DEPTH
Definition: rs_sensor.h:45
CompressionFactory::getObject
static std::shared_ptr< ICompression > getObject(int t_width, int t_height, rs2_format t_format, rs2_stream t_streamType, int t_bpp)
Definition: CompressionFactory.cpp:9
CompressionFactory::isCompressionSupported
static bool isCompressionSupported(rs2_format t_format, rs2_stream t_streamType)
Definition: CompressionFactory.cpp:48
lz
@ lz
Definition: CompressionFactory.h:14
RS2_FORMAT_UYVY
@ RS2_FORMAT_UYVY
Definition: rs_sensor.h:75
RS2_FORMAT_Y8
@ RS2_FORMAT_Y8
Definition: rs_sensor.h:70
RS2_STREAM_INFRARED
@ RS2_STREAM_INFRARED
Definition: rs_sensor.h:47
CompressionFactory.h
rs2_stream
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
RS2_FORMAT_BGR8
@ RS2_FORMAT_BGR8
Definition: rs_sensor.h:67


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:13:15