栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

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

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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;
    }

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/285082.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号