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
3a23752c
Commit
3a23752c
authored
Dec 24, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpc7/8: decode directly to the user-provided AVFrame
parent
2c785e25
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
17 deletions
+10
-17
mpc.h
libavcodec/mpc.h
+0
-1
mpc7.c
libavcodec/mpc7.c
+5
-8
mpc8.c
libavcodec/mpc8.c
+5
-8
No files found.
libavcodec/mpc.h
View file @
3a23752c
...
@@ -50,7 +50,6 @@ typedef struct Band {
...
@@ -50,7 +50,6 @@ typedef struct Band {
}
Band
;
}
Band
;
typedef
struct
MPCContext
{
typedef
struct
MPCContext
{
AVFrame
frame
;
DSPContext
dsp
;
DSPContext
dsp
;
MPADSPContext
mpadsp
;
MPADSPContext
mpadsp
;
GetBitContext
gb
;
GetBitContext
gb
;
...
...
libavcodec/mpc7.c
View file @
3a23752c
...
@@ -139,9 +139,6 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
...
@@ -139,9 +139,6 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
}
}
vlc_initialized
=
1
;
vlc_initialized
=
1
;
avcodec_get_frame_defaults
(
&
c
->
frame
);
avctx
->
coded_frame
=
&
c
->
frame
;
return
0
;
return
0
;
}
}
...
@@ -201,6 +198,7 @@ static int get_scale_idx(GetBitContext *gb, int ref)
...
@@ -201,6 +198,7 @@ static int get_scale_idx(GetBitContext *gb, int ref)
static
int
mpc7_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
static
int
mpc7_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
{
{
AVFrame
*
frame
=
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
;
int
buf_size
;
MPCContext
*
c
=
avctx
->
priv_data
;
MPCContext
*
c
=
avctx
->
priv_data
;
...
@@ -230,8 +228,8 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
...
@@ -230,8 +228,8 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
buf_size
-=
4
;
buf_size
-=
4
;
/* get output buffer */
/* get output buffer */
c
->
frame
.
nb_samples
=
last_frame
?
c
->
lastframelen
:
MPC_FRAME_SIZE
;
frame
->
nb_samples
=
last_frame
?
c
->
lastframelen
:
MPC_FRAME_SIZE
;
if
((
ret
=
ff_get_buffer
(
avctx
,
&
c
->
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
;
}
}
...
@@ -295,7 +293,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
...
@@ -295,7 +293,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
for
(
ch
=
0
;
ch
<
2
;
ch
++
)
for
(
ch
=
0
;
ch
<
2
;
ch
++
)
idx_to_quant
(
c
,
&
gb
,
bands
[
i
].
res
[
ch
],
c
->
Q
[
ch
]
+
off
);
idx_to_quant
(
c
,
&
gb
,
bands
[
i
].
res
[
ch
],
c
->
Q
[
ch
]
+
off
);
ff_mpc_dequantize_and_synth
(
c
,
mb
,
(
int16_t
**
)
c
->
frame
.
extended_data
,
2
);
ff_mpc_dequantize_and_synth
(
c
,
mb
,
(
int16_t
**
)
frame
->
extended_data
,
2
);
bits_used
=
get_bits_count
(
&
gb
);
bits_used
=
get_bits_count
(
&
gb
);
bits_avail
=
buf_size
*
8
;
bits_avail
=
buf_size
*
8
;
...
@@ -310,7 +308,6 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
...
@@ -310,7 +308,6 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
}
}
*
got_frame_ptr
=
1
;
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
c
->
frame
;
return
avpkt
->
size
;
return
avpkt
->
size
;
}
}
...
...
libavcodec/mpc8.c
View file @
3a23752c
...
@@ -230,15 +230,13 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
...
@@ -230,15 +230,13 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
}
}
vlc_initialized
=
1
;
vlc_initialized
=
1
;
avcodec_get_frame_defaults
(
&
c
->
frame
);
avctx
->
coded_frame
=
&
c
->
frame
;
return
0
;
return
0
;
}
}
static
int
mpc8_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
static
int
mpc8_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
{
{
AVFrame
*
frame
=
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
int
buf_size
=
avpkt
->
size
;
MPCContext
*
c
=
avctx
->
priv_data
;
MPCContext
*
c
=
avctx
->
priv_data
;
...
@@ -250,8 +248,8 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
...
@@ -250,8 +248,8 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
int
last
[
2
];
int
last
[
2
];
/* get output buffer */
/* get output buffer */
c
->
frame
.
nb_samples
=
MPC_FRAME_SIZE
;
frame
->
nb_samples
=
MPC_FRAME_SIZE
;
if
((
res
=
ff_get_buffer
(
avctx
,
&
c
->
frame
))
<
0
)
{
if
((
res
=
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
res
;
return
res
;
}
}
...
@@ -407,7 +405,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
...
@@ -407,7 +405,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
}
}
ff_mpc_dequantize_and_synth
(
c
,
maxband
-
1
,
ff_mpc_dequantize_and_synth
(
c
,
maxband
-
1
,
(
int16_t
**
)
c
->
frame
.
extended_data
,
(
int16_t
**
)
frame
->
extended_data
,
avctx
->
channels
);
avctx
->
channels
);
c
->
cur_frame
++
;
c
->
cur_frame
++
;
...
@@ -419,7 +417,6 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
...
@@ -419,7 +417,6 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
c
->
cur_frame
=
0
;
c
->
cur_frame
=
0
;
*
got_frame_ptr
=
1
;
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
c
->
frame
;
return
c
->
cur_frame
?
c
->
last_bits_used
>>
3
:
buf_size
;
return
c
->
cur_frame
?
c
->
last_bits_used
>>
3
:
buf_size
;
}
}
...
...
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