osci-render/Source/img/ImageParser.h

59 wiersze
1.7 KiB
C
Czysty Zwykły widok Historia

2024-05-11 22:10:54 +00:00
#pragma once
#include "../shape/OsciPoint.h"
2024-05-11 22:10:54 +00:00
#include <JuceHeader.h>
#include "../shape/Shape.h"
#include "../svg/SvgParser.h"
#include "../shape/Line.h"
#include "../concurrency/ReadProcess.h"
2024-05-11 22:10:54 +00:00
class OscirenderAudioProcessor;
class CommonPluginEditor;
2024-05-11 22:10:54 +00:00
class ImageParser {
public:
ImageParser(OscirenderAudioProcessor& p, juce::String fileName, juce::MemoryBlock image);
~ImageParser();
void setFrame(int index);
OsciPoint getSample();
2024-05-11 22:10:54 +00:00
private:
void findNearestNeighbour(int searchRadius, float thresholdPow, int stride, bool invert);
void resetPosition();
2024-06-02 16:15:04 +00:00
float getPixelValue(int x, int y, bool invert);
int getPixelIndex(int x, int y);
2024-06-02 16:15:04 +00:00
void findWhite(double thresholdPow, bool invert);
bool isOverThreshold(double pixel, double thresholdValue);
int jumpFrequency();
void handleError(juce::String message);
void processGifFile(juce::File& file);
void processImageFile(juce::File& file);
void processVideoFile(juce::File& file);
bool loadAllVideoFrames(const juce::File& file, const juce::File& ffmpegFile);
bool isVideoFile(const juce::String& extension) const;
const juce::String ALGORITHM = "HILLIGOSS";
2024-05-11 22:10:54 +00:00
OscirenderAudioProcessor& audioProcessor;
juce::Random rng;
int frameIndex = 0;
std::vector<std::vector<uint8_t>> frames;
std::vector<bool> visited;
int currentX, currentY;
int width = -1;
int height = -1;
2024-05-11 22:10:54 +00:00
int count = 0;
// Video processing fields
ReadProcess ffmpegProcess;
bool isVideo = false;
std::unique_ptr<juce::TemporaryFile> temp;
std::vector<uint8_t> frameBuffer;
int videoFrameSize = 0;
// experiments
double scanX = -1;
double scanY = 1;
int scanCount = 0;
};