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
5cd597f2
Commit
5cd597f2
authored
Dec 23, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alac: decode directly to the user-provided AVFrame
parent
bae4f479
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
alac.c
libavcodec/alac.c
+8
-12
No files found.
libavcodec/alac.c
View file @
5cd597f2
...
@@ -58,7 +58,6 @@
...
@@ -58,7 +58,6 @@
typedef
struct
{
typedef
struct
{
AVCodecContext
*
avctx
;
AVCodecContext
*
avctx
;
AVFrame
frame
;
GetBitContext
gb
;
GetBitContext
gb
;
int
channels
;
int
channels
;
...
@@ -248,7 +247,7 @@ static void append_extra_bits(int32_t *buffer[2], int32_t *extra_bits_buffer[2],
...
@@ -248,7 +247,7 @@ static void append_extra_bits(int32_t *buffer[2], int32_t *extra_bits_buffer[2],
buffer
[
ch
][
i
]
=
(
buffer
[
ch
][
i
]
<<
extra_bits
)
|
extra_bits_buffer
[
ch
][
i
];
buffer
[
ch
][
i
]
=
(
buffer
[
ch
][
i
]
<<
extra_bits
)
|
extra_bits_buffer
[
ch
][
i
];
}
}
static
int
decode_element
(
AVCodecContext
*
avctx
,
void
*
data
,
int
ch_index
,
static
int
decode_element
(
AVCodecContext
*
avctx
,
AVFrame
*
frame
,
int
ch_index
,
int
channels
)
int
channels
)
{
{
ALACContext
*
alac
=
avctx
->
priv_data
;
ALACContext
*
alac
=
avctx
->
priv_data
;
...
@@ -283,8 +282,8 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
...
@@ -283,8 +282,8 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
}
}
if
(
!
alac
->
nb_samples
)
{
if
(
!
alac
->
nb_samples
)
{
/* get output buffer */
/* get output buffer */
alac
->
frame
.
nb_samples
=
output_samples
;
frame
->
nb_samples
=
output_samples
;
if
((
ret
=
ff_get_buffer
(
avctx
,
&
alac
->
frame
))
<
0
)
{
if
((
ret
=
ff_get_buffer
(
avctx
,
frame
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
ret
;
return
ret
;
}
}
...
@@ -296,7 +295,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
...
@@ -296,7 +295,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
alac
->
nb_samples
=
output_samples
;
alac
->
nb_samples
=
output_samples
;
if
(
alac
->
sample_size
>
16
)
{
if
(
alac
->
sample_size
>
16
)
{
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
alac
->
output_samples_buffer
[
ch
]
=
(
int32_t
*
)
alac
->
frame
.
extended_data
[
ch_index
+
ch
];
alac
->
output_samples_buffer
[
ch
]
=
(
int32_t
*
)
frame
->
extended_data
[
ch_index
+
ch
];
}
}
if
(
is_compressed
)
{
if
(
is_compressed
)
{
...
@@ -377,7 +376,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
...
@@ -377,7 +376,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
switch
(
alac
->
sample_size
)
{
switch
(
alac
->
sample_size
)
{
case
16
:
{
case
16
:
{
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
{
int16_t
*
outbuffer
=
(
int16_t
*
)
alac
->
frame
.
extended_data
[
ch_index
+
ch
];
int16_t
*
outbuffer
=
(
int16_t
*
)
frame
->
extended_data
[
ch_index
+
ch
];
for
(
i
=
0
;
i
<
alac
->
nb_samples
;
i
++
)
for
(
i
=
0
;
i
<
alac
->
nb_samples
;
i
++
)
*
outbuffer
++
=
alac
->
output_samples_buffer
[
ch
][
i
];
*
outbuffer
++
=
alac
->
output_samples_buffer
[
ch
][
i
];
}}
}}
...
@@ -397,6 +396,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -397,6 +396,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
{
{
ALACContext
*
alac
=
avctx
->
priv_data
;
ALACContext
*
alac
=
avctx
->
priv_data
;
AVFrame
*
frame
=
data
;
enum
AlacRawDataBlockType
element
;
enum
AlacRawDataBlockType
element
;
int
channels
;
int
channels
;
int
ch
,
ret
,
got_end
;
int
ch
,
ret
,
got_end
;
...
@@ -423,7 +423,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -423,7 +423,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
ret
=
decode_element
(
avctx
,
data
,
ret
=
decode_element
(
avctx
,
frame
,
ff_alac_channel_layout_offsets
[
alac
->
channels
-
1
][
ch
],
ff_alac_channel_layout_offsets
[
alac
->
channels
-
1
][
ch
],
channels
);
channels
);
if
(
ret
<
0
&&
get_bits_left
(
&
alac
->
gb
))
if
(
ret
<
0
&&
get_bits_left
(
&
alac
->
gb
))
...
@@ -441,8 +441,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -441,8 +441,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
avpkt
->
size
*
8
-
get_bits_count
(
&
alac
->
gb
));
avpkt
->
size
*
8
-
get_bits_count
(
&
alac
->
gb
));
}
}
*
got_frame_ptr
=
1
;
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
alac
->
frame
;
return
avpkt
->
size
;
return
avpkt
->
size
;
}
}
...
@@ -563,9 +562,6 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
...
@@ -563,9 +562,6 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
return
ret
;
return
ret
;
}
}
avcodec_get_frame_defaults
(
&
alac
->
frame
);
avctx
->
coded_frame
=
&
alac
->
frame
;
return
0
;
return
0
;
}
}
...
...
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