[Ffmpeg-devel] [PATCH] almost-working 24bit truemotion
Reimar Döffinger
Reimar.Doeffinger
Sun Nov 6 21:33:57 CET 2005
Hi,
since I'm not sure I will have more time to work on this, here is my
patch that make decoding of 24 bit truemotion files almost work.
Remaining problems I know of:
1) It outputs RGBA32, not BGR24. Is that acceptable? I think it shouldn't
matter, and the code is easier like this.
2) I did not check if my changes match the vp code.
3) The width is only half of what it is supposed to be. Actually the
pixels_left -= 4; seems wrong to me, but changing it breaks decoding.
But at least it sure is an improvement *g*
Hints/comments as always welcome.
Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavcodec/truemotion1.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/truemotion1.c,v
retrieving revision 1.10
diff -u -r1.10 truemotion1.c
--- libavcodec/truemotion1.c 1 Jun 2005 21:19:00 -0000 1.10
+++ libavcodec/truemotion1.c 6 Nov 2005 20:32:00 -0000
@@ -232,7 +232,7 @@
lo = ydt[p1];
hi = ydt[p2];
- return ((lo + (hi << 8)) << 1);
+ return ((lo + (hi << 8) + (hi << 16)) << 1);
}
#ifdef WORDS_BIGENDIAN
@@ -410,7 +410,7 @@
// FIXME: where to place this ?!?!
if (compression_types[header.compression].algorithm == ALGO_RGB24H)
- s->avctx->pix_fmt = PIX_FMT_BGR24;
+ s->avctx->pix_fmt = PIX_FMT_RGBA32;
else
s->avctx->pix_fmt = PIX_FMT_RGB555; // RGB565 is supported aswell
@@ -474,7 +474,7 @@
/* there is a vertical predictor for each pixel in a line; each vertical
* predictor is 0 to start with */
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;
}
@@ -533,13 +533,13 @@
#define APPLY_C_PREDICTOR_24() \
predictor_pair = s->c_predictor_table[index]; \
- c_horiz_pred += (predictor_pair >> 1); \
+ horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
GET_NEXT_INDEX() \
if (!index) { \
GET_NEXT_INDEX() \
predictor_pair = s->fat_c_predictor_table[index]; \
- c_horiz_pred += (predictor_pair >> 1); \
+ horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) \
GET_NEXT_INDEX() \
else \
@@ -547,7 +547,6 @@
} \
} else \
index++;
-// c_last+coff = clast+c_horiz_pred;
#define APPLY_Y_PREDICTOR() \
@@ -613,7 +612,7 @@
int index;
/* 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();
@@ -727,7 +726,6 @@
int pixels_left; /* remaining pixels on this line */
unsigned int predictor_pair;
unsigned int horiz_pred;
- unsigned int c_horiz_pred;
unsigned int *vert_pred;
unsigned int *current_pixel_pair;
unsigned int *prev_pixel_pair;
@@ -753,7 +751,7 @@
for (y = 0; y < s->avctx->height; y++) {
/* re-init variables for the next line iteration */
- horiz_pred = c_horiz_pred = 0;
+ horiz_pred = 0;
current_pixel_pair = (unsigned int *)current_line;
prev_pixel_pair = (unsigned int *)prev_line;
vert_pred = s->vert_pred;
@@ -774,19 +772,15 @@
APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR();
-// OUTPUT_PIXEL_PAIR_24_C();
APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR();
-// OUTPUT_PIXEL_PAIR_24_C();
} else {
APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR();
-// OUTPUT_PIXEL_PAIR_24_C();
APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR();
-// OUTPUT_PIXEL_PAIR_24_C();
}
break;
@@ -806,19 +800,15 @@
APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR();
-// OUTPUT_PIXEL_PAIR_24_C();
APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR();
-// OUTPUT_PIXEL_PAIR_24_C();
} else if (s->block_type == BLOCK_4x2) {
APPLY_C_PREDICTOR_24();
APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR();
-// OUTPUT_PIXEL_PAIR_24_C();
APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR();
-// OUTPUT_PIXEL_PAIR_24_C();
} else {
APPLY_Y_PREDICTOR_24();
OUTPUT_PIXEL_PAIR();
@@ -836,7 +826,6 @@
*vert_pred++ = *current_pixel_pair++;
*current_pixel_pair = *prev_pixel_pair++;
horiz_pred = *current_pixel_pair - *vert_pred;
-// c_horiz_pred = *current_pixel_pair - *vert_pred;
*vert_pred++ = *current_pixel_pair++;
}
More information about the ffmpeg-devel
mailing list