Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libdvbpsi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
libdvbpsi
Commits
20f6f247
Commit
20f6f247
authored
Apr 16, 2012
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATSC: descriptors refactor
- refactor descriptor structs allocations
parent
5886ce5e
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
83 additions
and
71 deletions
+83
-71
src/descriptors/dr_13.c
src/descriptors/dr_13.c
+15
-9
src/descriptors/dr_13.h
src/descriptors/dr_13.h
+6
-8
src/descriptors/dr_14.c
src/descriptors/dr_14.c
+23
-22
src/descriptors/dr_14.h
src/descriptors/dr_14.h
+10
-11
src/descriptors/dr_62.h
src/descriptors/dr_62.h
+0
-2
src/descriptors/dr_66.c
src/descriptors/dr_66.c
+17
-8
src/descriptors/dr_66.h
src/descriptors/dr_66.h
+6
-4
src/descriptors/dr_73.h
src/descriptors/dr_73.h
+2
-5
src/descriptors/dr_83.h
src/descriptors/dr_83.h
+2
-2
src/dvbpsi_private.h
src/dvbpsi_private.h
+2
-0
No files found.
src/descriptors/dr_13.c
View file @
20f6f247
...
@@ -33,6 +33,20 @@ Decode Carousel Id Descriptor.
...
@@ -33,6 +33,20 @@ Decode Carousel Id Descriptor.
#include "dr_13.h"
#include "dr_13.h"
static
dvbpsi_carousel_id_dr_t
*
NewCarouselDr
(
const
size_t
i_private
)
{
dvbpsi_carousel_id_dr_t
*
p_carousel
;
if
(
i_private
<=
0
)
return
NULL
;
p_carousel
=
(
dvbpsi_carousel_id_dr_t
*
)
calloc
(
1
,
sizeof
(
dvbpsi_carousel_id_dr_t
)
+
i_private
);
if
(
p_carousel
)
{
p_carousel
->
p_private_data
=
p_carousel
+
sizeof
(
dvbpsi_carousel_id_dr_t
);
p_carousel
->
i_private_data_len
=
i_private
;
}
return
p_carousel
;
}
/*****************************************************************************
/*****************************************************************************
* dvbpsi_DecodeCarouselIdDr
* dvbpsi_DecodeCarouselIdDr
...
@@ -53,18 +67,10 @@ dvbpsi_carousel_id_dr_t *dvbpsi_DecodeCarouselIdDr(dvbpsi_descriptor_t *p_descri
...
@@ -53,18 +67,10 @@ dvbpsi_carousel_id_dr_t *dvbpsi_DecodeCarouselIdDr(dvbpsi_descriptor_t *p_descri
if
(
p_descriptor
->
i_length
<
4
)
if
(
p_descriptor
->
i_length
<
4
)
return
NULL
;
return
NULL
;
p_decoded
=
(
dvbpsi_carousel_id_dr_t
*
)
malloc
(
sizeof
(
dvbpsi_carousel_id_dr_t
)
);
p_decoded
=
NewCarouselDr
(
p_descriptor
->
i_length
-
4
);
if
(
!
p_decoded
)
if
(
!
p_decoded
)
return
NULL
;
return
NULL
;
p_decoded
->
p_private_data
=
malloc
(
p_descriptor
->
i_length
-
4
);
if
(
!
p_decoded
->
s_private_data
)
{
free
(
p_decoded
);
return
NULL
;
}
p_decoded
->
i_private_data_len
=
p_descriptor
->
i_length
-
4
;
p_decoded
->
i_carousel_id
=
((
p_descriptor
->
p_data
[
0
]
&
0xff
)
<<
24
)
|
((
p_descriptor
->
p_data
[
1
]
&
0xff
)
<<
16
)
|
p_decoded
->
i_carousel_id
=
((
p_descriptor
->
p_data
[
0
]
&
0xff
)
<<
24
)
|
((
p_descriptor
->
p_data
[
1
]
&
0xff
)
<<
16
)
|
((
p_descriptor
->
p_data
[
2
]
&
0xff
)
<<
8
)
|
(
p_descriptor
->
p_data
[
3
]
&
0xff
);
((
p_descriptor
->
p_data
[
2
]
&
0xff
)
<<
8
)
|
(
p_descriptor
->
p_data
[
3
]
&
0xff
);
...
...
src/descriptors/dr_13.h
View file @
20f6f247
...
@@ -38,10 +38,12 @@ Decode Carousel id Descriptor.
...
@@ -38,10 +38,12 @@ Decode Carousel id Descriptor.
*/
*/
typedef
struct
dvbpsi_carousel_id_dr_s
typedef
struct
dvbpsi_carousel_id_dr_s
{
{
uint32_t
i_carousel_id
;
uint32_t
i_carousel_id
;
/*< carousel identifier */
uint8_t
i_private_data_len
;
uint8_t
i_private_data_len
;
/*< length of private data pointer in bytes */
uint8_t
*
p_private_data
;
/*< allocated memory must be released */
uint8_t
*
p_private_data
;
/*< memory is allocated right after sizeof struct,
}
dvbpsi_carousel_id_dr_t
;
when freeing this struct the private data is
freed at the same time. */
}
dvbpsi_carousel_id_dr_t
;
/*****************************************************************************
/*****************************************************************************
* dvbpsi_DecodeCarouselIdDr
* dvbpsi_DecodeCarouselIdDr
...
@@ -57,7 +59,3 @@ typedef struct dvbpsi_carousel_id_dr_s
...
@@ -57,7 +59,3 @@ typedef struct dvbpsi_carousel_id_dr_s
dvbpsi_carousel_id_dr_t
*
dvbpsi_DecodeCarouselIdDr
(
dvbpsi_descriptor_t
*
p_descriptor
);
dvbpsi_carousel_id_dr_t
*
dvbpsi_DecodeCarouselIdDr
(
dvbpsi_descriptor_t
*
p_descriptor
);
#endif
#endif
src/descriptors/dr_14.c
View file @
20f6f247
...
@@ -33,6 +33,25 @@ Decode Assocation Tag Descriptor.
...
@@ -33,6 +33,25 @@ Decode Assocation Tag Descriptor.
#include "dr_14.h"
#include "dr_14.h"
static
dvbpsi_association_tag_dr_t
*
NewAssociationTagDr
(
const
size_t
i_selector
,
const
size_t
i_private
)
{
dvbpsi_association_tag_dr_t
*
p_tag
;
if
((
i_selector
<=
0
)
||
(
i_private
<=
0
))
return
NULL
;
size_t
i_size
=
sizeof
(
dvbpsi_association_tag_dr_t
)
+
i_selector
+
i_private
;
p_tag
=
(
dvbpsi_association_tag_dr_t
*
)
calloc
(
1
,
i_size
);
if
(
p_tag
)
{
p_tag
->
p_selector
=
p_tag
+
sizeof
(
dvbpsi_association_tag_dr_t
);
p_tag
->
i_selector_len
=
i_selector
;
p_tag
->
p_private_data
=
p_tag
->
p_selector
+
i_selector
;
p_tag
->
i_private_data_len
=
i_private
;
}
return
p_tag
;
}
/*****************************************************************************
/*****************************************************************************
* dvbpsi_DecodeAssociationTagDr
* dvbpsi_DecodeAssociationTagDr
...
@@ -56,41 +75,23 @@ dvbpsi_association_tag_dr_t *dvbpsi_DecodeAssociationTagDr(dvbpsi_descriptor_t *
...
@@ -56,41 +75,23 @@ dvbpsi_association_tag_dr_t *dvbpsi_DecodeAssociationTagDr(dvbpsi_descriptor_t *
return
NULL
;
return
NULL
;
selector_len
=
p_descriptor
->
p_data
[
4
];
selector_len
=
p_descriptor
->
p_data
[
4
];
private_data_len
=
p_descriptor
->
i_length
-
(
5
+
selector_len
);
/* Invalid selector length */
/* Invalid selector length */
if
(
selector_len
+
5
>
p_descriptor
->
i_length
)
if
(
selector_len
+
5
>
p_descriptor
->
i_length
)
return
NULL
;
return
NULL
;
private_data_len
=
p_descriptor
->
i_length
-
(
5
+
selector_len
);
p_decoded
=
NewAssociationTagDr
(
selector_len
,
private_data_len
);
p_decoded
=
(
dvbpsi_association_tag_dr_t
*
)
malloc
(
sizeof
(
dvbpsi_association_tag_dr_t
));
if
(
!
p_decoded
)
if
(
!
p_decoded
)
return
NULL
;
return
NULL
;
p_decoded
->
p_selector
=
malloc
(
selector_len
);
if
(
!
p_decoded
->
p_selector
)
{
free
(
p_decoder
);
return
NULL
;
}
p_decoded
->
p_private_data
=
malloc
(
private_data_len
);
if
(
!
p_decoded
->
p_private_data
)
{
free
(
p_decoded
->
p_selector
);
free
(
p_decoder
);
return
NULL
;
}
p_decoded
->
i_tag
=
((
p_descriptor
->
p_data
[
0
]
&
0xff
)
<<
8
)
|
(
p_descriptor
->
p_data
[
1
]
&
0xff
);
p_decoded
->
i_tag
=
((
p_descriptor
->
p_data
[
0
]
&
0xff
)
<<
8
)
|
(
p_descriptor
->
p_data
[
1
]
&
0xff
);
p_decoded
->
i_use
=
((
p_descriptor
->
p_data
[
2
]
&
0xff
)
<<
8
)
|
(
p_descriptor
->
p_data
[
3
]
&
0xff
);
p_decoded
->
i_use
=
((
p_descriptor
->
p_data
[
2
]
&
0xff
)
<<
8
)
|
(
p_descriptor
->
p_data
[
3
]
&
0xff
);
p_decoded
->
i_selector_len
=
selector_len
;
p_decoded
->
i_private_data_len
=
private_data_len
;
p_decoded
->
p_selector
=
((
void
*
)
p_decoded
)
+
sizeof
(
dvbpsi_association_tag_dr_t
);
p_decoded
->
p_private_data
=
p_decoded
->
p_selector
+
selector_len
;
memcpy
(
p_decoded
->
p_selector
,
&
p_descriptor
->
p_data
[
5
],
selector_len
);
memcpy
(
p_decoded
->
p_selector
,
&
p_descriptor
->
p_data
[
5
],
selector_len
);
memcpy
(
p_decoded
->
p_private_data
,
&
p_descriptor
->
p_data
[
5
+
selector_len
],
private_data_len
);
memcpy
(
p_decoded
->
p_private_data
,
&
p_descriptor
->
p_data
[
5
+
selector_len
],
private_data_len
);
p_descriptor
->
p_decoded
=
(
void
*
)
p_decoded
;
p_descriptor
->
p_decoded
=
(
void
*
)
p_decoded
;
return
p_decoded
;
return
p_decoded
;
}
}
src/descriptors/dr_14.h
View file @
20f6f247
...
@@ -38,12 +38,16 @@ Decode Association Tag Descriptor.
...
@@ -38,12 +38,16 @@ Decode Association Tag Descriptor.
*/
*/
typedef
struct
dvbpsi_association_tag_dr_s
typedef
struct
dvbpsi_association_tag_dr_s
{
{
uint16_t
i_tag
;
uint16_t
i_tag
;
/*< association tag identifier */
uint16_t
i_use
;
uint16_t
i_use
;
/*< indicator if association tag identifier is in use */
uint8_t
i_selector_len
;
uint8_t
i_selector_len
;
/*< length of selector data in bytes */
uint8_t
*
p_selector
;
uint8_t
*
p_selector
;
/*< pointer to selector. Memory is allocated
uint8_t
i_private_data_len
;
right after sizeof struct, when freeing this
uint8_t
*
p_private_data
;
/*< release allocated memory */
struct the private data is freed at the same time. */
uint8_t
i_private_data_len
;
/*< length of private data segment in bytes */
uint8_t
*
p_private_data
;
/*< pointer to private data. Memory is allocated
right after sizeof struct, when freeing this
struct the private data is freed at the same time. */
}
dvbpsi_association_tag_dr_t
;
}
dvbpsi_association_tag_dr_t
;
/*****************************************************************************
/*****************************************************************************
...
@@ -60,8 +64,3 @@ typedef struct dvbpsi_association_tag_dr_s
...
@@ -60,8 +64,3 @@ typedef struct dvbpsi_association_tag_dr_s
dvbpsi_association_tag_dr_t
*
dvbpsi_DecodeAssociationTagDr
(
dvbpsi_descriptor_t
*
p_descriptor
);
dvbpsi_association_tag_dr_t
*
dvbpsi_DecodeAssociationTagDr
(
dvbpsi_descriptor_t
*
p_descriptor
);
#endif
#endif
src/descriptors/dr_62.h
View file @
20f6f247
...
@@ -77,5 +77,3 @@ uint32_t dvbpsi_Bcd8ToUint32(uint32_t bcd);
...
@@ -77,5 +77,3 @@ uint32_t dvbpsi_Bcd8ToUint32(uint32_t bcd);
#endif
#endif
#endif
#endif
src/descriptors/dr_66.c
View file @
20f6f247
...
@@ -33,6 +33,22 @@ Decode Data Broadcast Id Descriptor.
...
@@ -33,6 +33,22 @@ Decode Data Broadcast Id Descriptor.
#include "dr_66.h"
#include "dr_66.h"
static
dvbpsi_data_broadcast_id_dr_t
*
NewDataBroadcastDr
(
const
size_t
i_private
)
{
dvbpsi_data_broadcast_id_dr_t
*
p_bcast
;
if
(
i_private
<=
0
)
return
NULL
;
p_bcast
=
(
dvbpsi_data_broadcast_id_dr_t
*
)
calloc
(
1
,
sizeof
(
dvbpsi_data_broadcast_id_dr_t
)
+
i_private
);
if
(
p_bcast
)
{
p_bcast
->
p_id_selector
=
p_bcast
+
sizeof
(
dvbpsi_data_broadcast_id_dr_t
);
p_bcast
->
i_id_selector_len
=
i_private
;
}
return
p_bcast
;
}
/*****************************************************************************
/*****************************************************************************
* dvbpsi_DecodeDataBroadcastIdDr
* dvbpsi_DecodeDataBroadcastIdDr
...
@@ -53,18 +69,11 @@ dvbpsi_data_broadcast_id_dr_t *dvbpsi_DecodeDataBroadcastIdDr(dvbpsi_descriptor_
...
@@ -53,18 +69,11 @@ dvbpsi_data_broadcast_id_dr_t *dvbpsi_DecodeDataBroadcastIdDr(dvbpsi_descriptor_
if
(
p_descriptor
->
i_length
<
2
)
if
(
p_descriptor
->
i_length
<
2
)
return
NULL
;
return
NULL
;
p_decoded
=
(
dvbpsi_data_broadcast_id_dr_t
*
)
malloc
(
sizeof
(
dvbpsi_data_broadcast_id_dr_t
)
);
p_decoded
=
NewDataBroadcastDr
(
p_descriptor
->
i_length
-
2
);
if
(
!
p_decoded
)
if
(
!
p_decoded
)
return
NULL
;
return
NULL
;
p_decoded
->
p_id_selector
=
malloc
(
p_descriptor
->
i_length
-
2
);
if
(
!
p_decoded
->
p_id_selector
)
{
free
(
p_decoded
);
return
NULL
;
}
p_decoded
->
i_data_broadcast_id
=
((
p_descriptor
->
p_data
[
0
]
&
0xff
)
<<
8
)
|
(
p_descriptor
->
p_data
[
1
]
&
0xff
);
p_decoded
->
i_data_broadcast_id
=
((
p_descriptor
->
p_data
[
0
]
&
0xff
)
<<
8
)
|
(
p_descriptor
->
p_data
[
1
]
&
0xff
);
p_decoded
->
i_id_selector_len
=
p_descriptor
->
i_length
-
2
;
memcpy
(
p_decoded
->
p_id_selector
,
&
p_descriptor
->
p_data
[
2
],
p_decoded
->
i_id_selector_len
);
memcpy
(
p_decoded
->
p_id_selector
,
&
p_descriptor
->
p_data
[
2
],
p_decoded
->
i_id_selector_len
);
p_descriptor
->
p_decoded
=
(
void
*
)
p_decoded
;
p_descriptor
->
p_decoded
=
(
void
*
)
p_decoded
;
...
...
src/descriptors/dr_66.h
View file @
20f6f247
...
@@ -38,10 +38,12 @@ Decode Data Broadcast id Descriptor.
...
@@ -38,10 +38,12 @@ Decode Data Broadcast id Descriptor.
*/
*/
typedef
struct
dvbpsi_data_broadcast_id_dr_s
typedef
struct
dvbpsi_data_broadcast_id_dr_s
{
{
uint16_t
i_data_broadcast_id
;
uint16_t
i_data_broadcast_id
;
/*< broadcast identifier */
uint8_t
i_id_selector_len
;
uint8_t
i_id_selector_len
;
/*< length of selector data in bytes */
uint8_t
*
p_id_selector
;
/*< release allocated memory */
uint8_t
*
p_id_selector
;
/*< pointer to selector data. Memory is allocated
}
dvbpsi_data_broadcast_id_dr_t
;
right after sizeof struct, when freeing this
struct the private data is freed at the same time. */
}
dvbpsi_data_broadcast_id_dr_t
;
/*****************************************************************************
/*****************************************************************************
* dvbpsi_DecodeDataBroadcastIdDr
* dvbpsi_DecodeDataBroadcastIdDr
...
...
src/descriptors/dr_73.h
View file @
20f6f247
...
@@ -43,8 +43,8 @@ extern "C" {
...
@@ -43,8 +43,8 @@ extern "C" {
*/
*/
typedef
struct
dvbpsi_default_authority_dr_s
typedef
struct
dvbpsi_default_authority_dr_s
{
{
uint8_t
authority
[
255
];
uint8_t
authority
[
255
];
/*< default authorizty descriptor */
}
dvbpsi_default_authority_dr_t
;
}
dvbpsi_default_authority_dr_t
;
/*****************************************************************************
/*****************************************************************************
* dvbpsi_DecodeLCNDr
* dvbpsi_DecodeLCNDr
...
@@ -63,6 +63,3 @@ dvbpsi_default_authority_dr_t *dvbpsi_DecodeDefaultAuthorityDr(dvbpsi_descriptor
...
@@ -63,6 +63,3 @@ dvbpsi_default_authority_dr_t *dvbpsi_DecodeDefaultAuthorityDr(dvbpsi_descriptor
#endif
#endif
#endif
#endif
src/descriptors/dr_83.h
View file @
20f6f247
...
@@ -45,8 +45,8 @@ typedef struct dvbpsi_lcn_entry_s
...
@@ -45,8 +45,8 @@ typedef struct dvbpsi_lcn_entry_s
{
{
uint16_t
i_service_id
;
/*!< Service ID this logical channel number refers to */
uint16_t
i_service_id
;
/*!< Service ID this logical channel number refers to */
int
b_visible_service_flag
;
/*!< Whether this LCN should be visible to the user. */
int
b_visible_service_flag
;
/*!< Whether this LCN should be visible to the user. */
uint16_t
i_logical_channel_number
;
/*!<The logical channel number for this service. */
uint16_t
i_logical_channel_number
;
/*!<
The logical channel number for this service. */
}
dvbpsi_lcn_entry_t
;
}
dvbpsi_lcn_entry_t
;
/*****************************************************************************
/*****************************************************************************
* dvbpsi_lcn_dr_s
* dvbpsi_lcn_dr_s
...
...
src/dvbpsi_private.h
View file @
20f6f247
...
@@ -30,6 +30,8 @@
...
@@ -30,6 +30,8 @@
#include <stdarg.h>
#include <stdarg.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
extern
uint32_t
dvbpsi_crc32_table
[];
extern
uint32_t
dvbpsi_crc32_table
[];
/*****************************************************************************
/*****************************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment