Skip to content

Commit

Permalink
* Prevent premature deallocations with LeptonicaFrameConverter (is…
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed Nov 26, 2018
1 parent 1190188 commit d86bea1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Prevent premature deallocations with `LeptonicaFrameConverter` ([issue bytedeco/javacpp#272](https://github.com/bytedeco/javacpp/issues/272))
* Fix `OpenCVFrameGrabber` from crashing when in `ImageMode.GRAY`
* Add support for multiple inputs to `FFmpegFrameFilter` ([issue #955](https://github.com/bytedeco/javacv/issues/955))
* Fix fps in output of `FFmpegFrameRecorder` by setting deprecated `AVStream.codec.time_base` ([issue #1069](https://github.com/bytedeco/javacv/issues/1069))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ public PIX convert(Frame frame) {
} else if (frame.opaque instanceof PIX) {
return (PIX)frame.opaque;
} else if (!isEqual(frame, pix)) {
pix = PIX.createHeader(frame.imageWidth, frame.imageHeight, frame.imageChannels * 8)
.wpl(frame.imageStride / 4 * Math.abs(frame.imageDepth) / 8);
Pointer data;
if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
pixBuffer = ByteBuffer.allocateDirect(frame.imageHeight * frame.imageStride).order(ByteOrder.BIG_ENDIAN);
pix.data(new IntPointer(new Pointer(pixBuffer)));
data = new Pointer(pixBuffer);
} else {
pix.data(new IntPointer(new Pointer(frame.image[0].position(0))));
data = new Pointer(frame.image[0].position(0));
}
pix = PIX.create(frame.imageWidth, frame.imageHeight, frame.imageChannels * 8, data)
.wpl(frame.imageStride / 4 * Math.abs(frame.imageDepth) / 8);
}

if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
Expand Down

0 comments on commit d86bea1

Please sign in to comment.