Compare commits
4 Commits
407bbe2ed7
...
main
Author | SHA1 | Date | |
---|---|---|---|
58d9b7ee5e | |||
53c68fa564 | |||
d646e95a0d | |||
fc3a5300af |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -47,3 +47,4 @@ CMakeUserPresets.json
|
|||||||
*.app
|
*.app
|
||||||
|
|
||||||
build/
|
build/
|
||||||
|
.cache/
|
||||||
|
@@ -1,5 +1,20 @@
|
|||||||
#ifndef CHARGE_VIDEO_BASE_H
|
#ifndef CHARGE_VIDEO_BASE_H
|
||||||
#define CHARGE_VIDEO_BASE_H
|
#define CHARGE_VIDEO_BASE_H
|
||||||
|
|
||||||
|
#include <Corrade/Containers/Array.h>
|
||||||
|
#include <Magnum/GL/Texture.h>
|
||||||
|
#include <Magnum/Image.h>
|
||||||
|
#include <Magnum/ImageView.h>
|
||||||
|
#include <Magnum/Magnum.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <functional>
|
||||||
|
#include <queue>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace ChargeVideo {
|
||||||
|
namespace _ffmpeg {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavcodec/codec.h>
|
#include <libavcodec/codec.h>
|
||||||
@@ -14,26 +29,11 @@ extern "C" {
|
|||||||
#include <libswresample/swresample.h>
|
#include <libswresample/swresample.h>
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
}
|
}
|
||||||
|
} // namespace _ffmpeg
|
||||||
#include <Corrade/Containers/Array.h>
|
|
||||||
|
|
||||||
#include <Magnum/GL/Texture.h>
|
|
||||||
#include <Magnum/Image.h>
|
|
||||||
#include <Magnum/ImageView.h>
|
|
||||||
#include <Magnum/Magnum.h>
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <functional>
|
|
||||||
#include <queue>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace Corrade;
|
using namespace Corrade;
|
||||||
using namespace Magnum;
|
using namespace Magnum;
|
||||||
using namespace Math::Literals;
|
using namespace Math::Literals;
|
||||||
|
|
||||||
namespace ChargeVideo {
|
|
||||||
// ======================== CLASSES ========================
|
// ======================== CLASSES ========================
|
||||||
class Time {
|
class Time {
|
||||||
public:
|
public:
|
||||||
@@ -85,13 +85,13 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Contextes
|
// Contextes
|
||||||
AVFormatContext *ctx;
|
_ffmpeg::AVFormatContext *ctx;
|
||||||
const AVCodec *vCodec;
|
const _ffmpeg::AVCodec *vCodec;
|
||||||
const AVCodec *aCodec;
|
const _ffmpeg::AVCodec *aCodec;
|
||||||
AVCodecContext *vCodecCtx, *aCodecCtx;
|
_ffmpeg::AVCodecContext *vCodecCtx, *aCodecCtx;
|
||||||
AVStream *videoStream, *audioStream;
|
_ffmpeg::AVStream *videoStream, *audioStream;
|
||||||
struct SwsContext *swsCtx = NULL; // Visual
|
struct _ffmpeg::SwsContext *swsCtx = NULL; // Visual
|
||||||
struct SwrContext *swrCtx = NULL; // Audio
|
struct _ffmpeg::SwrContext *swrCtx = NULL; // Audio
|
||||||
uint16_t ID = 0;
|
uint16_t ID = 0;
|
||||||
|
|
||||||
// Time specific
|
// Time specific
|
||||||
@@ -101,7 +101,7 @@ private:
|
|||||||
|
|
||||||
// Buffering
|
// Buffering
|
||||||
std::queue<Image2D> frameBuffer;
|
std::queue<Image2D> frameBuffer;
|
||||||
uint32_t bufferMaxFrames = 0, p = 0, z = 0;
|
uint32_t bufferMaxFrames = 0;
|
||||||
|
|
||||||
// SAR / Sizing
|
// SAR / Sizing
|
||||||
uint32_t scaleFactor = 1;
|
uint32_t scaleFactor = 1;
|
||||||
@@ -110,10 +110,11 @@ private:
|
|||||||
bool frameSet = false;
|
bool frameSet = false;
|
||||||
void continueVideo();
|
void continueVideo();
|
||||||
Containers::Array<char> loadNextFrame();
|
Containers::Array<char> loadNextFrame();
|
||||||
inline void frameDebug(AVFrame *frame);
|
inline void frameDebug(_ffmpeg::AVFrame *frame);
|
||||||
inline void frameSetScaleSAR(AVFrame *frame);
|
inline void frameSetScaleSAR(_ffmpeg::AVFrame *frame);
|
||||||
inline void frameConvert(AVFrame *sourceFrame, AVFrame *convertedFrame);
|
inline void frameConvert(_ffmpeg::AVFrame *sourceFrame,
|
||||||
inline void frameFlip(AVFrame *frame);
|
_ffmpeg::AVFrame *convertedFrame);
|
||||||
|
inline void frameFlip(_ffmpeg::AVFrame *frame);
|
||||||
|
|
||||||
inline void restartVideo();
|
inline void restartVideo();
|
||||||
void dumpAndRefillBuffer();
|
void dumpAndRefillBuffer();
|
||||||
|
@@ -1,12 +1,15 @@
|
|||||||
#include "ChargeVideo.hpp"
|
#include "ChargeVideo.hpp"
|
||||||
|
|
||||||
|
#include <Corrade/Utility/Utility.h>
|
||||||
|
|
||||||
#include <Magnum/GL/TextureFormat.h>
|
#include <Magnum/GL/TextureFormat.h>
|
||||||
#include <Magnum/Math/Functions.h>
|
#include <Magnum/Math/Functions.h>
|
||||||
#include <Magnum/PixelFormat.h>
|
#include <Magnum/PixelFormat.h>
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
using namespace ChargeVideo;
|
using namespace ChargeVideo;
|
||||||
|
using namespace _ffmpeg;
|
||||||
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
// ================== Video Construct/Destruct ==================
|
// ================== Video Construct/Destruct ==================
|
||||||
// ShouldVideoLoop default is true
|
// ShouldVideoLoop default is true
|
||||||
@@ -131,7 +134,6 @@ void Video::continueVideo() {
|
|||||||
Pause(); // Here we did that (check comment below)
|
Pause(); // Here we did that (check comment below)
|
||||||
return; // We remove what we are returning TO
|
return; // We remove what we are returning TO
|
||||||
}
|
}
|
||||||
Utility::Debug{} << "Audio" << p << "Video" << z;
|
|
||||||
restartVideo();
|
restartVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,9 +181,6 @@ Containers::Array<char> Video::loadNextFrame() {
|
|||||||
swr_convert(swrCtx, convertedAudioFrame->data,
|
swr_convert(swrCtx, convertedAudioFrame->data,
|
||||||
convertedAudioFrame->nb_samples, audioFrame->data,
|
convertedAudioFrame->nb_samples, audioFrame->data,
|
||||||
audioFrame->nb_samples);
|
audioFrame->nb_samples);
|
||||||
|
|
||||||
p++;
|
|
||||||
Utility::Debug{} << "Loaded an audio frame";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,14 +197,11 @@ Containers::Array<char> Video::loadNextFrame() {
|
|||||||
|
|
||||||
frameConvert(frame, convertedFrame);
|
frameConvert(frame, convertedFrame);
|
||||||
// FrameDebug(convertedFrame);
|
// FrameDebug(convertedFrame);
|
||||||
z++;
|
|
||||||
Utility::Debug{} << "Loaded a video frame";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
av_packet_unref(packet);
|
av_packet_unref(packet);
|
||||||
}
|
}
|
||||||
Utility::Debug{} << "Finished Load";
|
|
||||||
// You cannot use strlen(data) it does not work
|
// You cannot use strlen(data) it does not work
|
||||||
size_t dataSize = av_image_get_buffer_size(
|
size_t dataSize = av_image_get_buffer_size(
|
||||||
static_cast<AVPixelFormat>(convertedFrame->format), Dimensions.x(),
|
static_cast<AVPixelFormat>(convertedFrame->format), Dimensions.x(),
|
||||||
|
Reference in New Issue
Block a user