Commit 0403df3e authored by Jean-Paul Saman's avatar Jean-Paul Saman

dr_54: Various fixes

- add boundary checking
- add doxygen comment
- fix some typos.
- fix L1L2MERGE macro
parent cdee453c
...@@ -64,6 +64,8 @@ dvbpsi_content_dr_t * dvbpsi_DecodeContentDr( ...@@ -64,6 +64,8 @@ dvbpsi_content_dr_t * dvbpsi_DecodeContentDr(
return NULL; return NULL;
int i_contents_number = p_descriptor->i_length / 2; int i_contents_number = p_descriptor->i_length / 2;
if (i_contents_number > DVBPSI_CONTENT_DR_MAX)
i_contents_number = DVBPSI_CONTENT_DR_MAX;
p_decoded->i_contents_number = i_contents_number; p_decoded->i_contents_number = i_contents_number;
for (int i = 0; i < i_contents_number; i++) for (int i = 0; i < i_contents_number; i++)
...@@ -85,6 +87,9 @@ dvbpsi_descriptor_t * dvbpsi_GenContentDr( ...@@ -85,6 +87,9 @@ dvbpsi_descriptor_t * dvbpsi_GenContentDr(
dvbpsi_content_dr_t * p_decoded, dvbpsi_content_dr_t * p_decoded,
bool b_duplicate) bool b_duplicate)
{ {
if (p_decoded->i_contents_number > DVBPSI_CONTENT_DR_MAX)
p_decoded->i_contents_number = DVBPSI_CONTENT_DR_MAX;
/* Create the descriptor */ /* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x54, p_decoded->i_contents_number * 2 , NULL); dvbpsi_NewDescriptor(0x54, p_decoded->i_contents_number * 2 , NULL);
......
...@@ -34,9 +34,10 @@ ...@@ -34,9 +34,10 @@
extern "C" { extern "C" {
#endif #endif
#define DVDPSI_GetContentCategoryFromType(type) (type >> 4) #define DVDPSI_GetContentCategoryFromType(type) ((type) >> 4)
#define L1L2MERGE(L1,L2) ( ( DVBPSI_CONTENT_CAT ## L1<<4) | (L2) )
#define L1L2MERGE(L1,L2) ( ( DVBPSI_CONTENT ## L1<<4) | L2 )
#define DVBPSI_CONTENT_CAT_UNDEFINED 0x0 #define DVBPSI_CONTENT_CAT_UNDEFINED 0x0
#define DVBPSI_CONTENT_CAT_MOVIE 0x1 #define DVBPSI_CONTENT_CAT_MOVIE 0x1
#define DVBPSI_CONTENT_CAT_NEWS 0x2 #define DVBPSI_CONTENT_CAT_NEWS 0x2
...@@ -51,7 +52,7 @@ extern "C" { ...@@ -51,7 +52,7 @@ extern "C" {
#define DVBPSI_CONTENT_CAT_SPECIAL 0xb #define DVBPSI_CONTENT_CAT_SPECIAL 0xb
#define DVBPSI_CONTENT_CAT_USERDEFINED 0xf #define DVBPSI_CONTENT_CAT_USERDEFINED 0xf
/* Movie/Drama */ /* Movie/Drama */
#define DVBPSI_CONTENT_MOVIE_GENERAL L1L2MERGE( _MOVIE, 0x0 ) #define DVBPSI_CONTENT_MOVIE_GENERAL L1L2MERGE( _MOVIE, 0x0 )
#define DVBPSI_CONTENT_MOVIE_DETECTIVE L1L2MERGE( _MOVIE, 0x1 ) #define DVBPSI_CONTENT_MOVIE_DETECTIVE L1L2MERGE( _MOVIE, 0x1 )
#define DVBPSI_CONTENT_MOVIE_ADVENTURE L1L2MERGE( _MOVIE, 0x2 ) #define DVBPSI_CONTENT_MOVIE_ADVENTURE L1L2MERGE( _MOVIE, 0x2 )
...@@ -157,7 +158,6 @@ extern "C" { ...@@ -157,7 +158,6 @@ extern "C" {
#define DVBPSI_CONTENT_SPECIAL_USERDEFINED2 L1L2MERGE( _SPECIAL, 0xd ) #define DVBPSI_CONTENT_SPECIAL_USERDEFINED2 L1L2MERGE( _SPECIAL, 0xd )
#define DVBPSI_CONTENT_SPECIAL_USERDEFINED3 L1L2MERGE( _SPECIAL, 0xe ) #define DVBPSI_CONTENT_SPECIAL_USERDEFINED3 L1L2MERGE( _SPECIAL, 0xe )
#define DVBPSI_CONTENT_SPECIAL_USERDEFINED4 L1L2MERGE( _SPECIAL, 0xf ) #define DVBPSI_CONTENT_SPECIAL_USERDEFINED4 L1L2MERGE( _SPECIAL, 0xf )
#undef L1L2MERGE
/***************************************************************************** /*****************************************************************************
* dvbpsi_content_t * dvbpsi_content_t
...@@ -180,6 +180,11 @@ typedef struct dvbpsi_content_s ...@@ -180,6 +180,11 @@ typedef struct dvbpsi_content_s
} dvbpsi_content_t; } dvbpsi_content_t;
/*!
* \def DVBPSI_CONTENT_DR_MAX
* \brief Maximum number of dvbps_content_t entries present in @see dvbpsi_content_dr_t
*/
#define DVBPSI_CONTENT_DR_MAX 64
/***************************************************************************** /*****************************************************************************
* dvbpsi_content_dr_t * dvbpsi_content_dr_t
...@@ -198,7 +203,7 @@ typedef struct dvbpsi_content_s ...@@ -198,7 +203,7 @@ typedef struct dvbpsi_content_s
typedef struct dvbpsi_content_dr_s typedef struct dvbpsi_content_dr_s
{ {
uint8_t i_contents_number; /*!< number of content */ uint8_t i_contents_number; /*!< number of content */
dvbpsi_content_t p_content[64]; /*!< parental rating table */ dvbpsi_content_t p_content[DVBPSI_CONTENT_DR_MAX]; /*!< parental rating table */
} dvbpsi_content_dr_t; } dvbpsi_content_dr_t;
...@@ -241,6 +246,5 @@ dvbpsi_descriptor_t * dvbpsi_GenContentDr( ...@@ -241,6 +246,5 @@ dvbpsi_descriptor_t * dvbpsi_GenContentDr(
#endif #endif
#else #else
#error "Multiple inclusions of dr_55.h" #error "Multiple inclusions of dr_54.h"
#endif #endif
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