Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
3009f521
Commit
3009f521
authored
May 25, 2011
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ffplay: use new avcodec_open2 and avformat_find_stream_info API.
parent
8c8eab8b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
20 deletions
+40
-20
cmdutils.c
cmdutils.c
+17
-0
cmdutils.h
cmdutils.h
+5
-0
ffplay.c
ffplay.c
+18
-20
No files found.
cmdutils.c
View file @
3009f521
...
...
@@ -912,6 +912,23 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, int e
return
ret
;
}
AVDictionary
**
setup_find_stream_info_opts
(
AVFormatContext
*
s
)
{
int
i
;
AVDictionary
**
opts
;
if
(
!
s
->
nb_streams
)
return
NULL
;
opts
=
av_mallocz
(
s
->
nb_streams
*
sizeof
(
*
opts
));
if
(
!
opts
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Could not alloc memory for stream options.
\n
"
);
return
NULL
;
}
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
opts
[
i
]
=
filter_codec_opts
(
codec_opts
,
s
->
streams
[
i
]
->
codec
->
codec_id
,
0
);
return
opts
;
}
#if CONFIG_AVFILTER
static
int
ffsink_init
(
AVFilterContext
*
ctx
,
const
char
*
args
,
void
*
opaque
)
...
...
cmdutils.h
View file @
3009f521
...
...
@@ -156,6 +156,11 @@ void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec);
*/
AVDictionary
*
filter_codec_opts
(
AVDictionary
*
opts
,
enum
CodecID
codec_id
,
int
encoder
);
/*
* Setup AVCodecContext options for avformat_find_stream_info.
*/
AVDictionary
**
setup_find_stream_info_opts
(
AVFormatContext
*
s
);
/**
* Print an error message to stderr, indicating filename and a human
* readable description of the error code err.
...
...
ffplay.c
View file @
3009f521
...
...
@@ -2130,11 +2130,15 @@ static int stream_component_open(VideoState *is, int stream_index)
AVCodecContext
*
avctx
;
AVCodec
*
codec
;
SDL_AudioSpec
wanted_spec
,
spec
;
AVDictionary
*
opts
;
AVDictionaryEntry
*
t
=
NULL
;
if
(
stream_index
<
0
||
stream_index
>=
ic
->
nb_streams
)
return
-
1
;
avctx
=
ic
->
streams
[
stream_index
]
->
codec
;
opts
=
filter_codec_opts
(
codec_opts
,
avctx
->
codec_id
,
0
);
/* prepare audio output */
if
(
avctx
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
{
if
(
avctx
->
channels
>
0
)
{
...
...
@@ -2159,11 +2163,13 @@ static int stream_component_open(VideoState *is, int stream_index)
avctx
->
error_concealment
=
error_concealment
;
avctx
->
thread_count
=
thread_count
;
set_context_opts
(
avctx
,
avcodec_opts
[
avctx
->
codec_type
],
0
,
codec
);
if
(
!
codec
||
avcodec_open
(
avctx
,
codec
)
<
0
)
avcodec_open
2
(
avctx
,
codec
,
&
opts
)
<
0
)
return
-
1
;
if
((
t
=
av_dict_get
(
opts
,
""
,
NULL
,
AV_DICT_IGNORE_SUFFIX
)))
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Option %s not found.
\n
"
,
t
->
key
);
return
AVERROR_OPTION_NOT_FOUND
;
}
/* prepare audio output */
if
(
avctx
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
{
...
...
@@ -2313,6 +2319,8 @@ static int decode_thread(void *arg)
int
eof
=
0
;
int
pkt_in_play_range
=
0
;
AVDictionaryEntry
*
t
;
AVDictionary
**
opts
;
int
orig_nb_streams
;
memset
(
st_index
,
-
1
,
sizeof
(
st_index
));
is
->
video_stream
=
-
1
;
...
...
@@ -2338,29 +2346,19 @@ static int decode_thread(void *arg)
if
(
genpts
)
ic
->
flags
|=
AVFMT_FLAG_GENPTS
;
/* Set AVCodecContext options so they will be seen by av_find_stream_info() */
for
(
i
=
0
;
i
<
ic
->
nb_streams
;
i
++
)
{
AVCodecContext
*
dec
=
ic
->
streams
[
i
]
->
codec
;
switch
(
dec
->
codec_type
)
{
case
AVMEDIA_TYPE_AUDIO
:
set_context_opts
(
dec
,
avcodec_opts
[
AVMEDIA_TYPE_AUDIO
],
AV_OPT_FLAG_AUDIO_PARAM
|
AV_OPT_FLAG_DECODING_PARAM
,
NULL
);
break
;
case
AVMEDIA_TYPE_VIDEO
:
set_context_opts
(
dec
,
avcodec_opts
[
AVMEDIA_TYPE_VIDEO
],
AV_OPT_FLAG_VIDEO_PARAM
|
AV_OPT_FLAG_DECODING_PARAM
,
NULL
);
break
;
}
}
opts
=
setup_find_stream_info_opts
(
ic
);
orig_nb_streams
=
ic
->
nb_streams
;
err
=
av
_find_stream_info
(
ic
);
err
=
av
format_find_stream_info
(
ic
,
opts
);
if
(
err
<
0
)
{
fprintf
(
stderr
,
"%s: could not find codec parameters
\n
"
,
is
->
filename
);
ret
=
-
1
;
goto
fail
;
}
for
(
i
=
0
;
i
<
orig_nb_streams
;
i
++
)
av_dict_free
(
&
opts
[
i
]);
av_freep
(
&
opts
);
if
(
ic
->
pb
)
ic
->
pb
->
eof_reached
=
0
;
//FIXME hack, ffplay maybe should not use url_feof() to test for the end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment