Skip to content

Commit

Permalink
PRt IntelRealSense#12427 from OhadMeir/Coverity
Browse files Browse the repository at this point in the history
Fix Coverity issues
  • Loading branch information
OhadMeir authored Nov 20, 2023
2 parents 11878e6 + d5e33ec commit 2b5fecb
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 56 deletions.
2 changes: 0 additions & 2 deletions src/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ frame::frame( frame && r )
*this = std::move( r );
if( owner )
metadata_parsers = owner->get_md_parsers();
if( r.metadata_parsers )
metadata_parsers = std::move( r.metadata_parsers );
}

frame & frame::operator=( frame && r )
Expand Down
4 changes: 2 additions & 2 deletions src/fw-logs/fw-log-data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace librealsense
{
namespace fw_logs
{
fw_log_data::fw_log_data(void)
fw_log_data::fw_log_data()
{
_magic_number = 0;
_severity = 0;
Expand All @@ -34,7 +34,7 @@ namespace librealsense
}


fw_log_data::~fw_log_data(void)
fw_log_data::~fw_log_data()
{
}

Expand Down
98 changes: 50 additions & 48 deletions src/gl/colorizer-gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ namespace librealsense
_depth_units = df->get_units();
bool disparity = f.get_profile().format() == RS2_FORMAT_DISPARITY32 ? true : false;

auto gf = dynamic_cast<gpu_addon_interface*>((frame_interface*)res.get());

uint32_t depth_texture;
uint32_t hist_texture = _cm_texture;

Expand Down Expand Up @@ -290,64 +288,68 @@ namespace librealsense
}
}

uint32_t output_rgb;
gf->get_gpu_section().output_texture(0, &output_rgb, TEXTYPE_RGB);
glBindTexture(GL_TEXTURE_2D, output_rgb);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _width, _height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

gf->get_gpu_section().set_size(_width, _height);

glBindFramebuffer(GL_FRAMEBUFFER, _fbo->get());
glDrawBuffer(GL_COLOR_ATTACHMENT0);

glBindTexture(GL_TEXTURE_2D, output_rgb);
_fbo->createTextureAttachment(output_rgb);

_fbo->bind();
glClearColor(1, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);

auto& shader = (colorize_shader&)_viz->get_shader();
shader.begin();
float max = _max;;
float min = _min;;
if (disparity)
if( auto gf = dynamic_cast< gpu_addon_interface * >( (frame_interface *)res.get() ) )
{
auto __min = _min;
if (__min < 1e-6f) { __min = 1e-6f; } // Min value set to prevent zero division. only when _min is zero.
max = (_d2d_convert_factor / (__min)) * _depth_units + .5f;
min = (_d2d_convert_factor / (_max)) * _depth_units + .5f;
}
shader.set_params(_depth_units, min, max, MAX_DISPARITY, _equalize, disparity);
shader.end();
uint32_t output_rgb = 0;
gf->get_gpu_section().output_texture( 0, &output_rgb, TEXTYPE_RGB );
glBindTexture( GL_TEXTURE_2D, output_rgb );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, _width, _height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

glActiveTexture(GL_TEXTURE0 + shader.histogram_slot());
glBindTexture(GL_TEXTURE_2D, hist_texture);
gf->get_gpu_section().set_size( _width, _height );

glActiveTexture(GL_TEXTURE0 + shader.color_map_slot());
glBindTexture(GL_TEXTURE_2D, _cm_texture);
glBindFramebuffer(GL_FRAMEBUFFER, _fbo->get());
glDrawBuffer(GL_COLOR_ATTACHMENT0);

glActiveTexture(GL_TEXTURE0 + shader.texture_slot());
glBindTexture(GL_TEXTURE_2D, depth_texture);
glBindTexture(GL_TEXTURE_2D, output_rgb);
_fbo->createTextureAttachment(output_rgb);

_viz->draw_texture(depth_texture);
_fbo->bind();
glClearColor(1, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);

glActiveTexture(GL_TEXTURE0 + shader.texture_slot());
auto& shader = (colorize_shader&)_viz->get_shader();
shader.begin();
float max = _max;;
float min = _min;;
if (disparity)
{
auto __min = _min;
if (__min < 1e-6f) { __min = 1e-6f; } // Min value set to prevent zero division. only when _min is zero.
max = (_d2d_convert_factor / (__min)) * _depth_units + .5f;
min = (_d2d_convert_factor / (_max)) * _depth_units + .5f;
}
shader.set_params(_depth_units, min, max, MAX_DISPARITY, _equalize, disparity);
shader.end();

_fbo->unbind();
glActiveTexture(GL_TEXTURE0 + shader.histogram_slot());
glBindTexture(GL_TEXTURE_2D, hist_texture);

glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE0 + shader.color_map_slot());
glBindTexture(GL_TEXTURE_2D, _cm_texture);

if (!f.is<rs2::gl::gpu_frame>())
{
if (_equalize)
glActiveTexture(GL_TEXTURE0 + shader.texture_slot());
glBindTexture(GL_TEXTURE_2D, depth_texture);

_viz->draw_texture(depth_texture);

glActiveTexture(GL_TEXTURE0 + shader.texture_slot());

_fbo->unbind();

glBindTexture(GL_TEXTURE_2D, 0);

if (!f.is<rs2::gl::gpu_frame>())
{
glDeleteTextures(1, &hist_texture);
if (_equalize)
{
glDeleteTextures(1, &hist_texture);
}
glDeleteTextures(1, &depth_texture);
}
glDeleteTextures(1, &depth_texture);
}

},
[this]{
_enabled = false;
Expand Down
4 changes: 2 additions & 2 deletions src/proc/units-transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ namespace librealsense

if (new_f && _depth_units)
{
auto ptr = dynamic_cast<librealsense::depth_frame*>((librealsense::frame_interface*)new_f.get());
auto orig = dynamic_cast<librealsense::depth_frame*>((librealsense::frame_interface*)f.get());
auto ptr = reinterpret_cast< librealsense::frame_interface * >( new_f.get() );
auto orig = reinterpret_cast< librealsense::frame_interface * >( f.get() );

auto depth_data = (uint16_t*)orig->get_frame_data();
auto new_data = (float*)ptr->get_frame_data();
Expand Down
1 change: 0 additions & 1 deletion src/rs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ class calibration_change_callback : public rs2_calibration_change_callback
{
// Shouldn't get called...
throw std::runtime_error( "calibration_change_callback::release() ?!?!?!" );
delete this;
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/software-sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,11 @@ frame_interface * software_sensor::allocate_new_frame( rs2_extension extension,
stream_profile_interface * profile,
frame_additional_data && data )
{
auto frame_number = data.frame_number; // For logging
auto frame = _source.alloc_frame( extension, 0, std::move( data ), false );
if( ! frame )
{
LOG_WARNING( "Failed to allocate frame " << data.frame_number << " type " << extension );
LOG_WARNING( "Failed to allocate frame " << frame_number << " type " << extension );
}
else
{
Expand Down

0 comments on commit 2b5fecb

Please sign in to comment.