From patchwork Thu May 16 22:29:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13151 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 8F43044964F for ; Fri, 17 May 2019 01:43:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 71D29689B6F; Fri, 17 May 2019 01:43:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 401ED689AD1 for ; Fri, 17 May 2019 01:43:14 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id y3so5127520wmm.2 for ; Thu, 16 May 2019 15:43:14 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=DO4roELfF5yUN5MokkA/wZiG6EpglqWRRRJcU20yhjI=; b=glGGyGPhBdhKMA9od0OKO0LqDMmUuo76i7ByHP0pOmTRCpmqM+cqBSVgBr6QrlXIpi jHypEYRcE0ZMQ/1KDJYhn+Fb8ot6uIS447yqxD+xRCN9XVbIFGvi8iKAeA071VVRtxP4 /WY/yNNGFgfk5Zi/ytlIxbQvkQmpvo34VLp9TNilkQ6AMpe+O+mCNpTqpZfIQT6l26mX R+6JiSsV2926kF2R9V7ctJ0lhG9rhJQfztyb84OPEv5Cd0Yej7gg2N6x4YQV6zfyGynT N9AwJhZlIB9Ej64fPlwi1jqRX+i5ccbGH5bq936/QR5UEKu8rTfvIxWzIwYs1C8zj9Rp dlNQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=DO4roELfF5yUN5MokkA/wZiG6EpglqWRRRJcU20yhjI=; b=nTK8m6nTNkWdAD8e2+tlN+D+h5Xp5SUME3tMLBGvAJdFRVcQmtY66PpHQaXdPYJzYL ljFFZzJgoqHR0+xlq1OjiayuAK2lnwV4kkw9ooWmgBytCOjxzBOhqVr9Ut8iYz9B5A/b NjbShdzTmKYFUg0K9XV0HlLsMRKTf1lW5ncwKTBC5tU9Z4i45cajbrhAVXDtywj7GpV3 lzuAAH9uMkkYhpybk+Kjk5yPw43VYsGlNnE0Gf5+uAtxpuHV5fOGJX8sWRVlemt6M4uL NKyEXU+m5pVQrDfN9rO+Re6/7p3jP4zoBtDVOuMwO7X7DcJUqBStD7K01H+Dq43/whha Kyhg== X-Gm-Message-State: APjAAAWmq2uX2m1DL8el+kyCBI9fzMtBvxLK751yTsQcASSsQ/sBaj+3 6Z6ZUAJlIlrwnHr5lCwiTNhnacLV X-Google-Smtp-Source: APXvYqxCt7TCt8N1D6Bt0Rhnn64Yc8A8sl1bPTeuhIoD/vP90+sRGnfNflpzlyZrvbVXiRW15I4cug== X-Received: by 2002:a1c:a745:: with SMTP id q66mr19692128wme.83.1558046593508; Thu, 16 May 2019 15:43:13 -0700 (PDT) Received: from localhost.localdomain (ipbcc18715.dynamic.kabel-deutschland.de. [188.193.135.21]) by smtp.gmail.com with ESMTPSA id i185sm11168725wmg.32.2019.05.16.15.43.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 15:43:13 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 May 2019 00:29:58 +0200 Message-Id: <20190516223018.30827-15-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516223018.30827-1-andreas.rheinhardt@gmail.com> References: <20190516223018.30827-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/37] avformat/matroskadec: Remove non-incremental parsing of clusters 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" When the new incremental parser was introduced, the old parser was kept, because the new parser was unable to handle the way SSA packets are put into Matroska. But since 2014 (since c7d8dbad) this is no longer needed, so that the old parser can be completely removed. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 72 ++++++--------------------------------- 1 file changed, 10 insertions(+), 62 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index e01f1703e7..c0767c3529 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -362,9 +362,6 @@ typedef struct MatroskaDemuxContext { int64_t current_cluster_pos; MatroskaCluster current_cluster; - /* File has SSA subtitles which prevent incremental cluster parsing. */ - int contains_ssa; - /* WebM DASH Manifest live flag */ int is_live; @@ -709,25 +706,7 @@ static const EbmlSyntax matroska_blockgroup[] = { { 0 } }; -static const EbmlSyntax matroska_cluster[] = { - { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0, offsetof(MatroskaCluster, timecode) }, - { MATROSKA_ID_BLOCKGROUP, EBML_NEST, sizeof(MatroskaBlock), offsetof(MatroskaCluster, blocks), { .n = matroska_blockgroup } }, - { MATROSKA_ID_SIMPLEBLOCK, EBML_PASS, sizeof(MatroskaBlock), offsetof(MatroskaCluster, blocks), { .n = matroska_blockgroup } }, - { MATROSKA_ID_CLUSTERPOSITION, EBML_NONE }, - { MATROSKA_ID_CLUSTERPREVSIZE, EBML_NONE }, - { 0 } -}; - -static const EbmlSyntax matroska_clusters[] = { - { MATROSKA_ID_CLUSTER, EBML_NEST, 0, 0, { .n = matroska_cluster } }, - { MATROSKA_ID_INFO, EBML_NONE }, - { MATROSKA_ID_CUES, EBML_NONE }, - { MATROSKA_ID_TAGS, EBML_NONE }, - { MATROSKA_ID_SEEKHEAD, EBML_NONE }, - { 0 } -}; - -static const EbmlSyntax matroska_cluster_incremental_parsing[] = { +static const EbmlSyntax matroska_cluster_parsing[] = { { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0, offsetof(MatroskaCluster, timecode) }, { MATROSKA_ID_BLOCKGROUP, EBML_NEST, sizeof(MatroskaBlock), offsetof(MatroskaCluster, blocks), { .n = matroska_blockgroup } }, { MATROSKA_ID_SIMPLEBLOCK, EBML_PASS, sizeof(MatroskaBlock), offsetof(MatroskaCluster, blocks), { .n = matroska_blockgroup } }, @@ -741,7 +720,7 @@ static const EbmlSyntax matroska_cluster_incremental_parsing[] = { { 0 } }; -static const EbmlSyntax matroska_cluster_incremental[] = { +static const EbmlSyntax matroska_cluster[] = { { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0, offsetof(MatroskaCluster, timecode) }, { MATROSKA_ID_BLOCKGROUP, EBML_STOP }, { MATROSKA_ID_SIMPLEBLOCK, EBML_STOP }, @@ -750,8 +729,8 @@ static const EbmlSyntax matroska_cluster_incremental[] = { { 0 } }; -static const EbmlSyntax matroska_clusters_incremental[] = { - { MATROSKA_ID_CLUSTER, EBML_NEST, 0, 0, { .n = matroska_cluster_incremental } }, +static const EbmlSyntax matroska_clusters[] = { + { MATROSKA_ID_CLUSTER, EBML_NEST, 0, 0, { .n = matroska_cluster } }, { MATROSKA_ID_INFO, EBML_NONE }, { MATROSKA_ID_CUES, EBML_NONE }, { MATROSKA_ID_TAGS, EBML_NONE }, @@ -2648,8 +2627,6 @@ static int matroska_parse_tracks(AVFormatContext *s) } } else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) { st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; - if (st->codecpar->codec_id == AV_CODEC_ID_ASS) - matroska->contains_ssa = 1; } } @@ -3520,19 +3497,19 @@ end: return res; } -static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska) +static int matroska_parse_cluster(MatroskaDemuxContext *matroska) { EbmlList *blocks_list; MatroskaBlock *blocks; int i, res; res = ebml_parse(matroska, - matroska_cluster_incremental_parsing, + matroska_cluster_parsing, &matroska->current_cluster); if (res == 1) { /* New Cluster */ if (matroska->current_cluster_pos) ebml_level_end(matroska); - ebml_free(matroska_cluster, &matroska->current_cluster); + ebml_free(matroska_cluster_parsing, &matroska->current_cluster); memset(&matroska->current_cluster, 0, sizeof(MatroskaCluster)); matroska->current_cluster_num_blocks = 0; matroska->current_cluster_pos = avio_tell(matroska->ctx->pb); @@ -3540,12 +3517,12 @@ static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska) if (matroska->current_id) matroska->current_cluster_pos -= 4; res = ebml_parse(matroska, - matroska_clusters_incremental, + matroska_clusters, &matroska->current_cluster); /* Try parsing the block again. */ if (res == 1) res = ebml_parse(matroska, - matroska_cluster_incremental_parsing, + matroska_cluster_parsing, &matroska->current_cluster); } @@ -3576,35 +3553,6 @@ static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska) return res; } -static int matroska_parse_cluster(MatroskaDemuxContext *matroska) -{ - MatroskaCluster cluster = { 0 }; - EbmlList *blocks_list; - MatroskaBlock *blocks; - int i, res; - int64_t pos; - - if (!matroska->contains_ssa) - return matroska_parse_cluster_incremental(matroska); - pos = avio_tell(matroska->ctx->pb); - if (matroska->current_id) - pos -= 4; /* sizeof the ID which was already read */ - res = ebml_parse(matroska, matroska_clusters, &cluster); - blocks_list = &cluster.blocks; - blocks = blocks_list->elem; - for (i = 0; i < blocks_list->nb_elem; i++) - if (blocks[i].bin.size > 0 && blocks[i].bin.data) { - int is_keyframe = blocks[i].non_simple ? blocks[i].reference == INT64_MIN : -1; - res = matroska_parse_block(matroska, blocks[i].bin.buf, blocks[i].bin.data, - blocks[i].bin.size, blocks[i].bin.pos, - cluster.timecode, blocks[i].duration, - is_keyframe, NULL, 0, 0, pos, - blocks[i].discard_padding); - } - ebml_free(matroska_cluster, &cluster); - return res; -} - static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaDemuxContext *matroska = s->priv_data; @@ -3699,7 +3647,7 @@ static int matroska_read_close(AVFormatContext *s) for (n = 0; n < matroska->tracks.nb_elem; n++) if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO) av_freep(&tracks[n].audio.buf); - ebml_free(matroska_cluster, &matroska->current_cluster); + ebml_free(matroska_cluster_parsing, &matroska->current_cluster); ebml_free(matroska_segment, matroska); return 0;