This allows detecting more damaged blocks Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> --- 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-requ...@ffmpeg.org with subject "unsubscribe".