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
0d733ec3
Commit
0d733ec3
authored
Jan 26, 2016
by
Matthieu Bouron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/mjpegdec: speed up scan data copy
parent
e5b5676c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
10 deletions
+40
-10
mjpegdec.c
libavcodec/mjpegdec.c
+40
-10
No files found.
libavcodec/mjpegdec.c
View file @
0d733ec3
...
...
@@ -1921,24 +1921,54 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s,
/* unescape buffer of SOS, use special treatment for JPEG-LS */
if
(
start_code
==
SOS
&&
!
s
->
ls
)
{
const
uint8_t
*
src
=
*
buf_ptr
;
const
uint8_t
*
ptr
=
src
;
uint8_t
*
dst
=
s
->
buffer
;
while
(
src
<
buf_end
)
{
uint8_t
x
=
*
(
src
++
);
#define copy_data_segment(skip) do { \
ssize_t length = (ptr - src) - (skip); \
if (length > 0) { \
memcpy(dst, src, length); \
dst += length; \
src = ptr; \
} \
} while (0)
if
(
s
->
avctx
->
codec_id
==
AV_CODEC_ID_THP
)
{
ptr
=
buf_end
;
copy_data_segment
(
0
);
}
else
{
while
(
ptr
<
buf_end
)
{
uint8_t
x
=
*
(
ptr
++
);
*
(
dst
++
)
=
x
;
if
(
s
->
avctx
->
codec_id
!=
AV_CODEC_ID_THP
)
{
if
(
x
==
0xff
)
{
while
(
src
<
buf_end
&&
x
==
0xff
)
x
=
*
(
src
++
);
ssize_t
skip
=
0
;
while
(
ptr
<
buf_end
&&
x
==
0xff
)
{
x
=
*
(
ptr
++
);
skip
++
;
}
if
(
x
>=
0xd0
&&
x
<=
0xd7
)
*
(
dst
++
)
=
x
;
else
if
(
x
)
break
;
/* 0xFF, 0xFF, ... */
if
(
skip
>
1
)
{
copy_data_segment
(
skip
);
/* decrement src as it is equal to ptr after the
* copy_data_segment macro and we might want to
* copy the current value of x later on */
src
--
;
}
if
(
x
<
0xd0
||
x
>
0xd7
)
{
copy_data_segment
(
1
);
if
(
x
)
break
;
}
}
}
if
(
src
<
ptr
)
copy_data_segment
(
0
);
}
#undef copy_data_segment
*
unescaped_buf_ptr
=
s
->
buffer
;
*
unescaped_buf_size
=
dst
-
s
->
buffer
;
memset
(
s
->
buffer
+
*
unescaped_buf_size
,
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