From patchwork Fri Apr 21 15:40:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 3459 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp359131vsd; Fri, 21 Apr 2017 08:41:18 -0700 (PDT) X-Received: by 10.28.150.213 with SMTP id y204mr8397807wmd.138.1492789278003; Fri, 21 Apr 2017 08:41:18 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 10si15067414wrv.17.2017.04.21.08.41.17; Fri, 21 Apr 2017 08:41:17 -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; 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 EDC266898CA; Fri, 21 Apr 2017 18:41:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 57B38688380 for ; Fri, 21 Apr 2017 18:40:58 +0300 (EEST) Received: by mail-wm0-f68.google.com with SMTP id o81so5573720wmb.0 for ; Fri, 21 Apr 2017 08:41:07 -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=M7P1ee3+b4FkUddizjLsni5IS3ckpWI6lvTk5WF+T9A=; b=vgtcyw5DV9XbLzZxxKe/On/IVoCZeslb8CwBkQq1fqdO5O0ObZpX77NE+50VwY/srK uNl6YponjFNsLIkXi5IhMVQ8cB6Fu7AbTkn8rmEG6DEpDwFOegQ1vNR66ygJlTtQhJZE h45FPKyBPNhR5A/gxpmx0d9FGfvrPaBlPGH5zFKiU97bKZGlelRx8f6b0tmArebAcS02 7iaD3JkP7kOXwOfOufMZCVvwVJZPp1OPipk2JZx14nTkPoavJxvRlyqGib6deX73LUWS ahhq1QA75JjAZej0+s4vUl29sPIGk1DCLn3hGwkKmEFZcF85RrfuDtTsomBB4iUcGV2G tB9w== 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=M7P1ee3+b4FkUddizjLsni5IS3ckpWI6lvTk5WF+T9A=; b=jWwdoa0vam/72cviFhwt+pl6VXVLr61OrjCm6O/SSQdDTpFjAe7vnEU0Mq1IJFzrKN Mns4Y2MvYwwniLKvjW4t3x4S2ESv+ilGlCCWBeRwNNIKJWspVtk8/deam76kev8wtyo9 yk88G5TWcHJpQnwz8YPsA3jMDg9hv10r0ACDKiCzJHHimyhUt/4M/Cxa6Ee7ct3PXl5J D3+j8sjrKDKxwB141qHkS8JmQeZpPVxivo4UP5i1MnJHhJmq0G61aBTcrP7RJP/QPQ3C q7vIgyD0ofj2Pp9vTCxMS9HV79Gk36mrSd91Ouv/6AiqqEMK/o30WEH3xCy7PA+UoR4L Wz/w== X-Gm-Message-State: AN3rC/46ugl6svls5J7lZKYIlNvcmnJ0FGa9TQ8tuOBpipfyVu78p4WM dyMu9giep7HOUw== X-Received: by 10.28.182.69 with SMTP id g66mr8875403wmf.112.1492789267416; Fri, 21 Apr 2017 08:41:07 -0700 (PDT) Received: from vimeo-vm.localdomain ([82.129.105.223]) by smtp.googlemail.com with ESMTPSA id a37sm12049991wra.17.2017.04.21.08.41.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2017 08:41:06 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 Apr 2017 16:40:35 +0100 Message-Id: <1492789235-55398-1-git-send-email-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH] webm_dash_manifest_demuxer: Fix initialization range for files with cues at the front 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: vigneshv@google.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The WebM DASH spec states: The Initialization Segment shall not contain Clusters or Cues. The Segment Index corresponds to the Cues. Previously, it included the cues if they were at the front. Signed-off-by: Derek Buitenhuis --- libavformat/matroskadec.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 9adca8d..b3f68d3 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3815,7 +3815,7 @@ static int64_t webm_dash_manifest_compute_bandwidth(AVFormatContext *s, int64_t return (int64_t)bandwidth; } -static int webm_dash_manifest_cues(AVFormatContext *s) +static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range) { MatroskaDemuxContext *matroska = s->priv_data; EbmlList *seekhead_list = &matroska->seekhead; @@ -3854,6 +3854,11 @@ static int webm_dash_manifest_cues(AVFormatContext *s) // cues end av_dict_set_int(&s->streams[0]->metadata, CUES_END, cues_end, 0); + // if the file has cues at the start, fix up the init range so tht + // it does not include it + if (cues_start <= init_range) + av_dict_set_int(&s->streams[0]->metadata, INITIALIZATION_RANGE, cues_start - 1, 0); + // bandwidth bandwidth = webm_dash_manifest_compute_bandwidth(s, cues_start); if (bandwidth < 0) return -1; @@ -3883,6 +3888,7 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) { char *buf; int ret = matroska_read_header(s); + int64_t init_range; MatroskaTrack *tracks; MatroskaDemuxContext *matroska = s->priv_data; if (ret) { @@ -3903,7 +3909,8 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) // initialization range // 5 is the offset of Cluster ID. - av_dict_set_int(&s->streams[0]->metadata, INITIALIZATION_RANGE, avio_tell(s->pb) - 5, 0); + init_range = avio_tell(s->pb) - 5; + av_dict_set_int(&s->streams[0]->metadata, INITIALIZATION_RANGE, init_range, 0); } // basename of the file @@ -3916,7 +3923,7 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) // parse the cues and populate Cue related fields if (!matroska->is_live) { - ret = webm_dash_manifest_cues(s); + ret = webm_dash_manifest_cues(s, init_range); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Error parsing Cues\n"); return ret;