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
Hide 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,
...
@@ -499,70 +499,51 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
switch
(
avctx
->
codec
->
id
)
{
switch
(
avctx
->
codec
->
id
)
{
case
AV_CODEC_ID_ADPCM_IMA_WAV
:
case
AV_CODEC_ID_ADPCM_IMA_WAV
:
n
=
frame
->
nb_samples
/
8
;
{
c
->
status
[
0
].
prev_sample
=
samples
[
0
];
int
blocks
,
j
,
ch
;
/* c->status[0].step_index = 0;
XXX: not sure how to init the state machine */
blocks
=
(
frame
->
nb_samples
-
1
)
/
8
;
bytestream_put_le16
(
&
dst
,
c
->
status
[
0
].
prev_sample
);
*
dst
++
=
c
->
status
[
0
].
step_index
;
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
{
*
dst
++
=
0
;
/* unknown */
ADPCMChannelStatus
*
status
=
&
c
->
status
[
ch
];
samples
++
;
status
->
prev_sample
=
samples
[
ch
];
if
(
avctx
->
channels
==
2
)
{
/* status->step_index = 0;
c
->
status
[
1
].
prev_sample
=
samples
[
0
];
XXX: not sure how to init the state machine */
/* c->status[1].step_index = 0; */
bytestream_put_le16
(
&
dst
,
status
->
prev_sample
);
bytestream_put_le16
(
&
dst
,
c
->
status
[
1
].
prev_sample
);
*
dst
++
=
status
->
step_index
;
*
dst
++
=
c
->
status
[
1
].
step_index
;
*
dst
++
=
0
;
/* unknown */
*
dst
++
=
0
;
samples
++
;
}
}
/* stereo: 4 bytes (8 samples) for left,
/* stereo: 4 bytes (8 samples) for left, 4 bytes for right */
4 bytes for right, 4 bytes left, ... */
if
(
avctx
->
trellis
>
0
)
{
if
(
avctx
->
trellis
>
0
)
{
FF_ALLOC_OR_GOTO
(
avctx
,
buf
,
2
*
n
*
8
,
error
);
FF_ALLOC_OR_GOTO
(
avctx
,
buf
,
avctx
->
channels
*
blocks
*
8
,
error
);
adpcm_compress_trellis
(
avctx
,
samples
,
buf
,
&
c
->
status
[
0
],
n
*
8
);
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
{
if
(
avctx
->
channels
==
2
)
adpcm_compress_trellis
(
avctx
,
&
samples
[
avctx
->
channels
+
ch
],
adpcm_compress_trellis
(
avctx
,
samples
+
1
,
buf
+
n
*
8
,
buf
+
ch
*
blocks
*
8
,
&
c
->
status
[
ch
],
&
c
->
status
[
1
],
n
*
8
);
blocks
*
8
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
}
*
dst
++
=
buf
[
8
*
i
+
0
]
|
(
buf
[
8
*
i
+
1
]
<<
4
);
for
(
i
=
0
;
i
<
blocks
;
i
++
)
{
*
dst
++
=
buf
[
8
*
i
+
2
]
|
(
buf
[
8
*
i
+
3
]
<<
4
);
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
{
*
dst
++
=
buf
[
8
*
i
+
4
]
|
(
buf
[
8
*
i
+
5
]
<<
4
);
uint8_t
*
buf1
=
buf
+
ch
*
blocks
*
8
+
i
*
8
;
*
dst
++
=
buf
[
8
*
i
+
6
]
|
(
buf
[
8
*
i
+
7
]
<<
4
);
for
(
j
=
0
;
j
<
8
;
j
+=
2
)
if
(
avctx
->
channels
==
2
)
{
*
dst
++
=
buf1
[
j
]
|
(
buf1
[
j
+
1
]
<<
4
);
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
);
}
}
}
}
av_free
(
buf
);
av_free
(
buf
);
}
else
{
}
else
{
for
(;
n
>
0
;
n
--
)
{
for
(
i
=
0
;
i
<
blocks
;
i
++
)
{
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
0
]);
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
{
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
])
<<
4
;
ADPCMChannelStatus
*
status
=
&
c
->
status
[
ch
];
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
*
2
]);
const
int16_t
*
smp
=
&
samples
[
avctx
->
channels
*
(
1
+
i
*
8
)
+
ch
];
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
*
3
])
<<
4
;
for
(
j
=
0
;
j
<
8
;
j
+=
2
)
{
*
dst
=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
*
4
]);
*
dst
++
=
adpcm_ima_compress_sample
(
status
,
smp
[
avctx
->
channels
*
j
])
|
*
dst
++
|=
adpcm_ima_compress_sample
(
&
c
->
status
[
0
],
samples
[
avctx
->
channels
*
5
])
<<
4
;
(
adpcm_ima_compress_sample
(
status
,
smp
[
avctx
->
channels
*
(
j
+
1
)])
<<
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
;
}
}
}
}
break
;
break
;
}
case
AV_CODEC_ID_ADPCM_IMA_QT
:
case
AV_CODEC_ID_ADPCM_IMA_QT
:
{
{
int
ch
,
i
;
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