@@ -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]);
@@ -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
This allows detecting more damaged blocks Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavradio/rds.c | 16 ++++++++++++++++ libavradio/sdr.h | 1 + 2 files changed, 17 insertions(+)