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)
332 header_buffer[i - 1] = s->
buf[i] ^ s->
buf[i + 1];
340 header.
version = header_buffer[9];
342 header.
flags = header_buffer[11];
343 header.
control = header_buffer[12];
369 if ((s->
w < 213) && (s->
h >= 176))
403 s->
w >>= width_shift;
511 #define GET_NEXT_INDEX() \
513 if (index_stream_index >= s->index_stream_size) { \
514 av_log(s->avctx, AV_LOG_INFO, " help! truemotion1 decoder went out of bounds\n"); \
517 index = s->index_stream[index_stream_index++] * 4; \
522 if (index >= 1023) { \
523 av_log(s->avctx, AV_LOG_ERROR, "Invalid index value.\n"); \
529 #define APPLY_C_PREDICTOR() \
530 predictor_pair = s->c_predictor_table[index]; \
531 horiz_pred += (predictor_pair >> 1); \
532 if (predictor_pair & 1) { \
536 predictor_pair = s->c_predictor_table[index]; \
537 horiz_pred += ((predictor_pair >> 1) * 5); \
538 if (predictor_pair & 1) \
546 #define APPLY_C_PREDICTOR_24() \
547 predictor_pair = s->c_predictor_table[index]; \
548 horiz_pred += (predictor_pair >> 1); \
549 if (predictor_pair & 1) { \
553 predictor_pair = s->fat_c_predictor_table[index]; \
554 horiz_pred += (predictor_pair >> 1); \
555 if (predictor_pair & 1) \
564 #define APPLY_Y_PREDICTOR() \
565 predictor_pair = s->y_predictor_table[index]; \
566 horiz_pred += (predictor_pair >> 1); \
567 if (predictor_pair & 1) { \
571 predictor_pair = s->y_predictor_table[index]; \
572 horiz_pred += ((predictor_pair >> 1) * 5); \
573 if (predictor_pair & 1) \
581 #define APPLY_Y_PREDICTOR_24() \
582 predictor_pair = s->y_predictor_table[index]; \
583 horiz_pred += (predictor_pair >> 1); \
584 if (predictor_pair & 1) { \
588 predictor_pair = s->fat_y_predictor_table[index]; \
589 horiz_pred += (predictor_pair >> 1); \
590 if (predictor_pair & 1) \
598 #define OUTPUT_PIXEL_PAIR() \
599 *current_pixel_pair = *vert_pred + horiz_pred; \
600 *vert_pred++ = *current_pixel_pair++;
606 unsigned int predictor_pair;
607 unsigned int horiz_pred;
608 unsigned int *vert_pred;
609 unsigned int *current_pixel_pair;
610 unsigned char *current_line = s->
frame.
data[0];
615 unsigned char mb_change_byte;
616 unsigned char mb_change_byte_mask;
620 int index_stream_index = 0;
632 current_pixel_pair = (
unsigned int *)current_line;
635 mb_change_byte = mb_change_bits[mb_change_index++];
636 mb_change_byte_mask = 0x01;
639 while (pixels_left > 0) {
641 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
701 *vert_pred++ = *current_pixel_pair++;
702 horiz_pred = *current_pixel_pair - *vert_pred;
703 *vert_pred++ = *current_pixel_pair++;
708 mb_change_byte_mask <<= 1;
711 if (!mb_change_byte_mask) {
712 mb_change_byte = mb_change_bits[mb_change_index++];
713 mb_change_byte_mask = 0x01;
721 if (((y + 1) & 3) == 0)
732 unsigned int predictor_pair;
733 unsigned int horiz_pred;
734 unsigned int *vert_pred;
735 unsigned int *current_pixel_pair;
736 unsigned char *current_line = s->
frame.
data[0];
741 unsigned char mb_change_byte;
742 unsigned char mb_change_byte_mask;
746 int index_stream_index = 0;
758 current_pixel_pair = (
unsigned int *)current_line;
761 mb_change_byte = mb_change_bits[mb_change_index++];
762 mb_change_byte_mask = 0x01;
765 while (pixels_left > 0) {
767 if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {
827 *vert_pred++ = *current_pixel_pair++;
828 horiz_pred = *current_pixel_pair - *vert_pred;
829 *vert_pred++ = *current_pixel_pair++;
834 mb_change_byte_mask <<= 1;
837 if (!mb_change_byte_mask) {
838 mb_change_byte = mb_change_bits[mb_change_index++];
839 mb_change_byte_mask = 0x01;
847 if (((y + 1) & 3) == 0)
856 void *
data,
int *got_frame,
860 int buf_size = avpkt->
size;
903 .
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)
#define AVERROR_INVALIDDATA
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.