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
b56f94cc
Commit
b56f94cc
authored
Oct 08, 2012
by
Bobby Bingham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
targa: cosmetics - add some whitespace
Signed-off-by:
Bobby Bingham
<
uhmmmm@gmail.com
>
parent
50787fe3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
20 deletions
+25
-20
targa.c
libavcodec/targa.c
+25
-20
No files found.
libavcodec/targa.c
View file @
b56f94cc
...
@@ -98,7 +98,7 @@ static int targa_decode_rle(AVCodecContext *avctx, TargaContext *s,
...
@@ -98,7 +98,7 @@ static int targa_decode_rle(AVCodecContext *avctx, TargaContext *s,
}
}
}
}
if
(
count
)
{
if
(
count
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Packet went out of bounds
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Packet went out of bounds
\n
"
);
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
...
@@ -150,7 +150,7 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -150,7 +150,7 @@ static int decode_frame(AVCodecContext *avctx,
// skip identifier if any
// skip identifier if any
bytestream2_skip
(
&
s
->
gb
,
idlen
);
bytestream2_skip
(
&
s
->
gb
,
idlen
);
switch
(
bpp
)
{
switch
(
bpp
)
{
case
8
:
case
8
:
avctx
->
pix_fmt
=
((
compr
&
(
~
TGA_RLE
))
==
TGA_BW
)
?
AV_PIX_FMT_GRAY8
:
AV_PIX_FMT_PAL8
;
avctx
->
pix_fmt
=
((
compr
&
(
~
TGA_RLE
))
==
TGA_BW
)
?
AV_PIX_FMT_GRAY8
:
AV_PIX_FMT_PAL8
;
break
;
break
;
...
@@ -169,21 +169,22 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -169,21 +169,22 @@ static int decode_frame(AVCodecContext *avctx,
return
-
1
;
return
-
1
;
}
}
if
(
s
->
picture
.
data
[
0
])
if
(
s
->
picture
.
data
[
0
])
avctx
->
release_buffer
(
avctx
,
&
s
->
picture
);
avctx
->
release_buffer
(
avctx
,
&
s
->
picture
);
if
(
av_image_check_size
(
w
,
h
,
0
,
avctx
))
if
(
av_image_check_size
(
w
,
h
,
0
,
avctx
))
return
-
1
;
return
-
1
;
if
(
w
!=
avctx
->
width
||
h
!=
avctx
->
height
)
if
(
w
!=
avctx
->
width
||
h
!=
avctx
->
height
)
avcodec_set_dimensions
(
avctx
,
w
,
h
);
avcodec_set_dimensions
(
avctx
,
w
,
h
);
if
(
avctx
->
get_buffer
(
avctx
,
p
)
<
0
)
{
if
(
avctx
->
get_buffer
(
avctx
,
p
)
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
-
1
;
return
-
1
;
}
}
if
(
flags
&
TGA_TOPTOBOTTOM
)
{
if
(
flags
&
TGA_TOPTOBOTTOM
)
{
dst
=
p
->
data
[
0
];
dst
=
p
->
data
[
0
];
stride
=
p
->
linesize
[
0
];
stride
=
p
->
linesize
[
0
];
}
else
{
//image is upside-down
}
else
{
//image is upside-down
dst
=
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
h
-
1
);
dst
=
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
h
-
1
);
stride
=
-
p
->
linesize
[
0
];
stride
=
-
p
->
linesize
[
0
];
}
}
...
@@ -191,9 +192,9 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -191,9 +192,9 @@ static int decode_frame(AVCodecContext *avctx,
interleave
=
flags
&
TGA_INTERLEAVE2
?
2
:
interleave
=
flags
&
TGA_INTERLEAVE2
?
2
:
flags
&
TGA_INTERLEAVE4
?
4
:
1
;
flags
&
TGA_INTERLEAVE4
?
4
:
1
;
if
(
colors
)
{
if
(
colors
)
{
int
pal_size
,
pal_sample_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
;
}
}
...
@@ -207,9 +208,9 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -207,9 +208,9 @@ static int decode_frame(AVCodecContext *avctx,
return
-
1
;
return
-
1
;
}
}
pal_size
=
colors
*
pal_sample_size
;
pal_size
=
colors
*
pal_sample_size
;
if
(
avctx
->
pix_fmt
!=
AV_PIX_FMT_PAL8
)
//should not occur but skip palette anyway
if
(
avctx
->
pix_fmt
!=
AV_PIX_FMT_PAL8
)
//should not occur but skip palette anyway
bytestream2_skip
(
&
s
->
gb
,
pal_size
);
bytestream2_skip
(
&
s
->
gb
,
pal_size
);
else
{
else
{
int
t
;
int
t
;
uint32_t
*
pal
=
((
uint32_t
*
)
p
->
data
[
1
])
+
first_clr
;
uint32_t
*
pal
=
((
uint32_t
*
)
p
->
data
[
1
])
+
first_clr
;
...
@@ -244,10 +245,11 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -244,10 +245,11 @@ static int decode_frame(AVCodecContext *avctx,
p
->
palette_has_changed
=
1
;
p
->
palette_has_changed
=
1
;
}
}
}
}
if
((
compr
&
(
~
TGA_RLE
))
==
TGA_NODATA
)
{
if
((
compr
&
(
~
TGA_RLE
))
==
TGA_NODATA
)
{
memset
(
p
->
data
[
0
],
0
,
p
->
linesize
[
0
]
*
h
);
memset
(
p
->
data
[
0
],
0
,
p
->
linesize
[
0
]
*
h
);
}
else
{
}
else
{
if
(
compr
&
TGA_RLE
)
{
if
(
compr
&
TGA_RLE
)
{
int
res
=
targa_decode_rle
(
avctx
,
s
,
dst
,
w
,
h
,
stride
,
bpp
,
interleave
);
int
res
=
targa_decode_rle
(
avctx
,
s
,
dst
,
w
,
h
,
stride
,
bpp
,
interleave
);
if
(
res
<
0
)
if
(
res
<
0
)
return
res
;
return
res
;
...
@@ -268,12 +270,13 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -268,12 +270,13 @@ static int decode_frame(AVCodecContext *avctx,
}
while
(
line
);
}
while
(
line
);
}
}
}
}
if
(
flags
&
TGA_RIGHTTOLEFT
)
{
// right-to-left, needs horizontal flip
if
(
flags
&
TGA_RIGHTTOLEFT
)
{
// right-to-left, needs horizontal flip
int
x
;
int
x
;
for
(
y
=
0
;
y
<
h
;
y
++
)
{
for
(
y
=
0
;
y
<
h
;
y
++
)
{
void
*
line
=
&
p
->
data
[
0
][
y
*
p
->
linesize
[
0
]];
void
*
line
=
&
p
->
data
[
0
][
y
*
p
->
linesize
[
0
]];
for
(
x
=
0
;
x
<
w
>>
1
;
x
++
)
{
for
(
x
=
0
;
x
<
w
>>
1
;
x
++
)
{
switch
(
bpp
)
{
switch
(
bpp
)
{
case
32
:
case
32
:
FFSWAP
(
uint32_t
,
((
uint32_t
*
)
line
)[
x
],
((
uint32_t
*
)
line
)[
w
-
x
-
1
]);
FFSWAP
(
uint32_t
,
((
uint32_t
*
)
line
)[
x
],
((
uint32_t
*
)
line
)[
w
-
x
-
1
]);
break
;
break
;
...
@@ -298,7 +301,8 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -298,7 +301,8 @@ static int decode_frame(AVCodecContext *avctx,
return
avpkt
->
size
;
return
avpkt
->
size
;
}
}
static
av_cold
int
targa_init
(
AVCodecContext
*
avctx
){
static
av_cold
int
targa_init
(
AVCodecContext
*
avctx
)
{
TargaContext
*
s
=
avctx
->
priv_data
;
TargaContext
*
s
=
avctx
->
priv_data
;
avcodec_get_frame_defaults
(
&
s
->
picture
);
avcodec_get_frame_defaults
(
&
s
->
picture
);
...
@@ -307,10 +311,11 @@ static av_cold int targa_init(AVCodecContext *avctx){
...
@@ -307,10 +311,11 @@ static av_cold int targa_init(AVCodecContext *avctx){
return
0
;
return
0
;
}
}
static
av_cold
int
targa_end
(
AVCodecContext
*
avctx
){
static
av_cold
int
targa_end
(
AVCodecContext
*
avctx
)
{
TargaContext
*
s
=
avctx
->
priv_data
;
TargaContext
*
s
=
avctx
->
priv_data
;
if
(
s
->
picture
.
data
[
0
])
if
(
s
->
picture
.
data
[
0
])
avctx
->
release_buffer
(
avctx
,
&
s
->
picture
);
avctx
->
release_buffer
(
avctx
,
&
s
->
picture
);
return
0
;
return
0
;
...
...
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