diff options
Diffstat (limited to 'libavcodec/libkvazaar.c')
-rw-r--r-- | libavcodec/libkvazaar.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c index fa64bf5..41a1bbb 100644 --- a/libavcodec/libkvazaar.c +++ b/libavcodec/libkvazaar.c @@ -3,20 +3,20 @@ * * Copyright (c) 2015 Tampere University of Technology * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -25,6 +25,7 @@ #include <string.h> #include "libavutil/attributes.h" +#include "libavutil/avassert.h" #include "libavutil/dict.h" #include "libavutil/error.h" #include "libavutil/imgutils.h" @@ -54,12 +55,6 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx) kvz_config *cfg = NULL; kvz_encoder *enc = NULL; - if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { - av_log(avctx, AV_LOG_ERROR, - "Set -strict experimental to use this encoder.\n"); - return AVERROR_EXPERIMENTAL; - } - /* Kvazaar requires width and height to be multiples of eight. */ if (avctx->width % 8 || avctx->height % 8) { av_log(avctx, AV_LOG_ERROR, @@ -84,6 +79,11 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx) cfg->width = avctx->width; cfg->height = avctx->height; + if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) { + av_log(avctx, AV_LOG_ERROR, + "Could not set framerate for kvazaar: integer overflow\n"); + return AVERROR(EINVAL); + } cfg->framerate_num = avctx->time_base.den; cfg->framerate_denom = avctx->time_base.num * avctx->ticks_per_frame; cfg->target_bitrate = avctx->bit_rate; @@ -166,6 +166,8 @@ static int libkvazaar_encode(AVCodecContext *avctx, uint32_t len_out = 0; int retval = 0; + *got_packet_ptr = 0; + if (frame) { if (frame->width != ctx->config->width || frame->height != ctx->config->height) { @@ -222,18 +224,21 @@ static int libkvazaar_encode(AVCodecContext *avctx, retval = AVERROR_INVALIDDATA; goto done; } + else + retval = 0; /* kvazaar returns 1 on success */ if (data_out) { kvz_data_chunk *chunk = NULL; uint64_t written = 0; - retval = ff_alloc_packet(avpkt, len_out); + retval = ff_alloc_packet2(avctx, avpkt, len_out, len_out); if (retval < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n"); goto done; } for (chunk = data_out; chunk != NULL; chunk = chunk->next) { + av_assert0(written + chunk->len <= len_out); memcpy(avpkt->data + written, chunk->data, chunk->len); written += chunk->len; } @@ -268,7 +273,6 @@ static const enum AVPixelFormat pix_fmts[] = { static const AVOption options[] = { { "kvazaar-params", "Set kvazaar parameters as a comma-separated list of key=value pairs.", OFFSET(kvz_params), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE }, - { NULL }, }; |