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
6781b531
Commit
6781b531
authored
Nov 17, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rl2: cosmetics, reformat
parent
3c6e5a84
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
40 deletions
+42
-40
rl2.c
libavcodec/rl2.c
+42
-40
No files found.
libavcodec/rl2.c
View file @
6781b531
...
...
@@ -66,60 +66,60 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size,
int
stride_adj
=
stride
-
s
->
avctx
->
width
;
int
i
;
const
uint8_t
*
back_frame
=
s
->
back_frame
;
const
uint8_t
*
in_end
=
in
+
size
;
const
uint8_t
*
out_end
=
out
+
stride
*
s
->
avctx
->
height
;
const
uint8_t
*
in_end
=
in
+
size
;
const
uint8_t
*
out_end
=
out
+
stride
*
s
->
avctx
->
height
;
uint8_t
*
line_end
;
/** copy start of the background frame */
for
(
i
=
0
;
i
<=
base_y
;
i
++
)
{
if
(
s
->
back_frame
)
memcpy
(
out
,
back_frame
,
s
->
avctx
->
width
);
out
+=
stride
;
for
(
i
=
0
;
i
<=
base_y
;
i
++
)
{
if
(
s
->
back_frame
)
memcpy
(
out
,
back_frame
,
s
->
avctx
->
width
);
out
+=
stride
;
back_frame
+=
s
->
avctx
->
width
;
}
back_frame
+=
base_x
-
s
->
avctx
->
width
;
line_end
=
out
-
stride_adj
;
out
+=
base_x
-
stride
;
line_end
=
out
-
stride_adj
;
out
+=
base_x
-
stride
;
/** decode the variable part of the frame */
while
(
in
<
in_end
)
{
while
(
in
<
in_end
)
{
uint8_t
val
=
*
in
++
;
int
len
=
1
;
if
(
val
>=
0x80
)
{
if
(
in
>=
in_end
)
int
len
=
1
;
if
(
val
>=
0x80
)
{
if
(
in
>=
in_end
)
break
;
len
=
*
in
++
;
if
(
!
len
)
if
(
!
len
)
break
;
}
if
(
len
>=
out_end
-
out
)
if
(
len
>=
out_end
-
out
)
break
;
if
(
s
->
back_frame
)
if
(
s
->
back_frame
)
val
|=
0x80
;
else
val
&=
~
0x80
;
while
(
len
--
)
{
*
out
++
=
(
val
==
0x80
)
?
*
back_frame
:
val
;
while
(
len
--
)
{
*
out
++
=
(
val
==
0x80
)
?
*
back_frame
:
val
;
back_frame
++
;
if
(
out
==
line_end
)
{
out
+=
stride_adj
;
if
(
out
==
line_end
)
{
out
+=
stride_adj
;
line_end
+=
stride
;
if
(
len
>=
out_end
-
out
)
if
(
len
>=
out_end
-
out
)
break
;
}
}
}
/** copy the rest from the background frame */
if
(
s
->
back_frame
)
{
while
(
out
<
out_end
)
{
if
(
s
->
back_frame
)
{
while
(
out
<
out_end
)
{
memcpy
(
out
,
back_frame
,
line_end
-
out
);
back_frame
+=
line_end
-
out
;
out
=
line_end
+
stride_adj
;
line_end
+=
stride
;
out
=
line_end
+
stride_adj
;
line_end
+=
stride
;
}
}
}
...
...
@@ -135,37 +135,38 @@ static av_cold int rl2_decode_init(AVCodecContext *avctx)
Rl2Context
*
s
=
avctx
->
priv_data
;
int
back_size
;
int
i
;
s
->
avctx
=
avctx
;
s
->
avctx
=
avctx
;
avctx
->
pix_fmt
=
AV_PIX_FMT_PAL8
;
/** parse extra data */
if
(
!
avctx
->
extradata
||
avctx
->
extradata_size
<
EXTRADATA1_SIZE
)
{
if
(
!
avctx
->
extradata
||
avctx
->
extradata_size
<
EXTRADATA1_SIZE
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid extradata size
\n
"
);
return
AVERROR
(
EINVAL
);
}
/** get frame_offset */
s
->
video_base
=
AV_RL16
(
&
avctx
->
extradata
[
0
]);
s
->
clr_count
=
AV_RL32
(
&
avctx
->
extradata
[
2
]);
s
->
clr_count
=
AV_RL32
(
&
avctx
->
extradata
[
2
]);
if
(
s
->
video_base
>=
avctx
->
width
*
avctx
->
height
)
{
if
(
s
->
video_base
>=
avctx
->
width
*
avctx
->
height
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid video_base
\n
"
);
return
AVERROR_INVALIDDATA
;
}
/** initialize palette */
for
(
i
=
0
;
i
<
AVPALETTE_COUNT
;
i
++
)
for
(
i
=
0
;
i
<
AVPALETTE_COUNT
;
i
++
)
s
->
palette
[
i
]
=
AV_RB24
(
&
avctx
->
extradata
[
6
+
i
*
3
]);
/** decode background frame if present */
back_size
=
avctx
->
extradata_size
-
EXTRADATA1_SIZE
;
if
(
back_size
>
0
)
{
if
(
back_size
>
0
)
{
uint8_t
*
back_frame
=
av_mallocz
(
avctx
->
width
*
avctx
->
height
);
if
(
!
back_frame
)
if
(
!
back_frame
)
return
AVERROR
(
ENOMEM
);
rl2_rle_decode
(
s
,
avctx
->
extradata
+
EXTRADATA1_SIZE
,
back_size
,
back_frame
,
avctx
->
width
,
0
);
rl2_rle_decode
(
s
,
avctx
->
extradata
+
EXTRADATA1_SIZE
,
back_size
,
back_frame
,
avctx
->
width
,
0
);
s
->
back_frame
=
back_frame
;
}
return
0
;
...
...
@@ -173,25 +174,26 @@ static av_cold int rl2_decode_init(AVCodecContext *avctx)
static
int
rl2_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
{
const
uint8_t
*
buf
=
avpkt
->
data
;
int
ret
,
buf_size
=
avpkt
->
size
;
int
ret
,
buf_size
=
avpkt
->
size
;
Rl2Context
*
s
=
avctx
->
priv_data
;
if
(
s
->
frame
.
data
[
0
])
if
(
s
->
frame
.
data
[
0
])
avctx
->
release_buffer
(
avctx
,
&
s
->
frame
);
/** get buffer */
s
->
frame
.
reference
=
0
;
s
->
frame
.
reference
=
0
;
if
((
ret
=
ff_get_buffer
(
avctx
,
&
s
->
frame
))
<
0
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
ret
;
}
/** run length decode */
rl2_rle_decode
(
s
,
buf
,
buf_size
,
s
->
frame
.
data
[
0
],
s
->
frame
.
linesize
[
0
],
s
->
video_base
);
rl2_rle_decode
(
s
,
buf
,
buf_size
,
s
->
frame
.
data
[
0
],
s
->
frame
.
linesize
[
0
],
s
->
video_base
);
/** make the palette available on the way out */
memcpy
(
s
->
frame
.
data
[
1
],
s
->
palette
,
AVPALETTE_SIZE
);
...
...
@@ -213,7 +215,7 @@ static av_cold int rl2_decode_end(AVCodecContext *avctx)
{
Rl2Context
*
s
=
avctx
->
priv_data
;
if
(
s
->
frame
.
data
[
0
])
if
(
s
->
frame
.
data
[
0
])
avctx
->
release_buffer
(
avctx
,
&
s
->
frame
);
av_free
(
s
->
back_frame
);
...
...
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