From 512f3ffe9b4bb86767c2b1176554407c75fe1a5c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 23 Dec 2013 18:42:11 +0100 Subject: dsputil: Split off HuffYUV encoding bits into their own context Also shorten HuffYUV context member names to avoid clutter. --- libavcodec/huffyuvenc.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'libavcodec/huffyuvenc.c') diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 1442b753de..b401a9542a 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -29,6 +29,7 @@ #include "avcodec.h" #include "huffyuv.h" #include "huffman.h" +#include "huffyuvencdsp.h" #include "put_bits.h" static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst, @@ -48,7 +49,7 @@ static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst, dst[i] = temp - left; left = temp; } - s->dsp.diff_bytes(dst + 16, src + 16, src + 15, w - 16); + s->hencdsp.diff_bytes(dst + 16, src + 16, src + 15, w - 16); return src[w-1]; } } @@ -80,7 +81,7 @@ static inline void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst, a = at; } - s->dsp.diff_bytes(dst + 16, src + 16, src + 12, w * 4 - 16); + s->hencdsp.diff_bytes(dst + 16, src + 16, src + 12, w * 4 - 16); *red = src[(w - 1) * 4 + R]; *green = src[(w - 1) * 4 + G]; @@ -109,7 +110,7 @@ static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst, b = bt; } - s->dsp.diff_bytes(dst + 48, src + 48, src + 48 - 3, w * 3 - 48); + s->hencdsp.diff_bytes(dst + 48, src + 48, src + 48 - 3, w * 3 - 48); *red = src[(w - 1) * 3 + 0]; *green = src[(w - 1) * 3 + 1]; @@ -146,6 +147,7 @@ static av_cold int encode_init(AVCodecContext *avctx) int i, j; ff_huffyuv_common_init(avctx); + ff_huffyuvencdsp_init(&s->hencdsp); avctx->extradata = av_mallocz(1024*30); // 256*3+4 == 772 avctx->stats_out = av_mallocz(1024*30); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132 @@ -503,9 +505,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, lefttopy = p->data[0][3]; lefttopu = p->data[1][1]; lefttopv = p->data[2][1]; - s->dsp.sub_hfyu_median_prediction(s->temp[0], p->data[0]+4, p->data[0] + fake_ystride + 4, width - 4 , &lefty, &lefttopy); - s->dsp.sub_hfyu_median_prediction(s->temp[1], p->data[1]+2, p->data[1] + fake_ustride + 2, width2 - 2, &leftu, &lefttopu); - s->dsp.sub_hfyu_median_prediction(s->temp[2], p->data[2]+2, p->data[2] + fake_vstride + 2, width2 - 2, &leftv, &lefttopv); + s->hencdsp.sub_hfyu_median_pred(s->temp[0], p->data[0] + 4, p->data[0] + fake_ystride + 4, width - 4, &lefty, &lefttopy); + s->hencdsp.sub_hfyu_median_pred(s->temp[1], p->data[1] + 2, p->data[1] + fake_ustride + 2, width2 - 2, &leftu, &lefttopu); + s->hencdsp.sub_hfyu_median_pred(s->temp[2], p->data[2] + 2, p->data[2] + fake_vstride + 2, width2 - 2, &leftv, &lefttopv); encode_422_bitstream(s, 0, width - 4); y++; cy++; @@ -515,7 +517,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (s->bitstream_bpp == 12) { while (2 * cy > y) { ydst = p->data[0] + p->linesize[0] * y; - s->dsp.sub_hfyu_median_prediction(s->temp[0], ydst - fake_ystride, ydst, width , &lefty, &lefttopy); + s->hencdsp.sub_hfyu_median_pred(s->temp[0], ydst - fake_ystride, ydst, width, &lefty, &lefttopy); encode_gray_bitstream(s, width); y++; } @@ -525,9 +527,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, udst = p->data[1] + p->linesize[1] * cy; vdst = p->data[2] + p->linesize[2] * cy; - s->dsp.sub_hfyu_median_prediction(s->temp[0], ydst - fake_ystride, ydst, width , &lefty, &lefttopy); - s->dsp.sub_hfyu_median_prediction(s->temp[1], udst - fake_ustride, udst, width2, &leftu, &lefttopu); - s->dsp.sub_hfyu_median_prediction(s->temp[2], vdst - fake_vstride, vdst, width2, &leftv, &lefttopv); + s->hencdsp.sub_hfyu_median_pred(s->temp[0], ydst - fake_ystride, ydst, width, &lefty, &lefttopy); + s->hencdsp.sub_hfyu_median_pred(s->temp[1], udst - fake_ustride, udst, width2, &leftu, &lefttopu); + s->hencdsp.sub_hfyu_median_pred(s->temp[2], vdst - fake_vstride, vdst, width2, &leftv, &lefttopv); encode_422_bitstream(s, 0, width); } @@ -540,7 +542,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, ydst = p->data[0] + p->linesize[0] * y; if (s->predictor == PLANE && s->interlaced < y) { - s->dsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width); + s->hencdsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width); lefty = sub_left_prediction(s, s->temp[0], s->temp[1], width , lefty); } else { @@ -556,9 +558,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, vdst = p->data[2] + p->linesize[2] * cy; if (s->predictor == PLANE && s->interlaced < cy) { - s->dsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width); - s->dsp.diff_bytes(s->temp[2], udst, udst - fake_ustride, width2); - s->dsp.diff_bytes(s->temp[2] + width2, vdst, vdst - fake_vstride, width2); + s->hencdsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width); + s->hencdsp.diff_bytes(s->temp[2], udst, udst - fake_ustride, width2); + s->hencdsp.diff_bytes(s->temp[2] + width2, vdst, vdst - fake_vstride, width2); lefty = sub_left_prediction(s, s->temp[0], s->temp[1], width , lefty); leftu = sub_left_prediction(s, s->temp[1], s->temp[2], width2, leftu); @@ -591,7 +593,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, for (y = 1; y < s->height; y++) { uint8_t *dst = data + y*stride; if (s->predictor == PLANE && s->interlaced < y) { - s->dsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width * 4); + s->hencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width * 4); sub_left_prediction_bgr32(s, s->temp[0], s->temp[1], width, &leftr, &leftg, &leftb, &lefta); } else { @@ -619,8 +621,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, for (y = 1; y < s->height; y++) { uint8_t *dst = data + y * stride; if (s->predictor == PLANE && s->interlaced < y) { - s->dsp.diff_bytes(s->temp[1], dst, dst - fake_stride, - width * 3); + s->hencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, + width * 3); sub_left_prediction_rgb24(s, s->temp[0], s->temp[1], width, &leftr, &leftg, &leftb); } else { -- cgit v1.2.3