X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flibkvazaar.c;h=9032547678cc292ff4cd72f39974447e666c0463;hb=172af0ee516939168c57ef543d44179274f3fe29;hp=a89ca7f74951c0337f1eacc11bf31a5983c80265;hpb=409e684e79b6ee0c511292326f09b13fe230e58e;p=ffmpeg diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c index a89ca7f7495..9032547678c 100644 --- a/libavcodec/libkvazaar.c +++ b/libavcodec/libkvazaar.c @@ -37,6 +37,7 @@ #include "avcodec.h" #include "internal.h" +#include "packet_internal.h" typedef struct LibkvazaarContext { const AVClass *class; @@ -80,13 +81,8 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx) cfg->height = avctx->height; if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { - if (avctx->ticks_per_frame > INT_MAX / avctx->framerate.den) { - av_log(avctx, AV_LOG_ERROR, - "Could not set framerate for kvazaar: integer overflow\n"); - return AVERROR(EINVAL); - } cfg->framerate_num = avctx->framerate.num; - cfg->framerate_denom = avctx->time_base.den * avctx->ticks_per_frame; + cfg->framerate_denom = avctx->framerate.den; } else { if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) { av_log(avctx, AV_LOG_ERROR, @@ -110,8 +106,8 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx) entry->key, entry->value); } } - av_dict_free(&dict); } + av_dict_free(&dict); } ctx->encoder = enc = api->encoder_open(cfg); @@ -175,6 +171,7 @@ static int libkvazaar_encode(AVCodecContext *avctx, kvz_data_chunk *data_out = NULL; uint32_t len_out = 0; int retval = 0; + int pict_type; *got_packet_ptr = 0; @@ -262,6 +259,34 @@ static int libkvazaar_encode(AVCodecContext *avctx, avpkt->flags |= AV_PKT_FLAG_KEY; } + switch (frame_info.slice_type) { + case KVZ_SLICE_I: + pict_type = AV_PICTURE_TYPE_I; + break; + case KVZ_SLICE_P: + pict_type = AV_PICTURE_TYPE_P; + break; + case KVZ_SLICE_B: + pict_type = AV_PICTURE_TYPE_B; + break; + default: + av_log(avctx, AV_LOG_ERROR, "Unknown picture type encountered.\n"); + return AVERROR_EXTERNAL; + } +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->pict_type = pict_type; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + ff_side_data_set_encoder_stats(avpkt, frame_info.qp * FF_QP2LAMBDA, NULL, 0, pict_type); + +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->quality = frame_info.qp * FF_QP2LAMBDA; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + *got_packet_ptr = 1; }