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
e2570297
Commit
e2570297
authored
Nov 13, 2006
by
Kostya Shishkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
8-bit images support for TIFF
Originally committed as revision 7005 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
380fd08f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
15 deletions
+69
-15
tiff.c
libavcodec/tiff.c
+69
-15
No files found.
libavcodec/tiff.c
View file @
e2570297
...
@@ -37,7 +37,8 @@ enum TiffTags{
...
@@ -37,7 +37,8 @@ enum TiffTags{
TIFF_STRIP_SIZE
,
TIFF_STRIP_SIZE
,
TIFF_XPOS
=
0x11E
,
TIFF_XPOS
=
0x11E
,
TIFF_YPOS
=
0x11F
,
TIFF_YPOS
=
0x11F
,
TIFF_PREDICTOR
=
0x13D
TIFF_PREDICTOR
=
0x13D
,
TIFF_PAL
=
0x140
};
};
enum
TiffCompr
{
enum
TiffCompr
{
...
@@ -69,6 +70,7 @@ typedef struct TiffContext {
...
@@ -69,6 +70,7 @@ typedef struct TiffContext {
unsigned
int
bpp
;
unsigned
int
bpp
;
int
le
;
int
le
;
int
compr
;
int
compr
;
int
invert
;
int
strips
,
rps
;
int
strips
,
rps
;
int
sot
;
int
sot
;
...
@@ -187,6 +189,7 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
...
@@ -187,6 +189,7 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
int
tag
,
type
,
count
,
off
,
value
=
0
;
int
tag
,
type
,
count
,
off
,
value
=
0
;
uint8_t
*
src
,
*
dst
;
uint8_t
*
src
,
*
dst
;
int
i
,
j
,
ssize
,
soff
,
stride
;
int
i
,
j
,
ssize
,
soff
,
stride
;
int
*
pal
,
*
rp
,
*
gp
,
*
bp
;
tag
=
tget_short
(
&
buf
,
s
->
le
);
tag
=
tget_short
(
&
buf
,
s
->
le
);
type
=
tget_short
(
&
buf
,
s
->
le
);
type
=
tget_short
(
&
buf
,
s
->
le
);
...
@@ -224,18 +227,6 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
...
@@ -224,18 +227,6 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
break
;
break
;
case
TIFF_HEIGHT
:
case
TIFF_HEIGHT
:
s
->
height
=
value
;
s
->
height
=
value
;
s
->
avctx
->
pix_fmt
=
PIX_FMT_RGB24
;
if
(
s
->
width
!=
s
->
avctx
->
width
||
s
->
height
!=
s
->
avctx
->
height
){
if
(
avcodec_check_dimensions
(
s
->
avctx
,
s
->
width
,
s
->
height
))
return
-
1
;
avcodec_set_dimensions
(
s
->
avctx
,
s
->
width
,
s
->
height
);
}
if
(
s
->
picture
.
data
[
0
])
s
->
avctx
->
release_buffer
(
s
->
avctx
,
&
s
->
picture
);
if
(
s
->
avctx
->
get_buffer
(
s
->
avctx
,
&
s
->
picture
)
<
0
){
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
-
1
;
}
break
;
break
;
case
TIFF_BPP
:
case
TIFF_BPP
:
if
(
count
==
1
)
s
->
bpp
=
value
;
if
(
count
==
1
)
s
->
bpp
=
value
;
...
@@ -253,10 +244,34 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
...
@@ -253,10 +244,34 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
s
->
bpp
=
-
1
;
s
->
bpp
=
-
1
;
}
}
}
}
if
(
s
->
bpp
!=
24
){
switch
(
s
->
bpp
){
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Only RGB24 is supported
\n
"
);
case
8
:
s
->
avctx
->
pix_fmt
=
PIX_FMT_PAL8
;
break
;
case
24
:
s
->
avctx
->
pix_fmt
=
PIX_FMT_RGB24
;
break
;
default
:
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Only RGB24 is supported (this bpp=%i)
\n
"
,
s
->
bpp
);
return
-
1
;
}
if
(
s
->
width
!=
s
->
avctx
->
width
||
s
->
height
!=
s
->
avctx
->
height
){
if
(
avcodec_check_dimensions
(
s
->
avctx
,
s
->
width
,
s
->
height
))
return
-
1
;
avcodec_set_dimensions
(
s
->
avctx
,
s
->
width
,
s
->
height
);
}
if
(
s
->
picture
.
data
[
0
])
s
->
avctx
->
release_buffer
(
s
->
avctx
,
&
s
->
picture
);
if
(
s
->
avctx
->
get_buffer
(
s
->
avctx
,
&
s
->
picture
)
<
0
){
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
-
1
;
return
-
1
;
}
}
if
(
s
->
bpp
==
8
){
/* make default grayscale pal */
pal
=
s
->
picture
.
data
[
1
];
for
(
i
=
0
;
i
<
256
;
i
++
)
pal
[
i
]
=
i
*
0x010101
;
}
break
;
break
;
case
TIFF_COMPR
:
case
TIFF_COMPR
:
s
->
compr
=
value
;
s
->
compr
=
value
;
...
@@ -364,6 +379,33 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
...
@@ -364,6 +379,33 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
}
}
}
}
break
;
break
;
case
TIFF_INVERT
:
switch
(
value
){
case
0
:
s
->
invert
=
1
;
break
;
case
1
:
s
->
invert
=
0
;
break
;
}
break
;
case
TIFF_PAL
:
if
(
s
->
avctx
->
pix_fmt
!=
PIX_FMT_PAL8
){
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Palette met but this is not palettized format
\n
"
);
return
-
1
;
}
pal
=
s
->
picture
.
data
[
1
];
off
=
(
type
==
TIFF_SHORT
)
?
2
:
1
;
rp
=
buf
;
gp
=
buf
+
count
/
3
*
off
;
bp
=
buf
+
count
/
3
*
off
*
2
;
off
=
(
type
==
TIFF_SHORT
)
?
8
:
0
;
for
(
i
=
0
;
i
<
count
/
3
;
i
++
){
j
=
(
tget
(
&
rp
,
type
,
s
->
le
)
>>
off
)
<<
16
;
j
|=
(
tget
(
&
gp
,
type
,
s
->
le
)
>>
off
)
<<
8
;
j
|=
tget
(
&
bp
,
type
,
s
->
le
)
>>
off
;
pal
[
i
]
=
j
;
}
}
}
return
0
;
return
0
;
}
}
...
@@ -388,6 +430,7 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -388,6 +430,7 @@ static int decode_frame(AVCodecContext *avctx,
return
-
1
;
return
-
1
;
}
}
s
->
le
=
le
;
s
->
le
=
le
;
s
->
invert
=
0
;
// As TIFF 6.0 specification puts it "An arbitrary but carefully chosen number
// As TIFF 6.0 specification puts it "An arbitrary but carefully chosen number
// that further identifies the file as a TIFF file"
// that further identifies the file as a TIFF file"
if
(
tget_short
(
&
buf
,
le
)
!=
42
){
if
(
tget_short
(
&
buf
,
le
)
!=
42
){
...
@@ -408,6 +451,17 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -408,6 +451,17 @@ static int decode_frame(AVCodecContext *avctx,
buf
+=
12
;
buf
+=
12
;
}
}
if
(
s
->
invert
){
uint8_t
*
src
;
int
j
;
src
=
s
->
picture
.
data
[
0
];
for
(
j
=
0
;
j
<
s
->
height
;
j
++
){
for
(
i
=
0
;
i
<
s
->
picture
.
linesize
[
0
];
i
++
)
src
[
i
]
=
255
-
src
[
i
];
src
+=
s
->
picture
.
linesize
[
0
];
}
}
*
picture
=
*
(
AVFrame
*
)
&
s
->
picture
;
*
picture
=
*
(
AVFrame
*
)
&
s
->
picture
;
*
data_size
=
sizeof
(
AVPicture
);
*
data_size
=
sizeof
(
AVPicture
);
...
...
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