79 #define FLAG_SPRITE 32
80 #define FLAG_KEYFRAME 16
81 #define FLAG_INTERFRAME 8
82 #define FLAG_INTERPOLATED 4
103 #define ALGO_RGB16V 1
104 #define ALGO_RGB16H 2
105 #define ALGO_RGB24H 3
149 if (delta_table_index > 3)
152 memcpy(s->
ydt,
ydts[delta_table_index], 8 *
sizeof(int16_t));
153 memcpy(s->
cdt,
cdts[delta_table_index], 8 *
sizeof(int16_t));
159 for (i = 0; i < 8; i++)
177 lo += (lo << 5) + (lo << 10);
179 hi += (hi << 5) + (hi << 10);
180 return (lo + (hi << 16)) << 1;
190 return (lo + (lo << 16)) << 1;
202 lo += (lo << 6) + (lo << 11);
204 hi += (hi << 6) + (hi << 11);
205 return (lo + (hi << 16)) << 1;
215 return (lo + (lo << 16)) << 1;
224 return (lo + (hi << 8) + (hi << 16)) << 1;
239 unsigned char delta_pair;
241 for (i = 0; i < 1024; i += 4)
243 len = *sel_vector_table++ / 2;
244 for (j = 0; j <
len; j++)
246 delta_pair = *sel_vector_table++;
260 unsigned char delta_pair;
262 for (i = 0; i < 1024; i += 4)
264 len = *sel_vector_table++ / 2;
265 for (j = 0; j <
len; j++)
267 delta_pair = *sel_vector_table++;
281 unsigned char delta_pair;
283 for (i = 0; i < 1024; i += 4)
285 len = *sel_vector_table++ / 2;
286 for (j = 0; j <
len; j++)
288 delta_pair = *sel_vector_table++;
313 uint8_t header_buffer[128];
314 const uint8_t *sel_vector_table;
317 if (s->
buf[0] < 0x10)
329 memset(header_buffer, 0, 128);
331 header_buffer[i - 1] = s->
buf[i] ^ s->
buf[i + 1];
339 header.
version = header_buffer[9];
341 header.
flags = header_buffer[11];
342 header.
control = header_buffer[12];
375 if ((s->
w < 213) && (s->
h >= 176))
409 s->
w >>= width_shift;
517 #define GET_NEXT_INDEX() \
519 if (index_stream_index >= s->index_stream_size) { \
520 av_log(s->avctx, AV_LOG_INFO, " help! truemotion1 decoder went out of bounds\n"); \
523 index = s->index_stream[index_stream_index++] * 4; \
526 #define APPLY_C_PREDICTOR() \
527 predictor_pair = s->c_predictor_table[index]; \
528 horiz_pred += (predictor_pair >> 1); \
529 if (predictor_pair & 1) { \
533 predictor_pair = s->c_predictor_table[index]; \
534 horiz_pred += ((predictor_pair >> 1) * 5); \
535 if (predictor_pair & 1) \
543 #define APPLY_C_PREDICTOR_24() \
544 predictor_pair = s->c_predictor_table[index]; \
545 horiz_pred += (predictor_pair >> 1); \
546 if (predictor_pair & 1) { \
550 predictor_pair = s->fat_c_predictor_table[index]; \
551 horiz_pred += (predictor_pair >> 1); \
552 if (predictor_pair & 1) \
561 #define APPLY_Y_PREDICTOR() \
562 predictor_pair = s->y_predictor_table[index]; \
563 horiz_pred += (predictor_pair >> 1); \
564 if (predictor_pair & 1) { \
568 predictor_pair = s->y_predictor_table[index]; \
569 horiz_pred += ((predictor_pair >> 1) * 5); \
570 if (predictor_pair & 1) \
578 #define APPLY_Y_PREDICTOR_24() \
579 predictor_pair = s->y_predictor_table[index]; \
580 horiz_pred += (predictor_pair >> 1); \
581 if (predictor_pair & 1) { \
585 predictor_pair = s->fat_y_predictor_table[index]; \
586 horiz_pred += (predictor_pair >> 1); \
587 if (predictor_pair & 1) \
595 #define OUTPUT_PIXEL_PAIR() \
596 *current_pixel_pair = *vert_pred + horiz_pred; \
597 *vert_pred++ = *current_pixel_pair++;
603 unsigned int predictor_pair;
604 unsigned int horiz_pred;
605 unsigned int *vert_pred;
606 unsigned int *current_pixel_pair;
607 unsigned char *current_line = s->
frame.
data[0];
612 unsigned char mb_change_byte;
613 unsigned char mb_change_byte_mask;
617 int index_stream_index = 0;
629 current_pixel_pair = (
unsigned int *)current_line;
632 mb_change_byte = mb_change_bits[mb_change_index++];
633 mb_change_byte_mask = 0x01;
636 while (pixels_left > 0) {
638 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
698 *vert_pred++ = *current_pixel_pair++;
699 horiz_pred = *current_pixel_pair - *vert_pred;
700 *vert_pred++ = *current_pixel_pair++;
705 mb_change_byte_mask <<= 1;
708 if (!mb_change_byte_mask) {
709 mb_change_byte = mb_change_bits[mb_change_index++];
710 mb_change_byte_mask = 0x01;
718 if (((y + 1) & 3) == 0)
729 unsigned int predictor_pair;
730 unsigned int horiz_pred;
731 unsigned int *vert_pred;
732 unsigned int *current_pixel_pair;
733 unsigned char *current_line = s->
frame.
data[0];
738 unsigned char mb_change_byte;
739 unsigned char mb_change_byte_mask;
743 int index_stream_index = 0;
755 current_pixel_pair = (
unsigned int *)current_line;
758 mb_change_byte = mb_change_bits[mb_change_index++];
759 mb_change_byte_mask = 0x01;
762 while (pixels_left > 0) {
764 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
824 *vert_pred++ = *current_pixel_pair++;
825 horiz_pred = *current_pixel_pair - *vert_pred;
826 *vert_pred++ = *current_pixel_pair++;
831 mb_change_byte_mask <<= 1;
834 if (!mb_change_byte_mask) {
835 mb_change_byte = mb_change_bits[mb_change_index++];
836 mb_change_byte_mask = 0x01;
844 if (((y + 1) & 3) == 0)
853 void *
data,
int *data_size,
856 const uint8_t *buf = avpkt->
data;
857 int buf_size = avpkt->
size;
900 .
name =
"truemotion1",
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define FF_BUFFER_HINTS_VALID
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[]
#define OUTPUT_PIXEL_PAIR()
static void truemotion1_decode_16bit(TrueMotion1Context *s)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
static void gen_vector_table24(TrueMotion1Context *s, const uint8_t *sel_vector_table)
AVCodec ff_truemotion1_decoder
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
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
#define FF_DEBUG_PICT_INFO
int mb_change_bits_row_size
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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(). ...
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. ...
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]
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.
struct AVFrame AVFrame
Audio Video Frame.
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()
#define FF_BUFFER_HINTS_REUSABLE
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.
void av_log_ask_for_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message asking for a sample.
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 AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_BUFFER_HINTS_PRESERVE
static av_cold int truemotion1_decode_init(AVCodecContext *avctx)
#define APPLY_Y_PREDICTOR()
#define APPLY_C_PREDICTOR()
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int truemotion1_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
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)
uint32_t fat_y_predictor_table[1024]
uint32_t y_predictor_table[1024]
static const int16_t *const fat_cdts[]
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