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
b1835732
Commit
b1835732
authored
Mar 19, 2012
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LucasArts SMUSH VIMA audio decoder
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
5a90e55e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
242 additions
and
1 deletion
+242
-1
general.texi
doc/general.texi
+2
-0
Makefile
libavcodec/Makefile
+1
-0
allcodecs.c
libavcodec/allcodecs.c
+1
-0
avcodec.h
libavcodec/avcodec.h
+1
-0
version.h
libavcodec/version.h
+1
-1
vima.c
libavcodec/vima.c
+236
-0
No files found.
doc/general.texi
View file @
b1835732
...
...
@@ -830,6 +830,8 @@ following image formats are supported:
@item TrueHD @tab @tab X
@tab Used in HD-DVD and Blu-Ray discs.
@item TwinVQ (VQF flavor) @tab @tab X
@item VIMA
@tab Used in LucasArts SMUSH animations.
@item Vorbis @tab E @tab X
@tab A native but very primitive encoder exists.
@item WavPack @tab @tab X
...
...
libavcodec/Makefile
View file @
b1835732
...
...
@@ -612,6 +612,7 @@ OBJS-$(CONFIG_ADPCM_THP_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_XA_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER)
+=
adpcmenc.o
adpcm_data.o
OBJS-$(CONFIG_VIMA_DECODER)
+=
vima.o
adpcm_data.o
# libavformat dependencies
OBJS-$(CONFIG_ADTS_MUXER)
+=
mpeg4audio.o
...
...
libavcodec/allcodecs.c
View file @
b1835732
...
...
@@ -395,6 +395,7 @@ void avcodec_register_all(void)
REGISTER_DECODER
(
ADPCM_THP
,
adpcm_thp
);
REGISTER_DECODER
(
ADPCM_XA
,
adpcm_xa
);
REGISTER_ENCDEC
(
ADPCM_YAMAHA
,
adpcm_yamaha
);
REGISTER_DECODER
(
VIMA
,
vima
);
/* subtitles */
REGISTER_ENCDEC
(
ASS
,
ass
);
...
...
libavcodec/avcodec.h
View file @
b1835732
...
...
@@ -332,6 +332,7 @@ enum CodecID {
CODEC_ID_ADPCM_IMA_ISS
,
CODEC_ID_ADPCM_G722
,
CODEC_ID_ADPCM_IMA_APC
,
CODEC_ID_VIMA
=
MKBETAG
(
'V'
,
'I'
,
'M'
,
'A'
),
/* AMR */
CODEC_ID_AMR_NB
=
0x12000
,
...
...
libavcodec/version.h
View file @
b1835732
...
...
@@ -27,7 +27,7 @@
*/
#define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MINOR 2
7
#define LIBAVCODEC_VERSION_MINOR 2
8
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
...
...
libavcodec/vima.c
0 → 100644
View file @
b1835732
/*
* LucasArt VIMA decoder
* Copyright (c) 2012 Paul B Mahol
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/audioconvert.h"
#include "avcodec.h"
#include "get_bits.h"
#include "adpcm_data.h"
typedef
struct
{
AVFrame
frame
;
uint16_t
predict_table
[
5786
*
2
];
}
VimaContext
;
static
const
uint8_t
size_table
[]
=
{
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
};
static
const
int8_t
index_table1
[]
=
{
-
1
,
4
,
-
1
,
4
};
static
const
int8_t
index_table2
[]
=
{
-
1
,
-
1
,
2
,
6
,
-
1
,
-
1
,
2
,
6
};
static
const
int8_t
index_table3
[]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
1
,
2
,
4
,
6
,
-
1
,
-
1
,
-
1
,
-
1
,
1
,
2
,
4
,
6
};
static
const
int8_t
index_table4
[]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
1
,
1
,
1
,
2
,
2
,
4
,
5
,
6
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
1
,
1
,
1
,
2
,
2
,
4
,
5
,
6
};
static
const
int8_t
index_table5
[]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
1
,
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
4
,
4
,
4
,
5
,
5
,
6
,
6
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
1
,
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
4
,
4
,
4
,
5
,
5
,
6
,
6
};
static
const
int8_t
index_table6
[]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
4
,
4
,
4
,
4
,
4
,
4
,
5
,
5
,
5
,
5
,
6
,
6
,
6
,
6
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
4
,
4
,
4
,
4
,
4
,
4
,
5
,
5
,
5
,
5
,
6
,
6
,
6
,
6
};
static
const
int8_t
*
const
step_index_tables
[]
=
{
index_table1
,
index_table2
,
index_table3
,
index_table4
,
index_table5
,
index_table6
};
static
av_cold
int
decode_init
(
AVCodecContext
*
avctx
)
{
VimaContext
*
vima
=
avctx
->
priv_data
;
int
start_pos
;
for
(
start_pos
=
0
;
start_pos
<
64
;
start_pos
++
)
{
unsigned
int
dest_pos
,
table_pos
;
for
(
table_pos
=
0
,
dest_pos
=
start_pos
;
table_pos
<
FF_ARRAY_ELEMS
(
ff_adpcm_step_table
);
table_pos
++
,
dest_pos
+=
64
)
{
int
put
=
0
,
count
,
table_value
;
table_value
=
ff_adpcm_step_table
[
table_pos
];
for
(
count
=
32
;
count
!=
0
;
count
>>=
1
)
{
if
(
start_pos
&
count
)
put
+=
table_value
;
table_value
>>=
1
;
}
vima
->
predict_table
[
dest_pos
]
=
put
;
}
}
avcodec_get_frame_defaults
(
&
vima
->
frame
);
avctx
->
coded_frame
=
&
vima
->
frame
;
avctx
->
sample_fmt
=
AV_SAMPLE_FMT_S16
;
return
0
;
}
static
int
decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
pkt
)
{
GetBitContext
gb
;
VimaContext
*
vima
=
avctx
->
priv_data
;
int16_t
pcm_data
[
2
];
uint32_t
samples
;
int8_t
channel_hint
[
2
];
int
ret
,
chan
,
channels
=
1
;
init_get_bits
(
&
gb
,
pkt
->
data
,
pkt
->
size
*
8
);
if
(
pkt
->
size
<
13
)
return
AVERROR_INVALIDDATA
;
samples
=
get_bits_long
(
&
gb
,
32
);
if
(
samples
==
0xffffffff
)
{
skip_bits_long
(
&
gb
,
32
);
samples
=
get_bits_long
(
&
gb
,
32
);
}
if
(
samples
>
pkt
->
size
*
2
)
return
AVERROR_INVALIDDATA
;
channel_hint
[
0
]
=
get_sbits
(
&
gb
,
8
);
if
(
channel_hint
[
0
]
&
0x80
)
{
channel_hint
[
0
]
=
~
channel_hint
[
0
];
channels
=
2
;
}
avctx
->
channels
=
channels
;
avctx
->
channel_layout
=
(
channels
==
2
)
?
AV_CH_LAYOUT_STEREO
:
AV_CH_LAYOUT_MONO
;
pcm_data
[
0
]
=
get_sbits
(
&
gb
,
16
);
if
(
channels
>
1
)
{
channel_hint
[
1
]
=
get_sbits
(
&
gb
,
8
);
pcm_data
[
1
]
=
get_sbits
(
&
gb
,
16
);
}
vima
->
frame
.
nb_samples
=
samples
;
if
((
ret
=
avctx
->
get_buffer
(
avctx
,
&
vima
->
frame
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
ret
;
}
for
(
chan
=
0
;
chan
<
channels
;
chan
++
)
{
uint16_t
*
dest
=
(
uint16_t
*
)
vima
->
frame
.
data
[
0
]
+
chan
;
int
step_index
=
channel_hint
[
chan
];
int
output
=
pcm_data
[
chan
];
int
sample
;
for
(
sample
=
0
;
sample
<
samples
;
sample
++
)
{
int
lookup_size
,
lookup
,
highbit
,
lowbits
;
step_index
=
av_clip
(
step_index
,
0
,
88
);
lookup_size
=
size_table
[
step_index
];
lookup
=
get_bits
(
&
gb
,
lookup_size
);
highbit
=
1
<<
(
lookup_size
-
1
);
lowbits
=
highbit
-
1
;
if
(
lookup
&
highbit
)
lookup
^=
highbit
;
else
highbit
=
0
;
if
(
lookup
==
lowbits
)
{
output
=
get_sbits
(
&
gb
,
16
);
}
else
{
int
predict_index
,
diff
;
predict_index
=
(
lookup
<<
(
7
-
lookup_size
))
|
(
step_index
<<
6
);
predict_index
=
av_clip
(
predict_index
,
0
,
5785
);
diff
=
vima
->
predict_table
[
predict_index
];
if
(
lookup
)
diff
+=
ff_adpcm_step_table
[
step_index
]
>>
(
lookup_size
-
1
);
if
(
highbit
)
diff
=
-
diff
;
output
=
av_clip_int16
(
output
+
diff
);
}
*
dest
=
output
;
dest
+=
channels
;
step_index
+=
step_index_tables
[
lookup_size
-
2
][
lookup
];
}
}
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
vima
->
frame
;
return
pkt
->
size
;
}
AVCodec
ff_vima_decoder
=
{
.
name
=
"vima"
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
id
=
CODEC_ID_VIMA
,
.
priv_data_size
=
sizeof
(
VimaContext
),
.
init
=
decode_init
,
.
decode
=
decode_frame
,
.
capabilities
=
CODEC_CAP_DR1
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"LucasArts VIMA audio"
),
};
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