Compare commits
20 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
0d9222dd7e | 11 months ago |
|
|
0bfe81da12 | 11 months ago |
|
|
844104b3ef | 11 months ago |
|
|
14dbf9269b | 11 months ago |
|
|
22e2838843 | 11 months ago |
|
|
bccdfc9268 | 11 months ago |
|
|
4b8d0732a6 | 11 months ago |
|
|
1db9be8367 | 11 months ago |
|
|
776a1b8ce0 | 11 months ago |
|
|
6048141bd4 | 11 months ago |
|
|
e0bf3559fc | 11 months ago |
|
|
cdc17350db | 11 months ago |
|
|
73017258ed | 11 months ago |
|
|
a676058385 | 11 months ago |
|
|
1bc9e6f732 | 11 months ago |
|
|
0d6892df17 | 11 months ago |
|
|
7ff37fcee5 | 11 months ago |
|
|
8add84ec2e | 11 months ago |
|
|
2c1ee5a305 | 11 months ago |
|
|
d2f2568b16 | 11 months ago |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,135 +0,0 @@
|
||||
#include "FFVideoFormatConvert.h"
|
||||
#include "VideoObjNetwork.h"
|
||||
|
||||
CFFVideoFormatConvert::CFFVideoFormatConvert(void)
|
||||
: m_img_convert_ctx(NULL)
|
||||
, m_pFrame(NULL)
|
||||
, m_pBuffer(NULL), m_uBufferSize(0)
|
||||
, m_iWidth(0), m_iHeight(0)
|
||||
, m_pImage(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CFFVideoFormatConvert::~CFFVideoFormatConvert(void)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void CFFVideoFormatConvert::Close()
|
||||
{
|
||||
if (m_img_convert_ctx)
|
||||
{
|
||||
sws_freeContext(m_img_convert_ctx);
|
||||
m_img_convert_ctx = NULL;
|
||||
}
|
||||
|
||||
if (m_pFrame)
|
||||
{
|
||||
av_frame_free(&m_pFrame);
|
||||
m_pFrame = NULL;
|
||||
}
|
||||
|
||||
if (m_pBuffer)
|
||||
{
|
||||
av_free(m_pBuffer);
|
||||
m_pBuffer = NULL;
|
||||
m_uBufferSize = 0;
|
||||
}
|
||||
|
||||
if (m_pImage != NULL)
|
||||
{
|
||||
delete m_pImage;
|
||||
m_pImage = NULL;
|
||||
}
|
||||
|
||||
m_iWidth = 0;
|
||||
m_iHeight = 0;
|
||||
}
|
||||
|
||||
bool CFFVideoFormatConvert::RGB32toYUV420P(const QImage* pIn, AVFrame** pOut)
|
||||
{
|
||||
// reinitialize object if image width or height changed
|
||||
if (pIn->width() != m_iWidth || pIn->height() != m_iHeight)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
if (m_pBuffer == NULL)
|
||||
{
|
||||
m_iWidth = pIn->width();
|
||||
m_iHeight = pIn->height();
|
||||
m_uBufferSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pIn->width(), pIn->height(), 1);
|
||||
m_pBuffer = (uint8_t *) av_malloc(m_uBufferSize);
|
||||
}
|
||||
|
||||
if (m_pFrame == NULL)
|
||||
{
|
||||
m_pFrame = av_frame_alloc();
|
||||
m_pFrame->width = pIn->width();
|
||||
m_pFrame->height = pIn->height();
|
||||
av_image_fill_arrays(m_pFrame->data, m_pFrame->linesize,
|
||||
m_pBuffer, AV_PIX_FMT_YUV420P, pIn->width(), pIn->height(), 1);
|
||||
}
|
||||
|
||||
if (m_img_convert_ctx == NULL)
|
||||
{
|
||||
m_img_convert_ctx = sws_getContext(pIn->width(), pIn->height(),
|
||||
AV_PIX_FMT_RGB32,
|
||||
pIn->width(), pIn->height(),
|
||||
AV_PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
const uint8_t *const srcSlice[] = { pIn->bits() };
|
||||
const int srcStride[] = { pIn->bytesPerLine()};
|
||||
sws_scale(m_img_convert_ctx,
|
||||
srcSlice,
|
||||
srcStride, 0, pIn->height(),
|
||||
m_pFrame->data,
|
||||
m_pFrame->linesize);
|
||||
|
||||
*pOut = m_pFrame;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFFVideoFormatConvert::YUV420P2RGB32(const AVFrame* pIn, QImage** pOut)
|
||||
{
|
||||
// reinitialize object if image width or height changed
|
||||
if (pIn->width != m_iWidth || pIn->height != m_iHeight)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
if (m_pBuffer == NULL)
|
||||
{
|
||||
m_iWidth = pIn->width;
|
||||
m_iHeight = pIn->height;
|
||||
m_uBufferSize = av_image_get_buffer_size(AV_PIX_FMT_RGB32, pIn->width, pIn->height, 1);
|
||||
m_pBuffer = (uint8_t *)av_malloc(m_uBufferSize);
|
||||
}
|
||||
|
||||
if (m_pFrame == NULL)
|
||||
{
|
||||
m_pFrame = av_frame_alloc();
|
||||
av_image_fill_arrays(m_pFrame->data, m_pFrame->linesize,
|
||||
m_pBuffer, AV_PIX_FMT_RGB32, pIn->width, pIn->height, 1);
|
||||
}
|
||||
|
||||
if (m_img_convert_ctx == NULL)
|
||||
{
|
||||
m_img_convert_ctx = sws_getContext(pIn->width, pIn->height,
|
||||
AV_PIX_FMT_YUV420P,
|
||||
pIn->width, pIn->height,
|
||||
AV_PIX_FMT_RGB32, SWS_BICUBIC, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
sws_scale(m_img_convert_ctx,
|
||||
(uint8_t const * const *)pIn->data,
|
||||
pIn->linesize, 0, pIn->height,
|
||||
m_pFrame->data,
|
||||
m_pFrame->linesize);
|
||||
|
||||
*pOut = new QImage((uchar *)m_pFrame->data[0], m_iWidth, m_iHeight, QImage::Format_RGB32);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
#include <QImage>
|
||||
|
||||
struct AVFrame;
|
||||
struct SwsContext;
|
||||
|
||||
class CFFVideoFormatConvert
|
||||
{
|
||||
public:
|
||||
CFFVideoFormatConvert(void);
|
||||
~CFFVideoFormatConvert(void);
|
||||
|
||||
bool RGB32toYUV420P(const QImage* pIn, AVFrame** pOut);
|
||||
bool YUV420P2RGB32(const AVFrame* pIn, QImage** pOut);
|
||||
private:
|
||||
void Close();
|
||||
private:
|
||||
SwsContext* m_img_convert_ctx;
|
||||
AVFrame* m_pFrame;
|
||||
|
||||
uint8_t* m_pBuffer;
|
||||
uint m_uBufferSize;
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
|
||||
QImage* m_pImage;
|
||||
};
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
#ifndef QTCAMERACAPTURE_H
|
||||
#define QTCAMERACAPTURE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractVideoSurface>
|
||||
#include <QDebug>
|
||||
|
||||
class QtCameraCapture : public QAbstractVideoSurface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum PixelFormat {
|
||||
Format_Invalid,
|
||||
Format_ARGB32,
|
||||
Format_ARGB32_Premultiplied,
|
||||
Format_RGB32,
|
||||
Format_RGB24,
|
||||
Format_RGB565,
|
||||
Format_RGB555,
|
||||
Format_ARGB8565_Premultiplied,
|
||||
Format_BGRA32,
|
||||
Format_BGRA32_Premultiplied,
|
||||
Format_BGR32,
|
||||
Format_BGR24,
|
||||
Format_BGR565,
|
||||
Format_BGR555,
|
||||
Format_BGRA5658_Premultiplied,
|
||||
|
||||
Format_AYUV444,
|
||||
Format_AYUV444_Premultiplied,
|
||||
Format_YUV444,
|
||||
Format_YUV420P,
|
||||
Format_YV12,
|
||||
Format_UYVY,
|
||||
Format_YUYV,
|
||||
Format_NV12,
|
||||
Format_NV21,
|
||||
Format_IMC1,
|
||||
Format_IMC2,
|
||||
Format_IMC3,
|
||||
Format_IMC4,
|
||||
Format_Y8,
|
||||
Format_Y16,
|
||||
|
||||
Format_Jpeg,
|
||||
|
||||
Format_CameraRaw,
|
||||
Format_AdobeDng,
|
||||
|
||||
#ifndef Q_QDOC
|
||||
NPixelFormats,
|
||||
#endif
|
||||
Format_User = 1000
|
||||
};
|
||||
|
||||
Q_ENUM(PixelFormat)
|
||||
|
||||
explicit QtCameraCapture(QObject *parent = 0);
|
||||
|
||||
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
|
||||
|
||||
bool present(const QVideoFrame &frame) override;
|
||||
|
||||
signals:
|
||||
void frameAvailable(QImage frame);
|
||||
|
||||
};
|
||||
|
||||
#endif // QTCAMERACAPTURE_H
|
||||
@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
#define GET_STR(x) #x
|
||||
#define A_VER 3
|
||||
#define T_VER 4
|
||||
|
||||
// vertex shader
|
||||
const char *vString = GET_STR(
|
||||
attribute vec4 vertexIn;
|
||||
attribute vec2 textureIn;
|
||||
varying vec2 textureOut;
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = vertexIn;
|
||||
textureOut = textureIn;
|
||||
}
|
||||
);
|
||||
|
||||
// texture shader
|
||||
const char *tString = GET_STR(
|
||||
varying vec2 textureOut;
|
||||
uniform sampler2D tex_y;
|
||||
uniform sampler2D tex_u;
|
||||
uniform sampler2D tex_v;
|
||||
void main(void)
|
||||
{
|
||||
vec3 yuv;
|
||||
vec3 rgb;
|
||||
yuv.x = texture2D(tex_y, textureOut).r;
|
||||
yuv.y = texture2D(tex_u, textureOut).r - 0.5;
|
||||
yuv.z = texture2D(tex_v, textureOut).r - 0.5;
|
||||
rgb = mat3(1.0, 1.0, 1.0,
|
||||
0.0, -0.39465, 2.03211,
|
||||
1.13983, -0.58060, 0.0) * yuv;
|
||||
gl_FragColor = vec4(rgb, 1.0);
|
||||
}
|
||||
);
|
||||
@ -1,66 +0,0 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libswscale/swscale.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
};
|
||||
|
||||
typedef void (*VideoDataCallback)(int iEncode, int iWidth, int iHeight, const char* pData, long lLen, long lPTS, void* pUserParam);
|
||||
|
||||
class VLKVideoWidget;
|
||||
class CVideoObjNetwork
|
||||
{
|
||||
public:
|
||||
CVideoObjNetwork();
|
||||
virtual ~CVideoObjNetwork();
|
||||
|
||||
virtual bool Open(const std::string& strURL, VLKVideoWidget* pVideoWidget);
|
||||
virtual bool IsOpen();
|
||||
void SetDataCallback(VideoDataCallback pVideoDataCB, long lUserParam);
|
||||
virtual void Clear();
|
||||
virtual void Close();
|
||||
virtual bool StartLocalRecord();
|
||||
virtual void StopLocalRecord();
|
||||
virtual void Capture();
|
||||
private:
|
||||
static void ThreadFunc(CVideoObjNetwork* pThis);
|
||||
virtual void OnThreadFunc();
|
||||
|
||||
bool OpenDemux(const std::string& strURL);
|
||||
void CloseDemux();
|
||||
void WriteLocalRecord(const AVPacket* pkt);
|
||||
static int interrupt_callback(void* para);
|
||||
void ReadPacketLoop();
|
||||
|
||||
bool OpenDecoder(const AVCodecParameters *para);
|
||||
void Send2Decode(const AVPacket* pkt);
|
||||
void Send2Display(const AVFrame* frame);
|
||||
void CloseDecoder();
|
||||
private:
|
||||
static bool m_bInit;
|
||||
std::mutex m_mutex;
|
||||
std::string m_strURL;
|
||||
VLKVideoWidget* m_pVideoWidget;
|
||||
|
||||
AVFormatContext* m_pAVFmtContext;
|
||||
int m_iVideoStreamIndex;
|
||||
int m_iAudioStreamIndex;
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
|
||||
std::thread* m_pThread;
|
||||
bool m_bExit;
|
||||
|
||||
VideoDataCallback m_cbFunc;
|
||||
long m_lUserParam;
|
||||
|
||||
AVCodecContext* m_pCodecContext;
|
||||
};
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
#ifndef IMAGEPREVIEWDIALOG_H
|
||||
#define IMAGEPREVIEWDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
|
||||
class ImagePreviewDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImagePreviewDialog(const QString &imagePath, QWidget *parent = nullptr);
|
||||
~ImagePreviewDialog();
|
||||
|
||||
private:
|
||||
QLabel *m_imageLabel;
|
||||
QScrollArea *m_scrollArea;
|
||||
QPushButton *m_closeButton;
|
||||
|
||||
void setupUi();
|
||||
void loadImage(const QString &imagePath);
|
||||
};
|
||||
|
||||
#endif // IMAGEPREVIEWDIALOG_H
|
||||
@ -1,28 +0,0 @@
|
||||
#include "widget.h"
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
// print SDK Version
|
||||
qDebug() << "ViewLink SDK Version: " << GetSDKVersion();
|
||||
|
||||
// initialize SDK
|
||||
VLK_Init();
|
||||
|
||||
|
||||
Widget w;
|
||||
w.show();
|
||||
|
||||
int ret = a.exec();
|
||||
|
||||
// diconnect all
|
||||
VLK_Disconnect();
|
||||
|
||||
// uninitialize SDK
|
||||
VLK_UnInit();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
Subproject commit 39c8188929657d71dfecbac4288025765589c300
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 115 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue