comparison mace.c @ 7808:0acafe424d54 libavcodec

Use the same 8 bit -> 16 bit conversion as QuickTime.
author vitor
date Sun, 07 Sep 2008 09:46:55 +0000
parents 8c32b5606f83
children 74a7ac273231
comparison
equal deleted inserted replaced
7807:8c32b5606f83 7808:0acafe424d54
232 { 0x342C, 0x7FFF, 0x8000, 0xCBD3, 0, 0, 0, 0 }, { 0x3681, 0x7FFF, 0x8000, 0xC97E, 0, 0, 0, 0 }, 232 { 0x342C, 0x7FFF, 0x8000, 0xCBD3, 0, 0, 0, 0 }, { 0x3681, 0x7FFF, 0x8000, 0xC97E, 0, 0, 0, 0 },
233 { 0x38F0, 0x7FFF, 0x8000, 0xC70F, 0, 0, 0, 0 }, { 0x3B7A, 0x7FFF, 0x8000, 0xC485, 0, 0, 0, 0 }, 233 { 0x38F0, 0x7FFF, 0x8000, 0xC70F, 0, 0, 0, 0 }, { 0x3B7A, 0x7FFF, 0x8000, 0xC485, 0, 0, 0, 0 },
234 { 0x3E22, 0x7FFF, 0x8000, 0xC1DD, 0, 0, 0, 0 }, { 0x40E7, 0x7FFF, 0x8000, 0xBF18, 0, 0, 0, 0 }, 234 { 0x3E22, 0x7FFF, 0x8000, 0xC1DD, 0, 0, 0, 0 }, { 0x40E7, 0x7FFF, 0x8000, 0xBF18, 0, 0, 0, 0 },
235 }; 235 };
236 236
237 #define QT_8S_2_16S(x) (((x) & 0xFF00) | (((x) >> 8) & 0xFF))
238
237 typedef struct ChannelData { 239 typedef struct ChannelData {
238 short index, lev, factor, prev2, previous, level; 240 short index, lev, factor, prev2, previous, level;
239 } ChannelData; 241 } ChannelData;
240 242
241 typedef struct MACEContext { 243 typedef struct MACEContext {
257 else 259 else
258 current += ctx->lev; 260 current += ctx->lev;
259 261
260 ctx->lev = current - (current >> 3); 262 ctx->lev = current - (current >> 3);
261 //*ctx->outPtr++=current >> 8; 263 //*ctx->outPtr++=current >> 8;
262 *output = current; 264 *output = QT_8S_2_16S(current);
263 if (( ctx->index += tab1[val]-(ctx->index >> 5) ) < 0) 265 if (( ctx->index += tab1[val]-(ctx->index >> 5) ) < 0)
264 ctx->index = 0; 266 ctx->index = 0;
265 } 267 }
266 268
267 static void chomp6(ChannelData *ctx, int16_t *output, uint8_t val, 269 static void chomp6(ChannelData *ctx, int16_t *output, uint8_t val,
294 ctx->level = ((current*ctx->factor) >> 15); 296 ctx->level = ((current*ctx->factor) >> 15);
295 current >>= 1; 297 current >>= 1;
296 298
297 // *ctx->outPtr++=(ctx->previous+ctx->prev2-((ctx->prev2-current) >> 2)) >> 8; 299 // *ctx->outPtr++=(ctx->previous+ctx->prev2-((ctx->prev2-current) >> 2)) >> 8;
298 // *ctx->outPtr++=(ctx->previous+current+((ctx->prev2-current) >> 2)) >> 8; 300 // *ctx->outPtr++=(ctx->previous+current+((ctx->prev2-current) >> 2)) >> 8;
299 output[0] = (ctx->previous + ctx->prev2 - ((ctx->prev2-current) >> 2)); 301 output[0] = QT_8S_2_16S(ctx->previous + ctx->prev2 -
300 output[numChannels] = (ctx->previous + current + ((ctx->prev2-current) >> 2)); 302 ((ctx->prev2-current) >> 2));
303 output[numChannels] = QT_8S_2_16S(ctx->previous + current +
304 ((ctx->prev2-current) >> 2));
301 ctx->prev2 = ctx->previous; 305 ctx->prev2 = ctx->previous;
302 ctx->previous = current; 306 ctx->previous = current;
303 307
304 if ((ctx->index += tab1[val] - (ctx->index >> 5)) < 0) 308 if ((ctx->index += tab1[val] - (ctx->index >> 5)) < 0)
305 ctx->index = 0; 309 ctx->index = 0;