From patchwork Mon Mar 2 04:35:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17989 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 34065447B68 for ; Mon, 2 Mar 2020 06:35:59 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0BB316899BB; Mon, 2 Mar 2020 06:35:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 198F56899BB for ; Mon, 2 Mar 2020 06:35:52 +0200 (EET) Received: by mail-wm1-f52.google.com with SMTP id f15so9551438wml.3 for ; Sun, 01 Mar 2020 20:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3jAZ6fOgxpU51qWiqtVMCewbNEpGFy2Y0/ma9mC0bBI=; b=pRrAnmgpftw/A9XAxa7ockOX8pqK+16KiI5+1jn8Sh+OrKt/XtXnrKxQJ0Y0NIId+G 72dwPSqQL7s5nBvtm54OgU/+2kJvPnGkonOmGRMMB7s9Dumr1UAgXZWC8ory03IENC+b VqBos6JSi6N5v35l4e9B/qTXLBPPIN+LC2ojV32GXTKBvpkij4ZCLYE1yXc6Akrr8CbT IMJqkwt5Gs0aEaj8WdBKtmN+Rdx9TPDF9OZnQFReR9JgB1fES2stsbfgEpBCuj8REIG0 mI2nZTr1Sn23jZwGcnrXgUNG/V6YCzFYsax1utkAX6KiK5RpvSiyvEGiq0tvhpPIncI9 gM6A== 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:mime-version :content-transfer-encoding; bh=3jAZ6fOgxpU51qWiqtVMCewbNEpGFy2Y0/ma9mC0bBI=; b=HcZW2iYB0oXOoA0OctpSquQX9NjXAeuSc8IK9t7rN6A+kM9MtO8uN0htvY9rRAwD0a K4sUV/0KB/AvUli0W296nRzSMzMVS6vST0x3wNV/I6B3Lw57A27O5cyVyqIgil5YTVYx wqq/D7mUpxlhUba8uBWFIn2WUzgTlLtUx3VP0XyTN+OdYAZ44Zgk2Wsl+mD2Q7kaYXEC tGsDzuQ7x78FYmiSc+aldD7lWnu7ZaG8D+uAhR1tihkpjwBwQH89amoMHQ9ITnttGJfW XfD88juIJ3M6QeWl6X7bVaUYI6Ox+FoCSIBk7+aIXv4slhSJn9TMf99Lvocu6qVoLeho J/pA== X-Gm-Message-State: APjAAAXAp1z8Qiu3Fqo8VO4y4/owRsK5+hrXdmqKg7UThkwUKNNN+03s 3B2wY0BOVd8rw7HCloQrJLnGdrox X-Google-Smtp-Source: APXvYqxeZSI9/s2KnC4gSuuhkLl4jl+nHfGv/e6jc8OA96xgL/WfDLY8TQwnKlqDRo4I3rb69A+t3w== X-Received: by 2002:a05:600c:218a:: with SMTP id e10mr17214314wme.6.1583123751182; Sun, 01 Mar 2020 20:35:51 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id g7sm20842429wrm.72.2020.03.01.20.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:35:50 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:35:17 +0100 Message-Id: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/17] avformat: Use correct error in case muxer is not found 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" Signed-off-by: Andreas Rheinhardt --- libavformat/mpegtsenc.c | 2 +- libavformat/mux.c | 4 ++-- libavformat/rtpenc_chain.c | 2 +- libavformat/rtpenc_mpegts.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index ccb631d746..47463cbcdb 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -971,7 +971,7 @@ static int mpegts_init(AVFormatContext *s) av_guess_format((ts->flags & MPEGTS_FLAG_AAC_LATM) ? "latm" : "adts", NULL, NULL); if (!ts_st->amux->oformat) { - ret = AVERROR(EINVAL); + ret = AVERROR_MUXER_NOT_FOUND; goto fail; } if (!(ast = avformat_new_stream(ts_st->amux, NULL))) { diff --git a/libavformat/mux.c b/libavformat/mux.c index d88746e8c5..565a7d7c18 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -160,15 +160,15 @@ int avformat_alloc_output_context2(AVFormatContext **avctx, ff_const59 AVOutputF oformat = av_guess_format(format, NULL, NULL); if (!oformat) { av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format); - ret = AVERROR(EINVAL); + ret = AVERROR_MUXER_NOT_FOUND; goto error; } } else { oformat = av_guess_format(NULL, filename, NULL); if (!oformat) { - ret = AVERROR(EINVAL); av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n", filename); + ret = AVERROR_MUXER_NOT_FOUND; goto error; } } diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index e6b603db70..a4a9fb8c3a 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -36,7 +36,7 @@ int ff_rtp_chain_mux_open(AVFormatContext **out, AVFormatContext *s, AVDictionary *opts = NULL; if (!rtp_format) { - ret = AVERROR(ENOSYS); + ret = AVERROR_MUXER_NOT_FOUND; goto fail; } diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c index 7d7377db7a..1650462eef 100644 --- a/libavformat/rtpenc_mpegts.c +++ b/libavformat/rtpenc_mpegts.c @@ -54,7 +54,7 @@ static int rtp_mpegts_write_header(AVFormatContext *s) AVStream *st; if (!mpegts_format || !rtp_format) - return AVERROR(ENOSYS); + return AVERROR_MUXER_NOT_FOUND; mpegts_ctx = avformat_alloc_context(); if (!mpegts_ctx) return AVERROR(ENOMEM); From patchwork Mon Mar 2 04:35:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17991 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 E0D9D449FD2 for ; Mon, 2 Mar 2020 06:43:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B937268AF81; Mon, 2 Mar 2020 06:43:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 26CAC68AE75 for ; Mon, 2 Mar 2020 06:43:40 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id p9so9582551wmc.2 for ; Sun, 01 Mar 2020 20:43:40 -0800 (PST) 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=hzxJhZB1cSa7zRswsoq9RXf1yFE5INUkn9tPLnPhxBw=; b=oMsBrNwXOL2rjmv7md+Hobyu2sY1hO1EQNS+B9uKZzKT9D7QPEwexT0H1F15zVGUML rf1inLOUPFEEnId6kIBofA1Dfih+obOy4dXIe2bw8at3qRj9hV+LRTI1NqksuD16MOxW s4xky0wbrKUJ3GsNvbAdFOojMBy47Bs/lEh1z1qZ1k2JPKHOai39rHsIDoMG4AHWjzrQ 8gnvCm9Bcie1Owsq+Enj+3lDIj+pjs6ctUAjKlG1rRQE3eZW6ZcrjWZOMa5ruitkbKGS /EGKTmc3vYmgm/4ICeTXdKhpx+VOQX+27F4m7+WnugN+feyBOSSAH7SHMkl/y2p6C6Ri dJpA== 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=hzxJhZB1cSa7zRswsoq9RXf1yFE5INUkn9tPLnPhxBw=; b=Qyx9hxwr/bKlPiUyIV0gZ6YXSMWvzLayJwpKXkYhSfp+SRySgTP1kF4OYNKVZJHf8c GZ39QzeAQsSdE1Pvp4He/vm+v8jy0Mf06MphGhXgleYjN//WBCco60BdVd1AKTbBwAvD uPzzoQZbxdCH5MT8agHEIdN4ltR6K3Lf1e+d1ctFaWsaWDooQ6yweroioo51U1VAP4eK phQGO142hhB2oUI4s9Gcb0sl/LByYyS3dGCxz2AIYFlT/AWUob/eclfo5/6nhsbffHSa 1Ka5OEWG++Sz6oHxxECxlAZA8J0bWJf9ENUrcyFj5U7ZhccMjMWOhV7TEcSUKMRGHArU +rsQ== X-Gm-Message-State: APjAAAVT0IcMwLL1Y3iSwD9qCYsn5+807P5NenPUZD9CRggDRYiIs5Hk 8LOVhk9dYzbrpsa1ddBEQYFZ/5GB X-Google-Smtp-Source: APXvYqz9sXYrRKt+vXXkEEh9SG778l1AQovAM5mKZz5dxYT9ENQkSgf7EZdr80hS2hKsfh+3IAKVBQ== X-Received: by 2002:a1c:1982:: with SMTP id 124mr18402183wmz.83.1583123778913; Sun, 01 Mar 2020 20:36:18 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id g7sm20842429wrm.72.2020.03.01.20.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:36:18 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:35:18 +0100 Message-Id: <20200302043520.14165-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/17] avformat/hlsenc: Remove redundant setting of output format 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" avformat_alloc_output_context2() already sets the oformat member, so that there is no reason to overwrite it again with the value it already has. Signed-off-by: Andreas Rheinhardt --- libavformat/hlsenc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index f6dd894343..e58da7328f 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -776,7 +776,6 @@ static int hls_mux_init(AVFormatContext *s, VariantStream *vs) if (!oc->url) return AVERROR(ENOMEM); - oc->oformat = vs->oformat; oc->interrupt_callback = s->interrupt_callback; oc->max_delay = s->max_delay; oc->opaque = s->opaque; @@ -790,7 +789,6 @@ static int hls_mux_init(AVFormatContext *s, VariantStream *vs) if (ret < 0) return ret; vtt_oc = vs->vtt_avf; - vtt_oc->oformat = vs->vtt_oformat; av_dict_copy(&vtt_oc->metadata, s->metadata, 0); } From patchwork Mon Mar 2 04:35:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17990 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 397EC447C8B for ; Mon, 2 Mar 2020 06:36:38 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1D1B068AF81; Mon, 2 Mar 2020 06:36:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 540C86899BB for ; Mon, 2 Mar 2020 06:36:31 +0200 (EET) Received: by mail-wr1-f47.google.com with SMTP id j7so10677040wrp.13 for ; Sun, 01 Mar 2020 20:36:31 -0800 (PST) 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=w8htMq2PEFGZqhzmgFVIsg781XcCvMe33t4zvNdJ+Vk=; b=LSoW8OTdbn5a0g6fE3+6Dn72pQ/i342ebJrkSrtqSa5SVI1G8OqYeLawGjxh4rPOEU xsOEEGQadrBIL4cFCzbXVNZZ1OOQMXC9psMF6P3S9Zp1HeCltnQnK7QVbR60XwKFmQiF R5yBNQLsC5OhoQdGyN1NgHc3zLFs/cnUUvSD3MwpBV4+sIkVZ5A95Et15ifAKNNpST1f 9gRHlZ6HuZqslZeIOnAbSpwgJ3YVcwVW9VQRjCvhfl9kWZ87294M80FS/426FMZzwIle GZGU/T6eIhushMoVhHt/QWr05Vnzxa7Z3VfpTLzJ1W7pqof54viRHA+x8D7Mk21+0agZ RHhQ== 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=w8htMq2PEFGZqhzmgFVIsg781XcCvMe33t4zvNdJ+Vk=; b=MbyOvw2wQeb8WKIFX2Z1Ehw5Fc5iNmfP47TCUUPNN3krcdv7VfCkjoxe9+leYOlpw1 NHjypirYihAN7u4bBC2aFJP0imADqWuc3e90zn8NyAeEIQv/O2YiYCbqapWoFJUpgsDz kn1Sd0EPg0ydczWjNxD4OOzJvmOr9jNvA9glEFpWTII+Ed9oOE7M3ZwbtZLjLuBi0C0/ Bor60fnF7Pl5tP97BUkmaRE4K9LAOaMOp2g9ZDj9XsgNzaNOrp0fl/jWN+y9W2ZHLj+i Mxfg76OHKJrVWm01f8qX8uKiQGM79ltdM5rXm5qghDDS16aEBmEukeNjFg38VeriZm9o oVpg== X-Gm-Message-State: APjAAAVFHlk0w5da3yBB7D38mvOFC0JOxH3Y10c0V4qfaKhy4rbKJFCU +gD/s81ubajFrMZYwBvGc0joN3Pd X-Google-Smtp-Source: APXvYqyVK/eNcHfs5NHkdnnLlBo4nMh8xsrSh9iU2pJHi7v7YMNRW7+ebG/PPNbaESrNDzLqMOoOtg== X-Received: by 2002:a5d:4902:: with SMTP id x2mr20860749wrq.301.1583123790267; Sun, 01 Mar 2020 20:36:30 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id g7sm20842429wrm.72.2020.03.01.20.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:36:29 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:35:19 +0100 Message-Id: <20200302043520.14165-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/17] avformat/avformat: Allow const AVOutputFormat where possible 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" 9461e4bc made preparations to constify the various AVOutputFormat pointers because the underlying AVOutputFormats should not be changed. To do this, a preprocessor directive (ff_const59) is used that will add const to certain AVOutputFormat * after the next major version bump. This approach has the drawback that it does not allow users to write future-proof code now (if one needs to use av_guess_format(), e.g. because of the mime_type parameter). Yet this is possible: Currently both avformat_alloc_output_context2() and av_guess_codec() have a pointer to AVOutputFormat as function parameter. They can also accept a pointer to const AVOutputFormat without imparing ABI/API compability. Users can then already write future-proof code now by using const. This also makes it possible to already use const now in certain parts of our own code. For the time being, avformat_alloc_output_context2() will have to cast the const away internally until the next major version bump. Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 4 ++++ libavformat/avformat.h | 4 ++-- libavformat/fifo.c | 4 ++-- libavformat/format.c | 4 ++-- libavformat/hlsenc.c | 4 ++-- libavformat/mux.c | 4 ++-- libavformat/segment.c | 2 +- libavformat/version.h | 4 ++-- libavformat/webm_chunk.c | 2 +- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 5bfb0a654e..a2d428e4ef 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-03-01 - xxxxxxxxxx - lavf 58.40.100 - avformat.h + avformat_alloc_output_context2() and av_guess_codec() now accept + pointer to const AVOutputFormat. + 2020-02-21 - xxxxxxxxxx - lavc 58.73.101 - avcodec.h Add AV_CODEC_EXPORT_DATA_PRFT. diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 9b9b634ec3..a260c02072 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2224,7 +2224,7 @@ AVProgram *av_new_program(AVFormatContext *s, int id); * @return >= 0 in case of success, a negative AVERROR code in case of * failure */ -int avformat_alloc_output_context2(AVFormatContext **ctx, ff_const59 AVOutputFormat *oformat, +int avformat_alloc_output_context2(AVFormatContext **ctx, const AVOutputFormat *oformat, const char *format_name, const char *filename); /** @@ -2707,7 +2707,7 @@ ff_const59 AVOutputFormat *av_guess_format(const char *short_name, /** * Guess the codec ID based upon muxer and filename. */ -enum AVCodecID av_guess_codec(ff_const59 AVOutputFormat *fmt, const char *short_name, +enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type); diff --git a/libavformat/fifo.c b/libavformat/fifo.c index 7b37fff6da..3989ca4119 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -441,7 +441,7 @@ static void *fifo_consumer_thread(void *data) return NULL; } -static int fifo_mux_init(AVFormatContext *avf, ff_const59 AVOutputFormat *oformat, +static int fifo_mux_init(AVFormatContext *avf, const AVOutputFormat *oformat, const char *filename) { FifoContext *fifo = avf->priv_data; @@ -480,7 +480,7 @@ static int fifo_mux_init(AVFormatContext *avf, ff_const59 AVOutputFormat *oforma static int fifo_init(AVFormatContext *avf) { FifoContext *fifo = avf->priv_data; - ff_const59 AVOutputFormat *oformat; + const AVOutputFormat *oformat; int ret = 0; if (fifo->recovery_wait_streamtime && !fifo->drop_pkts_on_overflow) { diff --git a/libavformat/format.c b/libavformat/format.c index c47490c8eb..a926d5be0c 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -84,12 +84,12 @@ ff_const59 AVOutputFormat *av_guess_format(const char *short_name, const char *f return fmt_found; } -enum AVCodecID av_guess_codec(ff_const59 AVOutputFormat *fmt, const char *short_name, +enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type) { if (av_match_name("segment", fmt->name) || av_match_name("ssegment", fmt->name)) { - ff_const59 AVOutputFormat *fmt2 = av_guess_format(NULL, filename, NULL); + const AVOutputFormat *fmt2 = av_guess_format(NULL, filename, NULL); if (fmt2) fmt = fmt2; } diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e58da7328f..d685ec0179 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -113,8 +113,8 @@ typedef struct VariantStream { unsigned var_stream_idx; unsigned number; int64_t sequence; - ff_const59 AVOutputFormat *oformat; - ff_const59 AVOutputFormat *vtt_oformat; + const AVOutputFormat *oformat; + const AVOutputFormat *vtt_oformat; AVIOContext *out; int packets_written; int init_range_length; diff --git a/libavformat/mux.c b/libavformat/mux.c index 565a7d7c18..6a973186ff 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -145,7 +145,7 @@ enum AVChromaLocation ff_choose_chroma_location(AVFormatContext *s, AVStream *st } -int avformat_alloc_output_context2(AVFormatContext **avctx, ff_const59 AVOutputFormat *oformat, +int avformat_alloc_output_context2(AVFormatContext **avctx, const AVOutputFormat *oformat, const char *format, const char *filename) { AVFormatContext *s = avformat_alloc_context(); @@ -174,7 +174,7 @@ int avformat_alloc_output_context2(AVFormatContext **avctx, ff_const59 AVOutputF } } - s->oformat = oformat; + s->oformat = (ff_const59 AVOutputFormat *)oformat; if (s->oformat->priv_data_size > 0) { s->priv_data = av_mallocz(s->oformat->priv_data_size); if (!s->priv_data) diff --git a/libavformat/segment.c b/libavformat/segment.c index bf9e706c1c..5f7fe76600 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -72,7 +72,7 @@ typedef struct SegmentContext { int segment_idx_wrap; ///< number after which the index wraps int segment_idx_wrap_nb; ///< number of time the index has wraped int segment_count; ///< number of segment files already written - ff_const59 AVOutputFormat *oformat; + const AVOutputFormat *oformat; AVFormatContext *avf; char *format; ///< format to use for output segment files AVDictionary *format_options; diff --git a/libavformat/version.h b/libavformat/version.h index 4724269b3c..a233b67351 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,8 +32,8 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 39 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 40 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 4e2ce21a79..bc3d346a00 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -53,7 +53,7 @@ typedef struct WebMChunkContext { char *http_method; uint64_t duration_written; int64_t prev_pts; - ff_const59 AVOutputFormat *oformat; + const AVOutputFormat *oformat; AVFormatContext *avf; } WebMChunkContext; From patchwork Mon Mar 2 04:35:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18005 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 DFC1B44B4C5 for ; Mon, 2 Mar 2020 07:07:21 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B25D368B293; Mon, 2 Mar 2020 07:07:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DC55A68AB80 for ; Mon, 2 Mar 2020 07:07:15 +0200 (EET) Received: by mail-lf1-f65.google.com with SMTP id z9so6901939lfa.2 for ; Sun, 01 Mar 2020 21:07:15 -0800 (PST) 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=hlwEc4Frc8vfzrr0wbJU3ZNxDHieHxxyWDS4TOu6v1Q=; b=NTO4vflq2shuiKFNkcwfIrO/ld1trGCseTeMOt8YDX4Mk6oK/VuECb45I9W73ZGhiM QhRDIdkU3mEGWLr/lFzNosj+WHvSog7QgvNXcq0kkbDqcKweVMJEwapFsy1BeOpKIBEh 9rK0/NqztXOz09ClO4B68Z/r8sD0RZt2FaAE9/YVtJymazBkNRJMtICAr5j3tCv+avwB kuR88utzrs3Z6v/zDUFyoXqmAV+tMvyuYOWYFLTn3LWan6VzkRcYjVNGp6nfCg9a5iRN DT5VW+OQdpeGp0opqeqpXJRIjGuXUEmWEy0TFx4XX5r3ng6QKxxDMV/a2kQJomUGQCJ3 xY4g== 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=hlwEc4Frc8vfzrr0wbJU3ZNxDHieHxxyWDS4TOu6v1Q=; b=V20uqiWRs5Aftx4KuH78FxJY+3rjXNZ5dbkkhU3iXoI7RDtmq34RjtR+A1ZDxyhJ0L 6zA7PR4wDkRQh5xLOaEfH+Zx4zBs1nFxoUWHhcyLF0/UMkKe2NRTb2waMzyud1nOpbx9 BvqcVZLOIAx9zw1/jueGDCon2WNE8EE63FPEo7EFNWJ8Vnq1D0RkOpaiaRoWIFSPNA6d Bk/Wk0V+kOd0q/cpOFmWQfY8soq5MXc9TLSctRq3N0+KEgaRkSZ0m3dN2fcAhTeuztDm zDV26sV81O3PGoUM8Kxl1EPDazoJ4VBJ4GL+bACp0kF9z66hz99HegNA+AXZnJAozz4C ayyA== X-Gm-Message-State: ANhLgQ18Qc+0S/jabFWWg9T+jQLnlXGc1xynwGpRU/iEY02yfu5m1Duu 0muNdwPxE3keyQ3NsX/WOJfoPFw0 X-Google-Smtp-Source: APXvYqwkvpSrvLEH8x1NPd5lIYt7XYuYBeJwS5VD/3oxMrz4VUxOsYwT1pdDvVDt3cukBvV/J1nugw== X-Received: by 2002:adf:e808:: with SMTP id o8mr14773409wrm.8.1583123798094; Sun, 01 Mar 2020 20:36:38 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id g7sm20842429wrm.72.2020.03.01.20.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:36:37 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:35:20 +0100 Message-Id: <20200302043520.14165-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/17] avformat/segment: Don't set extradata size twice 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" ff_alloc_extradata() already sets the size of the extradata so doing it again is unnecessary. Signed-off-by: Andreas Rheinhardt --- libavformat/segment.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/segment.c b/libavformat/segment.c index 5f7fe76600..d565183349 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -882,7 +882,6 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) goto calc_times; } memcpy(st->codecpar->extradata, pkt_extradata, pkt_extradata_size); - st->codecpar->extradata_size = pkt_extradata_size; } } From patchwork Mon Mar 2 04:44:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17992 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 20E97449CCD for ; Mon, 2 Mar 2020 06:45:04 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0689768B082; Mon, 2 Mar 2020 06:45:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1428D68AA9A for ; Mon, 2 Mar 2020 06:44:57 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id z12so9553848wmi.4 for ; Sun, 01 Mar 2020 20:44:57 -0800 (PST) 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=LDfQ6fGtkFALb9q8KvfZ5T7envKm+++T6KWOQK6kh20=; b=cP7kY1tdL7rXdw8MmbHCarQ5aiChkX/aMXlT71gjmaiMlc46m4hm3S23vLvPb3NH7w wq8LyZT/AOSMRRTKKaJpfT0iWGKLl834Wf3EQvr1iZf8OlXknqJ6VkMaegCxLgslIgW9 PZ5TvsJO24xsp7YiIcuF83ikfoMC5Sg51Evvy7YrSZM212ygF/bdv4NLQcawg3x9SsPr DWEfkNeP0UJ3xrTwidgRorBjic+7xmHZ2TktQCdib1jYZcrf7qQxl0eibx0tQRgVjt0S Y6n+ZgP4ft3x6EQtME7OStjrox6NdSj1vNi0MWIa2uNb3HtXXlKO2ioanLodz4UzGCcq Vqpw== 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=LDfQ6fGtkFALb9q8KvfZ5T7envKm+++T6KWOQK6kh20=; b=qpPVkX7Tc5zOh+Yj4PN2cUmDtZfYoKdLktcOuCKDH8d5gJeDl2Kinx+1WAKlXXjB19 2YC/gxlqEYTdf9s0Tiwf5B+6RA9lGKeeQjf2yeebN2QpbrAJnlNvBrSmZi5d37CSZYR/ 3VZ6R6dSPdPkPuWI3/rFk8/bhDVyDRho2fbzgmFRlBQM4hJBRg0h2Yzo8U+byrdtQ1rz 1OsrQYg/X/KMyxWWg+nFRAKA4w1AWgCZONXTuQ/BzxtWUAXYCHsXsXaAtkwwz1tAbD+u Jq13kcH/MLb3fOnGivoW602bT+SpwaNjZ6OzhdeyteD7Cpge1eMHD8hCnTKzKe2mNQ10 CIBg== X-Gm-Message-State: APjAAAUymWykmV4Itf8X2jtTIDcEucmK4hOukgEM56I0vMAPEm6RjIvh aKuL97hyT0M6uJGp7+f2P9RgftpP X-Google-Smtp-Source: APXvYqx0IUYLdVLHp7UCBASN++jQJyQWQteiy6zUtzqMXsRo0CFftDg5wEPKecCej6Z7bPZQTWgJHQ== X-Received: by 2002:a7b:c204:: with SMTP id x4mr17514069wmi.20.1583124296402; Sun, 01 Mar 2020 20:44:56 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:44:55 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:33 +0100 Message-Id: <20200302044445.14842-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/17] avformat/webm_chunk: Don't use child AVFormatContext for logging 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" Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index bc3d346a00..0d4e3598ed 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -87,25 +87,24 @@ static int chunk_mux_init(AVFormatContext *s) static int get_chunk_filename(AVFormatContext *s, int is_header, char filename[MAX_FILENAME_SIZE]) { WebMChunkContext *wc = s->priv_data; - AVFormatContext *oc = wc->avf; if (!filename) { return AVERROR(EINVAL); } if (is_header) { int len; if (!wc->header_filename) { - av_log(oc, AV_LOG_ERROR, "No header filename provided\n"); + av_log(s, AV_LOG_ERROR, "No header filename provided\n"); return AVERROR(EINVAL); } len = av_strlcpy(filename, wc->header_filename, MAX_FILENAME_SIZE); if (len >= MAX_FILENAME_SIZE) { - av_log(oc, AV_LOG_ERROR, "Header filename too long\n"); + av_log(s, AV_LOG_ERROR, "Header filename too long\n"); return AVERROR(EINVAL); } } else { if (av_get_frame_filename(filename, MAX_FILENAME_SIZE, s->url, wc->chunk_index - 1) < 0) { - av_log(oc, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url); + av_log(s, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url); return AVERROR(EINVAL); } } From patchwork Mon Mar 2 04:44:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17993 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 19E9A449CCD for ; Mon, 2 Mar 2020 06:45:05 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B4B568AE75; Mon, 2 Mar 2020 06:45:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA12E68AA9A for ; Mon, 2 Mar 2020 06:44:57 +0200 (EET) Received: by mail-wm1-f66.google.com with SMTP id p9so9583910wmc.2 for ; Sun, 01 Mar 2020 20:44:57 -0800 (PST) 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=lBdaGsD3s6vJFdOG+KOQfcyfyJ60GXvb0U+/YezWEIw=; b=a6ltnMin9JSONMnWRiijRRfbJVJw4Yu9HZxewpX2PM7rJO++s564o26tP/qLsEFRgm yru0DplVUc+acGAR/uGcpP1MJNDYH/MTUeo3kSaBNdk5U5qMFf/pcvmGxdX/0NqWjwPq rGAt5JXPEsnF2aZX2J99qrh+ag57vw2URPLxVUeMT6ULbdxr32nsozRhaFlIUh0Pi+MT /tSo5Ab4pGGEC/axEpgnH0aO2EGAbln7ApUL+NY9Apos0NzxUtG8G5t33T+whJyK91fg 7GGfODl+bJubopSBPjFOUHuPIEMZcDhUq43W7mejCmRGKPdGmaBptz31sX1QYT++8W1s Li5Q== 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=lBdaGsD3s6vJFdOG+KOQfcyfyJ60GXvb0U+/YezWEIw=; b=MK3Hv4Zwe/ax5E8NdAyGxa3TDQL4l9jjlxx7HmHGuMhBQB71/5jwDU30Vs8FAF5bfL to853e5Bbe1jfepwuHpoycGfrdgC498C8Q8iXIDO0/O9ZayqQzQEkBJdFhJ+ClDgK+Sc JgmDVBmKTimqTa1iqJK0/eWwOM/u0hzCaFkmVnJa1r8loEiqsX4ymsUXw38fPIpYpUlG 27WtpkGVCpxmaC++k7PqKXfamRYZigTAZfo+yz1pCBAdL384oSk7x/pRQBcy8mxlB/EG A68l+BBxI8MPXYtyDOP46JcoD5SJ6n34R/9xKrglWA+/4uTzp8k5Hy4VybwwwC6OlHGt 8Zhw== X-Gm-Message-State: APjAAAU4z0HtNVEM/PxlXDDQcBVPcv5nCfQxdy/Imgc5+IyLXs1sEUVj uwNCcQNcd4BmxaggZxbeq/eSTSfD X-Google-Smtp-Source: APXvYqx5XdK1ShwFIOufbYWbdT8ngx0GBUTRhuqPq1vGsjsK8T23TfOgzWjFBVtEiO+1BQrxk7epSQ== X-Received: by 2002:a05:600c:cd:: with SMTP id u13mr17109320wmm.38.1583124297186; Sun, 01 Mar 2020 20:44:57 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:44:56 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:34 +0100 Message-Id: <20200302044445.14842-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/17] avformat/webm_chunk: Close IO if writing header fails 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" Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 0d4e3598ed..d42f46aab2 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -150,9 +150,9 @@ static int webm_chunk_write_header(AVFormatContext *s) oc->pb->seekable = 0; ret = oc->oformat->write_header(oc); + ff_format_io_close(s, &oc->pb); if (ret < 0) return ret; - ff_format_io_close(s, &oc->pb); for (i = 0; i < s->nb_streams; i++) { // ms precision is the de-facto standard timescale for mkv files. avpriv_set_pts_info(s->streams[i], 64, 1, 1000); From patchwork Mon Mar 2 04:44:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17994 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 CE559449CCD for ; Mon, 2 Mar 2020 06:45:05 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B74DC68B1EA; Mon, 2 Mar 2020 06:45:05 +0200 (EET) 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 A659168B05E for ; Mon, 2 Mar 2020 06:44:58 +0200 (EET) Received: by mail-wm1-f68.google.com with SMTP id m3so9356701wmi.0 for ; Sun, 01 Mar 2020 20:44:58 -0800 (PST) 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=kEx0otTvLxlL9NVQjElbpqxf3JYPWs37za3gWK6loLI=; b=ggLAQKLmXzvhHnurXkupb40L8tZezsou6bNBtSl2bE1l4Zd+DOON1wGFl5Nm83RbIc gB0fGOD/hyDNqRunivM+dzTayNCYfwFwKamfuUye4bYVDKSDDS+x6avBfI1kLeAIFEsa XGZAw1dAn54BxIVyFFTpo/JBJySFycPLOXstnXwdlUuQRNxi37IJ4h6oG6qMqwLqQh/1 BPmjx0Yo0vNQYA94I49n+AwmiTZUK3fv/4K+Yx5ndO12FrlZow6LvXz0gOzvnDObaB4w kVqpbHlV4m1u+nKin5QPOAKGW6G7aClalCnY+nf8ON8BNjw6JE4uVPNW9huOWY0xDUGi 4fXw== 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=kEx0otTvLxlL9NVQjElbpqxf3JYPWs37za3gWK6loLI=; b=Q37SudDb5RPgcHSvxcB28Z/UgVOqB92dRUdTLBKL90SNQRASiCRfitDVw2hE+cACt9 xoYBRyNl0AX5skXkZCEE6jfsoO7MpHSa3FgNaicp/mJ/45TFHOVPi6um4AuEwpwqWyrk Wnhmtkp5cpKeCtnZIbBsWBdiME8hx5pDieICIPdT/KI4CWt82dyaKt/SEYEXQWomXkez CWFMvlzeeoXBHth+h/G0pILjuYgtRDq6OorUS9qV5Bmqe4MiN0SPZpf3hj0XItWD/cFC Sa6KJC25NfH9jz3ZyijiN3kdND+1X2mInu8uHT7e5DaicFZjDzH8DeZynafBrhtV8Vqd pq2g== X-Gm-Message-State: APjAAAVpsXSrwfT0K7IXcpMmXGL/+AWoYFfUJrsYqwl1SyGioAphIMO1 7xzGQ6Fna1uySo2m03OPTnh4xIuw X-Google-Smtp-Source: APXvYqxtBmuEZyze2UCZnDtxyoWhwZIaNFUcRhxwvVMuCBi5tiHrziL8su06K9Ux1ABNB7wP3GS9Cw== X-Received: by 2002:a7b:c1cf:: with SMTP id a15mr17651298wmj.85.1583124298017; Sun, 01 Mar 2020 20:44:58 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:44:57 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:35 +0100 Message-Id: <20200302044445.14842-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/17] avformat/webm_chunk: Copy more information to the child AVFormatContext 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" In particular the flags are important so that AVFMT_FLAG_BITEXACT can be honoured by the child muxer. Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index d42f46aab2..63c00d22e4 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -70,6 +70,9 @@ static int chunk_mux_init(AVFormatContext *s) oc->interrupt_callback = s->interrupt_callback; oc->max_delay = s->max_delay; + oc->flags = s->flags; + oc->strict_std_compliance = s->strict_std_compliance; + av_dict_copy(&oc->metadata, s->metadata, 0); *(const AVClass**)oc->priv_data = oc->oformat->priv_class; From patchwork Mon Mar 2 04:44:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17995 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 DD91B449CCD for ; Mon, 2 Mar 2020 06:45:06 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C033368B3E1; Mon, 2 Mar 2020 06:45:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8587968B074 for ; Mon, 2 Mar 2020 06:44:59 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id a5so9585156wmb.0 for ; Sun, 01 Mar 2020 20:44:59 -0800 (PST) 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=kBV0QOI92W8eKf7XU+2fIVgEVmuLMivCuqdNxUBvYQk=; b=k6YPVHldAObiXwHjpCnoV0omCo0d38+MPCtceEXeDrwWXMLPyZwOH1pRmiw/YDeyZR yxH2/Y6l1k3c7QxoJPARlhrh1Vjkvms7+kiqtYibhQ+t58quHo4gjkfEZH1G17Uc9rDl fL6GdpUm8Y4FX8o9V3zvdEeggHG9Pe9cFWSR7OoYNjt68Svv6hcsyX/Mm1qlP6qS3JoZ HMW+y7anKYZLVqjuKdy/7arh2yQS3mny8d15f39kqJMRbIvjAJ5luY60kufCxv+5jSls BYbc4C4RzOut/HgKgudCQYdH53QY1vekapI0cil7J4p/CLxNNv30LEpM3DnZsQfVhwfb kVuA== 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=kBV0QOI92W8eKf7XU+2fIVgEVmuLMivCuqdNxUBvYQk=; b=FsyU+Hsp0ZbwTd2jZBBKDYpsp4E5q4+nWLiF7OrVxmNaKqtL3muTpZ9kfbR3/E4Oez cKLH7SyXPjBNuy6AX0mv02GNA1Vp9j7SlPTt2V52g7towvBvICrmJhEg49y+9iCamVpC cH5dZA5xwns9UtqeLliIRajk2g/V3Ff03Sw+9WI9kJSBCsBDIIiIyUCVn4sBDYmAMopZ R+G0PGioA8p3S0SdSmCJYNuez1sAkT3XQ1EBpP14cTOt9kqIpVu9WhRPvKsgEgFImcjt WWPrBdsOF88K7pS8dGwHy0ojZOWYo79WkKjP+R0iK53PqpOi2K1b81NpNiv95qRQIhIQ xp1w== X-Gm-Message-State: APjAAAX9feHfJSFCTGRKSGrjYE1TuQsaThqT+VkLRc2gT8Ns+wxePJ2x 4XNFh+9oRzcjmhS2BFXAa0dV0gK9 X-Google-Smtp-Source: APXvYqyuSVGH0QM/gKyZMQpJ5V4GBD0ePKv2whODuTdSSXyTW9RdJxsN/2RV16s8DpjddKeM3Y7YFA== X-Received: by 2002:a05:600c:2551:: with SMTP id e17mr14517406wma.174.1583124298867; Sun, 01 Mar 2020 20:44:58 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.44.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:44:58 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:36 +0100 Message-Id: <20200302044445.14842-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/17] avformat/webm_chunk: Use appropriate initializer for AV_OPT_TYPE_STRING 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" Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 63c00d22e4..08d825449e 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -267,7 +267,7 @@ fail: #define OFFSET(x) offsetof(WebMChunkContext, x) static const AVOption options[] = { { "chunk_start_index", "start index of the chunk", OFFSET(chunk_start_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, - { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, { 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, + { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "audio_chunk_duration", "duration of each chunk in milliseconds", OFFSET(chunk_duration), AV_OPT_TYPE_INT, {.i64 = 5000}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "method", "set the HTTP method", OFFSET(http_method), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, From patchwork Mon Mar 2 04:44:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17996 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 D9878449CCD for ; Mon, 2 Mar 2020 06:45:07 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BD44B68B1DC; Mon, 2 Mar 2020 06:45:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9162F68B14F for ; Mon, 2 Mar 2020 06:45:00 +0200 (EET) Received: by mail-wm1-f52.google.com with SMTP id z12so9553909wmi.4 for ; Sun, 01 Mar 2020 20:45:00 -0800 (PST) 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=LZEqpZ9hYxLfJ+RYnOk4LuNRrtlK52y5nSlou9Isy8Q=; b=d8a4JQN1mrl2v2mwzD9/ucYNPr9PMPlJV8UbE75p9x6n1AjJPKQSALSJDrMunMq2Kp +2bX9rQQlTtrAuxvPVwx3Wdevk3XdL7HY/RoI7qR3mKI3LWZn99o1wa394PlvLvnLgIa v6dtem+gJpEV3DoOcOMSG1TKGXEwl1tU1JnINpcCyYxoWJEamWgDWDxqfYOkluuumU08 i7ccP6bFmstzuj3+wHwonzQR/sckrliS0FLD4b1Ca7HKAaSX9xNm4S+YkYEGWq0EPvJY 2o4FekCU3df2wwahMl6xn3Ewnt1+kU4wGLObejukxkRV68FbHs65j4Y8H6peSQ1IsC/z vc8A== 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=LZEqpZ9hYxLfJ+RYnOk4LuNRrtlK52y5nSlou9Isy8Q=; b=SjHrIi7iEUADPww9Dlu9/3asomY2RP7D7QwCrV2B8rvcEpLAsrc3HJ1nfeWD/4Kese Aj44kS6hNenSThcd/xtTxt7nG6mnHv1xcr5iaOALc7qMLymLwgNkpUWX2DgKkLZFQY6c 5/8I7vUvnFLqEs9QmalSob8quFAfrUHVyklaq3cVFHuPw5H7reY/YGtnlJMIZ3t2Sng7 c4WxZEIvnzMWUaqDLsKu7MY1s3agL7MGf/BLETJ3xIjpWttEZPYOmZfinQo1hlfmVSPi Z9pJQ7BHBuKXdXHHvpgQ5rEdtabR+ZNAHjdqRrxFRObavzTCksknr3SHfXs+0xYywar6 01vA== X-Gm-Message-State: APjAAAXtPfzlw1r27Nf+7sUfdZ26ENiF0UrGTJEbB/5nJnLUjCfoengn pv/bhkUjuMuv5nJ5+t/4PyKacb81 X-Google-Smtp-Source: APXvYqyW70K3//dzbqtFowKdeXiselIz60Ks6l/TIrp31I6Twmo8BkZaI+R6s0srd5O0AmVZ2vDJ1w== X-Received: by 2002:a1c:a746:: with SMTP id q67mr16816640wme.1.1583124299660; Sun, 01 Mar 2020 20:44:59 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.44.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:44:59 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:37 +0100 Message-Id: <20200302044445.14842-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/17] avformat/webm_chunk: Use API functions for child muxer 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" instead of calling the write_header/packet/trailer functions directly via the function pointers. Also, use distinct AVStreams for the child AVFormatContext (up until now the two AVFormatContexts shared their AVStreams because allocating their own was deemed too onerous). Using the function pointers directly meant that the Matroska muxer's init-function was never called, because init-functions were only introduced a few months after webm_chunk has been added and no one thought of/bothered to adapt webm_chunk for this (when the init-function was added in b287d7ea, the code setting the timebase was moved to it, so that the timebases were no longer set to ms-precision when using the webm_chunk muxer; this has been fixed after some time in 42a635dd by setting the timebases direcly (instead of calling the init-function)). And when 982a98a0 added a deinit-function for the Matroska muxer, it introduced memleaks in webm_chunk, because the child muxer's internal structures were no longer freed when calling write_trailer directly. (Given that the init function has never ever been called, the child muxer has never ever been properly initialized, so that the deinit-function was not called when freeing the child context.) This commit stops calling the function pointers directly and instead uses the standard API functions for muxers. This fixes the above mentioned memleaks. (Memleaks are still possible on error. This will be fixed in a future commit that adds a deinit-function to webm_chunk itself.) Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 59 ++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 08d825449e..3c00c562e5 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -61,6 +61,8 @@ static int chunk_mux_init(AVFormatContext *s) { WebMChunkContext *wc = s->priv_data; AVFormatContext *oc; + AVStream *st, *ost = s->streams[0]; + AVDictionary *dict = NULL; int ret; ret = avformat_alloc_output_context2(&wc->avf, wc->oformat, NULL, NULL); @@ -72,17 +74,42 @@ static int chunk_mux_init(AVFormatContext *s) oc->max_delay = s->max_delay; oc->flags = s->flags; oc->strict_std_compliance = s->strict_std_compliance; + oc->avoid_negative_ts = s->avoid_negative_ts; av_dict_copy(&oc->metadata, s->metadata, 0); - *(const AVClass**)oc->priv_data = oc->oformat->priv_class; - av_opt_set_defaults(oc->priv_data); - av_opt_set_int(oc->priv_data, "dash", 1, 0); - av_opt_set_int(oc->priv_data, "cluster_time_limit", wc->chunk_duration, 0); - av_opt_set_int(oc->priv_data, "live", 1, 0); + if (!(st = avformat_new_stream(oc, NULL))) + return AVERROR(ENOMEM); + + if ((ret = avcodec_parameters_copy(st->codecpar, ost->codecpar)) < 0 || + (ret = av_dict_copy(&st->metadata, ost->metadata, 0)) < 0) + return ret; + + st->sample_aspect_ratio = ost->sample_aspect_ratio; + st->disposition = ost->disposition; + avpriv_set_pts_info(st, ost->pts_wrap_bits, ost->time_base.num, + ost->time_base.den); + + av_dict_set_int(&dict, "dash", 1, 0); + av_dict_set_int(&dict, "cluster_time_limit", wc->chunk_duration, 0); + av_dict_set_int(&dict, "live", 1, 0); + + ret = avformat_init_output(oc, &dict); + av_dict_free(&dict); + if (ret < 0) + return ret; + + // Copy the timing info back to the original stream + // so that the timestamps of the packets are directly usable + avpriv_set_pts_info(ost, st->pts_wrap_bits, st->time_base.num, + st->time_base.den); - oc->streams = s->streams; - oc->nb_streams = s->nb_streams; + // This ensures that the timestamps will already be properly shifted + // when the packets arrive here, so we don't need to shift again. + s->avoid_negative_ts = oc->avoid_negative_ts; + s->internal->avoid_negative_ts_use_pts = + oc->internal->avoid_negative_ts_use_pts; + oc->avoid_negative_ts = 0; return 0; } @@ -119,7 +146,6 @@ static int webm_chunk_write_header(AVFormatContext *s) WebMChunkContext *wc = s->priv_data; AVFormatContext *oc = NULL; int ret; - int i; AVDictionary *options = NULL; char oc_filename[MAX_FILENAME_SIZE]; char *oc_url; @@ -152,14 +178,10 @@ static int webm_chunk_write_header(AVFormatContext *s) return ret; oc->pb->seekable = 0; - ret = oc->oformat->write_header(oc); + ret = avformat_write_header(oc, NULL); ff_format_io_close(s, &oc->pb); if (ret < 0) return ret; - for (i = 0; i < s->nb_streams; i++) { - // ms precision is the de-facto standard timescale for mkv files. - avpriv_set_pts_info(s->streams[i], 64, 1, 1000); - } return 0; } @@ -192,7 +214,7 @@ static int chunk_end(AVFormatContext *s, int flush) if (flush) // Flush the cluster in WebM muxer. - oc->oformat->write_packet(oc, NULL); + av_write_frame(oc, NULL); buffer_size = avio_close_dyn_buf(oc->pb, &buffer); oc->pb = NULL; ret = get_chunk_filename(s, 0, filename); @@ -239,9 +261,8 @@ static int webm_chunk_write_packet(AVFormatContext *s, AVPacket *pkt) } } - ret = oc->oformat->write_packet(oc, pkt); - - return ret; + // We only have one stream, so use the non-interleaving av_write_frame. + return av_write_frame(oc, pkt); } static int webm_chunk_write_trailer(AVFormatContext *s) @@ -255,11 +276,9 @@ static int webm_chunk_write_trailer(AVFormatContext *s) if (ret < 0) goto fail; } - oc->oformat->write_trailer(oc); + av_write_trailer(oc); ret = chunk_end(s, 0); fail: - oc->streams = NULL; - oc->nb_streams = 0; avformat_free_context(oc); return ret; } From patchwork Mon Mar 2 04:44:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17998 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 0CF63449CCD for ; Mon, 2 Mar 2020 06:45:10 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E43A268B4AC; Mon, 2 Mar 2020 06:45:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7AC4C68B112 for ; Mon, 2 Mar 2020 06:45:01 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id e10so9326164wrr.10 for ; Sun, 01 Mar 2020 20:45:01 -0800 (PST) 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=y0BNFkDtQ5d7MJL3bLXR3KAzi78QeRWkbAdjssyhwU8=; b=UerW32grfB/VZUauISUKsWPxhMR69zrB5r0/YjrkEyy7uPD1qPz2FIa+9u5gRKW7uc awPQB9rrtN+HcYIMMPOoz0+4elAKLWrADbAuEkY4hwLy1Wn7UfhDjTM1JmK/xTOxxpkY 2746OYlnAgYr0wQmo38czRMLpHUpvnrWaappFG60xnU5oIDC4SeHsjkZObKohzrcbfUW 3vhXelxTCMo5JWnyT8CFx6wZ8CfBm+flh3ICcPJqfjdIxmCYDnPgdWj1q5yUUO3DOT3p oCWDuind53QpMjkn/5a3IFJNR2TP4X8g3OhPK5kJ4PmJlaYT5mU6+YBgxhDqJrlgjdjn HnEA== 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=y0BNFkDtQ5d7MJL3bLXR3KAzi78QeRWkbAdjssyhwU8=; b=JP/kU7154tT4/NO1751rYlGo+5g53acdJxqGCm9sSeseIL/WDxYycEdcqL5OXkODgY FMpxQKdCHQBh2CESsbYxrZorYZ1s9GmkdzGqOtDiIFUHD0TOLL8A8nlxn85JmGWCR4et NQoMAIQXeUyfJn1SlB8d8kue4NNP6/ysp970VbGcc+3HjE7xL+sb0JjvjfNfoEBdAQ3h yAuk/1jxzzsY3n15KZP8v2vfjG1n3PfAWUye5P8IYaRYvjruNLlhZrPPLnpkxJkLZ5nF YUWXEAkkwGLxHR1ahrfZHDhL4UcSJyFwRkR8obkt5tdNz0+P0oeZhfNYpQ9+gyUvZCF6 jSHw== X-Gm-Message-State: APjAAAX+BorlqgIyy4cxyRb1YSkGhvlP8sXl9nVVD6soXkUYTL4k+QmI rR4MVz8XGC7oPRJIfZjEhEyMrRUW X-Google-Smtp-Source: APXvYqyg7dc61HWDN5BtpkZd02qkACoeaNPS6xPGY2fYgE8EZKagyTYb9X70mgTZJ5E1EVuVA/6AWw== X-Received: by 2002:a5d:5286:: with SMTP id c6mr13409230wrv.418.1583124300654; Sun, 01 Mar 2020 20:45:00 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:45:00 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:38 +0100 Message-Id: <20200302044445.14842-6-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/17] avformat/webm_chunk: Avoid unnecessary flushes 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" The webm_chunk muxer caches its output to a dynamic buffer and when it outputs anything, it explicitly flushes it. So set the flags indicating that flushing after each packet should not be done automatically (basically avoiding avio_write_marker() to be called by flush_if_needed() in libavformat/mux.c). Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 3c00c562e5..3beb267458 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -72,10 +72,12 @@ static int chunk_mux_init(AVFormatContext *s) oc->interrupt_callback = s->interrupt_callback; oc->max_delay = s->max_delay; - oc->flags = s->flags; + oc->flags = s->flags & ~AVFMT_FLAG_FLUSH_PACKETS; oc->strict_std_compliance = s->strict_std_compliance; oc->avoid_negative_ts = s->avoid_negative_ts; + oc->flush_packets = 0; + av_dict_copy(&oc->metadata, s->metadata, 0); if (!(st = avformat_new_stream(oc, NULL))) From patchwork Mon Mar 2 04:44:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18000 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 6B45F449CCD for ; Mon, 2 Mar 2020 06:45:11 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 59CA568B480; Mon, 2 Mar 2020 06:45:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 58F4168B458 for ; Mon, 2 Mar 2020 06:45:02 +0200 (EET) Received: by mail-wr1-f67.google.com with SMTP id l5so10777552wrx.4 for ; Sun, 01 Mar 2020 20:45:02 -0800 (PST) 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=J/R9llcQtnQxWLsEhE7oBDjzYjr/gvxeGzXilEs4CE0=; b=TlpQ+GX8WVoN7JSx9+F2nlEktsgPjWJYgcEz0s7anGJfypxjkMFGnzy9h3j/7S7WhT iIec3XwiL7k9M3panVxQihvMqveFUNg/4NOc0NBci7OOpIA4quhgtXSxdG5riKSSOWl/ qw6hgjYyz3GDPQPYjZggJi6xQMWG7BET7NHCUXnxUDzeNmrKddy1bN0FH4FnrkdmMsBq HwCkcSzaQ9tl/kdFMy50RdXOTNeWpAt7QWcKHQLyi1nK6viNs6Ra6RF1b/FzQmkFtZiR VAYPPJW5Diq1VJfPgQS98Ru3hjE/tkRdNqNVX/vjMvf/g+h5JE2KcXgIzSZgMWtdRBdf hikw== 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=J/R9llcQtnQxWLsEhE7oBDjzYjr/gvxeGzXilEs4CE0=; b=UkMreycvHXEV2hMGOhPeK1OB0BtMOrtEP/xF/mwVjqKKcuCDo8z+tN8YNnYNANzCNh 4S/lFyrd0q4tZQJeUvV46uBbU+1uw3SiGPeHIxrpAoGf2QgurlD5pma+TxT+iByi8n6P s8Gd8BRVdOQ13m2IhUAMqof5r8P4PoLaz5pgG42G2CjbWdhHBf/ck//Duh7gqzch6TDA zMitugHwxuOkiLvaqbd2gJ24ELP9D8vmZ8GOaTzU8E9/Qmgdu89RFDIy/d9m4tg1rxql qQTqMlu/XAmOJ21VS8G2lNZxeM4Kf7tb2uxAEWGwFadokj4TO1AHzgEJL7IhSfmnCEI9 DYTg== X-Gm-Message-State: APjAAAWw+VI2llb7k8ybrkq3fVxSNdyLaEmov7AOZjI+ywr0a/E3Yc4+ RxiBvuQFkUu53SKNqPcbWeMa7Epv X-Google-Smtp-Source: APXvYqzxZQgVfbrWuQmnKbqDRMuVJWwv8ruF6hBNWgbnxSILt2gt4/Thou/u7vFZ6T0hqjvXc9c6YA== X-Received: by 2002:a5d:494a:: with SMTP id r10mr19705646wrs.21.1583124301614; Sun, 01 Mar 2020 20:45:01 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:45:01 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:39 +0100 Message-Id: <20200302044445.14842-7-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/17] avformat/webm_chunk: Don't keep pointer to AVOutputFormat 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" It is no longer needed given that the function pointers of the child muxer's AVOutputFormat are no longer called directly. Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 3beb267458..d1b016bb14 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -53,19 +53,23 @@ typedef struct WebMChunkContext { char *http_method; uint64_t duration_written; int64_t prev_pts; - const AVOutputFormat *oformat; AVFormatContext *avf; } WebMChunkContext; static int chunk_mux_init(AVFormatContext *s) { WebMChunkContext *wc = s->priv_data; + const AVOutputFormat *oformat; AVFormatContext *oc; AVStream *st, *ost = s->streams[0]; AVDictionary *dict = NULL; int ret; - ret = avformat_alloc_output_context2(&wc->avf, wc->oformat, NULL, NULL); + oformat = av_guess_format("webm", s->url, "video/webm"); + if (!oformat) + return AVERROR_MUXER_NOT_FOUND; + + ret = avformat_alloc_output_context2(&wc->avf, oformat, NULL, NULL); if (ret < 0) return ret; oc = wc->avf; @@ -156,9 +160,6 @@ static int webm_chunk_write_header(AVFormatContext *s) if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; } wc->chunk_index = wc->chunk_start_index; - wc->oformat = av_guess_format("webm", s->url, "video/webm"); - if (!wc->oformat) - return AVERROR_MUXER_NOT_FOUND; wc->prev_pts = AV_NOPTS_VALUE; ret = chunk_mux_init(s); From patchwork Mon Mar 2 04:44:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18002 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 72B61449CCD for ; Mon, 2 Mar 2020 06:45:13 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 57C6268B4C7; Mon, 2 Mar 2020 06:45:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3265068B0EE for ; Mon, 2 Mar 2020 06:45:03 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id t11so4363306wrw.5 for ; Sun, 01 Mar 2020 20:45:03 -0800 (PST) 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=O9zsg8xO3uK+MYXGNQgILz5PgD2lGQKnweXHhF2N4YM=; b=NU1xfXFffR+S0IpdHSLupxrw1dfRq8U1Ha11/SVlriXuRf0uCf1xHoOJYOvbIuB1Vn QadOKJyq3bUqXUJIp00efNE9sc8xSCrusHKT2Epq5TvTxJTxeECfBuVuNavmNTlTeINg 5QlwujOd8oEbDYGrazCwjEQ3ckzCmjTBU4SUWaEmZWhFc5252mTDq+dwv7IDkkZZJi04 q9mVSiJ3eCjE+shVhX9MIZ5tROmm54sutqAvRI3cE1YAh41APZdCaIMm75Zq0JxZPg2C qZLhwcL1Ye7U/W0fq4W3PK9VjF5ynQ4kwdSxd7DShZFk2QSSwMw7Pev2HodOXIj24+sQ uPVw== 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=O9zsg8xO3uK+MYXGNQgILz5PgD2lGQKnweXHhF2N4YM=; b=o5rk5xStwh+si2VZyOTRJI/fcZi1UYs4K3wgpdR19lWxMin1qloqv5zEf6MmFKGyRX fQ4YnFLEYh/L3B2cW2HZG9PGElT0b6q/v2d392ELvGZYQPtKz9X+EUT3gBgNOy2Vp1Da l1myQDZCqFAMa376som/uSv3TVPlmFP4QaGBZEp2Xbfj5/cc82rrquf2RWYr632ru+Ja xKl+bEGREC9IIisfHdegPBQssr6YzNcunwkQX9m0ENSWSOlt4jNLjItPMmjtMfYV06qA n/l/+XrZ5skP0IOxRVyHnRfULiEaJmUW03jlP3uRH0pKXIKzVoksPzJqzjm0HpiIa5ky PchA== X-Gm-Message-State: APjAAAUNo1CMa7/W/DrPhtTR6VMVDcKWebuUXDb4rNBehqp/Nl2MVCK3 iNFBLR6to0lCNvLpqXW/f8vZa97/ X-Google-Smtp-Source: APXvYqyWnGxTRxVDdGlBm5fmX+XYODEHoqHZKtHWRcaESPfBTUjkhk3Tfknboe5xgQuWr85BP2WEtA== X-Received: by 2002:a5d:4807:: with SMTP id l7mr19778513wrq.250.1583124302441; Sun, 01 Mar 2020 20:45:02 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:45:01 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:40 +0100 Message-Id: <20200302044445.14842-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/17] avformat/webm_chunk: Don't copy header filename 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" Instead just reuse the filename string that is given via an option for the child muxer's url field. Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index d1b016bb14..a4aab04a44 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -65,6 +65,11 @@ static int chunk_mux_init(AVFormatContext *s) AVDictionary *dict = NULL; int ret; + if (!wc->header_filename) { + av_log(s, AV_LOG_ERROR, "No header filename provided\n"); + return AVERROR(EINVAL); + } + oformat = av_guess_format("webm", s->url, "video/webm"); if (!oformat) return AVERROR_MUXER_NOT_FOUND; @@ -74,6 +79,9 @@ static int chunk_mux_init(AVFormatContext *s) return ret; oc = wc->avf; + ff_format_set_url(oc, wc->header_filename); + wc->header_filename = NULL; + oc->interrupt_callback = s->interrupt_callback; oc->max_delay = s->max_delay; oc->flags = s->flags & ~AVFMT_FLAG_FLUSH_PACKETS; @@ -120,30 +128,17 @@ static int chunk_mux_init(AVFormatContext *s) return 0; } -static int get_chunk_filename(AVFormatContext *s, int is_header, char filename[MAX_FILENAME_SIZE]) +static int get_chunk_filename(AVFormatContext *s, char filename[MAX_FILENAME_SIZE]) { WebMChunkContext *wc = s->priv_data; if (!filename) { return AVERROR(EINVAL); } - if (is_header) { - int len; - if (!wc->header_filename) { - av_log(s, AV_LOG_ERROR, "No header filename provided\n"); - return AVERROR(EINVAL); - } - len = av_strlcpy(filename, wc->header_filename, MAX_FILENAME_SIZE); - if (len >= MAX_FILENAME_SIZE) { - av_log(s, AV_LOG_ERROR, "Header filename too long\n"); - return AVERROR(EINVAL); - } - } else { if (av_get_frame_filename(filename, MAX_FILENAME_SIZE, s->url, wc->chunk_index - 1) < 0) { av_log(s, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url); return AVERROR(EINVAL); } - } return 0; } @@ -153,8 +148,6 @@ static int webm_chunk_write_header(AVFormatContext *s) AVFormatContext *oc = NULL; int ret; AVDictionary *options = NULL; - char oc_filename[MAX_FILENAME_SIZE]; - char *oc_url; // DASH Streams can only have either one track per file. if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; } @@ -166,13 +159,6 @@ static int webm_chunk_write_header(AVFormatContext *s) if (ret < 0) return ret; oc = wc->avf; - ret = get_chunk_filename(s, 1, oc_filename); - if (ret < 0) - return ret; - oc_url = av_strdup(oc_filename); - if (!oc_url) - return AVERROR(ENOMEM); - ff_format_set_url(oc, oc_url); if (wc->http_method) av_dict_set(&options, "method", wc->http_method, 0); ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &options); @@ -220,7 +206,7 @@ static int chunk_end(AVFormatContext *s, int flush) av_write_frame(oc, NULL); buffer_size = avio_close_dyn_buf(oc->pb, &buffer); oc->pb = NULL; - ret = get_chunk_filename(s, 0, filename); + ret = get_chunk_filename(s, filename); if (ret < 0) goto fail; if (wc->http_method) From patchwork Mon Mar 2 04:44:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18003 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 6A950449CCD for ; Mon, 2 Mar 2020 06:45:14 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 55B3068B4D5; Mon, 2 Mar 2020 06:45:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 09EE968B499 for ; Mon, 2 Mar 2020 06:45:04 +0200 (EET) Received: by mail-wr1-f67.google.com with SMTP id y17so10786949wrn.6 for ; Sun, 01 Mar 2020 20:45:04 -0800 (PST) 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=0Usj7HyHAwb06t3fuiXvAfCoqj0OhwCwhNVu66/X4hY=; b=a+lfBM7vWMxNSvc5KE/wcMyP0vn3sgaKpJEzK8Gt4feOQaZ0qGJBS44cS61Z+hXm9Y JEQNsjWIJgIbOzlmzKlo74V/+aQFQFHXGs0FnVq1MzBEdU+u9AP2xHH53Awd+82eIzma vQBXnAw8nNYI3eAR/B6Dcm+QBGUDX5FdwGbU4K2Lbz4M3RU2jY8lztkSleD3eIU42+Ai VnZnNqZGd5Le7CX+HqQd0bzrpaghsBO3ZsUcIigFbj5VoK5N80DHF4Cby0z3OExp4I1l 4UPG9KQQ//ayyFowLO8s5rUMDVFI3PzkZu3YYR1KAmrrVoopWyJ2JLOrM3r8zvv20whB htig== 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=0Usj7HyHAwb06t3fuiXvAfCoqj0OhwCwhNVu66/X4hY=; b=m4nyJEV7mA8e+JU9/fNOgY8B5QED2mLC+GEZst5Qdn8RSY7Pw07Vahf9fFmjizjOht f0jrGhkhsgEKY9tjtaeSrSxPj61nFKzLKLD0l68PFHOg50sC5rPNp/HirKYfPd4kO2Qx o7Kon3HFam+KOT1eDzKmqbNF1xIu4LeTjdf67RPfjxexWWqlNGHrseU7r/j1Iv8AnP9V Xi6Aypwx3Hj4sTB95O7og6xx1D3GTs0eIRZn1RDkYahPiwNpMfuZsxTeuPWPaIairdhd tHmBqs4Fe5DRL+kuo3cqa5K3199BnxkaliKnOb1eDDq+J9Zo4YA7A02341ov2rQuir8k L6kg== X-Gm-Message-State: APjAAAWdLVj1Bz1/OJc/nDw+rx5zRvBbRUU20zAi6k8dLu4vAk5SIipj G8ApHeNAZCyExO9LKnTr7dNvUmlP X-Google-Smtp-Source: APXvYqzGmBcQiSzYRDc/KU9EqM8PJtk1B4M6ARN4uTGJ9tTK7FvDAuohSup+f+RtRt+KIwLO2Gln9Q== X-Received: by 2002:adf:f745:: with SMTP id z5mr18302149wrp.54.1583124303355; Sun, 01 Mar 2020 20:45:03 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:45:02 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:41 +0100 Message-Id: <20200302044445.14842-9-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/17] avformat/webm_chunk: Remove unnecessary variable 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" chunk_start_index (which was set via an option) was only used to initialize chunk_index and otherwise unused. So initialize chunk_index directly via the option and remove chunk_start_index. Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index a4aab04a44..8abfc2870b 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -46,7 +46,6 @@ typedef struct WebMChunkContext { const AVClass *class; - int chunk_start_index; char *header_filename; int chunk_duration; int chunk_index; @@ -152,7 +151,6 @@ static int webm_chunk_write_header(AVFormatContext *s) // DASH Streams can only have either one track per file. if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; } - wc->chunk_index = wc->chunk_start_index; wc->prev_pts = AV_NOPTS_VALUE; ret = chunk_mux_init(s); @@ -274,7 +272,7 @@ fail: #define OFFSET(x) offsetof(WebMChunkContext, x) static const AVOption options[] = { - { "chunk_start_index", "start index of the chunk", OFFSET(chunk_start_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, + { "chunk_start_index", "start index of the chunk", OFFSET(chunk_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "audio_chunk_duration", "duration of each chunk in milliseconds", OFFSET(chunk_duration), AV_OPT_TYPE_INT, {.i64 = 5000}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "method", "set the HTTP method", OFFSET(http_method), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, From patchwork Mon Mar 2 04:44:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18004 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 182D6449CCD for ; Mon, 2 Mar 2020 06:45:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 081F368B4DF; Mon, 2 Mar 2020 06:45:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D834D68B485 for ; Mon, 2 Mar 2020 06:45:04 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id j16so10804282wrt.3 for ; Sun, 01 Mar 2020 20:45:04 -0800 (PST) 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=thJChplhtayHP2JCZn7sE3slIzrxVZ0Fo1vOHFm+GRc=; b=qneu9wkU24TfIr2hZ9+quhDer/GGfCDlEKBTS3/ooI50RBbhLCrJP4xEYDnxRPz8C+ IYQLUZ3z1Oobcu4XCCtxD/ye56nRfifjWmRjVOwoDxhaNOfbBuYOmZxUYC7XvceVpgH2 N5Mv30vKKmabDbm3ZS4k2rtF7/JK7tDjc+Was+OPGZdA45vjOXgju0VNuAPVErQ7zyS3 quiN6RZQ+6AtZykTt3MbEX4Sb+NQ+RxrWnrgysmH0y6Ywplnmr/E0sZ6kfnCPB7kJ8H+ pv7wZcTnabmWOEJEHpDcXmluUBg0jvcdtN0vXVyko2Y2xSqvJ+O0J2a8EUdwKkcpCAX2 gkrg== 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=thJChplhtayHP2JCZn7sE3slIzrxVZ0Fo1vOHFm+GRc=; b=Fg0inGYbBMw24U3TRNKDXOGE7wh2m1C+Nwo24JxNykmNzPad6AvuJ7PZfFtnBUlAEq pSc/wjHH18OlJ9hPwMaJlkPJnoNNdw81RC+ypIHEgXHzc80IGQImJleuzaudn1XW+tSS Xb3WBERAJMyuxikWyrbOqqkw2JM+AhRHdiJr4Hq7sQHoAbvJkrbEI1sVA5LaR1TbFSnZ uuKf+heqpAAD8IlpGnWN24UCSHZiLszUEcgdZp6q8rvb2g08JlBfZ548oSbFkM0ZzMJi tdhTWm5fPxBXAWAkGo9D4r63t1/pR0j/e3A6DCHafULb4zPIkvWsAsSaXMl/n4Pn1dFV ecuw== X-Gm-Message-State: APjAAAWycBM3dqJh9D7AY7SZAbJ5C5VDnj23NEYE0al2pom+b8Z0mRu3 ENm2bU2FgtRKgjn0RWRfHdFmWdYY X-Google-Smtp-Source: APXvYqw4O4DL2p5mB8F+ogjZXh7jDLBu6cYI2wPPwZmspt1swVWF0HtfP6HOJdPLSvBbOSREdrTJzw== X-Received: by 2002:adf:ed04:: with SMTP id a4mr19417789wro.76.1583124304218; Sun, 01 Mar 2020 20:45:04 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:45:03 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:42 +0100 Message-Id: <20200302044445.14842-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/17] avformat/webm_chunk: Add init function 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" Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 8abfc2870b..efdce62391 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -55,7 +55,7 @@ typedef struct WebMChunkContext { AVFormatContext *avf; } WebMChunkContext; -static int chunk_mux_init(AVFormatContext *s) +static int webm_chunk_init(AVFormatContext *s) { WebMChunkContext *wc = s->priv_data; const AVOutputFormat *oformat; @@ -64,11 +64,17 @@ static int chunk_mux_init(AVFormatContext *s) AVDictionary *dict = NULL; int ret; + // DASH Streams can only have one track per file. + if (s->nb_streams != 1) + return AVERROR(EINVAL); + if (!wc->header_filename) { av_log(s, AV_LOG_ERROR, "No header filename provided\n"); return AVERROR(EINVAL); } + wc->prev_pts = AV_NOPTS_VALUE; + oformat = av_guess_format("webm", s->url, "video/webm"); if (!oformat) return AVERROR_MUXER_NOT_FOUND; @@ -144,19 +150,10 @@ static int get_chunk_filename(AVFormatContext *s, char filename[MAX_FILENAME_SIZ static int webm_chunk_write_header(AVFormatContext *s) { WebMChunkContext *wc = s->priv_data; - AVFormatContext *oc = NULL; + AVFormatContext *oc = wc->avf; int ret; AVDictionary *options = NULL; - // DASH Streams can only have either one track per file. - if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; } - - wc->prev_pts = AV_NOPTS_VALUE; - - ret = chunk_mux_init(s); - if (ret < 0) - return ret; - oc = wc->avf; if (wc->http_method) av_dict_set(&options, "method", wc->http_method, 0); ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &options); @@ -295,6 +292,7 @@ AVOutputFormat ff_webm_chunk_muxer = { .flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER | AVFMT_NEEDNUMBER | AVFMT_TS_NONSTRICT, .priv_data_size = sizeof(WebMChunkContext), + .init = webm_chunk_init, .write_header = webm_chunk_write_header, .write_packet = webm_chunk_write_packet, .write_trailer = webm_chunk_write_trailer, From patchwork Mon Mar 2 04:44:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17997 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 1EDC8449CCD for ; Mon, 2 Mar 2020 06:45:09 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F0F0A68B472; Mon, 2 Mar 2020 06:45:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AEB0C68B0C7 for ; Mon, 2 Mar 2020 06:45:05 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id y17so10787006wrn.6 for ; Sun, 01 Mar 2020 20:45:05 -0800 (PST) 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=q8LzofkQDxqDeTTPCBDRgHhjNrBTxLp0/9UoR2JH0hM=; b=Pz0PaWhXFMJgwrw+UhCqPAmjRRJAzHUC8sY6sS7WF2P6e6XFWQFgcYYPR5wECOwk3r Ueigoy4N/FvB809ugowzk3oTmZ5ZylK7tt3jNE9EvgZDmoHdQ0AaAOv4IQNXBT7431nu oQe9zIOm/Xl1Pwx21M4hTnD4bwM9kJvoYQm+yH8X62PRmlWxgmypwNCjY/SBAF5hH9EA cFmjda4qV427pruTaXHD0lFyuFPP9Y1U25ihw1ZmpYBhO6E308hy/stivqZW/xVCKYK6 3Dnfeyl8Tx+OSwOl58iMZn/CHdQINI37prGg32mb0TilFQ87+C2uY4UER/Y+WaaRxbq9 9diw== 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=q8LzofkQDxqDeTTPCBDRgHhjNrBTxLp0/9UoR2JH0hM=; b=WusPS42jaw2NTLtuDAVqM45RBSsnbIU4PuUfUTVlzRppDgj8EtTb8U6icK9Yp5n0zO hT5X1R5SUOI78GFJNVJRyiiRIzl9K5DMTGfzbG2N0CZrM2IPtVsWpxmbLuVve2DDWj8T cjb319PFoey4yIk68yTxxh2CK0fQ39eCLPJEVzrALeT0bNT1yRDf+TVqWpjohKoanQwF vxcvizaC2VmknRN2/Y8wSBJtepkJvuJwPPuVKA6GB4zfyQt67XIn3JV6HzPfkh5I7R1D mQhTesJxTH5zKXYoOnlMLBKOBCLCefkeR1O5qV53Ffxr1OiKy5hS3rS/WcOfoQ4xzVuk kUGQ== X-Gm-Message-State: APjAAAULGpVfCNCg6r0/RFytB6S2MbyaDeKIqX7H35DKa7PdYGxhrbv/ 6o53EQsYu/hG5upLPIiocT8BTyW3 X-Google-Smtp-Source: APXvYqwzyu+c93pSfTz/ofP8HlWTvaEMoFF7/Lvwps5/zaPgj79gJBr+d9Tpx7RwRPqCi3KgrMHhkw== X-Received: by 2002:adf:e910:: with SMTP id f16mr19606033wrm.20.1583124305001; Sun, 01 Mar 2020 20:45:05 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:45:04 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:43 +0100 Message-Id: <20200302044445.14842-11-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/17] avformat/webm_chunk: Add deinit function 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" This fixes memleaks if an error happens after one of the allocations in init; or if the trailer isn't written (e.g. because there was an error when writing a packet). Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index efdce62391..6ffe952eff 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -258,13 +258,22 @@ static int webm_chunk_write_trailer(AVFormatContext *s) if (!oc->pb) { ret = chunk_start(s); if (ret < 0) - goto fail; + return ret; } av_write_trailer(oc); - ret = chunk_end(s, 0); -fail: - avformat_free_context(oc); - return ret; + return chunk_end(s, 0); +} + +static void webm_chunk_deinit(AVFormatContext *s) +{ + WebMChunkContext *wc = s->priv_data; + + if (!wc->avf) + return; + + ffio_free_dyn_buf(&wc->avf->pb); + avformat_free_context(wc->avf); + wc->avf = NULL; } #define OFFSET(x) offsetof(WebMChunkContext, x) @@ -296,6 +305,7 @@ AVOutputFormat ff_webm_chunk_muxer = { .write_header = webm_chunk_write_header, .write_packet = webm_chunk_write_packet, .write_trailer = webm_chunk_write_trailer, + .deinit = webm_chunk_deinit, .priv_class = &webm_chunk_class, }; #endif From patchwork Mon Mar 2 04:44:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17999 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 AD59B449CCD for ; Mon, 2 Mar 2020 06:45:10 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A08B268B4BA; Mon, 2 Mar 2020 06:45:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B763068B396 for ; Mon, 2 Mar 2020 06:45:06 +0200 (EET) Received: by mail-wr1-f50.google.com with SMTP id e10so9326332wrr.10 for ; Sun, 01 Mar 2020 20:45:06 -0800 (PST) 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=QxXgAxgFJYFkdbu0qZIbKzRByF/0swANtfwhA43KkJU=; b=qrFvAPfr1N6goMLn4g7eNhZrhH9jEa63UZsp1O5WbiC69AebxSGwrJ594LB3NebSGl iNaxlOafv0qNuFJcalWohJA/JjK1zqFx0N6UJmzN8KUX09WcYSxUz6fAOGMjdfAvdT9W U+nBOSzcrFXAbzo3J5Ie6KHRywjGYZoa3TC9ASJE3oCCoveRrESYsrUQgjKJY29O9loc d4QnjsVeHhGbwOtxYk57OiBeI0mwjGkwEi7cSWWvBNwy9jt0fS5w0pfOTpjCw+rjNzAS Cq7c/D6GlmmmySoE7VQkVb3MuIdbr22isjaC0xYqrcvQfhMtxS3+9jCyoBVDq2x5IKYu nXXA== 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=QxXgAxgFJYFkdbu0qZIbKzRByF/0swANtfwhA43KkJU=; b=XSyAUWKUpx+DA529EqRblWHNQerpCzCu1vTgWmRSwAgfLRrl7H5dqotU936UN5ziXF HCjz3nQBqymPCeVGRDWENR8s0OyJSDy7RrqIQ0dIKmtAYCXVfcvE9D6RCV5qx/npkYQk wv/tEmv9ubAwhfpB4EE5rrFf31798Ih5XBGwRHAn5dixPcZxHNpnm1fxlqeZK+JvQVIF msfHJdGE5OMsHHO6Gzd6rW70rKPmruZQ8OGffg3VovWFwi5GpOfiLRa80jnm3IbvHba7 OwrQEIQhdVr6dGLIGEPRTaOLCDr6RGPKsqL1Jqncnld6DlTpnMKIhIjWDJnkZkKzCR2I ieeg== X-Gm-Message-State: APjAAAXwoDexPo35N5mUoYAlCK+wjLDxngSlarhhscVSNzDwOZVbv2b7 Av8g0Iz+IqwHg4YkuXxwCXNoN5tQ X-Google-Smtp-Source: APXvYqw/xPSq42e3tFLetSbPz0HrIXOtT4t1k62WwHjFDVye4PrlawChFAsqTJIPTXmmzgS+a6vujQ== X-Received: by 2002:adf:c445:: with SMTP id a5mr19731241wrg.14.1583124305801; Sun, 01 Mar 2020 20:45:05 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:45:05 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:44 +0100 Message-Id: <20200302044445.14842-12-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/17] avformat/webm_chunk: Check unchecked functions for errors 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" Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 6ffe952eff..8f1f884c98 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -95,7 +95,8 @@ static int webm_chunk_init(AVFormatContext *s) oc->flush_packets = 0; - av_dict_copy(&oc->metadata, s->metadata, 0); + if ((ret = av_dict_copy(&oc->metadata, s->metadata, 0)) < 0) + return ret; if (!(st = avformat_new_stream(oc, NULL))) return AVERROR(ENOMEM); @@ -109,11 +110,14 @@ static int webm_chunk_init(AVFormatContext *s) avpriv_set_pts_info(st, ost->pts_wrap_bits, ost->time_base.num, ost->time_base.den); - av_dict_set_int(&dict, "dash", 1, 0); - av_dict_set_int(&dict, "cluster_time_limit", wc->chunk_duration, 0); - av_dict_set_int(&dict, "live", 1, 0); + if ((ret = av_dict_set_int(&dict, "dash", 1, 0)) < 0 || + (ret = av_dict_set_int(&dict, "cluster_time_limit", + wc->chunk_duration, 0)) < 0 || + (ret = av_dict_set_int(&dict, "live", 1, 0)) < 0) + goto fail; ret = avformat_init_output(oc, &dict); +fail: av_dict_free(&dict); if (ret < 0) return ret; @@ -155,7 +159,8 @@ static int webm_chunk_write_header(AVFormatContext *s) AVDictionary *options = NULL; if (wc->http_method) - av_dict_set(&options, "method", wc->http_method, 0); + if ((ret = av_dict_set(&options, "method", wc->http_method, 0)) < 0) + return ret; ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &options); av_dict_free(&options); if (ret < 0) @@ -205,14 +210,15 @@ static int chunk_end(AVFormatContext *s, int flush) if (ret < 0) goto fail; if (wc->http_method) - av_dict_set(&options, "method", wc->http_method, 0); + if ((ret = av_dict_set(&options, "method", wc->http_method, 0)) < 0) + goto fail; ret = s->io_open(s, &pb, filename, AVIO_FLAG_WRITE, &options); + av_dict_free(&options); if (ret < 0) goto fail; avio_write(pb, buffer, buffer_size); ff_format_io_close(s, &pb); fail: - av_dict_free(&options); av_free(buffer); return (ret < 0) ? ret : 0; } @@ -260,7 +266,9 @@ static int webm_chunk_write_trailer(AVFormatContext *s) if (ret < 0) return ret; } - av_write_trailer(oc); + ret = av_write_trailer(oc); + if (ret < 0) + return ret; return chunk_end(s, 0); } From patchwork Mon Mar 2 04:44:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18001 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 43187449CCD for ; Mon, 2 Mar 2020 06:45:12 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3116A68B082; Mon, 2 Mar 2020 06:45:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7A35D68B255 for ; Mon, 2 Mar 2020 06:45:07 +0200 (EET) Received: by mail-wm1-f67.google.com with SMTP id m3so9356866wmi.0 for ; Sun, 01 Mar 2020 20:45:07 -0800 (PST) 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=uTN4XHd1fB/qRlxSwjWCkg1832o2UxTTO3RHpXIeuyA=; b=XWBXSfEguQsnB5Q7/15dWyiOOqapDGLsQRzvgQR1v++gAN+9ats0M3jvnCA6ldnb1F 525TrOPvo4iCwnAYGLq5yQ0RXTgjBQ1N97tNX/o3xK9H6xnPLizPZb4CeLOIaZLlhO8w +LV84OyUUnemY5H9tOBUsAQEyWZtVQvPbdTRxmG+ncYXPbIwQvNT3VIz+xB7GjCWv5PB c3jjXyYAnKuEOIc3EClMadM1NdAMIoxTLM071oISzU2YLf7hNcywFOhmcDxydEL/ZLji evbcibMfBaj+/ljKI3P5FfDjQfmxHuJsitruMwIoV5I9jJjcEXqBkxpqJdZ+XJus/E1g psZw== 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=uTN4XHd1fB/qRlxSwjWCkg1832o2UxTTO3RHpXIeuyA=; b=YjAHovBMlGn5xVqVk/F+0acRBU+/7CFhq6JByOtjl/wnNZWxb2fbgmK2PtOOZaoANd Uzv/u0F8fM2isRaFm0+d6vWEttbACyjlkIFRc2w3XKECdjKIknMqBim3fzfzX9+C72yP zg8x4qQ1VqwqTOqMxdx2RL4cqMIKw/SzSZxDF8rn3rZKE1/o8E8b6LkKmZINj6cVk5Kb wsCnCm9SabvCNAVmMMLD9CisRIVHxYyt9QmeGnGjXAfT0brHKVOLYb0x6YpKzUfuo1ms 1bDj/U7dsco4qE8BZ2EUOBx8GSRTQZyMSB/UUmZ0gHr7vSxB3wWTe3NvPx1lyoXNwpKH Ve1g== X-Gm-Message-State: APjAAAWl8beYpO0qELnpSNkg/bElWMCTMeYttzoLFmjCi3TcgRvqcxsR TTmJ8TurCxLySTJcLl5yHd9EKKr8 X-Google-Smtp-Source: APXvYqzikqsSHlgt2eFfpO/B9PSMAJ5UC9ivdeMovJrPFPnnD3MwtUeTsR01JZV8+3Ofdxy20u0Gig== X-Received: by 2002:a05:600c:2207:: with SMTP id z7mr17531254wml.138.1583124306672; Sun, 01 Mar 2020 20:45:06 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:45:06 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:45 +0100 Message-Id: <20200302044445.14842-13-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/17] avformat/webm_chunk: Cosmetics 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" Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 8f1f884c98..d173a4a5ce 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -87,8 +87,8 @@ static int webm_chunk_init(AVFormatContext *s) ff_format_set_url(oc, wc->header_filename); wc->header_filename = NULL; - oc->interrupt_callback = s->interrupt_callback; - oc->max_delay = s->max_delay; + oc->interrupt_callback = s->interrupt_callback; + oc->max_delay = s->max_delay; oc->flags = s->flags & ~AVFMT_FLAG_FLUSH_PACKETS; oc->strict_std_compliance = s->strict_std_compliance; oc->avoid_negative_ts = s->avoid_negative_ts; @@ -143,11 +143,11 @@ static int get_chunk_filename(AVFormatContext *s, char filename[MAX_FILENAME_SIZ if (!filename) { return AVERROR(EINVAL); } - if (av_get_frame_filename(filename, MAX_FILENAME_SIZE, - s->url, wc->chunk_index - 1) < 0) { - av_log(s, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url); - return AVERROR(EINVAL); - } + if (av_get_frame_filename(filename, MAX_FILENAME_SIZE, + s->url, wc->chunk_index - 1) < 0) { + av_log(s, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url); + return AVERROR(EINVAL); + } return 0; }