Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
0b4e5451
Commit
0b4e5451
authored
Dec 13, 2011
by
Clément Bœsch
Committed by
Clément Bœsch
Dec 13, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi: use the new audio API in amovie source filter.
parent
220481e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
25 deletions
+16
-25
src_movie.c
libavfilter/src_movie.c
+16
-25
No files found.
libavfilter/src_movie.c
View file @
0b4e5451
...
@@ -57,8 +57,6 @@ typedef struct {
...
@@ -57,8 +57,6 @@ typedef struct {
AVFilterBufferRef
*
picref
;
AVFilterBufferRef
*
picref
;
/* audio-only fields */
/* audio-only fields */
void
*
samples_buf
;
int
samples_buf_size
;
int
bps
;
///< bytes per sample
int
bps
;
///< bytes per sample
AVPacket
pkt
,
pkt0
;
AVPacket
pkt
,
pkt0
;
AVFilterBufferRef
*
samplesref
;
AVFilterBufferRef
*
samplesref
;
...
@@ -176,6 +174,11 @@ static av_cold int movie_common_init(AVFilterContext *ctx, const char *args, voi
...
@@ -176,6 +174,11 @@ static av_cold int movie_common_init(AVFilterContext *ctx, const char *args, voi
movie
->
seek_point
,
movie
->
format_name
,
movie
->
file_name
,
movie
->
seek_point
,
movie
->
format_name
,
movie
->
file_name
,
movie
->
stream_index
);
movie
->
stream_index
);
if
(
!
(
movie
->
frame
=
avcodec_alloc_frame
())
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Failed to alloc frame
\n
"
);
return
AVERROR
(
ENOMEM
);
}
return
0
;
return
0
;
}
}
...
@@ -194,7 +197,6 @@ static av_cold void movie_common_uninit(AVFilterContext *ctx)
...
@@ -194,7 +197,6 @@ static av_cold void movie_common_uninit(AVFilterContext *ctx)
av_freep
(
&
movie
->
frame
);
av_freep
(
&
movie
->
frame
);
avfilter_unref_buffer
(
movie
->
samplesref
);
avfilter_unref_buffer
(
movie
->
samplesref
);
av_freep
(
&
movie
->
samples_buf
);
}
}
#if CONFIG_MOVIE_FILTER
#if CONFIG_MOVIE_FILTER
...
@@ -207,11 +209,6 @@ static av_cold int movie_init(AVFilterContext *ctx, const char *args, void *opaq
...
@@ -207,11 +209,6 @@ static av_cold int movie_init(AVFilterContext *ctx, const char *args, void *opaq
if
((
ret
=
movie_common_init
(
ctx
,
args
,
opaque
,
AVMEDIA_TYPE_VIDEO
))
<
0
)
if
((
ret
=
movie_common_init
(
ctx
,
args
,
opaque
,
AVMEDIA_TYPE_VIDEO
))
<
0
)
return
ret
;
return
ret
;
if
(
!
(
movie
->
frame
=
avcodec_alloc_frame
())
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Failed to alloc frame
\n
"
);
return
AVERROR
(
ENOMEM
);
}
movie
->
w
=
movie
->
codec_ctx
->
width
;
movie
->
w
=
movie
->
codec_ctx
->
width
;
movie
->
h
=
movie
->
codec_ctx
->
height
;
movie
->
h
=
movie
->
codec_ctx
->
height
;
...
@@ -378,7 +375,7 @@ static int amovie_get_samples(AVFilterLink *outlink)
...
@@ -378,7 +375,7 @@ static int amovie_get_samples(AVFilterLink *outlink)
{
{
MovieContext
*
movie
=
outlink
->
src
->
priv
;
MovieContext
*
movie
=
outlink
->
src
->
priv
;
AVPacket
pkt
;
AVPacket
pkt
;
int
ret
,
samples_size
,
decoded_data_size
;
int
ret
,
got_frame
=
0
;
if
(
!
movie
->
pkt
.
size
&&
movie
->
is_done
==
1
)
if
(
!
movie
->
pkt
.
size
&&
movie
->
is_done
==
1
)
return
AVERROR_EOF
;
return
AVERROR_EOF
;
...
@@ -402,20 +399,9 @@ static int amovie_get_samples(AVFilterLink *outlink)
...
@@ -402,20 +399,9 @@ static int amovie_get_samples(AVFilterLink *outlink)
}
}
}
}
/* reallocate the buffer for the decoded samples, if necessary */
samples_size
=
FFMAX
(
movie
->
pkt
.
size
*
sizeof
(
movie
->
bps
),
AVCODEC_MAX_AUDIO_FRAME_SIZE
);
if
(
samples_size
>
movie
->
samples_buf_size
)
{
movie
->
samples_buf
=
av_fast_realloc
(
movie
->
samples_buf
,
&
movie
->
samples_buf_size
,
samples_size
);
if
(
!
movie
->
samples_buf
)
return
AVERROR
(
ENOMEM
);
}
decoded_data_size
=
movie
->
samples_buf_size
;
/* decode and update the movie pkt */
/* decode and update the movie pkt */
ret
=
avcodec_decode_audio3
(
movie
->
codec_ctx
,
movie
->
samples_buf
,
avcodec_get_frame_defaults
(
movie
->
frame
);
&
decoded_data_siz
e
,
&
movie
->
pkt
);
ret
=
avcodec_decode_audio4
(
movie
->
codec_ctx
,
movie
->
frame
,
&
got_fram
e
,
&
movie
->
pkt
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
movie
->
pkt
.
size
=
0
;
movie
->
pkt
.
size
=
0
;
return
ret
;
return
ret
;
...
@@ -424,11 +410,16 @@ static int amovie_get_samples(AVFilterLink *outlink)
...
@@ -424,11 +410,16 @@ static int amovie_get_samples(AVFilterLink *outlink)
movie
->
pkt
.
size
-=
ret
;
movie
->
pkt
.
size
-=
ret
;
/* wrap the decoded data in a samplesref */
/* wrap the decoded data in a samplesref */
if
(
decoded_data_size
>
0
)
{
if
(
got_frame
)
{
int
nb_samples
=
decoded_data_size
/
movie
->
bps
/
movie
->
codec_ctx
->
channels
;
int
nb_samples
=
movie
->
frame
->
nb_samples
;
int
data_size
=
av_samples_get_buffer_size
(
NULL
,
movie
->
codec_ctx
->
channels
,
nb_samples
,
movie
->
codec_ctx
->
sample_fmt
,
1
);
if
(
data_size
<
0
)
return
data_size
;
movie
->
samplesref
=
movie
->
samplesref
=
avfilter_get_audio_buffer
(
outlink
,
AV_PERM_WRITE
,
nb_samples
);
avfilter_get_audio_buffer
(
outlink
,
AV_PERM_WRITE
,
nb_samples
);
memcpy
(
movie
->
samplesref
->
data
[
0
],
movie
->
samples_buf
,
decoded_
data_size
);
memcpy
(
movie
->
samplesref
->
data
[
0
],
movie
->
frame
->
data
[
0
],
data_size
);
movie
->
samplesref
->
pts
=
movie
->
pkt
.
pts
;
movie
->
samplesref
->
pts
=
movie
->
pkt
.
pts
;
movie
->
samplesref
->
pos
=
movie
->
pkt
.
pos
;
movie
->
samplesref
->
pos
=
movie
->
pkt
.
pos
;
movie
->
samplesref
->
audio
->
sample_rate
=
movie
->
codec_ctx
->
sample_rate
;
movie
->
samplesref
->
audio
->
sample_rate
=
movie
->
codec_ctx
->
sample_rate
;
...
...
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