Skip to content

Commit ef10dbd

Browse files
committed
Use mackjpeg instead of TJ directly
1 parent 033e200 commit ef10dbd

5 files changed

Lines changed: 20 additions & 92 deletions

File tree

.idea/discord.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ apply from: 'build.common.gradle'
99

1010
allprojects {
1111
group = 'org.deltacv.visionloop'
12-
version = '1.2.7'
12+
version = '1.2.8'
1313
}
1414

1515
repositories {

streaming/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ tasks.register('sourcesJar', Jar) {
1313

1414
repositories {
1515
mavenCentral()
16-
maven { url "https://jitpack.io" }
1716
maven { url "https://maven.pkg.jetbrains.space/public/p/compose/dev" }
18-
maven { url 'https://maven.scijava.org/content/repositories/public/' }
1917
}
2018

2119
dependencies {
2220
compileOnly project(':')
23-
implementation("io.javalin:javalin:6.3.0")
21+
implementation("io.javalin:javalin:6.7.0")
2422

2523
compileOnly 'org.jetbrains.skiko:skiko-awt:0.8.15'
26-
implementation 'ome:turbojpeg:8.0.0'
24+
implementation 'org.deltacv:mackjpeg:1.0.2'
2725

2826
testImplementation platform('org.junit:junit-bom:5.10.0')
2927
testImplementation 'org.junit.jupiter:junit-jupiter'

streaming/src/main/java/io/github/deltacv/visionloop/sink/MjpegHttpStreamSink.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
import android.graphics.Bitmap;
44
import io.github.deltacv.visionloop.processor.Processor;
5-
import io.github.deltacv.visionloop.tj.TJLoader;
65
import io.javalin.Javalin;
76
import io.javalin.http.Handler;
7+
import org.deltacv.mackjpeg.JPEGCompressor;
8+
import org.deltacv.mackjpeg.MackJPEG;
9+
import org.deltacv.mackjpeg.PixelFormat;
10+
import org.deltacv.mackjpeg.turbojpeg.TurboJPEGBackend;
811
import org.eclipse.jetty.io.EofException;
912
import org.firstinspires.ftc.robotcore.internal.collections.EvictingBlockingQueue;
1013
import org.jetbrains.skia.impl.BufferUtil;
11-
import org.libjpegturbo.turbojpeg.TJ;
12-
import org.libjpegturbo.turbojpeg.TJCompressor;
1314
import org.opencv.core.*;
1415
import org.opencv.imgproc.Imgproc;
1516
import org.openftc.easyopencv.MatRecycler;
@@ -70,10 +71,6 @@ public class MjpegHttpStreamSink extends CanvasViewportSink {
7071
private final BlockingQueue<CompressedFrame> compressedFrames = new ArrayBlockingQueue<>(QUEUE_SIZE);
7172
private final AtomicBoolean isRunning = new AtomicBoolean(true);
7273

73-
static {
74-
TJLoader.load();
75-
}
76-
7774
/**
7875
* Represents a compressed JPEG frame ready to be sent to clients
7976
*/
@@ -147,21 +144,21 @@ private void submitCompressionTask(MatRecycler.RecyclableMat frame) {
147144
frameCopy.get(0, 0, frameData);
148145
frameCopy.returnMat();
149146

150-
TJCompressor compressor = new TJCompressor();
147+
JPEGCompressor compressor = MackJPEG.getSupportedBackend().makeCompressor();
148+
151149
try {
152150
synchronized (qualityLock){
153-
compressor.setJPEGQuality(quality);
151+
compressor.setQuality(quality);
154152
}
155153

156-
compressor.setSubsamp(TJ.SAMP_440);
157-
compressor.setSourceImage(frameData, frame.width(), 0, frame.height(), TJ.PF_BGR);
154+
compressor.setImage(frameData, frame.width(), frame.height(), PixelFormat.RGB);
158155

159156
byte[] buffer = getOrCreateReusableBuffer(2_000_000); // Pre-allocate buffer
160-
compressor.compress(buffer, TJ.FLAG_FASTDCT);
157+
compressor.compress(buffer);
161158

162159
returnReusableBuffer(frameData);
163160

164-
int compressedSize = (int) compressor.getCompressedSize();
161+
int compressedSize = compressor.getCompressedSize();
165162

166163
// Add compressed frame to the output queue if we're still running
167164
if (isRunning.get()) {

streaming/src/main/java/io/github/deltacv/visionloop/tj/TJLoader.java

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)