avcodec/v410enc: Avoid copying packet data, allow user-supplied buffers
When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data by using ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
7bfa533793
commit
14407e84b9
@ -23,6 +23,7 @@
|
|||||||
#include "libavutil/common.h"
|
#include "libavutil/common.h"
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "encode.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
static av_cold int v410_encode_init(AVCodecContext *avctx)
|
static av_cold int v410_encode_init(AVCodecContext *avctx)
|
||||||
@ -46,8 +47,8 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
uint32_t val;
|
uint32_t val;
|
||||||
int i, j, ret;
|
int i, j, ret;
|
||||||
|
|
||||||
if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 4,
|
ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 4, 0);
|
||||||
avctx->width * avctx->height * 4)) < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
dst = pkt->data;
|
dst = pkt->data;
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ const AVCodec ff_v410_encoder = {
|
|||||||
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"),
|
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"),
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.id = AV_CODEC_ID_V410,
|
.id = AV_CODEC_ID_V410,
|
||||||
|
.capabilities = AV_CODEC_CAP_DR1,
|
||||||
.init = v410_encode_init,
|
.init = v410_encode_init,
|
||||||
.encode2 = v410_encode_frame,
|
.encode2 = v410_encode_frame,
|
||||||
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_NONE },
|
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_NONE },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user