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
faaebcdf
Commit
faaebcdf
authored
Jan 02, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
targa: add support for rgb555 palette
parent
e1a7af6f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
+29
-10
targa.c
libavcodec/targa.c
+29
-10
No files found.
libavcodec/targa.c
View file @
faaebcdf
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "avcodec.h"
#include "bytestream.h"
#include "targa.h"
#include "targa.h"
typedef
struct
TargaContext
{
typedef
struct
TargaContext
{
...
@@ -172,27 +173,45 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -172,27 +173,45 @@ static int decode_frame(AVCodecContext *avctx,
}
}
if
(
colors
){
if
(
colors
){
size_t
pal
_size
;
int
pal_size
,
pal_sample
_size
;
if
((
colors
+
first_clr
)
>
256
){
if
((
colors
+
first_clr
)
>
256
){
av_log
(
avctx
,
AV_LOG_ERROR
,
"Incorrect palette: %i colors with offset %i
\n
"
,
colors
,
first_clr
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Incorrect palette: %i colors with offset %i
\n
"
,
colors
,
first_clr
);
return
-
1
;
return
-
1
;
}
}
if
(
csize
!=
24
){
switch
(
csize
)
{
case
24
:
pal_sample_size
=
3
;
break
;
case
16
:
case
15
:
pal_sample_size
=
2
;
break
;
default:
av_log
(
avctx
,
AV_LOG_ERROR
,
"Palette entry size %i bits is not supported
\n
"
,
csize
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Palette entry size %i bits is not supported
\n
"
,
csize
);
return
-
1
;
return
-
1
;
}
}
pal_size
=
colors
*
((
csize
+
1
)
>>
3
)
;
pal_size
=
colors
*
pal_sample_size
;
CHECK_BUFFER_SIZE
(
buf
,
buf_end
,
pal_size
,
"color table"
);
CHECK_BUFFER_SIZE
(
buf
,
buf_end
,
pal_size
,
"color table"
);
if
(
avctx
->
pix_fmt
!=
PIX_FMT_PAL8
)
//should not occur but skip palette anyway
if
(
avctx
->
pix_fmt
!=
PIX_FMT_PAL8
)
//should not occur but skip palette anyway
buf
+=
pal_size
;
buf
+=
pal_size
;
else
{
else
{
int
r
,
g
,
b
,
t
;
int
t
;
int32_t
*
pal
=
((
int32_t
*
)
p
->
data
[
1
])
+
first_clr
;
uint32_t
*
pal
=
((
uint32_t
*
)
p
->
data
[
1
])
+
first_clr
;
for
(
t
=
0
;
t
<
colors
;
t
++
){
r
=
*
buf
++
;
switch
(
pal_sample_size
)
{
g
=
*
buf
++
;
case
3
:
b
=
*
buf
++
;
/* RGB24 */
*
pal
++
=
(
b
<<
16
)
|
(
g
<<
8
)
|
r
;
for
(
t
=
0
;
t
<
colors
;
t
++
)
*
pal
++
=
bytestream_get_le24
(
&
buf
);
break
;
case
2
:
/* RGB555 */
for
(
t
=
0
;
t
<
colors
;
t
++
)
{
uint32_t
v
=
bytestream_get_le16
(
&
buf
);
v
=
((
v
&
0x7C00
)
<<
9
)
|
((
v
&
0x03E0
)
<<
6
)
|
((
v
&
0x001F
)
<<
3
);
/* left bit replication */
v
|=
(
v
&
0xE0E0E0U
)
>>
5
;
*
pal
++
=
v
;
}
break
;
}
}
p
->
palette_has_changed
=
1
;
p
->
palette_has_changed
=
1
;
}
}
...
...
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