Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
6ef30976
Commit
6ef30976
authored
Oct 22, 2013
by
Derek Buitenhuis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
timefilter: Handle memory allocation failure
Signed-off-by:
Derek Buitenhuis
<
derek.buitenhuis@gmail.com
>
parent
fc7be7dd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
0 deletions
+16
-0
jack_audio.c
libavdevice/jack_audio.c
+4
-0
timefilter.c
libavdevice/timefilter.c
+8
-0
timefilter.h
libavdevice/timefilter.h
+2
-0
v4l2.c
libavdevice/v4l2.c
+2
-0
No files found.
libavdevice/jack_audio.c
View file @
6ef30976
...
@@ -188,6 +188,10 @@ static int start_jack(AVFormatContext *context)
...
@@ -188,6 +188,10 @@ static int start_jack(AVFormatContext *context)
/* Create time filter */
/* Create time filter */
self
->
timefilter
=
ff_timefilter_new
(
1
.
0
/
self
->
sample_rate
,
self
->
buffer_size
,
1
.
5
);
self
->
timefilter
=
ff_timefilter_new
(
1
.
0
/
self
->
sample_rate
,
self
->
buffer_size
,
1
.
5
);
if
(
!
self
->
timefilter
)
{
jack_client_close
(
self
->
client
);
return
AVERROR
(
ENOMEM
);
}
/* Create FIFO buffers */
/* Create FIFO buffers */
self
->
filled_pkts
=
av_fifo_alloc
(
FIFO_PACKETS_NUM
*
sizeof
(
AVPacket
));
self
->
filled_pkts
=
av_fifo_alloc
(
FIFO_PACKETS_NUM
*
sizeof
(
AVPacket
));
...
...
libavdevice/timefilter.c
View file @
6ef30976
...
@@ -49,6 +49,10 @@ TimeFilter *ff_timefilter_new(double time_base,
...
@@ -49,6 +49,10 @@ TimeFilter *ff_timefilter_new(double time_base,
{
{
TimeFilter
*
self
=
av_mallocz
(
sizeof
(
TimeFilter
));
TimeFilter
*
self
=
av_mallocz
(
sizeof
(
TimeFilter
));
double
o
=
2
*
M_PI
*
bandwidth
*
period
*
time_base
;
double
o
=
2
*
M_PI
*
bandwidth
*
period
*
time_base
;
if
(
!
self
)
return
NULL
;
self
->
clock_period
=
time_base
;
self
->
clock_period
=
time_base
;
self
->
feedback2_factor
=
qexpneg
(
M_SQRT2
*
o
);
self
->
feedback2_factor
=
qexpneg
(
M_SQRT2
*
o
);
self
->
feedback3_factor
=
qexpneg
(
o
*
o
)
/
period
;
self
->
feedback3_factor
=
qexpneg
(
o
*
o
)
/
period
;
...
@@ -121,6 +125,10 @@ int main(void)
...
@@ -121,6 +125,10 @@ int main(void)
for
(
par1
=
bestpar1
*
0
.
8
;
par1
<=
bestpar1
*
1
.
21
;
par1
+=
bestpar1
*
0
.
05
)
{
for
(
par1
=
bestpar1
*
0
.
8
;
par1
<=
bestpar1
*
1
.
21
;
par1
+=
bestpar1
*
0
.
05
)
{
double
error
=
0
;
double
error
=
0
;
TimeFilter
*
tf
=
ff_timefilter_new
(
1
,
par0
,
par1
);
TimeFilter
*
tf
=
ff_timefilter_new
(
1
,
par0
,
par1
);
if
(
!
tf
)
{
printf
(
"Could not alocate memory for timefilter.
\n
"
);
exit
(
1
);
}
for
(
i
=
0
;
i
<
SAMPLES
;
i
++
)
{
for
(
i
=
0
;
i
<
SAMPLES
;
i
++
)
{
double
filtered
;
double
filtered
;
filtered
=
ff_timefilter_update
(
tf
,
samples
[
i
],
i
?
(
samplet
[
i
]
-
samplet
[
i
-
1
])
:
1
);
filtered
=
ff_timefilter_update
(
tf
,
samples
[
i
],
i
?
(
samplet
[
i
]
-
samplet
[
i
-
1
])
:
1
);
...
...
libavdevice/timefilter.h
View file @
6ef30976
...
@@ -58,6 +58,8 @@ typedef struct TimeFilter TimeFilter;
...
@@ -58,6 +58,8 @@ typedef struct TimeFilter TimeFilter;
* @param period expected update interval, in input units
* @param period expected update interval, in input units
* @param brandwidth filtering bandwidth, in Hz
* @param brandwidth filtering bandwidth, in Hz
*
*
* @return a pointer to a TimeFilter struct, or NULL on error
*
* For more details about these parameters and background concepts please see:
* For more details about these parameters and background concepts please see:
* http://www.kokkinizita.net/papers/usingdll.pdf
* http://www.kokkinizita.net/papers/usingdll.pdf
*/
*/
...
...
libavdevice/v4l2.c
View file @
6ef30976
...
@@ -455,6 +455,8 @@ static int init_convert_timestamp(AVFormatContext *ctx, int64_t ts)
...
@@ -455,6 +455,8 @@ static int init_convert_timestamp(AVFormatContext *ctx, int64_t ts)
av_log
(
ctx
,
AV_LOG_INFO
,
"Detected monotonic timestamps, converting
\n
"
);
av_log
(
ctx
,
AV_LOG_INFO
,
"Detected monotonic timestamps, converting
\n
"
);
/* microseconds instead of seconds, MHz instead of Hz */
/* microseconds instead of seconds, MHz instead of Hz */
s
->
timefilter
=
ff_timefilter_new
(
1
,
period
,
1.0E-6
);
s
->
timefilter
=
ff_timefilter_new
(
1
,
period
,
1.0E-6
);
if
(
!
s
->
timefilter
)
return
AVERROR
(
ENOMEM
);
s
->
ts_mode
=
V4L_TS_CONVERT_READY
;
s
->
ts_mode
=
V4L_TS_CONVERT_READY
;
return
0
;
return
0
;
}
}
...
...
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