Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
a8068346
Commit
a8068346
authored
Jun 01, 2014
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc: add a variant of av_get_audio_frame_duration working with AVCodecParameters
parent
998e1b8f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
12 deletions
+29
-12
APIchanges
doc/APIchanges
+1
-0
avcodec.h
libavcodec/avcodec.h
+6
-0
utils.c
libavcodec/utils.c
+22
-12
No files found.
doc/APIchanges
View file @
a8068346
...
...
@@ -15,6 +15,7 @@ API changes, most recent first:
2016-xx-xx - lavc 57.14.0 - avcodec.h
xxxxxxx - Add AVCodecParameters and its related API.
xxxxxxx - Add av_get_audio_frame_duration2().
2016-xx-xx - xxxxxxx - lavf 57.4.0 - avformat.h
Add AVFormatContext.protocol_whitelist and protocol_blacklist.
...
...
libavcodec/avcodec.h
View file @
a8068346
...
...
@@ -4686,6 +4686,12 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id);
*/
int
av_get_audio_frame_duration
(
AVCodecContext
*
avctx
,
int
frame_bytes
);
/**
* This function is the same as av_get_audio_frame_duration(), except it works
* with AVCodecParameters instead of an AVCodecContext.
*/
int
av_get_audio_frame_duration2
(
AVCodecParameters
*
par
,
int
frame_bytes
);
typedef
struct
AVBitStreamFilterContext
{
void
*
priv_data
;
...
...
libavcodec/utils.c
View file @
a8068346
...
...
@@ -2037,21 +2037,15 @@ int av_get_bits_per_sample(enum AVCodecID codec_id)
}
}
int
av_get_audio_frame_duration
(
AVCodecContext
*
avctx
,
int
frame_bytes
)
static
int
get_audio_frame_duration
(
enum
AVCodecID
id
,
int
sr
,
int
ch
,
int
ba
,
uint32_t
tag
,
int
bits_per_coded_sample
,
int
frame_bytes
)
{
int
id
,
sr
,
ch
,
ba
,
tag
,
bps
;
id
=
avctx
->
codec_id
;
sr
=
avctx
->
sample_rate
;
ch
=
avctx
->
channels
;
ba
=
avctx
->
block_align
;
tag
=
avctx
->
codec_tag
;
bps
=
av_get_exact_bits_per_sample
(
avctx
->
codec_id
);
int
bps
=
av_get_exact_bits_per_sample
(
id
);
/* codecs with an exact constant bits per sample */
if
(
bps
>
0
&&
ch
>
0
&&
frame_bytes
>
0
)
return
(
frame_bytes
*
8
)
/
(
bps
*
ch
);
bps
=
avctx
->
bits_per_coded_sample
;
bps
=
bits_per_coded_sample
;
/* codecs with a fixed packet duration */
switch
(
id
)
{
...
...
@@ -2155,7 +2149,7 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
if
(
ba
>
0
)
{
/* calc from frame_bytes, channels, and block_align */
int
blocks
=
frame_bytes
/
ba
;
switch
(
avctx
->
codec_
id
)
{
switch
(
id
)
{
case
AV_CODEC_ID_ADPCM_IMA_WAV
:
return
blocks
*
(
1
+
(
ba
-
4
*
ch
)
/
(
4
*
ch
)
*
8
);
case
AV_CODEC_ID_ADPCM_IMA_DK3
:
...
...
@@ -2169,7 +2163,7 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
if
(
bps
>
0
)
{
/* calc from frame_bytes, channels, and bits_per_coded_sample */
switch
(
avctx
->
codec_
id
)
{
switch
(
id
)
{
case
AV_CODEC_ID_PCM_DVD
:
return
2
*
(
frame_bytes
/
((
bps
*
2
/
8
)
*
ch
));
case
AV_CODEC_ID_PCM_BLURAY
:
...
...
@@ -2184,6 +2178,22 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
return
0
;
}
int
av_get_audio_frame_duration
(
AVCodecContext
*
avctx
,
int
frame_bytes
)
{
return
get_audio_frame_duration
(
avctx
->
codec_id
,
avctx
->
sample_rate
,
avctx
->
channels
,
avctx
->
block_align
,
avctx
->
codec_tag
,
avctx
->
bits_per_coded_sample
,
frame_bytes
);
}
int
av_get_audio_frame_duration2
(
AVCodecParameters
*
par
,
int
frame_bytes
)
{
return
get_audio_frame_duration
(
par
->
codec_id
,
par
->
sample_rate
,
par
->
channels
,
par
->
block_align
,
par
->
codec_tag
,
par
->
bits_per_coded_sample
,
frame_bytes
);
}
#if !HAVE_THREADS
int
ff_thread_init
(
AVCodecContext
*
s
)
{
...
...
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