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
1e35574b
Commit
1e35574b
authored
Aug 25, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adpcm_ima_wav: simplify encoding
parent
cfc0a80a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
53 deletions
+34
-53
adpcmenc.c
libavcodec/adpcmenc.c
+34
-53
No files found.
libavcodec/adpcmenc.c
View file @
1e35574b
...
...
@@ -499,70 +499,51 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
switch
(
avctx
->
codec
->
id
)
{
case
AV_CODEC_ID_ADPCM_IMA_WAV
:
n
=
frame
->
nb_samples
/
8
;
c
->
status
[
0
].
prev_sample
=
samples
[
0
];
/* c->status[0].step_index = 0;
{
int
blocks
,
j
,
ch
;
blocks
=
(
frame
->
nb_samples
-
1
)
/
8
;
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
{
ADPCMChannelStatus
*
status
=
&
c
->
status
[
ch
];
status
->
prev_sample
=
samples
[
ch
];
/* status->step_index = 0;
XXX: not sure how to init the state machine */
bytestream_put_le16
(
&
dst
,
c
->
status
[
0
].
prev_sample
);
*
dst
++
=
c
->
status
[
0
].
step_index
;
bytestream_put_le16
(
&
dst
,
status
->
prev_sample
);
*
dst
++
=
status
->
step_index
;
*
dst
++
=
0
;
/* unknown */
samples
++
;
if
(
avctx
->
channels
==
2
)
{
c
->
status
[
1
].
prev_sample
=
samples
[
0
];
/* c->status[1].step_index = 0; */
bytestream_put_le16
(
&
dst
,
c
->
status
[
1
].
prev_sample
);
*
dst
++
=
c
->
status
[
1
].
step_index
;
*
dst
++
=
0
;
samples
++
;
}
/* stereo: 4 bytes (8 samples) for left,
4 bytes for right, 4 bytes left, ... */
}
/* stereo: 4 bytes (8 samples) for left, 4 bytes for right */
if
(
avctx
->
trellis
>
0
)
{
FF_ALLOC_OR_GOTO
(
avctx
,
buf
,
2
*
n
*
8
,
error
);
adpcm_compress_trellis
(
avctx
,
samples
,
buf
,
&
c
->
status
[
0
],
n
*
8
);
if
(
avctx
->
channels
==
2
)
adpcm_compress_trellis
(
avctx
,
samples
+
1
,
buf
+
n
*
8
,
&
c
->
status
[
1
],
n
*
8
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
*
dst
++
=
buf
[
8
*
i
+
0
]
|
(
buf
[
8
*
i
+
1
]
<<
4
);
*
dst
++
=
buf
[
8
*
i
+
2
]
|
(
buf
[
8
*
i
+
3
]
<<
4
);
*
dst
++
=
buf
[
8
*
i
+
4
]
|
(
buf
[
8
*
i
+
5
]
<<
4
);
*
dst
++
=
buf
[
8
*
i
+
6
]
|
(
buf
[
8
*
i
+
7
]
<<
4
);
if
(
avctx
->
channels
==
2
)
{
uint8_t
*
buf1
=
buf
+
n
*
8
;
*
dst
++
=
buf1
[
8
*
i
+
0
]
|
(
buf1
[
8
*
i
+
1
]
<<
4
);
*
dst
++
=
buf1
[
8
*
i
+
2
]
|
(
buf1
[
8
*
i
+
3
]
<<
4
);
*
dst
++
=
buf1
[
8
*
i
+
4
]
|
(
buf1
[
8
*
i
+
5
]
<<
4
);
*
dst
++
=
buf1
[
8
*
i
+
6
]
|
(
buf1
[
8
*
i
+
7
]
<<
4
);
FF_ALLOC_OR_GOTO
(
avctx
,
buf
,
avctx
->
channels
*
blocks
*
8
,
error
);
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
{
adpcm_compress_trellis
(
avctx
,
&
samples
[
avctx
->
channels
+
ch
],
buf
+
ch
*
blocks
*
8
,
&
c
->
status
[
ch
],
blocks
*
8
);
}
for
(
i
=
0
;
i
<
blocks
;
i
++
)
{
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
{
uint8_t
*
buf1
=
buf
+
ch
*
blocks
*
8
+
i
*
8
;
for
(
j
=
0
;
j
<
8
;
j
+=
2
)
*
dst
++
=
buf1
[
j
]
|
(
buf1
[
j
+
1
]
<<
4
);
}
}
av_free
(
buf
);
}
else
{
for
(;
n
>
0
;
n
--
)
{
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
0
]);
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
])
<<
4
;
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
*
2
]);
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
*
3
])
<<
4
;
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
*
4
]);
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
*
5
])
<<
4
;
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
*
6
]);
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
*
7
])
<<
4
;
/* right channel */
if
(
avctx
->
channels
==
2
)
{
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
1
],
samples
[
1
]);
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
1
],
samples
[
3
])
<<
4
;
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
1
],
samples
[
5
]);
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
1
],
samples
[
7
])
<<
4
;
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
1
],
samples
[
9
]);
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
1
],
samples
[
11
])
<<
4
;
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
1
],
samples
[
13
]);
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
1
],
samples
[
15
])
<<
4
;
}
samples
+=
8
*
avctx
->
channels
;
for
(
i
=
0
;
i
<
blocks
;
i
++
)
{
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
{
ADPCMChannelStatus
*
status
=
&
c
->
status
[
ch
];
const
int16_t
*
smp
=
&
samples
[
avctx
->
channels
*
(
1
+
i
*
8
)
+
ch
];
for
(
j
=
0
;
j
<
8
;
j
+=
2
)
{
*
dst
++
=
adpcm_ima_compress_sample
(
status
,
smp
[
avctx
->
channels
*
j
])
|
(
adpcm_ima_compress_sample
(
status
,
smp
[
avctx
->
channels
*
(
j
+
1
)])
<<
4
);
}
}
}
}
break
;
}
case
AV_CODEC_ID_ADPCM_IMA_QT
:
{
int
ch
,
i
;
...
...
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