static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) { GetBitContext gb; int i, ret; int count = 3; if ((ret = init_get_bits(&gb, src, length * 8)) < 0) return ret; if (s->version > 2) count = 1 + s->alpha + 2*s->chroma; for (i = 0; i < count; i++) { if ((ret = read_len_table(s->len[i], &gb, s->vlc_n)) < 0) return ret; if ((ret = ff_huffyuv_generate_bits_table(s->bits[i], s->len[i], s->vlc_n)) < 0) return ret; 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) return ret; } if ((ret = generate_joint_tables(s)) < 0) return ret; return (get_bits_count(&gb) + 7) / 8; }
static int read_old_huffman_tables(HYuvContext *s){ #if 1 GetBitContext gb; int i; init_get_bits(&gb, classic_shift_luma, classic_shift_luma_table_size*8); if(read_len_table(s->len[0], &gb)<0) return -1; init_get_bits(&gb, classic_shift_chroma, classic_shift_chroma_table_size*8); if(read_len_table(s->len[1], &gb)<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]; 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->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++){ ff_free_vlc(&s->vlc[i]); init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0); } generate_joint_tables(s); return 0; #else av_log(s->avctx, AV_LOG_DEBUG, "v1 huffyuv is not supported \n"); return -1; #endif }
static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) { GetBitContext gb; int i; int ret; init_get_bits(&gb, src, length * 8); for (i = 0; i < 3; 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) { return -1; } 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) return ret; } if ((ret = generate_joint_tables(s)) < 0) return ret; return (get_bits_count(&gb) + 7) / 8; }
static int read_huffman_tables(HYuvContext *s, uint8_t *src, int length){ GetBitContext gb; int i; init_get_bits(&gb, src, length*8); for(i=0; i<3; i++){ if(read_len_table(s->len[i], &gb)<0) return -1; if(generate_bits_table(s->bits[i], s->len[i])<0){ return -1; } #if 0 for(j=0; j<256; j++){ printf("%6X, %2d, %3d\n", s->bits[i][j], s->len[i][j], j); } #endif free_vlc(&s->vlc[i]); init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0); } generate_joint_tables(s); return (get_bits_count(&gb)+7)/8; }
static int read_old_huffman_tables(HYuvContext *s) { GetBitContext gb; int i, ret; if ((ret = init_get_bits(&gb, classic_shift_luma, classic_shift_luma_table_size * 8)) < 0) return ret; if ((ret = read_len_table(s->len[0], &gb)) < 0) return ret; if ((ret = init_get_bits(&gb, classic_shift_chroma, classic_shift_chroma_table_size * 8)) < 0) return ret; if ((ret = read_len_table(s->len[1], &gb)) < 0) return ret; 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->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++) { 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) return ret; } if ((ret = generate_joint_tables(s)) < 0) return ret; return 0; }