Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
3a19405d
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,发现更多精彩内容 >>
提交
3a19405d
编写于
3月 13, 2014
作者:
L
Luca Barbato
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avformat: Use the mime type information in input probe
It should provide a quicker guess for elementary streams provided by http.
上级
69e7336b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
12 deletion
+37
-12
libavformat/avformat.h
libavformat/avformat.h
+11
-0
libavformat/format.c
libavformat/format.c
+22
-12
libavformat/version.h
libavformat/version.h
+4
-0
未找到文件。
libavformat/avformat.h
浏览文件 @
3a19405d
...
...
@@ -391,9 +391,13 @@ typedef struct AVProbeData {
const
char
*
filename
;
unsigned
char
*
buf
;
/**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */
int
buf_size
;
/**< Size of buf except extra allocated bytes */
#ifdef FF_API_PROBE_MIME
uint8_t
*
mime_type
;
/**< mime_type, when known. */
#endif
}
AVProbeData
;
#define AVPROBE_SCORE_EXTENSION 50 ///< score for file extension
#define AVPROBE_SCORE_MIME 75 ///< score for file mime type
#define AVPROBE_SCORE_MAX 100 ///< maximum score
#define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer
...
...
@@ -535,6 +539,13 @@ typedef struct AVInputFormat {
const
AVClass
*
priv_class
;
///< AVClass for the private context
/**
* Comma-separated list of mime types.
* It is used check for matching mime types while probing.
* @see av_probe_input_format2
*/
const
char
*
mime_type
;
/*****************************************************************
* No fields below this line are part of the public API. They
* may not be used outside of libavformat and can be changed and
...
...
libavformat/format.c
浏览文件 @
3a19405d
...
...
@@ -20,6 +20,7 @@
*/
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "avio_internal.h"
#include "avformat.h"
...
...
@@ -194,6 +195,10 @@ AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened,
if
(
av_match_ext
(
lpd
.
filename
,
fmt1
->
extensions
))
score
=
AVPROBE_SCORE_EXTENSION
;
}
#ifdef FF_API_PROBE_MIME
if
(
av_match_name
(
lpd
.
mime_type
,
fmt1
->
mime_type
))
score
=
FFMAX
(
score
,
AVPROBE_SCORE_EXTENSION
);
#endif
if
(
score
>
*
score_max
)
{
*
score_max
=
score
;
fmt
=
fmt1
;
...
...
@@ -251,7 +256,10 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
return
AVERROR
(
EINVAL
);
avio_skip
(
pb
,
offset
);
max_probe_size
-=
offset
;
#ifdef FF_API_PROBE_MIME
if
(
pb
->
av_class
)
av_opt_get
(
pb
,
"mime_type"
,
AV_OPT_SEARCH_CHILDREN
,
&
pd
.
mime_type
);
#endif
for
(
probe_size
=
PROBE_BUF_MIN
;
probe_size
<=
max_probe_size
&&
!*
fmt
;
probe_size
=
FFMIN
(
probe_size
<<
1
,
FFMAX
(
max_probe_size
,
probe_size
+
1
)))
{
...
...
@@ -259,14 +267,13 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
/* Read probe data. */
if
((
ret
=
av_reallocp
(
&
buf
,
probe_size
+
AVPROBE_PADDING_SIZE
))
<
0
)
return
ret
;
goto
fail
;
if
((
ret
=
avio_read
(
pb
,
buf
+
pd
.
buf_size
,
probe_size
-
pd
.
buf_size
))
<
0
)
{
/* Fail if error was not end of file, otherwise, lower score. */
if
(
ret
!=
AVERROR_EOF
)
{
av_free
(
buf
);
return
ret
;
}
if
(
ret
!=
AVERROR_EOF
)
goto
fail
;
score
=
0
;
ret
=
0
;
/* error was end of file, nothing read */
}
...
...
@@ -289,14 +296,17 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
}
}
if
(
!*
fmt
)
{
av_free
(
buf
);
return
AVERROR_INVALIDDATA
;
}
if
(
!*
fmt
)
ret
=
AVERROR_INVALIDDATA
;
fail:
/* Rewind. Reuse probe buffer to avoid seeking. */
if
((
ret
=
ffio_rewind_with_probe_data
(
pb
,
buf
,
pd
.
buf_size
))
<
0
)
if
(
ret
<
0
||
(
ret
=
ffio_rewind_with_probe_data
(
pb
,
buf
,
pd
.
buf_size
))
<
0
)
{
av_free
(
buf
);
}
#ifdef FF_API_PROBE_MIME
av_free
(
pd
.
mime_type
);
#endif
return
ret
;
}
libavformat/version.h
浏览文件 @
3a19405d
...
...
@@ -61,4 +61,8 @@
#define FF_API_LAVF_CODEC_TB (LIBAVFORMAT_VERSION_MAJOR < 57)
#endif
#ifndef FF_API_PROBE_MIME
#define FF_API_PROBE_MIME (LIBAVFORMAT_VERSION_MAJOR > 55)
#endif
#endif
/* AVFORMAT_VERSION_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录