From patchwork Thu Apr 12 08:48:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 8418 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp1646393jad; Thu, 12 Apr 2018 01:49:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/i0A9dqB9HhPT+S7AMnaIpedqqUh1zoMcHRtwNiQctHfCGTUtziNe5h3Hv7AlGbmDw7oQC X-Received: by 10.223.189.14 with SMTP id j14mr61498wrh.138.1523522966140; Thu, 12 Apr 2018 01:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523522966; cv=none; d=google.com; s=arc-20160816; b=T76vHwCLK7LILz2NETz73PbUw+Dfhsuz60BFqKnvd5KylkSf1hjkEA3h/qyGMT4q+Q aLm5/Y4xxVyUBI5Wks/feYXWKzNsZ2reJSt3Q2i96U4MWU0hklPKUFuhv2nXzgBI3mt3 nBWyGPsXeAxGDaPWXZuQxn9DJ4dOqNSHqEXyXYsF2qurdZYUixDKIVvV6F9bAc2UNp28 5i2WwdXgsshxk5TX21EwJj2NZ4axFq81dDTZUdswM6K75eZejEnyTeO/rDLpIt45TT94 W8ArEcRTayAtNlbJko3C9cke2G5zGBH+OetI2B8gFiagvSJSANqD0H83Sy8RKshbtTx2 S06A== 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:feedback-id:message-id:date:to:from :delivered-to:arc-authentication-results; bh=/TYRz2pNiJ57m9dgLMGfQDF12/n7HVRyuttVci76fMY=; b=YVrRDuIl9sQBzYtUKbomdKa6WZ+pIj4ahbwQLDJA/2XYywxPwbXHy4xlLsWHaEse35 jLSBl2FV9nPGXcfdnvxntPqGz1BAGHSzH9YtGvvLtaz8d7hqTTfO1PS33jdUv5ns5lrd QIw5mWa4uQiZRs3WIxHcvoWhtZd0IkZtr5iXVtvq7P6Gw6UV0PhUkFuuFrMPDTX/34eK njCkJjhvwZGKBk6At1UhIXOOqTrhnPgxIXuiypMCN8zT/PvB/2luJD2eP4hKL+LCfUG2 ZmMeGTLedCJnTQR5y22XoDBQS4xYpUXQwVdvHXk/wC+1PAlw2fDHoQiW4DjAy58XHTyl Vq4A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 42si2182772wrk.441.2018.04.12.01.49.25; Thu, 12 Apr 2018 01:49:26 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D78BB68A346; Thu, 12 Apr 2018 11:48:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbg352.qq.com (SMTPBG352.QQ.COM [183.57.50.167]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1D87468A2BE for ; Thu, 12 Apr 2018 11:48:51 +0300 (EEST) X-QQ-mid: bizesmtp10t1523522920t7ak13fm Received: from localhost (unknown [47.90.47.25]) by esmtp10.qq.com (ESMTP) with id ; Thu, 12 Apr 2018 16:48:39 +0800 (CST) X-QQ-SSF: 01100000002000F0FKF0000A0000000 X-QQ-FEAT: 5t7Y1p3pIzFStiwYTtnYqcDhBwb9QEGKVMiFISUo8ZTHUzdR+D0H+SBvFnr94 CoioAHmG5Efb0SSai/Suw8Cp+iUX7Tb9Vzko1k+TCRfCGcJDP0J1N56qIAXFUYCtgEkA/qc zZHpmRj34O+7FjVBxOTs4JLAh+DDAI0Hfs2ixiCaxFwZhxwf1IGtizTGQPlOoYhpl+Ytqz+ PrQYLlEqlMfpu8ZGaHtaMIHazGzuNTsfwpoDU6uUNNaRo4YyZb2awjn7pyxkAvEcXTxsc/B FAemiPqVo1ZZsou3QqZYrARqrqh81e3eMjRw== X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 12 Apr 2018 16:48:35 +0800 Message-Id: <20180412084835.26565-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1.382.ga23ca1b.dirty X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign4 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/hls: remove redundant code 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: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Steven Liu --- libavformat/hls.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index ae0545a086..74f0c2ccc5 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -945,14 +945,8 @@ static struct segment *next_segment(struct playlist *pls) return pls->segments[n]; } -enum ReadFromURLMode { - READ_NORMAL, - READ_COMPLETE, -}; - static int read_from_url(struct playlist *pls, struct segment *seg, - uint8_t *buf, int buf_size, - enum ReadFromURLMode mode) + uint8_t *buf, int buf_size) { int ret; @@ -960,12 +954,9 @@ static int read_from_url(struct playlist *pls, struct segment *seg, if (seg->size >= 0) buf_size = FFMIN(buf_size, seg->size - pls->cur_seg_offset); - if (mode == READ_COMPLETE) { - ret = avio_read(pls->input, buf, buf_size); - if (ret != buf_size) - av_log(NULL, AV_LOG_ERROR, "Could not read complete segment.\n"); - } else - ret = avio_read(pls->input, buf, buf_size); + ret = avio_read(pls->input, buf, buf_size); + if (ret != buf_size) + av_log(NULL, AV_LOG_ERROR, "Could not read complete segment.\n"); if (ret > 0) pls->cur_seg_offset += ret; @@ -1085,7 +1076,7 @@ static void intercept_id3(struct playlist *pls, uint8_t *buf, while (1) { /* see if we can retrieve enough data for ID3 header */ if (*len < ID3v2_HEADER_SIZE && buf_size >= ID3v2_HEADER_SIZE) { - bytes = read_from_url(pls, seg, buf + *len, ID3v2_HEADER_SIZE - *len, READ_COMPLETE); + bytes = read_from_url(pls, seg, buf + *len, ID3v2_HEADER_SIZE - *len); if (bytes > 0) { if (bytes == ID3v2_HEADER_SIZE - *len) @@ -1137,7 +1128,7 @@ static void intercept_id3(struct playlist *pls, uint8_t *buf, if (remaining > 0) { /* read the rest of the tag in */ - if (read_from_url(pls, seg, pls->id3_buf + id3_buf_pos, remaining, READ_COMPLETE) != remaining) + if (read_from_url(pls, seg, pls->id3_buf + id3_buf_pos, remaining) != remaining) break; id3_buf_pos += remaining; av_log(pls->ctx, AV_LOG_DEBUG, "Stripped additional %d HLS ID3 bytes\n", remaining); @@ -1151,7 +1142,7 @@ static void intercept_id3(struct playlist *pls, uint8_t *buf, /* re-fill buffer for the caller unless EOF */ if (*len >= 0 && (fill_buf || *len == 0)) { - bytes = read_from_url(pls, seg, buf + *len, buf_size - *len, READ_NORMAL); + bytes = read_from_url(pls, seg, buf + *len, buf_size - *len); /* ignore error if we already had some data */ if (bytes >= 0) @@ -1311,7 +1302,7 @@ static int update_init_section(struct playlist *pls, struct segment *seg) av_fast_malloc(&pls->init_sec_buf, &pls->init_sec_buf_size, sec_size); ret = read_from_url(pls, seg->init_section, pls->init_sec_buf, - pls->init_sec_buf_size, READ_COMPLETE); + pls->init_sec_buf_size); ff_format_io_close(pls->parent, &pls->input); if (ret < 0) @@ -1506,7 +1497,7 @@ reload: } seg = current_segment(v); - ret = read_from_url(v, seg, buf, buf_size, READ_NORMAL); + ret = read_from_url(v, seg, buf, buf_size); if (ret > 0) { if (just_opened && v->is_id3_timestamped != 0) { /* Intercept ID3 tags here, elementary audio streams are required