Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
415365d2
Commit
415365d2
authored
18 years ago
by
Michael Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
avoid i++ in decode_block()
Originally committed as revision 5238 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
7d2b787d
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/mjpeg.c
+22
-13
22 additions, 13 deletions
libavcodec/mjpeg.c
with
22 additions
and
13 deletions
libavcodec/mjpeg.c
+
22
−
13
View file @
415365d2
...
...
@@ -894,14 +894,24 @@ typedef struct MJpegDecodeContext {
static
int
mjpeg_decode_dht
(
MJpegDecodeContext
*
s
);
static
int
build_vlc
(
VLC
*
vlc
,
const
uint8_t
*
bits_table
,
const
uint8_t
*
val_table
,
int
nb_codes
,
int
use_static
)
int
nb_codes
,
int
use_static
,
int
is_ac
)
{
uint8_t
huff_size
[
256
];
uint16_t
huff_code
[
256
];
uint8_t
huff_size
[
256
+
16
];
uint16_t
huff_code
[
256
+
16
];
assert
(
nb_codes
<=
256
);
memset
(
huff_size
,
0
,
sizeof
(
huff_size
));
build_huffman_codes
(
huff_size
,
huff_code
,
bits_table
,
val_table
);
if
(
is_ac
){
memmove
(
huff_size
+
16
,
huff_size
,
sizeof
(
uint8_t
)
*
nb_codes
);
memmove
(
huff_code
+
16
,
huff_code
,
sizeof
(
uint16_t
)
*
nb_codes
);
memset
(
huff_size
,
0
,
sizeof
(
uint8_t
)
*
16
);
memset
(
huff_code
,
0
,
sizeof
(
uint16_t
)
*
16
);
nb_codes
+=
16
;
}
return
init_vlc
(
vlc
,
9
,
nb_codes
,
huff_size
,
1
,
1
,
huff_code
,
2
,
2
,
use_static
);
}
...
...
@@ -930,10 +940,10 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
s
->
first_picture
=
1
;
s
->
org_height
=
avctx
->
coded_height
;
build_vlc
(
&
s
->
vlcs
[
0
][
0
],
bits_dc_luminance
,
val_dc_luminance
,
12
,
0
);
build_vlc
(
&
s
->
vlcs
[
0
][
1
],
bits_dc_chrominance
,
val_dc_chrominance
,
12
,
0
);
build_vlc
(
&
s
->
vlcs
[
1
][
0
],
bits_ac_luminance
,
val_ac_luminance
,
251
,
0
);
build_vlc
(
&
s
->
vlcs
[
1
][
1
],
bits_ac_chrominance
,
val_ac_chrominance
,
251
,
0
);
build_vlc
(
&
s
->
vlcs
[
0
][
0
],
bits_dc_luminance
,
val_dc_luminance
,
12
,
0
,
0
);
build_vlc
(
&
s
->
vlcs
[
0
][
1
],
bits_dc_chrominance
,
val_dc_chrominance
,
12
,
0
,
0
);
build_vlc
(
&
s
->
vlcs
[
1
][
0
],
bits_ac_luminance
,
val_ac_luminance
,
251
,
0
,
1
);
build_vlc
(
&
s
->
vlcs
[
1
][
1
],
bits_ac_chrominance
,
val_ac_chrominance
,
251
,
0
,
1
);
if
(
avctx
->
flags
&
CODEC_FLAG_EXTERN_HUFF
)
{
...
...
@@ -1084,7 +1094,7 @@ static int mjpeg_decode_dht(MJpegDecodeContext *s)
free_vlc
(
&
s
->
vlcs
[
class
][
index
]);
dprintf
(
"class=%d index=%d nb_codes=%d
\n
"
,
class
,
index
,
code_max
+
1
);
if
(
build_vlc
(
&
s
->
vlcs
[
class
][
index
],
bits_table
,
val_table
,
code_max
+
1
,
0
)
<
0
){
if
(
build_vlc
(
&
s
->
vlcs
[
class
][
index
],
bits_table
,
val_table
,
code_max
+
1
,
0
,
class
>
0
)
<
0
){
return
-
1
;
}
}
...
...
@@ -1262,16 +1272,16 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
block
[
0
]
=
val
;
/* AC coefs */
ac_vlc
=
&
s
->
vlcs
[
1
][
ac_index
];
i
=
1
;
i
=
0
;
OPEN_READER
(
re
,
&
s
->
gb
)
for
(;;)
{
UPDATE_CACHE
(
re
,
&
s
->
gb
);
GET_VLC
(
code
,
re
,
&
s
->
gb
,
s
->
vlcs
[
1
][
ac_index
].
table
,
9
,
2
)
/* EOB */
if
(
code
==
0
)
if
(
code
==
0x1
0
)
break
;
if
(
code
==
0x
f
0
)
{
if
(
code
==
0x
10
0
)
{
i
+=
16
;
}
else
{
i
+=
((
unsigned
)
code
)
>>
4
;
...
...
@@ -1293,8 +1303,7 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
}
j
=
s
->
scantable
.
permutated
[
i
];
block
[
j
]
=
level
*
quant_matrix
[
j
];
i
++
;
if
(
i
>=
64
)
if
(
i
>=
63
)
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment