if (s->bitstream_bpp < 24 || s->version > 2) {
int p, i, y, u;
- for (p = 0; p < 3; p++) {
+ for (p = 0; p < 4; p++) {
int p0 = s->version > 2 ? p : 0;
for (i = y = 0; y < 256; y++) {
int len0 = s->len[p0][y];
i++;
}
}
- ff_free_vlc(&s->vlc[3 + p]);
- if ((ret = ff_init_vlc_sparse(&s->vlc[3 + p], VLC_BITS, i, len, 1, 1,
+ ff_free_vlc(&s->vlc[4 + p]);
+ if ((ret = ff_init_vlc_sparse(&s->vlc[4 + p], VLC_BITS, i, len, 1, 1,
bits, 2, 2, symbols, 2, 2, 0)) < 0)
return ret;
}
}
}
}
- ff_free_vlc(&s->vlc[3]);
- if ((ret = init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0)) < 0)
+ ff_free_vlc(&s->vlc[4]);
+ if ((ret = init_vlc(&s->vlc[4], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0)) < 0)
return ret;
}
return 0;
GetBitContext gb;
int i;
int ret;
+ int count = 3;
init_get_bits(&gb, src, length * 8);
- for (i = 0; i < 3; i++) {
+ if (s->version > 2)
+ count = 1 + s->alpha + 2*s->chroma;
+
+ for (i = 0; i < count; i++) {
if (read_len_table(s->len[i], &gb) < 0)
return -1;
if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i]) < 0) {
memcpy(s->bits[2], s->bits[1], 256 * sizeof(uint32_t));
memcpy(s->len[2] , s->len [1], 256 * sizeof(uint8_t));
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 4; i++) {
ff_free_vlc(&s->vlc[i]);
if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
s->bits[i], 4, 4, 0)) < 0)
HYuvContext *s = avctx->priv_data;
ff_huffyuv_common_init(avctx);
- memset(s->vlc, 0, 3 * sizeof(VLC));
+ memset(s->vlc, 0, 4 * sizeof(VLC));
s->interlaced = s->height > 288;
case 0x070:
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
break;
+ case 0x170:
+ avctx->pix_fmt = AV_PIX_FMT_GRAY8A;
+ break;
case 0x470:
avctx->pix_fmt = AV_PIX_FMT_GBRP;
break;
+ case 0x570:
+ avctx->pix_fmt = AV_PIX_FMT_GBRAP;
+ break;
case 0x670:
avctx->pix_fmt = AV_PIX_FMT_YUV444P;
break;
case 0x67A:
avctx->pix_fmt = AV_PIX_FMT_YUV410P;
break;
+ case 0x770:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
+ break;
+ case 0x771:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA422P;
+ break;
+ case 0x775:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA420P;
+ break;
}
}
return AVERROR(ENOMEM);
}
- for (i = 0; i < 6; i++)
+ for (i = 0; i < 8; i++)
s->vlc[i].table = NULL;
if (s->version >= 2) {
/* TODO instead of restarting the read when the code isn't in the first level
* of the joint table, jump into the 2nd level of the individual table. */
#define READ_2PIX(dst0, dst1, plane1){\
- uint16_t code = get_vlc2(&s->gb, s->vlc[3+plane1].table, VLC_BITS, 1);\
+ uint16_t code = get_vlc2(&s->gb, s->vlc[4+plane1].table, VLC_BITS, 1);\
if(code != 0xffff){\
dst0 = code>>8;\
dst1 = code;\
}
#define READ_2PIX_PLANE(dst0, dst1, plane){\
- uint16_t code = get_vlc2(&s->gb, s->vlc[3+plane].table, VLC_BITS, 1);\
+ uint16_t code = get_vlc2(&s->gb, s->vlc[4+plane].table, VLC_BITS, 1);\
if(code != 0xffff){\
dst0 = code>>8;\
dst1 = code;\
{
int i;
for (i = 0; i < count; i++) {
- int code = get_vlc2(&s->gb, s->vlc[3].table, VLC_BITS, 1);
+ int code = get_vlc2(&s->gb, s->vlc[4].table, VLC_BITS, 1);
if (code != -1) {
*(uint32_t*)&s->temp[0][4 * i] = s->pix_bgr_map[code];
} else if(decorrelate) {
ff_huffyuv_common_end(s);
av_freep(&s->bitstream_buffer);
- for (i = 0; i < 6; i++) {
+ for (i = 0; i < 8; i++) {
ff_free_vlc(&s->vlc[i]);
}
HYuvContext *s = avctx->priv_data;
int i, j;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ int extradata_tables;
ff_huffyuv_common_init(avctx);
case AV_PIX_FMT_YUV440P:
case AV_PIX_FMT_GBRP:
case AV_PIX_FMT_GRAY8:
+ case AV_PIX_FMT_YUVA444P:
+ case AV_PIX_FMT_YUVA420P:
+ case AV_PIX_FMT_YUVA422P:
+ case AV_PIX_FMT_GBRAP:
+ case AV_PIX_FMT_GRAY8A:
s->version = 3;
break;
case AV_PIX_FMT_RGB32:
return AVERROR(EINVAL);
}
+ extradata_tables = 1 + 2*s->chroma + s->alpha;
((uint8_t*)avctx->extradata)[0] = s->predictor | (s->decorrelate << 6);
((uint8_t*)avctx->extradata)[2] = s->interlaced ? 0x10 : 0x20;
if (s->context)
if (s->version < 3) {
((uint8_t*)avctx->extradata)[1] = s->bitstream_bpp;
((uint8_t*)avctx->extradata)[3] = 0;
+ extradata_tables = 3;
} else {
((uint8_t*)avctx->extradata)[1] = ((s->bps-1)<<4) | s->chroma_h_shift | (s->chroma_v_shift<<2);
if (s->chroma)
if (avctx->stats_in) {
char *p = avctx->stats_in;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 4; i++)
for (j = 0; j < 256; j++)
s->stats[i][j] = 1;
for (;;) {
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 4; i++) {
char *next;
for (j = 0; j < 256; j++) {
if (p[0] == 0 || p[1] == 0 || p[2] == 0) break;
}
} else {
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 4; i++)
for (j = 0; j < 256; j++) {
int d = FFMIN(j, 256 - j);
}
}
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < extradata_tables; i++) {
ff_huff_gen_len_table(s->len[i], s->stats[i]);
if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i]) < 0) {
}
if (s->context) {
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 4; i++) {
int pels = s->width * s->height / (i ? 40 : 10);
for (j = 0; j < 256; j++) {
int d = FFMIN(j, 256 - j);
}
}
} else {
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 4; i++)
for (j = 0; j < 256; j++)
s->stats[i][j]= 0;
}
return ret;
if (s->context) {
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 4; i++) {
ff_huff_gen_len_table(s->len[i], s->stats[i]);
if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i]) < 0)
return -1;
size += store_table(s, s->len[i], &pkt->data[size]);
}
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 4; i++)
for (j = 0; j < 256; j++)
s->stats[i][j] >>= 1;
}
int j;
char *p = avctx->stats_out;
char *end = p + 1024*30;
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 4; i++) {
for (j = 0; j < 256; j++) {
snprintf(p, end-p, "%"PRIu64" ", s->stats[i][j]);
p += strlen(p);
AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV440P,
AV_PIX_FMT_GBRP,
AV_PIX_FMT_GRAY8,
+ AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
+ AV_PIX_FMT_GBRAP,
+ AV_PIX_FMT_GRAY8A,
AV_PIX_FMT_RGB24,
AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE
},