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;
319 if (s->
buf[0] < 0x10)
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;
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; \
517 if (index >= 1023) { \
518 av_log(s->avctx, AV_LOG_ERROR, "Invalid index value.\n"); \
524 #define APPLY_C_PREDICTOR() \
525 predictor_pair = s->c_predictor_table[index]; \
526 horiz_pred += (predictor_pair >> 1); \
527 if (predictor_pair & 1) { \
531 predictor_pair = s->c_predictor_table[index]; \
532 horiz_pred += ((predictor_pair >> 1) * 5); \
533 if (predictor_pair & 1) \
541 #define APPLY_C_PREDICTOR_24() \
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() \
560 predictor_pair = s->y_predictor_table[index]; \
561 horiz_pred += (predictor_pair >> 1); \
562 if (predictor_pair & 1) { \
566 predictor_pair = s->y_predictor_table[index]; \
567 horiz_pred += ((predictor_pair >> 1) * 5); \
568 if (predictor_pair & 1) \
576 #define APPLY_Y_PREDICTOR_24() \
577 predictor_pair = s->y_predictor_table[index]; \
578 horiz_pred += (predictor_pair >> 1); \
579 if (predictor_pair & 1) { \
583 predictor_pair = s->fat_y_predictor_table[index]; \
584 horiz_pred += (predictor_pair >> 1); \
585 if (predictor_pair & 1) \
593 #define OUTPUT_PIXEL_PAIR() \
594 *current_pixel_pair = *vert_pred + horiz_pred; \
595 *vert_pred++ = *current_pixel_pair++;
601 unsigned int predictor_pair;
602 unsigned int horiz_pred;
603 unsigned int *vert_pred;
604 unsigned int *current_pixel_pair;
605 unsigned char *current_line = s->
frame.
data[0];
610 unsigned char mb_change_byte;
611 unsigned char mb_change_byte_mask;
615 int index_stream_index = 0;
627 current_pixel_pair = (
unsigned int *)current_line;
630 mb_change_byte = mb_change_bits[mb_change_index++];
631 mb_change_byte_mask = 0x01;
634 while (pixels_left > 0) {
636 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
696 *vert_pred++ = *current_pixel_pair++;
697 horiz_pred = *current_pixel_pair - *vert_pred;
698 *vert_pred++ = *current_pixel_pair++;
703 mb_change_byte_mask <<= 1;
706 if (!mb_change_byte_mask) {
707 mb_change_byte = mb_change_bits[mb_change_index++];
708 mb_change_byte_mask = 0x01;
716 if (((y + 1) & 3) == 0)
727 unsigned int predictor_pair;
728 unsigned int horiz_pred;
729 unsigned int *vert_pred;
730 unsigned int *current_pixel_pair;
731 unsigned char *current_line = s->
frame.
data[0];
736 unsigned char mb_change_byte;
737 unsigned char mb_change_byte_mask;
741 int index_stream_index = 0;
753 current_pixel_pair = (
unsigned int *)current_line;
756 mb_change_byte = mb_change_bits[mb_change_index++];
757 mb_change_byte_mask = 0x01;
760 while (pixels_left > 0) {
762 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
822 *vert_pred++ = *current_pixel_pair++;
823 horiz_pred = *current_pixel_pair - *vert_pred;
824 *vert_pred++ = *current_pixel_pair++;
829 mb_change_byte_mask <<= 1;
832 if (!mb_change_byte_mask) {
833 mb_change_byte = mb_change_bits[mb_change_index++];
834 mb_change_byte_mask = 0x01;
842 if (((y + 1) & 3) == 0)
851 void *
data,
int *got_frame,
855 int buf_size = avpkt->
size;
898 .
name =
"truemotion1",
This structure describes decoded (raw) audio or video data.
int buffer_hints
codec suggestion on buffer type if != 0
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
static const int16_t *const fat_ydts[]
memory handling functions
#define OUTPUT_PIXEL_PAIR()
static void truemotion1_decode_16bit(TrueMotion1Context *s)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static void gen_vector_table24(TrueMotion1Context *s, const uint8_t *sel_vector_table)
AVCodec ff_truemotion1_decoder
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
static int truemotion1_decode_header(TrueMotion1Context *s)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
const uint8_t * index_stream
int mb_change_bits_row_size
#define AV_PIX_FMT_RGB555
static int init(AVCodecParserContext *s)
struct comp_types comp_types
static av_cold int truemotion1_decode_end(AVCodecContext *avctx)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void av_log_ask_for_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message asking for a sample.
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define FF_DEBUG_PICT_INFO
static void truemotion1_decode_24bit(TrueMotion1Context *s)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static const uint8_t *const tables[]
static const uint8_t pc_tbl2[]
uint32_t c_predictor_table[1024]
common internal API header
struct AVRational AVRational
rational number numerator/denominator
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int width
picture width / height.
static int make_ydt15_entry(int p1, int p2, int16_t *ydt)
struct TrueMotion1Context TrueMotion1Context
static int make_cdt24_entry(int p1, int p2, int16_t *cdt)
static const comp_types compression_types[17]
#define APPLY_C_PREDICTOR_24()
static int make_ydt24_entry(int p1, int p2, int16_t *ydt)
static const int16_t *const cdts[]
static void gen_vector_table16(TrueMotion1Context *s, const uint8_t *sel_vector_table)
static const int16_t *const ydts[]
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
uint32_t fat_c_predictor_table[1024]
static void close(AVCodecParserContext *s)
static int make_cdt15_entry(int p1, int p2, int16_t *cdt)
#define FF_BUFFER_HINTS_REUSABLE
static av_cold int truemotion1_decode_init(AVCodecContext *avctx)
static int truemotion1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define APPLY_Y_PREDICTOR()
#define APPLY_C_PREDICTOR()
#define FF_BUFFER_HINTS_PRESERVE
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int make_ydt16_entry(int p1, int p2, int16_t *ydt)
static void gen_vector_table15(TrueMotion1Context *s, const uint8_t *sel_vector_table)
static int make_cdt16_entry(int p1, int p2, int16_t *cdt)
#define AVERROR_PATCHWELCOME
uint32_t fat_y_predictor_table[1024]
uint32_t y_predictor_table[1024]
static const int16_t *const fat_cdts[]
#define FF_BUFFER_HINTS_VALID
static void select_delta_tables(TrueMotion1Context *s, int delta_table_index)
#define APPLY_Y_PREDICTOR_24()
const uint8_t * mb_change_bits
#define FLAG_INTERPOLATED
This structure stores compressed data.