Skip to content

Commit

Permalink
Hardware buffer acquire fix
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Nov 14, 2024
1 parent 5d9775b commit b82fd8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Upgrade libjxl, speed improvements and stability
Improvements for f16, fixes for non standard cpu processors
10 changes: 5 additions & 5 deletions app/src/main/java/com/awxkee/jxlcoder/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class MainActivity : ComponentActivity() {
}
LaunchedEffect(key1 = Unit, block = {
lifecycleScope.launch(Dispatchers.IO) {
val buffer5 =
assets.open("hatice.jpg").source().buffer().readByteArray()
// val buffer5 =
// assets.open("hatice.jpg").source().buffer().readByteArray()
// val bitmap = BitmapFactory.decodeByteArray(buffer5, 0, buffer5.size)
// .scale(500, 500)
// val encoder = JxlAnimatedEncoder(
Expand Down Expand Up @@ -190,7 +190,7 @@ class MainActivity : ComponentActivity() {

var assets =
(this@MainActivity.assets.list("") ?: return@launch).toList()
assets = assets.filter { it.contains("20181110_213419__MMC1561-HDR.jxl") }
// assets = assets.filter { it.contains("20181110_213419__MMC1561-HDR.jxl") }
for (asset in assets) {
try {
val buffer4 =
Expand All @@ -204,9 +204,9 @@ class MainActivity : ComponentActivity() {
buffer4,
largeImageSize.width / 2,
largeImageSize.height / 2,
preferredColorConfig = PreferredColorConfig.RGBA_F16,
preferredColorConfig = PreferredColorConfig.HARDWARE,
com.awxkee.jxlcoder.ScaleMode.FIT,
toneMapper = JxlToneMapper.FILMIC,
toneMapper = JxlToneMapper.REC2408,
)
// val srcImage = JxlCoder.decode(buffer4,
// preferredColorConfig = PreferredColorConfig.RGB_565,
Expand Down
10 changes: 10 additions & 0 deletions jxlcoder/src/main/cpp/JniDecoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ Java_com_awxkee_jxlcoder_JxlCoder_decodeSampledImpl(JNIEnv *env, jobject thiz,
std::string errorString = "Not enough memory to decode this image";
throwException(env, errorString);
return nullptr;
} catch (std::runtime_error &err) {
std::string w1 = err.what();
std::string errorString = "Error while decoding: " + w1;
throwException(env, errorString);
return nullptr;
}
}

Expand Down Expand Up @@ -346,6 +351,11 @@ Java_com_awxkee_jxlcoder_JxlCoder_decodeByteBufferSampledImpl(JNIEnv *env, jobje
std::string errorString = "Not enough memory to decode this image";
throwException(env, errorString);
return nullptr;
} catch (std::runtime_error &err) {
std::string w1 = err.what();
std::string errorString = "Error while decoding: " + w1;
throwException(env, errorString);
return nullptr;
}
}

Expand Down

0 comments on commit b82fd8d

Please sign in to comment.