package com.foxx.androidcast.media;

/*********************************************************************
 * RgbToYuv420Test.java
 * Created at: Sat 16 May 2026 18:50:36 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class RgbToYuv420Test
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (2 commits, 32 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	1c56cd45207ad3363b04c4357d89a21e37a19a23b018b63bd0fa72e5afcdafcd
**********************************************************************/
import org.junit.Test;

import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertEquals;

public class RgbToYuv420Test {

    @Test
    public void redPixelDiffersBetweenYAndChromaPlanes() {
        int[] argb = {0xFFFF0000, 0, 0, 0xFFFF0000};
        byte[] i420 = RgbToYuv420.fromArgb(argb, 2, 2, RgbToYuv420.Layout.I420);
        int y = i420[0] & 0xff;
        int u = i420[4] & 0xff;
        int v = i420[5] & 0xff;
        assertNotEquals(y, u);
        assertNotEquals(y, v);
    }

    @Test
    public void bufferSizeMatchesI420Layout() {
        assertEquals(960 * 540 + (960 * 540) / 2, RgbToYuv420.bufferSize(960, 540));
    }
}
