Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github_28344065
scrcpy
提交
94a53ea5
S
scrcpy
项目概览
github_28344065
/
scrcpy
与 Fork 源项目一致
从无法访问的项目Fork
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
scrcpy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
94a53ea5
编写于
2月 21, 2021
作者:
R
Romain Vimont
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip resizer
上级
d76db3ad
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
186 addition
and
0 deletion
+186
-0
app/meson.build
app/meson.build
+1
-0
app/src/resizer.c
app/src/resizer.c
+132
-0
app/src/resizer.h
app/src/resizer.h
+53
-0
未找到文件。
app/meson.build
浏览文件 @
94a53ea5
...
...
@@ -15,6 +15,7 @@ src = [
'src/opengl.c',
'src/receiver.c',
'src/recorder.c',
'src/resizer.c',
'src/scrcpy.c',
'src/screen.c',
'src/server.c',
...
...
app/src/resizer.c
0 → 100644
浏览文件 @
94a53ea5
#include "resizer.h"
#include <assert.h>
#include "util/log.h"
bool
sc_resizer_init
(
struct
sc_resizer
*
resizer
,
struct
video_buffer
*
vb_in
,
struct
video_buffer
*
vb_out
,
struct
size
size
)
{
bool
ok
=
sc_mutex_init
(
&
resizer
->
mutex
);
if
(
!
ok
)
{
return
false
;
}
ok
=
sc_cond_init
(
&
resizer
->
req_cond
);
if
(
!
ok
)
{
sc_mutex_destroy
(
&
resizer
->
mutex
);
return
false
;
}
resizer
->
resized_frame
=
av_frame_alloc
();
if
(
!
resizer
->
resized_frame
)
{
sc_cond_destroy
(
&
resizer
->
req_cond
);
sc_mutex_destroy
(
&
resizer
->
mutex
);
return
false
;
}
resizer
->
vb_in
=
vb_in
;
resizer
->
vb_out
=
vb_out
;
resizer
->
size
=
size
;
resizer
->
input_frame
=
NULL
;
resizer
->
has_request
=
false
;
resizer
->
has_new_frame
=
false
;
resizer
->
interrupted
=
false
;
return
true
;
}
void
sc_resizer_destroy
(
struct
sc_resizer
*
resizer
)
{
av_frame_free
(
&
resizer
->
resized_frame
);
sc_cond_destroy
(
&
resizer
->
req_cond
);
sc_mutex_destroy
(
&
resizer
->
mutex
);
}
static
bool
sc_resizer_swscale
(
struct
sc_resizer
*
resizer
)
{
assert
(
!
resizer
->
resized_frame
->
buf
[
0
]);
// The frame must be "empty"
return
false
;
}
static
int
run_resizer
(
void
*
data
)
{
struct
sc_resizer
*
resizer
=
data
;
sc_mutex_lock
(
&
resizer
->
mutex
);
while
(
!
resizer
->
interrupted
)
{
while
(
!
resizer
->
interrupted
&&
!
resizer
->
has_request
)
{
sc_cond_wait
(
&
resizer
->
req_cond
,
&
resizer
->
mutex
);
}
if
(
resizer
->
has_new_frame
)
{
resizer
->
input_frame
=
video_buffer_consumer_take_frame
(
resizer
->
vb_in
);
resizer
->
has_new_frame
=
false
;
}
resizer
->
has_request
=
false
;
sc_mutex_unlock
(
&
resizer
->
mutex
);
// Do the actual work without mutex
sc_resizer_swscale
(
resizer
);
video_buffer_producer_offer_frame
(
resizer
->
vb_out
,
&
resizer
->
resized_frame
);
sc_mutex_lock
(
&
resizer
->
mutex
);
}
sc_mutex_unlock
(
&
resizer
->
mutex
);
return
0
;
}
bool
sc_resizer_start
(
struct
sc_resizer
*
resizer
)
{
LOGD
(
"Starting resizer thread"
);
bool
ok
=
sc_thread_create
(
&
resizer
->
thread
,
run_resizer
,
"resizer"
,
resizer
);
if
(
!
ok
)
{
LOGE
(
"Could not start resizer thread"
);
return
false
;
}
return
true
;
}
void
sc_resizer_stop
(
struct
sc_resizer
*
resizer
)
{
sc_mutex_lock
(
&
resizer
->
mutex
);
resizer
->
interrupted
=
true
;
sc_cond_signal
(
&
resizer
->
req_cond
);
sc_mutex_unlock
(
&
resizer
->
mutex
);
video_buffer_interrupt
(
resizer
->
vb_out
);
}
void
sc_resizer_join
(
struct
sc_resizer
*
resizer
)
{
sc_thread_join
(
&
resizer
->
thread
,
NULL
);
}
void
sc_resizer_process_new_frame
(
struct
sc_resizer
*
resizer
)
{
sc_mutex_lock
(
&
resizer
->
mutex
);
resizer
->
has_request
=
true
;
resizer
->
has_new_frame
=
true
;
sc_cond_signal
(
&
resizer
->
req_cond
);
sc_mutex_unlock
(
&
resizer
->
mutex
);
}
void
sc_resizer_process_new_size
(
struct
sc_resizer
*
resizer
,
struct
size
size
)
{
sc_mutex_lock
(
&
resizer
->
mutex
);
resizer
->
size
=
size
;
resizer
->
has_request
=
true
;
sc_cond_signal
(
&
resizer
->
req_cond
);
sc_mutex_unlock
(
&
resizer
->
mutex
);
}
app/src/resizer.h
0 → 100644
浏览文件 @
94a53ea5
#ifndef SC_RESIZER
#define SC_RESIZER
#include "common.h"
#include <stdbool.h>
#include <libavformat/avformat.h>
#include "coords.h"
#include "util/thread.h"
#include "video_buffer.h"
struct
sc_resizer
{
struct
video_buffer
*
vb_in
;
struct
video_buffer
*
vb_out
;
struct
size
size
;
// valid until the next call to video_buffer_consumer_take_frame(vb_in)
const
AVFrame
*
input_frame
;
AVFrame
*
resized_frame
;
sc_thread
thread
;
sc_mutex
mutex
;
sc_cond
req_cond
;
bool
has_request
;
bool
has_new_frame
;
bool
interrupted
;
};
bool
sc_resizer_init
(
struct
sc_resizer
*
resizer
,
struct
video_buffer
*
vb_in
,
struct
video_buffer
*
vb_out
,
struct
size
initial_size
);
void
sc_resizer_destroy
(
struct
sc_resizer
*
resizer
);
bool
sc_resizer_start
(
struct
sc_resizer
*
resizer
);
void
sc_resizer_stop
(
struct
sc_resizer
*
resizer
);
void
sc_resizer_join
(
struct
sc_resizer
*
resizer
);
void
sc_resizer_process_new_frame
(
struct
sc_resizer
*
resizer
);
void
sc_resizer_process_new_size
(
struct
sc_resizer
*
resizer
,
struct
size
size
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录