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
0112ad2f
Commit
0112ad2f
authored
Oct 06, 2011
by
Georgi Chorbadzhiyski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpeg/psi: Add support for descriptor 0x2a (AVC timing and HRD descriptor).
parent
1c39b4ea
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
291 additions
and
1 deletion
+291
-1
README
README
+1
-0
TODO
TODO
+0
-1
examples/dvb_gen_si.c
examples/dvb_gen_si.c
+17
-0
mpeg/psi/desc_2a.h
mpeg/psi/desc_2a.h
+271
-0
mpeg/psi/descs_list.h
mpeg/psi/descs_list.h
+1
-0
mpeg/psi/descs_print.h
mpeg/psi/descs_print.h
+1
-0
No files found.
README
View file @
0112ad2f
...
...
@@ -87,6 +87,7 @@ Supported MPEG descriptors
* Descriptor 0x23: MultiplexBuffer descriptor
* Descriptor 0x27: Metadata STD descriptor
* Descriptor 0x28: AVC video descriptor
* Descriptor 0x2a: AVC timing and HRD descriptor
Supported DVB descriptors
...
...
TODO
View file @
0112ad2f
...
...
@@ -8,7 +8,6 @@ so if you like something just do it and send a patch.
- Descriptor 0x25 metadata_pointer_descriptor
- Descriptor 0x26 metadata_descriptor
- Descriptor 0x29 IPMP_descriptor (defined in ISO/IEC 13818-11, MPEG-2 IPMP)
- Descriptor 0x2a AVC timing and HRD descriptor
- Descriptor 0x2b MPEG-2_AAC_audio_descriptor
- Descriptor 0x2c FlexMuxTiming_descriptor
...
...
examples/dvb_gen_si.c
View file @
0112ad2f
...
...
@@ -309,6 +309,20 @@ static void build_desc28(uint8_t *desc) {
desc28_set_avc_24_hour_picture_flag
(
desc
,
false
);
}
/* MPEG Descriptor 0x2a: AVC timing and HRD descriptor */
static
void
build_desc2a
(
uint8_t
*
desc
)
{
desc2a_init
(
desc
);
desc2a_set_hrd_management_valid_flag
(
desc
,
false
);
desc2a_set_picture_and_timing_info_present
(
desc
,
true
);
desc2a_set_90khz_flag
(
desc
,
false
);
// depends on picture_and_timing_info
desc2a_set_N
(
desc
,
12345678
);
// depends on 90khz == false
desc2a_set_K
(
desc
,
34567890
);
// depends on 90khz == false
desc2a_set_num_units_in_tick
(
desc
,
456789
);
// depends on picture_and_timing_info
desc2a_set_fixed_frame_rate_flag
(
desc
,
true
);
desc2a_set_temporal_poc_flag
(
desc
,
false
);
desc2a_set_picture_to_display_conversion_flag
(
desc
,
true
);
}
/* =========================================================================
* DVB defined descriptors
* ========================================================================= */
...
...
@@ -1701,6 +1715,9 @@ static void generate_pmt(void) {
desc
=
descs_get_desc
(
desc_loop
,
desc_counter
++
);
build_desc28
(
desc
);
desc
=
descs_get_desc
(
desc_loop
,
desc_counter
++
);
build_desc2a
(
desc
);
// Finish descriptor generation
desc
=
descs_get_desc
(
desc_loop
,
desc_counter
);
// Get next descriptor pos
descs_set_length
(
desc_loop
,
desc
-
desc_loop
-
DESCS_HEADER_SIZE
);
...
...
mpeg/psi/desc_2a.h
0 → 100644
View file @
0112ad2f
/*****************************************************************************
* desc_2a.h: ISO/IEC 13818-1 Descriptor 0x2a (AVC timing and HRD descriptor)
*****************************************************************************
* Copyright (C) 2011 Unix Solutions Ltd.
*
* Authors: Georgi Chorbadzhiyski <georgi@unixsol.org>
*
* 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_DESC_2A_H__
#define __BITSTREAM_MPEG_DESC_2A_H__
#include <bitstream/common.h>
#include <bitstream/mpeg/psi/descriptors.h>
#ifdef __cplusplus
extern
"C"
{
#endif
/*****************************************************************************
* Descriptor 0x2a (AVC timing and HRD descriptor)
*****************************************************************************/
#define DESC2A_HEADER_SIZE (DESC_HEADER_SIZE + 2)
#define DESC2A_HEADER_SIZE2 (DESC_HEADER_SIZE + 2 + 5)
#define DESC2A_HEADER_SIZE3 (DESC_HEADER_SIZE + 2 + 5 + 8)
static
inline
void
desc2a_init
(
uint8_t
*
p_desc
)
{
desc_set_tag
(
p_desc
,
0x2a
);
desc_set_length
(
p_desc
,
DESC2A_HEADER_SIZE
-
DESC_HEADER_SIZE
);
p_desc
[
2
]
=
0x7e
;
}
static
inline
bool
desc2a_get_hrd_management_valid_flag
(
const
uint8_t
*
p_desc
)
{
return
(
p_desc
[
2
]
&
0x80
)
==
0x80
;
}
static
inline
void
desc2a_set_hrd_management_valid_flag
(
uint8_t
*
p_desc
,
bool
b_hrd_management_valid_flag
)
{
p_desc
[
2
]
=
b_hrd_management_valid_flag
?
(
p_desc
[
2
]
|
0x80
)
:
(
p_desc
[
2
]
&~
0x80
);
}
static
inline
bool
desc2a_get_picture_and_timing_info_present
(
const
uint8_t
*
p_desc
)
{
return
(
p_desc
[
2
]
&
0x01
)
==
0x01
;
}
static
inline
void
desc2a_set_picture_and_timing_info_present
(
uint8_t
*
p_desc
,
bool
b_picture_and_timing_info_present
)
{
if
(
b_picture_and_timing_info_present
)
desc_set_length
(
p_desc
,
DESC2A_HEADER_SIZE2
-
DESC_HEADER_SIZE
);
else
desc_set_length
(
p_desc
,
DESC2A_HEADER_SIZE
-
DESC_HEADER_SIZE
);
p_desc
[
2
]
=
b_picture_and_timing_info_present
?
(
p_desc
[
2
]
|
0x01
)
:
(
p_desc
[
2
]
&~
0x01
);
}
static
inline
bool
desc2a_get_90khz_flag
(
const
uint8_t
*
p_desc
)
{
if
(
!
desc2a_get_picture_and_timing_info_present
(
p_desc
))
return
false
;
return
(
p_desc
[
3
]
&
0x80
)
==
0x80
;
}
static
inline
void
desc2a_set_90khz_flag
(
uint8_t
*
p_desc
,
bool
b_90khz_flag
)
{
if
(
!
desc2a_get_picture_and_timing_info_present
(
p_desc
))
return
;
if
(
b_90khz_flag
)
desc_set_length
(
p_desc
,
DESC2A_HEADER_SIZE2
-
DESC_HEADER_SIZE
);
else
desc_set_length
(
p_desc
,
DESC2A_HEADER_SIZE3
-
DESC_HEADER_SIZE
);
p_desc
[
3
]
=
0x7f
;
p_desc
[
3
]
=
b_90khz_flag
?
(
p_desc
[
3
]
|
0x80
)
:
(
p_desc
[
3
]
&~
0x80
);
}
static
inline
uint32_t
desc2a_get_N
(
const
uint8_t
*
p_desc
)
{
if
(
!
desc2a_get_picture_and_timing_info_present
(
p_desc
))
return
0
;
if
(
desc2a_get_90khz_flag
(
p_desc
))
return
0
;
return
(
p_desc
[
4
]
<<
24
)
|
(
p_desc
[
5
]
<<
16
)
|
(
p_desc
[
6
]
<<
8
)
|
p_desc
[
7
];
}
static
inline
void
desc2a_set_N
(
uint8_t
*
p_desc
,
uint32_t
i_N
)
{
if
(
!
desc2a_get_picture_and_timing_info_present
(
p_desc
))
return
;
if
(
desc2a_get_90khz_flag
(
p_desc
))
return
;
p_desc
[
4
]
=
(
i_N
>>
24
)
&
0xff
;
p_desc
[
5
]
=
(
i_N
>>
16
)
&
0xff
;
p_desc
[
6
]
=
(
i_N
>>
8
)
&
0xff
;
p_desc
[
7
]
=
i_N
&
0xff
;
}
static
inline
uint32_t
desc2a_get_K
(
const
uint8_t
*
p_desc
)
{
if
(
!
desc2a_get_picture_and_timing_info_present
(
p_desc
))
return
0
;
if
(
desc2a_get_90khz_flag
(
p_desc
))
return
0
;
return
(
p_desc
[
8
]
<<
24
)
|
(
p_desc
[
9
]
<<
16
)
|
(
p_desc
[
10
]
<<
8
)
|
p_desc
[
11
];
}
static
inline
void
desc2a_set_K
(
uint8_t
*
p_desc
,
uint32_t
i_K
)
{
if
(
!
desc2a_get_picture_and_timing_info_present
(
p_desc
))
return
;
if
(
desc2a_get_90khz_flag
(
p_desc
))
return
;
p_desc
[
8
]
=
(
i_K
>>
24
)
&
0xff
;
p_desc
[
9
]
=
(
i_K
>>
16
)
&
0xff
;
p_desc
[
10
]
=
(
i_K
>>
8
)
&
0xff
;
p_desc
[
11
]
=
i_K
&
0xff
;
}
static
inline
uint32_t
desc2a_get_num_units_in_tick
(
const
uint8_t
*
p_desc
)
{
uint8_t
ofs
;
if
(
!
desc2a_get_picture_and_timing_info_present
(
p_desc
))
return
0
;
ofs
=
desc2a_get_90khz_flag
(
p_desc
)
==
0
?
12
:
4
;
return
(
p_desc
[
ofs
+
0
]
<<
24
)
|
(
p_desc
[
ofs
+
1
]
<<
16
)
|
(
p_desc
[
ofs
+
2
]
<<
8
)
|
p_desc
[
ofs
+
3
];
}
static
inline
void
desc2a_set_num_units_in_tick
(
uint8_t
*
p_desc
,
uint32_t
i_num_units_in_tick
)
{
uint8_t
ofs
;
if
(
!
desc2a_get_picture_and_timing_info_present
(
p_desc
))
return
;
ofs
=
desc2a_get_90khz_flag
(
p_desc
)
==
0
?
12
:
4
;
p_desc
[
ofs
+
0
]
=
(
i_num_units_in_tick
>>
24
)
&
0xff
;
p_desc
[
ofs
+
1
]
=
(
i_num_units_in_tick
>>
16
)
&
0xff
;
p_desc
[
ofs
+
2
]
=
(
i_num_units_in_tick
>>
8
)
&
0xff
;
p_desc
[
ofs
+
3
]
=
i_num_units_in_tick
&
0xff
;
}
#define desc2a_init_offset \
uint8_t ofs = 3; \
do { \
if (desc2a_get_picture_and_timing_info_present(p_desc)) \
{ \
ofs += 5; \
if (desc2a_get_90khz_flag(p_desc) == false) \
ofs += 8; \
} \
} while(0)
static
inline
bool
desc2a_get_fixed_frame_rate_flag
(
const
uint8_t
*
p_desc
)
{
desc2a_init_offset
;
return
(
p_desc
[
ofs
]
&
0x80
)
==
0x80
;
}
static
inline
void
desc2a_set_fixed_frame_rate_flag
(
uint8_t
*
p_desc
,
bool
i_fixed_frame_rate_flag
)
{
desc2a_init_offset
;
p_desc
[
ofs
]
|=
0x1f
;
p_desc
[
ofs
]
=
i_fixed_frame_rate_flag
?
(
p_desc
[
ofs
]
|
0x80
)
:
(
p_desc
[
ofs
]
&~
0x80
);
}
static
inline
bool
desc2a_get_temporal_poc_flag
(
const
uint8_t
*
p_desc
)
{
desc2a_init_offset
;
return
(
p_desc
[
ofs
]
&
0x40
)
==
0x40
;
}
static
inline
void
desc2a_set_temporal_poc_flag
(
uint8_t
*
p_desc
,
bool
i_temporal_poc_flag
)
{
desc2a_init_offset
;
p_desc
[
ofs
]
|=
0x1f
;
p_desc
[
ofs
]
=
i_temporal_poc_flag
?
(
p_desc
[
ofs
]
|
0x40
)
:
(
p_desc
[
ofs
]
&~
0x40
);
}
static
inline
bool
desc2a_get_picture_to_display_conversion_flag
(
const
uint8_t
*
p_desc
)
{
desc2a_init_offset
;
return
(
p_desc
[
ofs
]
&
0x20
)
==
0x20
;
}
static
inline
void
desc2a_set_picture_to_display_conversion_flag
(
uint8_t
*
p_desc
,
bool
i_picture_to_display_conversion
)
{
desc2a_init_offset
;
p_desc
[
ofs
]
|=
0x1f
;
p_desc
[
ofs
]
=
i_picture_to_display_conversion
?
(
p_desc
[
ofs
]
|
0x20
)
:
(
p_desc
[
ofs
]
&~
0x20
);
}
#undef desc2a_init_offset
static
inline
bool
desc2a_validate
(
const
uint8_t
*
p_desc
)
{
uint8_t
desc2a_header_size
=
DESC2A_HEADER_SIZE
;
if
(
desc2a_get_picture_and_timing_info_present
(
p_desc
))
{
desc2a_header_size
=
DESC2A_HEADER_SIZE2
;
if
(
desc2a_get_90khz_flag
(
p_desc
)
==
false
)
desc2a_header_size
=
DESC2A_HEADER_SIZE3
;
}
return
desc_get_length
(
p_desc
)
>=
desc2a_header_size
-
DESC_HEADER_SIZE
;
}
static
inline
void
desc2a_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
,
"<AVC_TIMING_AND_HRD_DESC hrd_management_valid_flag=
\"
%u
\"
"
" picture_and_timing_info_present=
\"
%u
\"
"
" 90khz_flag=
\"
%u
\"
N=
\"
%u
\"
K=
\"
%u
\"
num_units_in_tick=
\"
%u
\"
"
" fixed_frame_rate_flag=
\"
%u
\"
temporal_poc_flag=
\"
%u
\"
"
" picture_to_display_conversion_flag=
\"
%u
\"
/>"
,
desc2a_get_hrd_management_valid_flag
(
p_desc
),
desc2a_get_picture_and_timing_info_present
(
p_desc
),
desc2a_get_90khz_flag
(
p_desc
),
desc2a_get_N
(
p_desc
),
desc2a_get_K
(
p_desc
),
desc2a_get_num_units_in_tick
(
p_desc
),
desc2a_get_fixed_frame_rate_flag
(
p_desc
),
desc2a_get_temporal_poc_flag
(
p_desc
),
desc2a_get_picture_to_display_conversion_flag
(
p_desc
)
);
break
;
default:
pf_print
(
opaque
,
" - desc 2a avc_timing_and_hrd hrd_management_valid_flag=%u"
" picture_and_timing_info_present=%u"
" 90khz_flag=%u N=%u K=%u num_units_in_tick=%u"
" fixed_frame_rate_flag=%u temporal_poc_flag=%u"
" picture_to_display_conversion_flag=%u"
,
desc2a_get_hrd_management_valid_flag
(
p_desc
),
desc2a_get_picture_and_timing_info_present
(
p_desc
),
desc2a_get_90khz_flag
(
p_desc
),
desc2a_get_N
(
p_desc
),
desc2a_get_K
(
p_desc
),
desc2a_get_num_units_in_tick
(
p_desc
),
desc2a_get_fixed_frame_rate_flag
(
p_desc
),
desc2a_get_temporal_poc_flag
(
p_desc
),
desc2a_get_picture_to_display_conversion_flag
(
p_desc
)
);
}
}
#ifdef __cplusplus
}
#endif
#endif
mpeg/psi/descs_list.h
View file @
0112ad2f
...
...
@@ -60,5 +60,6 @@
#include <bitstream/mpeg/psi/desc_23.h>
#include <bitstream/mpeg/psi/desc_27.h>
#include <bitstream/mpeg/psi/desc_28.h>
#include <bitstream/mpeg/psi/desc_2a.h>
#endif
mpeg/psi/descs_print.h
View file @
0112ad2f
...
...
@@ -126,6 +126,7 @@ static inline void descl_print(uint8_t *p_descl, uint16_t i_length,
CASE_DESC
(
23
)
CASE_DESC
(
27
)
CASE_DESC
(
28
)
CASE_DESC
(
2
a
)
CASE_DESC_ICONV
(
40
)
CASE_DESC
(
41
)
CASE_DESC
(
43
)
...
...
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