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 DDF7846DE2 for ; Wed, 12 Jul 2023 23:38:16 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CE5B968C663; Thu, 13 Jul 2023 02:37:23 +0300 (EEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 58C0368C64F for ; Thu, 13 Jul 2023 02:37:15 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 94DF5C0003 for ; Wed, 12 Jul 2023 23:37:14 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 13 Jul 2023 01:36:59 +0200 Message-Id: <20230712233706.449054-7-michael@niedermayer.cc> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230712233706.449054-1-michael@niedermayer.cc> References: <20230712233706.449054-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 07/14] avradio/rds: Implement RadioText Plus 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: Signed-off-by: Michael Niedermayer --- libavradio/rds.c | 44 ++++++++++++++++++++++++++++++++++++++++- libavradio/sdr.h | 7 +++++++ libavradio/vissualize.c | 5 +++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/libavradio/rds.c b/libavradio/rds.c index e121c9db8e..30e4209ae8 100644 --- a/libavradio/rds.c +++ b/libavradio/rds.c @@ -143,6 +143,17 @@ static int decode_rds_group(SDRContext *sdr, Station *station, uint16_t group[4] AV_WB16(station->radiotext + 4*(group[1]&15) + 2, group[3]); } break;} + case 3: + if (!b) { + int application_id = group[3]; + switch (application_id) { + case 0x4BD7: + //RadioText Plus / RT+ for group 2A RT - IEC 62106-6:2023 + station->rtp_appgroup = group[1] & 31; + break; + } + } + break; case 10: if (b==0) { AV_WB16(station->programm_type_name + 4*(group[1]&1) , group[2]); @@ -152,7 +163,38 @@ static int decode_rds_group(SDRContext *sdr, Station *station, uint16_t group[4] // case 14: // break; default: - av_log(sdr->avfmt, AV_LOG_DEBUG, "RDS: PI %X, A %X B %X PTY %X\n", pi,a,b,pty); + if (2*a + b == station->rtp_appgroup) { + int toggle_bit = group[1]&16; + int running_bit = group[1]&8; + uint64_t v = ((group[1]&7LL)<<32) + ((uint64_t)group[2]<<16) + group[3]; + int tag[2][3]; + if (toggle_bit != station->rtp_toggle_bit) { + station->artist[0] = + station->title[0] = + station->album[0] = 0; + } + station->rtp_toggle_bit = toggle_bit; + for(int i = 0; i<6; i++) { + tag[i/3][i%3] = (v>>29) & 63; + v <<= 6; + } + tag[1][2] >>= 1; + av_log(0,0, "\n"); + for(int i = 0; i<2; i++) { + char *target= NULL; + switch(tag[i][0]) { + case 1: target = station->title; break; + case 2: target = station->album; break; + case 4: target = station->artist; break; + default: + av_log(sdr->avfmt, AV_LOG_DEBUG, "Unhandled RT+ code %d\n", tag[i][0]); + } + if (target) { + memcpy(target, station->radiotext + tag[i][1], 1 + tag[i][2]); + target[1+tag[i][2]] = 0; + } + } + } } return 0; diff --git a/libavradio/sdr.h b/libavradio/sdr.h index 4b3e14da02..ac6b7dffe0 100644 --- a/libavradio/sdr.h +++ b/libavradio/sdr.h @@ -72,10 +72,17 @@ typedef enum Modulation { typedef struct Station { char name[9]; + char radiotext[65]; + char artist[65]; + char title[65]; + char album[65]; char programm_type_name[9]; int program_id[2]; uint8_t rt_ab_flag; + uint8_t rtp_toggle_bit; + uint8_t rtp_running_bit; + uint16_t rtp_appgroup; enum Modulation modulation; double frequency; diff --git a/libavradio/vissualize.c b/libavradio/vissualize.c index d87ca167de..a3dcf5801b 100644 --- a/libavradio/vissualize.c +++ b/libavradio/vissualize.c @@ -221,6 +221,11 @@ int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, AVPacket *pkt) if (s->radiotext[0]) { draw_string(pkt->data, 4*w, s->radiotext, xmid + 8*yd, 320*h2 + 24*yd, xd, yd, color, color, color, w, h); } + if (s->title[0] || s->artist[0]) { + int len = strlen(s->title) + 1; + draw_string(pkt->data, 4*w, s->title , xmid + 8*yd, 320*h2 + 2*24*yd, xd, yd, color, color*1.5, color, w, h); + draw_string(pkt->data, 4*w, s->artist, xmid + 8*yd + 9*xd*len, 320*h2 + 2*24*yd + 9*yd*len, xd, yd, color, color*2, color, w, h); + } } } -- 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".