summaryrefslogtreecommitdiff
path: root/libavcodec/libxavs2.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-25 01:43:26 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-05-23 15:17:13 +0200
commit3abdf0efac7d588efb757837e962afd9334b3bf6 (patch)
treed76fed1678cd91ee68fc88f77427cc017ca286d3 /libavcodec/libxavs2.c
parent7a3613696d9beb625c09c703723884eb18a58976 (diff)
avcodec/libxavs2: Allow user-supplied buffers
Here the packet size is known before allocating the packet, so that supporting user-supplied buffers is trivial. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/libxavs2.c')
-rw-r--r--libavcodec/libxavs2.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 99fe0e3286..9c5a576e90 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -23,6 +23,7 @@
*/
#include "xavs2.h"
+#include "encode.h"
#include "mpeg12.h"
#include "libavutil/avstring.h"
@@ -214,10 +215,9 @@ static int xavs2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
if ((cae->packet.len) && (cae->packet.state != XAVS2_STATE_FLUSH_END)) {
- if (av_new_packet(pkt, cae->packet.len) < 0) {
- av_log(avctx, AV_LOG_ERROR, "Failed to alloc xavs2 packet.\n");
+ if ((ret = ff_get_encode_buffer(avctx, pkt, cae->packet.len, 0)) < 0) {
cae->api->encoder_packet_unref(cae->encoder, &cae->packet);
- return AVERROR(ENOMEM);
+ return ret;
}
pkt->pts = cae->packet.pts;
@@ -230,7 +230,6 @@ static int xavs2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
memcpy(pkt->data, cae->packet.stream, cae->packet.len);
- pkt->size = cae->packet.len;
cae->api->encoder_packet_unref(cae->encoder, &cae->packet);
@@ -290,11 +289,12 @@ const AVCodec ff_libxavs2_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("libxavs2 AVS2-P2/IEEE1857.4"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_AVS2,
+ .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
+ AV_CODEC_CAP_OTHER_THREADS,
.priv_data_size = sizeof(XAVS2EContext),
.init = xavs2_init,
.encode2 = xavs2_encode_frame,
.close = xavs2_close,
- .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,
.caps_internal = FF_CODEC_CAP_AUTO_THREADS,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE },