diff mbox series

[FFmpeg-devel,06/14] avradio/rds: Implement clearing radio text

Message ID 20230712233706.449054-6-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,01/14] avradio/rds: reset station timeout on successfull group decode | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch
yinshiyou/configure_loongarch64 warning Failed to apply patch

Commit Message

Michael Niedermayer July 12, 2023, 11:36 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavradio/rds.c | 9 +++++++--
 libavradio/sdr.h | 2 ++
 2 files changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavradio/rds.c b/libavradio/rds.c
index 55b24a0d9e..e121c9db8e 100644
--- a/libavradio/rds.c
+++ b/libavradio/rds.c
@@ -130,14 +130,19 @@  static int decode_rds_group(SDRContext *sdr, Station *station, uint16_t group[4]
     case 0:
         AV_WB16(station->name + 2*(group[1]&3), group[3]);
     break;
-    case 2:
+    case 2:{
+        int new_ab_flag = group[1] & 16;
+        if (new_ab_flag != station->rt_ab_flag) {
+            memset(station->radiotext, 0, sizeof(station->radiotext));
+            station->rt_ab_flag = new_ab_flag;
+        }
         if (b) {
             AV_WB16(station->radiotext + 2*(group[1]&15)    , group[3]);
         } else {
             AV_WB16(station->radiotext + 4*(group[1]&15)    , group[2]);
             AV_WB16(station->radiotext + 4*(group[1]&15) + 2, group[3]);
         }
-    break;
+    break;}
     case 10:
         if (b==0) {
             AV_WB16(station->programm_type_name + 4*(group[1]&1)    , group[2]);
diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 29ac4a2963..4b3e14da02 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -75,6 +75,8 @@  typedef struct Station {
     char radiotext[65];
     char programm_type_name[9];
     int program_id[2];
+    uint8_t rt_ab_flag;
+
     enum Modulation modulation;
     double frequency;
     int nb_frequency;       ///< number of detections which are used to compute the frequency