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
7cac568b
Commit
7cac568b
authored
Feb 10, 2015
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/mjpegenc: support trellis quantization
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
7366bb38
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
mjpegenc.c
libavcodec/mjpegenc.c
+36
-0
mpegvideo_enc.c
libavcodec/mpegvideo_enc.c
+5
-1
No files found.
libavcodec/mjpegenc.c
View file @
7cac568b
...
...
@@ -38,6 +38,35 @@
#include "mjpeg.h"
#include "mjpegenc.h"
static
uint8_t
uni_ac_vlc_len
[
64
*
64
*
2
];
static
uint8_t
uni_chroma_ac_vlc_len
[
64
*
64
*
2
];
static
av_cold
void
init_uni_ac_vlc
(
const
uint8_t
huff_size_ac
[
256
],
uint8_t
*
uni_ac_vlc_len
)
{
int
i
;
for
(
i
=
0
;
i
<
128
;
i
++
)
{
int
level
=
i
-
64
;
int
run
;
if
(
!
level
)
continue
;
for
(
run
=
0
;
run
<
64
;
run
++
)
{
int
len
,
code
,
nbits
;
int
alevel
=
FFABS
(
level
);
len
=
(
run
>>
4
)
*
huff_size_ac
[
0xf0
];
nbits
=
av_log2_16bit
(
alevel
)
+
1
;
code
=
((
15
&
run
)
<<
4
)
|
nbits
;
len
+=
huff_size_ac
[
code
]
+
nbits
;
uni_ac_vlc_len
[
UNI_AC_ENC_INDEX
(
run
,
i
)]
=
len
;
// We ignore EOB as its just a constant which does not change generally
}
}
}
av_cold
int
ff_mjpeg_encode_init
(
MpegEncContext
*
s
)
{
MJpegContext
*
m
;
...
...
@@ -72,6 +101,13 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
avpriv_mjpeg_bits_ac_chrominance
,
avpriv_mjpeg_val_ac_chrominance
);
init_uni_ac_vlc
(
m
->
huff_size_ac_luminance
,
uni_ac_vlc_len
);
init_uni_ac_vlc
(
m
->
huff_size_ac_chrominance
,
uni_chroma_ac_vlc_len
);
s
->
intra_ac_vlc_length
=
s
->
intra_ac_vlc_last_length
=
uni_ac_vlc_len
;
s
->
intra_chroma_ac_vlc_length
=
s
->
intra_chroma_ac_vlc_last_length
=
uni_chroma_ac_vlc_len
;
s
->
mjpeg_ctx
=
m
;
return
0
;
}
...
...
libavcodec/mpegvideo_enc.c
View file @
7cac568b
...
...
@@ -3811,8 +3811,9 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
start_i
=
1
;
last_non_zero
=
0
;
qmat
=
n
<
4
?
s
->
q_intra_matrix
[
qscale
]
:
s
->
q_chroma_intra_matrix
[
qscale
];
if
(
s
->
mpeg_quant
||
s
->
out_format
==
FMT_MPEG1
)
if
(
s
->
mpeg_quant
||
s
->
out_format
==
FMT_MPEG1
||
s
->
out_format
==
FMT_MJPEG
)
bias
=
1
<<
(
QMAT_SHIFT
-
1
);
if
(
n
>
3
&&
s
->
intra_chroma_ac_vlc_length
)
{
length
=
s
->
intra_chroma_ac_vlc_length
;
last_length
=
s
->
intra_chroma_ac_vlc_last_length
;
...
...
@@ -3899,6 +3900,9 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
if
(
s
->
out_format
==
FMT_H263
||
s
->
out_format
==
FMT_H261
){
unquant_coeff
=
alevel
*
qmul
+
qadd
;
}
else
if
(
s
->
out_format
==
FMT_MJPEG
)
{
j
=
s
->
idsp
.
idct_permutation
[
scantable
[
i
]];
unquant_coeff
=
alevel
*
s
->
intra_matrix
[
j
]
*
8
;
}
else
{
//MPEG1
j
=
s
->
idsp
.
idct_permutation
[
scantable
[
i
]];
// FIXME: optimize
if
(
s
->
mb_intra
){
...
...
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