From d003ce16227faedba1525bbb7e804af9044ee632 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Thu, 2 Jan 2020 11:48:29 +0000 Subject: [PATCH] Don't store invalid user codes. --- tools/library/tbc/testvbidecoder/testvbidecoder.cpp | 4 ---- tools/library/tbc/vbidecoder.cpp | 12 +++++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/library/tbc/testvbidecoder/testvbidecoder.cpp b/tools/library/tbc/testvbidecoder/testvbidecoder.cpp index 5f1c42740..e27acc6d6 100644 --- a/tools/library/tbc/testvbidecoder/testvbidecoder.cpp +++ b/tools/library/tbc/testvbidecoder/testvbidecoder.cpp @@ -77,8 +77,6 @@ void testDecode() // the standard says shouldn't work (e.g. invalid BCD digits), and for // things that discs do anyway regardless of what the standard says :-) - // FIXME - #if 0 blocks are tests that should pass but don't - cerr << "Testing VbiDecoder::decode\n"; cerr << "IEC 60857-1986 - 10.1.1 Lead-in\n"; @@ -283,10 +281,8 @@ void testDecode() { Vbi expected; -#if 0 // Ignore X1 not in range 0-7 assertSame(decoder.decode(0x88DAFE, 0, 0), expected); -#endif } cerr << "IEC 60857-1986 - 10.1.10 CLV picture number\n"; diff --git a/tools/library/tbc/vbidecoder.cpp b/tools/library/tbc/vbidecoder.cpp index 5e321cc94..9848d6828 100644 --- a/tools/library/tbc/vbidecoder.cpp +++ b/tools/library/tbc/vbidecoder.cpp @@ -549,11 +549,13 @@ VbiDecoder::Vbi VbiDecoder::decode(qint32 vbi16, qint32 vbi17, qint32 vbi18) quint32 x3x4x5 = (usersCode & 0x000FFF); // x1 should be 0x00-0x07, x3-x5 are 0x00-0x0F - if (x1 > 7) if (verboseDebug) qDebug() << "VbiDecoder::decode(): VBI invalid user code, X1 is > 7"; - - // Add the two results together to get the user code - vbi.userCode = QString::number(x1, 16).toUpper() + QString::number(x3x4x5, 16).toUpper(); - if (verboseDebug) qDebug() << "VbiDecoder::decode(): VBI user code is" << vbi.userCode; + if (x1 > 7) { + if (verboseDebug) qDebug() << "VbiDecoder::decode(): VBI invalid user code, X1 is > 7"; + } else { + // Add the two results together to get the user code + vbi.userCode = QString::number(x1, 16).toUpper() + QString::number(x3x4x5, 16).toUpper(); + if (verboseDebug) qDebug() << "VbiDecoder::decode(): VBI user code is" << vbi.userCode; + } } // IEC 60857-1986 - 10.1.10 CLV picture number --------------------------------------------------------------------