Message ID | CAO7y9i-A6qZAr_S2NRPvuomM=AM7oLm+qsBGJ0GuMh20G8CqAw@mail.gmail.com |
---|---|
State | New |
Headers |
Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp1309066vsb; Wed, 26 Jul 2017 15:45:11 -0700 (PDT) X-Received: by 10.223.129.245 with SMTP id 108mr1907240wra.67.1501109111185; Wed, 26 Jul 2017 15:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501109111; cv=none; d=google.com; s=arc-20160816; b=V/Zc5SygPx2ygoyGElWabGOWjRevBPRcTxHmnuRit3EnYmo6aNLqdCXtRFTrYT/v9+ RG6EL9jbkIna1j8IaZzbc0s+3iZH1kR7kRdhHaSPW4iwMalpxO5MMogHnz1njCJXX7VR i315u7DMWNYeUmiOzjlt8Fxq3mLsEsMHtZWACHXtvvfXOh7HO8+L2ifq8oNu0t2yF3ia x2NBs8YUbnaYO35Rzujurbl7BhEmJ4vgf57GtOrNclgD2XihMKD2mbCVgRWCqMp3j5Tx eNJWFGd/q3mR4cFSUyk+v/+bXrYUf74HdupOA92DDPYCiRW057BK4SItkS38oLPXco1c WIGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:to:message-id:date:from:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=Mmv8aJSHoF/v3IPybkXMU4y5hzJF4iQA+F8VlzMrqzw=; b=BYct0FzCKghhLMaVIGw1ZGT5SecORHe9YPT4lRgrhZAkeERx5s28sdyunwOsibQjtl z10eDvaNzp65o7zFWRqbb4p7+525dXyDuYczAMIyTJhQGpym+6qLgGJ7wwYep5sBrZuT 11ZAOpJPlItl38ztnMnxWtRLLB0hmVAeBvTMp/SYvFbHWv9xGHbe0IOMOiXYNWb/mFCp BgXz8Ds1jWXBHeUWiL1gUr9kBmn/Viydz8D7WgQrZlsIYWiIGugSX7igFbm0grswM7YY v6KkrZE+vrevo8ZZsByk6vK1SIjHmPUVF099k9ctXabP72oWhW5yfgtB17rU6mlR1hJB 5WKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=QPmexvio; 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: <ffmpeg-devel-bounces@ffmpeg.org> Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v75si9861252wmf.273.2017.07.26.15.45.10; Wed, 26 Jul 2017 15:45:11 -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=@google.com header.s=20161025 header.b=QPmexvio; 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 A77BF689BB8; Thu, 27 Jul 2017 01:45:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 52D5B6891D4 for <ffmpeg-devel@ffmpeg.org>; Thu, 27 Jul 2017 01:45:00 +0300 (EEST) Received: by mail-wr0-f179.google.com with SMTP id k71so83424662wrc.2 for <ffmpeg-devel@ffmpeg.org>; Wed, 26 Jul 2017 15:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=eKhytOoCB3TXfm2zdEmbAdoSDNxx480yoEdQnU9x7m4=; b=QPmexviowhlYORsDw/EUaHte1EH3+wCk/IMdk2GbUpTPgqkyOv6BUpaO0YxraqGzcK cowY72ZI/RxU7iLFO0QxR6wEfeW0ZQ43ENHGnHThd4YM3xtl3v7/Aa7t1CLSBTxaXQkS XIcPF+Z3mO3uFjz0Mz0c5cEzQm8eSonmFEHsj5YDiiJLWaP2fvy3fe1dqwK4tgdMJibU fe67lAm/EaEKcIGm8/2O1u6RUhPfJvxrQSjHuUuZn9XQbltmdeVDhVuSppbukoVe19cA eI2rmWpiITtcA6uZ7YCb+4qFTRV2LkTGytq9HovIsMdBaHmjv6R5zJZ0nsYFF1WGIKmJ n/9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=eKhytOoCB3TXfm2zdEmbAdoSDNxx480yoEdQnU9x7m4=; b=nab4RpAOZtvAAUMvTmLZ2+ze7fSzfLB0OmZlIXHrii6U9SEKX++OJg0z8ZwP++Hzee rUOQx8gL/gES9UPB1K6LFIEc3vBLR1Q1QQ6jxe90pZ0sUxJO6TjTTQD3uC1F6ze/JLXP YPvE8jvOVTONl+iQT4JJuH/I2tGi0BPeTVOCR5uGflGmOyPxGj9NJLXqa/EZBulRAHk4 SzTwDmoG7Dgh/1zl9VSVOJV5XXVwnptcnA6hOGH5qIUsqr8OuekyJu8cGYGwOD2/y7Q8 VSn1d+DIkJtbltmJI75bQeGmxwh0/3nrs1yGtyJkjqmQTErWEgb9ezGD6Oh3BtvP0Ttm tE6Q== X-Gm-Message-State: AIVw112FtVcTfkyqzPldFOcjqYxISn9FXf6ayZ9hyvwRtxo+oyJkAnFb DSp6gsAnG8Y1bSsdNuFF08rOsLaqh1DULjXEuA== X-Received: by 10.223.174.209 with SMTP id y75mr1783616wrc.19.1501108636955; Wed, 26 Jul 2017 15:37:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.143.1 with HTTP; Wed, 26 Jul 2017 15:37:16 -0700 (PDT) From: Jacob Trimble <modmaker-at-google.com@ffmpeg.org> Date: Wed, 26 Jul 2017 15:37:16 -0700 Message-ID: <CAO7y9i-A6qZAr_S2NRPvuomM=AM7oLm+qsBGJ0GuMh20G8CqAw@mail.gmail.com> To: ffmpeg-devel@ffmpeg.org X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] libavformat/mov: Fix inserting frames before current_frame X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org> List-Unsubscribe: <http://ffmpeg.org/mailman/options/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> List-Archive: <http://ffmpeg.org/pipermail/ffmpeg-devel/> List-Post: <mailto:ffmpeg-devel@ffmpeg.org> List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> List-Subscribe: <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> |
Commit Message
Jacob Trimble
July 26, 2017, 10:37 p.m. UTC
When using streaming input, it may be possible to see frames that appear
before the current_frame. When these frames are inserted into the
index, the current_frame needs to be updated so it is still pointing
at the same frame.
Signed-off-by: Jacob Trimble <modmaker@google.com>
---
libavformat/mov.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
if (c->fc->streams[i]->id == frag->track_id) {
@@ -4352,13 +4352,19 @@ static int mov_read_trun(MOVContext *c, AVIOContext
*pb, MOVAtom atom)
MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES));
if (keyframe)
distance = 0;
+ old_nb_index_entries = st->nb_index_entries;
err = av_add_index_entry(st, offset, dts, sample_size, distance,
keyframe ? AVINDEX_KEYFRAME : 0);
if (err < 0) {
av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n");
+ } else if (err <= sc->current_sample && err + 1 !=
st->nb_index_entries &&
+ st->nb_index_entries != old_nb_index_entries) {
+ // if we inserted a new item before the current sample, move
the
+ // counter ahead so it is still pointing to the same sample.
+ sc->current_sample++;
}
- av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %u, offset
%"PRIx64", dts %"PRId64", "
- "size %u, distance %d, keyframe %d\n", st->index,
sc->sample_count+i,
+ av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %d, offset
%"PRIx64", dts %"PRId64", "
+ "size %u, distance %d, keyframe %d\n", st->index, err,
offset, dts, sample_size, distance, keyframe);
distance++;
dts += sample_duration;
Comments
On Wed, Jul 26, 2017 at 15:37:16 -0700, Jacob Trimble wrote: > av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n"); > + } else if (err <= sc->current_sample && err + 1 != > st->nb_index_entries && > + st->nb_index_entries != old_nb_index_entries) { Your mailer inserted line breaks into the patch. Please either attach it, or even better, send it with git send-email. Thanks, Moritz
diff --git a/libavformat/mov.c b/libavformat/mov.c index 63f84be782..d039f27063 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4259,7 +4259,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) int64_t dts; int data_offset = 0; unsigned entries, first_sample_flags = frag->flags; - int flags, distance, i, err; + int flags, distance, i, err, old_nb_index_entries; for (i = 0; i < c->fc->nb_streams; i++) {