Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
9128ae08
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,发现更多精彩内容 >>
提交
9128ae08
编写于
12月 27, 2010
作者:
N
Nicolas George
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement av_find_best_stream.
Originally committed as revision 26104 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
107a7e3e
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
96 addition
and
1 deletion
+96
-1
doc/APIchanges
doc/APIchanges
+3
-0
libavformat/avformat.h
libavformat/avformat.h
+32
-1
libavformat/utils.c
libavformat/utils.c
+61
-0
未找到文件。
doc/APIchanges
浏览文件 @
9128ae08
...
...
@@ -13,6 +13,9 @@ libavutil: 2009-03-08
API changes, most recent first:
2010-12-XX - r26104 - lavformat 52.91.0 - av_find_best_stream()
Add av_find_best_stream to libavformat/avformat.h.
2010-12-27 - r26103 - lavf 52.90.0
Add AVFMT_NOSTREAMS flag for formats with no streams,
like e.g. text metadata.
...
...
libavformat/avformat.h
浏览文件 @
9128ae08
...
...
@@ -22,7 +22,7 @@
#define AVFORMAT_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52
#define LIBAVFORMAT_VERSION_MINOR 9
0
#define LIBAVFORMAT_VERSION_MINOR 9
1
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
...
...
@@ -1140,6 +1140,37 @@ AVFormatContext *avformat_alloc_context(void);
*/
int
av_find_stream_info
(
AVFormatContext
*
ic
);
/**
* Find the "best" stream in the file.
* The best stream is determined according to various heuristics as the most
* likely to be what the user expects.
* If the decoder parameter is non-NULL, av_find_best_stream will find the
* default decoder for the stream's codec; streams for which no decoder can
* be found are ignored.
*
* @param ic media file handle
* @param type stream type: video, audio, subtitles, etc.
* @param wanted_stream_nb user-requested stream number,
* or -1 for automatic selection
* @param related_stream try to find a stream related (eg. in the same
* program) to this one, or -1 if none
* @param decoder_ret if non-NULL, returns the decoder for the
* selected stream
* @param flags flags; none are currently defined
* @return the non-negative stream number in case of success,
* AVERROR_STREAM_NOT_FOUND if no stream with the requested type
* could be found,
* AVERROR_DECODER_NOT_FOUND if streams were found but no decoder
* @note If av_find_best_stream returns successfully and decoder_ret is not
* NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec.
*/
int
av_find_best_stream
(
AVFormatContext
*
ic
,
enum
AVMediaType
type
,
int
wanted_stream_nb
,
int
related_stream
,
AVCodec
**
decoder_ret
,
int
flags
);
/**
* Read a transport packet from a media file.
*
...
...
libavformat/utils.c
浏览文件 @
9128ae08
...
...
@@ -2458,6 +2458,67 @@ int av_find_stream_info(AVFormatContext *ic)
return
ret
;
}
static
AVProgram
*
find_program_from_stream
(
AVFormatContext
*
ic
,
int
s
)
{
int
i
,
j
;
for
(
i
=
0
;
i
<
ic
->
nb_programs
;
i
++
)
for
(
j
=
0
;
j
<
ic
->
programs
[
i
]
->
nb_stream_indexes
;
j
++
)
if
(
ic
->
programs
[
i
]
->
stream_index
[
j
]
==
s
)
return
ic
->
programs
[
i
];
return
NULL
;
}
int
av_find_best_stream
(
AVFormatContext
*
ic
,
enum
AVMediaType
type
,
int
wanted_stream_nb
,
int
related_stream
,
AVCodec
**
decoder_ret
,
int
flags
)
{
int
i
,
nb_streams
=
ic
->
nb_streams
,
stream_number
=
0
;
int
ret
=
AVERROR_STREAM_NOT_FOUND
,
best_count
=
-
1
;
unsigned
*
program
=
NULL
;
AVCodec
*
decoder
=
NULL
,
*
best_decoder
=
NULL
;
if
(
related_stream
>=
0
&&
wanted_stream_nb
<
0
)
{
AVProgram
*
p
=
find_program_from_stream
(
ic
,
related_stream
);
if
(
p
)
{
program
=
p
->
stream_index
;
nb_streams
=
p
->
nb_stream_indexes
;
}
}
for
(
i
=
0
;
i
<
nb_streams
;
i
++
)
{
AVStream
*
st
=
ic
->
streams
[
program
?
program
[
i
]
:
i
];
AVCodecContext
*
avctx
=
st
->
codec
;
if
(
avctx
->
codec_type
!=
type
)
continue
;
if
(
wanted_stream_nb
>=
0
&&
stream_number
++
!=
wanted_stream_nb
)
continue
;
if
(
decoder_ret
)
{
decoder
=
avcodec_find_decoder
(
ic
->
streams
[
i
]
->
codec
->
codec_id
);
if
(
!
decoder
)
{
if
(
ret
<
0
)
ret
=
AVERROR_DECODER_NOT_FOUND
;
continue
;
}
}
if
(
best_count
>=
st
->
codec_info_nb_frames
)
continue
;
best_count
=
st
->
codec_info_nb_frames
;
ret
=
i
;
best_decoder
=
decoder
;
if
(
program
&&
i
==
nb_streams
-
1
&&
ret
<
0
)
{
program
=
NULL
;
nb_streams
=
ic
->
nb_streams
;
i
=
0
;
/* no related stream found, try again with everything */
}
}
if
(
decoder_ret
)
*
decoder_ret
=
best_decoder
;
return
ret
;
}
/*******************************************************/
int
av_read_play
(
AVFormatContext
*
s
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录