Skip to content

Conversation

fran6co
Copy link
Contributor

@fran6co fran6co commented Aug 21, 2015

Mac OS X >= 10.8 jpeg decoding (a bit hidden).

It's around the same speed as JpegTurbo but it's a lot gentler on the cpu:

[VTRgbPacketProcessor] avg. time: 20.3996ms -> ~49.0207Hz

vs

[TurboJpegRgbPacketProcessor] avg. time: 23.2275ms -> ~43.0525Hz

@xlz
Copy link
Member

xlz commented Aug 21, 2015

How is the CPU usage improvement?

@fran6co
Copy link
Contributor Author

fran6co commented Aug 21, 2015

It's hard to measure, OS X creates a separate system process for decoding. Should I just throw in the %?

I did a double check on it, and it's not using a hardware accelerated jpeg decoder contrary to what I thought. So, not sure if it's worth it.

@xlz
Copy link
Member

xlz commented Aug 21, 2015

Ideally it should be using hardware acceleration. Even if not, an alternative is always good. Some users reported color corruption with custom compiled turbojpeg. Besides making it possible to remove the hard dependency on turbojpeg on Mac is also nice.

@fran6co fran6co force-pushed the vt_rgb branch 2 times, most recently from 275d7f9 to f3d6e35 Compare August 27, 2015 18:00
@fran6co
Copy link
Contributor Author

fran6co commented Aug 27, 2015

Now it replaces TurboJPEG for Mac OS X.

@xlz
Copy link
Member

xlz commented Aug 27, 2015

VideoToolbox does not conflict with Turbojpeg. I don't think it needs to replace turbojpeg? Turbojpeg is fine along with this. Making VT the default is sure.

OK it seems the above commit just makes turbojpeg optional for Mac OS. It is fine.

@fran6co
Copy link
Contributor Author

fran6co commented Aug 27, 2015

Not sure what's the use of compiling TurboJPEG if it's not going to be used. In any case just updated the PR to build it anyways if it's available.

@floe floe added this to the 0.2 milestone Sep 2, 2015
@fran6co
Copy link
Contributor Author

fran6co commented Sep 7, 2015

Rebased

@fran6co
Copy link
Contributor Author

fran6co commented Sep 24, 2015

Rebased

@fran6co
Copy link
Contributor Author

fran6co commented Oct 22, 2015

Rebased

@fran6co fran6co force-pushed the vt_rgb branch 2 times, most recently from 0ba4ec9 to 1050caf Compare November 6, 2015 12:22
@RyanGordon
Copy link
Contributor

Just tested on my MacBook Air, and it's definitely faster than TurboJPEG by about 7-10Hz

@xlz
Copy link
Member

xlz commented Feb 4, 2016

Can you rebase again? I took a look and it seems there is no major conflict. If you test OK, I'll merge it quickly.

Also, can you add a paragraph saying "You are still able to build with optional TurboJPEG support with brew install jpeg-turbo along with other dependencies"? (Also, delete[] NULL is legal).

@fran6co fran6co force-pushed the vt_rgb branch 2 times, most recently from aa5fa87 to 73b8930 Compare February 6, 2016 20:18
@fran6co
Copy link
Contributor Author

fran6co commented Feb 6, 2016

@xlz Rebased

RgbPacketProcessor *rgb = new VTRgbPacketProcessor();
#else
RgbPacketProcessor *rgb = new TurboJpegRgbPacketProcessor();
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create a new function to do this?

static RgbPacketProcessor *getDefaultRgbPacketProcessor()
{
#ifdef LIBFREENECT2_WITH_VT_SUPPORT
  return new VTRgbPacketProcessor();
#endif
//in the future
//#ifdef LIBFREENECT_WITH_VAAPI_SUPPORT
//  return ...
//#endif
  return new TurboJpegRgbPacketProcessor();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Had to change it a bit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think returning NULL is well intentioned. But the configuration in CMake makes it never return NULL, so I'm ok with this.

Mac OS X >= 10.8 has hardware accelerated jpeg decoding (a bit hidden)
xlz added a commit that referenced this pull request Feb 6, 2016
New VideoToolbox rgb packet processor
@xlz xlz merged commit 8060189 into OpenKinect:master Feb 6, 2016
@fran6co fran6co deleted the vt_rgb branch February 6, 2016 21:40
@xlz
Copy link
Member

xlz commented Feb 6, 2016

There are things to consider for improvement:

  • Does this decoder allocate new buffers internally and memcpy the data from packet.buffer to the internal buffers? Is there memory mapping mechanism that can be used?
  • It looks like all the returned Frame share the same pixel buffers? How did you design it such that when the user is reading the content of a Frame, the content is not overwritten by the procesor?
  • How to add an option to make it decode in gray and YUV formats?

@xlz
Copy link
Member

xlz commented Feb 6, 2016

I see a thing in your code: nil. Did you mean NULL? You should change it next time.

@fran6co
Copy link
Contributor Author

fran6co commented Feb 6, 2016

@xlz
Copy link
Member

xlz commented Feb 6, 2016

It seems you didn't pass some metadata as in https://github.com/OpenKinect/libfreenect2/blob/master/src/turbo_jpeg_rgb_packet_processor.cpp#L93

Can you create a new PR to fix this missing metadata, fix the nil, and fix returning NULL in getDefaultRgbPacketProcessor()? (There must be a fallback jpeg decoder. Returning NULL is just pushing the problem back to runtime instead of build time).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants