mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
libvpxenc: Support forcing keyframes
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
ec5da7aee2
commit
774e6fc9ed
@ -495,6 +495,7 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
struct vpx_image *rawimg = NULL;
|
struct vpx_image *rawimg = NULL;
|
||||||
int64_t timestamp = 0;
|
int64_t timestamp = 0;
|
||||||
int res, coded_size;
|
int res, coded_size;
|
||||||
|
vpx_enc_frame_flags_t flags = 0;
|
||||||
|
|
||||||
if (frame) {
|
if (frame) {
|
||||||
rawimg = &ctx->rawimg;
|
rawimg = &ctx->rawimg;
|
||||||
@ -505,10 +506,12 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
rawimg->stride[VPX_PLANE_U] = frame->linesize[1];
|
rawimg->stride[VPX_PLANE_U] = frame->linesize[1];
|
||||||
rawimg->stride[VPX_PLANE_V] = frame->linesize[2];
|
rawimg->stride[VPX_PLANE_V] = frame->linesize[2];
|
||||||
timestamp = frame->pts;
|
timestamp = frame->pts;
|
||||||
|
if (frame->pict_type == AV_PICTURE_TYPE_I)
|
||||||
|
flags |= VPX_EFLAG_FORCE_KF;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp,
|
res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp,
|
||||||
avctx->ticks_per_frame, 0, ctx->deadline);
|
avctx->ticks_per_frame, flags, ctx->deadline);
|
||||||
if (res != VPX_CODEC_OK) {
|
if (res != VPX_CODEC_OK) {
|
||||||
log_encoder_error(avctx, "Error encoding frame");
|
log_encoder_error(avctx, "Error encoding frame");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
Loading…
Reference in New Issue
Block a user