12 |
* editors and their companies, will have no liability for use of this |
* editors and their companies, will have no liability for use of this |
13 |
* software or modifications or derivatives thereof. |
* software or modifications or derivatives thereof. |
14 |
* |
* |
15 |
* This program is free software; you can redistribute it and/or modify |
* This program is xvid_free software; you can redistribute it and/or modify |
16 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
17 |
* the Free Software Foundation; either version 2 of the License, or |
* the xvid_free Software Foundation; either version 2 of the License, or |
18 |
* (at your option) any later version. |
* (at your option) any later version. |
19 |
* |
* |
20 |
* This program is distributed in the hope that it will be useful, |
* This program is distributed in the hope that it will be useful, |
23 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
24 |
* |
* |
25 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
26 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the xvid_free Software |
27 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
28 |
* |
* |
29 |
*************************************************************************/ |
*************************************************************************/ |
62 |
|
|
63 |
#include "image/image.h" |
#include "image/image.h" |
64 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
65 |
|
#include "utils/mem_align.h" |
66 |
|
|
67 |
int decoder_create(XVID_DEC_PARAM * param) |
int decoder_create(XVID_DEC_PARAM * param) |
68 |
{ |
{ |
69 |
DECODER * dec; |
DECODER * dec; |
70 |
|
|
71 |
dec = malloc(sizeof(DECODER)); |
dec = xvid_malloc(sizeof(DECODER), CACHE_LINE); |
72 |
if (dec == NULL) |
if (dec == NULL) |
73 |
{ |
{ |
74 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
86 |
|
|
87 |
if (image_create(&dec->cur, dec->edged_width, dec->edged_height)) |
if (image_create(&dec->cur, dec->edged_width, dec->edged_height)) |
88 |
{ |
{ |
89 |
free(dec); |
xvid_free(dec); |
90 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
91 |
} |
} |
92 |
|
|
93 |
if (image_create(&dec->refn, dec->edged_width, dec->edged_height)) |
if (image_create(&dec->refn, dec->edged_width, dec->edged_height)) |
94 |
{ |
{ |
95 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
96 |
free(dec); |
xvid_free(dec); |
97 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
98 |
} |
} |
99 |
|
|
100 |
dec->mbs = malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); |
dec->mbs = xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, CACHE_LINE); |
101 |
if (dec->mbs == NULL) |
if (dec->mbs == NULL) |
102 |
{ |
{ |
103 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
104 |
free(dec); |
xvid_free(dec); |
105 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
106 |
} |
} |
107 |
|
|
114 |
|
|
115 |
int decoder_destroy(DECODER * dec) |
int decoder_destroy(DECODER * dec) |
116 |
{ |
{ |
117 |
free(dec->mbs); |
xvid_free(dec->mbs); |
118 |
image_destroy(&dec->refn, dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn, dec->edged_width, dec->edged_height); |
119 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
120 |
free(dec); |
xvid_free(dec); |
121 |
|
|
122 |
destroy_vlc_tables(); |
destroy_vlc_tables(); |
123 |
|
|
142 |
for (k = 0; k < 6; k++) |
for (k = 0; k < 6; k++) |
143 |
{ |
{ |
144 |
uint32_t dcscalar; |
uint32_t dcscalar; |
145 |
int16_t block[64]; |
CACHE_ALIGN int16_t block[64]; |
146 |
int16_t data[64]; |
CACHE_ALIGN int16_t data[64]; |
147 |
int16_t predictors[8]; |
int16_t predictors[8]; |
148 |
int start_coeff; |
int start_coeff; |
149 |
|
|
272 |
|
|
273 |
for (k = 0; k < 6; k++) |
for (k = 0; k < 6; k++) |
274 |
{ |
{ |
275 |
int16_t block[64]; |
CACHE_ALIGN int16_t block[64]; |
276 |
int16_t data[64]; |
CACHE_ALIGN int16_t data[64]; |
277 |
|
|
278 |
if (cbp & (1 << (5-k))) // coded |
if (cbp & (1 << (5-k))) // coded |
279 |
{ |
{ |
447 |
mcbpc = get_mcbpc_inter(bs); |
mcbpc = get_mcbpc_inter(bs); |
448 |
mb->mode = mcbpc & 7; |
mb->mode = mcbpc & 7; |
449 |
cbpc = (mcbpc >> 4); |
cbpc = (mcbpc >> 4); |
450 |
|
acpred_flag = 0; |
451 |
|
|
452 |
intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q); |
intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q); |
453 |
|
|