awxkee / avif-coder

AVIF/HEIC coder for Android, Kotlin, Java
MIT License
57 stars 7 forks source link

The new version doesn't work #9

Closed T8RIN closed 1 year ago

T8RIN commented 1 year ago

I've just tried a new library version and it is not displaying images, and also not saving them, something went wrong with encode and decode functions i think, also no errors during these processes are thrown... F.e. version 1.0.24 work as expected

awxkee commented 1 year ago

I've just tried a new library version and it is not displaying images, and also not saving them, something went wrong with encode and decode functions i think, also no errors during these processes are thrown... F.e. version 1.0.24 work as expected

There should be definitely an exception somewhere, may you check for it? I done tons of math for hdr some glitches may happen

awxkee commented 1 year ago

Also if that possible I would like to ask you a few images that you trying to display

T8RIN commented 1 year ago

I've just tried a new library version and it is not displaying images, and also not saving them, something went wrong with encode and decode functions i think, also no errors during these processes are thrown... F.e. version 1.0.24 work as expected

There should be definitely an exception somewhere, may you check for it? I done tons of math for hdr some glitches may happen

Maybe yes, but i have exceptions handlers everywhere, and nothing just happens

T8RIN commented 1 year ago

Also if that possible I would like to ask you a few images that you trying to display

This happens with every image , i.e. coil loader now just breaks everything, i can't even display jpg, because heif coder fails, i will check it's logs now, and send the app compiled with the new version

awxkee commented 1 year ago

I've just tried a new library version and it is not displaying images, and also not saving them, something went wrong with encode and decode functions i think, also no errors during these processes are thrown... F.e. version 1.0.24 work as expected

There should be definitely an exception somewhere, may you check for it? I done tons of math for hdr some glitches may happen

Maybe yes, but i have exceptions handlers everywhere, and nothing just happens

If you have an exceptions handle everywhere it definitely an error 'somewhere handled'

awxkee commented 1 year ago

Also if that possible I would like to ask you a few images that you trying to display

This happens with every image , i.e. coil loader now just breaks everything, i can't even display jpg, because heif coder fails, i will check it's logs now, and send the app compiled with the new version

Are you trying '1.1.4' version?

T8RIN commented 1 year ago

Also if that possible I would like to ask you a few images that you trying to display

This happens with every image , i.e. coil loader now just breaks everything, i can't even display jpg, because heif coder fails, i will check it's logs now, and send the app compiled with the new version

Are you trying '1.1.4' version?

Yes

T8RIN commented 1 year ago

I've just tried a new library version and it is not displaying images, and also not saving them, something went wrong with encode and decode functions i think, also no errors during these processes are thrown... F.e. version 1.0.24 work as expected

There should be definitely an exception somewhere, may you check for it? I done tons of math for hdr some glitches may happen

Maybe yes, but i have exceptions handlers everywhere, and nothing just happens

If you have an exceptions handle everywhere it definitely an error 'somewhere handled'

I mean they handled and shown to user, but with coil factories this doesn't work, and errors just shown in error block of coil loader, so i'll check what happens internally

awxkee commented 1 year ago

I found it. It just coil decoder related issue. I'm on it

T8RIN commented 1 year ago

I found it. It just coil decoder related issue. I'm on it

Oh, okay, waiting!

awxkee commented 1 year ago

I found it. It just coil decoder related issue. I'm on it

Oh, okay, waiting!

I made the fix

T8RIN commented 1 year ago

Could you also fix jxl Loosy to Lossy and Loseless to Lossless ? (there is typos i think)

T8RIN commented 1 year ago

I found it. It just coil decoder related issue. I'm on it

Oh, okay, waiting!

I made the fix

will check now

awxkee commented 1 year ago

Could you also fix jxl Loosy to Lossy and Loseless to Lossless ? (there is typos i think)

Done

T8RIN commented 1 year ago

I found it. It just coil decoder related issue. I'm on it

Oh, okay, waiting!

I made the fix

image

not working :(

T8RIN commented 1 year ago

By some reason now your coil factory cannot determine if this is an heif file... and brokes everything after

T8RIN commented 1 year ago

i found the issue

val originalBytes = result.source.source().readByteArray()
            if (HeifCoder().isSupportedImage(originalBytes)) {
                return HeifDecoder(result, options, imageLoader, originalBytes)
            } else return null

did you remember when i replaced this to DecodeUtils.isHeif ? it is needed to proper work :(

awxkee commented 1 year ago

I found it. It just coil decoder related issue. I'm on it

Oh, okay, waiting!

I made the fix

image

not working :(

It is not mine. My coil plugin do not using BitmapFactory

T8RIN commented 1 year ago

I know, check the latest PR from me

awxkee commented 1 year ago

I know, check the latest PR from me

It is definitely not right to check only ftyp. Tons of formats using ftyp starting from MP-4 finishing by avif

T8RIN commented 1 year ago

I know, check the latest PR from me

It is definitely not right to check only ftyp. Tons of formats using ftyp starting from MP-4 finishing by avif

Then you could implement personal checking, but using buffered source, without "eating" bytearray

T8RIN commented 1 year ago

That how i used it in jxl-coder based coil decoder

class Factory : Decoder.Factory {
        override fun create(
            result: SourceResult,
            options: Options,
            imageLoader: ImageLoader
        ) = if (isJXL(result.source.source())) {
            JxlDecoder(result, options, imageLoader)
        } else null

        private val MAGIC_1 = byteArrayOf(0xFF.toByte(), 0x0A).toByteString()
        private val MAGIC_2 = byteArrayOf(
            0x0.toByte(),
            0x0.toByte(),
            0x0.toByte(),
            0x0C.toByte(),
            0x4A,
            0x58,
            0x4C,
            0x20,
            0x0D,
            0x0A,
            0x87.toByte(),
            0x0A
        ).toByteString()

        private fun isJXL(source: BufferedSource): Boolean {
            return source.rangeEquals(2, MAGIC_1) || source.rangeEquals(
                MAGIC_2.size.toLong(),
                MAGIC_2
            )
        }
    }
awxkee commented 1 year ago

That how i used it in jxl-coder based coil

Yep, I know. But HEIC, HEIF and AVIF are different from JXL you can't check that this way

awxkee commented 1 year ago

Ok. I think I'll do same. But it's unclear why BufferedSource in coil is just one-shot

T8RIN commented 1 year ago

That how i used it in jxl-coder based coil

Yep, I know. But HEIC, HEIF and AVIF are different from JXL you can't check that this way

Then how are you checking if the bytearray contains heif data?

T8RIN commented 1 year ago

Ok. I think I'll do same. But it's unclear why BufferedSource in coil is just one-shot

Maybe in performance purposes?

awxkee commented 1 year ago

Ok. I think I'll do same. But it's unclear why BufferedSource in coil is just one-shot

Maybe in performance purposes?

BufferedSource means it's buffered... If you buffering some it means it should be always available until deleted.

I'm making validation via libheif, it is the most exact way to be sured that image is valid. Another ways will lead to false-positive results, but if coil work this way I'll do another

T8RIN commented 1 year ago

Ok. I think I'll do same. But it's unclear why BufferedSource in coil is just one-shot

Maybe in performance purposes?

BufferedSource means it's buffered... If you buffering some it means it should be always available until deleted.

I'm making validation via libheif, it is the most exact way to be sured that image is valid. Another ways will lead to false-positive results, but if coil work this way I'll do another

Okay, got it :)

awxkee commented 1 year ago

Try '1.1.7' version

T8RIN commented 1 year ago

Thanks! It works