From patchwork Fri Oct 25 08:52:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 15946 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E9AF344823B for ; Fri, 25 Oct 2019 11:52:37 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C7FD068B035; Fri, 25 Oct 2019 11:52:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1099C68AEA4 for ; Fri, 25 Oct 2019 11:52:31 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id w9so1148948wmm.5 for ; Fri, 25 Oct 2019 01:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1XPs14gmecBt+PwVC9L640US9JjeO+7mhe9OGIYVWZg=; b=UUvjMNEv8Cpkut2mG328YT+d/w/feuYzg6P1JqabrS0j/QGsQctGKY4RHcFwH4fM7U vA0oCX2JgPZ0Otv85btST6Nn8lM66Iy/LddNE9C4tOBrzGyaomsZDUVr2GxpArhD4Y44 idegg9lnPIj2U/pwyF24+dX0DIUcEhgOEt/NM6U3lIilofKgBRG1AVio0vYZzeDWbgef cyFh5Au2Dlv7hi1OwzwK/ju9l5CYNL78ZL/AWSRPNQxRb90HoasN/8eiDdCgRAtPgl0X f8IJy+yuaiprC/BpTnXFiXv7YBdHHHCtfNfoeA8gOuZ1a4hU8Y0tYYQt7aJvuAjv+qcc kf6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1XPs14gmecBt+PwVC9L640US9JjeO+7mhe9OGIYVWZg=; b=MdZ0KrbHkay9Pe3B3DRcRpRh2ZBHcBk70CwEiKHh6CxtOMEGDDlEJMhbCI6vWnCGHH cIx7AI0QFwHKvtLE1W5ysNYG2fFS4/bzpQhNQY1wjDWkscNHMy9x0YgfAUhFPXK44/A4 m2/rXJILAtYqVxkrVKuaJHaXWxifWNb7HdXKJePff+yCIU1xcawMv/dMBrXJb98Fj9P3 TlMz7fUw/6hiPCqGsi0QiE6jD3X4he2q1P8Mk7TnLrAJ+whcqDCwHheFcyiKsx0YOA5v xDCrw3NdkWtn0ptcYXVM23AZhmGCl9zflTDvjyTd9MK8mxTI3rkn8ayzwyFWmuB050d8 y78g== X-Gm-Message-State: APjAAAXVdtP8PRXoOm5VNNezueFdoSEWnQhO9pmW+HfufBt02tGTTyx3 Ctrj/+1aaJW5qXT+YY3ZaPjy9wmG X-Google-Smtp-Source: APXvYqyO8XxrZzcPbjmu8Edq/s+0WPb30Up/ATmUwxwTA9vWTuEG9xKwblgM2M2Yn3yxjeYwcbSeFw== X-Received: by 2002:a1c:7f96:: with SMTP id a144mr2539334wmd.143.1571993550395; Fri, 25 Oct 2019 01:52:30 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08937.dynamic.kabel-deutschland.de. [188.192.137.55]) by smtp.gmail.com with ESMTPSA id l18sm3472271wrn.48.2019.10.25.01.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 01:52:29 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 25 Oct 2019 10:52:19 +0200 Message-Id: <20191025085222.4498-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <0191024173638.GZ27353@michaelspb> References: <0191024173638.GZ27353@michaelspb> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] avformat/flvenc: Forward errors from allocating keyframe index X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" While the function adding a new element to the keyframe index checked the allocation, the caller didn't check the return value. This has been changed. To do so, the return value has been changed to an ordinary ret instead of pb->error. This doesn't pose a problem, as write_packet() in mux.c already checks for write errors (since 9ad1e0c1). Signed-off-by: Andreas Rheinhardt --- libavformat/flvenc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index fb1dede7ae..e327545dcf 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -887,7 +887,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) unsigned ts; int size = pkt->size; uint8_t *data = NULL; - int flags = -1, flags_size, ret; + int flags = -1, flags_size, ret = 0; int64_t cur_offset = avio_tell(pb); if (par->codec_type == AVMEDIA_TYPE_AUDIO && !pkt->size) { @@ -1055,15 +1055,17 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) case AVMEDIA_TYPE_VIDEO: flv->videosize += (avio_tell(pb) - cur_offset); flv->lasttimestamp = flv->acurframeindex / flv->framerate; + flv->acurframeindex++; if (pkt->flags & AV_PKT_FLAG_KEY) { - double ts = flv->acurframeindex / flv->framerate; + double ts = flv->lasttimestamp; int64_t pos = cur_offset; - flv->lastkeyframetimestamp = flv->acurframeindex / flv->framerate; + flv->lastkeyframetimestamp = ts; flv->lastkeyframelocation = pos; - flv_append_keyframe_info(s, flv, ts, pos); + ret = flv_append_keyframe_info(s, flv, ts, pos); + if (ret < 0) + goto fail; } - flv->acurframeindex++; break; case AVMEDIA_TYPE_AUDIO: @@ -1075,10 +1077,10 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) break; } } - +fail: av_free(data); - return pb->error; + return ret; } static int flv_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)