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
67ca64c2
Commit
67ca64c2
authored
May 05, 2023
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_adelay: fix frame pts and set frame duration
parent
217bb59f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
16 deletions
+42
-16
af_adelay.c
libavfilter/af_adelay.c
+42
-16
No files found.
libavfilter/af_adelay.c
View file @
67ca64c2
...
@@ -44,9 +44,12 @@ typedef struct AudioDelayContext {
...
@@ -44,9 +44,12 @@ typedef struct AudioDelayContext {
int
block_align
;
int
block_align
;
int64_t
padding
;
int64_t
padding
;
int64_t
max_delay
;
int64_t
max_delay
;
int64_t
offset
;
int64_t
next_pts
;
int64_t
next_pts
;
int
eof
;
int
eof
;
AVFrame
*
input
;
void
(
*
delay_channel
)(
ChanDelay
*
d
,
int
nb_samples
,
void
(
*
delay_channel
)(
ChanDelay
*
d
,
int
nb_samples
,
const
uint8_t
*
src
,
uint8_t
*
dst
);
const
uint8_t
*
src
,
uint8_t
*
dst
);
int
(
*
resize_channel_samples
)(
ChanDelay
*
d
,
int64_t
new_delay
);
int
(
*
resize_channel_samples
)(
ChanDelay
*
d
,
int64_t
new_delay
);
...
@@ -187,6 +190,7 @@ static int config_input(AVFilterLink *inlink)
...
@@ -187,6 +190,7 @@ static int config_input(AVFilterLink *inlink)
char
*
p
,
*
saveptr
=
NULL
;
char
*
p
,
*
saveptr
=
NULL
;
int
i
;
int
i
;
s
->
next_pts
=
AV_NOPTS_VALUE
;
s
->
chandelay
=
av_calloc
(
inlink
->
ch_layout
.
nb_channels
,
sizeof
(
*
s
->
chandelay
));
s
->
chandelay
=
av_calloc
(
inlink
->
ch_layout
.
nb_channels
,
sizeof
(
*
s
->
chandelay
));
if
(
!
s
->
chandelay
)
if
(
!
s
->
chandelay
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -224,6 +228,10 @@ static int config_input(AVFilterLink *inlink)
...
@@ -224,6 +228,10 @@ static int config_input(AVFilterLink *inlink)
d
->
delay
-=
s
->
padding
;
d
->
delay
-=
s
->
padding
;
}
}
s
->
offset
=
av_rescale_q
(
s
->
padding
,
av_make_q
(
1
,
inlink
->
sample_rate
),
inlink
->
time_base
);
}
}
for
(
i
=
0
;
i
<
s
->
nb_delays
;
i
++
)
{
for
(
i
=
0
;
i
<
s
->
nb_delays
;
i
++
)
{
...
@@ -323,11 +331,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
...
@@ -323,11 +331,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
AVFrame
*
out_frame
;
AVFrame
*
out_frame
;
int
i
;
int
i
;
if
(
ctx
->
is_disabled
||
!
s
->
delays
)
if
(
ctx
->
is_disabled
||
!
s
->
delays
)
{
s
->
input
=
NULL
;
return
ff_filter_frame
(
outlink
,
frame
);
return
ff_filter_frame
(
outlink
,
frame
);
}
s
->
next_pts
=
av_rescale_q
(
frame
->
pts
,
inlink
->
time_base
,
outlink
->
time_base
);
out_frame
=
ff_get_audio_buffer
(
outlink
,
frame
->
nb_samples
);
out_frame
=
ff_get_audio_buffer
(
outlink
,
frame
->
nb_samples
);
if
(
!
out_frame
)
{
if
(
!
out_frame
)
{
s
->
input
=
NULL
;
av_frame_free
(
&
frame
);
av_frame_free
(
&
frame
);
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
}
}
...
@@ -344,9 +357,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
...
@@ -344,9 +357,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
s
->
delay_channel
(
d
,
frame
->
nb_samples
,
src
,
dst
);
s
->
delay_channel
(
d
,
frame
->
nb_samples
,
src
,
dst
);
}
}
out_frame
->
pts
=
s
->
next_pts
;
out_frame
->
pts
=
s
->
next_pts
+
s
->
offset
;
s
->
next_pts
+=
av_rescale_q
(
frame
->
nb_samples
,
(
AVRational
){
1
,
outlink
->
sample_rate
},
outlink
->
time_base
);
out_frame
->
duration
=
av_rescale_q
(
out_frame
->
nb_samples
,
(
AVRational
){
1
,
outlink
->
sample_rate
},
outlink
->
time_base
);
s
->
next_pts
+=
out_frame
->
duration
;
av_frame_free
(
&
frame
);
av_frame_free
(
&
frame
);
s
->
input
=
NULL
;
return
ff_filter_frame
(
outlink
,
out_frame
);
return
ff_filter_frame
(
outlink
,
out_frame
);
}
}
...
@@ -361,6 +376,20 @@ static int activate(AVFilterContext *ctx)
...
@@ -361,6 +376,20 @@ static int activate(AVFilterContext *ctx)
FF_FILTER_FORWARD_STATUS_BACK
(
outlink
,
inlink
);
FF_FILTER_FORWARD_STATUS_BACK
(
outlink
,
inlink
);
if
(
!
s
->
input
)
{
ret
=
ff_inlink_consume_frame
(
inlink
,
&
s
->
input
);
if
(
ret
<
0
)
return
ret
;
}
if
(
ff_inlink_acknowledge_status
(
inlink
,
&
status
,
&
pts
))
{
if
(
status
==
AVERROR_EOF
)
s
->
eof
=
1
;
}
if
(
s
->
next_pts
==
AV_NOPTS_VALUE
&&
pts
!=
AV_NOPTS_VALUE
)
s
->
next_pts
=
av_rescale_q
(
pts
,
inlink
->
time_base
,
outlink
->
time_base
);
if
(
s
->
padding
)
{
if
(
s
->
padding
)
{
int
nb_samples
=
FFMIN
(
s
->
padding
,
2048
);
int
nb_samples
=
FFMIN
(
s
->
padding
,
2048
);
...
@@ -374,24 +403,17 @@ static int activate(AVFilterContext *ctx)
...
@@ -374,24 +403,17 @@ static int activate(AVFilterContext *ctx)
outlink
->
ch_layout
.
nb_channels
,
outlink
->
ch_layout
.
nb_channels
,
frame
->
format
);
frame
->
format
);
frame
->
duration
=
av_rescale_q
(
frame
->
nb_samples
,
(
AVRational
){
1
,
outlink
->
sample_rate
},
outlink
->
time_base
);
frame
->
pts
=
s
->
next_pts
;
frame
->
pts
=
s
->
next_pts
;
if
(
s
->
next_pts
!=
AV_NOPTS_VALUE
)
s
->
next_pts
+=
frame
->
duration
;
s
->
next_pts
+=
av_rescale_q
(
nb_samples
,
(
AVRational
){
1
,
outlink
->
sample_rate
},
outlink
->
time_base
);
return
ff_filter_frame
(
outlink
,
frame
);
return
ff_filter_frame
(
outlink
,
frame
);
}
}
ret
=
ff_inlink_consume_frame
(
inlink
,
&
frame
);
if
(
s
->
input
)
if
(
ret
<
0
)
return
filter_frame
(
inlink
,
s
->
input
);
return
ret
;
if
(
ret
>
0
)
return
filter_frame
(
inlink
,
frame
);
if
(
ff_inlink_acknowledge_status
(
inlink
,
&
status
,
&
pts
))
{
if
(
status
==
AVERROR_EOF
)
s
->
eof
=
1
;
}
if
(
s
->
eof
&&
s
->
max_delay
)
{
if
(
s
->
eof
&&
s
->
max_delay
)
{
int
nb_samples
=
FFMIN
(
s
->
max_delay
,
2048
);
int
nb_samples
=
FFMIN
(
s
->
max_delay
,
2048
);
...
@@ -406,7 +428,11 @@ static int activate(AVFilterContext *ctx)
...
@@ -406,7 +428,11 @@ static int activate(AVFilterContext *ctx)
outlink
->
ch_layout
.
nb_channels
,
outlink
->
ch_layout
.
nb_channels
,
frame
->
format
);
frame
->
format
);
frame
->
duration
=
av_rescale_q
(
frame
->
nb_samples
,
(
AVRational
){
1
,
outlink
->
sample_rate
},
outlink
->
time_base
);
frame
->
pts
=
s
->
next_pts
;
frame
->
pts
=
s
->
next_pts
;
s
->
next_pts
+=
frame
->
duration
;
return
filter_frame
(
inlink
,
frame
);
return
filter_frame
(
inlink
,
frame
);
}
}
...
...
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