So when lollipop was released, it broke 4k recording capabilities in Color OS camera. First i doubt it was something related with libraries (camera client etc.) or some changes in parameters but when i looked into bacon's (OnePlus One) device tree, my doubts were cleared. Now it was clear that there is no difference between them (KK and LP) in terms of libraries and HAL.Same is the case for Cyanogen OS 12. There is no major difference between KK and LP's camera module (a quick overview + log tells they both are almost same)
I was confused, what was going wrong then? Whenever we try to record 4k recording, it always records it in FWVGA resolution. I started debugging with Xposed to make things much easier but everything was fine there. Parameters were set correctly, log was not showing error etc. There were no errors on log which was making it difficult to find errors.
Now i decompiled CameraNext apk from COS 12 to see if there are any changes with calls to native libs. But damn Cyngn obfuscated it and so it was nearly impossible to trace down. I left it there.
After a week's drop (damn studies :( ) i started messing with it again. i was iterating over same and same functions again and again. Then suddenly i got attention over package android.media and class CamcorderProfile. These both are declared inside OppoCamera's package. What happens here is that when we call any member of class CamcorderProfile, they's are used from local package instead of global one (i.e from android framework). I started checking it found that some integers were defined inside it. Those integers represents the video quality (i.e/ resolution, fps etc). These integers must match with same declared in native layer (see CamcorderProfile.java). I matched them with OppoCamera's variables and found the reason why 4k was not working on CM12, COS12. The reason was that integers representing quality were changed in LP. In KitKat, 4k (QUALITY_2160P) was represented by value 12 and 8 was used for FWVGA. In LP these both were swapped and so in LP, when Oppocamera was requesting 4k, actually it was requesting FWVGA.
So it is just a minor change :) but actually it is not that easy. Why? the reason is optimizations provided by compiler. Compiler inlines constant values to improve performance. In lining means it hardcodes value directly into the code instead of fetching it statically from class. Actually this is causing more problems because i need to find everyplace where 12 is used to represent 4k quality.
Now adding 4k dci was also easier as it was represented by value 13, i just included it into list and it started working. I also added compatibility code for KK with hack by using API level numbering so that i don't need to release two versions.
Now we have 4k recording working on COS12 but preview is bugged. I don't have any solution for it yet. I'm much busy at the moment so it'll take some time.
Hope you enjoyed....
This is my first blog post so deal with it...:D
I was confused, what was going wrong then? Whenever we try to record 4k recording, it always records it in FWVGA resolution. I started debugging with Xposed to make things much easier but everything was fine there. Parameters were set correctly, log was not showing error etc. There were no errors on log which was making it difficult to find errors.
Now i decompiled CameraNext apk from COS 12 to see if there are any changes with calls to native libs. But damn Cyngn obfuscated it and so it was nearly impossible to trace down. I left it there.
After a week's drop (damn studies :( ) i started messing with it again. i was iterating over same and same functions again and again. Then suddenly i got attention over package android.media and class CamcorderProfile. These both are declared inside OppoCamera's package. What happens here is that when we call any member of class CamcorderProfile, they's are used from local package instead of global one (i.e from android framework). I started checking it found that some integers were defined inside it. Those integers represents the video quality (i.e/ resolution, fps etc). These integers must match with same declared in native layer (see CamcorderProfile.java). I matched them with OppoCamera's variables and found the reason why 4k was not working on CM12, COS12. The reason was that integers representing quality were changed in LP. In KitKat, 4k (QUALITY_2160P) was represented by value 12 and 8 was used for FWVGA. In LP these both were swapped and so in LP, when Oppocamera was requesting 4k, actually it was requesting FWVGA.
So it is just a minor change :) but actually it is not that easy. Why? the reason is optimizations provided by compiler. Compiler inlines constant values to improve performance. In lining means it hardcodes value directly into the code instead of fetching it statically from class. Actually this is causing more problems because i need to find everyplace where 12 is used to represent 4k quality.
Now adding 4k dci was also easier as it was represented by value 13, i just included it into list and it started working. I also added compatibility code for KK with hack by using API level numbering so that i don't need to release two versions.
Now we have 4k recording working on COS12 but preview is bugged. I don't have any solution for it yet. I'm much busy at the moment so it'll take some time.
Hope you enjoyed....
This is my first blog post so deal with it...:D
ReplyDeleteThank you for your feedback. We're glad you enjoyed the post. Feel free to share it with others you think may benefit from this information.
Buy One Plus x Case Online