Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bitstream
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
bitstream
Commits
c5a78ac8
Commit
c5a78ac8
authored
Oct 10, 2011
by
Christophe Massiot
Committed by
Georgi Chorbadzhiyski
Oct 10, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpeg/psi: Move descriptor functions mpeg/psi/descriptors.h
parent
e3dfa22a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
192 additions
and
142 deletions
+192
-142
Makefile
Makefile
+3
-1
mpeg/psi.h
mpeg/psi.h
+1
-141
mpeg/psi/descriptors.h
mpeg/psi/descriptors.h
+188
-0
No files found.
Makefile
View file @
c5a78ac8
...
...
@@ -13,7 +13,9 @@ install:
@
install
-d
$(INCLUDE)
/ietf
@
install
-m
644 ietf/
*
$(INCLUDE)
/ietf
@
install
-d
$(INCLUDE)
/mpeg
@
install
-m
644 mpeg/
*
$(INCLUDE)
/mpeg
@
install
-m
644 mpeg/
*
.h
$(INCLUDE)
/mpeg
@
install
-d
$(INCLUDE)
/mpeg/psi
@
install
-m
644 mpeg/psi/
*
.h
$(INCLUDE)
/mpeg/psi
uninstall
:
@
echo
"REMOVE
$(INCLUDE)
"
...
...
mpeg/psi.h
View file @
c5a78ac8
...
...
@@ -36,96 +36,13 @@
#include <bitstream/common.h>
#include <bitstream/mpeg/ts.h>
#include <bitstream/mpeg/psi/descriptors.h>
#ifdef __cplusplus
extern
"C"
{
#endif
/*****************************************************************************
* Descriptor
*****************************************************************************/
#define DESC_HEADER_SIZE 2
static
inline
void
desc_set_tag
(
uint8_t
*
p_desc
,
uint8_t
i_tag
)
{
p_desc
[
0
]
=
i_tag
;
}
static
inline
uint8_t
desc_get_tag
(
const
uint8_t
*
p_desc
)
{
return
p_desc
[
0
];
}
static
inline
void
desc_set_length
(
uint8_t
*
p_desc
,
uint8_t
i_length
)
{
p_desc
[
1
]
=
i_length
;
}
static
inline
uint8_t
desc_get_length
(
const
uint8_t
*
p_desc
)
{
return
p_desc
[
1
];
}
static
inline
void
desc_print_begin
(
const
uint8_t
*
p_desc
,
f_print
pf_print
,
void
*
opaque
,
print_type_t
i_print_type
)
{
switch
(
i_print_type
)
{
case
PRINT_XML
:
{
uint8_t
i
,
i_length
=
desc_get_length
(
p_desc
);
char
psz_value
[
2
*
i_length
+
1
];
for
(
i
=
0
;
i
<
i_length
;
i
++
)
sprintf
(
psz_value
+
2
*
i
,
"%2.2hhx"
,
p_desc
[
2
+
i
]);
psz_value
[
2
*
i
]
=
'\0'
;
pf_print
(
opaque
,
"<DESC id=
\"
%hhu
\"
value=
\"
%s
\"
>"
,
desc_get_tag
(
p_desc
),
psz_value
);
break
;
}
default:
break
;
}
}
static
inline
void
desc_print_end
(
const
uint8_t
*
p_desc
,
f_print
pf_print
,
void
*
opaque
,
print_type_t
i_print_type
)
{
switch
(
i_print_type
)
{
case
PRINT_XML
:
pf_print
(
opaque
,
"</DESC>"
);
break
;
default:
break
;
}
}
static
inline
void
desc_print_error
(
const
uint8_t
*
p_desc
,
f_print
pf_print
,
void
*
opaque
,
print_type_t
i_print_type
)
{
switch
(
i_print_type
)
{
case
PRINT_XML
:
pf_print
(
opaque
,
"<INVALID_DESC />"
);
break
;
default:
pf_print
(
opaque
,
"desc %2.2hhx invalid"
,
desc_get_tag
(
p_desc
));
}
}
static
inline
void
desc_print
(
const
uint8_t
*
p_desc
,
f_print
pf_print
,
void
*
opaque
,
print_type_t
i_print_type
)
{
switch
(
i_print_type
)
{
case
PRINT_XML
:
pf_print
(
opaque
,
"<UNKNOWN_DESC />"
);
break
;
default:
pf_print
(
opaque
,
" - desc %2.2hhx unknown"
,
desc_get_tag
(
p_desc
));
}
}
/*****************************************************************************
* Descriptor 0x05: Registration descriptor
*****************************************************************************/
...
...
@@ -272,63 +189,6 @@ static inline void desc0a_print(uint8_t *p_desc, f_print pf_print,
}
}
/*****************************************************************************
* Descriptors list
*****************************************************************************/
static
inline
uint8_t
*
descl_get_desc
(
uint8_t
*
p_descl
,
uint16_t
i_length
,
uint16_t
n
)
{
uint8_t
*
p_desc
=
p_descl
;
while
(
n
)
{
if
(
p_desc
+
DESC_HEADER_SIZE
-
p_descl
>
i_length
)
return
NULL
;
p_desc
+=
DESC_HEADER_SIZE
+
desc_get_length
(
p_desc
);
n
--
;
}
if
(
p_desc
-
p_descl
>=
i_length
)
return
NULL
;
return
p_desc
;
}
static
inline
bool
descl_validate
(
const
uint8_t
*
p_descl
,
uint16_t
i_length
)
{
const
uint8_t
*
p_desc
=
p_descl
;
while
(
p_desc
+
DESC_HEADER_SIZE
-
p_descl
<=
i_length
)
p_desc
+=
DESC_HEADER_SIZE
+
desc_get_length
(
p_desc
);
return
(
p_desc
-
p_descl
==
i_length
);
}
/*****************************************************************************
* Descriptors structure
*****************************************************************************/
#define DESCS_HEADER_SIZE 2
#define DESCS_MAX_SIZE 4095
static
inline
void
descs_set_length
(
uint8_t
*
p_descs
,
uint16_t
i_length
)
{
p_descs
[
0
]
&=
0xf0
;
p_descs
[
0
]
|=
(
i_length
>>
8
)
&
0xf
;
p_descs
[
1
]
=
i_length
&
0xff
;
}
static
inline
uint16_t
descs_get_length
(
const
uint8_t
*
p_descs
)
{
return
((
p_descs
[
0
]
&
0xf
)
<<
8
)
|
p_descs
[
1
];
}
static
inline
uint8_t
*
descs_get_desc
(
uint8_t
*
p_descs
,
uint16_t
n
)
{
return
descl_get_desc
(
p_descs
+
DESCS_HEADER_SIZE
,
descs_get_length
(
p_descs
),
n
);
}
static
inline
bool
descs_validate
(
const
uint8_t
*
p_descs
)
{
return
descl_validate
(
p_descs
+
DESCS_HEADER_SIZE
,
descs_get_length
(
p_descs
));
}
/*****************************************************************************
* p_psi_crc_table
*****************************************************************************
...
...
mpeg/psi/descriptors.h
0 → 100644
View file @
c5a78ac8
/*****************************************************************************
* descriptors.h: ISO/IEC 13818-1 descriptors
*****************************************************************************
* Copyright (C) 2009-2010 VideoLAN
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/
/*
* Normative references:
* - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems)
*/
#ifndef __BITSTREAM_MPEG_DESCRIPTORS_H__
#define __BITSTREAM_MPEG_DESCRIPTORS_H__
#include <bitstream/common.h>
#ifdef __cplusplus
extern
"C"
{
#endif
/*****************************************************************************
* Descriptor
*****************************************************************************/
#define DESC_HEADER_SIZE 2
static
inline
void
desc_set_tag
(
uint8_t
*
p_desc
,
uint8_t
i_tag
)
{
p_desc
[
0
]
=
i_tag
;
}
static
inline
uint8_t
desc_get_tag
(
const
uint8_t
*
p_desc
)
{
return
p_desc
[
0
];
}
static
inline
void
desc_set_length
(
uint8_t
*
p_desc
,
uint8_t
i_length
)
{
p_desc
[
1
]
=
i_length
;
}
static
inline
uint8_t
desc_get_length
(
const
uint8_t
*
p_desc
)
{
return
p_desc
[
1
];
}
static
inline
void
desc_print_begin
(
const
uint8_t
*
p_desc
,
f_print
pf_print
,
void
*
opaque
,
print_type_t
i_print_type
)
{
switch
(
i_print_type
)
{
case
PRINT_XML
:
{
uint8_t
i
,
i_length
=
desc_get_length
(
p_desc
);
char
psz_value
[
2
*
i_length
+
1
];
for
(
i
=
0
;
i
<
i_length
;
i
++
)
sprintf
(
psz_value
+
2
*
i
,
"%2.2hhx"
,
p_desc
[
2
+
i
]);
psz_value
[
2
*
i
]
=
'\0'
;
pf_print
(
opaque
,
"<DESC id=
\"
%hhu
\"
value=
\"
%s
\"
>"
,
desc_get_tag
(
p_desc
),
psz_value
);
break
;
}
default:
break
;
}
}
static
inline
void
desc_print_end
(
const
uint8_t
*
p_desc
,
f_print
pf_print
,
void
*
opaque
,
print_type_t
i_print_type
)
{
switch
(
i_print_type
)
{
case
PRINT_XML
:
pf_print
(
opaque
,
"</DESC>"
);
break
;
default:
break
;
}
}
static
inline
void
desc_print_error
(
const
uint8_t
*
p_desc
,
f_print
pf_print
,
void
*
opaque
,
print_type_t
i_print_type
)
{
switch
(
i_print_type
)
{
case
PRINT_XML
:
pf_print
(
opaque
,
"<INVALID_DESC />"
);
break
;
default:
pf_print
(
opaque
,
"desc %2.2hhx invalid"
,
desc_get_tag
(
p_desc
));
}
}
static
inline
void
desc_print
(
const
uint8_t
*
p_desc
,
f_print
pf_print
,
void
*
opaque
,
print_type_t
i_print_type
)
{
switch
(
i_print_type
)
{
case
PRINT_XML
:
pf_print
(
opaque
,
"<UNKNOWN_DESC />"
);
break
;
default:
pf_print
(
opaque
,
" - desc %2.2hhx unknown"
,
desc_get_tag
(
p_desc
));
}
}
/*****************************************************************************
* Descriptors list
*****************************************************************************/
static
inline
uint8_t
*
descl_get_desc
(
uint8_t
*
p_descl
,
uint16_t
i_length
,
uint16_t
n
)
{
uint8_t
*
p_desc
=
p_descl
;
while
(
n
)
{
if
(
p_desc
+
DESC_HEADER_SIZE
-
p_descl
>
i_length
)
return
NULL
;
p_desc
+=
DESC_HEADER_SIZE
+
desc_get_length
(
p_desc
);
n
--
;
}
if
(
p_desc
-
p_descl
>=
i_length
)
return
NULL
;
return
p_desc
;
}
static
inline
bool
descl_validate
(
const
uint8_t
*
p_descl
,
uint16_t
i_length
)
{
const
uint8_t
*
p_desc
=
p_descl
;
while
(
p_desc
+
DESC_HEADER_SIZE
-
p_descl
<=
i_length
)
p_desc
+=
DESC_HEADER_SIZE
+
desc_get_length
(
p_desc
);
return
(
p_desc
-
p_descl
==
i_length
);
}
/*****************************************************************************
* Descriptors structure
*****************************************************************************/
#define DESCS_HEADER_SIZE 2
#define DESCS_MAX_SIZE 4095
static
inline
void
descs_set_length
(
uint8_t
*
p_descs
,
uint16_t
i_length
)
{
p_descs
[
0
]
&=
0xf0
;
p_descs
[
0
]
|=
(
i_length
>>
8
)
&
0xf
;
p_descs
[
1
]
=
i_length
&
0xff
;
}
static
inline
uint16_t
descs_get_length
(
const
uint8_t
*
p_descs
)
{
return
((
p_descs
[
0
]
&
0xf
)
<<
8
)
|
p_descs
[
1
];
}
static
inline
uint8_t
*
descs_get_desc
(
uint8_t
*
p_descs
,
uint16_t
n
)
{
return
descl_get_desc
(
p_descs
+
DESCS_HEADER_SIZE
,
descs_get_length
(
p_descs
),
n
);
}
static
inline
bool
descs_validate
(
const
uint8_t
*
p_descs
)
{
return
descl_validate
(
p_descs
+
DESCS_HEADER_SIZE
,
descs_get_length
(
p_descs
));
}
#ifdef __cplusplus
}
#endif
#endif
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