From bff384e67794d625405f3524ee9ed6994eb52ae5 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 13 Jan 2017 15:46:41 +0300 Subject: [PATCH] Refactored CEA-708 symbol struct --- src/lib_ccx/ccx_decoders_708.c | 2 +- src/lib_ccx/ccx_decoders_708.h | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lib_ccx/ccx_decoders_708.c b/src/lib_ccx/ccx_decoders_708.c index cea0f84b..b9c24484 100644 --- a/src/lib_ccx/ccx_decoders_708.c +++ b/src/lib_ccx/ccx_decoders_708.c @@ -1246,7 +1246,7 @@ int _dtvcc_handle_G0(ccx_dtvcc_service_decoder *decoder, unsigned char *data, in ccx_common_logging.debug_ftn(CCX_DMT_708, "[CEA-708] G0: [%02X] (%c)\n", c, c); ccx_dtvcc_symbol sym; if (c == 0x7F) { // musical note replaces the Delete command code in ASCII - sym.sym = CCX_DTVCC_MUSICAL_NOTE_CHAR; + CCX_DTVCC_SYM_SET(sym, CCX_DTVCC_MUSICAL_NOTE_CHAR); } else { unsigned char uc = dtvcc_get_internal_from_G0(c); CCX_DTVCC_SYM_SET(sym, uc); diff --git a/src/lib_ccx/ccx_decoders_708.h b/src/lib_ccx/ccx_decoders_708.h index a801a923..5481b13b 100644 --- a/src/lib_ccx/ccx_decoders_708.h +++ b/src/lib_ccx/ccx_decoders_708.h @@ -250,17 +250,14 @@ typedef struct ccx_dtvcc_window_attribs typedef struct ccx_dtvcc_symbol { unsigned short sym; //symbol itself, at least 16 bit - unsigned char len; //length. could be 1 or 2 + unsigned char init; //initialized or not. could be 0 or 1 } ccx_dtvcc_symbol; -#define CCX_DTVCC_SYM_SET(x, c) {x.len = 1; x.sym = c;} -#define CCX_DTVCC_SYM_SET_16(x, c1, c2) {x.len = 2; x.sym = (c1 << 8) | c2;} -#define CCX_DTVCC_SYM_IS_16(x) (x.len == 2) +#define CCX_DTVCC_SYM_SET(x, c) {x.init = 1; x.sym = c;} +#define CCX_DTVCC_SYM_SET_16(x, c1, c2) {x.init = 1; x.sym = (c1 << 8) | c2;} #define CCX_DTVCC_SYM(x) ((unsigned char)(x.sym)) -#define CCX_DTVCC_SYM_16_FIRST(x) ((unsigned char)(x.sym >> 8)) -#define CCX_DTVCC_SYM_16_SECOND(x) ((unsigned char)(x.sym & 0xff)) -#define CCX_DTVCC_SYM_IS_EMPTY(x) (x.len == 0) -#define CCX_DTVCC_SYM_IS_SET(x) (x.len > 0) +#define CCX_DTVCC_SYM_IS_EMPTY(x) (x.init == 0) +#define CCX_DTVCC_SYM_IS_SET(x) (x.init == 1) typedef struct ccx_dtvcc_window {