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
3ac718d6
Commit
3ac718d6
authored
Sep 01, 2012
by
Peter Ross
Committed by
Michael Niedermayer
Sep 01, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ansi: support 256-colors
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
95b9e56b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
6 deletions
+29
-6
ansi.c
libavcodec/ansi.c
+26
-3
ansi
tests/ref/fate/ansi
+3
-3
No files found.
libavcodec/ansi.c
View file @
3ac718d6
...
...
@@ -89,6 +89,21 @@ static av_cold int decode_init(AVCodecContext *avctx)
return
0
;
}
static
void
set_palette
(
uint32_t
*
pal
)
{
int
r
,
g
,
b
;
memcpy
(
pal
,
ff_cga_palette
,
16
*
4
);
pal
+=
16
;
#define COLOR(x) ((x) * 40 + 55)
for
(
r
=
0
;
r
<
6
;
r
++
)
for
(
g
=
0
;
g
<
6
;
g
++
)
for
(
b
=
0
;
b
<
6
;
b
++
)
*
pal
++
=
0xFF000000
|
(
COLOR
(
r
)
<<
16
)
|
(
COLOR
(
g
)
<<
8
)
|
COLOR
(
b
);
#define GRAY(x) ((x) * 10 + 8)
for
(
g
=
0
;
g
<
24
;
g
++
)
*
pal
++
=
0xFF000000
|
(
GRAY
(
g
)
<<
16
)
|
(
GRAY
(
g
)
<<
8
)
|
GRAY
(
g
);
}
static
void
hscroll
(
AVCodecContext
*
avctx
)
{
AnsiContext
*
s
=
avctx
->
priv_data
;
...
...
@@ -232,7 +247,7 @@ static int execute_code(AVCodecContext * avctx, int c)
}
s
->
frame
.
pict_type
=
AV_PICTURE_TYPE_I
;
s
->
frame
.
palette_has_changed
=
1
;
memcpy
(
s
->
frame
.
data
[
1
],
ff_cga_palette
,
16
*
4
);
set_palette
((
uint32_t
*
)
s
->
frame
.
data
[
1
]
);
erase_screen
(
avctx
);
}
else
if
(
c
==
'l'
)
{
erase_screen
(
avctx
);
...
...
@@ -280,12 +295,20 @@ static int execute_code(AVCodecContext * avctx, int c)
s
->
bg
=
DEFAULT_BG_COLOR
;
}
else
if
(
m
==
1
||
m
==
2
||
m
==
4
||
m
==
5
||
m
==
7
||
m
==
8
)
{
s
->
attributes
|=
1
<<
(
m
-
1
);
}
else
if
(
m
>=
30
&&
m
<=
3
8
)
{
}
else
if
(
m
>=
30
&&
m
<=
3
7
)
{
s
->
fg
=
ansi_to_cga
[
m
-
30
];
}
else
if
(
m
==
38
&&
i
+
2
<
s
->
nb_args
&&
s
->
args
[
i
+
1
]
==
5
&&
s
->
args
[
i
+
2
]
<
256
)
{
int
index
=
s
->
args
[
i
+
2
];
s
->
fg
=
index
<
16
?
ansi_to_cga
[
index
]
:
index
;
i
+=
2
;
}
else
if
(
m
==
39
)
{
s
->
fg
=
ansi_to_cga
[
DEFAULT_FG_COLOR
];
}
else
if
(
m
>=
40
&&
m
<=
47
)
{
s
->
bg
=
ansi_to_cga
[
m
-
40
];
}
else
if
(
m
==
48
&&
i
+
2
<
s
->
nb_args
&&
s
->
args
[
i
+
1
]
==
5
&&
s
->
args
[
i
+
2
]
<
256
)
{
int
index
=
s
->
args
[
i
+
2
];
s
->
bg
=
index
<
16
?
ansi_to_cga
[
index
]
:
index
;
i
+=
2
;
}
else
if
(
m
==
49
)
{
s
->
fg
=
ansi_to_cga
[
DEFAULT_BG_COLOR
];
}
else
{
...
...
@@ -329,7 +352,7 @@ static int decode_frame(AVCodecContext *avctx,
}
s
->
frame
.
pict_type
=
AV_PICTURE_TYPE_I
;
s
->
frame
.
palette_has_changed
=
1
;
memcpy
(
s
->
frame
.
data
[
1
],
ff_cga_palette
,
16
*
4
);
set_palette
((
uint32_t
*
)
s
->
frame
.
data
[
1
]
);
while
(
buf
<
buf_end
)
{
switch
(
s
->
state
)
{
...
...
tests/ref/fate/ansi
View file @
3ac718d6
#tb 0: 1/25
0, 0, 0, 1, 768000, 0x
3032d0de
0, 1, 1, 1, 768000, 0x
c3be5922
0, 2, 2, 1, 768000, 0x
f530c47
6
0, 0, 0, 1, 768000, 0x
c4865718
0, 1, 1, 1, 768000, 0x
2c7de258
0, 2, 2, 1, 768000, 0x
0d6b8dc
6
0, 3, 3, 1, 768000, 0x11c1fb8e
0, 4, 4, 1, 768000, 0x72d12da9
0, 5, 5, 1, 768000, 0x39c7a70d
...
...
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