41 |
#include "bitstream/mbcoding.h" |
#include "bitstream/mbcoding.h" |
42 |
|
|
43 |
#include "quant/quant.h" |
#include "quant/quant.h" |
44 |
|
#include "quant/quant_matrix.h" |
45 |
#include "dct/idct.h" |
#include "dct/idct.h" |
46 |
#include "dct/fdct.h" |
#include "dct/fdct.h" |
47 |
#include "utils/mem_transfer.h" |
#include "utils/mem_transfer.h" |
176 |
if (dec == NULL) { |
if (dec == NULL) { |
177 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
178 |
} |
} |
179 |
|
|
180 |
memset(dec, 0, sizeof(DECODER)); |
memset(dec, 0, sizeof(DECODER)); |
181 |
|
|
182 |
|
dec->mpeg_quant_matrices = xvid_malloc(sizeof(uint16_t) * 64 * 8, CACHE_LINE); |
183 |
|
if (dec->mpeg_quant_matrices == NULL) { |
184 |
|
xvid_free(dec); |
185 |
|
return XVID_ERR_MEMORY; |
186 |
|
} |
187 |
|
|
188 |
create->handle = dec; |
create->handle = dec; |
189 |
|
|
190 |
dec->width = create->width; |
dec->width = create->width; |
204 |
dec->last_mbs = NULL; |
dec->last_mbs = NULL; |
205 |
|
|
206 |
init_timer(); |
init_timer(); |
207 |
|
init_mpeg_matrix(dec->mpeg_quant_matrices); |
208 |
|
|
209 |
/* For B-frame support (used to save reference frame's time */ |
/* For B-frame support (used to save reference frame's time */ |
210 |
dec->frames = 0; |
dec->frames = 0; |
235 |
image_destroy(&dec->tmp, dec->edged_width, dec->edged_height); |
image_destroy(&dec->tmp, dec->edged_width, dec->edged_height); |
236 |
image_destroy(&dec->qtmp, dec->edged_width, dec->edged_height); |
image_destroy(&dec->qtmp, dec->edged_width, dec->edged_height); |
237 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
238 |
|
xvid_free(dec->mpeg_quant_matrices); |
239 |
xvid_free(dec); |
xvid_free(dec); |
240 |
|
|
241 |
write_timer(); |
write_timer(); |
331 |
|
|
332 |
start_timer(); |
start_timer(); |
333 |
if (dec->quant_type == 0) { |
if (dec->quant_type == 0) { |
334 |
dequant_h263_intra(&data[i * 64], &block[i * 64], iQuant, iDcScaler); |
dequant_h263_intra(&data[i * 64], &block[i * 64], iQuant, iDcScaler, dec->mpeg_quant_matrices); |
335 |
} else { |
} else { |
336 |
dequant_mpeg_intra(&data[i * 64], &block[i * 64], iQuant, iDcScaler); |
dequant_mpeg_intra(&data[i * 64], &block[i * 64], iQuant, iDcScaler, dec->mpeg_quant_matrices); |
337 |
} |
} |
338 |
stop_iquant_timer(); |
stop_iquant_timer(); |
339 |
|
|
402 |
stop_coding_timer(); |
stop_coding_timer(); |
403 |
|
|
404 |
start_timer(); |
start_timer(); |
405 |
dequant(&data[i * 64], block, iQuant); |
dequant(&data[i * 64], block, iQuant, dec->mpeg_quant_matrices); |
406 |
stop_iquant_timer(); |
stop_iquant_timer(); |
407 |
|
|
408 |
start_timer(); |
start_timer(); |
1491 |
/* attemping to decode a bvop without atleast 2 reference frames */ |
/* attemping to decode a bvop without atleast 2 reference frames */ |
1492 |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
1493 |
"broken b-frame, mising ref frames"); |
"broken b-frame, mising ref frames"); |
1494 |
|
stats->type = XVID_TYPE_NOTHING; |
1495 |
} else if (dec->time_pp <= dec->time_bp) { |
} else if (dec->time_pp <= dec->time_bp) { |
1496 |
/* this occurs when dx50_bvop_compatibility==0 sequences are |
/* this occurs when dx50_bvop_compatibility==0 sequences are |
1497 |
decoded in vfw. */ |
decoded in vfw. */ |
1498 |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
1499 |
"broken b-frame, tpp=%i tbp=%i", dec->time_pp, dec->time_bp); |
"broken b-frame, tpp=%i tbp=%i", dec->time_pp, dec->time_bp); |
1500 |
|
stats->type = XVID_TYPE_NOTHING; |
1501 |
} else { |
} else { |
1502 |
decoder_bframe(dec, &bs, quant, fcode_forward, fcode_backward); |
decoder_bframe(dec, &bs, quant, fcode_forward, fcode_backward); |
1503 |
|
decoder_output(dec, &dec->cur, dec->mbs, frame, stats, coding_type); |
1504 |
} |
} |
1505 |
|
|
|
decoder_output(dec, &dec->cur, dec->mbs, frame, stats, coding_type); |
|
1506 |
output = 1; |
output = 1; |
1507 |
dec->frames++; |
dec->frames++; |
1508 |
} |
} |