Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
96cba1c5
Commit
96cba1c5
authored
Sep 07, 2016
by
Timo Rothenpieler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/nvenc: use av_image_copy for copying frame data
parent
30a09eae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
73 deletions
+21
-73
nvenc.c
libavcodec/nvenc.c
+21
-73
No files found.
libavcodec/nvenc.c
View file @
96cba1c5
...
@@ -1276,84 +1276,32 @@ static NvencSurface *get_free_frame(NvencContext *ctx)
...
@@ -1276,84 +1276,32 @@ static NvencSurface *get_free_frame(NvencContext *ctx)
return
NULL
;
return
NULL
;
}
}
static
int
nvenc_copy_frame
(
AVCodecContext
*
avctx
,
NvencSurface
*
inSurf
,
static
int
nvenc_copy_frame
(
AVCodecContext
*
avctx
,
NvencSurface
*
nv_surface
,
NV_ENC_LOCK_INPUT_BUFFER
*
lock
BufferP
arams
,
const
AVFrame
*
frame
)
NV_ENC_LOCK_INPUT_BUFFER
*
lock
_buffer_p
arams
,
const
AVFrame
*
frame
)
{
{
uint8_t
*
buf
=
lockBufferParams
->
bufferDataPtr
;
int
dst_linesize
[
4
]
=
{
int
off
=
inSurf
->
height
*
lockBufferParams
->
pitch
;
lock_buffer_params
->
pitch
,
lock_buffer_params
->
pitch
,
if
(
frame
->
format
==
AV_PIX_FMT_YUV420P
)
{
lock_buffer_params
->
pitch
,
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
lock_buffer_params
->
pitch
frame
->
data
[
0
],
frame
->
linesize
[
0
],
};
avctx
->
width
,
avctx
->
height
);
uint8_t
*
dst_data
[
4
];
int
ret
;
buf
+=
off
;
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
>>
1
,
frame
->
data
[
2
],
frame
->
linesize
[
2
],
avctx
->
width
>>
1
,
avctx
->
height
>>
1
);
buf
+=
off
>>
2
;
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
>>
1
,
frame
->
data
[
1
],
frame
->
linesize
[
1
],
avctx
->
width
>>
1
,
avctx
->
height
>>
1
);
}
else
if
(
frame
->
format
==
AV_PIX_FMT_NV12
)
{
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
frame
->
data
[
0
],
frame
->
linesize
[
0
],
avctx
->
width
,
avctx
->
height
);
buf
+=
off
;
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
frame
->
data
[
1
],
frame
->
linesize
[
1
],
avctx
->
width
,
avctx
->
height
>>
1
);
}
else
if
(
frame
->
format
==
AV_PIX_FMT_P010
)
{
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
frame
->
data
[
0
],
frame
->
linesize
[
0
],
avctx
->
width
<<
1
,
avctx
->
height
);
buf
+=
off
;
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
frame
->
data
[
1
],
frame
->
linesize
[
1
],
avctx
->
width
<<
1
,
avctx
->
height
>>
1
);
}
else
if
(
frame
->
format
==
AV_PIX_FMT_YUV444P
)
{
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
frame
->
data
[
0
],
frame
->
linesize
[
0
],
avctx
->
width
,
avctx
->
height
);
buf
+=
off
;
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
frame
->
data
[
1
],
frame
->
linesize
[
1
],
avctx
->
width
,
avctx
->
height
);
buf
+=
off
;
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
frame
->
data
[
2
],
frame
->
linesize
[
2
],
avctx
->
width
,
avctx
->
height
);
}
else
if
(
frame
->
format
==
AV_PIX_FMT_YUV444P16
)
{
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
frame
->
data
[
0
],
frame
->
linesize
[
0
],
avctx
->
width
<<
1
,
avctx
->
height
);
buf
+=
off
;
if
(
frame
->
format
==
AV_PIX_FMT_YUV420P
)
dst_linesize
[
1
]
=
dst_linesize
[
2
]
>>=
1
;
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
ret
=
av_image_fill_pointers
(
dst_data
,
frame
->
format
,
nv_surface
->
height
,
frame
->
data
[
1
],
frame
->
linesize
[
1
],
lock_buffer_params
->
bufferDataPtr
,
dst_linesize
);
avctx
->
width
<<
1
,
avctx
->
height
);
if
(
ret
<
0
)
return
ret
;
buf
+=
off
;
if
(
frame
->
format
==
AV_PIX_FMT_YUV420P
)
FFSWAP
(
uint8_t
*
,
dst_data
[
1
],
dst_data
[
2
]);
av_image_copy_plane
(
buf
,
lockBufferParams
->
pitch
,
av_image_copy
(
dst_data
,
dst_linesize
,
frame
->
data
[
2
],
frame
->
linesize
[
2
],
(
const
uint8_t
**
)
frame
->
data
,
frame
->
linesize
,
frame
->
format
,
avctx
->
width
<<
1
,
avctx
->
height
);
nv_surface
->
width
,
nv_surface
->
height
);
}
else
{
av_log
(
avctx
,
AV_LOG_FATAL
,
"Invalid pixel format!
\n
"
);
return
AVERROR
(
EINVAL
);
}
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