summaryrefslogtreecommitdiff
path: root/libavcodec/libx265.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-11-06 14:09:37 +0000
committerMartin Storsjö <martin@martin.st>2016-11-07 10:16:10 +0200
commitdb0b3dccb3842de134721e8d5c275f56d384340d (patch)
tree4b003c10d507dc754bff364f8c8605ab84fce2e7 /libavcodec/libx265.c
parent3cba09e5228c889d63814dc43bc68f15c9dbac77 (diff)
libx265: Add option to force IDR frames
This is in the same the same vein as 380146924ecad2e05e9dcc5c3c2e1b5ba47c51e8. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec/libx265.c')
-rw-r--r--libavcodec/libx265.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index f5d3d0f3c0..add05692c5 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -42,6 +42,7 @@ typedef struct libx265Context {
const x265_api *api;
float crf;
+ int forced_idr;
char *preset;
char *tune;
char *x265_opts;
@@ -263,7 +264,8 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
x265pic.pts = pic->pts;
x265pic.bitDepth = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth;
- x265pic.sliceType = pic->pict_type == AV_PICTURE_TYPE_I ? X265_TYPE_I :
+ x265pic.sliceType = pic->pict_type == AV_PICTURE_TYPE_I ?
+ (ctx->forced_idr ? X265_TYPE_IDR : X265_TYPE_I) :
pic->pict_type == AV_PICTURE_TYPE_P ? X265_TYPE_P :
pic->pict_type == AV_PICTURE_TYPE_B ? X265_TYPE_B :
X265_TYPE_AUTO;
@@ -348,6 +350,7 @@ static av_cold void libx265_encode_init_csp(AVCodec *codec)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "crf", "set the x265 crf", OFFSET(crf), AV_OPT_TYPE_FLOAT, { .dbl = -1 }, -1, FLT_MAX, VE },
+ { "forced-idr", "if forcing keyframes, force them as IDR frames", OFFSET(forced_idr),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ "preset", "set the x265 preset", OFFSET(preset), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
{ "tune", "set the x265 tune parameter", OFFSET(tune), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
{ "x265-params", "set the x265 configuration using a :-separated list of key=value parameters", OFFSET(x265_opts), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },