mtk6737如何改差值文件

一、.背景介绍

图像比例 拍出图像像素 代码中字串id 相机界面显示像素(英文)
4:3 320x240 @string/pref_camera_picturesize_entry_320x240 QVGA
640x480 @string/pref_camera_picturesize_entry_640x480 VGA
1024x768 @string/pref_camera_picturesize_entry_1024x768 1M
1280x960 @string/pref_camera_picturesize_entry_1280x960 1.3M
1600x1200 @string/pref_camera_picturesize_entry_1600x1200 2M
2048x1536 @string/pref_camera_picturesize_entry_2048x1536 3M
2560x1920 @string/pref_camera_picturesize_entry_2592x1936 5M
3264x2448 @string/pref_camera_picturesize_entry_3264x2448 8M
3600x2700 @string/pref_camera_picturesize_entry_3600x2700 9.5M
3672x2754 @string/pref_camera_picturesize_entry_3672x2754 10M
4096x3072 @string/pref_camera_picturesize_entry_4096x3072 12M
4160x3120 @string/pref_camera_picturesize_entry_4160x3120 13M
4608x3456 @string/pref_camera_picturesize_entry_4608x3456 16M
5120x3840 @string/pref_camera_picturesize_entry_5120x3840 20M
       
vanzo增加 4352x3264 @string/pref_camera_picturesize_entry_4352x3264 14M
       
       
16:9
(如果手机屏幕比例是16:9,这像素就是全屏像素)
1280x720 @string/pref_camera_picturesize_entry_1280x720 1M
1600x912 @string/pref_camera_picturesize_entry_1280x960 1.3M
2048x1152 @string/pref_camera_picturesize_entry_2048x1536 3M
2560x1440 @string/pref_camera_picturesize_entry_2560x1440 4M
3328x1872 @string/pref_camera_picturesize_entry_3328x1872 6M
4096x2304 @string/pref_camera_picturesize_entry_3600x2700 9.5M
4608x2592 @string/pref_camera_picturesize_entry_4096x3072 12M
5120x2880 @string/pref_camera_picturesize_entry_5120x2880 15M
       
       
5:3
(如果手机屏幕比例是5:3,这像素就是全屏像素)
1280x768 @string/pref_camera_picturesize_entry_1280x768 1M
1600x960 @string/pref_camera_picturesize_entry_1600x1200 2M
2880x1728 @string/pref_camera_picturesize_entry_2592x1936 5M
3600x2160 @string/pref_camera_picturesize_entry_3264x2448 8M
       
       
3:2
(如果手机屏幕比例是3:2,这像素就是全屏像素)
1024x688 @string/pref_camera_picturesize_entry_1024x768 1M
1440x960 @string/pref_camera_picturesize_entry_1280x960 1.3M
2048x1360 @string/pref_camera_picturesize_entry_2048x1536 3M
2560x1712 @string/pref_camera_picturesize_entry_2592x1936 5M
       
