From patchwork Fri Jun 4 06:28:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valerii Zapodovnikov X-Patchwork-Id: 28079 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp800882iof; Thu, 3 Jun 2021 23:28:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJyAnATKtoWHq3O/TA/dLauVOcEsPrWy8JOrvr52XL7maQq7hmi9R73jMeqlc22kY52LnY X-Received: by 2002:a05:6402:51ce:: with SMTP id r14mr3220956edd.138.1622788112960; Thu, 03 Jun 2021 23:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622788112; cv=none; d=google.com; s=arc-20160816; b=qVCXeKT9pBCZ5iX5szIYSRnp5BAyiIdc2Thg/koI+e/NJ/c1cjorppY7f4sgiSsE5K YSrUObYYbJSC3rZduzU34nI2NMUvM653kYl5i7o1Lf3gWmCW7AQXJK15tTAVjnthFejQ Zp8jZ1D7G1MLW3jqzEZLTEVy1XhJmE1K/tw4o8iew2954QhAsK9yMQJqQPA03wpJLPjf P3zZpNPQZZ7PxaJ3OBI/QvQtMaykLBbkXSleq/5s8x6rUJKG/3zfwLeYol8VRd091iZR IB9/6R4+XvPTRhafCY07q/ni8VFILnRi6M3Za1BP3SxnFPyVaazZm5hR4bSRbv2XYPNb Ju8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=HU+JOBXY3Ix404DXGantnJdF3XxdulfQJCUBJ9PqkDQ=; b=YXlSPoOO+8YgAcW9Q3SpmB+kv71JxmVr7sqLDZQ6h4CnFN+g3M5a7uYKnj19AnA2YF p5nucR5acWIVptanVF3o7plgf2e1FBAihck/gyoMqgRXPsU9BS+tTsJBE05ydtoRYCYl 6+LvKdOwAd1OC/QWb7EjWtjymoVBKq9qd30/DeAP0Lz8+KVFLaSmtrTPQFJN7Up66Co+ E7aeyD05Edfa4zCr4meTLXhOJGeZSfL+ryoIPqLOo50LnrTU9zRmNeK/RQkgGjxVTDXm gybZJ+A3o/Tvvvi1pbC1fN0gaCXCHG7nf/0ro3Y40djxw/kYiopCv+04RjGch4Gsq0v7 BYgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ES+6638H; 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 x16si2226308ejj.678.2021.06.03.23.28.32; Thu, 03 Jun 2021 23:28:32 -0700 (PDT) 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=20161025 header.b=ES+6638H; 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 7F83268A15F; Fri, 4 Jun 2021 09:28:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA45B689963 for ; Fri, 4 Jun 2021 09:28:21 +0300 (EEST) Received: by mail-lj1-f181.google.com with SMTP id f12so10203316ljp.2 for ; Thu, 03 Jun 2021 23:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VF12TbWgEf7/RRYvfp57bVNyUGt6eBfcnCZWxVT7xCY=; b=ES+6638H+A4pe70EckyOnfY1U8EFbIo8PnwI+DHdYyqrKU9GrbjthGnmSSkoIvPPLy 22+38+e9FCOXgJVjFmnVHZrPkLOdERnbOCGX86C0Hr7mU3Ee2nGFrh/XrnPhPE2kcV1S tGH1ZwqsRWnrXuBAVlbP/EiR1iRc+rP25aFwCBiX/IC8SjKXM0/VwofLedeR5HSj3c8L Q1bLAXqHkCGCIcEDKN3mX68+5UVmcSmNvKb7N5Jy/zDMlOp5/3dHYmosSY8xcLwDJb1R J4K2lm3vQTGkRxeW15uWzMnM52UnkqaOq7RT0H9uMNoupZwfCVU1EmByW6RS2cIqdcxW TI0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VF12TbWgEf7/RRYvfp57bVNyUGt6eBfcnCZWxVT7xCY=; b=NVbeIfffW9OiZoDzD+Qd3NLz7+X5DVaNn9bYo1/pmo1I1fJAMKevLMpRQVfvjZSUi0 9DyDzSvqvrlSAobWbzq6SI2xLSpjiyswD0ElVsRTLxfZlDwOBdwofg8h7c8vjonKyPBF 9rX1KL7P8HKJqXTZaQZidX1+YtdB+7jKTN11sjjQz8SSjTGRMcn5GtNNeU4bNnM3fp/x pNF0li4xAzKnM+XH18IgVyXioxkojnaH5jiAj3ABsLQ61wok0qLZSlPSWP/g7dtRcbDa BBQLy1GHX5HNzijwqj/Y7n70BFj3ySSCFTgAZCDaP4xa4EGpwtcVk3p9JJgWt3D56tcT EXBA== X-Gm-Message-State: AOAM531GHPMgCV7YJiLlhgCrvFJ2EvK5WSmjQOgOeZ9V/mRzaX+SzYFM eKSEXZAApaCnxiJhwDDf1oVsFCk2uSas+vtKQxY= X-Received: by 2002:a05:651c:514:: with SMTP id o20mr2324611ljp.201.1622788100054; Thu, 03 Jun 2021 23:28:20 -0700 (PDT) Received: from localhost ([2a00:1370:812d:8d4d:cf4d:6838:971e:b293]) by smtp.gmail.com with ESMTPSA id p6sm559194lfc.280.2021.06.03.23.28.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Jun 2021 23:28:19 -0700 (PDT) From: Valerii Zapodovnikov To: ffmpeg-devel@ffmpeg.org Date: Fri, 4 Jun 2021 09:28:18 +0300 Message-Id: <20210604062818.2099-1-val.zapod.vz@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avformat/avio: fixed AVSEEK_FORCE and documentation 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Og+tTxhWXOYE Always true expression: we would have returned on line 265, if whence were SEEK_END we would've already returned. Because of short circuiting force will never be checked. Was broken since 7a6fe01f99cb95797ba59134f44b6666b1a5e792. That is 11 years! Also fixed other commit that did confuse ORing / passing: 41ed7ab45fc693f7d7fc35664c0233f4c32d69bb. --- libavformat/avio.h | 4 ++-- libavformat/aviobuf.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 0b35409787..83e2a71b67 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -505,14 +505,14 @@ int avio_put_str16be(AVIOContext *s, const char *str); void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type); /** - * ORing this as the "whence" parameter to a seek function causes it to + * Passing this as the "whence" parameter to a seek function causes it to * return the filesize without seeking anywhere. Supporting this is optional. * If it is not supported then the seek function will return <0. */ #define AVSEEK_SIZE 0x10000 /** - * Passing this flag as the "whence" parameter to a seek function causes it to + * OR'ing this flag into the "whence" parameter to a seek function causes it to * seek by any means (like reopening and linear reading) or other normally unreasonable * means that can be extremely slow. * This may be ignored by the seek code. diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index ddfa4ecbf1..d748cda397 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -286,8 +286,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) } else if ((!(s->seekable & AVIO_SEEKABLE_NORMAL) || offset1 <= buffer_size + short_seek) && !s->write_flag && offset1 >= 0 && - (!s->direct || !s->seek) && - (whence != SEEK_END || force)) { + (!s->direct || !s->seek) || force) { while(s->pos < offset && !s->eof_reached) fill_buffer(s); if (s->eof_reached)