Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
afc86853
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,发现更多精彩内容 >>
提交
afc86853
编写于
6月 15, 2013
作者:
L
Luca Barbato
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avf: split off format register and lookup function
上级
f80b60ad
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
184 addition
and
146 deletion
+184
-146
libavformat/Makefile
libavformat/Makefile
+1
-0
libavformat/format.c
libavformat/format.c
+183
-0
libavformat/utils.c
libavformat/utils.c
+0
-146
未找到文件。
libavformat/Makefile
浏览文件 @
afc86853
...
...
@@ -9,6 +9,7 @@ OBJS = allformats.o \
avio.o
\
aviobuf.o
\
cutils.o
\
format.o
\
id3v1.o
\
id3v2.o
\
log2_tab.o
\
...
...
libavformat/format.c
0 → 100644
浏览文件 @
afc86853
/*
* Format register and lookup
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "internal.h"
#include "libavutil/avstring.h"
/**
* @file
* Format register and lookup
*/
/** head of registered input format linked list */
static
AVInputFormat
*
first_iformat
=
NULL
;
/** head of registered output format linked list */
static
AVOutputFormat
*
first_oformat
=
NULL
;
AVInputFormat
*
av_iformat_next
(
AVInputFormat
*
f
)
{
if
(
f
)
return
f
->
next
;
else
return
first_iformat
;
}
AVOutputFormat
*
av_oformat_next
(
AVOutputFormat
*
f
)
{
if
(
f
)
return
f
->
next
;
else
return
first_oformat
;
}
void
av_register_input_format
(
AVInputFormat
*
format
)
{
AVInputFormat
**
p
=
&
first_iformat
;
while
(
*
p
!=
NULL
)
p
=
&
(
*
p
)
->
next
;
*
p
=
format
;
format
->
next
=
NULL
;
}
void
av_register_output_format
(
AVOutputFormat
*
format
)
{
AVOutputFormat
**
p
=
&
first_oformat
;
while
(
*
p
!=
NULL
)
p
=
&
(
*
p
)
->
next
;
*
p
=
format
;
format
->
next
=
NULL
;
}
int
av_match_ext
(
const
char
*
filename
,
const
char
*
extensions
)
{
const
char
*
ext
,
*
p
;
char
ext1
[
32
],
*
q
;
if
(
!
filename
)
return
0
;
ext
=
strrchr
(
filename
,
'.'
);
if
(
ext
)
{
ext
++
;
p
=
extensions
;
for
(;;)
{
q
=
ext1
;
while
(
*
p
!=
'\0'
&&
*
p
!=
','
&&
q
-
ext1
<
sizeof
(
ext1
)
-
1
)
*
q
++
=
*
p
++
;
*
q
=
'\0'
;
if
(
!
av_strcasecmp
(
ext1
,
ext
))
return
1
;
if
(
*
p
==
'\0'
)
break
;
p
++
;
}
}
return
0
;
}
static
int
match_format
(
const
char
*
name
,
const
char
*
names
)
{
const
char
*
p
;
int
len
,
namelen
;
if
(
!
name
||
!
names
)
return
0
;
namelen
=
strlen
(
name
);
while
((
p
=
strchr
(
names
,
','
)))
{
len
=
FFMAX
(
p
-
names
,
namelen
);
if
(
!
av_strncasecmp
(
name
,
names
,
len
))
return
1
;
names
=
p
+
1
;
}
return
!
av_strcasecmp
(
name
,
names
);
}
AVOutputFormat
*
av_guess_format
(
const
char
*
short_name
,
const
char
*
filename
,
const
char
*
mime_type
)
{
AVOutputFormat
*
fmt
=
NULL
,
*
fmt_found
;
int
score_max
,
score
;
/* specific test for image sequences */
#if CONFIG_IMAGE2_MUXER
if
(
!
short_name
&&
filename
&&
av_filename_number_test
(
filename
)
&&
ff_guess_image2_codec
(
filename
)
!=
AV_CODEC_ID_NONE
)
{
return
av_guess_format
(
"image2"
,
NULL
,
NULL
);
}
#endif
/* Find the proper file type. */
fmt_found
=
NULL
;
score_max
=
0
;
while
((
fmt
=
av_oformat_next
(
fmt
)))
{
score
=
0
;
if
(
fmt
->
name
&&
short_name
&&
!
av_strcasecmp
(
fmt
->
name
,
short_name
))
score
+=
100
;
if
(
fmt
->
mime_type
&&
mime_type
&&
!
strcmp
(
fmt
->
mime_type
,
mime_type
))
score
+=
10
;
if
(
filename
&&
fmt
->
extensions
&&
av_match_ext
(
filename
,
fmt
->
extensions
))
{
score
+=
5
;
}
if
(
score
>
score_max
)
{
score_max
=
score
;
fmt_found
=
fmt
;
}
}
return
fmt_found
;
}
enum
AVCodecID
av_guess_codec
(
AVOutputFormat
*
fmt
,
const
char
*
short_name
,
const
char
*
filename
,
const
char
*
mime_type
,
enum
AVMediaType
type
)
{
if
(
type
==
AVMEDIA_TYPE_VIDEO
)
{
enum
AVCodecID
codec_id
=
AV_CODEC_ID_NONE
;
#if CONFIG_IMAGE2_MUXER
if
(
!
strcmp
(
fmt
->
name
,
"image2"
)
||
!
strcmp
(
fmt
->
name
,
"image2pipe"
))
{
codec_id
=
ff_guess_image2_codec
(
filename
);
}
#endif
if
(
codec_id
==
AV_CODEC_ID_NONE
)
codec_id
=
fmt
->
video_codec
;
return
codec_id
;
}
else
if
(
type
==
AVMEDIA_TYPE_AUDIO
)
return
fmt
->
audio_codec
;
else
if
(
type
==
AVMEDIA_TYPE_SUBTITLE
)
return
fmt
->
subtitle_codec
;
else
return
AV_CODEC_ID_NONE
;
}
AVInputFormat
*
av_find_input_format
(
const
char
*
short_name
)
{
AVInputFormat
*
fmt
=
NULL
;
while
((
fmt
=
av_iformat_next
(
fmt
)))
if
(
match_format
(
short_name
,
fmt
->
name
))
return
fmt
;
return
NULL
;
}
libavformat/utils.c
浏览文件 @
afc86853
...
...
@@ -66,152 +66,6 @@ const char *avformat_license(void)
return
LICENSE_PREFIX
LIBAV_LICENSE
+
sizeof
(
LICENSE_PREFIX
)
-
1
;
}
/** head of registered input format linked list */
static
AVInputFormat
*
first_iformat
=
NULL
;
/** head of registered output format linked list */
static
AVOutputFormat
*
first_oformat
=
NULL
;
AVInputFormat
*
av_iformat_next
(
AVInputFormat
*
f
)
{
if
(
f
)
return
f
->
next
;
else
return
first_iformat
;
}
AVOutputFormat
*
av_oformat_next
(
AVOutputFormat
*
f
)
{
if
(
f
)
return
f
->
next
;
else
return
first_oformat
;
}
void
av_register_input_format
(
AVInputFormat
*
format
)
{
AVInputFormat
**
p
;
p
=
&
first_iformat
;
while
(
*
p
!=
NULL
)
p
=
&
(
*
p
)
->
next
;
*
p
=
format
;
format
->
next
=
NULL
;
}
void
av_register_output_format
(
AVOutputFormat
*
format
)
{
AVOutputFormat
**
p
;
p
=
&
first_oformat
;
while
(
*
p
!=
NULL
)
p
=
&
(
*
p
)
->
next
;
*
p
=
format
;
format
->
next
=
NULL
;
}
int
av_match_ext
(
const
char
*
filename
,
const
char
*
extensions
)
{
const
char
*
ext
,
*
p
;
char
ext1
[
32
],
*
q
;
if
(
!
filename
)
return
0
;
ext
=
strrchr
(
filename
,
'.'
);
if
(
ext
)
{
ext
++
;
p
=
extensions
;
for
(;;)
{
q
=
ext1
;
while
(
*
p
!=
'\0'
&&
*
p
!=
','
&&
q
-
ext1
<
sizeof
(
ext1
)
-
1
)
*
q
++
=
*
p
++
;
*
q
=
'\0'
;
if
(
!
av_strcasecmp
(
ext1
,
ext
))
return
1
;
if
(
*
p
==
'\0'
)
break
;
p
++
;
}
}
return
0
;
}
static
int
match_format
(
const
char
*
name
,
const
char
*
names
)
{
const
char
*
p
;
int
len
,
namelen
;
if
(
!
name
||
!
names
)
return
0
;
namelen
=
strlen
(
name
);
while
((
p
=
strchr
(
names
,
','
)))
{
len
=
FFMAX
(
p
-
names
,
namelen
);
if
(
!
av_strncasecmp
(
name
,
names
,
len
))
return
1
;
names
=
p
+
1
;
}
return
!
av_strcasecmp
(
name
,
names
);
}
AVOutputFormat
*
av_guess_format
(
const
char
*
short_name
,
const
char
*
filename
,
const
char
*
mime_type
)
{
AVOutputFormat
*
fmt
=
NULL
,
*
fmt_found
;
int
score_max
,
score
;
/* specific test for image sequences */
#if CONFIG_IMAGE2_MUXER
if
(
!
short_name
&&
filename
&&
av_filename_number_test
(
filename
)
&&
ff_guess_image2_codec
(
filename
)
!=
AV_CODEC_ID_NONE
)
{
return
av_guess_format
(
"image2"
,
NULL
,
NULL
);
}
#endif
/* Find the proper file type. */
fmt_found
=
NULL
;
score_max
=
0
;
while
((
fmt
=
av_oformat_next
(
fmt
)))
{
score
=
0
;
if
(
fmt
->
name
&&
short_name
&&
!
av_strcasecmp
(
fmt
->
name
,
short_name
))
score
+=
100
;
if
(
fmt
->
mime_type
&&
mime_type
&&
!
strcmp
(
fmt
->
mime_type
,
mime_type
))
score
+=
10
;
if
(
filename
&&
fmt
->
extensions
&&
av_match_ext
(
filename
,
fmt
->
extensions
))
{
score
+=
5
;
}
if
(
score
>
score_max
)
{
score_max
=
score
;
fmt_found
=
fmt
;
}
}
return
fmt_found
;
}
enum
AVCodecID
av_guess_codec
(
AVOutputFormat
*
fmt
,
const
char
*
short_name
,
const
char
*
filename
,
const
char
*
mime_type
,
enum
AVMediaType
type
){
if
(
type
==
AVMEDIA_TYPE_VIDEO
){
enum
AVCodecID
codec_id
=
AV_CODEC_ID_NONE
;
#if CONFIG_IMAGE2_MUXER
if
(
!
strcmp
(
fmt
->
name
,
"image2"
)
||
!
strcmp
(
fmt
->
name
,
"image2pipe"
)){
codec_id
=
ff_guess_image2_codec
(
filename
);
}
#endif
if
(
codec_id
==
AV_CODEC_ID_NONE
)
codec_id
=
fmt
->
video_codec
;
return
codec_id
;
}
else
if
(
type
==
AVMEDIA_TYPE_AUDIO
)
return
fmt
->
audio_codec
;
else
if
(
type
==
AVMEDIA_TYPE_SUBTITLE
)
return
fmt
->
subtitle_codec
;
else
return
AV_CODEC_ID_NONE
;
}
AVInputFormat
*
av_find_input_format
(
const
char
*
short_name
)
{
AVInputFormat
*
fmt
=
NULL
;
while
((
fmt
=
av_iformat_next
(
fmt
)))
{
if
(
match_format
(
short_name
,
fmt
->
name
))
return
fmt
;
}
return
NULL
;
}
/* an arbitrarily chosen "sane" max packet size -- 50M */
#define SANE_CHUNK_SIZE (50000000)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录