mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
cleanup, use chroma_shift
This commit is contained in:
parent
f05e2ba9c9
commit
7d4230095c
|
@ -51,8 +51,8 @@ void NetVideoSource::pushVPXFrame(vpx_image *image)
|
|||
for (int x = 0; x < dw; ++x)
|
||||
{
|
||||
uint8_t Y = yData[x + y * bpl];
|
||||
uint8_t U = uData[x/2 + y/2*cxbpl];
|
||||
uint8_t V = vData[x/2 + y/2*cxbpl];
|
||||
uint8_t U = uData[x/(1 << image->x_chroma_shift) + y/(1 << image->y_chroma_shift)*cxbpl];
|
||||
uint8_t V = vData[x/(1 << image->x_chroma_shift) + y/(1 << image->y_chroma_shift)*cxbpl];
|
||||
|
||||
frame.frameData.data()[dw * 3 * y + x * 3 + 0] = Y;
|
||||
frame.frameData.data()[dw * 3 * y + x * 3 + 1] = U;
|
||||
|
|
|
@ -16,16 +16,14 @@
|
|||
|
||||
#include "videoframe.h"
|
||||
|
||||
vpx_image_t VideoFrame::createVpxImage()
|
||||
vpx_image_t VideoFrame::createVpxImage() const
|
||||
{
|
||||
vpx_image img;
|
||||
img.w = 0;
|
||||
img.h = 0;
|
||||
|
||||
if (isValid())
|
||||
{
|
||||
img.w = 0;
|
||||
img.h = 0;
|
||||
if (!isValid())
|
||||
return img;
|
||||
}
|
||||
|
||||
const int w = resolution.width();
|
||||
const int h = resolution.height();
|
||||
|
@ -44,10 +42,10 @@ vpx_image_t VideoFrame::createVpxImage()
|
|||
|
||||
img.planes[VPX_PLANE_Y][x + y * img.stride[VPX_PLANE_Y]] = ((66 * r + 129 * g + 25 * b) >> 8) + 16;
|
||||
|
||||
if (!(x % 2) && !(y % 2))
|
||||
if (!(x % (1 << img.x_chroma_shift)) && !(y % (1 << img.y_chroma_shift)))
|
||||
{
|
||||
const int i = x / 2;
|
||||
const int j = y / 2;
|
||||
const int i = x / (1 << img.x_chroma_shift);
|
||||
const int j = y / (1 << img.y_chroma_shift);
|
||||
|
||||
img.planes[VPX_PLANE_U][i + j * img.stride[VPX_PLANE_U]] = ((112 * r + -94 * g + -18 * b) >> 8) + 128;
|
||||
img.planes[VPX_PLANE_V][i + j * img.stride[VPX_PLANE_V]] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128;
|
||||
|
|
|
@ -45,12 +45,12 @@ struct VideoFrame
|
|||
resolution = QSize(-1,-1);
|
||||
}
|
||||
|
||||
bool isValid()
|
||||
bool isValid() const
|
||||
{
|
||||
return !frameData.isEmpty() && resolution.isValid();
|
||||
return !frameData.isEmpty() && resolution.isValid() && format != NONE;
|
||||
}
|
||||
|
||||
vpx_image_t createVpxImage();
|
||||
vpx_image_t createVpxImage() const;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(VideoFrame)
|
||||
|
|
Loading…
Reference in New Issue
Block a user