Commit 1cc82390 authored by melanson's avatar melanson

improvements by Reimar Döffinger; 24-bit decoding is not perfect, only

the left half of the frame is painted, but the area that is painted
looks correct


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@4686 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent f1dcc944
...@@ -232,7 +232,7 @@ static int make_ydt24_entry(int p1, int p2, int16_t *ydt) ...@@ -232,7 +232,7 @@ static int make_ydt24_entry(int p1, int p2, int16_t *ydt)
lo = ydt[p1]; lo = ydt[p1];
hi = ydt[p2]; hi = ydt[p2];
return ((lo + (hi << 8)) << 1); return ((lo + (hi << 8) + (hi << 16)) << 1);
} }
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
...@@ -410,7 +410,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) ...@@ -410,7 +410,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
// FIXME: where to place this ?!?! // FIXME: where to place this ?!?!
if (compression_types[header.compression].algorithm == ALGO_RGB24H) if (compression_types[header.compression].algorithm == ALGO_RGB24H)
s->avctx->pix_fmt = PIX_FMT_BGR24; s->avctx->pix_fmt = PIX_FMT_RGBA32;
else else
s->avctx->pix_fmt = PIX_FMT_RGB555; // RGB565 is supported aswell s->avctx->pix_fmt = PIX_FMT_RGB555; // RGB565 is supported aswell
...@@ -474,7 +474,7 @@ static int truemotion1_decode_init(AVCodecContext *avctx) ...@@ -474,7 +474,7 @@ static int truemotion1_decode_init(AVCodecContext *avctx)
/* there is a vertical predictor for each pixel in a line; each vertical /* there is a vertical predictor for each pixel in a line; each vertical
* predictor is 0 to start with */ * predictor is 0 to start with */
s->vert_pred = s->vert_pred =
(unsigned int *)av_malloc(s->avctx->width * sizeof(unsigned short)); (unsigned int *)av_malloc(s->avctx->width * sizeof(unsigned int));
return 0; return 0;
} }
...@@ -533,13 +533,13 @@ hres,vres,i,i%vres (0 < i < 4) ...@@ -533,13 +533,13 @@ hres,vres,i,i%vres (0 < i < 4)
#define APPLY_C_PREDICTOR_24() \ #define APPLY_C_PREDICTOR_24() \
predictor_pair = s->c_predictor_table[index]; \ predictor_pair = s->c_predictor_table[index]; \
c_horiz_pred += (predictor_pair >> 1); \ horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \ if (predictor_pair & 1) { \
GET_NEXT_INDEX() \ GET_NEXT_INDEX() \
if (!index) { \ if (!index) { \
GET_NEXT_INDEX() \ GET_NEXT_INDEX() \
predictor_pair = s->fat_c_predictor_table[index]; \ predictor_pair = s->fat_c_predictor_table[index]; \
c_horiz_pred += (predictor_pair >> 1); \ horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) \ if (predictor_pair & 1) \
GET_NEXT_INDEX() \ GET_NEXT_INDEX() \
else \ else \
...@@ -547,7 +547,6 @@ hres,vres,i,i%vres (0 < i < 4) ...@@ -547,7 +547,6 @@ hres,vres,i,i%vres (0 < i < 4)
} \ } \
} else \ } else \
index++; index++;
// c_last+coff = clast+c_horiz_pred;
#define APPLY_Y_PREDICTOR() \ #define APPLY_Y_PREDICTOR() \
...@@ -613,7 +612,7 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s) ...@@ -613,7 +612,7 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s)
int index; int index;
/* clean out the line buffer */ /* clean out the line buffer */
memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned short)); memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned int));
GET_NEXT_INDEX(); GET_NEXT_INDEX();
...@@ -727,7 +726,6 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) ...@@ -727,7 +726,6 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
int pixels_left; /* remaining pixels on this line */ int pixels_left; /* remaining pixels on this line */
unsigned int predictor_pair; unsigned int predictor_pair;
unsigned int horiz_pred; unsigned int horiz_pred;
unsigned int c_horiz_pred;
unsigned int *vert_pred; unsigned int *vert_pred;
unsigned int *current_pixel_pair; unsigned int *current_pixel_pair;
unsigned int *prev_pixel_pair; unsigned int *prev_pixel_pair;
...@@ -753,7 +751,7 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) ...@@ -753,7 +751,7 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
for (y = 0; y < s->avctx->height; y++) { for (y = 0; y < s->avctx->height; y++) {
/* re-init variables for the next line iteration */ /* re-init variables for the next line iteration */
horiz_pred = c_horiz_pred = 0; horiz_pred = 0;
current_pixel_pair = (unsigned int *)current_line; current_pixel_pair = (unsigned int *)current_line;
prev_pixel_pair = (unsigned int *)prev_line; prev_pixel_pair = (unsigned int *)prev_line;
vert_pred = s->vert_pred; vert_pred = s->vert_pred;
...@@ -774,19 +772,15 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) ...@@ -774,19 +772,15 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
APPLY_C_PREDICTOR_24(); APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24(); APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR(); OUTPUT_PIXEL_PAIR();
// OUTPUT_PIXEL_PAIR_24_C();
APPLY_C_PREDICTOR_24(); APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24(); APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR(); OUTPUT_PIXEL_PAIR();
// OUTPUT_PIXEL_PAIR_24_C();
} else { } else {
APPLY_C_PREDICTOR_24(); APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24(); APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR(); OUTPUT_PIXEL_PAIR();
// OUTPUT_PIXEL_PAIR_24_C();
APPLY_Y_PREDICTOR_24(); APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR(); OUTPUT_PIXEL_PAIR();
// OUTPUT_PIXEL_PAIR_24_C();
} }
break; break;
...@@ -806,19 +800,15 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) ...@@ -806,19 +800,15 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
APPLY_C_PREDICTOR_24(); APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24(); APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR(); OUTPUT_PIXEL_PAIR();
// OUTPUT_PIXEL_PAIR_24_C();
APPLY_C_PREDICTOR_24(); APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24(); APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR(); OUTPUT_PIXEL_PAIR();
// OUTPUT_PIXEL_PAIR_24_C();
} else if (s->block_type == BLOCK_4x2) { } else if (s->block_type == BLOCK_4x2) {
APPLY_C_PREDICTOR_24(); APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24(); APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR(); OUTPUT_PIXEL_PAIR();
// OUTPUT_PIXEL_PAIR_24_C();
APPLY_Y_PREDICTOR_24(); APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR(); OUTPUT_PIXEL_PAIR();
// OUTPUT_PIXEL_PAIR_24_C();
} else { } else {
APPLY_Y_PREDICTOR_24(); APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR(); OUTPUT_PIXEL_PAIR();
...@@ -836,7 +826,6 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) ...@@ -836,7 +826,6 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
*vert_pred++ = *current_pixel_pair++; *vert_pred++ = *current_pixel_pair++;
*current_pixel_pair = *prev_pixel_pair++; *current_pixel_pair = *prev_pixel_pair++;
horiz_pred = *current_pixel_pair - *vert_pred; horiz_pred = *current_pixel_pair - *vert_pred;
// c_horiz_pred = *current_pixel_pair - *vert_pred;
*vert_pred++ = *current_pixel_pair++; *vert_pred++ = *current_pixel_pair++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment