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
17a59a63
Commit
17a59a63
authored
Feb 20, 2022
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/framepool: fix alignment requirements for audio and video filters
parent
9da19c29
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
22 deletions
+18
-22
audio.c
libavfilter/audio.c
+5
-6
framepool.c
libavfilter/framepool.c
+8
-10
video.c
libavfilter/video.c
+5
-6
No files found.
libavfilter/audio.c
View file @
17a59a63
...
...
@@ -22,15 +22,13 @@
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/cpu.h"
#include "audio.h"
#include "avfilter.h"
#include "framepool.h"
#include "internal.h"
#define BUFFER_ALIGN 0
AVFrame
*
ff_null_get_audio_buffer
(
AVFilterLink
*
link
,
int
nb_samples
)
{
return
ff_get_audio_buffer
(
link
->
dst
->
outputs
[
0
],
nb_samples
);
...
...
@@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
AVFrame
*
frame
=
NULL
;
int
channels
=
link
->
channels
;
int
channel_layout_nb_channels
=
av_get_channel_layout_nb_channels
(
link
->
channel_layout
);
int
align
=
av_cpu_max_align
();
av_assert0
(
channels
==
channel_layout_nb_channels
||
!
channel_layout_nb_channels
);
if
(
!
link
->
frame_pool
)
{
link
->
frame_pool
=
ff_frame_pool_audio_init
(
av_buffer_allocz
,
channels
,
nb_samples
,
link
->
format
,
BUFFER_ALIGN
);
nb_samples
,
link
->
format
,
align
);
if
(
!
link
->
frame_pool
)
return
NULL
;
}
else
{
...
...
@@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
}
if
(
pool_channels
!=
channels
||
pool_nb_samples
<
nb_samples
||
pool_format
!=
link
->
format
||
pool_align
!=
BUFFER_ALIGN
)
{
pool_format
!=
link
->
format
||
pool_align
!=
align
)
{
ff_frame_pool_uninit
((
FFFramePool
**
)
&
link
->
frame_pool
);
link
->
frame_pool
=
ff_frame_pool_audio_init
(
av_buffer_allocz
,
channels
,
nb_samples
,
link
->
format
,
BUFFER_ALIGN
);
nb_samples
,
link
->
format
,
align
);
if
(
!
link
->
frame_pool
)
return
NULL
;
}
...
...
libavfilter/framepool.c
View file @
17a59a63
...
...
@@ -76,27 +76,25 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
}
if
(
!
pool
->
linesize
[
0
])
{
for
(
i
=
1
;
i
<=
align
;
i
+=
i
)
{
ret
=
av_image_fill_linesizes
(
pool
->
linesize
,
pool
->
format
,
FFALIGN
(
pool
->
width
,
i
));
FFALIGN
(
pool
->
width
,
align
));
if
(
ret
<
0
)
{
goto
fail
;
}
if
(
!
(
pool
->
linesize
[
0
]
&
(
pool
->
align
-
1
)))
break
;
}
for
(
i
=
0
;
i
<
4
&&
pool
->
linesize
[
i
];
i
++
)
{
pool
->
linesize
[
i
]
=
FFALIGN
(
pool
->
linesize
[
i
],
pool
->
align
);
if
((
pool
->
linesize
[
i
]
&
(
pool
->
align
-
1
)))
goto
fail
;
}
}
for
(
i
=
0
;
i
<
4
&&
pool
->
linesize
[
i
];
i
++
)
{
int
h
=
FFALIGN
(
pool
->
height
,
32
)
;
int
h
=
pool
->
height
;
if
(
i
==
1
||
i
==
2
)
h
=
AV_CEIL_RSHIFT
(
h
,
desc
->
log2_chroma_h
);
pool
->
pools
[
i
]
=
av_buffer_pool_init
(
pool
->
linesize
[
i
]
*
h
+
16
+
16
-
1
,
pool
->
pools
[
i
]
=
av_buffer_pool_init
(
pool
->
linesize
[
i
]
*
h
+
align
,
alloc
);
if
(
!
pool
->
pools
[
i
])
goto
fail
;
...
...
libavfilter/video.c
View file @
17a59a63
...
...
@@ -24,6 +24,7 @@
#include <stdio.h>
#include "libavutil/buffer.h"
#include "libavutil/cpu.h"
#include "libavutil/hwcontext.h"
#include "libavutil/imgutils.h"
...
...
@@ -32,9 +33,6 @@
#include "internal.h"
#include "video.h"
#define BUFFER_ALIGN 32
AVFrame
*
ff_null_get_video_buffer
(
AVFilterLink
*
link
,
int
w
,
int
h
)
{
return
ff_get_video_buffer
(
link
->
dst
->
outputs
[
0
],
w
,
h
);
...
...
@@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
int
pool_width
=
0
;
int
pool_height
=
0
;
int
pool_align
=
0
;
int
align
=
av_cpu_max_align
();
enum
AVPixelFormat
pool_format
=
AV_PIX_FMT_NONE
;
if
(
link
->
hw_frames_ctx
&&
...
...
@@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
if
(
!
link
->
frame_pool
)
{
link
->
frame_pool
=
ff_frame_pool_video_init
(
av_buffer_allocz
,
w
,
h
,
link
->
format
,
BUFFER_ALIGN
);
link
->
format
,
align
);
if
(
!
link
->
frame_pool
)
return
NULL
;
}
else
{
...
...
@@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
}
if
(
pool_width
!=
w
||
pool_height
!=
h
||
pool_format
!=
link
->
format
||
pool_align
!=
BUFFER_ALIGN
)
{
pool_format
!=
link
->
format
||
pool_align
!=
align
)
{
ff_frame_pool_uninit
((
FFFramePool
**
)
&
link
->
frame_pool
);
link
->
frame_pool
=
ff_frame_pool_video_init
(
av_buffer_allocz
,
w
,
h
,
link
->
format
,
BUFFER_ALIGN
);
link
->
format
,
align
);
if
(
!
link
->
frame_pool
)
return
NULL
;
}
...
...
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