1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/vc2enc: Allow user-supplied buffers

Trivial for an encoder that has a very good estimate of the size
of the output packet in advance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2021-04-27 16:58:16 +02:00
parent 911806ec75
commit ed8a7c25cd

View File

@ -22,6 +22,7 @@
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "dirac.h"
#include "encode.h"
#include "put_bits.h"
#include "internal.h"
#include "version.h"
@ -914,9 +915,8 @@ static int encode_frame(VC2EncContext *s, AVPacket *avpkt, const AVFrame *frame,
max_frame_bytes = header_size + calc_slice_sizes(s);
if (field < 2) {
ret = ff_alloc_packet2(s->avctx, avpkt,
max_frame_bytes << s->interlaced,
max_frame_bytes << s->interlaced);
ret = ff_get_encode_buffer(s->avctx, avpkt,
max_frame_bytes << s->interlaced, 0);
if (ret) {
av_log(s->avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
@ -1231,10 +1231,10 @@ const AVCodec ff_vc2_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-2"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_DIRAC,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS,
.priv_data_size = sizeof(VC2EncContext),
.init = vc2_encode_init,
.close = vc2_encode_end,
.capabilities = AV_CODEC_CAP_SLICE_THREADS,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
.encode2 = vc2_encode_frame,
.priv_class = &vc2enc_class,