82 #define FLAG_SPRITE 32
83 #define FLAG_KEYFRAME 16
84 #define FLAG_INTERFRAME 8
85 #define FLAG_INTERPOLATED 4
106 #define ALGO_RGB16V 1
107 #define ALGO_RGB16H 2
108 #define ALGO_RGB24H 3
152 if (delta_table_index > 3)
155 memcpy(s->
ydt,
ydts[delta_table_index], 8 *
sizeof(int16_t));
156 memcpy(s->
cdt,
cdts[delta_table_index], 8 *
sizeof(int16_t));
162 for (i = 0; i < 8; i++)
180 lo += (lo << 5) + (lo << 10);
182 hi += (hi << 5) + (hi << 10);
183 return (lo + (hi << 16)) << 1;
193 return (lo + (lo << 16)) << 1;
205 lo += (lo << 6) + (lo << 11);
207 hi += (hi << 6) + (hi << 11);
208 return (lo + (hi << 16)) << 1;
218 return (lo + (lo << 16)) << 1;
227 return (lo + (hi << 8) + (hi << 16)) << 1;
242 unsigned char delta_pair;
244 for (i = 0; i < 1024; i += 4)
246 len = *sel_vector_table++ / 2;
247 for (j = 0; j <
len; j++)
249 delta_pair = *sel_vector_table++;
263 unsigned char delta_pair;
265 for (i = 0; i < 1024; i += 4)
267 len = *sel_vector_table++ / 2;
268 for (j = 0; j <
len; j++)
270 delta_pair = *sel_vector_table++;
284 unsigned char delta_pair;
286 for (i = 0; i < 1024; i += 4)
288 len = *sel_vector_table++ / 2;
289 for (j = 0; j <
len; j++)
291 delta_pair = *sel_vector_table++;
316 uint8_t header_buffer[128] = { 0 };
317 const uint8_t *sel_vector_table;
328 header_buffer[i - 1] = s->
buf[i] ^ s->
buf[i + 1];
336 header.
version = header_buffer[9];
338 header.
flags = header_buffer[11];
339 header.
control = header_buffer[12];
365 if ((s->
w < 213) && (s->
h >= 176))
399 s->
w >>= width_shift;
506 #define GET_NEXT_INDEX() \
508 if (index_stream_index >= s->index_stream_size) { \
509 av_log(s->avctx, AV_LOG_INFO, " help! truemotion1 decoder went out of bounds\n"); \
512 index = s->index_stream[index_stream_index++] * 4; \
515 #define APPLY_C_PREDICTOR() \
517 av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
520 predictor_pair = s->c_predictor_table[index]; \
521 horiz_pred += (predictor_pair >> 1); \
522 if (predictor_pair & 1) { \
526 predictor_pair = s->c_predictor_table[index]; \
527 horiz_pred += ((predictor_pair >> 1) * 5); \
528 if (predictor_pair & 1) \
536 #define APPLY_C_PREDICTOR_24() \
538 av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
541 predictor_pair = s->c_predictor_table[index]; \
542 horiz_pred += (predictor_pair >> 1); \
543 if (predictor_pair & 1) { \
547 predictor_pair = s->fat_c_predictor_table[index]; \
548 horiz_pred += (predictor_pair >> 1); \
549 if (predictor_pair & 1) \
558 #define APPLY_Y_PREDICTOR() \
560 av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
563 predictor_pair = s->y_predictor_table[index]; \
564 horiz_pred += (predictor_pair >> 1); \
565 if (predictor_pair & 1) { \
569 predictor_pair = s->y_predictor_table[index]; \
570 horiz_pred += ((predictor_pair >> 1) * 5); \
571 if (predictor_pair & 1) \
579 #define APPLY_Y_PREDICTOR_24() \
581 av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
584 predictor_pair = s->y_predictor_table[index]; \
585 horiz_pred += (predictor_pair >> 1); \
586 if (predictor_pair & 1) { \
590 predictor_pair = s->fat_y_predictor_table[index]; \
591 horiz_pred += (predictor_pair >> 1); \
592 if (predictor_pair & 1) \
600 #define OUTPUT_PIXEL_PAIR() \
601 *current_pixel_pair = *vert_pred + horiz_pred; \
602 *vert_pred++ = *current_pixel_pair++;
608 unsigned int predictor_pair;
609 unsigned int horiz_pred;
610 unsigned int *vert_pred;
611 unsigned int *current_pixel_pair;
612 unsigned char *current_line = s->
frame.
data[0];
617 unsigned char mb_change_byte;
618 unsigned char mb_change_byte_mask;
622 int index_stream_index = 0;
634 current_pixel_pair = (
unsigned int *)current_line;
637 mb_change_byte = mb_change_bits[mb_change_index++];
638 mb_change_byte_mask = 0x01;
641 while (pixels_left > 0) {
643 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
703 *vert_pred++ = *current_pixel_pair++;
704 horiz_pred = *current_pixel_pair - *vert_pred;
705 *vert_pred++ = *current_pixel_pair++;
710 mb_change_byte_mask <<= 1;
713 if (!mb_change_byte_mask) {
714 mb_change_byte = mb_change_bits[mb_change_index++];
715 mb_change_byte_mask = 0x01;
723 if (((y + 1) & 3) == 0)
734 unsigned int predictor_pair;
735 unsigned int horiz_pred;
736 unsigned int *vert_pred;
737 unsigned int *current_pixel_pair;
738 unsigned char *current_line = s->
frame.
data[0];
743 unsigned char mb_change_byte;
744 unsigned char mb_change_byte_mask;
748 int index_stream_index = 0;
760 current_pixel_pair = (
unsigned int *)current_line;
763 mb_change_byte = mb_change_bits[mb_change_index++];
764 mb_change_byte_mask = 0x01;
767 while (pixels_left > 0) {
769 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
829 *vert_pred++ = *current_pixel_pair++;
830 horiz_pred = *current_pixel_pair - *vert_pred;
831 *vert_pred++ = *current_pixel_pair++;
836 mb_change_byte_mask <<= 1;
839 if (!mb_change_byte_mask) {
840 mb_change_byte = mb_change_bits[mb_change_index++];
841 mb_change_byte_mask = 0x01;
849 if (((y + 1) & 3) == 0)
858 void *
data,
int *got_frame,
862 int ret, buf_size = avpkt->
size;
900 .
name =
"truemotion1",