81 #define FLAG_SPRITE 32
82 #define FLAG_KEYFRAME 16
83 #define FLAG_INTERFRAME 8
84 #define FLAG_INTERPOLATED 4
105 #define ALGO_RGB16V 1
106 #define ALGO_RGB16H 2
107 #define ALGO_RGB24H 3
151 if (delta_table_index > 3)
154 memcpy(s->
ydt,
ydts[delta_table_index], 8 *
sizeof(int16_t));
155 memcpy(s->
cdt,
cdts[delta_table_index], 8 *
sizeof(int16_t));
161 for (i = 0; i < 8; i++)
179 lo += (lo << 5) + (lo << 10);
181 hi += (hi << 5) + (hi << 10);
182 return (lo + (hi << 16)) << 1;
192 return (lo + (lo << 16)) << 1;
204 lo += (lo << 6) + (lo << 11);
206 hi += (hi << 6) + (hi << 11);
207 return (lo + (hi << 16)) << 1;
217 return (lo + (lo << 16)) << 1;
226 return (lo + (hi << 8) + (hi << 16)) << 1;
241 unsigned char delta_pair;
243 for (i = 0; i < 1024; i += 4)
245 len = *sel_vector_table++ / 2;
246 for (j = 0; j <
len; j++)
248 delta_pair = *sel_vector_table++;
262 unsigned char delta_pair;
264 for (i = 0; i < 1024; i += 4)
266 len = *sel_vector_table++ / 2;
267 for (j = 0; j <
len; j++)
269 delta_pair = *sel_vector_table++;
283 unsigned char delta_pair;
285 for (i = 0; i < 1024; i += 4)
287 len = *sel_vector_table++ / 2;
288 for (j = 0; j <
len; j++)
290 delta_pair = *sel_vector_table++;
315 uint8_t header_buffer[128] = { 0 };
316 const uint8_t *sel_vector_table;
327 header_buffer[i - 1] = s->
buf[i] ^ s->
buf[i + 1];
335 header.
version = header_buffer[9];
337 header.
flags = header_buffer[11];
338 header.
control = header_buffer[12];
364 if ((s->
w < 213) && (s->
h >= 176))
398 s->
w >>= width_shift;
507 #define GET_NEXT_INDEX() \
509 if (index_stream_index >= s->index_stream_size) { \
510 av_log(s->avctx, AV_LOG_INFO, " help! truemotion1 decoder went out of bounds\n"); \
513 index = s->index_stream[index_stream_index++] * 4; \
516 #define APPLY_C_PREDICTOR() \
518 av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
521 predictor_pair = s->c_predictor_table[index]; \
522 horiz_pred += (predictor_pair >> 1); \
523 if (predictor_pair & 1) { \
527 predictor_pair = s->c_predictor_table[index]; \
528 horiz_pred += ((predictor_pair >> 1) * 5); \
529 if (predictor_pair & 1) \
537 #define APPLY_C_PREDICTOR_24() \
539 av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
542 predictor_pair = s->c_predictor_table[index]; \
543 horiz_pred += (predictor_pair >> 1); \
544 if (predictor_pair & 1) { \
548 predictor_pair = s->fat_c_predictor_table[index]; \
549 horiz_pred += (predictor_pair >> 1); \
550 if (predictor_pair & 1) \
559 #define APPLY_Y_PREDICTOR() \
561 av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
564 predictor_pair = s->y_predictor_table[index]; \
565 horiz_pred += (predictor_pair >> 1); \
566 if (predictor_pair & 1) { \
570 predictor_pair = s->y_predictor_table[index]; \
571 horiz_pred += ((predictor_pair >> 1) * 5); \
572 if (predictor_pair & 1) \
580 #define APPLY_Y_PREDICTOR_24() \
582 av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
585 predictor_pair = s->y_predictor_table[index]; \
586 horiz_pred += (predictor_pair >> 1); \
587 if (predictor_pair & 1) { \
591 predictor_pair = s->fat_y_predictor_table[index]; \
592 horiz_pred += (predictor_pair >> 1); \
593 if (predictor_pair & 1) \
601 #define OUTPUT_PIXEL_PAIR() \
602 *current_pixel_pair = *vert_pred + horiz_pred; \
603 *vert_pred++ = *current_pixel_pair++;
609 unsigned int predictor_pair;
610 unsigned int horiz_pred;
611 unsigned int *vert_pred;
612 unsigned int *current_pixel_pair;
613 unsigned char *current_line = s->
frame.
data[0];
618 unsigned char mb_change_byte;
619 unsigned char mb_change_byte_mask;
623 int index_stream_index = 0;
635 current_pixel_pair = (
unsigned int *)current_line;
638 mb_change_byte = mb_change_bits[mb_change_index++];
639 mb_change_byte_mask = 0x01;
642 while (pixels_left > 0) {
644 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
704 *vert_pred++ = *current_pixel_pair++;
705 horiz_pred = *current_pixel_pair - *vert_pred;
706 *vert_pred++ = *current_pixel_pair++;
711 mb_change_byte_mask <<= 1;
714 if (!mb_change_byte_mask) {
715 mb_change_byte = mb_change_bits[mb_change_index++];
716 mb_change_byte_mask = 0x01;
724 if (((y + 1) & 3) == 0)
735 unsigned int predictor_pair;
736 unsigned int horiz_pred;
737 unsigned int *vert_pred;
738 unsigned int *current_pixel_pair;
739 unsigned char *current_line = s->
frame.
data[0];
744 unsigned char mb_change_byte;
745 unsigned char mb_change_byte_mask;
749 int index_stream_index = 0;
761 current_pixel_pair = (
unsigned int *)current_line;
764 mb_change_byte = mb_change_bits[mb_change_index++];
765 mb_change_byte_mask = 0x01;
768 while (pixels_left > 0) {
770 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
830 *vert_pred++ = *current_pixel_pair++;
831 horiz_pred = *current_pixel_pair - *vert_pred;
832 *vert_pred++ = *current_pixel_pair++;
837 mb_change_byte_mask <<= 1;
840 if (!mb_change_byte_mask) {
841 mb_change_byte = mb_change_bits[mb_change_index++];
842 mb_change_byte_mask = 0x01;
850 if (((y + 1) & 3) == 0)
859 void *
data,
int *got_frame,
863 int buf_size = avpkt->
size;
906 .
name =
"truemotion1",