mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(videoframe, camerasource, corevideosource): Change calls deprecated functions
This commit is contained in:
parent
446626dabe
commit
082fb4c056
@ -337,7 +337,7 @@ void CameraSource::stream()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Free the packet that was allocated by av_read_frame
|
// Free the packet that was allocated by av_read_frame
|
||||||
av_free_packet(&packet);
|
av_packet_unref(&packet);
|
||||||
};
|
};
|
||||||
|
|
||||||
forever {
|
forever {
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
#include <libavutil/imgutils.h>
|
||||||
}
|
}
|
||||||
#include "corevideosource.h"
|
#include "corevideosource.h"
|
||||||
#include "videoframe.h"
|
#include "videoframe.h"
|
||||||
@ -53,7 +54,8 @@ void CoreVideoSource::pushFrame(const vpx_image_t* vpxframe)
|
|||||||
avframe->height = height;
|
avframe->height = height;
|
||||||
avframe->format = AV_PIX_FMT_YUV420P;
|
avframe->format = AV_PIX_FMT_YUV420P;
|
||||||
|
|
||||||
buf = (uint8_t*)av_malloc(avpicture_get_size(AV_PIX_FMT_YUV420P, width, height));
|
int imgBufferSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, width, height, 1);
|
||||||
|
buf = (uint8_t*)av_malloc(imgBufferSize);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
av_frame_free(&avframe);
|
av_frame_free(&avframe);
|
||||||
@ -61,7 +63,9 @@ void CoreVideoSource::pushFrame(const vpx_image_t* vpxframe)
|
|||||||
}
|
}
|
||||||
avframe->opaque = buf;
|
avframe->opaque = buf;
|
||||||
|
|
||||||
avpicture_fill((AVPicture*)avframe, buf, AV_PIX_FMT_YUV420P, width, height);
|
uint8_t** data = avframe->data;
|
||||||
|
int* linesize = avframe->linesize;
|
||||||
|
av_image_fill_arrays(data, linesize, buf, AV_PIX_FMT_YUV420P, width, height, 1);
|
||||||
|
|
||||||
dstStride=avframe->linesize[0], srcStride=vpxframe->stride[0], minStride=std::min(dstStride, srcStride);
|
dstStride=avframe->linesize[0], srcStride=vpxframe->stride[0], minStride=std::min(dstStride, srcStride);
|
||||||
for (int i=0; i<height; i++)
|
for (int i=0; i<height; i++)
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <vpx/vpx_image.h>
|
#include <vpx/vpx_image.h>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
#include <libavutil/imgutils.h>
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
}
|
}
|
||||||
#include "videoframe.h"
|
#include "videoframe.h"
|
||||||
@ -154,7 +155,8 @@ bool VideoFrame::convertToRGB24(QSize size)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* buf = (uint8_t*)av_malloc(avpicture_get_size(AV_PIX_FMT_RGB24, size.width(), size.height()));
|
int imgBufferSize = av_image_get_buffer_size(AV_PIX_FMT_RGB24, size.width(), size.height(), 1);
|
||||||
|
uint8_t* buf = (uint8_t*)av_malloc(imgBufferSize);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
qCritical() << "av_malloc failed";
|
qCritical() << "av_malloc failed";
|
||||||
@ -163,7 +165,9 @@ bool VideoFrame::convertToRGB24(QSize size)
|
|||||||
}
|
}
|
||||||
frameRGB24->opaque = buf;
|
frameRGB24->opaque = buf;
|
||||||
|
|
||||||
avpicture_fill((AVPicture*)frameRGB24, buf, AV_PIX_FMT_RGB24, size.width(), size.height());
|
uint8_t** data = frameRGB24->data;
|
||||||
|
int* linesize = frameRGB24->linesize;
|
||||||
|
av_image_fill_arrays(data, linesize, buf, AV_PIX_FMT_RGB24, size.width(), size.height(), 1);
|
||||||
frameRGB24->width = size.width();
|
frameRGB24->width = size.width();
|
||||||
frameRGB24->height = size.height();
|
frameRGB24->height = size.height();
|
||||||
|
|
||||||
@ -211,7 +215,8 @@ bool VideoFrame::convertToYUV420()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* buf = (uint8_t*)av_malloc(avpicture_get_size(AV_PIX_FMT_RGB24, width, height));
|
int imgBufferSize = av_image_get_buffer_size(AV_PIX_FMT_RGB24, width, height, 1);
|
||||||
|
uint8_t* buf = (uint8_t*)av_malloc(imgBufferSize);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
qCritical() << "av_malloc failed";
|
qCritical() << "av_malloc failed";
|
||||||
@ -220,7 +225,9 @@ bool VideoFrame::convertToYUV420()
|
|||||||
}
|
}
|
||||||
frameYUV420->opaque = buf;
|
frameYUV420->opaque = buf;
|
||||||
|
|
||||||
avpicture_fill((AVPicture*)frameYUV420, buf, AV_PIX_FMT_YUV420P, width, height);
|
uint8_t** data = frameYUV420->data;
|
||||||
|
int* linesize = frameYUV420->linesize;
|
||||||
|
av_image_fill_arrays(data, linesize, buf, AV_PIX_FMT_YUV420P, width, height, 1);
|
||||||
|
|
||||||
SwsContext *swsCtx = sws_getContext(width, height, (AVPixelFormat)pixFmt,
|
SwsContext *swsCtx = sws_getContext(width, height, (AVPixelFormat)pixFmt,
|
||||||
width, height, AV_PIX_FMT_YUV420P,
|
width, height, AV_PIX_FMT_YUV420P,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user