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 }
#define ERR
Definition: NetdevLog.h:9
rs2_format
A stream&#39;s format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:59
static bool isCompressionSupported(rs2_format t_format, rs2_stream t_streamType)
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
static std::shared_ptr< ICompression > getObject(int t_width, int t_height, rs2_format t_format, rs2_stream t_streamType, int t_bpp)
static bool & getIsEnabled()
ZipMethod


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:12