备注 以上是92新平台本身支持的像素,MTK更新到Camera源码中的。
如有特殊差值需求,只要摄像头物理像素支持,或差值后支持,也可满足,但是要满足以下像素条件:(假设宽为w,高为h,想要个18M的像素)
1.w,h都是16的倍数
2.w:h = 4:3(或16:9,根据需求定)
3.w*h = 18M(根据需求定)
满足以上条件的w,h就可以做差值
另外:差值最好在以下范围内:VGA->2M(或3M),2M->5M,5M->8M,8M->12M,12M->18M(再大还没遇到过

 

计算差值规则:

1.    插值的倍数只能小于等于16倍,也就是说假如是1M的sensor,那最多只能插值到16M;

2.    插值后的width和height都不能超过8192,也就是picture size设置的width和height的大小都不能超过8192;

3.由于hardware jpeg encoder的限制,插值时设置的width和height请您分别都设为16的整数倍,若设置非16整数倍的width或height,则可能导致拍出来的图片会有异常(如图片扭曲、花屏、连拍的图片绿屏)。

4.摄像头物理像素支持(??)

5. 计算差值可以先尝试4:3再试16:9 ,例如18M的差值:

4:3:

x = 16 * 4 * n, y = 16 * 3 * n,n的值大约为77(选76为佳)


二、Camera插值在底层已经做好,我们只需要在hal和app层添加一个对应的picture size即可(以4096x3072为例

(一)中间层修改

 

1.mediatek\custom\<project>\hal\imgsensor\<sensor name>\config.ftbl.<sensor name>.h    

 

(若没有该文件,则修改

 

mediatek\custom\<project>\hal\imgsensor\src\config.ftbl.common_raw.h

 

或者config.ftbl.common_yuv.h

 

 

在如下定义picture size的地方增加您想要的size (宽和高必须是16的整数倍,宽高比例建议先用4:3的验证测试),如果已经包含您要加的size,就不需要再增加。

 

 

 

#if 1

 

//  Picture Size

 

FTABLE_CONFIG_AS_TYPE_OF_DEFAULT_VALUES(

 

KEY_AS_(MtkCameraParameters::KEY_PICTURE_SIZE),

 

SCENE_AS_DEFAULT_SCENE(

 

ITEM_AS_DEFAULT_("2560x1920"),

 

ITEM_AS_VALUES_(

 

"320x240",      "640x480",      "1024x768",     "1280x720",     "1280x768",     "1280x960"

 

)

 

),

 

)

 

#endif

 

 

 

例如:

 

//  Picture Size

 

FTABLE_CONFIG_AS_TYPE_OF_DEFAULT_VALUES(

 

KEY_AS_(MtkCameraParameters::KEY_PICTURE_SIZE),

 

SCENE_AS_DEFAULT_SCENE(

 

ITEM_AS_DEFAULT_("2560x1920"),

 

ITEM_AS_VALUES_(

 

"320x240",      "640x480",      "1024x768",     "1280x720",     "1280x768",     "1280x960", "4096x3072"

 

)

 

),

 

)

 

#endif

 

 

 

(二) app层的修改可以按照如下来修改:

 

1.alps\packages\apps\LegacyCamera\res\values\strings.xml

 

增加您想要的size,如果已经包含您要加的size,就不需要再增加

(注意最好添加到最上面一行)

 

 <string name="pref_camera_picturesize_entry_3264x2448">8M pixels</string>

 

<string name="pref_camera_picturesize_entry_2592x1936">5M pixels</string>

 

<string name="pref_camera_picturesize_entry_2048x1536">3M pixels</string>

 

<string name="pref_camera_picturesize_entry_1600x1200">2M pixels</string>

 

<string name="pref_camera_picturesize_entry_1280x960">1.3M pixels</string>

 

<string name="pref_camera_picturesize_entry_1024x768">1M pixels</string>

 

<string name="pref_camera_picturesize_entry_640x480">VGA</string>

 

<string name="pref_camera_picturesize_entry_320x240">QVGA</string>

 

 

 

例如:

 

<string name="pref_camera_picturesize_entry_4096x3072">12M Pixels</string>

 

<string name="pref_camera_picturesize_entry_3264x2448">8M pixels</string>

 

<string name="pref_camera_picturesize_entry_2592x1936">5M pixels</string>

 

<string name="pref_camera_picturesize_entry_2048x1536">3M pixels</string>

 

<string name="pref_camera_picturesize_entry_1600x1200">2M pixels</string>

 

<string name="pref_camera_picturesize_entry_1280x960">1.3M pixels</string>

 

<string name="pref_camera_picturesize_entry_1024x768">1M pixels</string>

 

<string name="pref_camera_picturesize_entry_640x480">VGA</string>

 

<string name="pref_camera_picturesize_entry_320x240">QVGA</string>

 

 

 

2.alps\packages\apps\LegacyCamera\res\values\arrays.xml

 

<string-array name="pref_camera_picturesize_entries" translatable="false">

 

<!-- TODO: Change to a better name of the preference.

 

The first element of the array should be

 

"pref_camera_picturesize_entry_2592x1944". However, we are too

 

late for the translation. Since we show the same label as the

 

second item, we just use the second one instead.

 

-->

 

<item>@string/pref_camera_picturesize_entry_3264x2448</item>

 

<item>@string/pref_camera_picturesize_entry_2592x1936</item>

 

<item>@string/pref_camera_picturesize_entry_2592x1936</item>

 

<item>@string/pref_camera_picturesize_entry_2592x1936</item>

 

<item>@string/pref_camera_picturesize_entry_2048x1536</item>

 

<item>@string/pref_camera_picturesize_entry_1600x1200</item>

 

<item>@string/pref_camera_picturesize_entry_1280x960</item>

 

<item>@string/pref_camera_picturesize_entry_1024x768</item>

 

<item>@string/pref_camera_picturesize_entry_640x480</item>

 

<item>@string/pref_camera_picturesize_entry_320x240</item>

 

</string-array>

 

 

 

增加您想要的size,如果已经包含您要加的size,就不需要再增加

 

例如:

 

<string-array name="pref_camera_picturesize_entries" translatable="false">

 

<!-- TODO: Change to a better name of the preference.

 

The first element of the array should be

 

"pref_camera_picturesize_entry_2592x1944". However, we are too

 

late for the translation. Since we show the same label as the

 

second item, we just use the second one instead.

 

-->

 

<item>@string/pref_camera_picturesize_entry_4096x3072</item>

 

<item>@string/pref_camera_picturesize_entry_3264x2448</item>

 

<item>@string/pref_camera_picturesize_entry_2592x1936</item>

 

<item>@string/pref_camera_picturesize_entry_2592x1936</item>

 

<item>@string/pref_camera_picturesize_entry_2592x1936</item>

 

<item>@string/pref_camera_picturesize_entry_2048x1536</item>

 

<item>@string/pref_camera_picturesize_entry_1600x1200</item>

 

<item>@string/pref_camera_picturesize_entry_1280x960</item>

 

<item>@string/pref_camera_picturesize_entry_1024x768</item>

 

<item>@string/pref_camera_picturesize_entry_640x480</item>

 

<item>@string/pref_camera_picturesize_entry_320x240</item>

 

</string-array>

 

 

 

3.alps\packages\apps\LegacyCamera\res\values\arrays.xml (与2.是同一个文件,注意两个添加位置顺序必须完全一致)

 

<string-array name="pref_camera_picturesize_entryvalues" translatable="false">

 

<item>3264x2448</item>

 

<item>2592x1944</item>

 

<item>2592x1936</item>

 

<item>2560x1920</item>

 

<item>2048x1536</item>

 

<item>1600x1200</item>

 

<item>1280x960</item>

 

<item>1024x768</item>

 

<item>640x480</item>

 

<item>320x240</item>

 

</string-array>

 

 

 

增加您想要的size,如果已经包含你要加的size,就不需要再增加

 

例如:

 

<string-array name="pref_camera_picturesize_entryvalues" translatable="false">

 

<item>4096x3072</item>

 

<item>3264x2448</item>

 

<item>2592x1944</item>

 

<item>2592x1936</item>

 

<item>2560x1920</item>

 

<item>2048x1536</item>

 

<item>1600x1200</item>

 

<item>1280x960</item>

 

<item>1024x768</item>

 

<item>640x480</item>

 

<item>320x240</item>

 

</string-array>

 

 

 

4.\packages\apps\LegacyCamera\src\com\Android\Camera\CameraSettings.java(这个文件不需要修改,知道即可)

 public static void initialCameraPictureSize(
            Context context, Parameters parameters) {
        // When launching the camera app first time,
we will set the picture
        // size to the first one in the list defined in "arrays.xml"
and is also
        // supported by the driver.
        List<Size> supported = parameters.getSupportedPictureSizes();
        if (supported == null) return;
        for (String candidate : context.getResources().getStringArray(
                R.array.pref_camera_picturesize_entryvalues)) {
            if (setCameraPictureSize(candidate, supported, parameters)) {
                SharedPreferences.Editor editor = ComboPreferences
                        .get(context).edit();
                editor.putString(KEY_PICTURE_SIZE, candidate);
                editor.apply();
                return;
            }
        }
        Log.e(TAG, "No supported picture size found");
    }


附件:

<!-- Camera Preferences Picture size dialog box entries -->
    <string-array name="pref_camera_picturesize_entries" translatable="false">
        <!-- TODO: Change to a better name of the preference.
                The first element of the array sould be
                "pref_camera_picturesize_entry_2592x1944". However, we are too
                late for the translation. Since we show the same label as the
                second item, we just use the second one instead.
        -->
        <item>@string/pref_camera_picturesize_entry_2592x1936</item>
        <item>@string/pref_camera_picturesize_entry_2592x1936</item>
        <item>@string/pref_camera_picturesize_entry_2592x1936</item>
        <item>@string/pref_camera_picturesize_entry_2048x1536</item>
        <item>@string/pref_camera_picturesize_entry_1600x1200</item>
        <item>@string/pref_camera_picturesize_entry_1280x960</item>
        <item>@string/pref_camera_picturesize_entry_1024x768</item>
        <item>@string/pref_camera_picturesize_entry_640x480</item>
        <item>@string/pref_camera_picturesize_entry_320x240</item>
    </string-array>


    <!-- When launching the camera app first time, we will set the picture
         size to the first one in the list that is also supported by the
         driver -->
    <string-array name="pref_camera_picturesize_entryvalues" translatable="false">
        <item>2592x1944</item>
        <item>2592x1936</item>
        <item>2560x1920</item>
        <item>2048x1536</item>
        <item>1600x1200</item>
        <item>1280x960</item>
        <item>1024x768</item>
        <item>640x480</item>
        <item>320x240</item>
    </string-array>

总结:实际的开发中,不同于ZSD需要软件也修改,差值仅仅修改config.ftbl.<sensor name>.h中即可,app层根本不用修改,实际验证有效。


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值