Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
merge_av
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
胡斌
2018-12-13 08:47:53 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d97baa41cd12cbc0fe91e42862a91980cd69ad68
d97baa41
1 parent
7fe27c9f
print the run time and speed ratio for encoding
fix the bug for RGB2YUV
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
27 行增加
和
6 行删除
pip/AVTranscoder.cpp
pip/AVTranscoder.h
pip/merge_pip.cpp
pip/pip.vcxproj
pip/pip.vcxproj.filters
pip/tools.cpp
pip/AVTranscoder.cpp
查看文件 @
d97baa4
#include "AVTranscoder.h"
#include "tools.h"
extern
"C"
{
#include <libswscale/swscale.h>
}
...
...
@@ -10,6 +12,9 @@ extern "C" {
#define SCALED_H 60
#define SRC_W 320
#define SRC_H 240
uint8_t
blank_r
=
0x16
;
uint8_t
blank_g
=
0x5a
;
uint8_t
blank_b
=
0x82
;
CAVTranscoder
::
CAVTranscoder
(
bool
bOne2One
)
:
_start_time
(
INT64_MAX
),
...
...
@@ -43,6 +48,7 @@ _last_videos_got(-1)
printf
(
"Error alloc frame buffer for scaling video frame"
);
}
}
RGB2YUV
(
blank_r
,
blank_g
,
blank_b
,
&
_blank_y
,
&
_blank_u
,
&
_blank_v
);
}
...
...
@@ -342,9 +348,9 @@ int CAVTranscoder::open_output_file(const char *filename)
}
}
if
(
fill_pure_color
){
//fill with pure color
memset
(
pDstFrame
->
data
[
0
],
0
,
_nOutputWidth
*
_nOutputHeight
);
memset
(
pDstFrame
->
data
[
1
],
0x80
,
_nOutputWidth
*
_nOutputHeight
/
4
);
memset
(
pDstFrame
->
data
[
2
],
0x80
,
_nOutputWidth
*
_nOutputHeight
/
4
);
memset
(
pDstFrame
->
data
[
0
],
_blank_y
,
_nOutputWidth
*
_nOutputHeight
);
memset
(
pDstFrame
->
data
[
1
],
_blank_u
,
_nOutputWidth
*
_nOutputHeight
/
4
);
memset
(
pDstFrame
->
data
[
2
],
_blank_v
,
_nOutputWidth
*
_nOutputHeight
/
4
);
}
int
imageIdx
=
0
;
...
...
@@ -422,7 +428,10 @@ int CAVTranscoder::open_output_file(const char *filename)
int
nDstSize
=
avpicture_get_size
(
AV_PIX_FMT_YUV420P
,
_nOutputWidth
,
_nOutputHeight
);
uint8_t
*
dstbuf
=
new
uint8_t
[
nDstSize
];
avpicture_fill
((
AVPicture
*
)
pDstFrame
,
dstbuf
,
AV_PIX_FMT_YUV420P
,
_nOutputWidth
,
_nOutputHeight
);
memset
(
dstbuf
,
0x80
,
nDstSize
);
memset
(
pDstFrame
->
data
[
0
],
_blank_y
,
_nOutputWidth
*
_nOutputHeight
);
memset
(
pDstFrame
->
data
[
1
],
_blank_u
,
_nOutputWidth
*
_nOutputHeight
/
4
);
memset
(
pDstFrame
->
data
[
2
],
_blank_v
,
_nOutputWidth
*
_nOutputHeight
/
4
);
if
(
decoders_got_frame
.
size
()
==
2
){
if
(
_last_videos_got
!=
2
)
{
...
...
pip/AVTranscoder.h
查看文件 @
d97baa4
...
...
@@ -44,6 +44,8 @@ private:
struct
SwsContext
*
_swsCtx
;
AVFrame
*
_scaledFrame
;
int
_last_videos_got
;
uint8_t
_blank_y
,
_blank_u
,
_blank_v
;
public
:
void
set_max_audio
(
int
max_audio
);
};
...
...
pip/merge_pip.cpp
查看文件 @
d97baa4
...
...
@@ -961,6 +961,8 @@ int load_record_info(char * record_info)
int
process_av_files
(
char
*
record_info
)
{
time_t
start
,
end
;
time
(
&
start
);
load_record_info
(
record_info
);
get_outinfo_file_name
(
record_info
);
...
...
@@ -1014,6 +1016,10 @@ int process_av_files(char * record_info)
save_out_info
(((
double
)
cur_time
)
/
1000.0
,
out_media_file
.
c_str
());
time
(
&
end
);
printf
(
"
\n
finished,used %"
PRIu64
" second,encoded %.0lf second, the speed ratio is %.3lfX
\n
"
,
end
-
start
,
(
double
)
cur_time
/
1000
,
cur_time
/
1000.0
/
(
end
-
start
));
return
0
;
}
...
...
pip/pip.vcxproj
查看文件 @
d97baa4
...
...
@@ -93,6 +93,7 @@
<ClInclude Include="AudioDecoder.h" />
<ClInclude Include="AVDecoder.h" />
<ClInclude Include="media_info.h" />
<ClInclude Include="tools.h" />
<ClInclude Include="VideoDecoder.h" />
<ClInclude Include="AVTranscoder.h" />
</ItemGroup>
...
...
pip/pip.vcxproj.filters
查看文件 @
d97baa4
...
...
@@ -53,5 +53,8 @@
<ClInclude Include="AVTranscoder.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="tools.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
...
...
pip/tools.cpp
查看文件 @
d97baa4
...
...
@@ -39,6 +39,6 @@ time_t calc_sec1970(int Y, int M, int D, int h, int m, int s)
void
RGB2YUV
(
unsigned
char
r
,
unsigned
char
g
,
unsigned
char
b
,
unsigned
char
*
y
,
unsigned
char
*
u
,
unsigned
char
*
v
){
*
y
=
(
unsigned
char
)(
0.30
*
r
+
0.59
*
g
+
0.11
*
b
);
*
u
=
(
unsigned
char
)(
0.493
*
(
b
-
(
*
y
)));
*
v
=
(
unsigned
char
)(
0.877
*
(
r
-
(
*
y
)));
*
u
=
(
unsigned
char
)(
0.493
*
(
b
-
(
*
y
))
+
128
);
*
v
=
(
unsigned
char
)(
0.877
*
(
r
-
(
*
y
))
+
128
);
}
...
...
请
注册
或
登录
后发表评论