Commit c1e7fb60 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'c065f4a0'

* commit 'c065f4a0':
  huffyuv: K&R formatting cosmetics

Conflicts:
	libavcodec/huffyuvdec.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 2aeeb3ba c065f4a0
......@@ -41,17 +41,18 @@
#define classic_shift_luma_table_size 42
static const unsigned char classic_shift_luma[classic_shift_luma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = {
34,36,35,69,135,232,9,16,10,24,11,23,12,16,13,10,14,8,15,8,
16,8,17,20,16,10,207,206,205,236,11,8,10,21,9,23,8,8,199,70,
69,68, 0,
34, 36, 35, 69, 135, 232, 9, 16, 10, 24, 11, 23, 12, 16, 13, 10,
14, 8, 15, 8, 16, 8, 17, 20, 16, 10, 207, 206, 205, 236, 11, 8,
10, 21, 9, 23, 8, 8, 199, 70, 69, 68, 0,
0,0,0,0,0,0,0,0,
};
#define classic_shift_chroma_table_size 59
static const unsigned char classic_shift_chroma[classic_shift_chroma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = {
66,36,37,38,39,40,41,75,76,77,110,239,144,81,82,83,84,85,118,183,
56,57,88,89,56,89,154,57,58,57,26,141,57,56,58,57,58,57,184,119,
214,245,116,83,82,49,80,79,78,77,44,75,41,40,39,38,37,36,34, 0,
66, 36, 37, 38, 39, 40, 41, 75, 76, 77, 110, 239, 144, 81, 82, 83,
84, 85, 118, 183, 56, 57, 88, 89, 56, 89, 154, 57, 58, 57, 26, 141,
57, 56, 58, 57, 58, 57, 184, 119, 214, 245, 116, 83, 82, 49, 80, 79,
78, 77, 44, 75, 41, 40, 39, 38, 37, 36, 34, 0,
0,0,0,0,0,0,0,0,
};
......@@ -78,16 +79,16 @@ static const unsigned char classic_add_chroma[256] = {
3, 1, 2, 2, 2, 2, 3, 3, 7, 5, 7, 5, 8, 6, 11, 9,
7, 13, 11, 10, 9, 8, 7, 5, 9, 7, 6, 4, 7, 5, 8, 7,
11, 8, 13, 11, 19, 15, 22, 23, 20, 33, 32, 28, 27, 29, 51, 77,
43, 45, 76, 81, 46, 82, 75, 55, 56,144, 58, 80, 60, 74,147, 63,
43, 45, 76, 81, 46, 82, 75, 55, 56, 144, 58, 80, 60, 74, 147, 63,
143, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 27, 30, 21, 22,
17, 14, 5, 6,100, 54, 47, 50, 51, 53,106,107,108,109,110,111,
112,113,114,115, 4,117,118, 92, 94,121,122, 3,124,103, 2, 1,
0,129,130,131,120,119,126,125,136,137,138,139,140,141,142,134,
135,132,133,104, 64,101, 62, 57,102, 95, 93, 59, 61, 28, 97, 96,
17, 14, 5, 6, 100, 54, 47, 50, 51, 53, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 4, 117, 118, 92, 94, 121, 122, 3, 124, 103, 2, 1,
0, 129, 130, 131, 120, 119, 126, 125, 136, 137, 138, 139, 140, 141, 142, 134,
135, 132, 133, 104, 64, 101, 62, 57, 102, 95, 93, 59, 61, 28, 97, 96,
52, 49, 48, 29, 32, 25, 24, 46, 23, 98, 45, 44, 43, 20, 42, 41,
19, 18, 99, 40, 15, 39, 38, 16, 13, 12, 11, 37, 10, 9, 8, 36,
7,128,127,105,123,116, 35, 34, 33,145, 31, 79, 42,146, 78, 26,
7, 128, 127, 105, 123, 116, 35, 34, 33, 145, 31, 79, 42, 146, 78, 26,
83, 48, 49, 50, 44, 47, 26, 31, 30, 18, 17, 19, 21, 24, 25, 13,
14, 16, 17, 18, 20, 21, 12, 14, 15, 9, 10, 6, 9, 6, 5, 8,
6, 12, 8, 10, 7, 9, 6, 4, 6, 2, 2, 3, 3, 3, 3, 2,
......@@ -126,15 +127,15 @@ static int generate_joint_tables(HYuvContext *s)
for (i = y = 0; y < s->vlc_n; y++) {
int len0 = s->len[p0][y];
int limit = VLC_BITS - len0;
if(limit <= 0 || !len0)
if (limit <= 0 || !len0)
continue;
if((sign_extend(y, 8) & (s->vlc_n-1)) != y)
if ((sign_extend(y, 8) & (s->vlc_n-1)) != y)
continue;
for (u = 0; u < s->vlc_n; u++) {
int len1 = s->len[p][u];
if (len1 > limit || !len1)
continue;
if((sign_extend(u, 8) & (s->vlc_n-1)) != u)
if ((sign_extend(u, 8) & (s->vlc_n-1)) != u)
continue;
av_assert0(i < (1 << VLC_BITS));
len[i] = len0 + len1;
......@@ -149,13 +150,13 @@ static int generate_joint_tables(HYuvContext *s)
return ret;
}
} else {
uint8_t (*map)[4] = (uint8_t(*)[4])s->pix_bgr_map;
uint8_t (*map)[4] = (uint8_t(*)[4]) s->pix_bgr_map;
int i, b, g, r, code;
int p0 = s->decorrelate;
int p1 = !s->decorrelate;
// restrict the range to +/-16 because that's pretty much guaranteed to
// cover all the combinations that fit in 11 bits total, and it doesn't
// matter if we miss a few rare codes.
/* Restrict the range to +/-16 because that's pretty much guaranteed
* to cover all the combinations that fit in 11 bits total, and it
* does not matter if we miss a few rare codes. */
for (i = 0, g = -16; g < 16; g++) {
int len0 = s->len[p0][g & 255];
int limit0 = VLC_BITS - len0;
......@@ -209,9 +210,8 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length)
for (i = 0; i < count; i++) {
if (read_len_table(s->len[i], &gb, s->vlc_n) < 0)
return -1;
if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i], s->vlc_n) < 0) {
if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i], s->vlc_n) < 0)
return -1;
}
ff_free_vlc(&s->vlc[i]);
if ((ret = init_vlc(&s->vlc[i], VLC_BITS, s->vlc_n, s->len[i], 1, 1,
s->bits[i], 4, 4, 0)) < 0)
......@@ -240,15 +240,17 @@ static int read_old_huffman_tables(HYuvContext *s)
if (read_len_table(s->len[1], &gb, 256) < 0)
return -1;
for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i];
for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i];
for (i = 0; i < 256; i++)
s->bits[0][i] = classic_add_luma[i];
for (i = 0; i < 256; i++)
s->bits[1][i] = classic_add_chroma[i];
if (s->bitstream_bpp >= 24) {
memcpy(s->bits[1], s->bits[0], 256 * sizeof(uint32_t));
memcpy(s->len[1] , s->len [0], 256 * sizeof(uint8_t));
memcpy(s->len[1], s->len[0], 256 * sizeof(uint8_t));
}
memcpy(s->bits[2], s->bits[1], 256 * sizeof(uint32_t));
memcpy(s->len[2] , s->len [1], 256 * sizeof(uint8_t));
memcpy(s->len[2], s->len[1], 256 * sizeof(uint8_t));
for (i = 0; i < 4; i++) {
ff_free_vlc(&s->vlc[i]);
......@@ -271,7 +273,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
memset(s->vlc, 0, 4 * sizeof(VLC));
s->interlaced = avctx->height > 288;
s->bgr32 = 1;
if (avctx->extradata_size) {
......@@ -295,11 +296,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (avctx->extradata_size < 4)
return -1;
method = ((uint8_t*)avctx->extradata)[0];
method = ((uint8_t *) avctx->extradata)[0];
s->decorrelate = method & 64 ? 1 : 0;
s->predictor = method & 63;
if (s->version == 2) {
s->bitstream_bpp = ((uint8_t*)avctx->extradata)[1];
s->bitstream_bpp = ((uint8_t *) avctx->extradata)[1];
if (s->bitstream_bpp == 0)
s->bitstream_bpp = avctx->bits_per_coded_sample & ~7;
} else {
......@@ -308,18 +309,18 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->vlc_n = FFMIN(s->n, MAX_VLC_N);
s->chroma_h_shift = avctx->extradata[1] & 3;
s->chroma_v_shift = (avctx->extradata[1] >> 2) & 3;
s->yuv = !!(((uint8_t*)avctx->extradata)[2] & 1);
s->chroma= !!(((uint8_t*)avctx->extradata)[2] & 3);
s->alpha = !!(((uint8_t*)avctx->extradata)[2] & 4);
s->yuv = !!(((uint8_t *) avctx->extradata)[2] & 1);
s->chroma= !!(((uint8_t *) avctx->extradata)[2] & 3);
s->alpha = !!(((uint8_t *) avctx->extradata)[2] & 4);
}
interlace = (((uint8_t*)avctx->extradata)[2] & 0x30) >> 4;
interlace = (((uint8_t *) avctx->extradata)[2] & 0x30) >> 4;
s->interlaced = (interlace == 1) ? 1 : (interlace == 2) ? 0 : s->interlaced;
s->context = ((uint8_t*)avctx->extradata)[2] & 0x40 ? 1 : 0;
s->context = ((uint8_t *) avctx->extradata)[2] & 0x40 ? 1 : 0;
if ( read_huffman_tables(s, ((uint8_t*)avctx->extradata) + 4,
if (read_huffman_tables(s, ((uint8_t *) avctx->extradata) + 4,
avctx->extradata_size - 4) < 0)
return AVERROR_INVALIDDATA;
}else{
} else {
switch (avctx->bits_per_coded_sample & 7) {
case 1:
s->predictor = LEFT;
......@@ -338,7 +339,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->decorrelate = 0;
break;
default:
s->predictor = LEFT; //OLD
s->predictor = LEFT; // OLD
s->decorrelate = 0;
break;
}
......@@ -356,19 +357,17 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->yuv = 1;
break;
case 16:
if (s->yuy2) {
if (s->yuy2)
avctx->pix_fmt = AV_PIX_FMT_YUYV422;
} else {
else
avctx->pix_fmt = AV_PIX_FMT_YUV422P;
}
s->yuv = 1;
break;
case 24:
if (s->bgr32) {
if (s->bgr32)
avctx->pix_fmt = AV_PIX_FMT_0RGB32;
} else {
else
avctx->pix_fmt = AV_PIX_FMT_BGR24;
}
break;
case 32:
av_assert0(s->bgr32);
......@@ -549,7 +548,7 @@ static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
s->vlc[i].table = NULL;
if (s->version >= 2) {
if (read_huffman_tables(s, ((uint8_t*)avctx->extradata) + 4,
if (read_huffman_tables(s, ((uint8_t *) avctx->extradata) + 4,
avctx->extradata_size) < 0)
return AVERROR_INVALIDDATA;
} else {
......@@ -608,7 +607,7 @@ static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
#define OP8bits(dst0, dst1, code) dst0 = code>>8; dst1 = code
#define READ_2PIX(dst0, dst1, plane1)\
#define READ_2PIX(dst0, dst1, plane1) \
UPDATE_CACHE(re, &s->gb); \
GET_VLC_DUAL(dst0, dst1, re, &s->gb, s->vlc[4+plane1].table, \
s->vlc[0].table, s->vlc[plane1].table, VLC_BITS, 3, OP8bits)
......@@ -622,7 +621,7 @@ static void decode_422_bitstream(HYuvContext *s, int count)
icount = get_bits_left(&s->gb) / (32 * 4);
if (count >= icount) {
for (i = 0; i < icount; i++) {
READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1);
READ_2PIX(s->temp[0][2 * i], s->temp[1][i], 1);
READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2);
}
for (; i < count && get_bits_left(&s->gb) > 0; i++) {
......@@ -635,7 +634,7 @@ static void decode_422_bitstream(HYuvContext *s, int count)
s->temp[0][2 * i + 1] = s->temp[2][i] = 0;
} else {
for (i = 0; i < count; i++) {
READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1);
READ_2PIX(s->temp[0][2 * i], s->temp[1][i], 1);
READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2);
}
}
......@@ -661,7 +660,7 @@ static void decode_plane_bitstream(HYuvContext *s, int count, int plane)
{
int i;
count/=2;
count /= 2;
if (s->bps <= 8) {
OPEN_READER(re, &s->gb);
......@@ -704,14 +703,14 @@ static void decode_gray_bitstream(HYuvContext *s, int count)
{
int i;
OPEN_READER(re, &s->gb);
count/=2;
count /= 2;
if (count >= (get_bits_left(&s->gb)) / (32 * 2)) {
for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
READ_2PIX(s->temp[0][2 * i], s->temp[0][2 * i + 1], 0);
}
} else {
for(i=0; i<count; i++){
for (i = 0; i < count; i++) {
READ_2PIX(s->temp[0][2 * i], s->temp[0][2 * i + 1], 0);
}
}
......@@ -734,11 +733,11 @@ static av_always_inline void decode_bgr_1(HYuvContext *s, int count,
if (n>0) {
code = s->vlc[4].table[index][0];
*(uint32_t*)&s->temp[0][4 * i] = s->pix_bgr_map[code];
*(uint32_t *) &s->temp[0][4 * i] = s->pix_bgr_map[code];
LAST_SKIP_BITS(re, &s->gb, n);
} else {
int nb_bits;
if(decorrelate) {
if (decorrelate) {
VLC_INTERN(s->temp[0][4 * i + G], s->vlc[1].table,
&s->gb, re, VLC_BITS, 3);
......@@ -780,12 +779,12 @@ static av_always_inline void decode_bgr_1(HYuvContext *s, int count,
static void decode_bgr_bitstream(HYuvContext *s, int count)
{
if (s->decorrelate) {
if (s->bitstream_bpp==24)
if (s->bitstream_bpp == 24)
decode_bgr_1(s, count, 1, 0);
else
decode_bgr_1(s, count, 1, 1);
} else {
if (s->bitstream_bpp==24)
if (s->bitstream_bpp == 24)
decode_bgr_1(s, count, 0, 0);
else
decode_bgr_1(s, count, 0, 1);
......@@ -797,17 +796,16 @@ static void draw_slice(HYuvContext *s, AVFrame *frame, int y)
int h, cy, i;
int offset[AV_NUM_DATA_POINTERS];
if (s->avctx->draw_horiz_band==NULL)
if (s->avctx->draw_horiz_band == NULL)
return;
h = y - s->last_slice_end;
y -= h;
if (s->bitstream_bpp == 12) {
cy = y>>1;
} else {
if (s->bitstream_bpp == 12)
cy = y >> 1;
else
cy = y;
}
offset[0] = frame->linesize[0] * y;
offset[1] = frame->linesize[1] * cy;
......@@ -854,11 +852,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
int buf_size = avpkt->size;
HYuvContext *s = avctx->priv_data;
const int width = s->width;
const int width2 = s->width>>1;
const int width2 = s->width >> 1;
const int height = s->height;
int fake_ystride, fake_ustride, fake_vstride;
ThreadFrame frame = { .f = data };
AVFrame * const p = data;
AVFrame *const p = data;
int table_size = 0, ret;
av_fast_padded_malloc(&s->bitstream_buffer,
......@@ -879,11 +877,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return AVERROR_INVALIDDATA;
}
if ((unsigned)(buf_size-table_size) >= INT_MAX / 8)
if ((unsigned) (buf_size - table_size) >= INT_MAX / 8)
return AVERROR_INVALIDDATA;
init_get_bits(&s->gb, s->bitstream_buffer+table_size,
(buf_size-table_size) * 8);
init_get_bits(&s->gb, s->bitstream_buffer + table_size,
(buf_size - table_size) * 8);
fake_ystride = s->interlaced ? p->linesize[0] * 2 : p->linesize[0];
fake_ustride = s->interlaced ? p->linesize[1] * 2 : p->linesize[1];
......@@ -971,18 +969,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
"YUY2 output is not implemented yet\n");
return AVERROR_PATCHWELCOME;
} else {
leftv = p->data[2][0] = get_bits(&s->gb, 8);
lefty = p->data[0][1] = get_bits(&s->gb, 8);
leftu = p->data[1][0] = get_bits(&s->gb, 8);
leftv =
p->data[2][0] = get_bits(&s->gb, 8);
lefty =
p->data[0][1] = get_bits(&s->gb, 8);
leftu =
p->data[1][0] = get_bits(&s->gb, 8);
p->data[0][0] = get_bits(&s->gb, 8);
switch (s->predictor) {
case LEFT:
case PLANE:
decode_422_bitstream(s, width-2);
lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + 2, s->temp[0], width - 2, lefty);
if (!(s->flags&CODEC_FLAG_GRAY)) {
decode_422_bitstream(s, width - 2);
lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + 2, s->temp[0],
width - 2, lefty);
if (!(s->flags & CODEC_FLAG_GRAY)) {
leftu = s->hdsp.add_hfyu_left_pred(p->data[1] + 1, s->temp[1], width2 - 1, leftu);
leftv = s->hdsp.add_hfyu_left_pred(p->data[2] + 1, s->temp[2], width2 - 1, leftv);
}
......@@ -995,23 +996,26 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
ydst = p->data[0] + p->linesize[0] * y;
lefty = s->hdsp.add_hfyu_left_pred(ydst, s->temp[0], width, lefty);
lefty = s->hdsp.add_hfyu_left_pred(ydst, s->temp[0],
width, lefty);
if (s->predictor == PLANE) {
if (y > s->interlaced)
s->hdsp.add_bytes(ydst, ydst - fake_ystride, width);
}
y++;
if (y >= s->height) break;
if (y >= s->height)
break;
}
draw_slice(s, p, y);
ydst = p->data[0] + p->linesize[0]*y;
udst = p->data[1] + p->linesize[1]*cy;
vdst = p->data[2] + p->linesize[2]*cy;
ydst = p->data[0] + p->linesize[0] * y;
udst = p->data[1] + p->linesize[1] * cy;
vdst = p->data[2] + p->linesize[2] * cy;
decode_422_bitstream(s, width);
lefty = s->hdsp.add_hfyu_left_pred(ydst, s->temp[0], width, lefty);
lefty = s->hdsp.add_hfyu_left_pred(ydst, s->temp[0],
width, lefty);
if (!(s->flags & CODEC_FLAG_GRAY)) {
leftu = s->hdsp.add_hfyu_left_pred(udst, s->temp[1], width2, leftu);
leftv = s->hdsp.add_hfyu_left_pred(vdst, s->temp[2], width2, leftv);
......@@ -1032,7 +1036,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
case MEDIAN:
/* first line except first 2 pixels is left predicted */
decode_422_bitstream(s, width - 2);
lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + 2, s->temp[0], width - 2, lefty);
lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + 2, s->temp[0],
width - 2, lefty);
if (!(s->flags & CODEC_FLAG_GRAY)) {
leftu = s->hdsp.add_hfyu_left_pred(p->data[1] + 1, s->temp[1], width2 - 1, leftu);
leftv = s->hdsp.add_hfyu_left_pred(p->data[2] + 1, s->temp[2], width2 - 1, leftv);
......@@ -1043,18 +1048,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
/* second line is left predicted for interlaced case */
if (s->interlaced) {
decode_422_bitstream(s, width);
lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + p->linesize[0], s->temp[0], width, lefty);
lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + p->linesize[0],
s->temp[0], width, lefty);
if (!(s->flags & CODEC_FLAG_GRAY)) {
leftu = s->hdsp.add_hfyu_left_pred(p->data[1] + p->linesize[2], s->temp[1], width2, leftu);
leftv = s->hdsp.add_hfyu_left_pred(p->data[2] + p->linesize[1], s->temp[2], width2, leftv);
}
y++; cy++;
y++;
cy++;
}
/* next 4 pixels are left predicted too */
decode_422_bitstream(s, 4);
lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + fake_ystride, s->temp[0], 4, lefty);
if (!(s->flags&CODEC_FLAG_GRAY)) {
lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + fake_ystride,
s->temp[0], 4, lefty);
if (!(s->flags & CODEC_FLAG_GRAY)) {
leftu = s->hdsp.add_hfyu_left_pred(p->data[1] + fake_ustride, s->temp[1], 2, leftu);
leftv = s->hdsp.add_hfyu_left_pred(p->data[2] + fake_vstride, s->temp[2], 2, leftv);
}
......@@ -1062,26 +1070,32 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
/* next line except the first 4 pixels is median predicted */
lefttopy = p->data[0][3];
decode_422_bitstream(s, width - 4);
s->hdsp.add_hfyu_median_pred(p->data[0] + fake_ystride + 4, p->data[0] + 4, s->temp[0], width - 4, &lefty, &lefttopy);
if (!(s->flags&CODEC_FLAG_GRAY)) {
s->hdsp.add_hfyu_median_pred(p->data[0] + fake_ystride + 4,
p->data[0] + 4, s->temp[0],
width - 4, &lefty, &lefttopy);
if (!(s->flags & CODEC_FLAG_GRAY)) {
lefttopu = p->data[1][1];
lefttopv = p->data[2][1];
s->hdsp.add_hfyu_median_pred(p->data[1] + fake_ustride + 2, p->data[1] + 2, s->temp[1], width2 - 2, &leftu, &lefttopu);
s->hdsp.add_hfyu_median_pred(p->data[2] + fake_vstride + 2, p->data[2] + 2, s->temp[2], width2 - 2, &leftv, &lefttopv);
}
y++; cy++;
y++;
cy++;
for (; y<height; y++, cy++) {
for (; y < height; y++, cy++) {
uint8_t *ydst, *udst, *vdst;
if (s->bitstream_bpp == 12) {
while (2 * cy > y) {
decode_gray_bitstream(s, width);
ydst = p->data[0] + p->linesize[0] * y;
s->hdsp.add_hfyu_median_pred(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy);
s->hdsp.add_hfyu_median_pred(ydst, ydst - fake_ystride,
s->temp[0], width,
&lefty, &lefttopy);
y++;
}
if (y >= height) break;
if (y >= height)
break;
}
draw_slice(s, p, y);
......@@ -1091,7 +1105,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
udst = p->data[1] + p->linesize[1] * cy;
vdst = p->data[2] + p->linesize[2] * cy;
s->hdsp.add_hfyu_median_pred(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy);
s->hdsp.add_hfyu_median_pred(ydst, ydst - fake_ystride,
s->temp[0], width,
&lefty, &lefttopy);
if (!(s->flags & CODEC_FLAG_GRAY)) {
s->hdsp.add_hfyu_median_pred(udst, udst - fake_ustride, s->temp[1], width2, &leftu, &lefttopu);
s->hdsp.add_hfyu_median_pred(vdst, vdst - fake_vstride, s->temp[2], width2, &leftv, &lefttopv);
......@@ -1108,15 +1124,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
const int last_line = (height - 1) * p->linesize[0];
if (s->bitstream_bpp == 32) {
left[A] = p->data[0][last_line+A] = get_bits(&s->gb, 8);
left[R] = p->data[0][last_line+R] = get_bits(&s->gb, 8);
left[G] = p->data[0][last_line+G] = get_bits(&s->gb, 8);
left[B] = p->data[0][last_line+B] = get_bits(&s->gb, 8);
left[A] = p->data[0][last_line + A] = get_bits(&s->gb, 8);
left[R] = p->data[0][last_line + R] = get_bits(&s->gb, 8);
left[G] = p->data[0][last_line + G] = get_bits(&s->gb, 8);
left[B] = p->data[0][last_line + B] = get_bits(&s->gb, 8);
} else {
left[R] = p->data[0][last_line+R] = get_bits(&s->gb, 8);
left[G] = p->data[0][last_line+G] = get_bits(&s->gb, 8);
left[B] = p->data[0][last_line+B] = get_bits(&s->gb, 8);
left[A] = p->data[0][last_line+A] = 255;
left[R] = p->data[0][last_line + R] = get_bits(&s->gb, 8);
left[G] = p->data[0][last_line + G] = get_bits(&s->gb, 8);
left[B] = p->data[0][last_line + B] = get_bits(&s->gb, 8);
left[A] = p->data[0][last_line + A] = 255;
skip_bits(&s->gb, 8);
}
......@@ -1125,14 +1141,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
case LEFT:
case PLANE:
decode_bgr_bitstream(s, width - 1);
s->hdsp.add_hfyu_left_pred_bgr32(p->data[0] + last_line + 4, s->temp[0], width - 1, left);
s->hdsp.add_hfyu_left_pred_bgr32(p->data[0] + last_line + 4,
s->temp[0], width - 1, left);
for (y = s->height - 2; y >= 0; y--) { //Yes it is stored upside down.
for (y = s->height - 2; y >= 0; y--) { // Yes it is stored upside down.
decode_bgr_bitstream(s, width);
s->hdsp.add_hfyu_left_pred_bgr32(p->data[0] + p->linesize[0] * y, s->temp[0], width, left);
s->hdsp.add_hfyu_left_pred_bgr32(p->data[0] + p->linesize[0] * y,
s->temp[0], width, left);
if (s->predictor == PLANE) {
if (s->bitstream_bpp != 32) left[A] = 0;
if (s->bitstream_bpp != 32)
left[A] = 0;
if ((y & s->interlaced) == 0 &&
y < s->height - 1 - s->interlaced) {
s->hdsp.add_bytes(p->data[0] + p->linesize[0] * y,
......@@ -1148,7 +1167,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
av_log(avctx, AV_LOG_ERROR,
"prediction type not supported!\n");
}
}else{
} else {
av_log(avctx, AV_LOG_ERROR,
"BGR24 output is not implemented yet\n");
return AVERROR_PATCHWELCOME;
......@@ -1169,9 +1188,8 @@ static av_cold int decode_end(AVCodecContext *avctx)
ff_huffyuv_common_end(s);
av_freep(&s->bitstream_buffer);
for (i = 0; i < 8; i++) {
for (i = 0; i < 8; i++)
ff_free_vlc(&s->vlc[i]);
}
return 0;
}
......@@ -1204,4 +1222,4 @@ AVCodec ff_ffvhuff_decoder = {
CODEC_CAP_FRAME_THREADS,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
};
#endif
#endif /* CONFIG_FFVHUFF_DECODER */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment