From patchwork Tue Aug 11 01:26:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21594 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 53BAA448889 for ; Tue, 11 Aug 2020 04:27:14 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2C34768A107; Tue, 11 Aug 2020 04:27:14 +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 EAE7668A0F1 for ; Tue, 11 Aug 2020 04:27:07 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id d190so1153542wmd.4 for ; Mon, 10 Aug 2020 18:27:07 -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:mime-version :content-transfer-encoding; bh=3tc20UESS32GPu/Zd1ll1TAfthcoW3GesQATBP4cr2o=; b=Y5i9GDOZZyhQjv0DEOKkIaM6zFN0PBkKH/x40mZ43f5Yb6MenThzhiVr+g75Q4g3YV 9GbJJu3oQ61i1XQpC4nslB8re+1wEyZKBEaLtXAvX9PPWTfone7wthHIcqsE/+5r598z 5x4eVbU2Ja13wpw/n8WDYJRPMBOL0XHLHIiPRRujvoX+rQllPPvAX1UrJE01JeBpVd86 Z+jMS1q9Hn4POY2lm8bofwbm1zeoeyTsgRW2ZEGSsZfRjU5Erj/0WMbHOWiQj4iyoSwP V/L/QyFOPA/ipLjqU4NAqyxxtpg58cJ075fSb/2/L2ei4KgW3tKrRn5tdSQEvQgsQH2x K+mQ== 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:mime-version :content-transfer-encoding; bh=3tc20UESS32GPu/Zd1ll1TAfthcoW3GesQATBP4cr2o=; b=AOZjcDbMJ/KlX1s8CUJD9xCXb8Xk23TQPe3dEr0V/jtD26/ZAZ5bQrwSiF1H4E4vda 9xCTs9y8RwCLYxqDAn2qQWP5utC4f9+IexOEz7RSY73tLn4LVsTfQmtyaIidIL01yQ4G AANHFr9CaXu+RrNaJ78awqHMCsm3ashp53X/VIEZ3UMF2xbNALwG2WUW1zsZHkzgci/C uynzgKsnu7/f1XH0qwrlGoivXav5buCjR4rj14Kwv10BD0oN94kdAKAsYUQARkmWDreP QlVLKVhitbd66ILyic0ruuCqZ6IobvhWa2koN9FWfNQodoqsAoASyFNtjvEhjeSkdJWU 60nA== X-Gm-Message-State: AOAM531VZA39Qzb0jEwK1iphnQG3yilO5c30SQcjFMVQhr2DoJzifv3r Nf2l8Pi1gAMbILve91r9tfIS/ze1 X-Google-Smtp-Source: ABdhPJyNkGGuBg8p/1cWh9mMQRZulY94qKu1ojXhNku2a6TVlo8Oy3V5+jsUvA0RTsEaRkanHC4AdQ== X-Received: by 2002:a1c:7e12:: with SMTP id z18mr1631592wmc.188.1597109226869; Mon, 10 Aug 2020 18:27:06 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id j5sm2365333wmb.12.2020.08.10.18.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2020 18:27:06 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Aug 2020 03:26:59 +0200 Message-Id: <20200811012659.20934-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/ty: Remove write-only array and variable 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" Up until now, the TiVo demuxer parse an array of SEQ entries, yet it has never ever made any use of them. In fact, parse_master, the function parsing said table, only influenced the outside world in three ways: Via an excessive amount of error message in case a certain parameter is not what it expected; via an allocation (the aforementioned write-only array); and by setting a certain parameter (ty->cur_chunk_pos), but that parameter is always overwritten before it is used (it is overwritten in get_chunk() on success and if get_chunk() fails, the error is returned to the caller anyway). So remove the array and the function used to parse it. Signed-off-by: Andreas Rheinhardt --- Furthermore, the parsing code seems not to work at all: The current position is not incremented by map_size if map_size <= 8. libavformat/ty.c | 68 +----------------------------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) diff --git a/libavformat/ty.c b/libavformat/ty.c index 738a22e7de..c8e1067c0e 100644 --- a/libavformat/ty.c +++ b/libavformat/ty.c @@ -72,11 +72,6 @@ typedef enum { TIVO_AUDIO_MPEG } TiVo_audio; -typedef struct TySeqTable { - uint64_t timestamp; - uint8_t chunk_bitmask[8]; -} TySeqTable; - typedef struct TYDemuxContext { unsigned cur_chunk; unsigned cur_chunk_pos; @@ -90,7 +85,6 @@ typedef struct TYDemuxContext { int pes_buf_cnt; /* how many bytes in our buffer */ size_t ac3_pkt_size; /* length of ac3 pkt we've seen so far */ uint64_t last_ty_pts; /* last TY timestamp we've seen */ - unsigned seq_table_size; /* number of entries in SEQ table */ int64_t first_audio_pts; int64_t last_audio_pts; @@ -99,8 +93,6 @@ typedef struct TYDemuxContext { TyRecHdr *rec_hdrs; /* record headers array */ int cur_rec; /* current record in this chunk */ int num_recs; /* number of recs in this chunk */ - int seq_rec; /* record number where seq start is */ - TySeqTable *seq_table; /* table of SEQ entries from mstr chk */ int first_chunk; uint8_t chunk[CHUNK_SIZE]; @@ -339,58 +331,6 @@ static int ty_read_header(AVFormatContext *s) return 0; } -/* parse a master chunk, filling the SEQ table and other variables. - * We assume the stream is currently pointing to it. - */ -static void parse_master(AVFormatContext *s) -{ - TYDemuxContext *ty = s->priv_data; - unsigned map_size; /* size of bitmask, in bytes */ - unsigned i, j; - - /* Note that the entries in the SEQ table in the stream may have - different sizes depending on the bits per entry. We store them - all in the same size structure, so we have to parse them out one - by one. If we had a dynamic structure, we could simply read the - entire table directly from the stream into memory in place. */ - - /* clear the SEQ table */ - av_freep(&ty->seq_table); - - /* parse header info */ - - map_size = AV_RB32(ty->chunk + 20); /* size of bitmask, in bytes */ - i = AV_RB32(ty->chunk + 28); /* size of SEQ table, in bytes */ - - ty->seq_table_size = i / (8LL + map_size); - - if (ty->seq_table_size == 0) { - ty->seq_table = NULL; - return; - } - - /* parse all the entries */ - ty->seq_table = av_calloc(ty->seq_table_size, sizeof(TySeqTable)); - if (ty->seq_table == NULL) { - ty->seq_table_size = 0; - return; - } - - ty->cur_chunk_pos = 32; - for (j = 0; j < ty->seq_table_size; j++) { - if (ty->cur_chunk_pos >= CHUNK_SIZE - 8) - return; - ty->seq_table[j].timestamp = AV_RB64(ty->chunk + ty->cur_chunk_pos); - ty->cur_chunk_pos += 8; - if (map_size > 8) { - av_log(s, AV_LOG_ERROR, "Unsupported SEQ bitmap size in master chunk.\n"); - ty->cur_chunk_pos += map_size; - } else { - memcpy(ty->seq_table[j].chunk_bitmask, ty->chunk + ty->cur_chunk_pos, map_size); - } - } -} - static int get_chunk(AVFormatContext *s) { TYDemuxContext *ty = s->priv_data; @@ -413,7 +353,7 @@ static int get_chunk(AVFormatContext *s) /* check if it's a PART Header */ if (AV_RB32(ty->chunk) == TIVO_PES_FILEID) { - parse_master(s); /* parse master chunk */ + /* skip master chunk and read new chunk */ return get_chunk(s); } @@ -421,14 +361,9 @@ static int get_chunk(AVFormatContext *s) if (ty->chunk[3] & 0x80) { /* 16 bit rec cnt */ ty->num_recs = num_recs = (ty->chunk[1] << 8) + ty->chunk[0]; - ty->seq_rec = (ty->chunk[3] << 8) + ty->chunk[2]; - if (ty->seq_rec != 0xffff) { - ty->seq_rec &= ~0x8000; - } } else { /* 8 bit reclen - TiVo 1.3 format */ ty->num_recs = num_recs = ty->chunk[0]; - ty->seq_rec = ty->chunk[1]; } ty->cur_rec = 0; ty->first_chunk = 0; @@ -770,7 +705,6 @@ static int ty_read_close(AVFormatContext *s) { TYDemuxContext *ty = s->priv_data; - av_freep(&ty->seq_table); av_freep(&ty->rec_hdrs); return 0;