Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
31a46750
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
31a46750
编写于
3月 06, 2014
作者:
A
Anton Khirnov
提交者:
Luca Barbato
5月 11, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vda: use hwaccel private data for internal bitstream buffer
上级
66e6c8a7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
18 deletion
+38
-18
libavcodec/vda.h
libavcodec/vda.h
+3
-3
libavcodec/vda_h264.c
libavcodec/vda_h264.c
+35
-15
未找到文件。
libavcodec/vda.h
浏览文件 @
31a46750
...
...
@@ -112,17 +112,17 @@ struct vda_context {
OSType
cv_pix_fmt_type
;
/**
*
The current bitstream buffer.
*
unused
*/
uint8_t
*
priv_bitstream
;
/**
*
The current size of the bitstream.
*
unused
*/
int
priv_bitstream_size
;
/**
*
The reference size used for fast reallocation.
*
unused
*/
int
priv_allocated_size
;
};
...
...
libavcodec/vda_h264.c
浏览文件 @
31a46750
...
...
@@ -28,6 +28,17 @@
#include "h264.h"
#include "vda.h"
typedef
struct
VDAContext
{
// The current bitstream buffer.
uint8_t
*
bitstream
;
// The current size of the bitstream.
int
bitstream_size
;
// The reference size used for fast reallocation.
int
allocated_size
;
}
VDAContext
;
/* Decoder callback that adds the VDA frame to the queue in display order. */
static
void
vda_decoder_callback
(
void
*
vda_hw_ctx
,
CFDictionaryRef
user_info
,
...
...
@@ -46,15 +57,15 @@ static void vda_decoder_callback(void *vda_hw_ctx,
vda_ctx
->
cv_buffer
=
CVPixelBufferRetain
(
image_buffer
);
}
static
int
vda_sync_decode
(
struct
vda_context
*
vda_ctx
)
static
int
vda_sync_decode
(
VDAContext
*
ctx
,
struct
vda_context
*
vda_ctx
)
{
OSStatus
status
;
CFDataRef
coded_frame
;
uint32_t
flush_flags
=
1
<<
0
;
///< kVDADecoderFlush_emitFrames
coded_frame
=
CFDataCreate
(
kCFAllocatorDefault
,
vda_ctx
->
priv_
bitstream
,
vda_ctx
->
priv_
bitstream_size
);
ctx
->
bitstream
,
ctx
->
bitstream_size
);
status
=
VDADecoderDecode
(
vda_ctx
->
decoder
,
0
,
coded_frame
,
NULL
);
...
...
@@ -71,12 +82,13 @@ static int vda_h264_start_frame(AVCodecContext *avctx,
av_unused
const
uint8_t
*
buffer
,
av_unused
uint32_t
size
)
{
VDAContext
*
vda
=
avctx
->
internal
->
hwaccel_priv_data
;
struct
vda_context
*
vda_ctx
=
avctx
->
hwaccel_context
;
if
(
!
vda_ctx
->
decoder
)
return
-
1
;
vda
_ctx
->
priv_
bitstream_size
=
0
;
vda
->
bitstream_size
=
0
;
return
0
;
}
...
...
@@ -85,24 +97,25 @@ static int vda_h264_decode_slice(AVCodecContext *avctx,
const
uint8_t
*
buffer
,
uint32_t
size
)
{
VDAContext
*
vda
=
avctx
->
internal
->
hwaccel_priv_data
;
struct
vda_context
*
vda_ctx
=
avctx
->
hwaccel_context
;
void
*
tmp
;
if
(
!
vda_ctx
->
decoder
)
return
-
1
;
tmp
=
av_fast_realloc
(
vda
_ctx
->
priv_
bitstream
,
&
vda
_ctx
->
priv_
allocated_size
,
vda
_ctx
->
priv_
bitstream_size
+
size
+
4
);
tmp
=
av_fast_realloc
(
vda
->
bitstream
,
&
vda
->
allocated_size
,
vda
->
bitstream_size
+
size
+
4
);
if
(
!
tmp
)
return
AVERROR
(
ENOMEM
);
vda
_ctx
->
priv_
bitstream
=
tmp
;
vda
->
bitstream
=
tmp
;
AV_WB32
(
vda
_ctx
->
priv_bitstream
+
vda_ctx
->
priv_
bitstream_size
,
size
);
memcpy
(
vda
_ctx
->
priv_bitstream
+
vda_ctx
->
priv_
bitstream_size
+
4
,
buffer
,
size
);
AV_WB32
(
vda
->
bitstream
+
vda
->
bitstream_size
,
size
);
memcpy
(
vda
->
bitstream
+
vda
->
bitstream_size
+
4
,
buffer
,
size
);
vda
_ctx
->
priv_
bitstream_size
+=
size
+
4
;
vda
->
bitstream_size
+=
size
+
4
;
return
0
;
}
...
...
@@ -110,14 +123,15 @@ static int vda_h264_decode_slice(AVCodecContext *avctx,
static
int
vda_h264_end_frame
(
AVCodecContext
*
avctx
)
{
H264Context
*
h
=
avctx
->
priv_data
;
VDAContext
*
vda
=
avctx
->
internal
->
hwaccel_priv_data
;
struct
vda_context
*
vda_ctx
=
avctx
->
hwaccel_context
;
AVFrame
*
frame
=
&
h
->
cur_pic_ptr
->
f
;
int
status
;
if
(
!
vda_ctx
->
decoder
||
!
vda
_ctx
->
priv_
bitstream
)
if
(
!
vda_ctx
->
decoder
||
!
vda
->
bitstream
)
return
-
1
;
status
=
vda_sync_decode
(
vda_ctx
);
status
=
vda_sync_decode
(
vda
,
vda
_ctx
);
frame
->
data
[
3
]
=
(
void
*
)
vda_ctx
->
cv_buffer
;
if
(
status
)
...
...
@@ -217,11 +231,15 @@ int ff_vda_destroy_decoder(struct vda_context *vda_ctx)
if
(
vda_ctx
->
decoder
)
status
=
VDADecoderDestroy
(
vda_ctx
->
decoder
);
av_freep
(
&
vda_ctx
->
priv_bitstream
);
return
status
;
}
static
void
vda_h264_uninit
(
AVCodecContext
*
avctx
)
{
VDAContext
*
vda
=
avctx
->
internal
->
priv_data
;
av_freep
(
&
vda
->
bitstream
);
}
AVHWAccel
ff_h264_vda_hwaccel
=
{
.
name
=
"h264_vda"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
...
...
@@ -230,4 +248,6 @@ AVHWAccel ff_h264_vda_hwaccel = {
.
start_frame
=
vda_h264_start_frame
,
.
decode_slice
=
vda_h264_decode_slice
,
.
end_frame
=
vda_h264_end_frame
,
.
uninit
=
vda_h264_uninit
,
.
priv_data_size
=
sizeof
(
VDAContext
),
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录