Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
1c01b025
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,发现更多精彩内容 >>
提交
1c01b025
编写于
11月 09, 2013
作者:
A
Anton Khirnov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mpegvideo_enc: use the AVFrame API properly.
上级
a6064b12
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
25 deletion
+33
-25
libavcodec/mpegvideo.h
libavcodec/mpegvideo.h
+3
-0
libavcodec/mpegvideo_enc.c
libavcodec/mpegvideo_enc.c
+30
-25
未找到文件。
libavcodec/mpegvideo.h
浏览文件 @
1c01b025
...
...
@@ -754,6 +754,9 @@ typedef struct MpegEncContext {
ERContext
er
;
int
error_rate
;
/* temporary frames used by b_frame_strategy = 2 */
AVFrame
*
tmp_frames
[
MAX_B_FRAMES
+
2
];
}
MpegEncContext
;
#define REBASE_PICTURE(pic, new_ctx, old_ctx) \
...
...
libavcodec/mpegvideo_enc.c
浏览文件 @
1c01b025
...
...
@@ -221,7 +221,7 @@ static void MPV_encode_defaults(MpegEncContext *s)
av_cold
int
ff_MPV_encode_init
(
AVCodecContext
*
avctx
)
{
MpegEncContext
*
s
=
avctx
->
priv_data
;
int
i
;
int
i
,
ret
;
int
chroma_h_shift
,
chroma_v_shift
;
MPV_encode_defaults
(
s
);
...
...
@@ -780,12 +780,29 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
FF_ENABLE_DEPRECATION_WARNINGS
;
#endif
if
(
avctx
->
b_frame_strategy
==
2
)
{
for
(
i
=
0
;
i
<
s
->
max_b_frames
+
2
;
i
++
)
{
s
->
tmp_frames
[
i
]
=
av_frame_alloc
();
if
(
!
s
->
tmp_frames
[
i
])
return
AVERROR
(
ENOMEM
);
s
->
tmp_frames
[
i
]
->
format
=
AV_PIX_FMT_YUV420P
;
s
->
tmp_frames
[
i
]
->
width
=
s
->
width
>>
avctx
->
brd_scale
;
s
->
tmp_frames
[
i
]
->
height
=
s
->
height
>>
avctx
->
brd_scale
;
ret
=
av_frame_get_buffer
(
s
->
tmp_frames
[
i
],
32
);
if
(
ret
<
0
)
return
ret
;
}
}
return
0
;
}
av_cold
int
ff_MPV_encode_end
(
AVCodecContext
*
avctx
)
{
MpegEncContext
*
s
=
avctx
->
priv_data
;
int
i
;
ff_rate_control_uninit
(
s
);
...
...
@@ -796,6 +813,9 @@ av_cold int ff_MPV_encode_end(AVCodecContext *avctx)
av_freep
(
&
avctx
->
extradata
);
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
s
->
tmp_frames
);
i
++
)
av_frame_free
(
&
s
->
tmp_frames
[
i
]);
return
0
;
}
...
...
@@ -1025,7 +1045,6 @@ static int estimate_best_b_count(MpegEncContext *s)
{
AVCodec
*
codec
=
avcodec_find_encoder
(
s
->
avctx
->
codec_id
);
AVCodecContext
*
c
=
avcodec_alloc_context3
(
NULL
);
AVFrame
input
[
MAX_B_FRAMES
+
2
];
const
int
scale
=
s
->
avctx
->
brd_scale
;
int
i
,
j
,
out_size
,
p_lambda
,
b_lambda
,
lambda2
;
int64_t
best_rd
=
INT64_MAX
;
...
...
@@ -1060,19 +1079,9 @@ static int estimate_best_b_count(MpegEncContext *s)
return
-
1
;
for
(
i
=
0
;
i
<
s
->
max_b_frames
+
2
;
i
++
)
{
int
ysize
=
c
->
width
*
c
->
height
;
int
csize
=
(
c
->
width
/
2
)
*
(
c
->
height
/
2
);
Picture
pre_input
,
*
pre_input_ptr
=
i
?
s
->
input_picture
[
i
-
1
]
:
s
->
next_picture_ptr
;
avcodec_get_frame_defaults
(
&
input
[
i
]);
input
[
i
].
data
[
0
]
=
av_malloc
(
ysize
+
2
*
csize
);
input
[
i
].
data
[
1
]
=
input
[
i
].
data
[
0
]
+
ysize
;
input
[
i
].
data
[
2
]
=
input
[
i
].
data
[
1
]
+
csize
;
input
[
i
].
linesize
[
0
]
=
c
->
width
;
input
[
i
].
linesize
[
1
]
=
input
[
i
].
linesize
[
2
]
=
c
->
width
/
2
;
if
(
pre_input_ptr
&&
(
!
i
||
s
->
input_picture
[
i
-
1
]))
{
pre_input
=
*
pre_input_ptr
;
...
...
@@ -1082,13 +1091,13 @@ static int estimate_best_b_count(MpegEncContext *s)
pre_input
.
f
.
data
[
2
]
+=
INPLACE_OFFSET
;
}
s
->
dsp
.
shrink
[
scale
](
input
[
i
].
data
[
0
],
input
[
i
].
linesize
[
0
],
s
->
dsp
.
shrink
[
scale
](
s
->
tmp_frames
[
i
]
->
data
[
0
],
s
->
tmp_frames
[
i
]
->
linesize
[
0
],
pre_input
.
f
.
data
[
0
],
pre_input
.
f
.
linesize
[
0
],
c
->
width
,
c
->
height
);
s
->
dsp
.
shrink
[
scale
](
input
[
i
].
data
[
1
],
input
[
i
].
linesize
[
1
],
s
->
dsp
.
shrink
[
scale
](
s
->
tmp_frames
[
i
]
->
data
[
1
],
s
->
tmp_frames
[
i
]
->
linesize
[
1
],
pre_input
.
f
.
data
[
1
],
pre_input
.
f
.
linesize
[
1
],
c
->
width
>>
1
,
c
->
height
>>
1
);
s
->
dsp
.
shrink
[
scale
](
input
[
i
].
data
[
2
],
input
[
i
].
linesize
[
2
],
s
->
dsp
.
shrink
[
scale
](
s
->
tmp_frames
[
i
]
->
data
[
2
],
s
->
tmp_frames
[
i
]
->
linesize
[
2
],
pre_input
.
f
.
data
[
2
],
pre_input
.
f
.
linesize
[
2
],
c
->
width
>>
1
,
c
->
height
>>
1
);
}
...
...
@@ -1102,21 +1111,21 @@ static int estimate_best_b_count(MpegEncContext *s)
c
->
error
[
0
]
=
c
->
error
[
1
]
=
c
->
error
[
2
]
=
0
;
input
[
0
].
pict_type
=
AV_PICTURE_TYPE_I
;
input
[
0
].
quality
=
1
*
FF_QP2LAMBDA
;
s
->
tmp_frames
[
0
]
->
pict_type
=
AV_PICTURE_TYPE_I
;
s
->
tmp_frames
[
0
]
->
quality
=
1
*
FF_QP2LAMBDA
;
out_size
=
encode_frame
(
c
,
&
input
[
0
]);
out_size
=
encode_frame
(
c
,
s
->
tmp_frames
[
0
]);
//rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT;
for
(
i
=
0
;
i
<
s
->
max_b_frames
+
1
;
i
++
)
{
int
is_p
=
i
%
(
j
+
1
)
==
j
||
i
==
s
->
max_b_frames
;
input
[
i
+
1
].
pict_type
=
is_p
?
s
->
tmp_frames
[
i
+
1
]
->
pict_type
=
is_p
?
AV_PICTURE_TYPE_P
:
AV_PICTURE_TYPE_B
;
input
[
i
+
1
].
quality
=
is_p
?
p_lambda
:
b_lambda
;
s
->
tmp_frames
[
i
+
1
]
->
quality
=
is_p
?
p_lambda
:
b_lambda
;
out_size
=
encode_frame
(
c
,
&
input
[
i
+
1
]);
out_size
=
encode_frame
(
c
,
s
->
tmp_frames
[
i
+
1
]);
rd
+=
(
out_size
*
lambda2
)
>>
(
FF_LAMBDA_SHIFT
-
3
);
}
...
...
@@ -1138,10 +1147,6 @@ static int estimate_best_b_count(MpegEncContext *s)
avcodec_close
(
c
);
av_freep
(
&
c
);
for
(
i
=
0
;
i
<
s
->
max_b_frames
+
2
;
i
++
)
{
av_freep
(
&
input
[
i
].
data
[
0
]);
}
return
best_b_count
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录