Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 07/14] avradio/rds: Implement RadioText Plus
Date: Thu, 13 Jul 2023 01:36:59 +0200
Message-ID: <20230712233706.449054-7-michael@niedermayer.cc> (raw)
In-Reply-To: <20230712233706.449054-1-michael@niedermayer.cc>

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 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".

  parent reply	other threads:[~2023-07-12 23:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-12 23:36 [FFmpeg-devel] [PATCH 01/14] avradio/rds: reset station timeout on successfull group decode Michael Niedermayer
2023-07-12 23:36 ` [FFmpeg-devel] [PATCH 02/14] avradio/sdr: Factor demodulate_all_fm out Michael Niedermayer
2023-07-12 23:36 ` [FFmpeg-devel] [PATCH 03/14] avradio/sdrdemux: require better timeout for replacing station Michael Niedermayer
2023-07-12 23:36 ` [FFmpeg-devel] [PATCH 04/14] avradio/sdrdemux: Compute FM station frequency more exactly Michael Niedermayer
2023-07-12 23:36 ` [FFmpeg-devel] [PATCH 05/14] avradio/sdrdemux: basic warning cleanup Michael Niedermayer
2023-07-12 23:36 ` [FFmpeg-devel] [PATCH 06/14] avradio/rds: Implement clearing radio text Michael Niedermayer
2023-07-12 23:36 ` Michael Niedermayer [this message]
2023-07-12 23:37 ` [FFmpeg-devel] [PATCH 08/14] avradio/rds: Better file title Michael Niedermayer
2023-07-12 23:37 ` [FFmpeg-devel] [PATCH 09/14] remove stray av_log() Michael Niedermayer
2023-07-12 23:37 ` [FFmpeg-devel] [PATCH 10/14] avradio/sdrdemux: Export RT+ metadata updates Michael Niedermayer
2023-07-12 23:37 ` [FFmpeg-devel] [PATCH 11/14] avradio/sdrdemux: Basic prefilter for RDS Michael Niedermayer
2023-07-12 23:37 ` [FFmpeg-devel] [PATCH 12/14] avradio/sdrdemux: Reduce FM audio bandwidth down toward reality Michael Niedermayer
2023-07-12 23:37 ` [FFmpeg-devel] [PATCH 13/14] avradio/sdrdemux: deemphasis filter fixes Michael Niedermayer
2023-07-12 23:37 ` [FFmpeg-devel] [PATCH 14/14] avradio/sdrdemux: Print log_debug level message on metadata changes Michael Niedermayer
2023-07-13 19:50 ` [FFmpeg-devel] [PATCH 01/14] avradio/rds: reset station timeout on successfull group decode Michael Niedermayer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230712233706.449054-7-michael@niedermayer.cc \
    --to=michael@niedermayer.cc \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git