All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jcodec.api.transcode.PixelStoreImpl Maven / Gradle / Ivy

There is a newer version: 0.2.5
Show newest version
package org.jcodec.api.transcode;

import java.util.ArrayList;
import java.util.List;

import org.jcodec.common.model.ColorSpace;
import org.jcodec.common.model.Picture;

public class PixelStoreImpl implements PixelStore {
    private List buffers = new ArrayList();

    @Override
    public LoanerPicture getPicture(int width, int height, ColorSpace color) {
        for (Picture picture : buffers) {
            if (picture.getWidth() == width && picture.getHeight() == height
                    && picture.getColor() == color) {
                buffers.remove(picture);
                return new LoanerPicture(picture, 1);
            }
        }
        return new LoanerPicture(Picture.create(width, height, color), 1);
    }

    @Override
    public void putBack(LoanerPicture frame) {
        frame.decRefCnt();
        if (frame.unused()) {
            Picture pixels = frame.getPicture();
            pixels.setCrop(null);
            buffers.add(pixels);
        }
    }

    @Override
    public void retake(LoanerPicture frame) {
        frame.incRefCnt();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy