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
626c1a33
Commit
626c1a33
authored
Sep 02, 2012
by
Alberto Delmás
Committed by
Kostya Shishkov
Sep 03, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mss12: reduce SliceContext size from 1067 to 164 KB
Signed-off-by:
Kostya Shishkov
<
kostya.shishkov@gmail.com
>
parent
a97ee41b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
37 deletions
+30
-37
mss1.c
libavcodec/mss1.c
+1
-1
mss12.c
libavcodec/mss12.c
+24
-30
mss12.h
libavcodec/mss12.h
+4
-5
mss2.c
libavcodec/mss2.c
+1
-1
No files found.
libavcodec/mss1.c
View file @
626c1a33
...
@@ -89,7 +89,7 @@ static int arith_get_number(ArithCoder *c, int mod_val)
...
@@ -89,7 +89,7 @@ static int arith_get_number(ArithCoder *c, int mod_val)
return
val
;
return
val
;
}
}
static
int
arith_get_prob
(
ArithCoder
*
c
,
int
*
probs
)
static
int
arith_get_prob
(
ArithCoder
*
c
,
int
16_t
*
probs
)
{
{
int
range
=
c
->
high
-
c
->
low
+
1
;
int
range
=
c
->
high
-
c
->
low
+
1
;
int
val
=
((
c
->
value
-
c
->
low
+
1
)
*
probs
[
0
]
-
1
)
/
range
;
int
val
=
((
c
->
value
-
c
->
low
+
1
)
*
probs
[
0
]
-
1
)
/
range
;
...
...
libavcodec/mss12.c
View file @
626c1a33
...
@@ -61,13 +61,9 @@ static void model_reset(Model *m)
...
@@ -61,13 +61,9 @@ static void model_reset(Model *m)
m
->
weights
[
i
]
=
1
;
m
->
weights
[
i
]
=
1
;
m
->
cum_prob
[
i
]
=
m
->
num_syms
-
i
;
m
->
cum_prob
[
i
]
=
m
->
num_syms
-
i
;
}
}
m
->
weights
[
0
]
=
-
1
;
m
->
weights
[
0
]
=
0
;
m
->
idx2sym
[
0
]
=
-
1
;
for
(
i
=
0
;
i
<
m
->
num_syms
;
i
++
)
m
->
sym2idx
[
m
->
num_syms
]
=
-
1
;
for
(
i
=
0
;
i
<
m
->
num_syms
;
i
++
)
{
m
->
sym2idx
[
i
]
=
i
+
1
;
m
->
idx2sym
[
i
+
1
]
=
i
;
m
->
idx2sym
[
i
+
1
]
=
i
;
}
}
}
static
av_cold
void
model_init
(
Model
*
m
,
int
num_syms
,
int
thr_weight
)
static
av_cold
void
model_init
(
Model
*
m
,
int
num_syms
,
int
thr_weight
)
...
@@ -75,7 +71,6 @@ static av_cold void model_init(Model *m, int num_syms, int thr_weight)
...
@@ -75,7 +71,6 @@ static av_cold void model_init(Model *m, int num_syms, int thr_weight)
m
->
num_syms
=
num_syms
;
m
->
num_syms
=
num_syms
;
m
->
thr_weight
=
thr_weight
;
m
->
thr_weight
=
thr_weight
;
m
->
threshold
=
num_syms
*
thr_weight
;
m
->
threshold
=
num_syms
*
thr_weight
;
model_reset
(
m
);
}
}
static
void
model_rescale_weights
(
Model
*
m
)
static
void
model_rescale_weights
(
Model
*
m
)
...
@@ -109,8 +104,6 @@ void ff_mss12_model_update(Model *m, int val)
...
@@ -109,8 +104,6 @@ void ff_mss12_model_update(Model *m, int val)
m
->
idx2sym
[
val
]
=
sym2
;
m
->
idx2sym
[
val
]
=
sym2
;
m
->
idx2sym
[
i
]
=
sym1
;
m
->
idx2sym
[
i
]
=
sym1
;
m
->
sym2idx
[
sym1
]
=
i
;
m
->
sym2idx
[
sym2
]
=
val
;
val
=
i
;
val
=
i
;
}
}
...
@@ -123,7 +116,7 @@ void ff_mss12_model_update(Model *m, int val)
...
@@ -123,7 +116,7 @@ void ff_mss12_model_update(Model *m, int val)
static
void
pixctx_reset
(
PixContext
*
ctx
)
static
void
pixctx_reset
(
PixContext
*
ctx
)
{
{
int
i
,
j
,
k
;
int
i
,
j
;
if
(
!
ctx
->
special_initial_cache
)
if
(
!
ctx
->
special_initial_cache
)
for
(
i
=
0
;
i
<
ctx
->
cache_size
;
i
++
)
for
(
i
=
0
;
i
<
ctx
->
cache_size
;
i
++
)
...
@@ -137,16 +130,15 @@ static void pixctx_reset(PixContext *ctx)
...
@@ -137,16 +130,15 @@ static void pixctx_reset(PixContext *ctx)
model_reset
(
&
ctx
->
cache_model
);
model_reset
(
&
ctx
->
cache_model
);
model_reset
(
&
ctx
->
full_model
);
model_reset
(
&
ctx
->
full_model
);
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
15
;
i
++
)
for
(
j
=
0
;
j
<
sec_order_sizes
[
i
];
j
++
)
for
(
j
=
0
;
j
<
4
;
j
++
)
for
(
k
=
0
;
k
<
4
;
k
++
)
model_reset
(
&
ctx
->
sec_models
[
i
][
j
]);
model_reset
(
&
ctx
->
sec_models
[
i
][
j
][
k
]);
}
}
static
av_cold
void
pixctx_init
(
PixContext
*
ctx
,
int
cache_size
,
static
av_cold
void
pixctx_init
(
PixContext
*
ctx
,
int
cache_size
,
int
full_model_syms
,
int
special_initial_cache
)
int
full_model_syms
,
int
special_initial_cache
)
{
{
int
i
,
j
,
k
;
int
i
,
j
,
k
,
idx
;
ctx
->
cache_size
=
cache_size
+
4
;
ctx
->
cache_size
=
cache_size
+
4
;
ctx
->
num_syms
=
cache_size
;
ctx
->
num_syms
=
cache_size
;
...
@@ -155,10 +147,10 @@ static av_cold void pixctx_init(PixContext *ctx, int cache_size,
...
@@ -155,10 +147,10 @@ static av_cold void pixctx_init(PixContext *ctx, int cache_size,
model_init
(
&
ctx
->
cache_model
,
ctx
->
num_syms
+
1
,
THRESH_LOW
);
model_init
(
&
ctx
->
cache_model
,
ctx
->
num_syms
+
1
,
THRESH_LOW
);
model_init
(
&
ctx
->
full_model
,
full_model_syms
,
THRESH_HIGH
);
model_init
(
&
ctx
->
full_model
,
full_model_syms
,
THRESH_HIGH
);
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
,
idx
=
0
;
i
<
4
;
i
++
)
for
(
j
=
0
;
j
<
sec_order_sizes
[
i
];
j
++
)
for
(
j
=
0
;
j
<
sec_order_sizes
[
i
];
j
++
,
idx
++
)
for
(
k
=
0
;
k
<
4
;
k
++
)
for
(
k
=
0
;
k
<
4
;
k
++
)
model_init
(
&
ctx
->
sec_models
[
i
][
j
][
k
],
2
+
i
,
model_init
(
&
ctx
->
sec_models
[
i
dx
][
k
],
2
+
i
,
i
?
THRESH_LOW
:
THRESH_ADAPTIVE
);
i
?
THRESH_LOW
:
THRESH_ADAPTIVE
);
}
}
...
@@ -268,46 +260,48 @@ static int decode_pixel_in_context(ArithCoder *acoder, PixContext *pctx,
...
@@ -268,46 +260,48 @@ static int decode_pixel_in_context(ArithCoder *acoder, PixContext *pctx,
switch
(
nlen
)
{
switch
(
nlen
)
{
case
1
:
case
1
:
case
4
:
layer
=
0
;
layer
=
0
;
break
;
break
;
case
2
:
case
2
:
if
(
neighbours
[
TOP
]
==
neighbours
[
TOP_LEFT
])
{
if
(
neighbours
[
TOP
]
==
neighbours
[
TOP_LEFT
])
{
if
(
neighbours
[
TOP_RIGHT
]
==
neighbours
[
TOP_LEFT
])
if
(
neighbours
[
TOP_RIGHT
]
==
neighbours
[
TOP_LEFT
])
layer
=
3
;
layer
=
1
;
else
if
(
neighbours
[
LEFT
]
==
neighbours
[
TOP_LEFT
])
else
if
(
neighbours
[
LEFT
]
==
neighbours
[
TOP_LEFT
])
layer
=
2
;
layer
=
2
;
else
else
layer
=
4
;
layer
=
3
;
}
else
if
(
neighbours
[
TOP_RIGHT
]
==
neighbours
[
TOP_LEFT
])
{
}
else
if
(
neighbours
[
TOP_RIGHT
]
==
neighbours
[
TOP_LEFT
])
{
if
(
neighbours
[
LEFT
]
==
neighbours
[
TOP_LEFT
])
if
(
neighbours
[
LEFT
]
==
neighbours
[
TOP_LEFT
])
layer
=
1
;
layer
=
4
;
else
else
layer
=
5
;
layer
=
5
;
}
else
if
(
neighbours
[
LEFT
]
==
neighbours
[
TOP_LEFT
])
{
}
else
if
(
neighbours
[
LEFT
]
==
neighbours
[
TOP_LEFT
])
{
layer
=
6
;
layer
=
6
;
}
else
{
}
else
{
layer
=
0
;
layer
=
7
;
}
}
break
;
break
;
case
3
:
case
3
:
if
(
neighbours
[
TOP
]
==
neighbours
[
TOP_LEFT
])
if
(
neighbours
[
TOP
]
==
neighbours
[
TOP_LEFT
])
layer
=
0
;
layer
=
8
;
else
if
(
neighbours
[
TOP_RIGHT
]
==
neighbours
[
TOP_LEFT
])
else
if
(
neighbours
[
TOP_RIGHT
]
==
neighbours
[
TOP_LEFT
])
layer
=
1
;
layer
=
9
;
else
if
(
neighbours
[
LEFT
]
==
neighbours
[
TOP_LEFT
])
else
if
(
neighbours
[
LEFT
]
==
neighbours
[
TOP_LEFT
])
layer
=
2
;
layer
=
10
;
else
if
(
neighbours
[
TOP_RIGHT
]
==
neighbours
[
TOP
])
else
if
(
neighbours
[
TOP_RIGHT
]
==
neighbours
[
TOP
])
layer
=
3
;
layer
=
11
;
else
if
(
neighbours
[
TOP
]
==
neighbours
[
LEFT
])
else
if
(
neighbours
[
TOP
]
==
neighbours
[
LEFT
])
layer
=
4
;
layer
=
12
;
else
else
layer
=
5
;
layer
=
13
;
break
;
case
4
:
layer
=
14
;
break
;
break
;
}
}
pix
=
acoder
->
get_model_sym
(
acoder
,
pix
=
acoder
->
get_model_sym
(
acoder
,
&
pctx
->
sec_models
[
nlen
-
1
][
layer
][
sub
]);
&
pctx
->
sec_models
[
layer
][
sub
]);
if
(
pix
<
nlen
)
if
(
pix
<
nlen
)
return
ref_pix
[
pix
];
return
ref_pix
[
pix
];
else
else
...
...
libavcodec/mss12.h
View file @
626c1a33
...
@@ -38,10 +38,9 @@
...
@@ -38,10 +38,9 @@
#define THRESH_HIGH 50
#define THRESH_HIGH 50
typedef
struct
Model
{
typedef
struct
Model
{
int
cum_prob
[
MODEL_MAX_SYMS
+
1
];
int16_t
cum_prob
[
MODEL_MAX_SYMS
+
1
];
int
weights
[
MODEL_MAX_SYMS
+
1
];
int16_t
weights
[
MODEL_MAX_SYMS
+
1
];
int
idx2sym
[
MODEL_MAX_SYMS
+
1
];
uint8_t
idx2sym
[
MODEL_MAX_SYMS
+
1
];
int
sym2idx
[
MODEL_MAX_SYMS
+
1
];
int
num_syms
;
int
num_syms
;
int
thr_weight
,
threshold
;
int
thr_weight
,
threshold
;
}
Model
;
}
Model
;
...
@@ -60,7 +59,7 @@ typedef struct PixContext {
...
@@ -60,7 +59,7 @@ typedef struct PixContext {
int
cache_size
,
num_syms
;
int
cache_size
,
num_syms
;
uint8_t
cache
[
12
];
uint8_t
cache
[
12
];
Model
cache_model
,
full_model
;
Model
cache_model
,
full_model
;
Model
sec_models
[
4
][
8
][
4
];
Model
sec_models
[
15
][
4
];
int
special_initial_cache
;
int
special_initial_cache
;
}
PixContext
;
}
PixContext
;
...
...
libavcodec/mss2.c
View file @
626c1a33
...
@@ -106,7 +106,7 @@ static int arith2_get_number(ArithCoder *c, int n)
...
@@ -106,7 +106,7 @@ static int arith2_get_number(ArithCoder *c, int n)
return
val
;
return
val
;
}
}
static
int
arith2_get_prob
(
ArithCoder
*
c
,
int
*
probs
)
static
int
arith2_get_prob
(
ArithCoder
*
c
,
int
16_t
*
probs
)
{
{
int
range
=
c
->
high
-
c
->
low
+
1
,
n
=
*
probs
;
int
range
=
c
->
high
-
c
->
low
+
1
,
n
=
*
probs
;
int
scale
=
av_log2
(
range
)
-
av_log2
(
n
);
int
scale
=
av_log2
(
range
)
-
av_log2
(
n
);
...
...
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