From patchwork Mon Jul 15 17:48:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13953 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 81FE644948E for ; Mon, 15 Jul 2019 20:49:12 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5C8EB68A898; Mon, 15 Jul 2019 20:49:12 +0300 (EEST) 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 D4A4768A56C for ; Mon, 15 Jul 2019 20:49:05 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id 31so18086235wrm.1 for ; Mon, 15 Jul 2019 10:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GppGPWcpbhz5IB8BRFdPvlFuNF4lhMqyBrGraxUKWHc=; b=oNFj88kqRlFh4AKSJeCNjhJ3hsjChbSopQ41zGQCIHIbQQXm6bTaJoBzdyRv4CtjUQ dLyyh44BW+rUfuiWvSEgJUDm73Xf4GR79kmN6pZ3guAom5sdHROxwu+JlQZ4JXA85l7Z hN6uhO7z0wHWQ3fTkCShonFw4JfsYhAMiO7HZrcAEQQ0nnC4Ah5gSh51j+wBsuCGqJFx km3MEGE8WsmIYL9iLp4Fzhsn7hBJfo633APlU2aeizwzkvszzDfd8bvWJdl3ONdOJmkX UuJhD6c0Xamp70A+0tyJ3WQIxiWE0yiI3AJOyrJjM3OJ5WUwWc2TYNVIcWqHOZ0NrJ4f Bj7w== 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=GppGPWcpbhz5IB8BRFdPvlFuNF4lhMqyBrGraxUKWHc=; b=Z4V7wlLF8Kd1WK/Hl4cqIqcsTpPa7jh+Exqi+OflfmcJJ0Iww1OdDd8so18+8hhlMW u8LiKbOJTb+uruPNii4zfE4CGsK2VqTEAZkC2Fq9m3u7EvE4P/XVNjzKi1sqFFCk3h6C qqbvY1vZKzvGpO55y+2eugBPhlR3W5LQIBSec6U+zZndtPrGCHqonSP26yLGsk9NZ5/c FPbylTpoeTalOdmSl2PRa/Pt71FjMJ7Gl0MeXuiRZAEMfMJkgttDGwwtgYDK0iHP5bKy WMynpUzHES06RYJ8uv/aZsNA3F6dvx08Ac2Q4dq+SwTbbw6X2ccVGLJNDHhn56b//7Ej Hx2A== X-Gm-Message-State: APjAAAVoGw+BqvAe/oLl3qu3LXl0fDmzWov10jMAKBUQo4Zisf5In0NO l5PcNwWauMhZ7rXH1hqcdKzx0THz X-Google-Smtp-Source: APXvYqzIiwh+C8RYjicpR7OTVkzN7GPpA9Pdw45YmnFnekbFMsVMb8mHuizCAAyASVE6zivw3kMEXg== X-Received: by 2002:a5d:564e:: with SMTP id j14mr29508218wrw.1.1563212945068; Mon, 15 Jul 2019 10:49:05 -0700 (PDT) Received: from localhost.localdomain (ipbcc08b8f.dynamic.kabel-deutschland.de. [188.192.139.143]) by smtp.gmail.com with ESMTPSA id g131sm12494266wmf.37.2019.07.15.10.49.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 10:49:04 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jul 2019 19:48:35 +0200 Message-Id: <20190715174835.46772-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190715170904.46574-1-andreas.rheinhardt@gmail.com> References: <20190715170904.46574-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavformat/subfile: Fix SEEK_CUR and SEEK_END seeking 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" Up until now, when performing a SEEK_END seek, the subfile protocol ignored the desired position (relative to EOF) and used the current absolute offset in the input file instead. And when performing a SEEK_CUR seek, the current position has been ignored. Signed-off-by: Andreas Rheinhardt --- Sorry for the noise of another email, but I just found out that SEEK_CUR is buggy as well. This probably hasn't been detected earlier because avio_seek translates SEEK_CUR to SEEK_SET internally. libavformat/subfile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/subfile.c b/libavformat/subfile.c index 2f162e0a34..5d8659c8c4 100644 --- a/libavformat/subfile.c +++ b/libavformat/subfile.c @@ -116,7 +116,7 @@ static int subfile_read(URLContext *h, unsigned char *buf, int size) static int64_t subfile_seek(URLContext *h, int64_t pos, int whence) { SubfileContext *c = h->priv_data; - int64_t new_pos = -1, end; + int64_t new_pos, end; int ret; if (whence == AVSEEK_SIZE || whence == SEEK_END) { @@ -132,10 +132,10 @@ static int64_t subfile_seek(URLContext *h, int64_t pos, int whence) new_pos = c->start + pos; break; case SEEK_CUR: - new_pos += pos; + new_pos = c->pos + pos; break; case SEEK_END: - new_pos = end + c->pos; + new_pos = end + pos; break; } if (new_pos < c->start)