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;
320 if (s->
buf[0] < 0x10)
333 header_buffer[i - 1] = s->
buf[i] ^ s->
buf[i + 1];
341 header.
version = header_buffer[9];
343 header.
flags = header_buffer[11];
344 header.
control = header_buffer[12];
370 if ((s->
w < 213) && (s->
h >= 176))
404 s->
w >>= width_shift;
520 #define GET_NEXT_INDEX() \
522 if (index_stream_index >= s->index_stream_size) { \
523 av_log(s->avctx, AV_LOG_INFO, " help! truemotion1 decoder went out of bounds\n"); \
526 index = s->index_stream[index_stream_index++] * 4; \
531 if (index >= 1023) { \
532 av_log(s->avctx, AV_LOG_ERROR, "Invalid index value.\n"); \
538 #define APPLY_C_PREDICTOR() \
539 predictor_pair = s->c_predictor_table[index]; \
540 horiz_pred += (predictor_pair >> 1); \
541 if (predictor_pair & 1) { \
545 predictor_pair = s->c_predictor_table[index]; \
546 horiz_pred += ((predictor_pair >> 1) * 5); \
547 if (predictor_pair & 1) \
555 #define APPLY_C_PREDICTOR_24() \
556 predictor_pair = s->c_predictor_table[index]; \
557 horiz_pred += (predictor_pair >> 1); \
558 if (predictor_pair & 1) { \
562 predictor_pair = s->fat_c_predictor_table[index]; \
563 horiz_pred += (predictor_pair >> 1); \
564 if (predictor_pair & 1) \
573 #define APPLY_Y_PREDICTOR() \
574 predictor_pair = s->y_predictor_table[index]; \
575 horiz_pred += (predictor_pair >> 1); \
576 if (predictor_pair & 1) { \
580 predictor_pair = s->y_predictor_table[index]; \
581 horiz_pred += ((predictor_pair >> 1) * 5); \
582 if (predictor_pair & 1) \
590 #define APPLY_Y_PREDICTOR_24() \
591 predictor_pair = s->y_predictor_table[index]; \
592 horiz_pred += (predictor_pair >> 1); \
593 if (predictor_pair & 1) { \
597 predictor_pair = s->fat_y_predictor_table[index]; \
598 horiz_pred += (predictor_pair >> 1); \
599 if (predictor_pair & 1) \
607 #define OUTPUT_PIXEL_PAIR() \
608 *current_pixel_pair = *vert_pred + horiz_pred; \
609 *vert_pred++ = *current_pixel_pair++;
615 unsigned int predictor_pair;
616 unsigned int horiz_pred;
617 unsigned int *vert_pred;
618 unsigned int *current_pixel_pair;
619 unsigned char *current_line = s->
frame->
data[0];
624 unsigned char mb_change_byte;
625 unsigned char mb_change_byte_mask;
629 int index_stream_index = 0;
641 current_pixel_pair = (
unsigned int *)current_line;
644 mb_change_byte = mb_change_bits[mb_change_index++];
645 mb_change_byte_mask = 0x01;
648 while (pixels_left > 0) {
650 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
710 *vert_pred++ = *current_pixel_pair++;
711 horiz_pred = *current_pixel_pair - *vert_pred;
712 *vert_pred++ = *current_pixel_pair++;
717 mb_change_byte_mask <<= 1;
720 if (!mb_change_byte_mask) {
721 mb_change_byte = mb_change_bits[mb_change_index++];
722 mb_change_byte_mask = 0x01;
730 if (((y + 1) & 3) == 0)
741 unsigned int predictor_pair;
742 unsigned int horiz_pred;
743 unsigned int *vert_pred;
744 unsigned int *current_pixel_pair;
745 unsigned char *current_line = s->
frame->
data[0];
750 unsigned char mb_change_byte;
751 unsigned char mb_change_byte_mask;
755 int index_stream_index = 0;
767 current_pixel_pair = (
unsigned int *)current_line;
770 mb_change_byte = mb_change_bits[mb_change_index++];
771 mb_change_byte_mask = 0x01;
774 while (pixels_left > 0) {
776 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
836 *vert_pred++ = *current_pixel_pair++;
837 horiz_pred = *current_pixel_pair - *vert_pred;
838 *vert_pred++ = *current_pixel_pair++;
843 mb_change_byte_mask <<= 1;
846 if (!mb_change_byte_mask) {
847 mb_change_byte = mb_change_bits[mb_change_index++];
848 mb_change_byte_mask = 0x01;
856 if (((y + 1) & 3) == 0)
865 void *
data,
int *got_frame,
869 int ret, buf_size = avpkt->
size;
907 .
name =
"truemotion1",