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
e57daa87
Commit
e57daa87
authored
Dec 23, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adpcm: decode directly to the user-provided AVFrame
parent
55d2e12a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
adpcm.c
libavcodec/adpcm.c
+9
-13
No files found.
libavcodec/adpcm.c
View file @
e57daa87
...
@@ -85,7 +85,6 @@ static const int swf_index_tables[4][16] = {
...
@@ -85,7 +85,6 @@ static const int swf_index_tables[4][16] = {
/* end of tables */
/* end of tables */
typedef
struct
ADPCMDecodeContext
{
typedef
struct
ADPCMDecodeContext
{
AVFrame
frame
;
ADPCMChannelStatus
status
[
6
];
ADPCMChannelStatus
status
[
6
];
int
vqa_version
;
/**< VQA version. Used for ADPCM_IMA_WS */
int
vqa_version
;
/**< VQA version. Used for ADPCM_IMA_WS */
}
ADPCMDecodeContext
;
}
ADPCMDecodeContext
;
...
@@ -156,9 +155,6 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
...
@@ -156,9 +155,6 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
avctx
->
sample_fmt
=
AV_SAMPLE_FMT_S16
;
avctx
->
sample_fmt
=
AV_SAMPLE_FMT_S16
;
}
}
avcodec_get_frame_defaults
(
&
c
->
frame
);
avctx
->
coded_frame
=
&
c
->
frame
;
return
0
;
return
0
;
}
}
...
@@ -591,6 +587,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
...
@@ -591,6 +587,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
static
int
adpcm_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
static
int
adpcm_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
;
ADPCMDecodeContext
*
c
=
avctx
->
priv_data
;
ADPCMDecodeContext
*
c
=
avctx
->
priv_data
;
...
@@ -611,20 +608,20 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -611,20 +608,20 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
}
}
/* get output buffer */
/* get output buffer */
c
->
frame
.
nb_samples
=
nb_samples
;
frame
->
nb_samples
=
nb_samples
;
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
;
}
}
samples
=
(
short
*
)
c
->
frame
.
data
[
0
];
samples
=
(
short
*
)
frame
->
data
[
0
];
samples_p
=
(
int16_t
**
)
c
->
frame
.
extended_data
;
samples_p
=
(
int16_t
**
)
frame
->
extended_data
;
/* use coded_samples when applicable */
/* use coded_samples when applicable */
/* it is always <= nb_samples, so the output buffer will be large enough */
/* it is always <= nb_samples, so the output buffer will be large enough */
if
(
coded_samples
)
{
if
(
coded_samples
)
{
if
(
coded_samples
!=
nb_samples
)
if
(
coded_samples
!=
nb_samples
)
av_log
(
avctx
,
AV_LOG_WARNING
,
"mismatch in coded sample count
\n
"
);
av_log
(
avctx
,
AV_LOG_WARNING
,
"mismatch in coded sample count
\n
"
);
c
->
frame
.
nb_samples
=
nb_samples
=
coded_samples
;
frame
->
nb_samples
=
nb_samples
=
coded_samples
;
}
}
st
=
avctx
->
channels
==
2
?
1
:
0
;
st
=
avctx
->
channels
==
2
?
1
:
0
;
...
@@ -710,7 +707,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -710,7 +707,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
}
}
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
{
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
{
samples
=
(
int16_t
*
)
c
->
frame
.
data
[
i
];
samples
=
(
int16_t
*
)
frame
->
data
[
i
];
cs
=
&
c
->
status
[
i
];
cs
=
&
c
->
status
[
i
];
for
(
n
=
nb_samples
>>
1
;
n
>
0
;
n
--
)
{
for
(
n
=
nb_samples
>>
1
;
n
>
0
;
n
--
)
{
int
v
=
bytestream2_get_byteu
(
&
gb
);
int
v
=
bytestream2_get_byteu
(
&
gb
);
...
@@ -1097,7 +1094,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1097,7 +1094,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
}
}
}
}
c
->
frame
.
nb_samples
=
count
*
28
;
frame
->
nb_samples
=
count
*
28
;
bytestream2_seek
(
&
gb
,
0
,
SEEK_END
);
bytestream2_seek
(
&
gb
,
0
,
SEEK_END
);
break
;
break
;
}
}
...
@@ -1278,8 +1275,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1278,8 +1275,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
return
-
1
;
return
-
1
;
}
}
*
got_frame_ptr
=
1
;
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
c
->
frame
;
return
bytestream2_tell
(
&
gb
);
return
bytestream2_tell
(
&
gb
);
}
}
...
...
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