From patchwork Fri Mar 8 09:25:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 12253 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 0E41F4490CB for ; Fri, 8 Mar 2019 11:35:31 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EF6CF68A79B; Fri, 8 Mar 2019 11:35:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B345568A500 for ; Fri, 8 Mar 2019 11:35:24 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id f65so11867770wma.2 for ; Fri, 08 Mar 2019 01:35:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CMcx3bcgvEWZ4LtDSeeL5RQmpWkz0kCScn6dv7orvTo=; b=RhGAUDgU/tbeIRlNkGwECJyPXtd1l7TRvhYOvchP3DPc5mOjkxy9b34Sb1w5jm+ot2 VmSoIIDTyiZ6NfMWUBuO16oZcf3U6jW6yvG3o1HAlbMlopZUZ6W6b/LJ4V0UdFvIRDIY /LzgfEanUwI3jHHsBFcQtIFSDMKkc3+yDxpHBIwk+a1moIfQ5x+X3OMTHNWTdJdITEwV 1fBjo/443ER0qwiofD4zc+COJ3Zx2WqUWtM6y1yJHfachx4iXU3XGKUXZV3Go7RY7hun CoH5zNKUr/poINfWWDwaifOimRCshFVvoM2l4/b53WD4SZ3t+dsw1gG8yUrFUXUFjLU5 ySmg== 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=CMcx3bcgvEWZ4LtDSeeL5RQmpWkz0kCScn6dv7orvTo=; b=TgUThTofS9AsPsdQB16KNXoQoNIu9DNSnSn0jsXqV9/7Xq74MqIe7p+Rcb7RAv4oUj Jq8oa2OfHWy77/0UaRu77izunTTN/6VDSyteyPasEK02IT7v/8bkitVwyTaTlXksXjJL fdpSLPX4MLjsvJZoICvvh0X4CWckBAK6hVL+Sb4gg5mEkWblQci2cVfE/Yquvf+c8qqm R7tGi4I/ANCJyz6yi1qOsNDhdhONPMjsfoEVBgpmWTco0ERdU1z7RwBF4tiBR+CvnkK2 EAQxOHEWvjL5ZsGpvT+L9XBv/H1g06gXyMDCYA1REdtsmNiXiKDaNbxIb2jsnfj3VRmV YLOA== X-Gm-Message-State: APjAAAXkG2M0KMk4uajS/UbfH7U+xBPxpZBAUaojLqNFyYOfE3PuPn7p bt1wR6MIAh6UStKpZB4SHvJZiQrg/uc= X-Google-Smtp-Source: APXvYqxxRdINAe/9G/k61dXfUHM1b5OH0AgPRvWuIIPrN/cQThkQgDXBakQk+Pg5Tg9E5YLWmgxfbA== X-Received: by 2002:a1c:39d5:: with SMTP id g204mr8787314wma.17.1552037244577; Fri, 08 Mar 2019 01:27:24 -0800 (PST) Received: from localhost.localdomain (ipbcc08c44.dynamic.kabel-deutschland.de. [188.192.140.68]) by smtp.googlemail.com with ESMTPSA id v20sm12179825wmj.2.2019.03.08.01.27.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 01:27:24 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 8 Mar 2019 10:25:59 +0100 Message-Id: <20190308092604.3752-6-andreas.rheinhardt@googlemail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190308092604.3752-1-andreas.rheinhardt@googlemail.com> References: <20190308092604.3752-1-andreas.rheinhardt@googlemail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/10] 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 c7d8dbad14ed5fa3c217a4fc1790021d6c0b6416) 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 55a153d982..6ab9ef7a3e 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -360,9 +360,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; @@ -707,25 +704,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 } }, @@ -739,7 +718,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 }, @@ -748,8 +727,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 }, @@ -2584,8 +2563,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; } } @@ -3450,19 +3427,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); @@ -3470,12 +3447,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); } @@ -3507,35 +3484,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; @@ -3631,7 +3579,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;