From patchwork Wed Apr 18 19:29:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: misty@brew.sh X-Patchwork-Id: 8497 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.85 with SMTP id c82csp3455262jad; Wed, 18 Apr 2018 12:29:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/cSEcXJMFyzehM5s/P6WXxQlbRXxvg9ZlWvOWTtUQzoAWWPV+95o/1MvsslL6e5BaYYf/d X-Received: by 2002:adf:e210:: with SMTP id j16-v6mr1627915wri.118.1524079774213; Wed, 18 Apr 2018 12:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524079774; cv=none; d=google.com; s=arc-20160816; b=l9bp7rmoINN2V2g92SxRkkc3ZZGoF5GMc0aY+zZcjCHvAeQ5a+c+6tv5Zb/rMnZ9zA Lw+kt+bDCNQlgBQ2aJXeO52BjRCqj/WwGaduzOktc9veoxcTPH9wmB03bYLPC26YapS6 wFDyYkFO6g1tfaP0eyhxKFH2E3RNtaHeO6EZyR7AOmX04xDtw5pv7aZPQe7VVL9y/uHy taJgza+jXwW45JMQ1ns6nUemDIyWLpk7it36rKqVOgq0FdG5oyNKxvZj1v+Hu/Hh4ILX vIImb5ePLvqcF9l2srEMdcd5gJG+OIjpXc49kpsd3jMZnfN8QdY7XbxyE/aYFhhUI4kN 8Lpg== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=6jv5lTjeWmFoXd2UkjgpUMdAmusMW/uVXhB7Ddfq+yc=; b=B4X8pBDqHh3wIKv23kOF+03wZM16/lSeKtNN40uf/hb8gulIHCffXxs6A7wTsgJ+jU fZ0h2UW27K5BkKq/HrH95zZNTwhIEiUWNrryUW6Ndt20JeVUr3kktdyqs3N46EIkNayo /WhBRgyHXmrhHtxm+0KhOcAwD6wf11bbAbFOToEug+Vz/O9Nztkxb7q+jHZnt+lxqnP+ ark1d8o/5jMbIkMuXC1c2zmvL+VbRQrbNOSG6KOQRVXP44FFjskwRq/eWqlEW+CKIGNn mjVk9IdbPysUgCsDmLgxo8cOF1WGM9MVRFx7nLOI9uQnSknR8ILegIkGGgWtS2TYM0wi seLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=uKGqquP7; 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 y184si1573199wmg.61.2018.04.18.12.29.33; Wed, 18 Apr 2018 12:29:34 -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=uKGqquP7; 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 407C9689CD4; Wed, 18 Apr 2018 22:29:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl0-f68.google.com (mail-pl0-f68.google.com [209.85.160.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 24E846808D0 for ; Wed, 18 Apr 2018 22:28:58 +0300 (EEST) Received: by mail-pl0-f68.google.com with SMTP id m7-v6so1707864plt.3 for ; Wed, 18 Apr 2018 12:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=IGtn+8csEUHjI+PBoOoXno8NTaopFnVrPycHVBspLZA=; b=uKGqquP7oGkgEWxcznnrjFApwc/rkaCSLX/bRH1AsGjQnHCl8ADEFZWZ6i7pR9G24F tfhPII0M6OK0DffB87IbCrXT1btI2pgsI8BuupMyDImL0sAlkFlyUczS4VlrRDEBt6uu y0hrhg6ZMvdzMQ6QOtleI8V4hy1EY/gVvqKwhR7YORauVUMwGvfBa3dyqCEBxDUog8a+ Ly4otsNXW56e8CN//OmqAhJB8cpN8BkK0lg6H1MXebluO3kLnEg5rqAz2S7KfrMRm66w cfUOCRrJqE3oAMAiVkgNRhdE5qRd1gFvgkAkv5ek9y0wPOZ1MRDJ5552u/AAjtdAxkAo VGBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=IGtn+8csEUHjI+PBoOoXno8NTaopFnVrPycHVBspLZA=; b=GVjoYh0ZdwVDQM91kbY2oKq2GJ52B9nFCi+5oSmNNl/4ZjwtTWDHLoNmj6VgMrxbFx AWo52YG9LRGuHFeeE5TElR/tDO8lwa1S6Yyb7gzF2XJEfBRNKsjJRyHe/LYbA0myUr8D BC47hdWvLtNBrdqVAc79NyoL0PW8BSKInL+x411zJmyvs/VhPOA0vAGSw05nd+uypcRX jtD2e54LaLKFhPL4p8sCkbLGqMCWOiMV/WxMt2PqC6PFeKQLFt2fpyyXQ/HawtWzL+IB u0H2ZQIIPK4kBkiT4aG13QhlvLq6krK4p9QT7NQqctuHQq8JqigaCOhMlzdwJ/QqQy6C NepQ== X-Gm-Message-State: ALQs6tAQkxFVlf374Nn8NISBJWQZ+0Mbv52yHuI/OVE3gEvXhG+m0OWL VcXYc89pu4RQJTAt/XHyqfPhT18G X-Received: by 2002:a17:902:e81:: with SMTP id 1-v6mr3238820plx.158.1524079763833; Wed, 18 Apr 2018 12:29:23 -0700 (PDT) Received: from Hyun-ae.hitronhub.home (S0106f0f24947ab63.vc.shawcable.net. [70.79.35.154]) by smtp.gmail.com with ESMTPSA id d199sm3865450pfd.95.2018.04.18.12.29.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Apr 2018 12:29:23 -0700 (PDT) From: misty@brew.sh To: ffmpeg-devel@ffmpeg.org Date: Wed, 18 Apr 2018 12:29:16 -0700 Message-Id: <20180418192916.46055-2-misty@brew.sh> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180418192916.46055-1-misty@brew.sh> References: <20180418192916.46055-1-misty@brew.sh> Subject: [FFmpeg-devel] [PATCH 1/1] segafilm: fetch duration from the container 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: Misty De Meo MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Misty De Meo --- libavformat/segafilm.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c index e72c26b144..1529fc385e 100644 --- a/libavformat/segafilm.c +++ b/libavformat/segafilm.c @@ -43,6 +43,7 @@ typedef struct film_sample { int64_t sample_offset; unsigned int sample_size; int64_t pts; + uint32_t duration; int keyframe; } film_sample; @@ -226,6 +227,7 @@ static int film_read_header(AVFormatContext *s) ret = AVERROR_INVALIDDATA; goto fail; } + film->sample_table[i].duration = AV_RB32(&scratch[12]); if (AV_RB32(&scratch[8]) == 0xFFFFFFFF) { film->sample_table[i].stream = film->audio_stream_index; film->sample_table[i].pts = audio_frame_counter; @@ -270,7 +272,6 @@ static int film_read_packet(AVFormatContext *s, FilmDemuxContext *film = s->priv_data; AVIOContext *pb = s->pb; film_sample *sample; - film_sample *next_sample = NULL; int next_sample_id; int ret = 0; @@ -279,20 +280,6 @@ static int film_read_packet(AVFormatContext *s, sample = &film->sample_table[film->current_sample]; - /* Find the next sample from the same stream, assuming there is one; - * this is used to calculate the duration below */ - next_sample_id = film->current_sample + 1; - while (next_sample == NULL) { - if (next_sample_id >= film->sample_count) - break; - - next_sample = &film->sample_table[next_sample_id]; - if (next_sample->stream != sample->stream) { - next_sample = NULL; - next_sample_id++; - } - } - /* position the stream (will probably be there anyway) */ avio_seek(pb, sample->sample_offset, SEEK_SET); @@ -304,8 +291,7 @@ static int film_read_packet(AVFormatContext *s, pkt->dts = sample->pts; pkt->pts = sample->pts; pkt->flags |= sample->keyframe ? AV_PKT_FLAG_KEY : 0; - if (next_sample != NULL) - pkt->duration = next_sample->pts - sample->pts; + pkt->duration = sample->duration; film->current_sample++;