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 },