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-04 22:58:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
60b881aa1d3b07ddcfbad38d9ee45d2feec05b08
60b881aa
1 parent
94c6e743
support rotate 180,use preset superfast for h264 encoding
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
23 行增加
和
6 行删除
pip/AVTranscoder.cpp
pip/VideoDecoder.cpp
pip/VideoDecoder.h
pip/pip.vcxproj.filters
pip/AVTranscoder.cpp
查看文件 @
60b881a
...
...
@@ -157,7 +157,7 @@ int CAVTranscoder::open_output_file(const char *filename)
enc_ctx
->
height
=
_nOutputHeight
;
enc_ctx
->
width
=
_nOutputWidth
;
enc_ctx
->
sample_aspect_ratio
.
den
=
1
;
enc_ctx
->
sample_aspect_ratio
.
num
=
1
;
enc_ctx
->
sample_aspect_ratio
.
num
=
0
;
/* take first format from list of supported formats */
enc_ctx
->
pix_fmt
=
AV_PIX_FMT_YUV420P
;
/* video time_base can be set to whatever is handy and supported by encoder */
...
...
@@ -169,6 +169,11 @@ int CAVTranscoder::open_output_file(const char *filename)
enc_ctx
->
qmin
=
10
;
enc_ctx
->
qmax
=
30
;
enc_ctx
->
qcompress
=
0.6
;
AVDictionary
*
d
=
NULL
;
char
*
k
=
av_strdup
(
"preset"
);
// if your strings are already allocated,
char
*
v
=
av_strdup
(
"ultrafast"
);
// you can avoid copying them like this
av_dict_set
(
&
d
,
k
,
v
,
AV_DICT_DONT_STRDUP_KEY
|
AV_DICT_DONT_STRDUP_VAL
);
/* Third parameter can be used to pass settings to encoder */
ret
=
avcodec_open2
(
enc_ctx
,
encoder
,
NULL
);
if
(
ret
<
0
)
{
...
...
@@ -292,13 +297,14 @@ int CAVTranscoder::open_output_file(const char *filename)
if
(
!
pSrcFrame
){
return
0
;
}
for
(
int
i
=
0
;
i
<
pSrcFrame
->
height
;
i
++
)
{
memcpy
(
pDstFrame
->
data
[
0
]
+
(
y
+
i
)
*
pDstFrame
->
linesize
[
0
]
+
x
,
pSrcFrame
->
data
[
0
]
+
i
*
pSrcFrame
->
linesize
[
0
],
pSrcFrame
->
linesize
[
0
]);
memcpy
(
pDstFrame
->
data
[
0
]
+
(
y
+
i
)
*
pDstFrame
->
linesize
[
0
]
+
x
,
pSrcFrame
->
data
[
0
]
+
i
*
pSrcFrame
->
linesize
[
0
],
pSrcFrame
->
linesize
[
0
]
>
0
?
pSrcFrame
->
linesize
[
0
]
:
-
pSrcFrame
->
linesize
[
0
]
);
}
for
(
int
i
=
0
;
i
<
pSrcFrame
->
height
/
2
;
i
++
){
memcpy
(
pDstFrame
->
data
[
1
]
+
(
y
/
2
)
*
pDstFrame
->
linesize
[
1
]
+
x
/
2
,
pSrcFrame
->
data
[
1
]
+
i
*
pSrcFrame
->
linesize
[
1
],
pSrcFrame
->
linesize
[
1
]);
memcpy
(
pDstFrame
->
data
[
2
]
+
(
y
/
2
)
*
pDstFrame
->
linesize
[
2
]
+
x
/
2
,
pSrcFrame
->
data
[
2
]
+
i
*
pSrcFrame
->
linesize
[
2
],
pSrcFrame
->
linesize
[
2
]);
memcpy
(
pDstFrame
->
data
[
1
]
+
(
y
/
2
+
i
)
*
pDstFrame
->
linesize
[
1
]
+
x
/
2
,
pSrcFrame
->
data
[
1
]
+
i
*
pSrcFrame
->
linesize
[
1
],
pSrcFrame
->
linesize
[
1
]
>
0
?
pSrcFrame
->
linesize
[
1
]
:
-
pSrcFrame
->
linesize
[
1
]);
memcpy
(
pDstFrame
->
data
[
2
]
+
(
y
/
2
+
i
)
*
pDstFrame
->
linesize
[
2
]
+
x
/
2
,
pSrcFrame
->
data
[
2
]
+
i
*
pSrcFrame
->
linesize
[
2
],
pSrcFrame
->
linesize
[
2
]
>
0
?
pSrcFrame
->
linesize
[
2
]
:
-
pSrcFrame
->
linesize
[
2
]);
}
return
0
;
}
...
...
@@ -310,6 +316,8 @@ 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
);
if
(
decoders_got_frame
.
size
()
==
2
){
fillDestFrame
(
pDstFrame
,
decoders_got_frame
[
0
]
->
_cur_v_frame
,
0
,
decoders_got_frame
[
0
]
->
_media_role
==
mr_teacher
?
0
:
240
);
decoders_got_frame
[
0
]
->
free_cur_v_frame
();
...
...
pip/VideoDecoder.cpp
查看文件 @
60b881a
...
...
@@ -20,6 +20,7 @@ int CVideoDecoder::add(media_info &info)
_uid
=
info
.
uid
;
}
_info
.
push_back
(
info
);
_rotate
=
info
.
rotate
;
int
ret
;
...
...
@@ -300,7 +301,14 @@ int CVideoDecoder::filter_encode_write_frame(AVFrame *frame, unsigned int stream
}
filt_frame
->
pict_type
=
AV_PICTURE_TYPE_NONE
;
//todo: callback filted frame
if
(
_rotate
==
180
)
{
filt_frame
->
data
[
0
]
+=
filt_frame
->
linesize
[
0
]
*
(
filt_frame
->
height
-
1
);
filt_frame
->
linesize
[
0
]
=
-
filt_frame
->
linesize
[
0
];
filt_frame
->
data
[
1
]
+=
filt_frame
->
linesize
[
1
]
*
(
filt_frame
->
height
/
2
-
1
);
filt_frame
->
linesize
[
1
]
=
-
filt_frame
->
linesize
[
1
];
filt_frame
->
data
[
2
]
+=
filt_frame
->
linesize
[
2
]
*
(
filt_frame
->
height
/
2
-
1
);
filt_frame
->
linesize
[
2
]
=
-
filt_frame
->
linesize
[
2
];
}
_decoded_frames
.
push_back
(
filt_frame
);
}
...
...
pip/VideoDecoder.h
查看文件 @
60b881a
...
...
@@ -31,5 +31,6 @@ protected:
bool
_is_finished
;
AVRational
_codec_timebase
;
unsigned
int
_uid
;
int
_rotate
;
};
...
...
pip/pip.vcxproj.filters
查看文件 @
60b881a
...
...
@@ -40,7 +40,7 @@
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="merge_pip.cpp">
<Filter>
资
源文件</Filter>
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
...
...
请
注册
或
登录
后发表评论