Skip to content

Commit 1107f63

Browse files
committed
A lot of improvements, improve speed tests
1 parent 24bb7bf commit 1107f63

File tree

8 files changed

+6
-38
lines changed

8 files changed

+6
-38
lines changed

app/src/main/java/com/radzivon/bartoshyk/avif/MainActivity.kt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -191,31 +191,6 @@ class MainActivity : AppCompatActivity() {
191191
}
192192
}
193193
}
194-
195-
binding.buttonTest.setOnClickListener {
196-
lifecycleScope.launch(Dispatchers.IO) {
197-
val coder = HeifCoder(ToneMapper.REC2408)
198-
val file =
199-
getAllFilesFromAssets().filter {
200-
it.contains(".avif") || it.contains(".heic") || it.contains(
201-
".heif"
202-
)
203-
}.filter { it == "test_1.avif" }
204-
val buffer = this@MainActivity.assets.open(file[0]).source().buffer()
205-
.readByteArray()
206-
val decoded = coder.decodeSampled(
207-
buffer,
208-
1980,
209-
1020,
210-
preferredColorConfig = PreferredColorConfig.RGBA_8888,
211-
ScaleMode.FIT
212-
)
213-
val encodingTime = measureTimeMillis {
214-
coder.encodeAvif(decoded)
215-
}
216-
Log.d("MainActivity", "AVIF: Encoding time $encodingTime")
217-
}
218-
}
219194
}
220195

221196
private fun testEncoder(assetName: String) {

app/src/main/res/layout/activity_main.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,4 @@
5151

5252
</ScrollView>
5353

54-
<com.google.android.material.button.MaterialButton
55-
android:layout_width="wrap_content"
56-
android:text="Test"
57-
android:id="@+id/buttonTest"
58-
app:layout_constraintBottom_toBottomOf="parent"
59-
app:layout_constraintEnd_toEndOf="parent"
60-
app:layout_constraintStart_toStartOf="parent"
61-
app:layout_constraintTop_toTopOf="parent"
62-
android:layout_height="60dp"/>
63-
6454
</androidx.constraintlayout.widget.ConstraintLayout>

avif-coder/src/main/cpp/JniEncoder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,10 @@ Java_com_radzivon_bartoshyk_avif_coder_HeifCoder_getSizeImpl(JNIEnv *env, jobjec
869869
AvifImageSize size = AvifDecoderController::getImageSize(srcBuffer.data(), srcBuffer.size());
870870
jclass sizeClass = env->FindClass("android/util/Size");
871871
jmethodID methodID = env->GetMethodID(sizeClass, "<init>", "(II)V");
872-
auto sizeObject = env->NewObject(sizeClass, methodID, size.width, size.height);
872+
auto sizeObject = env->NewObject(sizeClass,
873+
methodID,
874+
static_cast<jint >(size.width),
875+
static_cast<jint>(size.height));
873876
return sizeObject;
874877
}
875878

112 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
-32 Bytes
Binary file not shown.
-96 Bytes
Binary file not shown.

avifpixart/src/cvt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn work_on_transmuted_ptr_f16<F>(
4646
let mut allocated = false;
4747
let mut dst_stride = rgba_stride as usize / 2;
4848
let mut working_slice: BufferStoreMut<'_, f16> = unsafe {
49-
if rgba as usize % 2 == 0 && rgba_stride / 2 != 0 {
49+
if rgba as usize % 2 == 0 && rgba_stride / 2 == 0 {
5050
BufferStoreMut::Borrowed(std::slice::from_raw_parts_mut(
5151
rgba as *mut f16,
5252
rgba_stride as usize / 2 * height,
@@ -110,7 +110,7 @@ fn work_on_transmuted_ptr_u16<F>(
110110
let mut allocated = false;
111111
let mut dst_stride = rgba_stride as usize / 2;
112112
let mut working_slice: BufferStoreMut<'_, u16> = unsafe {
113-
if rgba as usize % 2 == 0 && rgba_stride / 2 != 0 {
113+
if rgba as usize % 2 == 0 && rgba_stride / 2 == 0 {
114114
BufferStoreMut::Borrowed(std::slice::from_raw_parts_mut(
115115
rgba as *mut u16,
116116
rgba_stride as usize / 2 * height,

0 commit comments

Comments
 (0)