From patchwork Wed Oct 5 02:27:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodger Combs X-Patchwork-Id: 880 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp80921vsd; Tue, 4 Oct 2016 19:28:25 -0700 (PDT) X-Received: by 10.28.66.144 with SMTP id k16mr3333273wmi.129.1475634505126; Tue, 04 Oct 2016 19:28:25 -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 ws7si8481103wjb.93.2016.10.04.19.28.24; Tue, 04 Oct 2016 19:28:25 -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 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 501C9689DFE; Wed, 5 Oct 2016 05:27:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f67.google.com (mail-it0-f67.google.com [209.85.214.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFE1F689C91 for ; Wed, 5 Oct 2016 05:27:47 +0300 (EEST) Received: by mail-it0-f67.google.com with SMTP id j69so9941596itb.1 for ; Tue, 04 Oct 2016 19:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=IO4EKer43i7Larfv3cFFkjp2tXvX6Gfchcgbx2VvwKw=; b=xrE/jVltIOwSxMfIgHnelpeMx/tJrfO2kcJ9IUvce/81jH2Pgu7vT0i80k2x/zyuSV 8H2qWQUwDuoUz7vUjsi/GiuNpKhPqhY/mxSNsPuHrunnatfY8F7qaXXB/T1Z6CDe+/v9 EvU44IPfy5O+wuh7N9IFTOMn1GyalYYRDwgRsRmRdtFXKU9VVzL2K72nQSAXrR5YBqGB rH3Rftoz10ZjBJ7o3/09mhmogV6/YhtvGtNtZda/W6c4NikzbAvvwHowZm/v4dJW39Ky lCsmwcJeC8Trge4YMySPCwJ9L84yifq6R3e2Mj3DB/61g51elEcpVU6pKN/aMt6Micgy owzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=IO4EKer43i7Larfv3cFFkjp2tXvX6Gfchcgbx2VvwKw=; b=QglLhRd4UqlPttXkELfVTLyTb4hKW0OZ7zC4E2HafxvYp/RFmTW/bUPXIeaG8euw5P cB7kuozOpDG6BAaevBlaEIv2W4tDfnSpisRNR3mubze2C8V4jH+/008qaNiBEeDscDmj SLGP6qpu2PxuxCWvdHnf7BbUpaiD7uwkG+/AhFZ7d66da72dld+HlpaQrzWH6jJ650pW +mLBEoGPjBtNRjDje5WWxMLt7AEYDYts5qyLu96+ONEprxEOdnGudWNHXAwao2gd8j/Z f0Q0AT5JupP+RNNcgSf9DBzf1OHgXvP2GSyhLC0c1mSENeG4se1iLnoBpwbi7wHpxwpR VTFQ== X-Gm-Message-State: AA6/9RlXQrcg7qHY2WXN+08Sj4odcpQsOPg2FtRq8A4XT9yBdjxpQxOyJ9k9mBZmlC2ZWA== X-Received: by 10.107.28.196 with SMTP id c187mr8413490ioc.11.1475634481529; Tue, 04 Oct 2016 19:28:01 -0700 (PDT) Received: from Rodgers-MacBook-Pro.local.net (c-73-209-137-129.hsd1.il.comcast.net. [73.209.137.129]) by smtp.gmail.com with ESMTPSA id r123sm11707911ith.1.2016.10.04.19.28.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 04 Oct 2016 19:28:01 -0700 (PDT) From: Rodger Combs To: ffmpeg-devel@ffmpeg.org Date: Tue, 4 Oct 2016 21:27:54 -0500 Message-Id: <20161005022754.44256-3-rodger.combs@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161005022754.44256-1-rodger.combs@gmail.com> References: <20161005022754.44256-1-rodger.combs@gmail.com> Subject: [FFmpeg-devel] [PATCH 3/3] lavf/mov: reindent 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Reviewed-By: Michael Niedermayer --- libavformat/mov.c | 156 +++++++++++++++++++++++++++--------------------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index d0f1316..c9fef8a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5054,94 +5054,94 @@ static void mov_read_chapters(AVFormatContext *s) int chapter_track; for (j = 0; j < mov->nb_chapter_tracks; j++) { - chapter_track = mov->chapter_tracks[j]; - st = NULL; - for (i = 0; i < s->nb_streams; i++) - if (s->streams[i]->id == chapter_track) { - st = s->streams[i]; - break; + chapter_track = mov->chapter_tracks[j]; + st = NULL; + for (i = 0; i < s->nb_streams; i++) + if (s->streams[i]->id == chapter_track) { + st = s->streams[i]; + break; + } + if (!st) { + av_log(s, AV_LOG_ERROR, "Referenced QT chapter track not found\n"); + continue; } - if (!st) { - av_log(s, AV_LOG_ERROR, "Referenced QT chapter track not found\n"); - continue; - } - sc = st->priv_data; - cur_pos = avio_tell(sc->pb); + sc = st->priv_data; + cur_pos = avio_tell(sc->pb); + + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + st->disposition |= AV_DISPOSITION_ATTACHED_PIC | AV_DISPOSITION_TIMED_THUMBNAILS; + if (st->nb_index_entries) { + // Retrieve the first frame, if possible + AVPacket pkt; + AVIndexEntry *sample = &st->index_entries[0]; + if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { + av_log(s, AV_LOG_ERROR, "Failed to retrieve first frame\n"); + goto finish; + } - if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { - st->disposition |= AV_DISPOSITION_ATTACHED_PIC | AV_DISPOSITION_TIMED_THUMBNAILS; - if (st->nb_index_entries) { - // Retrieve the first frame, if possible - AVPacket pkt; - AVIndexEntry *sample = &st->index_entries[0]; - if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { - av_log(s, AV_LOG_ERROR, "Failed to retrieve first frame\n"); - goto finish; - } + if (av_get_packet(sc->pb, &pkt, sample->size) < 0) + goto finish; - if (av_get_packet(sc->pb, &pkt, sample->size) < 0) - goto finish; + st->attached_pic = pkt; + st->attached_pic.stream_index = st->index; + st->attached_pic.flags |= AV_PKT_FLAG_KEY; + } + } else { + st->codecpar->codec_type = AVMEDIA_TYPE_DATA; + st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA; + st->discard = AVDISCARD_ALL; + for (i = 0; i < st->nb_index_entries; i++) { + AVIndexEntry *sample = &st->index_entries[i]; + int64_t end = i+1 < st->nb_index_entries ? st->index_entries[i+1].timestamp : st->duration; + uint8_t *title; + uint16_t ch; + int len, title_len; + + if (end < sample->timestamp) { + av_log(s, AV_LOG_WARNING, "ignoring stream duration which is shorter than chapters\n"); + end = AV_NOPTS_VALUE; + } - st->attached_pic = pkt; - st->attached_pic.stream_index = st->index; - st->attached_pic.flags |= AV_PKT_FLAG_KEY; - } - } else { - st->codecpar->codec_type = AVMEDIA_TYPE_DATA; - st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA; - st->discard = AVDISCARD_ALL; - for (i = 0; i < st->nb_index_entries; i++) { - AVIndexEntry *sample = &st->index_entries[i]; - int64_t end = i+1 < st->nb_index_entries ? st->index_entries[i+1].timestamp : st->duration; - uint8_t *title; - uint16_t ch; - int len, title_len; - - if (end < sample->timestamp) { - av_log(s, AV_LOG_WARNING, "ignoring stream duration which is shorter than chapters\n"); - end = AV_NOPTS_VALUE; - } + if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { + av_log(s, AV_LOG_ERROR, "Chapter %d not found in file\n", i); + goto finish; + } - if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { - av_log(s, AV_LOG_ERROR, "Chapter %d not found in file\n", i); - goto finish; - } + // the first two bytes are the length of the title + len = avio_rb16(sc->pb); + if (len > sample->size-2) + continue; + title_len = 2*len + 1; + if (!(title = av_mallocz(title_len))) + goto finish; + + // The samples could theoretically be in any encoding if there's an encd + // atom following, but in practice are only utf-8 or utf-16, distinguished + // instead by the presence of a BOM + if (!len) { + title[0] = 0; + } else { + ch = avio_rb16(sc->pb); + if (ch == 0xfeff) + avio_get_str16be(sc->pb, len, title, title_len); + else if (ch == 0xfffe) + avio_get_str16le(sc->pb, len, title, title_len); + else { + AV_WB16(title, ch); + if (len == 1 || len == 2) + title[len] = 0; + else + avio_get_str(sc->pb, INT_MAX, title + 2, len - 1); + } + } - // the first two bytes are the length of the title - len = avio_rb16(sc->pb); - if (len > sample->size-2) - continue; - title_len = 2*len + 1; - if (!(title = av_mallocz(title_len))) - goto finish; - - // The samples could theoretically be in any encoding if there's an encd - // atom following, but in practice are only utf-8 or utf-16, distinguished - // instead by the presence of a BOM - if (!len) { - title[0] = 0; - } else { - ch = avio_rb16(sc->pb); - if (ch == 0xfeff) - avio_get_str16be(sc->pb, len, title, title_len); - else if (ch == 0xfffe) - avio_get_str16le(sc->pb, len, title, title_len); - else { - AV_WB16(title, ch); - if (len == 1 || len == 2) - title[len] = 0; - else - avio_get_str(sc->pb, INT_MAX, title + 2, len - 1); + avpriv_new_chapter(s, i, st->time_base, sample->timestamp, end, title); + av_freep(&title); } } - - avpriv_new_chapter(s, i, st->time_base, sample->timestamp, end, title); - av_freep(&title); - } - } finish: - avio_seek(sc->pb, cur_pos, SEEK_SET); + avio_seek(sc->pb, cur_pos, SEEK_SET); } }