Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[GUIDE][CAM] How To Hack SONY Xperia Camera (Bring Higher Bitrate & More Options)

OP Rizal Lovins

15th April 2014, 03:58 AM   |  #1  
Rizal Lovins's Avatar
OP Recognized Developer / Recognized Themer / Recognized Contributor
Flag Bandung - The Girl Next Door
Thanks Meter: 14,938
 
1,464 posts
Join Date:Joined: May 2012
More
Hello Xperia friends....

from the beginning until now SONY give us bad software camera compared to others OEM


I want to show you how to hack All Xperia Camera

Requirement :

Knowladge in decompile/recompile apps


Hacking Audio Bitrate Video Recording
INFO for smali code

Value 0
Name: LowRate
Type: REG_DWORD
Data: 0x1f400 (SONY use this low bitrate so find this code to replace in the next step)

Value 1
Name: MediumRate
Type: REG_DWORD
Data: 0x2ee00

Value 2
Name: MediumHighRate
Type: REG_DWORD
Data: 0x3e800 (i'm use this code)

Value 3
Name: HighRate
Type: REG_DWORD
Data: 0x4e200
1. Decompile SemcCameraUI.apk
2. Go to smali/com/sonyericsson/android/camera

open Constants.smali using text editor/notepad++ then find this line
Code:
.field public static final VIDEO_AUDIO_BIT_RATE:I = 0x1f400
change RED Color code to code from INFO CODE, example :
Code:
.field public static final VIDEO_AUDIO_BIT_RATE:I = 0x3e800
save it!!!!

3. Go to smali/com/sonyericsson/android/camera/configuration/parameters

open VideoSize$VideoProfile$Builder.smali ( if there smali available, i mean different Xperia have diffierent parameters like older Xperia 2011)

search this code
Code:
0x1f400
then change to
Code:
0x3e800
save it!!!

4. Go to smali/com/sonyericsson/android/camera/configuration/parameters

open VideoSize.smali

search all this code
Code:
0x1f400
then change all code to
Code:
0x3e800
save it!!! Done


LAG ON VIDEO RECORDING ON XPERIA 2011 & XPERIA 2012 (Snapdragon S3/Novathor)???

Here is solution change FORMAT H264 to MPEG4!!!
INFO H264 VS MPEG4
http://www.y-cam.com/blog/mpeg4-vs-h-264-45/

Smali code

H263 is
Code:
0x1
H264 is
Code:
0x2
MPEG4 is
Code:
0x3
1. Go to smali/com/sonyericsson/android/camera/configuration/parameters

open VideoSize.smali using text editor/notepad++ then find this line

(Note the Local maybe different)
Code:
.local v7, "videoFrameRate":I
const/4 v6, 0x2
change to

Code:
.local v7, "videoFrameRate":I
const/4 v6, 0x3
Save it!!! Done
Last edited by Rizal Lovins; 15th April 2014 at 07:00 AM.
The Following 62 Users Say Thank You to Rizal Lovins For This Useful Post: [ View ]
15th April 2014, 03:58 AM   |  #2  
Rizal Lovins's Avatar
OP Recognized Developer / Recognized Themer / Recognized Contributor
Flag Bandung - The Girl Next Door
Thanks Meter: 14,938
 
1,464 posts
Join Date:Joined: May 2012
More
Hacking Video Recording Bitrate

INFO for smali code
Value 1
Name: MediumRate
Data: 0xb71b00

Value 2
Name: MediumHighRate
Data: 0x10b0760

Value 3
Name: HighRate
Data: 0x1c9c380

1. Go to smali/com/sonyericsson/android/camera

open Constants.smali using text editor/notepad++ then find this line

For HD 720p
Code:
.field public static final VIDEO_BIT_RATE_EX_HIGH_12M:I = 0xb71b00
change to
Code:
.field public static final VIDEO_BIT_RATE_EX_HIGH_12M:I = 0x10b0760
For FULL HD 1080p
Code:
.field public static final VIDEO_BIT_RATE_EX_HIGH_17_5M:I = 0x10b0760
change to
Code:
.field public static final VIDEO_BIT_RATE_EX_HIGH_17_5M:I = 0x1c9c380
save it!!!

2. Go to smali/com/sonyericsson/android/camera/configuration/parameters

open VideoSize.smali the find this line

For HD 720p
Code:
0xb71b00
change to
Code:
0x10b0760
For FULL HD 1080p
Code:
0x10b0760
change that all code to
Code:
0x1c9c380
save it!!! Done

NOW AFTER EDITING VIDEO AUDIO BITRATE & VIDEO BITRATE YOU NEED TO EDIT media_profile.xml

open media_profile.xml using text editor/notepad++ thenfind this line

FIX 100% Image Quality
Code:
<!ATTLIST ImageEncoding quality (90|80|70|60|50|40) #REQUIRED>
change to
Code:
<!ATTLIST ImageEncoding quality (100|90|80|70|60|50) #REQUIRED>
There is 2 lines code for back camera & front camera

Code:
<ImageEncoding quality="95" />
<ImageEncoding quality="80" />
<ImageEncoding quality="70" />
change all code to
Code:
<ImageEncoding quality="100" />
<ImageEncoding quality="90" />
<ImageEncoding quality="80" />

Adjust the value of smali Video & Audio Video bitrate with media-profile.xml (as you modified it)

There is many lines code for Video you need to change them all, example

Code:
        <EncoderProfile quality="1080p" fileFormat="mp4" duration="60">
            <Video codec="h264"
                   bitRate="17500000"
                   width="1920"
                   height="1080"
                   frameRate="30" />

            <Audio codec="aac"
                   bitRate="156000"
                   sampleRate="48000"
                   channels="2" />
        </EncoderProfile>

        <EncoderProfile quality="720p" fileFormat="mp4" duration="60">
            <Video codec="h264"
                   bitRate="12000000"
                   width="1280"
                   height="720"
                   frameRate="30" />

            <Audio codec="aac"
                   bitRate="156000"
                   sampleRate="48000"
                   channels="2" />
        </EncoderProfile>
change to

Code:
        <EncoderProfile quality="1080p" fileFormat="mp4" duration="60">
            <Video codec="h264"
                   bitRate="20000000"
                   width="1920"
                   height="1080"
                   frameRate="30" />

            <Audio codec="aac"
                   bitRate="256000"
                   sampleRate="48000"
                   channels="2" />
        </EncoderProfile>

        <EncoderProfile quality="720p" fileFormat="mp4" duration="60">
            <Video codec="h264"
                   bitRate="1750000"
                   width="1280"
                   height="720"
                   frameRate="30" />

            <Audio codec="aac"
                   bitRate="256000"
                   sampleRate="48000"
                   channels="2" />
        </EncoderProfile>
Code:
    <VideoEncoderCap name="h264" enabled="true"
        minBitRate="64000" maxBitRate="20000000"
        minFrameWidth="176" maxFrameWidth="1920"
        minFrameHeight="144" maxFrameHeight="1080"
        minFrameRate="15" maxFrameRate="30" />
Code:
    <AudioEncoderCap name="aac" enabled="true"
        minBitRate="8000" maxBitRate="256000"
        minSampleRate="8000" maxSampleRate="48000"
        minChannels="1" maxChannels="2" />
Note maxChannels Number in RED Color, can be 6 or 2
Last edited by Rizal Lovins; 15th April 2014 at 06:59 AM.
The Following 29 Users Say Thank You to Rizal Lovins For This Useful Post: [ View ]
15th April 2014, 03:59 AM   |  #3  
Rizal Lovins's Avatar
OP Recognized Developer / Recognized Themer / Recognized Contributor
Flag Bandung - The Girl Next Door
Thanks Meter: 14,938
 
1,464 posts
Join Date:Joined: May 2012
More
EXperimental hacking, Change format RGB_565 to ARGB8888

I use ONLY on Xperia 2011

1. Go to smali/com/sonyericsson/android/camera

open CameraActivity.smali using text editor/notepad++ then find this line

Code:
sget-object v12, Landroid/graphics/Bitmap$Config;->RGB_565:Landroid/graphics/Bitmap$Config;
Code:
sget-object v0, Landroid/graphics/Bitmap$Config;->RGB_565:Landroid/graphics/Bitmap$Config;
Change RED Color code to

Code:
ARGB_8888
2. Go to smali/com/sonyericsson/android/camera

open ImageManager.smali then search for RGB example :
Code:
sget-object v0, Landroid/graphics/Bitmap$Config;->RGB_565:Landroid/graphics/Bitmap$Config;
change all code to
Code:
sget-object v0, Landroid/graphics/Bitmap$Config;->ARGB_8888:Landroid/graphics/Bitmap$Config;
3. Go to smali/com/sonyericsson/android/camera/device

open CameraExtensionValues.smali then search for RGB example :
Code:
.field public static final POSTVIEW_FORMAT_RGB565:Ljava/lang/String; = "rgb565"
change to

Code:
.field public static final POSTVIEW_FORMAT_RGB565:Ljava/lang/String; = "argb8888"
save it!!!

Enable inPreferQualityOverSpeed (I Use ONLY on Xperia 2011)

1. Go to smali/com/sonyericsson/android/camera

open CameraActivity.smali

Code:
.local v11, opt:Landroid/graphics/BitmapFactory$Options;
sget-object v15, Landroid/graphics/Bitmap$Config;->RGB_565:Landroid/graphics/Bitmap$Config;

iput-boolean v6, v11, Landroid/graphics/BitmapFactory$Options;->inPreferQualityOverSpeed:Z

iput-object v15, v11, Landroid/graphics/BitmapFactory$Options;->inPreferredConfig:Landroid/graphics/Bitmap$Config;
Look for RED Color it's should be like this
Code:

.local v11, opt:Landroid/graphics/BitmapFactory$Options;
const/4 v6, 0x1
iput-boolean v6, v11, Landroid/graphics/BitmapFactory$Options;->inPreferQualityOverSpeed:Z

iput-boolean v6, v11, Landroid/graphics/BitmapFactory$Options;->inDither:Z

sget-object v15, Landroid/graphics/Bitmap$Config;->ARGB_8888:Landroid/graphics/Bitmap$Config;

iput-object v15, v11, Landroid/graphics/BitmapFactory$Options;->inPreferredConfig:Landroid/graphics/Bitmap$Config;
Last edited by Rizal Lovins; 15th April 2014 at 06:20 AM.
The Following 26 Users Say Thank You to Rizal Lovins For This Useful Post: [ View ]
15th April 2014, 03:59 AM   |  #4  
Rizal Lovins's Avatar
OP Recognized Developer / Recognized Themer / Recognized Contributor
Flag Bandung - The Girl Next Door
Thanks Meter: 14,938
 
1,464 posts
Join Date:Joined: May 2012
More
Hacking Camera Resolution/MP (More Options)

More Options for Photo (Only work for Xperia 2011 & 2012 Snapdragon S3/Novathor)

For Xperia 2012 Snapdragon S4 and 2013/2014 doesn't work, need to be removing some code in smali, i'm still looking for it

1. Go to res/value

open arrays.xml using text editor/notepad++ then find this line

For 12MP Camera
Code:
<string-array name="ux_recommended_resolution_array_main_12m">
     <item>TWELVE_MP</item>
     <item>NINE_MP</item>
     <item>TWO_MP</item>
     <item>TWO_MP_WIDE</item>
add others line
Code:
<string-array name="ux_recommended_resolution_array_main_12m">
        <item>TWELVE_MP</item>
        <item>NINE_MP</item>
	<item>EIGHT_MP</item>
	<item>FIVE_MP</item>
	<item>THREE_MP_WIDE</item>
        <item>TWO_MP</item>
        <item>TWO_MP_WIDE</item>
For 8MP Camera
Code:
<string-array name="ux_recommended_resolution_array_main_8m">
     <item>EIGHT_MP</item>
     <item>SIX_MP</item>
     <item>TWO_MP</item>
     <item>TWO_MP_WIDE</item>
add others line
Code:
<string-array name="ux_recommended_resolution_array_main_8m">
     <item>EIGHT_MP</item>
     <item>SIX_MP</item>
     <item>FIVE_MP</item>
     <item>THREE_MP</item>
     <item>TWO_MP</item>
     <item>TWO_MP_WIDE</item>

More Options for Video (Work for all Xperia)

1. Go to res/value

open arrays.xml using text editor/notepad++ then find this line

For 20MP Camera
Code:
<string-array name="ux_recommended_video_size_array_main_20m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>MMS</item>
add others line
Code:
<string-array name="ux_recommended_video_size_array_main_20m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
For 13MP Camera
Code:
<string-array name="ux_recommended_video_size_array_main_13m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>MMS</item>
add others line
Code:
<string-array name="ux_recommended_video_size_array_main_13m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
For 12MP Camera
Code:
<string-array name="ux_recommended_video_size_array_main_12m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>MMS</item>
add others line
Code:
<string-array name="ux_recommended_video_size_array_main_12m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
For 8MP Camera FULL HD 1080p
Code:
<string-array name="ux_recommended_video_size_array_main_8m_full_hd">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>MMS</item>
add others line
Code:
<string-array name="ux_recommended_video_size_array_main_8m_full_hd">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
For 8MP Camera HD 720p
Code:
<string-array name="ux_recommended_video_size_array_main_8m_hd">
     <item>HD</item>
     <item>FWVGA</item>
     <item>QVGA</item>
     <item>MMS</item>
add others line
Code:
<string-array name="ux_recommended_video_size_array_main_8m_hd">
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
For 5MP Camera HD 720p
Code:
<string-array name="ux_recommended_video_size_array_main_5m_fwvga">
     <item>HD</item>
     <item>FWVGA</item>
     <item>QVGA</item>
     <item>MMS</item>
add others line
Code:
<string-array name="ux_recommended_video_size_array_main_5m_fwvga">
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
Save it!!!
Last edited by Rizal Lovins; 15th April 2014 at 05:35 AM.
The Following 30 Users Say Thank You to Rizal Lovins For This Useful Post: [ View ]
15th April 2014, 04:00 AM   |  #5  
Rizal Lovins's Avatar
OP Recognized Developer / Recognized Themer / Recognized Contributor
Flag Bandung - The Girl Next Door
Thanks Meter: 14,938
 
1,464 posts
Join Date:Joined: May 2012
More
Enable 12MP Superior Auto on Jelly Bean 4.3

How to Install :

- Download the file in attachment
- Copy to system with root explorer etc
- Set permissions to 644 (rw-r--r--)
- Move the file to system>vendor>overlay
- Reboot
- After boot go to settings>apps>all
- Clear data Camera & try open camera app


NOTE : for some device need to rename the apk to android-res.apk and replace the original if is there

Enjoy


Credits :
Thanks to SONY Mobile that made all this possible
Thanks to my old friend @Xperia-Ray for helping me from beginning
Attached Files
File Type: apk com.sonyericsson.android.camera-res.apk - [Click for QR Code] (3.2 KB, 292 views)
Last edited by Rizal Lovins; 15th April 2014 at 05:52 AM.
The Following 23 Users Say Thank You to Rizal Lovins For This Useful Post: [ View ]
15th April 2014, 04:01 AM   |  #6  
poria1999's Avatar
Senior Member
Flag Tehran
Thanks Meter: 462
 
342 posts
Join Date:Joined: Feb 2013
More
Nice guide man!
Will try it

Sent from my LT18i using Tapatalk 2
The Following 2 Users Say Thank You to poria1999 For This Useful Post: [ View ]
15th April 2014, 04:30 AM   |  #7  
devilmaycry2020's Avatar
Senior Member
Thanks Meter: 129
 
829 posts
Join Date:Joined: Apr 2013
More
Thanks,this guide change audio bitrate only,how about video bitrate?
15th April 2014, 04:57 AM   |  #8  
cuatzstress's Avatar
Senior Member
Flag you tell me
Thanks Meter: 73
 
153 posts
Join Date:Joined: Sep 2012
More
Nuhun kang, I'll try ur guide, anyway how to change the photo quality? Is it same method?

Sent from my C1905 using XDA Premium 4 mobile app
15th April 2014, 05:40 AM   |  #9  
xperiaz2's Avatar
Recognized Themer
Thanks Meter: 4,110
 
466 posts
Join Date:Joined: Oct 2013
wow
awesome guide bro very nice
The Following User Says Thank You to xperiaz2 For This Useful Post: [ View ]
15th April 2014, 07:27 AM   |  #10  
Senior Member
Flag Mumbai
Thanks Meter: 77
 
223 posts
Join Date:Joined: Oct 2010
More
Thumbs up It WOKS..... :)
thank you it does work for decompile and recompile of the apk iused this tool


http://forum.xda-developers.com/show....php?t=2326604

awesome....

The Following User Says Thank You to ramkrsn For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes