From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 8EDCD46DB3 for ; Tue, 11 Jul 2023 21:19:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5DF8D68C604; Wed, 12 Jul 2023 00:19:22 +0300 (EEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A483B68C59F for ; Wed, 12 Jul 2023 00:19:15 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id DBD1DE0002 for ; Tue, 11 Jul 2023 21:19:14 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 11 Jul 2023 23:19:01 +0200 Message-Id: <20230711211910.1257355-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230711211910.1257355-1-michael@niedermayer.cc> References: <20230711211910.1257355-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 03/12] avradio/rds: Keep track of program_id X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This allows detecting more damaged blocks Signed-off-by: Michael Niedermayer --- libavradio/rds.c | 16 ++++++++++++++++ libavradio/sdr.h | 1 + 2 files changed, 17 insertions(+) diff --git a/libavradio/rds.c b/libavradio/rds.c index 2cb7942bbd..dc7124cab3 100644 --- a/libavradio/rds.c +++ b/libavradio/rds.c @@ -85,7 +85,13 @@ static int check_rds_block(Station *station, uint16_t group[4], const float diff int ret = burst_len(syndrom); group[block] ^= (syndrom << i) >> 10; + if (block == 0 && station->program_id[0]) { + if (group[0] == station->program_id[0]) { return ret; + } else if (group[0] == station->program_id[1]) { + return ret; + } else if (ret) { + return 20; //PI change is uncommon, so dont accept this in a damaged block, PI is repeated alot so we can wait for a clean block } } @@ -108,6 +114,16 @@ static int decode_rds_group(SDRContext *sdr, SDRStream *sst, uint16_t group[4]) int tp = group[1] & 0x400; int pty= (group[1] >> 5) & 0x1F; + if (station->program_id[0] && station->program_id[0] != pi) + av_log(sdr->avfmt, AV_LOG_INFO, "PI changed to %X\n", pi); + + if (station->program_id[1] == pi) { + FFSWAP(int, station->program_id[1], station->program_id[0]); + } else if (station->program_id[0] != pi) { + station->program_id[1] = pi; + return 0; // skip first packet with new PI, likely its just damaged + } + switch(a) { case 0: AV_WB16(station->name + 2*(group[1]&3), group[3]); diff --git a/libavradio/sdr.h b/libavradio/sdr.h index 212358fad9..b83264ae0d 100644 --- a/libavradio/sdr.h +++ b/libavradio/sdr.h @@ -74,6 +74,7 @@ typedef struct Station { char name[9]; char radiotext[65]; char programm_type_name[9]; + int program_id[2]; enum Modulation modulation; double frequency; int nb_frequency; ///< number of detections which are used to compute the frequency -- 2.31.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".