Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
6303d54c
Commit
6303d54c
authored
Apr 12, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/ffmpeg: make variables more local
parent
9d91aa23
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
25 deletions
+14
-25
ffmpeg_decoder_plugin.c
src/decoder/ffmpeg_decoder_plugin.c
+14
-25
No files found.
src/decoder/ffmpeg_decoder_plugin.c
View file @
6303d54c
...
@@ -92,13 +92,11 @@ static int64_t
...
@@ -92,13 +92,11 @@ static int64_t
mpd_ffmpeg_stream_seek
(
void
*
opaque
,
int64_t
pos
,
int
whence
)
mpd_ffmpeg_stream_seek
(
void
*
opaque
,
int64_t
pos
,
int
whence
)
{
{
struct
mpd_ffmpeg_stream
*
stream
=
opaque
;
struct
mpd_ffmpeg_stream
*
stream
=
opaque
;
bool
ret
;
if
(
whence
==
AVSEEK_SIZE
)
if
(
whence
==
AVSEEK_SIZE
)
return
stream
->
input
->
size
;
return
stream
->
input
->
size
;
ret
=
input_stream_seek
(
stream
->
input
,
pos
,
whence
,
NULL
);
if
(
!
input_stream_seek
(
stream
->
input
,
pos
,
whence
,
NULL
))
if
(
!
ret
)
return
-
1
;
return
-
1
;
return
stream
->
input
->
offset
;
return
stream
->
input
->
offset
;
...
@@ -171,28 +169,22 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
...
@@ -171,28 +169,22 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
AVCodecContext
*
codec_context
,
AVCodecContext
*
codec_context
,
const
AVRational
*
time_base
)
const
AVRational
*
time_base
)
{
{
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
uint8_t
audio_buf
[(
AVCODEC_MAX_AUDIO_FRAME_SIZE
*
3
)
/
2
+
16
];
int16_t
*
aligned_buffer
;
size_t
buffer_size
;
int
len
,
audio_size
;
uint8_t
*
packet_data
;
int
packet_size
;
if
(
packet
->
pts
!=
(
int64_t
)
AV_NOPTS_VALUE
)
if
(
packet
->
pts
!=
(
int64_t
)
AV_NOPTS_VALUE
)
decoder_timestamp
(
decoder
,
decoder_timestamp
(
decoder
,
av_rescale_q
(
packet
->
pts
,
*
time_base
,
av_rescale_q
(
packet
->
pts
,
*
time_base
,
(
AVRational
){
1
,
1
}));
(
AVRational
){
1
,
1
}));
packet_data
=
packet
->
data
;
const
uint8_t
*
packet_data
=
packet
->
data
;
packet_size
=
packet
->
size
;
int
packet_size
=
packet
->
size
;
buffer_size
=
sizeof
(
audio_buf
);
uint8_t
audio_buf
[(
AVCODEC_MAX_AUDIO_FRAME_SIZE
*
3
)
/
2
+
16
];
aligned_buffer
=
align16
(
audio_buf
,
&
buffer_size
);
size_t
buffer_size
=
sizeof
(
audio_buf
);
int16_t
*
aligned_buffer
=
align16
(
audio_buf
,
&
buffer_size
);
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
while
((
packet_size
>
0
)
&&
(
cmd
==
DECODE_COMMAND_NONE
))
{
while
((
packet_size
>
0
)
&&
(
cmd
==
DECODE_COMMAND_NONE
))
{
audio_size
=
buffer_size
;
int
audio_size
=
buffer_size
;
len
=
avcodec_decode_audio2
(
codec_context
,
int
len
=
avcodec_decode_audio2
(
codec_context
,
aligned_buffer
,
&
audio_size
,
aligned_buffer
,
&
audio_size
,
packet_data
,
packet_size
);
packet_data
,
packet_size
);
...
@@ -282,12 +274,8 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
...
@@ -282,12 +274,8 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
return
;
return
;
}
}
AVFormatContext
*
format_context
;
AVCodecContext
*
codec_context
;
AVCodec
*
codec
;
int
audio_stream
;
//ffmpeg works with ours "fileops" helper
//ffmpeg works with ours "fileops" helper
AVFormatContext
*
format_context
;
if
(
av_open_input_stream
(
&
format_context
,
stream
->
io
,
input
->
uri
,
if
(
av_open_input_stream
(
&
format_context
,
stream
->
io
,
input
->
uri
,
input_format
,
NULL
)
!=
0
)
{
input_format
,
NULL
)
!=
0
)
{
g_warning
(
"Open failed
\n
"
);
g_warning
(
"Open failed
\n
"
);
...
@@ -302,7 +290,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
...
@@ -302,7 +290,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
return
;
return
;
}
}
audio_stream
=
ffmpeg_find_audio_stream
(
format_context
);
int
audio_stream
=
ffmpeg_find_audio_stream
(
format_context
);
if
(
audio_stream
==
-
1
)
{
if
(
audio_stream
==
-
1
)
{
g_warning
(
"No audio stream inside
\n
"
);
g_warning
(
"No audio stream inside
\n
"
);
av_close_input_stream
(
format_context
);
av_close_input_stream
(
format_context
);
...
@@ -310,11 +298,12 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
...
@@ -310,11 +298,12 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
return
;
return
;
}
}
codec_context
=
format_context
->
streams
[
audio_stream
]
->
codec
;
AVCodecContext
*
codec_context
=
format_context
->
streams
[
audio_stream
]
->
codec
;
if
(
codec_context
->
codec_name
[
0
]
!=
0
)
if
(
codec_context
->
codec_name
[
0
]
!=
0
)
g_debug
(
"codec '%s'"
,
codec_context
->
codec_name
);
g_debug
(
"codec '%s'"
,
codec_context
->
codec_name
);
codec
=
avcodec_find_decoder
(
codec_context
->
codec_id
);
AVCodec
*
codec
=
avcodec_find_decoder
(
codec_context
->
codec_id
);
if
(
!
codec
)
{
if
(
!
codec
)
{
g_warning
(
"Unsupported audio codec
\n
"
);
g_warning
(
"Unsupported audio codec
\n
"
);
...
...
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