Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NotesChapter
ijkplayer
提交
2b80fbb4
I
ijkplayer
项目概览
NotesChapter
/
ijkplayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
ijkplayer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2b80fbb4
编写于
7月 06, 2015
作者:
Z
Zhang Rui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ff_ffplay: batch merge
上级
f4c034b6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
147 addition
and
87 deletion
+147
-87
ijkmedia/ijkplayer/config.h
ijkmedia/ijkplayer/config.h
+26
-0
ijkmedia/ijkplayer/ff_ffplay.c
ijkmedia/ijkplayer/ff_ffplay.c
+119
-87
ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj/project.pbxproj
ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj/project.pbxproj
+2
-0
未找到文件。
ijkmedia/ijkplayer/config.h
0 → 100644
浏览文件 @
2b80fbb4
/*
* Copyright (c) 2015 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer 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.
*
* ijkPlayer 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 ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FFPLAY__CONFIG_H
#define FFPLAY__CONFIG_H
// dummy file of ffmpeg/config.h
#endif//FFPLAY__CONFIG_H
ijkmedia/ijkplayer/ff_ffplay.c
浏览文件 @
2b80fbb4
/*
* ffplay_def.c
*
* Copyright (c) 2003 Fabrice Bellard
* Copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
...
...
@@ -23,7 +21,43 @@
#include "ff_ffplay.h"
/**
* @file
* simple media player based on the FFmpeg libraries
*/
#include "config.h"
#include <inttypes.h>
#include <math.h>
#include <limits.h>
#include <signal.h>
#include <stdint.h>
#include "libavutil/avstring.h"
// FFP_MERGE: #include "libavutil/colorspace.h"
#include "libavutil/eval.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/dict.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/avassert.h"
#include "libavutil/time.h"
#include "libavformat/avformat.h"
// FFP_MERGE: #include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#include "libswresample/swresample.h"
#if CONFIG_AVFILTER
# include "libavfilter/avcodec.h"
# include "libavfilter/avfilter.h"
# include "libavfilter/buffersink.h"
# include "libavfilter/buffersrc.h"
#endif
#include "ff_cmdutils.h"
#include "ff_fferror.h"
#include "ff_ffpipeline.h"
...
...
@@ -683,10 +717,10 @@ static void stream_close(VideoState *is)
/* free all pictures */
frame_queue_destory
(
&
is
->
pictq
);
frame_queue_destory
(
&
is
->
sampq
);
#ifdef FFP_MERGE
frame_queue_destory
(
&
is
->
subpq
);
#endif
frame_queue_destory
(
&
is
->
sampq
);
SDL_DestroyCond
(
is
->
continue_read_thread
);
SDL_DestroyMutex
(
is
->
play_mutex
);
#if !CONFIG_AVFILTER
...
...
@@ -1234,6 +1268,7 @@ static int get_video_frame(FFPlayer *ffp, AVFrame *frame)
}
}
}
return
got_picture
;
}
...
...
@@ -1482,7 +1517,8 @@ static int audio_thread(void *arg)
cmp_audio_fmts
(
is
->
audio_filter_src
.
fmt
,
is
->
audio_filter_src
.
channels
,
frame
->
format
,
av_frame_get_channels
(
frame
))
||
is
->
audio_filter_src
.
channel_layout
!=
dec_channel_layout
||
is
->
audio_filter_src
.
freq
!=
frame
->
sample_rate
||+
is
->
auddec
.
pkt_serial
!=
last_serial
;
is
->
audio_filter_src
.
freq
!=
frame
->
sample_rate
||
is
->
auddec
.
pkt_serial
!=
last_serial
;
if
(
reconfigure
)
{
char
buf1
[
1024
],
buf2
[
1024
];
...
...
@@ -1749,95 +1785,93 @@ static int audio_decode_frame(FFPlayer *ffp)
frame_queue_next
(
&
is
->
sampq
);
}
while
(
af
->
serial
!=
is
->
audioq
.
serial
);
{
data_size
=
av_samples_get_buffer_size
(
NULL
,
av_frame_get_channels
(
af
->
frame
),
af
->
frame
->
nb_samples
,
af
->
frame
->
format
,
1
);
dec_channel_layout
=
(
af
->
frame
->
channel_layout
&&
av_frame_get_channels
(
af
->
frame
)
==
av_get_channel_layout_nb_channels
(
af
->
frame
->
channel_layout
))
?
af
->
frame
->
channel_layout
:
av_get_default_channel_layout
(
av_frame_get_channels
(
af
->
frame
));
wanted_nb_samples
=
synchronize_audio
(
is
,
af
->
frame
->
nb_samples
);
if
(
af
->
frame
->
format
!=
is
->
audio_src
.
fmt
||
dec_channel_layout
!=
is
->
audio_src
.
channel_layout
||
af
->
frame
->
sample_rate
!=
is
->
audio_src
.
freq
||
(
wanted_nb_samples
!=
af
->
frame
->
nb_samples
&&
!
is
->
swr_ctx
))
{
data_size
=
av_samples_get_buffer_size
(
NULL
,
av_frame_get_channels
(
af
->
frame
),
af
->
frame
->
nb_samples
,
af
->
frame
->
format
,
1
);
dec_channel_layout
=
(
af
->
frame
->
channel_layout
&&
av_frame_get_channels
(
af
->
frame
)
==
av_get_channel_layout_nb_channels
(
af
->
frame
->
channel_layout
))
?
af
->
frame
->
channel_layout
:
av_get_default_channel_layout
(
av_frame_get_channels
(
af
->
frame
));
wanted_nb_samples
=
synchronize_audio
(
is
,
af
->
frame
->
nb_samples
);
if
(
af
->
frame
->
format
!=
is
->
audio_src
.
fmt
||
dec_channel_layout
!=
is
->
audio_src
.
channel_layout
||
af
->
frame
->
sample_rate
!=
is
->
audio_src
.
freq
||
(
wanted_nb_samples
!=
af
->
frame
->
nb_samples
&&
!
is
->
swr_ctx
))
{
swr_free
(
&
is
->
swr_ctx
);
is
->
swr_ctx
=
swr_alloc_set_opts
(
NULL
,
is
->
audio_tgt
.
channel_layout
,
is
->
audio_tgt
.
fmt
,
is
->
audio_tgt
.
freq
,
dec_channel_layout
,
af
->
frame
->
format
,
af
->
frame
->
sample_rate
,
0
,
NULL
);
if
(
!
is
->
swr_ctx
||
swr_init
(
is
->
swr_ctx
)
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!
\n
"
,
af
->
frame
->
sample_rate
,
av_get_sample_fmt_name
(
af
->
frame
->
format
),
av_frame_get_channels
(
af
->
frame
),
is
->
audio_tgt
.
freq
,
av_get_sample_fmt_name
(
is
->
audio_tgt
.
fmt
),
is
->
audio_tgt
.
channels
);
swr_free
(
&
is
->
swr_ctx
);
is
->
swr_ctx
=
swr_alloc_set_opts
(
NULL
,
is
->
audio_tgt
.
channel_layout
,
is
->
audio_tgt
.
fmt
,
is
->
audio_tgt
.
freq
,
dec_channel_layout
,
af
->
frame
->
format
,
af
->
frame
->
sample_rate
,
0
,
NULL
);
if
(
!
is
->
swr_ctx
||
swr_init
(
is
->
swr_ctx
)
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!
\n
"
,
af
->
frame
->
sample_rate
,
av_get_sample_fmt_name
(
af
->
frame
->
format
),
av_frame_get_channels
(
af
->
frame
),
is
->
audio_tgt
.
freq
,
av_get_sample_fmt_name
(
is
->
audio_tgt
.
fmt
),
is
->
audio_tgt
.
channels
);
swr_free
(
&
is
->
swr_ctx
);
return
-
1
;
}
is
->
audio_src
.
channel_layout
=
dec_channel_layout
;
is
->
audio_src
.
channels
=
av_frame_get_channels
(
af
->
frame
);
is
->
audio_src
.
freq
=
af
->
frame
->
sample_rate
;
is
->
audio_src
.
fmt
=
af
->
frame
->
format
;
return
-
1
;
}
if
(
is
->
swr_ctx
)
{
const
uint8_t
**
in
=
(
const
uint8_t
**
)
af
->
frame
->
extended_data
;
uint8_t
**
out
=
&
is
->
audio_buf1
;
int
out_count
=
(
int
)((
int64_t
)
wanted_nb_samples
*
is
->
audio_tgt
.
freq
/
af
->
frame
->
sample_rate
+
256
);
int
out_size
=
av_samples_get_buffer_size
(
NULL
,
is
->
audio_tgt
.
channels
,
out_count
,
is
->
audio_tgt
.
fmt
,
0
);
int
len2
;
if
(
out_size
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"av_samples_get_buffer_size() failed
\n
"
);
return
-
1
;
}
if
(
wanted_nb_samples
!=
af
->
frame
->
nb_samples
)
{
if
(
swr_set_compensation
(
is
->
swr_ctx
,
(
wanted_nb_samples
-
af
->
frame
->
nb_samples
)
*
is
->
audio_tgt
.
freq
/
af
->
frame
->
sample_rate
,
wanted_nb_samples
*
is
->
audio_tgt
.
freq
/
af
->
frame
->
sample_rate
)
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"swr_set_compensation() failed
\n
"
);
return
-
1
;
}
}
av_fast_malloc
(
&
is
->
audio_buf1
,
&
is
->
audio_buf1_size
,
out_size
);
if
(
!
is
->
audio_buf1
)
return
AVERROR
(
ENOMEM
);
len2
=
swr_convert
(
is
->
swr_ctx
,
out
,
out_count
,
in
,
af
->
frame
->
nb_samples
);
if
(
len2
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"swr_convert() failed
\n
"
);
is
->
audio_src
.
channel_layout
=
dec_channel_layout
;
is
->
audio_src
.
channels
=
av_frame_get_channels
(
af
->
frame
);
is
->
audio_src
.
freq
=
af
->
frame
->
sample_rate
;
is
->
audio_src
.
fmt
=
af
->
frame
->
format
;
}
if
(
is
->
swr_ctx
)
{
const
uint8_t
**
in
=
(
const
uint8_t
**
)
af
->
frame
->
extended_data
;
uint8_t
**
out
=
&
is
->
audio_buf1
;
int
out_count
=
(
int
)((
int64_t
)
wanted_nb_samples
*
is
->
audio_tgt
.
freq
/
af
->
frame
->
sample_rate
+
256
);
int
out_size
=
av_samples_get_buffer_size
(
NULL
,
is
->
audio_tgt
.
channels
,
out_count
,
is
->
audio_tgt
.
fmt
,
0
);
int
len2
;
if
(
out_size
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"av_samples_get_buffer_size() failed
\n
"
);
return
-
1
;
}
if
(
wanted_nb_samples
!=
af
->
frame
->
nb_samples
)
{
if
(
swr_set_compensation
(
is
->
swr_ctx
,
(
wanted_nb_samples
-
af
->
frame
->
nb_samples
)
*
is
->
audio_tgt
.
freq
/
af
->
frame
->
sample_rate
,
wanted_nb_samples
*
is
->
audio_tgt
.
freq
/
af
->
frame
->
sample_rate
)
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"swr_set_compensation() failed
\n
"
);
return
-
1
;
}
if
(
len2
==
out_count
)
{
av_log
(
NULL
,
AV_LOG_WARNING
,
"audio buffer is probably too small
\n
"
);
if
(
swr_init
(
is
->
swr_ctx
)
<
0
)
swr_free
(
&
is
->
swr_ctx
);
}
is
->
audio_buf
=
is
->
audio_buf1
;
resampled_data_size
=
len2
*
is
->
audio_tgt
.
channels
*
av_get_bytes_per_sample
(
is
->
audio_tgt
.
fmt
);
}
else
{
is
->
audio_buf
=
af
->
frame
->
data
[
0
];
resampled_data_size
=
data_size
;
}
av_fast_malloc
(
&
is
->
audio_buf1
,
&
is
->
audio_buf1_size
,
out_size
);
if
(
!
is
->
audio_buf1
)
return
AVERROR
(
ENOMEM
);
len2
=
swr_convert
(
is
->
swr_ctx
,
out
,
out_count
,
in
,
af
->
frame
->
nb_samples
);
if
(
len2
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"swr_convert() failed
\n
"
);
return
-
1
;
}
if
(
len2
==
out_count
)
{
av_log
(
NULL
,
AV_LOG_WARNING
,
"audio buffer is probably too small
\n
"
);
if
(
swr_init
(
is
->
swr_ctx
)
<
0
)
swr_free
(
&
is
->
swr_ctx
);
}
is
->
audio_buf
=
is
->
audio_buf1
;
resampled_data_size
=
len2
*
is
->
audio_tgt
.
channels
*
av_get_bytes_per_sample
(
is
->
audio_tgt
.
fmt
);
}
else
{
is
->
audio_buf
=
af
->
frame
->
data
[
0
];
resampled_data_size
=
data_size
;
}
audio_clock0
=
is
->
audio_clock
;
/* update the audio clock with the pts */
if
(
!
isnan
(
af
->
pts
))
is
->
audio_clock
=
af
->
pts
+
(
double
)
af
->
frame
->
nb_samples
/
af
->
frame
->
sample_rate
;
else
is
->
audio_clock
=
NAN
;
is
->
audio_clock_serial
=
af
->
serial
;
audio_clock0
=
is
->
audio_clock
;
/* update the audio clock with the pts */
if
(
!
isnan
(
af
->
pts
))
is
->
audio_clock
=
af
->
pts
+
(
double
)
af
->
frame
->
nb_samples
/
af
->
frame
->
sample_rate
;
else
is
->
audio_clock
=
NAN
;
is
->
audio_clock_serial
=
af
->
serial
;
#ifdef FFP_SHOW_AUDIO_DELAY
#ifdef DEBUG
{
static
double
last_clock
;
printf
(
"audio: delay=%0.3f clock=%0.3f clock0=%0.3f
\n
"
,
is
->
audio_clock
-
last_clock
,
is
->
audio_clock
,
audio_clock0
);
last_clock
=
is
->
audio_clock
;
}
{
static
double
last_clock
;
printf
(
"audio: delay=%0.3f clock=%0.3f clock0=%0.3f
\n
"
,
is
->
audio_clock
-
last_clock
,
is
->
audio_clock
,
audio_clock0
);
last_clock
=
is
->
audio_clock
;
}
#endif
#endif
}
return
resampled_data_size
;
}
...
...
@@ -1898,7 +1932,7 @@ static int audio_open(FFPlayer *opaque, int64_t wanted_channel_layout, int wante
#ifdef FFP_MERGE
static
const
int
next_sample_rates
[]
=
{
0
,
44100
,
48000
,
96000
,
192000
};
#endif
static
const
int
next_sample_rates
[]
=
{
6000
,
11025
,
12000
,
22050
,
2400
0
,
44100
,
48000
};
static
const
int
next_sample_rates
[]
=
{
0
,
44100
,
48000
};
int
next_sample_rate_idx
=
FF_ARRAY_ELEMS
(
next_sample_rates
)
-
1
;
env
=
SDL_getenv
(
"SDL_AUDIO_CHANNELS"
);
...
...
@@ -2029,15 +2063,13 @@ static int stream_component_open(FFPlayer *ffp, int stream_index)
av_dict_set_int
(
&
opts
,
"lowres"
,
stream_lowres
,
0
);
if
(
avctx
->
codec_type
==
AVMEDIA_TYPE_VIDEO
||
avctx
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
av_dict_set
(
&
opts
,
"refcounted_frames"
,
"1"
,
0
);
//if (avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
if
((
ret
=
avcodec_open2
(
avctx
,
codec
,
&
opts
))
<
0
)
{
goto
fail
;
}
//}
if
((
t
=
av_dict_get
(
opts
,
""
,
NULL
,
AV_DICT_IGNORE_SUFFIX
)))
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Option %s not found.
\n
"
,
t
->
key
);
#ifdef FFP_MERGE
ret
=
AVERROR_OPTION_NOT_FOUND
;
ret
=
AVERROR_OPTION_NOT_FOUND
;
goto
fail
;
#endif
}
...
...
ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj/project.pbxproj
浏览文件 @
2b80fbb4
...
...
@@ -141,6 +141,7 @@
E67C4E0419D15B3200415CEE
/* IJKAVPlayerLayerView.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
name
=
IJKAVPlayerLayerView.m
;
path
=
IJKMediaPlayer/IJKAVPlayerLayerView.m
;
sourceTree
=
"<group>"
;
};
E67C4E0619D15EEA00415CEE
/* IJKAVMoviePlayerController.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
name
=
IJKAVMoviePlayerController.h
;
path
=
IJKMediaPlayer/IJKAVMoviePlayerController.h
;
sourceTree
=
"<group>"
;
};
E67C4E0719D15EEA00415CEE
/* IJKAVMoviePlayerController.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
name
=
IJKAVMoviePlayerController.m
;
path
=
IJKMediaPlayer/IJKAVMoviePlayerController.m
;
sourceTree
=
"<group>"
;
};
E67FB4AC1B4A766F00AA94AA
/* config.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
config.h
;
sourceTree
=
"<group>"
;
};
E6903EB917EAF6C500CFD954
/* libIJKMediaPlayer.a */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
archive.ar
;
includeInIndex
=
0
;
path
=
libIJKMediaPlayer.a
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
E6903EC017EAF6C500CFD954
/* IJKMediaPlayer-Prefix.pch */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"IJKMediaPlayer-Prefix.pch"
;
sourceTree
=
"<group>"
;
};
E6903EC117EAF6C500CFD954
/* IJKMediaPlayback.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
name
=
IJKMediaPlayback.h
;
path
=
IJKMediaPlayer/IJKMediaPlayback.h
;
sourceTree
=
"<group>"
;
};
...
...
@@ -405,6 +406,7 @@
E6903FCE17EAFC6100CFD954
/* ijkplayer */
=
{
isa
=
PBXGroup
;
children
=
(
E67FB4AC1B4A766F00AA94AA
/* config.h */
,
E6903FD517EAFC6100CFD954
/* ff_cmdutils.c */
,
E6903FD617EAFC6100CFD954
/* ff_cmdutils.h */
,
E6903FD717EAFC6100CFD954
/* ff_fferror.h */
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录