Skip to content

Commit 12ad68b

Browse files
committed
utvideoenc: use dsp.sub_hfyu_median_prediction
Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
1 parent 729b2d0 commit 12ad68b

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

libavcodec/utvideoenc.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static void left_predict(uint8_t *src, uint8_t *dst, int stride,
262262
}
263263

264264
/* Write data to a plane with median prediction */
265-
static void median_predict(uint8_t *src, uint8_t *dst, int stride,
265+
static void median_predict(UtvideoContext *c, uint8_t *src, uint8_t *dst, int stride,
266266
int width, int height)
267267
{
268268
int i, j;
@@ -285,26 +285,12 @@ static void median_predict(uint8_t *src, uint8_t *dst, int stride,
285285
* Second line uses top prediction for the first sample,
286286
* and median for the rest.
287287
*/
288-
C = src[-stride];
289-
*dst++ = src[0] - C;
290-
A = src[0];
291-
for (i = 1; i < width; i++) {
292-
B = src[i - stride];
293-
*dst++ = src[i] - mid_pred(A, B, (A + B - C) & 0xFF);
294-
C = B;
295-
A = src[i];
296-
}
297-
298-
src += stride;
288+
A = C = 0;
299289

300290
/* Rest of the coded part uses median prediction */
301-
for (j = 2; j < height; j++) {
302-
for (i = 0; i < width; i++) {
303-
B = src[i - stride];
304-
*dst++ = src[i] - mid_pred(A, B, (A + B - C) & 0xFF);
305-
C = B;
306-
A = src[i];
307-
}
291+
for (j = 1; j < height; j++) {
292+
c->dsp.sub_hfyu_median_prediction(dst, src - stride, src, width, &A, &C);
293+
dst += width;
308294
src += stride;
309295
}
310296
}
@@ -413,7 +399,7 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
413399
for (i = 0; i < c->slices; i++) {
414400
sstart = send;
415401
send = height * (i + 1) / c->slices;
416-
median_predict(src + sstart * stride, dst + sstart * width,
402+
median_predict(c, src + sstart * stride, dst + sstart * width,
417403
stride, width, send - sstart);
418404
}
419405
break;

0 commit comments

Comments
 (0)