YUV420抖音蓝线挑战代码(JAVA版)


    static byte[] buffer_blueLine_Y = null;
    static byte[] buffer_blueLine_U = null;
    static byte[] buffer_blueLine_V = null;
    static byte[] buffer_result = null;
    static int blueHeight = 0;
    static int speed = 1;

    public static byte[] doBlueLining(byte[] bytes, int width, int height) {
        if (blueHeight >= height) return buffer_result;
        if (buffer_blueLine_Y == null) {
            buffer_blueLine_Y = new byte[width * height];
        }
        if (buffer_blueLine_U == null) {
            buffer_blueLine_U = new byte[width * height / 4];
        }
        if (buffer_blueLine_V == null) {
            buffer_blueLine_V = new byte[width * height / 4];
        }
        if (buffer_result == null) {
            buffer_result = new byte[width * height * 3 / 2];
        }
        //把新的蓝线这一条的数据添加到蓝线数据中

        //把Y的最新一行数据提出来
        for (int i = blueHeight * width; i < (blueHeight + 2 * speed) * width; i++) {
            buffer_blueLine_Y[i] = bytes[i];
        }
        //把U的最新一行数据提出来
        for (int i = (blueHeight / 2 * width / 2); i < ((blueHeight / 2 + speed) * width / 2); i++) {
            buffer_blueLine_U[i] = bytes[width * height + i];
        }
        //把V的最新一行数据提出来
        for (int i = (blueHeight / 2 * width / 2); i < ((blueHeight / 2 + speed) * width / 2); i++) {
            buffer_blueLine_V[i] = bytes[width * height * 5 / 4 + i];
        }
        //把Y提出来的数据放到result中
        for (int i = 0; i < (blueHeight + 2 * speed) * width; i++) {
            buffer_result[i] = buffer_blueLine_Y[i];
        }
        //把Y剩下的数据放到result中
        for (int i = (blueHeight + 2 * speed) * width - 1; i < width * height; i++) {
            buffer_result[i] = bytes[i];
        }
        //把U提出来的数据放到result中
        for (int i = 0; i < (blueHeight / 2 + speed) * width / 2; i++) {
            buffer_result[width * height + i] = buffer_blueLine_U[i];
        }
        //把U剩下的数据放到result中
        for (int i = width * height + (blueHeight / 2 + speed) * width / 2 - 1; i < width * height * 5 / 4; i++) {
            buffer_result[i] = bytes[i];
        }
        //把V提出来的数据放到result中
        for (int i = 0; i < (blueHeight / 2 + speed) * width / 2; i++) {
            buffer_result[width * height * 5 / 4 + i] = buffer_blueLine_V[i];
        }
        //把V剩下的数据放到result中
        for (int i = width * height * 5 / 4 + (blueHeight / 2 + speed) * width / 2 - 1; i < width * height * 3 / 2; i++) {
            buffer_result[i] = bytes[i];
        }
        
        blueHeight += 2 * speed;
        return buffer_result;
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值