avcodec/libopenh264enc: 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>
This commit is contained in:
parent
c59398970b
commit
0812a60fee
|
@ -30,6 +30,7 @@
|
||||||
#include "libavutil/mathematics.h"
|
#include "libavutil/mathematics.h"
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "encode.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "libopenh264.h"
|
#include "libopenh264.h"
|
||||||
|
|
||||||
|
@ -404,10 +405,9 @@ static int svc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||||
}
|
}
|
||||||
av_log(avctx, AV_LOG_DEBUG, "%d slices\n", fbi.sLayerInfo[fbi.iLayerNum - 1].iNalCount);
|
av_log(avctx, AV_LOG_DEBUG, "%d slices\n", fbi.sLayerInfo[fbi.iLayerNum - 1].iNalCount);
|
||||||
|
|
||||||
if ((ret = ff_alloc_packet2(avctx, avpkt, size, size))) {
|
if ((ret = ff_get_encode_buffer(avctx, avpkt, size, 0)))
|
||||||
av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
size = 0;
|
size = 0;
|
||||||
for (layer = first_layer; layer < fbi.iLayerNum; layer++) {
|
for (layer = first_layer; layer < fbi.iLayerNum; layer++) {
|
||||||
memcpy(avpkt->data + size, fbi.sLayerInfo[layer].pBsBuf, layer_size[layer]);
|
memcpy(avpkt->data + size, fbi.sLayerInfo[layer].pBsBuf, layer_size[layer]);
|
||||||
|
@ -433,11 +433,11 @@ const AVCodec ff_libopenh264_encoder = {
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
|
.long_name = NULL_IF_CONFIG_SMALL("OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.id = AV_CODEC_ID_H264,
|
.id = AV_CODEC_ID_H264,
|
||||||
|
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS,
|
||||||
.priv_data_size = sizeof(SVCContext),
|
.priv_data_size = sizeof(SVCContext),
|
||||||
.init = svc_encode_init,
|
.init = svc_encode_init,
|
||||||
.encode2 = svc_encode_frame,
|
.encode2 = svc_encode_frame,
|
||||||
.close = svc_encode_close,
|
.close = svc_encode_close,
|
||||||
.capabilities = AV_CODEC_CAP_OTHER_THREADS,
|
|
||||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP |
|
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP |
|
||||||
FF_CODEC_CAP_AUTO_THREADS,
|
FF_CODEC_CAP_AUTO_THREADS,
|
||||||
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
|
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user