Problems when scaling a YUV image using libyuv library

前端 未结 5 921
滥情空心
滥情空心 2021-01-07 17:12

I\'m developing a camera app based on Camera API 2 and I have found several problems using the libyuv. I want to convert YUV_420_888 images retriev

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-07 17:49

    You have an issue with the input size of the frame:

    It should be:

    int input_array_size = env->GetArrayLength(yuvByteArray_);
    int input_size = input_array_size * 2 / 3; //This is the frame size
    

    For example, If you have a Frame that is 6x4

    Chanel y size: 6*4 = 24

     1 2 3 4 5 6
     _ _ _ _ _ _
    |_|_|_|_|_|_| 1
    |_|_|_|_|_|_| 2
    |_|_|_|_|_|_| 3
    |_|_|_|_|_|_| 4
    

    Chanel u size: 3*2 = 6

      1   2   3 
     _ _ _ _ _ _
    |   |   |   | 
    |_ _|_ _|_ _| 1
    |   |   |   | 
    |_ _|_ _|_ _| 2
    

    Chanel v size: 3*2 = 6

      1   2   3 
     _ _ _ _ _ _
    |   |   |   | 
    |_ _|_ _|_ _| 1
    |   |   |   | 
    |_ _|_ _|_ _| 2
    

    Array Size = 6*4+3*2+3*2 = 36
    But actual Frame Size = channel y Size = 36 * 2 / 3 = 24

提交回复
热议问题