Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
b91a98ed
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b91a98ed
编写于
3月 19, 2015
作者:
J
John Bradley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
deps-libff: Refactor AVPacket into ff_packet
This also replaces AVPacketList with ff_packet_list.
上级
a7e81d6f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
60 addition
and
45 deletion
+60
-45
deps/libff/libff/ff-audio-decoder.c
deps/libff/libff/ff-audio-decoder.c
+18
-15
deps/libff/libff/ff-decoder.c
deps/libff/libff/ff-decoder.c
+2
-2
deps/libff/libff/ff-decoder.h
deps/libff/libff/ff-decoder.h
+1
-1
deps/libff/libff/ff-demuxer.c
deps/libff/libff/ff-demuxer.c
+3
-3
deps/libff/libff/ff-packet-queue.c
deps/libff/libff/ff-packet-queue.c
+17
-15
deps/libff/libff/ff-packet-queue.h
deps/libff/libff/ff-packet-queue.h
+15
-5
deps/libff/libff/ff-video-decoder.c
deps/libff/libff/ff-video-decoder.c
+4
-4
未找到文件。
deps/libff/libff/ff-audio-decoder.c
浏览文件 @
b91a98ed
...
...
@@ -28,29 +28,30 @@
#include <assert.h>
static
inline
void
shrink_packet
(
AVP
acket
*
packet
,
int
packet_length
)
static
inline
void
shrink_packet
(
struct
ff_p
acket
*
packet
,
int
packet_length
)
{
if
(
packet_length
<=
packet
->
size
)
{
int
remaining
=
packet
->
size
-
packet_length
;
if
(
packet_length
<=
packet
->
base
.
size
)
{
int
remaining
=
packet
->
base
.
size
-
packet_length
;
memmove
(
packet
->
data
,
&
packet
->
data
[
packet_length
],
remaining
);
av_shrink_packet
(
packet
,
remaining
);
memmove
(
packet
->
base
.
data
,
&
packet
->
base
.
data
[
packet_length
],
remaining
);
av_shrink_packet
(
&
packet
->
base
,
remaining
);
}
}
static
int
decode_frame
(
struct
ff_decoder
*
decoder
,
AVP
acket
*
packet
,
AVFrame
*
frame
,
bool
*
frame_complete
)
struct
ff_p
acket
*
packet
,
AVFrame
*
frame
,
bool
*
frame_complete
)
{
int
packet_length
;
int
ret
;
while
(
true
)
{
while
(
packet
->
size
>
0
)
{
while
(
packet
->
base
.
size
>
0
)
{
int
complete
;
packet_length
=
avcodec_decode_audio4
(
decoder
->
codec
,
frame
,
&
complete
,
packet
);
&
packet
->
base
);
if
(
packet_length
<
0
)
break
;
...
...
@@ -66,15 +67,16 @@ static int decode_frame(struct ff_decoder *decoder,
av_get_bytes_per_sample
(
frame
->
format
);
}
if
(
packet
->
data
!=
NULL
)
av_packet_unref
(
packet
);
if
(
packet
->
base
.
data
!=
NULL
)
av_packet_unref
(
&
packet
->
base
);
ret
=
packet_queue_get
(
&
decoder
->
packet_queue
,
packet
,
1
);
if
(
ret
==
FF_PACKET_FAIL
)
{
return
-
1
;
}
if
(
packet
->
data
==
decoder
->
packet_queue
.
flush_packet
.
data
)
{
if
(
packet
->
base
.
data
==
decoder
->
packet_queue
.
flush_packet
.
base
.
data
)
{
avcodec_flush_buffers
(
decoder
->
codec
);
// we were flushed, so try to get another packet
...
...
@@ -126,13 +128,14 @@ void *ff_audio_decoder_thread(void *opaque_audio_decoder)
{
struct
ff_decoder
*
decoder
=
opaque_audio_decoder
;
AVP
acket
packet
=
{
0
};
struct
ff_p
acket
packet
=
{
0
};
bool
frame_complete
;
AVFrame
*
frame
=
av_frame_alloc
();
while
(
!
decoder
->
abort
)
{
if
(
decode_frame
(
decoder
,
&
packet
,
frame
,
&
frame_complete
)
<
0
)
{
av_free_packet
(
&
packet
);
if
(
decode_frame
(
decoder
,
&
packet
,
frame
,
&
frame_complete
)
<
0
)
{
av_free_packet
(
&
packet
.
base
);
continue
;
}
...
...
@@ -148,7 +151,7 @@ void *ff_audio_decoder_thread(void *opaque_audio_decoder)
av_frame_unref
(
frame
);
}
av_free_packet
(
&
packet
);
av_free_packet
(
&
packet
.
base
);
}
av_frame_free
(
&
frame
);
...
...
deps/libff/libff/ff-decoder.c
浏览文件 @
b91a98ed
...
...
@@ -245,9 +245,9 @@ bool ff_decoder_full(struct ff_decoder *decoder)
return
(
decoder
->
packet_queue
.
total_size
>
decoder
->
packet_queue_size
);
}
bool
ff_decoder_accept
(
struct
ff_decoder
*
decoder
,
AVP
acket
*
packet
)
bool
ff_decoder_accept
(
struct
ff_decoder
*
decoder
,
struct
ff_p
acket
*
packet
)
{
if
(
decoder
&&
packet
->
stream_index
==
decoder
->
stream
->
index
)
{
if
(
decoder
&&
packet
->
base
.
stream_index
==
decoder
->
stream
->
index
)
{
packet_queue_put
(
&
decoder
->
packet_queue
,
packet
);
return
true
;
}
...
...
deps/libff/libff/ff-decoder.h
浏览文件 @
b91a98ed
...
...
@@ -59,7 +59,7 @@ bool ff_decoder_start(struct ff_decoder *decoder);
void
ff_decoder_free
(
struct
ff_decoder
*
decoder
);
bool
ff_decoder_full
(
struct
ff_decoder
*
decoder
);
bool
ff_decoder_accept
(
struct
ff_decoder
*
decoder
,
AVP
acket
*
packet
);
bool
ff_decoder_accept
(
struct
ff_decoder
*
decoder
,
struct
ff_p
acket
*
packet
);
double
ff_decoder_clock
(
void
*
opaque
);
...
...
deps/libff/libff/ff-demuxer.c
浏览文件 @
b91a98ed
...
...
@@ -448,7 +448,7 @@ static void *demux_thread(void *opaque)
struct
ff_demuxer
*
demuxer
=
(
struct
ff_demuxer
*
)
opaque
;
int
result
;
AVPacket
packet
;
struct
ff_packet
packet
=
{
0
}
;
if
(
!
open_input
(
demuxer
,
&
demuxer
->
format_context
))
goto
fail
;
...
...
@@ -469,7 +469,7 @@ static void *demux_thread(void *opaque)
continue
;
}
result
=
av_read_frame
(
demuxer
->
format_context
,
&
packet
);
result
=
av_read_frame
(
demuxer
->
format_context
,
&
packet
.
base
);
if
(
result
<
0
)
{
bool
eof
=
false
;
if
(
result
==
AVERROR_EOF
)
{
...
...
@@ -506,7 +506,7 @@ static void *demux_thread(void *opaque)
else
if
(
ff_decoder_accept
(
demuxer
->
audio_decoder
,
&
packet
))
continue
;
else
av_free_packet
(
&
packet
);
av_free_packet
(
&
packet
.
base
);
}
if
(
demuxer
->
audio_decoder
!=
NULL
)
demuxer
->
audio_decoder
->
eof
=
true
;
...
...
deps/libff/libff/ff-packet-queue.c
浏览文件 @
b91a98ed
...
...
@@ -26,8 +26,8 @@ bool packet_queue_init(struct ff_packet_queue *q)
if
(
pthread_cond_init
(
&
q
->
cond
,
NULL
)
!=
0
)
goto
fail1
;
av_init_packet
(
&
q
->
flush_packet
);
q
->
flush_packet
.
data
=
(
uint8_t
*
)
"FLUSH"
;
av_init_packet
(
&
q
->
flush_packet
.
base
);
q
->
flush_packet
.
base
.
data
=
(
uint8_t
*
)
"FLUSH"
;
return
true
;
...
...
@@ -53,22 +53,23 @@ void packet_queue_free(struct ff_packet_queue *q)
pthread_mutex_destroy
(
&
q
->
mutex
);
pthread_cond_destroy
(
&
q
->
cond
);
av_free_packet
(
&
q
->
flush_packet
);
av_free_packet
(
&
q
->
flush_packet
.
base
);
}
int
packet_queue_put
(
struct
ff_packet_queue
*
q
,
AVP
acket
*
packet
)
int
packet_queue_put
(
struct
ff_packet_queue
*
q
,
struct
ff_p
acket
*
packet
)
{
AVPacketL
ist
*
new_packet
;
struct
ff_packet_l
ist
*
new_packet
;
if
(
packet
!=
&
q
->
flush_packet
&&
av_dup_packet
(
packet
)
<
0
)
if
(
packet
!=
&
q
->
flush_packet
&&
av_dup_packet
(
&
packet
->
base
)
<
0
)
return
FF_PACKET_FAIL
;
new_packet
=
av_malloc
(
sizeof
(
AVPacketL
ist
));
new_packet
=
av_malloc
(
sizeof
(
struct
ff_packet_l
ist
));
if
(
new_packet
==
NULL
)
return
FF_PACKET_FAIL
;
new_packet
->
p
k
t
=
*
packet
;
new_packet
->
p
acke
t
=
*
packet
;
new_packet
->
next
=
NULL
;
pthread_mutex_lock
(
&
q
->
mutex
);
...
...
@@ -81,7 +82,7 @@ int packet_queue_put(struct ff_packet_queue *q, AVPacket *packet)
q
->
last_packet
=
new_packet
;
q
->
count
++
;
q
->
total_size
+=
new_packet
->
p
kt
.
size
;
q
->
total_size
+=
new_packet
->
p
acket
.
base
.
size
;
pthread_cond_signal
(
&
q
->
cond
);
pthread_mutex_unlock
(
&
q
->
mutex
);
...
...
@@ -94,9 +95,10 @@ int packet_queue_put_flush_packet(struct ff_packet_queue *q)
return
packet_queue_put
(
q
,
&
q
->
flush_packet
);
}
int
packet_queue_get
(
struct
ff_packet_queue
*
q
,
AVPacket
*
packet
,
bool
block
)
int
packet_queue_get
(
struct
ff_packet_queue
*
q
,
struct
ff_packet
*
packet
,
bool
block
)
{
AVPacketL
ist
*
potential_packet
;
struct
ff_packet_l
ist
*
potential_packet
;
int
return_status
;
pthread_mutex_lock
(
&
q
->
mutex
);
...
...
@@ -111,8 +113,8 @@ int packet_queue_get(struct ff_packet_queue *q, AVPacket *packet, bool block)
q
->
last_packet
=
NULL
;
q
->
count
--
;
q
->
total_size
-=
potential_packet
->
p
kt
.
size
;
*
packet
=
potential_packet
->
p
k
t
;
q
->
total_size
-=
potential_packet
->
p
acket
.
base
.
size
;
*
packet
=
potential_packet
->
p
acke
t
;
av_free
(
potential_packet
);
return_status
=
FF_PACKET_SUCCESS
;
break
;
...
...
@@ -137,14 +139,14 @@ int packet_queue_get(struct ff_packet_queue *q, AVPacket *packet, bool block)
void
packet_queue_flush
(
struct
ff_packet_queue
*
q
)
{
AVPacketL
ist
*
packet
;
struct
ff_packet_l
ist
*
packet
;
pthread_mutex_lock
(
&
q
->
mutex
);
for
(
packet
=
q
->
first_packet
;
packet
!=
NULL
;
packet
=
q
->
first_packet
)
{
q
->
first_packet
=
packet
->
next
;
av_free_packet
(
&
packet
->
p
kt
);
av_free_packet
(
&
packet
->
p
acket
.
base
);
av_freep
(
&
packet
);
}
...
...
deps/libff/libff/ff-packet-queue.h
浏览文件 @
b91a98ed
...
...
@@ -24,12 +24,21 @@
#define FF_PACKET_EMPTY 0
#define FF_PACKET_SUCCESS 1
struct
ff_packet
{
AVPacket
base
;
};
struct
ff_packet_list
{
struct
ff_packet
packet
;
struct
ff_packet_list
*
next
;
};
struct
ff_packet_queue
{
AVPacketL
ist
*
first_packet
;
AVPacketL
ist
*
last_packet
;
struct
ff_packet_l
ist
*
first_packet
;
struct
ff_packet_l
ist
*
last_packet
;
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
AVP
acket
flush_packet
;
struct
ff_p
acket
flush_packet
;
int
count
;
unsigned
int
total_size
;
bool
abort
;
...
...
@@ -40,8 +49,9 @@ typedef struct ff_packet_queue ff_packet_queue_t;
bool
packet_queue_init
(
struct
ff_packet_queue
*
q
);
void
packet_queue_abort
(
struct
ff_packet_queue
*
q
);
void
packet_queue_free
(
struct
ff_packet_queue
*
q
);
int
packet_queue_put
(
struct
ff_packet_queue
*
q
,
AVP
acket
*
packet
);
int
packet_queue_put
(
struct
ff_packet_queue
*
q
,
struct
ff_p
acket
*
packet
);
int
packet_queue_put_flush_packet
(
struct
ff_packet_queue
*
q
);
int
packet_queue_get
(
struct
ff_packet_queue
*
q
,
AVPacket
*
packet
,
bool
block
);
int
packet_queue_get
(
struct
ff_packet_queue
*
q
,
struct
ff_packet
*
packet
,
bool
block
);
void
packet_queue_flush
(
struct
ff_packet_queue
*
q
);
deps/libff/libff/ff-video-decoder.c
浏览文件 @
b91a98ed
...
...
@@ -68,7 +68,7 @@ void *ff_video_decoder_thread(void *opaque_video_decoder)
{
struct
ff_decoder
*
decoder
=
(
struct
ff_decoder
*
)
opaque_video_decoder
;
AVP
acket
packet
=
{
0
};
struct
ff_p
acket
packet
=
{
0
};
int
complete
;
AVFrame
*
frame
=
av_frame_alloc
();
int
ret
;
...
...
@@ -80,13 +80,13 @@ void *ff_video_decoder_thread(void *opaque_video_decoder)
break
;
}
if
(
packet
.
data
==
decoder
->
packet_queue
.
flush_packet
.
data
)
{
if
(
packet
.
base
.
data
==
decoder
->
packet_queue
.
flush_packet
.
base
.
data
)
{
avcodec_flush_buffers
(
decoder
->
codec
);
continue
;
}
avcodec_decode_video2
(
decoder
->
codec
,
frame
,
&
complete
,
&
packet
);
&
complete
,
&
packet
.
base
);
// Did we get an entire video frame? This doesn't guarantee
// there is a picture to show for some codecs, but we still want
...
...
@@ -104,7 +104,7 @@ void *ff_video_decoder_thread(void *opaque_video_decoder)
av_frame_unref
(
frame
);
}
av_free_packet
(
&
packet
);
av_free_packet
(
&
packet
.
base
);
}
av_frame_free
(
&
frame
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录