From patchwork Sun Jun 18 19:14:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kucera X-Patchwork-Id: 4022 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp605022vsw; Sun, 18 Jun 2017 12:14:41 -0700 (PDT) X-Received: by 10.28.17.198 with SMTP id 189mr13737831wmr.6.1497813281290; Sun, 18 Jun 2017 12:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497813281; cv=none; d=google.com; s=arc-20160816; b=NoAPkA9E1Zc1an9brI6O5pqXmXaHh0y5+kEnxXvRBe/fajGBKsinHDWaBnWoWtOiu4 Sw7abt9A1r+s7uWdAvIlEZgo/kKzRFXw8Irk/tBrFh/306TFyAsxAwpN4fyQ9SUmrI0r u2yJ+hfSdjrSgvdfrb6ZzhbZDoxuq0xGSFB5TNL0I2fDQvZFQxc75PoyEOQwoqTPI0dI FXPAhlsAfpghDNjmmTTK0qn0onO6LqkRK8dycYp2dryCCerRWecekkbP6lyo1zzdsCzo 6oTHmetg67CsD8qKKQicx6jbwdU5H4xG/7HQbwb8uznvwnU7EF0SgszzWqHRCCFxWGiI 4mTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=wADkwtDHkRcoOBKB2p1pGyCvTf6W8Rb9PNscF1PIKWY=; b=KNFxK0i2s8w2mXnyrSWi7tftTKviiZLwEnmyOBTeYMdJPccIZQq5ZHTEh0F6fvYhbU IpG7zMOwUff1mWSyIr4uxK4bxgUBkbNIqdChC0E/HEqPMzxiIX4EPdMEbezjRgpC1mjl RaTSYtd2xG290xz5j86Ji46dKG2vCIMSvqOiFzinf26NgVeZzbwBlo91tlev401f+JDU 3AySW8ht/qdrS2+g8AI3tbmWmMiDV2ehnK8xO7c9HaLjhs2pBm78EkY7fz8C1czxpHpf xK5mohmDzvOg5tJPNFkLxMak0MIt44rnWfcjZylMzKOnpT64IHruSn0aHzG++HoPaD8E RPYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=tb4cHQxe; 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=NONE 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 h65si7823957wrh.371.2017.06.18.12.14.40; Sun, 18 Jun 2017 12:14:41 -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.b=tb4cHQxe; 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=NONE 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 9E7F468A20B; Sun, 18 Jun 2017 22:14:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2CD9168A1C4 for ; Sun, 18 Jun 2017 22:14:27 +0300 (EEST) Received: by mail-wr0-f193.google.com with SMTP id x23so11168432wrb.0 for ; Sun, 18 Jun 2017 12:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=dYGa38+W8ZPccMQ0XHhmI+M8R+2IE0w5aXXURfZA7vo=; b=tb4cHQxeiGIgTuFlE3v04V1vDgjcktrJlmPn1iZjkU8FGBsw0xGimJ1M7C9qMPqhX7 iCrFy9r6N0adba377mKbXaF6ox/FnzQLBXUmMVliBf6EgL5VA9fo0WH5BRqUxaX6QY/C GVSBu4YdArO8X6hycG8M64snF1kDdV/9uQNlQhXSFu7e/jfL3ZkROkp5CKkl/6rB45YR y014pQjr73+xjOgmeB03YaSdCe5qwBumDNHV/tWMU95RifdPrl1zxZ30AdLj7QvZNLJq +TwGyvnRLd3rjP31FbgwE0ew9m79E4IpyUaNvExie7rDKml7XLLmncbHCXUPjSNTYXnX 1n9Q== 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; bh=dYGa38+W8ZPccMQ0XHhmI+M8R+2IE0w5aXXURfZA7vo=; b=C0WxwHsRHwLLKJCDNP5bdusLqZJgFkEVARqPlRokQ0VzODAuRv9IC9ywqHjmLwkVES 9lADP8fEJRudlnOkD8kZsj+vPyS8EI5TA99TL7phHTIqwx7YV5RFoMsWD3ZzH9olv6ro EBPPk1UeYxQ5niwrst78Z/ZBw8IDDEsV2HLYQBijlZRrGnVGnMq/TEKmsbx67/j8G4NH UVUd74TzPXLwvYbvx8y+bOUCVxxAkBWZRT4bynbejoW0+pAm4AyH9SoFNrmDQSghRtu3 z5MxJl+Sj6SE0Pb0VJ1QgdTJ7u6xqLUHqG+fRvy7afwiHbgoWfd7kYyO8X0hz0Dy/37C YSdw== X-Gm-Message-State: AKS2vOx34ITT98i03VN8nzMR1xGNVzbZsjE7A585JCVP1G/pYLtyWiw8 zIAse5k+s908mxEt X-Received: by 10.223.172.231 with SMTP id o94mr13797662wrc.201.1497813271127; Sun, 18 Jun 2017 12:14:31 -0700 (PDT) Received: from speedy.danman.eu ([2a06:cc0::5054:ff:febb:3523]) by smtp.gmail.com with ESMTPSA id k12sm7753666wrc.10.2017.06.18.12.14.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Jun 2017 12:14:29 -0700 (PDT) From: Daniel Kucera To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2017 21:14:21 +0200 Message-Id: <20170618191421.14889-1-daniel.kucera@gmail.com> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] libavformat/aviobuf: don't treat 0 as EOF 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: Daniel Kucera MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Daniel Kucera --- libavformat/aviobuf.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 1667e9f08b..293a7d3753 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -556,13 +556,14 @@ static void fill_buffer(AVIOContext *s) if (s->read_packet) len = s->read_packet(s->opaque, dst, len); else - len = 0; - if (len <= 0) { + len = AVERROR_EOF; + if (len == AVERROR_EOF) { /* do not modify buffer if EOF reached so that a seek back can be done without rereading data */ s->eof_reached = 1; - if (len < 0) - s->error = len; + } else if (len < 0) { + s->eof_reached = 1; + s->error= len; } else { s->pos += len; s->buf_ptr = dst; @@ -630,13 +631,16 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) // bypass the buffer and read data directly into buf if(s->read_packet) len = s->read_packet(s->opaque, buf, size); - - if (len <= 0) { + else + len = AVERROR_EOF; + if (len == AVERROR_EOF) { /* do not modify buffer if EOF reached so that a seek back can be done without rereading data */ s->eof_reached = 1; - if(len<0) - s->error= len; + break; + } else if (len < 0) { + s->eof_reached = 1; + s->error= len; break; } else { s->pos += len;