Skip to content

Commit

Permalink
hotfix of get_stride to return values in bytes not pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
dorodnic committed Sep 5, 2016
1 parent 6e9b2ac commit 952e19a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/cpp-stride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main() try

if (frames_queue[i].try_dequeue(&frame))
{
buffers[i].upload(frame.get_data(), frame.get_width(), frame.get_height(), frame.get_format(), frame.get_stride());
buffers[i].upload(frame);
}

auto x = (i % 2) * (w / 2);
Expand Down
2 changes: 1 addition & 1 deletion examples/example.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class texture_buffer
const double timestamp = frame.get_timestamp();
if(timestamp != last_timestamp)
{
upload(frame.get_data(), frame.get_width(), frame.get_height(), frame.get_format(), frame.get_stride());
upload(frame.get_data(), frame.get_width(), frame.get_height(), frame.get_format(), (frame.get_stride() * 8) / frame.get_bpp());
last_timestamp = timestamp;

++num_frames;
Expand Down
8 changes: 4 additions & 4 deletions include/librealsense/rs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ extern "C" {
#endif

#define RS_API_MAJOR_VERSION 1
#define RS_API_MINOR_VERSION 9
#define RS_API_PATCH_VERSION 6
#define RS_API_MINOR_VERSION 10
#define RS_API_PATCH_VERSION 0

#define STRINGIFY(arg) #arg
#define VAR_ARG_STRING(arg) STRINGIFY(arg)
Expand Down Expand Up @@ -741,7 +741,7 @@ unsigned long long rs_get_detached_frame_number(const rs_frame_ref * frame, rs_e
const void * rs_get_detached_frame_data(const rs_frame_ref * frame, rs_error ** error);

/**
* retrive frame intrinsic width
* retrive frame intrinsic width in pixels
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return intrinsic width
*/
Expand All @@ -762,7 +762,7 @@ int rs_get_detached_frame_height(const rs_frame_ref * frame, rs_error ** error);
int rs_get_detached_framerate(const rs_frame_ref * frameset, rs_error ** error);

/**
* retrive frame stride, meaning the actual line width in memory (not the logical image width)
* retrive frame stride, meaning the actual line width in memory in bytes (not the logical image width)
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return frame pad crop
*/
Expand Down
2 changes: 2 additions & 0 deletions include/librealsense/rs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ namespace rs
return r;
}

// returns image width in pixels
int get_width() const
{
rs_error * e = nullptr;
Expand All @@ -420,6 +421,7 @@ namespace rs
return r;
}

// retrive frame stride, meaning the actual line width in memory in bytes (not the logical image width)
int get_stride() const
{
rs_error * e = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ int frame_archive::frame::get_framerate() const

int frame_archive::frame::get_stride() const
{
return additional_data.stride_x;
return (additional_data.stride_x * additional_data.bpp) / 8;
}

int frame_archive::frame::get_bpp() const
Expand Down

0 comments on commit 952e19a

Please sign in to comment.