summaryrefslogtreecommitdiff
path: root/libavcodec/huffyuvenc.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-01-07 23:13:48 -0300
committerJames Almer <jamrial@gmail.com>2017-01-12 22:53:04 -0300
commitcf9ef839606dd50f779c395d8a277de143f7e5b2 (patch)
tree615bcdf1fc268c6ef0b3cc75273ca08aff8254bd /libavcodec/huffyuvenc.c
parent30c1f27299d3fc2b0c0858c003066cc5e36a28af (diff)
huffyuvencdsp: move shared functions to a new lossless_videoencdsp context
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/huffyuvenc.c')
-rw-r--r--libavcodec/huffyuvenc.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index f5bc99f196..89639b75df 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -33,6 +33,7 @@
#include "huffman.h"
#include "huffyuvencdsp.h"
#include "internal.h"
+#include "lossless_videoencdsp.h"
#include "put_bits.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
@@ -41,7 +42,7 @@ static inline void diff_bytes(HYuvContext *s, uint8_t *dst,
const uint8_t *src0, const uint8_t *src1, int w)
{
if (s->bps <= 8) {
- s->hencdsp.diff_bytes(dst, src0, src1, w);
+ s->llvidencdsp.diff_bytes(dst, src0, src1, w);
} else {
s->hencdsp.diff_int16((uint16_t *)dst, (const uint16_t *)src0, (const uint16_t *)src1, s->n - 1, w);
}
@@ -65,7 +66,7 @@ static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst,
dst[i] = temp - left;
left = temp;
}
- s->hencdsp.diff_bytes(dst + 32, src + 32, src + 31, w - 32);
+ s->llvidencdsp.diff_bytes(dst + 32, src + 32, src + 31, w - 32);
return src[w-1];
}
} else {
@@ -117,7 +118,7 @@ static inline void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst,
a = at;
}
- s->hencdsp.diff_bytes(dst + 16, src + 16, src + 12, w * 4 - 16);
+ s->llvidencdsp.diff_bytes(dst + 16, src + 16, src + 12, w * 4 - 16);
*red = src[(w - 1) * 4 + R];
*green = src[(w - 1) * 4 + G];
@@ -146,7 +147,7 @@ static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst,
b = bt;
}
- s->hencdsp.diff_bytes(dst + 48, src + 48, src + 48 - 3, w * 3 - 48);
+ s->llvidencdsp.diff_bytes(dst + 48, src + 48, src + 48 - 3, w * 3 - 48);
*red = src[(w - 1) * 3 + 0];
*green = src[(w - 1) * 3 + 1];
@@ -156,7 +157,7 @@ static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst,
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->hencdsp.sub_hfyu_median_pred(dst, src1, src2, w , left, left_top);
+ s->llvidencdsp.sub_median_pred(dst, src1, src2, w , left, left_top);
} else {
s->hencdsp.sub_hfyu_median_pred_int16((uint16_t *)dst, (const uint16_t *)src1, (const uint16_t *)src2, s->n - 1, w , left, left_top);
}
@@ -218,6 +219,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
ff_huffyuv_common_init(avctx);
ff_huffyuvencdsp_init(&s->hencdsp, avctx);
+ ff_llvidencdsp_init(&s->llvidencdsp);
avctx->extradata = av_mallocz(3*MAX_N + 4);
if (s->flags&AV_CODEC_FLAG_PASS1) {
@@ -823,9 +825,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->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);
+ s->llvidencdsp.sub_median_pred(s->temp[0], p->data[0] + 4, p->data[0] + fake_ystride + 4, width - 4, &lefty, &lefttopy);
+ s->llvidencdsp.sub_median_pred(s->temp[1], p->data[1] + 2, p->data[1] + fake_ustride + 2, width2 - 2, &leftu, &lefttopu);
+ s->llvidencdsp.sub_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++;
@@ -835,7 +837,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->hencdsp.sub_hfyu_median_pred(s->temp[0], ydst - fake_ystride, ydst, width, &lefty, &lefttopy);
+ s->llvidencdsp.sub_median_pred(s->temp[0], ydst - fake_ystride, ydst, width, &lefty, &lefttopy);
encode_gray_bitstream(s, width);
y++;
}
@@ -845,9 +847,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->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);
+ s->llvidencdsp.sub_median_pred(s->temp[0], ydst - fake_ystride, ydst, width, &lefty, &lefttopy);
+ s->llvidencdsp.sub_median_pred(s->temp[1], udst - fake_ustride, udst, width2, &leftu, &lefttopu);
+ s->llvidencdsp.sub_median_pred(s->temp[2], vdst - fake_vstride, vdst, width2, &leftv, &lefttopv);
encode_422_bitstream(s, 0, width);
}
@@ -860,7 +862,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->hencdsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width);
+ s->llvidencdsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width);
lefty = sub_left_prediction(s, s->temp[0], s->temp[1], width , lefty);
} else {
@@ -876,9 +878,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->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);
+ s->llvidencdsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width);
+ s->llvidencdsp.diff_bytes(s->temp[2], udst, udst - fake_ustride, width2);
+ s->llvidencdsp.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);
@@ -911,7 +913,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->hencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width * 4);
+ s->llvidencdsp.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 {
@@ -939,7 +941,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->hencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride,
+ s->llvidencdsp.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);