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
c43222f4
Commit
c43222f4
authored
Apr 11, 2014
by
Carl Eugen Hoyos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve amr bitrate calculation for VBR files.
Fixes ticket #3541.
parent
8b122937
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
amr.c
libavformat/amr.c
+12
-2
No files found.
libavformat/amr.c
View file @
c43222f4
...
...
@@ -30,6 +30,11 @@ Only mono files are supported.
#include "avformat.h"
#include "internal.h"
typedef
struct
{
uint64_t
cumulated_size
;
uint64_t
block_count
;
}
AMRContext
;
static
const
char
AMR_header
[]
=
"#!AMR
\n
"
;
static
const
char
AMRWB_header
[]
=
"#!AMR-WB
\n
"
;
...
...
@@ -110,6 +115,7 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
AVCodecContext
*
enc
=
s
->
streams
[
0
]
->
codec
;
int
read
,
size
=
0
,
toc
,
mode
;
int64_t
pos
=
avio_tell
(
s
->
pb
);
AMRContext
*
amr
=
s
->
priv_data
;
if
(
url_feof
(
s
->
pb
))
{
return
AVERROR
(
EIO
);
...
...
@@ -136,8 +142,11 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
if
(
!
size
||
av_new_packet
(
pkt
,
size
))
return
AVERROR
(
EIO
);
/* Both AMR formats have 50 frames per second */
s
->
streams
[
0
]
->
codec
->
bit_rate
=
size
*
8
*
50
;
if
(
amr
->
cumulated_size
<
UINT64_MAX
-
size
)
{
amr
->
cumulated_size
+=
size
;
/* Both AMR formats have 50 frames per second */
s
->
streams
[
0
]
->
codec
->
bit_rate
=
amr
->
cumulated_size
/
++
amr
->
block_count
*
8
*
50
;
}
pkt
->
stream_index
=
0
;
pkt
->
pos
=
pos
;
...
...
@@ -157,6 +166,7 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
AVInputFormat
ff_amr_demuxer
=
{
.
name
=
"amr"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"3GPP AMR"
),
.
priv_data_size
=
sizeof
(
AMRContext
),
.
read_probe
=
amr_probe
,
.
read_header
=
amr_read_header
,
.
read_packet
=
amr_read_packet
,
...
...
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