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
2fd39642
Commit
2fd39642
authored
Jan 16, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/huffyuv: fix median prediction for >8bps
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
3d879279
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
3 deletions
+56
-3
huffyuvdec.c
libavcodec/huffyuvdec.c
+28
-2
huffyuvenc.c
libavcodec/huffyuvenc.c
+28
-1
No files found.
libavcodec/huffyuvdec.c
View file @
2fd39642
...
...
@@ -725,6 +725,32 @@ static void add_bytes(HYuvContext *s, uint8_t *dst, uint8_t *src, int w)
}
}
static
void
add_median_prediction
(
HYuvContext
*
s
,
uint8_t
*
dst
,
const
uint8_t
*
src
,
const
uint8_t
*
diff
,
int
w
,
int
*
left
,
int
*
left_top
)
{
if
(
s
->
bps
<=
8
)
{
s
->
dsp
.
add_hfyu_median_prediction
(
dst
,
src
,
diff
,
w
,
left
,
left_top
);
}
else
{
//FIXME optimize
unsigned
mask
=
s
->
n
-
1
;
int
i
;
uint16_t
l
,
lt
;
const
uint16_t
*
src16
=
(
const
uint16_t
*
)
src
;
const
uint16_t
*
diff16
=
(
const
uint16_t
*
)
diff
;
uint16_t
*
dst16
=
(
uint16_t
*
)
dst
;
l
=
*
left
;
lt
=
*
left_top
;
for
(
i
=
0
;
i
<
w
;
i
++
){
l
=
(
mid_pred
(
l
,
src16
[
i
],
(
l
+
src16
[
i
]
-
lt
)
&
mask
)
+
diff16
[
i
])
&
mask
;
lt
=
src16
[
i
];
dst16
[
i
]
=
l
;
}
*
left
=
l
;
*
left_top
=
lt
;
}
}
static
int
decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
{
...
...
@@ -817,7 +843,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
lefttop
=
p
->
data
[
plane
][
0
];
decode_plane_bitstream
(
s
,
w
,
plane
);
s
->
dsp
.
add_hfyu_median_prediction
(
p
->
data
[
plane
]
+
fake_stride
,
p
->
data
[
plane
],
s
->
temp
[
0
],
w
,
&
left
,
&
lefttop
);
add_median_prediction
(
s
,
p
->
data
[
plane
]
+
fake_stride
,
p
->
data
[
plane
],
s
->
temp
[
0
],
w
,
&
left
,
&
lefttop
);
y
++
;
for
(;
y
<
h
;
y
++
)
{
...
...
@@ -827,7 +853,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
dst
=
p
->
data
[
plane
]
+
p
->
linesize
[
plane
]
*
y
;
s
->
dsp
.
add_hfyu_median_prediction
(
dst
,
dst
-
fake_stride
,
s
->
temp
[
0
],
w
,
&
left
,
&
lefttop
);
add_median_prediction
(
s
,
dst
,
dst
-
fake_stride
,
s
->
temp
[
0
],
w
,
&
left
,
&
lefttop
);
}
break
;
...
...
libavcodec/huffyuvenc.c
View file @
2fd39642
...
...
@@ -153,6 +153,33 @@ static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst,
*
blue
=
src
[(
w
-
1
)
*
3
+
2
];
}
static
void
sub_median_prediction
(
HYuvContext
*
s
,
uint8_t
*
dst
,
const
uint8_t
*
src1
,
const
uint8_t
*
src2
,
int
w
,
int
*
left
,
int
*
left_top
)
{
if
(
s
->
bps
<=
8
)
{
s
->
dsp
.
sub_hfyu_median_prediction
(
dst
,
src1
,
src2
,
w
,
left
,
left_top
);
}
else
{
int
i
;
uint16_t
l
,
lt
;
const
uint16_t
*
src116
=
(
const
uint16_t
*
)
src1
;
const
uint16_t
*
src216
=
(
const
uint16_t
*
)
src2
;
uint16_t
*
dst16
=
(
uint16_t
*
)
dst
;
unsigned
mask
=
s
->
n
-
1
;
l
=
*
left
;
lt
=
*
left_top
;
for
(
i
=
0
;
i
<
w
;
i
++
){
const
int
pred
=
mid_pred
(
l
,
src116
[
i
],
(
l
+
src116
[
i
]
-
lt
)
&
mask
);
lt
=
src116
[
i
];
l
=
src216
[
i
];
dst16
[
i
]
=
(
l
-
pred
)
&
mask
;
}
*
left
=
l
;
*
left_top
=
lt
;
}
}
static
int
store_table
(
HYuvContext
*
s
,
const
uint8_t
*
len
,
uint8_t
*
buf
)
{
int
i
;
...
...
@@ -857,7 +884,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
for
(;
y
<
h
;
y
++
)
{
uint8_t
*
dst
=
p
->
data
[
plane
]
+
p
->
linesize
[
plane
]
*
y
;
s
->
dsp
.
sub_hfyu_median_prediction
(
s
->
temp
[
0
],
dst
-
fake_stride
,
dst
,
w
,
&
left
,
&
lefttop
);
s
ub_median_prediction
(
s
,
s
->
temp
[
0
],
dst
-
fake_stride
,
dst
,
w
,
&
left
,
&
lefttop
);
encode_plane_bitstream
(
s
,
w
,
plane
);
}
...
...
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