Skip to content

Instantly share code, notes, and snippets.

@pnemonic78
pnemonic78 / YUV_I420toNV21.java
Created December 24, 2017 15:38
Convert YUV I420 to NV21
/** Convert I420 (YYYYYYYY:UU:VV) to NV21 (YYYYYYYYY:VUVU) */
public byte[] I420toNV21(final byte[] input, byte[] output, final int width, final int height) {
if (output == null) {
output = new byte[input.length];
}
final int size = width * height;
final int quarter = size / 4;
final int v0 = size + quarter;
System.arraycopy(input, 0, output, 0, size); // Y is same
@pnemonic78
pnemonic78 / YUV_YV12toNV21.java
Created December 24, 2017 15:39
Convert YUV YV12 to NV21
/** Convert YV12 (YYYYYYYY:UU:VV) to NV21 (YYYYYYYYY:VUVU) */
public byte[] YV12toNV21(final byte[] input, byte[] output, final int width, final int height) {
if (output == null) {
output = new byte[input.length];
}
final int size = width * height;
final int quarter = size / 4;
final int u0 = size + quarter;
System.arraycopy(input, 0, output, 0, size); // Y is same

Keybase proof

I hereby claim:

  • I am pnemonic78 on github.
  • I am pnemonic (https://keybase.io/pnemonic) on keybase.
  • I have a public key ASAjeu2za3lmo8DaxNxD_mMgSAIRkmjF82qBwrKIEtV1Zgo

To claim this, I am signing this object:

@pnemonic78
pnemonic78 / EnumIntSerializer.kt
Last active September 25, 2024 12:42
Kotlin JSON serializer for enum int
import kotlin.enums.EnumEntries
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.SerializationException
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder