crow-misia / libyuv-android

LibYUV for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IllegalArgumentException: Bad position at BufferFactory<I420Buffer>#wrap

BananaChipsLover opened this issue · comments

Hi libyuv-android,

Thank you for sharing this amazine project. We are trying to use it in our app.

During testing, we often get IllegalArgumentException: Bad position x/x error, If BufferFactory<I420Buffer>#getStrideWithCapacity to the following, everything works as expectec.

        private fun getStrideWithCapacity(width: Int, height: Int): IntArray {
            val halfWidth = (width + 1).shr(1)
            val capacity = width * height * 12 / 8
            return intArrayOf(width, capacity *4/6, halfWidth, capacity /6, halfWidth, capacity /6)
        }

Our raw data info: width:2342 height:1556 length of raw data ByteArray: 5466228

thanks for the report.
fixed the logic for calculating size.

Thank you so much. It's working perfectly now. 🙇‍♀️