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
01000064
Commit
01000064
authored
Mar 11, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avidec: calculate missing bitrates from index
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
52b6db84
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
avidec.c
libavformat/avidec.c
+41
-0
No files found.
libavformat/avidec.c
View file @
01000064
...
...
@@ -379,6 +379,46 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
}
}
static
int
calculate_bitrate
(
AVFormatContext
*
s
)
{
AVIContext
*
avi
=
s
->
priv_data
;
int
i
,
j
;
int64_t
lensum
=
0
;
int64_t
maxpos
=
0
;
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
int64_t
len
=
0
;
AVStream
*
st
=
s
->
streams
[
i
];
if
(
!
st
->
nb_index_entries
)
continue
;
for
(
j
=
0
;
j
<
st
->
nb_index_entries
;
j
++
)
len
+=
st
->
index_entries
[
j
].
size
;
maxpos
=
FFMAX
(
maxpos
,
st
->
index_entries
[
j
-
1
].
pos
);
lensum
+=
len
;
}
if
(
maxpos
<
avi
->
io_fsize
*
9
/
10
)
// index doesnt cover the whole file
return
0
;
if
(
lensum
*
9
/
10
>
maxpos
||
lensum
<
maxpos
*
9
/
10
)
// frame sum and filesize mismatch
return
0
;
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
int64_t
len
=
0
;
AVStream
*
st
=
s
->
streams
[
i
];
int64_t
duration
;
for
(
j
=
0
;
j
<
st
->
nb_index_entries
;
j
++
)
len
+=
st
->
index_entries
[
j
].
size
;
if
(
st
->
nb_index_entries
<
2
||
st
->
codec
->
bit_rate
>
0
)
continue
;
duration
=
st
->
index_entries
[
j
-
1
].
timestamp
-
st
->
index_entries
[
0
].
timestamp
;
st
->
codec
->
bit_rate
=
av_rescale
(
8
*
len
,
st
->
time_base
.
den
,
duration
*
st
->
time_base
.
num
);
}
return
1
;
}
static
int
avi_read_header
(
AVFormatContext
*
s
)
{
AVIContext
*
avi
=
s
->
priv_data
;
...
...
@@ -863,6 +903,7 @@ fail:
if
(
!
avi
->
index_loaded
&&
pb
->
seekable
)
avi_load_index
(
s
);
calculate_bitrate
(
s
);
avi
->
index_loaded
|=
1
;
avi
->
non_interleaved
|=
guess_ni_flag
(
s
)
|
(
s
->
flags
&
AVFMT_FLAG_SORT_DTS
);
...
...
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