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
dc475fd5
Commit
dc475fd5
authored
Feb 14, 2011
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src/table/pat*: Cleanup
- Use bool for structure members that are used as bools - Indentation
parent
4fc878e7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
141 additions
and
151 deletions
+141
-151
src/tables/pat.c
src/tables/pat.c
+139
-149
src/tables/pat.h
src/tables/pat.h
+1
-1
src/tables/pat_private.h
src/tables/pat_private.h
+1
-1
No files found.
src/tables/pat.c
View file @
dc475fd5
/*****************************************************************************
* pat.c: PAT decoder/generator
*----------------------------------------------------------------------------
* Copyright (C) 2001-201
0
VideoLAN
* Copyright (C) 2001-201
1
VideoLAN
* $Id$
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
...
...
@@ -66,7 +66,7 @@ bool dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback,
/* PSI decoder initial state */
p_pat_decoder
->
i_continuity_counter
=
31
;
p_pat_decoder
->
b_discontinuity
=
1
;
p_pat_decoder
->
b_discontinuity
=
true
;
p_pat_decoder
->
p_current_section
=
NULL
;
/* PAT decoder information */
...
...
@@ -74,7 +74,7 @@ bool dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback,
p_pat_decoder
->
p_cb_data
=
p_cb_data
;
/* PAT decoder initial state */
p_pat_decoder
->
b_current_valid
=
0
;
p_pat_decoder
->
b_current_valid
=
false
;
p_pat_decoder
->
p_building_pat
=
NULL
;
for
(
unsigned
int
i
=
0
;
i
<=
255
;
i
++
)
...
...
@@ -110,7 +110,6 @@ void dvbpsi_DetachPAT(dvbpsi_t *p_dvbpsi)
p_dvbpsi
->
p_private
=
NULL
;
}
/*****************************************************************************
* dvbpsi_InitPAT
*****************************************************************************
...
...
@@ -125,7 +124,6 @@ void dvbpsi_InitPAT(dvbpsi_pat_t* p_pat, uint16_t i_ts_id, uint8_t i_version,
p_pat
->
p_first_program
=
NULL
;
}
/*****************************************************************************
* dvbpsi_EmptyPAT
*****************************************************************************
...
...
@@ -144,7 +142,6 @@ void dvbpsi_EmptyPAT(dvbpsi_pat_t* p_pat)
p_pat
->
p_first_program
=
NULL
;
}
/*****************************************************************************
* dvbpsi_PATAddProgram
*****************************************************************************
...
...
@@ -176,7 +173,6 @@ dvbpsi_pat_program_t* dvbpsi_PATAddProgram(dvbpsi_pat_t* p_pat,
return
p_program
;
}
/*****************************************************************************
* dvbpsi_GatherPATSections
*****************************************************************************
...
...
@@ -185,59 +181,58 @@ dvbpsi_pat_program_t* dvbpsi_PATAddProgram(dvbpsi_pat_t* p_pat,
void
dvbpsi_GatherPATSections
(
dvbpsi_t
*
p_dvbpsi
,
dvbpsi_psi_section_t
*
p_section
)
{
dvbpsi_pat_decoder_t
*
p_pat_decoder
;
int
b_append
=
1
;
int
b_reinit
=
0
;
bool
b_reinit
=
false
;
assert
(
p_dvbpsi
);
assert
(
p_dvbpsi
->
p_private
);
dvbpsi_debug
(
p_dvbpsi
,
"PAT 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
);
p_pat_decoder
=
(
dvbpsi_pat_decoder_t
*
)
p_dvbpsi
->
p_private
;
if
(
p_section
->
i_table_id
!=
0x00
)
if
(
p_section
->
i_table_id
!=
0x00
)
{
/* Invalid table_id value */
dvbpsi_error
(
p_dvbpsi
,
"PAT decoder"
,
"invalid section (table_id == 0x%02x)"
,
p_section
->
i_table_id
);
b_append
=
0
;
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
if
(
b_append
&&
!
p_section
->
b_syntax_indicator
)
if
(
!
p_section
->
b_syntax_indicator
)
{
/* Invalid section_syntax_indicator */
dvbpsi_error
(
p_dvbpsi
,
"PAT decoder"
,
"invalid section (section_syntax_indicator == 0)"
);
b_append
=
0
;
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
/* Now if b_append is true then we have a valid PAT section */
if
(
b_append
)
{
/* Now we have a valid PAT section */
dvbpsi_debug
(
p_dvbpsi
,
"PAT 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
);
p_pat_decoder
=
(
dvbpsi_pat_decoder_t
*
)
p_dvbpsi
->
p_private
;
/* TS discontinuity check */
if
(
p_pat_decoder
->
b_discontinuity
)
if
(
p_pat_decoder
->
b_discontinuity
)
{
b_reinit
=
1
;
p_pat_decoder
->
b_discontinuity
=
0
;
b_reinit
=
true
;
p_pat_decoder
->
b_discontinuity
=
false
;
}
else
{
/* Perform a few sanity checks */
if
(
p_pat_decoder
->
p_building_pat
)
if
(
p_pat_decoder
->
p_building_pat
)
{
if
(
p_pat_decoder
->
p_building_pat
->
i_ts_id
!=
p_section
->
i_extension
)
if
(
p_pat_decoder
->
p_building_pat
->
i_ts_id
!=
p_section
->
i_extension
)
{
/* transport_stream_id */
dvbpsi_error
(
p_dvbpsi
,
"PAT decoder"
,
"'transport_stream_id' differs"
" whereas no TS discontinuity has occured"
);
b_reinit
=
1
;
b_reinit
=
true
;
}
else
if
(
p_pat_decoder
->
p_building_pat
->
i_version
!=
p_section
->
i_version
)
...
...
@@ -246,7 +241,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
dvbpsi_error
(
p_dvbpsi
,
"PAT decoder"
,
"'version_number' differs"
" whereas no discontinuity has occured"
);
b_reinit
=
1
;
b_reinit
=
true
;
}
else
if
(
p_pat_decoder
->
i_last_section_number
!=
p_section
->
i_last_number
)
...
...
@@ -255,7 +250,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
dvbpsi_error
(
p_dvbpsi
,
"PAT decoder"
,
"'last_section_number' differs"
" whereas no discontinuity has occured"
);
b_reinit
=
1
;
b_reinit
=
true
;
}
}
else
...
...
@@ -266,27 +261,30 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
p_section
->
b_current_next
))
{
/* Don't decode since this version is already decoded */
b_append
=
0
;
}
dvbpsi_debug
(
p_dvbpsi
,
"PAT decoder"
,
"ignoring already decoded section %d"
,
p_section
->
i_number
);
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
}
}
/* Reinit the decoder if wanted */
if
(
b_reinit
)
if
(
b_reinit
)
{
/* Force redecoding */
p_pat_decoder
->
b_current_valid
=
0
;
p_pat_decoder
->
b_current_valid
=
false
;
/* Free structures */
if
(
p_pat_decoder
->
p_building_pat
)
if
(
p_pat_decoder
->
p_building_pat
)
{
free
(
p_pat_decoder
->
p_building_pat
);
p_pat_decoder
->
p_building_pat
=
NULL
;
}
/* Clear the section array */
for
(
unsigned
int
i
=
0
;
i
<=
255
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<=
255
;
i
++
)
{
if
(
p_pat_decoder
->
ap_sections
[
i
]
!=
NULL
)
if
(
p_pat_decoder
->
ap_sections
[
i
]
!=
NULL
)
{
dvbpsi_DeletePSISections
(
p_pat_decoder
->
ap_sections
[
i
]);
p_pat_decoder
->
ap_sections
[
i
]
=
NULL
;
...
...
@@ -294,29 +292,29 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
}
}
/* Append the section to the list if wanted */
if
(
b_append
)
{
int
b_complete
;
/* Append the section to the list */
bool
b_complete
=
false
;
/* Initialize the structures if it's the first section received */
if
(
!
p_pat_decoder
->
p_building_pat
)
if
(
!
p_pat_decoder
->
p_building_pat
)
{
p_pat_decoder
->
p_building_pat
=
(
dvbpsi_pat_t
*
)
malloc
(
sizeof
(
dvbpsi_pat_t
));
if
(
p_pat_decoder
->
p_building_pat
)
dvbpsi_InitPAT
(
p_pat_decoder
->
p_building_pat
,
p_section
->
i_extension
,
p_section
->
i_
version
,
p_section
->
b_current_next
);
else
dvbpsi_error
(
p_dvbpsi
,
"PAT decoder"
,
"failed decoding section"
);
if
(
p_pat_decoder
->
p_building_pat
==
NULL
)
{
dvbpsi_error
(
p_dvbpsi
,
"PAT decoder"
,
"failed decoding section %d"
,
p_section
->
i_
number
);
dvbpsi_DeletePSISections
(
p_section
);
return
;
}
dvbpsi_InitPAT
(
p_pat_decoder
->
p_building_pat
,
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
);
p_pat_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
/* Fill the section array */
if
(
p_pat_decoder
->
ap_sections
[
p_section
->
i_number
]
!=
NULL
)
if
(
p_pat_decoder
->
ap_sections
[
p_section
->
i_number
]
!=
NULL
)
{
dvbpsi_debug
(
p_dvbpsi
,
"PAT decoder"
,
"overwrite section number %d"
,
p_section
->
i_number
);
...
...
@@ -325,25 +323,23 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
p_pat_decoder
->
ap_sections
[
p_section
->
i_number
]
=
p_section
;
/* Check if we have all the sections */
b_complete
=
0
;
for
(
unsigned
int
i
=
0
;
i
<=
p_pat_decoder
->
i_last_section_number
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<=
p_pat_decoder
->
i_last_section_number
;
i
++
)
{
if
(
!
p_pat_decoder
->
ap_sections
[
i
])
if
(
!
p_pat_decoder
->
ap_sections
[
i
])
break
;
if
(
i
==
p_pat_decoder
->
i_last_section_number
)
b_complete
=
1
;
if
(
i
==
p_pat_decoder
->
i_last_section_number
)
b_complete
=
true
;
}
if
(
b_complete
)
if
(
b_complete
)
{
/* Save the current information */
p_pat_decoder
->
current_pat
=
*
p_pat_decoder
->
p_building_pat
;
p_pat_decoder
->
b_current_valid
=
1
;
p_pat_decoder
->
b_current_valid
=
true
;
/* Chain the sections */
if
(
p_pat_decoder
->
i_last_section_number
)
if
(
p_pat_decoder
->
i_last_section_number
)
{
for
(
unsigned
int
i
=
0
;
(
int
)
i
<=
p_pat_decoder
->
i_last_section_number
-
1
;
i
++
)
for
(
unsigned
int
i
=
0
;
(
int
)
i
<=
p_pat_decoder
->
i_last_section_number
-
1
;
i
++
)
p_pat_decoder
->
ap_sections
[
i
]
->
p_next
=
p_pat_decoder
->
ap_sections
[
i
+
1
];
}
...
...
@@ -357,17 +353,11 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
p_pat_decoder
->
p_building_pat
);
/* Reinitialize the structures */
p_pat_decoder
->
p_building_pat
=
NULL
;
for
(
unsigned
int
i
=
0
;
i
<=
p_pat_decoder
->
i_last_section_number
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<=
p_pat_decoder
->
i_last_section_number
;
i
++
)
p_pat_decoder
->
ap_sections
[
i
]
=
NULL
;
}
}
else
{
dvbpsi_DeletePSISections
(
p_section
);
}
}
/*****************************************************************************
* dvbpsi_DecodePATSection
*****************************************************************************
...
...
src/tables/pat.h
View file @
dc475fd5
...
...
@@ -81,7 +81,7 @@ typedef struct dvbpsi_pat_s
{
uint16_t
i_ts_id
;
/*!< transport_stream_id */
uint8_t
i_version
;
/*!< version_number */
int
b_current_next
;
/*!< current_next_indicator */
bool
b_current_next
;
/*!< current_next_indicator */
dvbpsi_pat_program_t
*
p_first_program
;
/*!< program list */
...
...
src/tables/pat_private.h
View file @
dc475fd5
...
...
@@ -43,7 +43,7 @@ typedef struct dvbpsi_pat_decoder_s
dvbpsi_pat_t
current_pat
;
dvbpsi_pat_t
*
p_building_pat
;
int
b_current_valid
;
bool
b_current_valid
;
uint8_t
i_last_section_number
;
dvbpsi_psi_section_t
*
ap_sections
[
256
];
...
...
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