Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
c3bc6096
Commit
c3bc6096
authored
Oct 05, 2011
by
Alex Converse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpegts: Add support for multiple mp4 descriptors
parent
476d04a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
19 deletions
+32
-19
mpegts.c
libavformat/mpegts.c
+24
-16
mpegts.h
libavformat/mpegts.h
+7
-2
wtv.c
libavformat/wtv.c
+1
-1
No files found.
libavformat/mpegts.c
View file @
c3bc6096
...
@@ -42,6 +42,8 @@
...
@@ -42,6 +42,8 @@
#define MAX_PES_PAYLOAD 200*1024
#define MAX_PES_PAYLOAD 200*1024
#define MAX_MP4_DESCR_COUNT 16
enum
MpegTSFilterType
{
enum
MpegTSFilterType
{
MPEGTS_PES
,
MPEGTS_PES
,
MPEGTS_SECTION
,
MPEGTS_SECTION
,
...
@@ -905,8 +907,7 @@ static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size,
...
@@ -905,8 +907,7 @@ static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size,
int
ff_parse_mpeg2_descriptor
(
AVFormatContext
*
fc
,
AVStream
*
st
,
int
stream_type
,
int
ff_parse_mpeg2_descriptor
(
AVFormatContext
*
fc
,
AVStream
*
st
,
int
stream_type
,
const
uint8_t
**
pp
,
const
uint8_t
*
desc_list_end
,
const
uint8_t
**
pp
,
const
uint8_t
*
desc_list_end
,
int
mp4_dec_config_descr_len
,
int
mp4_es_id
,
int
pid
,
Mp4Descr
*
mp4_descr
,
int
mp4_descr_count
,
int
pid
)
uint8_t
*
mp4_dec_config_descr
)
{
{
const
uint8_t
*
desc_end
;
const
uint8_t
*
desc_end
;
int
desc_len
,
desc_tag
,
desc_es_id
;
int
desc_len
,
desc_tag
,
desc_es_id
;
...
@@ -932,10 +933,12 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
...
@@ -932,10 +933,12 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
switch
(
desc_tag
)
{
switch
(
desc_tag
)
{
case
0x1E
:
/* SL descriptor */
case
0x1E
:
/* SL descriptor */
desc_es_id
=
get16
(
pp
,
desc_end
);
desc_es_id
=
get16
(
pp
,
desc_end
);
if
(
mp4_dec_config_descr_len
&&
mp4_es_id
==
desc_es_id
)
{
for
(
i
=
0
;
i
<
mp4_descr_count
;
i
++
)
if
(
mp4_descr
[
i
].
dec_config_descr_len
&&
mp4_descr
[
i
].
es_id
==
desc_es_id
)
{
AVIOContext
pb
;
AVIOContext
pb
;
ffio_init_context
(
&
pb
,
mp4_dec_config_descr
,
ffio_init_context
(
&
pb
,
mp4_de
scr
[
i
].
de
c_config_descr
,
mp4_dec_config_descr_len
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
mp4_de
scr
[
i
].
de
c_config_descr_len
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ff_mp4_read_dec_config_descr
(
fc
,
st
,
&
pb
);
ff_mp4_read_dec_config_descr
(
fc
,
st
,
&
pb
);
if
(
st
->
codec
->
codec_id
==
CODEC_ID_AAC
&&
if
(
st
->
codec
->
codec_id
==
CODEC_ID_AAC
&&
st
->
codec
->
extradata_size
>
0
)
st
->
codec
->
extradata_size
>
0
)
...
@@ -944,11 +947,11 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
...
@@ -944,11 +947,11 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
break
;
break
;
case
0x1F
:
/* FMC descriptor */
case
0x1F
:
/* FMC descriptor */
get16
(
pp
,
desc_end
);
get16
(
pp
,
desc_end
);
if
(
st
->
codec
->
codec_id
==
CODEC_ID_AAC_LATM
&&
if
(
mp4_descr_count
>
0
&&
st
->
codec
->
codec_id
==
CODEC_ID_AAC_LATM
&&
mp4_de
c_config_descr_len
&&
mp4_
es_id
==
pid
)
{
mp4_de
scr
->
dec_config_descr_len
&&
mp4_descr
->
es_id
==
pid
)
{
AVIOContext
pb
;
AVIOContext
pb
;
ffio_init_context
(
&
pb
,
mp4_dec_config_descr
,
ffio_init_context
(
&
pb
,
mp4_de
scr
->
de
c_config_descr
,
mp4_dec_config_descr_len
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
mp4_de
scr
->
de
c_config_descr_len
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ff_mp4_read_dec_config_descr
(
fc
,
st
,
&
pb
);
ff_mp4_read_dec_config_descr
(
fc
,
st
,
&
pb
);
if
(
st
->
codec
->
codec_id
==
CODEC_ID_AAC
&&
if
(
st
->
codec
->
codec_id
==
CODEC_ID_AAC
&&
st
->
codec
->
extradata_size
>
0
)
st
->
codec
->
extradata_size
>
0
)
...
@@ -1032,9 +1035,10 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
...
@@ -1032,9 +1035,10 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
int
program_info_length
,
pcr_pid
,
pid
,
stream_type
;
int
program_info_length
,
pcr_pid
,
pid
,
stream_type
;
int
desc_list_len
;
int
desc_list_len
;
uint32_t
prog_reg_desc
=
0
;
/* registration descriptor */
uint32_t
prog_reg_desc
=
0
;
/* registration descriptor */
uint8_t
*
mp4_dec_config_descr
=
NULL
;
int
mp4_dec_config_descr_len
=
0
;
Mp4Descr
mp4_descr
[
MAX_MP4_DESCR_COUNT
]
=
{{
0
}};
int
mp4_es_id
=
0
;
int
mp4_descr_count
=
0
;
int
i
;
av_dlog
(
ts
->
stream
,
"PMT: len %i
\n
"
,
section_len
);
av_dlog
(
ts
->
stream
,
"PMT: len %i
\n
"
,
section_len
);
hex_dump_debug
(
ts
->
stream
,
(
uint8_t
*
)
section
,
section_len
);
hex_dump_debug
(
ts
->
stream
,
(
uint8_t
*
)
section
,
section_len
);
...
@@ -1076,8 +1080,11 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
...
@@ -1076,8 +1080,11 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
get8
(
&
p
,
p_end
);
// scope
get8
(
&
p
,
p_end
);
// scope
get8
(
&
p
,
p_end
);
// label
get8
(
&
p
,
p_end
);
// label
len
-=
2
;
len
-=
2
;
mp4_read_iods
(
ts
->
stream
,
p
,
len
,
&
mp4_es_id
,
if
(
mp4_descr_count
<
MAX_MP4_DESCR_COUNT
)
{
&
mp4_dec_config_descr
,
&
mp4_dec_config_descr_len
);
mp4_descr_count
++
;
mp4_read_iods
(
ts
->
stream
,
p
,
len
,
&
mp4_descr
->
es_id
,
&
mp4_descr
->
dec_config_descr
,
&
mp4_descr
->
dec_config_descr_len
);
}
}
else
if
(
tag
==
0x05
&&
len
>=
4
)
{
// registration descriptor
}
else
if
(
tag
==
0x05
&&
len
>=
4
)
{
// registration descriptor
prog_reg_desc
=
bytestream_get_le32
(
&
p
);
prog_reg_desc
=
bytestream_get_le32
(
&
p
);
len
-=
4
;
len
-=
4
;
...
@@ -1136,7 +1143,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
...
@@ -1136,7 +1143,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
break
;
break
;
for
(;;)
{
for
(;;)
{
if
(
ff_parse_mpeg2_descriptor
(
ts
->
stream
,
st
,
stream_type
,
&
p
,
desc_list_end
,
if
(
ff_parse_mpeg2_descriptor
(
ts
->
stream
,
st
,
stream_type
,
&
p
,
desc_list_end
,
mp4_de
c_config_descr_len
,
mp4_es_id
,
pid
,
mp4_dec_config_descr
)
<
0
)
mp4_de
scr
,
mp4_descr_count
,
pid
)
<
0
)
break
;
break
;
if
(
prog_reg_desc
==
AV_RL32
(
"HDMV"
)
&&
stream_type
==
0x83
&&
pes
->
sub_st
)
{
if
(
prog_reg_desc
==
AV_RL32
(
"HDMV"
)
&&
stream_type
==
0x83
&&
pes
->
sub_st
)
{
...
@@ -1148,7 +1155,8 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
...
@@ -1148,7 +1155,8 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
}
}
out:
out:
av_free
(
mp4_dec_config_descr
);
for
(
i
=
0
;
i
<
mp4_descr_count
;
i
++
)
av_free
(
mp4_descr
[
i
].
dec_config_descr
);
}
}
static
void
pat_cb
(
MpegTSFilter
*
filter
,
const
uint8_t
*
section
,
int
section_len
)
static
void
pat_cb
(
MpegTSFilter
*
filter
,
const
uint8_t
*
section
,
int
section_len
)
...
...
libavformat/mpegts.h
View file @
c3bc6096
...
@@ -64,6 +64,12 @@ int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
...
@@ -64,6 +64,12 @@ int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
const
uint8_t
*
buf
,
int
len
);
const
uint8_t
*
buf
,
int
len
);
void
ff_mpegts_parse_close
(
MpegTSContext
*
ts
);
void
ff_mpegts_parse_close
(
MpegTSContext
*
ts
);
typedef
struct
{
int
es_id
;
int
dec_config_descr_len
;
uint8_t
*
dec_config_descr
;
}
Mp4Descr
;
/**
/**
* Parse an MPEG-2 descriptor
* Parse an MPEG-2 descriptor
* @param[in] fc Format context (used for logging only)
* @param[in] fc Format context (used for logging only)
...
@@ -79,7 +85,6 @@ void ff_mpegts_parse_close(MpegTSContext *ts);
...
@@ -79,7 +85,6 @@ void ff_mpegts_parse_close(MpegTSContext *ts);
*/
*/
int
ff_parse_mpeg2_descriptor
(
AVFormatContext
*
fc
,
AVStream
*
st
,
int
stream_type
,
int
ff_parse_mpeg2_descriptor
(
AVFormatContext
*
fc
,
AVStream
*
st
,
int
stream_type
,
const
uint8_t
**
pp
,
const
uint8_t
*
desc_list_end
,
const
uint8_t
**
pp
,
const
uint8_t
*
desc_list_end
,
int
mp4_dec_config_descr_len
,
int
mp4_es_id
,
int
pid
,
Mp4Descr
*
mp4_descr
,
int
mp4_descr_count
,
int
pid
);
uint8_t
*
mp4_dec_config_descr
);
#endif
/* AVFORMAT_MPEGTS_H */
#endif
/* AVFORMAT_MPEGTS_H */
libavformat/wtv.c
View file @
c3bc6096
...
@@ -837,7 +837,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
...
@@ -837,7 +837,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
buf_size
=
FFMIN
(
len
-
consumed
,
sizeof
(
buf
));
buf_size
=
FFMIN
(
len
-
consumed
,
sizeof
(
buf
));
avio_read
(
pb
,
buf
,
buf_size
);
avio_read
(
pb
,
buf
,
buf_size
);
consumed
+=
buf_size
;
consumed
+=
buf_size
;
ff_parse_mpeg2_descriptor
(
s
,
st
,
0
,
&
pbuf
,
buf
+
buf_size
,
0
,
0
,
0
,
0
);
ff_parse_mpeg2_descriptor
(
s
,
st
,
0
,
&
pbuf
,
buf
+
buf_size
,
NULL
,
0
,
0
);
}
}
}
else
if
(
!
ff_guidcmp
(
g
,
EVENTID_AudioTypeSpanningEvent
))
{
}
else
if
(
!
ff_guidcmp
(
g
,
EVENTID_AudioTypeSpanningEvent
))
{
int
stream_index
=
ff_find_stream_index
(
s
,
sid
);
int
stream_index
=
ff_find_stream_index
(
s
,
sid
);
...
...
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