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
2322ced8
Commit
2322ced8
authored
Sep 12, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws_snd: decode to AV_SAMPLE_FMT_U8 instead of S16.
8-bit unsigned is the native sample format.
parent
4c5e7b27
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
23 deletions
+24
-23
ws-snd1.c
libavcodec/ws-snd1.c
+24
-23
No files found.
libavcodec/ws-snd1.c
View file @
2322ced8
...
...
@@ -37,13 +37,11 @@ static const int8_t ws_adpcm_4bit[] = {
-
9
,
-
8
,
-
6
,
-
5
,
-
4
,
-
3
,
-
2
,
-
1
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
8
};
#define CLIP8(a) if(a>127)a=127;if(a<-128)a=-128;
static
av_cold
int
ws_snd_decode_init
(
AVCodecContext
*
avctx
)
{
// WSSNDContext *c = avctx->priv_data;
avctx
->
sample_fmt
=
AV_SAMPLE_FMT_
S16
;
avctx
->
sample_fmt
=
AV_SAMPLE_FMT_
U8
;
return
0
;
}
...
...
@@ -56,15 +54,14 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
// WSSNDContext *c = avctx->priv_data;
int
in_size
,
out_size
;
int
sample
=
0
;
int
sample
=
128
;
int
i
;
shor
t
*
samples
=
data
;
uint8_
t
*
samples
=
data
;
if
(
!
buf_size
)
return
0
;
out_size
=
AV_RL16
(
&
buf
[
0
]);
*
data_size
=
out_size
*
2
;
in_size
=
AV_RL16
(
&
buf
[
2
]);
buf
+=
4
;
...
...
@@ -76,9 +73,12 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
av_log
(
avctx
,
AV_LOG_ERROR
,
"Frame data is larger than input buffer
\n
"
);
return
-
1
;
}
*
data_size
=
out_size
;
if
(
in_size
==
out_size
)
{
for
(
i
=
0
;
i
<
out_size
;
i
++
)
*
samples
++
=
(
*
buf
++
-
0x80
)
<<
8
;
*
samples
++
=
*
buf
++
;
return
buf_size
;
}
...
...
@@ -93,17 +93,17 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
for
(
count
++
;
count
>
0
;
count
--
)
{
code
=
*
buf
++
;
sample
+=
ws_adpcm_2bit
[
code
&
0x3
];
CLIP
8
(
sample
);
*
samples
++
=
sample
<<
8
;
sample
=
av_clip_uint
8
(
sample
);
*
samples
++
=
sample
;
sample
+=
ws_adpcm_2bit
[(
code
>>
2
)
&
0x3
];
CLIP
8
(
sample
);
*
samples
++
=
sample
<<
8
;
sample
=
av_clip_uint
8
(
sample
);
*
samples
++
=
sample
;
sample
+=
ws_adpcm_2bit
[(
code
>>
4
)
&
0x3
];
CLIP
8
(
sample
);
*
samples
++
=
sample
<<
8
;
sample
=
av_clip_uint
8
(
sample
);
*
samples
++
=
sample
;
sample
+=
ws_adpcm_2bit
[(
code
>>
6
)
&
0x3
];
CLIP
8
(
sample
);
*
samples
++
=
sample
<<
8
;
sample
=
av_clip_uint
8
(
sample
);
*
samples
++
=
sample
;
out_size
-=
4
;
}
break
;
...
...
@@ -111,11 +111,11 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
for
(
count
++
;
count
>
0
;
count
--
)
{
code
=
*
buf
++
;
sample
+=
ws_adpcm_4bit
[
code
&
0xF
];
CLIP
8
(
sample
);
*
samples
++
=
sample
<<
8
;
sample
=
av_clip_uint
8
(
sample
);
*
samples
++
=
sample
;
sample
+=
ws_adpcm_4bit
[
code
>>
4
];
CLIP
8
(
sample
);
*
samples
++
=
sample
<<
8
;
sample
=
av_clip_uint
8
(
sample
);
*
samples
++
=
sample
;
out_size
-=
2
;
}
break
;
...
...
@@ -125,19 +125,20 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
t
=
count
;
t
<<=
3
;
sample
+=
t
>>
3
;
*
samples
++
=
sample
<<
8
;
sample
=
av_clip_uint8
(
sample
);
*
samples
++
=
sample
;
out_size
--
;
}
else
{
/* copy */
for
(
count
++
;
count
>
0
;
count
--
)
{
*
samples
++
=
(
*
buf
++
-
0x80
)
<<
8
;
*
samples
++
=
*
buf
++
;
out_size
--
;
}
sample
=
buf
[
-
1
]
-
0x80
;
sample
=
buf
[
-
1
];
}
break
;
default:
/* run */
for
(
count
++
;
count
>
0
;
count
--
)
{
*
samples
++
=
sample
<<
8
;
*
samples
++
=
sample
;
out_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