Skip to content

Instantly share code, notes, and snippets.

View awxkee's full-sized avatar

Radzivon Bartoshyk awxkee

  • Lisbon
View GitHub Profile
@awxkee
awxkee / sixth_root.rs
Last active September 12, 2025 21:07
Sixth root
/*
Copyright 2024 Radzivon Bartoshyk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@awxkee
awxkee / bilinear_yuv.rs
Last active June 15, 2025 08:53
Bilinear YUV upsampling
/*
* Copyright (c) Radzivon Bartoshyk, 6/2025. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
trait StreamingIO: Read + Seek {}
struct IODynWrapper {
cursor: Box<dyn StreamingIO>,
buffer: Vec<u8>,
position: usize,
}
impl Read for IODynWrapper {
#[inline]
@awxkee
awxkee / histogram.rs
Last active January 19, 2025 22:52
Dynamic Image Histogram
use image::{DynamicImage, ImageReader};
use num_traits::AsPrimitive;
use std::fmt::Debug;
#[derive(Clone, Debug)]
pub struct ImageStatistics<A: Clone + Debug> {
pub hist_bins: Vec<Vec<A>>,
pub distinct_colors: u64,
}
@awxkee
awxkee / reduction_div.rs
Created December 18, 2024 15:27
Reduction table
const REDUCTION_TABLE: [[u32; 2]; 255] = [
[0, 0],
[0, 1],
[43691, 1],
[0, 2],
[52429, 2],
[43691, 2],
[9363, 66],
[0, 3],
[58255, 3],
@awxkee
awxkee / OpenGLESResizeRenderPass.kt
Last active November 30, 2024 15:24
Resing methods OpenGL
package com.android.example.rsmigration
import android.content.Context
import android.graphics.Bitmap
import android.opengl.EGL14
import android.opengl.EGL15
import android.opengl.EGLConfig
import android.opengl.EGLContext
import android.opengl.EGLDisplay
import android.opengl.EGLExt
@awxkee
awxkee / Gauss.kt
Last active June 10, 2025 02:46
OpenGLES 2/3 Gaussian Blur
package com.example.simpleegl
import android.app.ActivityManager
import android.content.Context
import android.graphics.Bitmap
import android.opengl.EGL14
import android.opengl.EGL15
import android.opengl.EGLConfig
import android.opengl.EGLContext
import android.opengl.EGLDisplay
#include <jni.h>
#include <android/bitmap.h>
#include <vector>
#include "JniExceptions.h"
#include "XScaler.h"
#include "Rgb1010102toF16.h"
#include "RGBAlpha.h"
#include "libyuv/convert_argb.h"
#include "libyuv/convert_from_argb.h"
#include "CopyUnaligned.h"
@awxkee
awxkee / animatedavifsdwebimage.swift
Created October 17, 2023 03:54
Animated AVIF SDWebImage
import avifc
public class SDWebImageAVIFAnimatedCoder: NSObject, SDAnimatedImageCoder {
private let decoder: AVIFAnimatedDecoder
public required init?(animatedImageData data: Data?, options: [SDImageCoderOption : Any]? = nil) {
guard let data, let mDecoder = AVIFAnimatedDecoder(data: data) else {
return nil
}
@awxkee
awxkee / avifanimated.swift
Created October 17, 2023 03:06
Avif animated gist
import avifc
Task(priority: .high) {
let animationAvifUrl = Bundle.main.url(forResource: "animation_6", withExtension: "avif")!
var data = try! Data(contentsOf: animationAvifUrl)
let animationDecoder = AVIFAnimatedDecoder(data: data)!
let framesCount = animationDecoder.framesCount()
var currentFrame = framesCount
while (true) {
if currentFrame >= framesCount {