add-ons/media/ffmpeg: Rework usage of AVPicture in AVCodecDecoder.
It has been deprecated since FFmpeg ~3.0, and is internally implemented using these functions now, so this should largely be a no-op change. AVCodecEncoder still uses it.
This commit is contained in:
@@ -1570,9 +1570,9 @@ AVCodecDecoder::_UpdateMediaHeaderForVideoFrame()
|
|||||||
fHeader.file_pos = 0;
|
fHeader.file_pos = 0;
|
||||||
fHeader.orig_size = 0;
|
fHeader.orig_size = 0;
|
||||||
fHeader.start_time = fRawDecodedPicture->pkt_dts;
|
fHeader.start_time = fRawDecodedPicture->pkt_dts;
|
||||||
fHeader.size_used = avpicture_get_size(
|
fHeader.size_used = av_image_get_buffer_size(
|
||||||
colorspace_to_pixfmt(fOutputColorSpace), fRawDecodedPicture->width,
|
colorspace_to_pixfmt(fOutputColorSpace), fRawDecodedPicture->width,
|
||||||
fRawDecodedPicture->height);
|
fRawDecodedPicture->height, 1);
|
||||||
fHeader.u.raw_video.display_line_width = fRawDecodedPicture->width;
|
fHeader.u.raw_video.display_line_width = fRawDecodedPicture->width;
|
||||||
fHeader.u.raw_video.display_line_count = fRawDecodedPicture->height;
|
fHeader.u.raw_video.display_line_count = fRawDecodedPicture->height;
|
||||||
fHeader.u.raw_video.bytes_per_row
|
fHeader.u.raw_video.bytes_per_row
|
||||||
@@ -1622,11 +1622,11 @@ AVCodecDecoder::_DeinterlaceAndColorConvertVideoFrame()
|
|||||||
{
|
{
|
||||||
int displayWidth = fRawDecodedPicture->width;
|
int displayWidth = fRawDecodedPicture->width;
|
||||||
int displayHeight = fRawDecodedPicture->height;
|
int displayHeight = fRawDecodedPicture->height;
|
||||||
AVPicture deinterlacedPicture;
|
AVFrame deinterlacedPicture;
|
||||||
bool useDeinterlacedPicture = false;
|
bool useDeinterlacedPicture = false;
|
||||||
|
|
||||||
if (fRawDecodedPicture->interlaced_frame) {
|
if (fRawDecodedPicture->interlaced_frame) {
|
||||||
AVPicture rawPicture;
|
AVFrame rawPicture;
|
||||||
rawPicture.data[0] = fRawDecodedPicture->data[0];
|
rawPicture.data[0] = fRawDecodedPicture->data[0];
|
||||||
rawPicture.data[1] = fRawDecodedPicture->data[1];
|
rawPicture.data[1] = fRawDecodedPicture->data[1];
|
||||||
rawPicture.data[2] = fRawDecodedPicture->data[2];
|
rawPicture.data[2] = fRawDecodedPicture->data[2];
|
||||||
@@ -1636,8 +1636,10 @@ AVCodecDecoder::_DeinterlaceAndColorConvertVideoFrame()
|
|||||||
rawPicture.linesize[2] = fRawDecodedPicture->linesize[2];
|
rawPicture.linesize[2] = fRawDecodedPicture->linesize[2];
|
||||||
rawPicture.linesize[3] = fRawDecodedPicture->linesize[3];
|
rawPicture.linesize[3] = fRawDecodedPicture->linesize[3];
|
||||||
|
|
||||||
avpicture_alloc(&deinterlacedPicture, fCodecContext->pix_fmt, displayWidth,
|
if (av_image_alloc(deinterlacedPicture.data,
|
||||||
displayHeight);
|
deinterlacedPicture.linesize, displayWidth, displayHeight,
|
||||||
|
fCodecContext->pix_fmt, 1) < 0)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
// deinterlace implemented using avfilter
|
// deinterlace implemented using avfilter
|
||||||
_ProcessFilterGraph(&deinterlacedPicture, &rawPicture,
|
_ProcessFilterGraph(&deinterlacedPicture, &rawPicture,
|
||||||
@@ -1717,7 +1719,7 @@ AVCodecDecoder::_DeinterlaceAndColorConvertVideoFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fRawDecodedPicture->interlaced_frame)
|
if (fRawDecodedPicture->interlaced_frame)
|
||||||
avpicture_free(&deinterlacedPicture);
|
av_freep(&deinterlacedPicture.data[0]);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -1787,7 +1789,7 @@ AVCodecDecoder::_InitFilterGraph(enum AVPixelFormat pixfmt, int32 width,
|
|||||||
\returns B_NO_MEMORY Not enough memory available for correct operation.
|
\returns B_NO_MEMORY Not enough memory available for correct operation.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
AVCodecDecoder::_ProcessFilterGraph(AVPicture *dst, const AVPicture *src,
|
AVCodecDecoder::_ProcessFilterGraph(AVFrame *dst, const AVFrame *src,
|
||||||
enum AVPixelFormat pixfmt, int32 width, int32 height)
|
enum AVPixelFormat pixfmt, int32 width, int32 height)
|
||||||
{
|
{
|
||||||
if (fFilterGraph == NULL || width != fLastWidth
|
if (fFilterGraph == NULL || width != fLastWidth
|
||||||
@@ -1812,8 +1814,8 @@ AVCodecDecoder::_ProcessFilterGraph(AVPicture *dst, const AVPicture *src,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
|
|
||||||
av_picture_copy(dst, (const AVPicture *)fFilterFrame, pixfmt, width,
|
av_image_copy(dst->data, dst->linesize, (const uint8**)fFilterFrame->data,
|
||||||
height);
|
fFilterFrame->linesize, pixfmt, width, height);
|
||||||
av_frame_unref(fFilterFrame);
|
av_frame_unref(fFilterFrame);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ extern "C" {
|
|||||||
#include "avfilter.h"
|
#include "avfilter.h"
|
||||||
#include "buffersink.h"
|
#include "buffersink.h"
|
||||||
#include "buffersrc.h"
|
#include "buffersrc.h"
|
||||||
|
#include "imgutils.h"
|
||||||
#include "swresample.h"
|
#include "swresample.h"
|
||||||
#include "swscale.h"
|
#include "swscale.h"
|
||||||
}
|
}
|
||||||
@@ -101,8 +102,8 @@ private:
|
|||||||
// video deinterlace filter graph
|
// video deinterlace filter graph
|
||||||
status_t _InitFilterGraph(enum AVPixelFormat pixfmt,
|
status_t _InitFilterGraph(enum AVPixelFormat pixfmt,
|
||||||
int32 width, int32 height);
|
int32 width, int32 height);
|
||||||
status_t _ProcessFilterGraph(AVPicture *dst,
|
status_t _ProcessFilterGraph(AVFrame *dst,
|
||||||
const AVPicture *src, enum AVPixelFormat pixfmt,
|
const AVFrame *src, enum AVPixelFormat pixfmt,
|
||||||
int32 width, int32 height);
|
int32 width, int32 height);
|
||||||
|
|
||||||
media_header fHeader;
|
media_header fHeader;
|
||||||
|
|||||||
Reference in New Issue
Block a user