Commit 360e93b0 authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/table/cat*: Cleanup

- Use bool for structure members that are used as bools
- Indentation
parent 9df18100
...@@ -71,14 +71,14 @@ bool dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback, ...@@ -71,14 +71,14 @@ bool dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback,
p_cat_decoder->i_section_max_size = 1024; p_cat_decoder->i_section_max_size = 1024;
/* PSI decoder initial state */ /* PSI decoder initial state */
p_cat_decoder->i_continuity_counter = 31; p_cat_decoder->i_continuity_counter = 31;
p_cat_decoder->b_discontinuity = 1; p_cat_decoder->b_discontinuity = true;
p_cat_decoder->p_current_section = NULL; p_cat_decoder->p_current_section = NULL;
/* CAT decoder configuration */ /* CAT decoder configuration */
p_cat_decoder->pf_cat_callback = pf_callback; p_cat_decoder->pf_cat_callback = pf_callback;
p_cat_decoder->p_cb_data = p_cb_data; p_cat_decoder->p_cb_data = p_cb_data;
/* CAT decoder initial state */ /* CAT decoder initial state */
p_cat_decoder->b_current_valid = 0; p_cat_decoder->b_current_valid = false;
p_cat_decoder->p_building_cat = NULL; p_cat_decoder->p_building_cat = NULL;
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
p_cat_decoder->ap_sections[i] = NULL; p_cat_decoder->ap_sections[i] = NULL;
...@@ -117,8 +117,7 @@ void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi) ...@@ -117,8 +117,7 @@ void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi)
***************************************************************************** *****************************************************************************
* Initialize a pre-allocated dvbpsi_cat_t structure. * Initialize a pre-allocated dvbpsi_cat_t structure.
*****************************************************************************/ *****************************************************************************/
void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat, void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat, uint8_t i_version, bool b_current_next)
uint8_t i_version, int b_current_next)
{ {
p_cat->i_version = i_version; p_cat->i_version = i_version;
p_cat->b_current_next = b_current_next; p_cat->b_current_next = b_current_next;
...@@ -176,15 +175,8 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -176,15 +175,8 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
dvbpsi_cat_decoder_t* p_cat_decoder dvbpsi_cat_decoder_t* p_cat_decoder
= (dvbpsi_cat_decoder_t*)p_dvbpsi->p_private; = (dvbpsi_cat_decoder_t*)p_dvbpsi->p_private;
int b_append = 1; bool b_append = true;
int b_reinit = 0; bool b_reinit = false;
dvbpsi_debug(p_dvbpsi, "CAT decoder",
"Table version %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
if (p_section->i_table_id != 0x01) if (p_section->i_table_id != 0x01)
{ {
...@@ -192,7 +184,8 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -192,7 +184,8 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
dvbpsi_error(p_dvbpsi, "CAT decoder", dvbpsi_error(p_dvbpsi, "CAT decoder",
"invalid section (table_id == 0x%02x)", "invalid section (table_id == 0x%02x)",
p_section->i_table_id); p_section->i_table_id);
b_append = 0; dvbpsi_DeletePSISections(p_section);
return;
} }
if (b_append && !p_section->b_syntax_indicator) if (b_append && !p_section->b_syntax_indicator)
...@@ -200,16 +193,24 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -200,16 +193,24 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
/* Invalid section_syntax_indicator */ /* Invalid section_syntax_indicator */
dvbpsi_error(p_dvbpsi, "CAT decoder", dvbpsi_error(p_dvbpsi, "CAT decoder",
"invalid section (section_syntax_indicator == 0)"); "invalid section (section_syntax_indicator == 0)");
b_append = 0; dvbpsi_DeletePSISections(p_section);
return;
} }
dvbpsi_debug(p_dvbpsi, "CAT decoder",
"Table version %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
if (b_append) if (b_append)
{ {
/* TS discontinuity check */ /* TS discontinuity check */
if (p_cat_decoder->b_discontinuity) if (p_cat_decoder->b_discontinuity)
{ {
b_reinit = 1; b_reinit = true;
p_cat_decoder->b_discontinuity = 0; p_cat_decoder->b_discontinuity = false;
} }
else else
{ {
...@@ -222,7 +223,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -222,7 +223,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
dvbpsi_error(p_dvbpsi, "CAT decoder", dvbpsi_error(p_dvbpsi, "CAT decoder",
"'version_number' differs" "'version_number' differs"
" whereas no discontinuity has occured"); " whereas no discontinuity has occured");
b_reinit = 1; b_reinit = true;
} }
else if (p_cat_decoder->i_last_section_number else if (p_cat_decoder->i_last_section_number
!= p_section->i_last_number) != p_section->i_last_number)
...@@ -231,7 +232,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -231,7 +232,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
dvbpsi_error(p_dvbpsi, "CAT decoder", dvbpsi_error(p_dvbpsi, "CAT decoder",
"'last_section_number' differs" "'last_section_number' differs"
" whereas no discontinuity has occured"); " whereas no discontinuity has occured");
b_reinit = 1; b_reinit = true;
} }
} }
else else
...@@ -242,7 +243,8 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -242,7 +243,8 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
p_section->b_current_next)) p_section->b_current_next))
{ {
/* Don't decode since this version is already decoded */ /* Don't decode since this version is already decoded */
b_append = 0; dvbpsi_DeletePSISections(p_section);
return;
} }
} }
} }
...@@ -252,7 +254,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -252,7 +254,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
if (b_reinit) if (b_reinit)
{ {
/* Force redecoding */ /* Force redecoding */
p_cat_decoder->b_current_valid = 0; p_cat_decoder->b_current_valid = false;
/* Free structures */ /* Free structures */
if (p_cat_decoder->p_building_cat) if (p_cat_decoder->p_building_cat)
{ {
...@@ -273,7 +275,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -273,7 +275,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
/* Append the section to the list if wanted */ /* Append the section to the list if wanted */
if (b_append) if (b_append)
{ {
int b_complete = 0; int b_complete = false;
/* Initialize the structures if it's the first section received */ /* Initialize the structures if it's the first section received */
if (!p_cat_decoder->p_building_cat) if (!p_cat_decoder->p_building_cat)
...@@ -304,7 +306,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -304,7 +306,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
break; break;
if (i == p_cat_decoder->i_last_section_number) if (i == p_cat_decoder->i_last_section_number)
b_complete = 1; b_complete = true;
} }
if (b_complete) if (b_complete)
...@@ -377,8 +379,8 @@ dvbpsi_psi_section_t* dvbpsi_GenCATSections(dvbpsi_t* p_dvbpsi, dvbpsi_cat_t* p_ ...@@ -377,8 +379,8 @@ dvbpsi_psi_section_t* dvbpsi_GenCATSections(dvbpsi_t* p_dvbpsi, dvbpsi_cat_t* p_
dvbpsi_descriptor_t* p_descriptor = p_cat->p_first_descriptor; dvbpsi_descriptor_t* p_descriptor = p_cat->p_first_descriptor;
p_current->i_table_id = 0x01; p_current->i_table_id = 0x01;
p_current->b_syntax_indicator = 1; p_current->b_syntax_indicator = true;
p_current->b_private_indicator = 0; p_current->b_private_indicator = false;
p_current->i_length = 9; /* header + CRC_32 */ p_current->i_length = 9; /* header + CRC_32 */
p_current->i_extension = 0; /* Not used in the CAT */ p_current->i_extension = 0; /* Not used in the CAT */
p_current->i_version = p_cat->i_version; p_current->i_version = p_cat->i_version;
...@@ -400,8 +402,8 @@ dvbpsi_psi_section_t* dvbpsi_GenCATSections(dvbpsi_t* p_dvbpsi, dvbpsi_cat_t* p_ ...@@ -400,8 +402,8 @@ dvbpsi_psi_section_t* dvbpsi_GenCATSections(dvbpsi_t* p_dvbpsi, dvbpsi_cat_t* p_
p_prev->p_next = p_current; p_prev->p_next = p_current;
p_current->i_table_id = 0x01; p_current->i_table_id = 0x01;
p_current->b_syntax_indicator = 1; p_current->b_syntax_indicator = true;
p_current->b_private_indicator = 0; p_current->b_private_indicator = false;
p_current->i_length = 9; /* header + CRC_32 */ p_current->i_length = 9; /* header + CRC_32 */
p_current->i_extension = 0; /* Not used in the CAT */ p_current->i_extension = 0; /* Not used in the CAT */
p_current->i_version = p_cat->i_version; p_current->i_version = p_cat->i_version;
......
...@@ -57,7 +57,7 @@ extern "C" { ...@@ -57,7 +57,7 @@ extern "C" {
typedef struct dvbpsi_cat_s typedef struct dvbpsi_cat_s
{ {
uint8_t i_version; /*!< version_number */ uint8_t i_version; /*!< version_number */
int b_current_next; /*!< current_next_indicator */ bool b_current_next; /*!< current_next_indicator */
dvbpsi_descriptor_t * p_first_descriptor; /*!< descriptor list */ dvbpsi_descriptor_t * p_first_descriptor; /*!< descriptor list */
...@@ -107,7 +107,7 @@ void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi); ...@@ -107,7 +107,7 @@ void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi);
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat, * \fn void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat,
uint8_t i_version, int b_current_next) uint8_t i_version, bool b_current_next)
* \brief Initialize a user-allocated dvbpsi_cat_t structure. * \brief Initialize a user-allocated dvbpsi_cat_t structure.
* \param p_cat pointer to the CAT structure * \param p_cat pointer to the CAT structure
* \param i_version CAT version * \param i_version CAT version
...@@ -115,7 +115,7 @@ void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi); ...@@ -115,7 +115,7 @@ void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi);
* \return nothing. * \return nothing.
*/ */
void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat, void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat,
uint8_t i_version, int b_current_next); uint8_t i_version, bool b_current_next);
/*! /*!
* \def dvbpsi_NewCAT(p_cat, * \def dvbpsi_NewCAT(p_cat,
......
...@@ -45,7 +45,7 @@ typedef struct dvbpsi_cat_decoder_s ...@@ -45,7 +45,7 @@ typedef struct dvbpsi_cat_decoder_s
dvbpsi_cat_t current_cat; dvbpsi_cat_t current_cat;
dvbpsi_cat_t * p_building_cat; dvbpsi_cat_t * p_building_cat;
int b_current_valid; bool b_current_valid;
uint8_t i_last_section_number; uint8_t i_last_section_number;
dvbpsi_psi_section_t * ap_sections [256]; dvbpsi_psi_section_t * ap_sections [256];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment