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
a0d7ce14
Commit
a0d7ce14
authored
Oct 01, 2016
by
Timo Rothenpieler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avutil/hwcontext_cuda: align allocated frames
parent
68822da8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
15 deletions
+20
-15
hwcontext_cuda.c
libavutil/hwcontext_cuda.c
+20
-15
No files found.
libavutil/hwcontext_cuda.c
View file @
a0d7ce14
...
@@ -25,6 +25,8 @@
...
@@ -25,6 +25,8 @@
#include "pixdesc.h"
#include "pixdesc.h"
#include "pixfmt.h"
#include "pixfmt.h"
#define CUDA_FRAME_ALIGNMENT 256
typedef
struct
CUDAFramesContext
{
typedef
struct
CUDAFramesContext
{
int
shift_width
,
shift_height
;
int
shift_width
,
shift_height
;
}
CUDAFramesContext
;
}
CUDAFramesContext
;
...
@@ -83,6 +85,7 @@ fail:
...
@@ -83,6 +85,7 @@ fail:
static
int
cuda_frames_init
(
AVHWFramesContext
*
ctx
)
static
int
cuda_frames_init
(
AVHWFramesContext
*
ctx
)
{
{
CUDAFramesContext
*
priv
=
ctx
->
internal
->
priv
;
CUDAFramesContext
*
priv
=
ctx
->
internal
->
priv
;
int
aligned_width
=
FFALIGN
(
ctx
->
width
,
CUDA_FRAME_ALIGNMENT
);
int
i
;
int
i
;
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
supported_formats
);
i
++
)
{
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
supported_formats
);
i
++
)
{
...
@@ -103,10 +106,10 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
...
@@ -103,10 +106,10 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
switch
(
ctx
->
sw_format
)
{
switch
(
ctx
->
sw_format
)
{
case
AV_PIX_FMT_NV12
:
case
AV_PIX_FMT_NV12
:
case
AV_PIX_FMT_YUV420P
:
case
AV_PIX_FMT_YUV420P
:
size
=
ctx
->
width
*
ctx
->
height
*
3
/
2
;
size
=
aligned_
width
*
ctx
->
height
*
3
/
2
;
break
;
break
;
case
AV_PIX_FMT_YUV444P
:
case
AV_PIX_FMT_YUV444P
:
size
=
ctx
->
width
*
ctx
->
height
*
3
;
size
=
aligned_
width
*
ctx
->
height
*
3
;
break
;
break
;
}
}
...
@@ -120,6 +123,8 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
...
@@ -120,6 +123,8 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
static
int
cuda_get_buffer
(
AVHWFramesContext
*
ctx
,
AVFrame
*
frame
)
static
int
cuda_get_buffer
(
AVHWFramesContext
*
ctx
,
AVFrame
*
frame
)
{
{
int
aligned_width
=
FFALIGN
(
ctx
->
width
,
CUDA_FRAME_ALIGNMENT
);
frame
->
buf
[
0
]
=
av_buffer_pool_get
(
ctx
->
pool
);
frame
->
buf
[
0
]
=
av_buffer_pool_get
(
ctx
->
pool
);
if
(
!
frame
->
buf
[
0
])
if
(
!
frame
->
buf
[
0
])
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -127,25 +132,25 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
...
@@ -127,25 +132,25 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
switch
(
ctx
->
sw_format
)
{
switch
(
ctx
->
sw_format
)
{
case
AV_PIX_FMT_NV12
:
case
AV_PIX_FMT_NV12
:
frame
->
data
[
0
]
=
frame
->
buf
[
0
]
->
data
;
frame
->
data
[
0
]
=
frame
->
buf
[
0
]
->
data
;
frame
->
data
[
1
]
=
frame
->
data
[
0
]
+
ctx
->
width
*
ctx
->
height
;
frame
->
data
[
1
]
=
frame
->
data
[
0
]
+
aligned_
width
*
ctx
->
height
;
frame
->
linesize
[
0
]
=
ctx
->
width
;
frame
->
linesize
[
0
]
=
aligned_
width
;
frame
->
linesize
[
1
]
=
ctx
->
width
;
frame
->
linesize
[
1
]
=
aligned_
width
;
break
;
break
;
case
AV_PIX_FMT_YUV420P
:
case
AV_PIX_FMT_YUV420P
:
frame
->
data
[
0
]
=
frame
->
buf
[
0
]
->
data
;
frame
->
data
[
0
]
=
frame
->
buf
[
0
]
->
data
;
frame
->
data
[
2
]
=
frame
->
data
[
0
]
+
ctx
->
width
*
ctx
->
height
;
frame
->
data
[
2
]
=
frame
->
data
[
0
]
+
aligned_
width
*
ctx
->
height
;
frame
->
data
[
1
]
=
frame
->
data
[
2
]
+
ctx
->
width
*
ctx
->
height
/
4
;
frame
->
data
[
1
]
=
frame
->
data
[
2
]
+
aligned_
width
*
ctx
->
height
/
4
;
frame
->
linesize
[
0
]
=
ctx
->
width
;
frame
->
linesize
[
0
]
=
aligned_
width
;
frame
->
linesize
[
1
]
=
ctx
->
width
/
2
;
frame
->
linesize
[
1
]
=
aligned_
width
/
2
;
frame
->
linesize
[
2
]
=
ctx
->
width
/
2
;
frame
->
linesize
[
2
]
=
aligned_
width
/
2
;
break
;
break
;
case
AV_PIX_FMT_YUV444P
:
case
AV_PIX_FMT_YUV444P
:
frame
->
data
[
0
]
=
frame
->
buf
[
0
]
->
data
;
frame
->
data
[
0
]
=
frame
->
buf
[
0
]
->
data
;
frame
->
data
[
1
]
=
frame
->
data
[
0
]
+
ctx
->
width
*
ctx
->
height
;
frame
->
data
[
1
]
=
frame
->
data
[
0
]
+
aligned_
width
*
ctx
->
height
;
frame
->
data
[
2
]
=
frame
->
data
[
1
]
+
ctx
->
width
*
ctx
->
height
;
frame
->
data
[
2
]
=
frame
->
data
[
1
]
+
aligned_
width
*
ctx
->
height
;
frame
->
linesize
[
0
]
=
ctx
->
width
;
frame
->
linesize
[
0
]
=
aligned_
width
;
frame
->
linesize
[
1
]
=
ctx
->
width
;
frame
->
linesize
[
1
]
=
aligned_
width
;
frame
->
linesize
[
2
]
=
ctx
->
width
;
frame
->
linesize
[
2
]
=
aligned_
width
;
break
;
break
;
default:
default:
av_frame_unref
(
frame
);
av_frame_unref
(
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