52 |
|
|
53 |
#include "bitstream.h" |
#include "bitstream.h" |
54 |
#include "zigzag.h" |
#include "zigzag.h" |
55 |
|
#include "../quant/quant_matrix.h" |
56 |
|
|
57 |
static int __inline log2bin(int value) |
static int __inline log2bin(int value) |
58 |
{ |
{ |
79 |
}; |
}; |
80 |
|
|
81 |
|
|
82 |
|
void bs_get_matrix(Bitstream * bs, uint8_t * matrix) |
83 |
|
{ |
84 |
|
int i = 0; |
85 |
|
int last, value = 0; |
86 |
|
|
87 |
|
do |
88 |
|
{ |
89 |
|
last = value; |
90 |
|
value = BitstreamGetBits(bs, 8); |
91 |
|
matrix[ scan_tables[0][i++] ] = value; |
92 |
|
} |
93 |
|
while (value != 0 && i < 64); |
94 |
|
|
95 |
|
while (i < 64) |
96 |
|
{ |
97 |
|
matrix[ scan_tables[0][i++] ] = last; |
98 |
|
} |
99 |
|
} |
100 |
|
|
101 |
/* |
/* |
102 |
decode headers |
decode headers |
103 |
returns coding_type, or -1 if error |
returns coding_type, or -1 if error |
333 |
{ |
{ |
334 |
if (BitstreamGetBit(bs)) // load_intra_quant_mat |
if (BitstreamGetBit(bs)) // load_intra_quant_mat |
335 |
{ |
{ |
336 |
DEBUG("TODO: load_intra_quant_mat"); |
uint8_t *matrix; |
337 |
// TODO |
bs_get_matrix(bs, matrix); |
338 |
return -1; |
set_intra_matrix(matrix); |
339 |
} |
} |
340 |
|
|
341 |
if (BitstreamGetBit(bs)) // load_inter_quant_mat |
if (BitstreamGetBit(bs)) // load_inter_quant_mat |
342 |
{ |
{ |
343 |
DEBUG("TODO: load_inter_quant_mat"); |
uint8_t *matrix; |
344 |
// TODO |
bs_get_matrix(bs, matrix); |
345 |
return -1; |
set_inter_matrix(matrix); |
346 |
} |
} |
347 |
|
|
348 |
if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) |
if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) |
351 |
DEBUG("TODO: grayscale matrix stuff"); |
DEBUG("TODO: grayscale matrix stuff"); |
352 |
return -1; |
return -1; |
353 |
} |
} |
354 |
|
|
355 |
} |
} |
356 |
|
|
357 |
|
|
630 |
|
|
631 |
// quant_type 0=h.263 1=mpeg4(quantizer tables) |
// quant_type 0=h.263 1=mpeg4(quantizer tables) |
632 |
BitstreamPutBit(bs, quant_type); |
BitstreamPutBit(bs, quant_type); |
633 |
/* |
|
634 |
if (quant_type) |
if (quant_type) |
635 |
{ |
{ |
636 |
BitstreamPutBit(bs, qmatrix->custom_intra); // load_intra_quant_mat |
BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat |
637 |
if (qmatrix->custom_intra) |
if (get_intra_matrix_status()) |
638 |
{ |
{ |
639 |
bs_put_matrix(bs, qmatrix->intra); |
bs_put_matrix(bs, get_intra_matrix()); |
640 |
} |
} |
641 |
|
|
642 |
BitstreamPutBit(bs, qmatrix->custom_inter); // load_inter_quant_mat |
BitstreamPutBit(bs, get_inter_matrix_status()); // load_inter_quant_mat |
643 |
if (qmatrix->custom_inter) |
if (get_inter_matrix_status()) |
644 |
{ |
{ |
645 |
bs_put_matrix(bs, qmatrix->inter); |
bs_put_matrix(bs, get_inter_matrix()); |
646 |
} |
} |
647 |
|
|
648 |
} |
} |
|
*/ |
|
|
if (quant_type) |
|
|
{ |
|
|
BitstreamPutBit(bs, 0); // load_intra_quant_mat |
|
|
BitstreamPutBit(bs, 0); // load_inter_quant_mat |
|
|
} |
|
649 |
|
|
650 |
BitstreamPutBit(bs, 1); // complexity_estimation_disable |
BitstreamPutBit(bs, 1); // complexity_estimation_disable |
651 |
BitstreamPutBit(bs, 1); // resync_marker_disable |
BitstreamPutBit(bs, 1); // resync_marker_disable |