From patchwork Sun Nov 21 23:25:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 31519 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp6086557iob; Sun, 21 Nov 2021 15:25:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJx73npHiIRdZq0LVZp4FvjVNTl5yC1GcNukVog87HysKz9L1rld3YjSmBeJv8hHB6QDEM5P X-Received: by 2002:a05:6402:8c9:: with SMTP id d9mr55974243edz.254.1637537140847; Sun, 21 Nov 2021 15:25:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637537140; cv=none; d=google.com; s=arc-20160816; b=yMMyQffd8jY/XYiMu0tbsGwNEVJmuny/8kTvLxKkCJMT9fgoXQZfRnFwa6NiqMzhZz hMH/qwmqfSZmtfJIRfFD8jwSTv5NqDwK+uM9N84LsyZmxNeYvLfahpfCCtaQfPcgZeAG DZv5rU8ljuql66CwFed9uMbVBS1b5hbQG6hZD0xGBGGUL/8+d9sp+fR+f2at9heWaoin 59qeyapmO8t0w21tU7BclpxC89pckh9tMrkk3ijm7cmHApA6ICTDlxv9A85QatprBmEr UbZGDUfHXMm+/Kn1f95tV3cV1LCNmBY9/QEwMN4urMo4BfA7S1dpJ2ZysKOLO83ZyYo8 /WAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=vcvkRZ4M4r4nb/c2XDThSTMSBCacfYqn6FWdOjxi5RM=; b=GZP4ZT/xWtVypfK4rb/CRlFkUoeV+g6WlY5+F1D9tEgVL3SgGv0yIOZhgR82yJfn1i Av4M6tRxO/0l2UtmblGaoifYPougsgPWnOxtRtHDNOrBJkM6+cXegjiV2lpIs7r8JFpY u3q0XuXveX44bLkwwlDD9EqqhP20vNFtNaRQtcTRyCy4r3XN/wQ4twBCpXfkGTl//Q85 HHkRZ64kxL0kFcWsx9CyXijkj+kQ0mkuPyRnl9Dxf273Te8yz78F7NNHU/sOcxukq5LP NUw2aTPofRstgoZt9qS88/svJUkAOJCtvgQr9yAoCm5oRF5XXsUMbVutcZJTfrjmKwWT OTEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=ewgm7WFS; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id qf15si22512151ejc.553.2021.11.21.15.25.40; Sun, 21 Nov 2021 15:25:40 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=ewgm7WFS; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 98F5B68A93E; Mon, 22 Nov 2021 01:25:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D3C7068A306 for ; Mon, 22 Nov 2021 01:25:28 +0200 (EET) Received: by mail-wr1-f49.google.com with SMTP id d5so29325688wrc.1 for ; Sun, 21 Nov 2021 15:25:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XX/tgw19oUX0wCIClHnWt6TB0UjXpxCCT/7GbZotPZg=; b=ewgm7WFS1t4TiyxruUarQRMWgAm7LdxgUSdns4yLph+LvhtUM/U8jMNSbHqn2tfAal IbahHtuLRN3J17CoXnyLUOK+qzA7onaQxmfrpPbMLgl/AtDS47egjHoQgGJVzsMSdbv8 gP/0IuIzAP8yP5bcMtnWcHGc/AQDsY+Mfa7UIpNMrXqtPG9ONjncM/Yj7I/o28X9O7Tt EXGDuFblKud1KRUPzdZv20ofrSPBC7cqAFL/CrYBZQRccSoyaQnEsb4/wcC58ms+Ks62 wX8oPlRxZmhk6xG7jpuFH3M5F4vr8unl4dp8MTNXGjdd3RXzolRIjrziU9oiUgISoD6B s4IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XX/tgw19oUX0wCIClHnWt6TB0UjXpxCCT/7GbZotPZg=; b=DnQ3KyfHZzq6Ab2J23rZlunNRdeeRx9mPyOyDP7DM9cDafrJBB8a/MFcst8EgibTfk LcWvkd7zhI9TreKT/tIax90oUII29WZcVyquGMUGmYjh5b6pExj4nhNGQ1ghMb3GQ43F I3J9Cwy0/PbGKNRcQWKdFtZmHLMtfuyuaABbVy2yRN+jcW7bA5n4ipDsquzMSosZQbAj ezc9tSO4ESBHlyd1MMixNPAo0xx39gll/EnSwDo4n84I/L9hRznBJdSQDpfiRcOHnmmV oaEIVeAS369rcbtw0J5504aIdH43tKxFUipmfkidrEprXJirnBNys5Nh1NQ/p6zPIVLR 4vvg== X-Gm-Message-State: AOAM5316SSe9WXbtVP8OaY7CSWjdfW/7Jkf9c53Q9MFWkeh+Yvo1CIFm +pI6N5sEQOKNBknG8vqKNCdvF+0Ng/8= X-Received: by 2002:a05:6000:1010:: with SMTP id a16mr31877940wrx.155.1637537127217; Sun, 21 Nov 2021 15:25:27 -0800 (PST) Received: from ePirats-MBP.fritz.box (84-112-75-55.cable.dynamic.surfer.at. [84.112.75.55]) by smtp.gmail.com with ESMTPSA id o4sm8904375wry.80.2021.11.21.15.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 15:25:26 -0800 (PST) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 00:25:16 +0100 Message-Id: <20211121232516.82986-1-epirat07@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat: do not use AVIO_FLAG_* with avio_alloc_context X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Marvin Scholz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Nmr9dkfiFPoO The documentation states that here 0 should be used for read-only and 1 for a writable buffer. AVIO_FLAG_WRITE however is 2, while it works due to the way the flag is handled internally, it is still wrong according to the documentation. Additionally it makes it seem as if the AVIO_FLAG_* values could be used here, which is actually not true, as when AVIO_FLAG_READ would be used here it would create a writable buffer as AVIO_FLAG_READ is defined as 1. --- libavformat/hdsenc.c | 2 +- libavformat/segment.c | 2 +- libavformat/smoothstreamingenc.c | 2 +- libavformat/tests/movenc.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c index e5353bac65..d8ec6a0b8e 100644 --- a/libavformat/hdsenc.c +++ b/libavformat/hdsenc.c @@ -370,7 +370,7 @@ static int hds_write_header(AVFormatContext *s) ctx->flags = s->flags; ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), - AVIO_FLAG_WRITE, os, + 1, os, NULL, hds_write, NULL); if (!ctx->pb) { return AVERROR(ENOMEM); diff --git a/libavformat/segment.c b/libavformat/segment.c index 2b024fd373..5482aa1868 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -569,7 +569,7 @@ static int open_null_ctx(AVIOContext **ctx) uint8_t *buf = av_malloc(buf_size); if (!buf) return AVERROR(ENOMEM); - *ctx = avio_alloc_context(buf, buf_size, AVIO_FLAG_WRITE, NULL, NULL, NULL, NULL); + *ctx = avio_alloc_context(buf, buf_size, 1, NULL, NULL, NULL, NULL); if (!*ctx) { av_free(buf); return AVERROR(ENOMEM); diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index 27b59c299c..6bede7c254 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -335,7 +335,7 @@ static int ism_write_header(AVFormatContext *s) st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; st->time_base = s->streams[i]->time_base; - ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), AVIO_FLAG_WRITE, os, NULL, ism_write, ism_seek); + ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), 1, os, NULL, ism_write, ism_seek); if (!ctx->pb) { return AVERROR(ENOMEM); } diff --git a/libavformat/tests/movenc.c b/libavformat/tests/movenc.c index 04155dde76..2af72f11c7 100644 --- a/libavformat/tests/movenc.c +++ b/libavformat/tests/movenc.c @@ -186,7 +186,7 @@ static void init_fps(int bf, int audio_preroll, int fps) ctx->oformat = av_guess_format(format, NULL, NULL); if (!ctx->oformat) exit(1); - ctx->pb = avio_alloc_context(iobuf, iobuf_size, AVIO_FLAG_WRITE, NULL, NULL, io_write, NULL); + ctx->pb = avio_alloc_context(iobuf, iobuf_size, 1, NULL, NULL, io_write, NULL); if (!ctx->pb) exit(1); ctx->pb->write_data_type = io_write_data_type;