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
a0b8f70c
Commit
a0b8f70c
authored
Dec 09, 2003
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better get_packet_size and probe
Originally committed as revision 2578 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
f8830383
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
17 deletions
+48
-17
mpegts.c
libavformat/mpegts.c
+48
-17
No files found.
libavformat/mpegts.c
View file @
a0b8f70c
...
...
@@ -218,24 +218,45 @@ void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter)
ts
->
pids
[
pid
]
=
NULL
;
}
static
int
analyze
(
const
uint8_t
*
buf
,
int
size
,
int
packet_size
,
int
*
index
){
int
stat
[
packet_size
];
int
i
;
int
x
=
0
;
int
best_score
=
0
;
memset
(
stat
,
0
,
packet_size
*
sizeof
(
int
));
for
(
x
=
i
=
0
;
i
<
size
;
i
++
){
if
(
buf
[
i
]
==
0x47
){
stat
[
x
]
++
;
if
(
stat
[
x
]
>
best_score
){
best_score
=
stat
[
x
];
if
(
index
)
*
index
=
x
;
}
}
x
++
;
if
(
x
==
packet_size
)
x
=
0
;
}
return
best_score
;
}
/* autodetect fec presence. Must have at least 1024 bytes */
static
int
get_packet_size
(
const
uint8_t
*
buf
,
int
size
)
{
int
i
;
int
score
,
fec_score
;
if
(
size
<
(
TS_FEC_PACKET_SIZE
*
5
+
1
))
return
-
1
;
for
(
i
=
0
;
i
<
5
;
i
++
)
{
if
(
buf
[
i
*
TS_PACKET_SIZE
]
!=
0x47
)
goto
try_fec
;
}
return
TS_PACKET_SIZE
;
try_fec:
for
(
i
=
0
;
i
<
5
;
i
++
)
{
if
(
buf
[
i
*
TS_FEC_PACKET_SIZE
]
!=
0x47
)
return
-
1
;
}
return
TS_FEC_PACKET_SIZE
;
score
=
analyze
(
buf
,
size
,
TS_PACKET_SIZE
,
NULL
);
fec_score
=
analyze
(
buf
,
size
,
TS_FEC_PACKET_SIZE
,
NULL
);
// av_log(NULL, AV_LOG_DEBUG, "score: %d, fec_score: %d \n", score, fec_score);
if
(
score
>
fec_score
)
return
TS_PACKET_SIZE
;
else
if
(
score
<
fec_score
)
return
TS_FEC_PACKET_SIZE
;
else
return
-
1
;
}
typedef
struct
SectionHeader
{
...
...
@@ -988,11 +1009,21 @@ static int handle_packets(MpegTSContext *ts, int nb_packets)
static
int
mpegts_probe
(
AVProbeData
*
p
)
{
#if 1
int
size
;
size
=
get_packet_size
(
p
->
buf
,
p
->
buf_size
);
if
(
size
<
0
)
return
0
;
return
AVPROBE_SCORE_MAX
-
1
;
const
int
size
=
p
->
buf_size
;
int
score
,
fec_score
;
#define CHECK_COUNT 10
if
(
size
<
(
TS_FEC_PACKET_SIZE
*
CHECK_COUNT
))
return
-
1
;
score
=
analyze
(
p
->
buf
,
TS_PACKET_SIZE
*
CHECK_COUNT
,
TS_PACKET_SIZE
,
NULL
);
fec_score
=
analyze
(
p
->
buf
,
TS_FEC_PACKET_SIZE
*
CHECK_COUNT
,
TS_FEC_PACKET_SIZE
,
NULL
);
// av_log(NULL, AV_LOG_DEBUG, "score: %d, fec_score: %d \n", score, fec_score);
// we need a clear definition for the returned score otherwise things will become messy sooner or later
if
(
score
>
fec_score
&&
score
>
6
)
return
AVPROBE_SCORE_MAX
+
score
-
CHECK_COUNT
;
else
if
(
fec_score
>
6
)
return
AVPROBE_SCORE_MAX
+
fec_score
-
CHECK_COUNT
;
else
return
-
1
;
#else
/* only use the extension for safer guess */
if
(
match_ext
(
p
->
filename
,
"ts"
))
...
...
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