comparison truemotion1.c @ 1927:d7505fbe66cb libavcodec

conversion to av_log
author alex
date Wed, 07 Apr 2004 13:26:47 +0000
parents 39ad6cd5d4a6
children 141a9539e270
comparison
equal deleted inserted replaced
1926:939a3c1df7a0 1927:d7505fbe66cb
34 34
35 #include "common.h" 35 #include "common.h"
36 #include "avcodec.h" 36 #include "avcodec.h"
37 #include "dsputil.h" 37 #include "dsputil.h"
38 38
39 #define printf(...) {} //(f)printf() usage is forbidden in libavcodec, use av_log
40 #define fprintf(...) {}
41
42 #include "truemotion1data.h" 39 #include "truemotion1data.h"
43 40
44 typedef struct TrueMotion1Context { 41 typedef struct TrueMotion1Context {
45 AVCodecContext *avctx; 42 AVCodecContext *avctx;
46 AVFrame frame; 43 AVFrame frame;
230 s->mb_change_bits_row_size = ((s->avctx->width >> 2) + 7) >> 3; 227 s->mb_change_bits_row_size = ((s->avctx->width >> 2) + 7) >> 3;
231 228
232 header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f; 229 header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f;
233 if (s->buf[0] < 0x10) 230 if (s->buf[0] < 0x10)
234 { 231 {
235 printf("invalid header size\n"); 232 av_log(s->avctx, AV_LOG_ERROR, "invalid header size\n");
236 return -1; 233 return -1;
237 } 234 }
238 235
239 /* unscramble the header bytes with a XOR operation */ 236 /* unscramble the header bytes with a XOR operation */
240 memset(header_buffer, 0, 128); 237 memset(header_buffer, 0, 128);
280 s->flags |= FLAG_INTERPOLATED; 277 s->flags |= FLAG_INTERPOLATED;
281 } 278 }
282 } 279 }
283 280
284 if (header.compression > 17) { 281 if (header.compression > 17) {
285 printf("invalid compression type (%d)\n", header.compression); 282 av_log(s->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", header.compression);
286 return -1; 283 return -1;
287 } 284 }
288 285
289 if ((header.deltaset != s->last_deltaset) || 286 if ((header.deltaset != s->last_deltaset) ||
290 (header.vectable != s->last_vectable)) 287 (header.vectable != s->last_vectable))
294 sel_vector_table = pc_tbl2; 291 sel_vector_table = pc_tbl2;
295 else { 292 else {
296 if (header.vectable < 4) 293 if (header.vectable < 4)
297 sel_vector_table = tables[header.vectable - 1]; 294 sel_vector_table = tables[header.vectable - 1];
298 else { 295 else {
299 printf("invalid vector table id (%d)\n", header.vectable); 296 av_log(s->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", header.vectable);
300 return -1; 297 return -1;
301 } 298 }
302 } 299 }
303 300
304 if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable)) 301 if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable))
305 { 302 {
306 if (compression_types[header.compression].algorithm == ALGO_RGB24H) 303 if (compression_types[header.compression].algorithm == ALGO_RGB24H)
307 { 304 {
308 printf("24bit compression not yet supported\n"); 305 av_log(s->avctx, AV_LOG_ERROR, "24bit compression not yet supported\n");
309 } 306 }
310 else 307 else
311 gen_vector_table(s, sel_vector_table); 308 gen_vector_table(s, sel_vector_table);
312 } 309 }
313 310
352 } 349 }
353 350
354 #define GET_NEXT_INDEX() \ 351 #define GET_NEXT_INDEX() \
355 {\ 352 {\
356 if (index_stream_index >= s->index_stream_size) { \ 353 if (index_stream_index >= s->index_stream_size) { \
357 printf (" help! truemotion1 decoder went out of bounds\n"); \ 354 av_log(s->avctx, AV_LOG_INFO, " help! truemotion1 decoder went out of bounds\n"); \
358 return; \ 355 return; \
359 } \ 356 } \
360 index = s->index_stream[index_stream_index++] * 4; \ 357 index = s->index_stream[index_stream_index++] * 4; \
361 } 358 }
362 359
540 s->buf = buf; 537 s->buf = buf;
541 s->size = buf_size; 538 s->size = buf_size;
542 539
543 s->frame.reference = 1; 540 s->frame.reference = 1;
544 if (avctx->get_buffer(avctx, &s->frame) < 0) { 541 if (avctx->get_buffer(avctx, &s->frame) < 0) {
545 fprintf(stderr, "truemotion1: get_buffer() failed\n"); 542 av_log(s->avctx, AV_LOG_ERROR, "truemotion1: get_buffer() failed\n");
546 return -1; 543 return -1;
547 } 544 }
548 545
549 /* no supplementary picture */ 546 /* no supplementary picture */
550 if (buf_size == 0) 547 if (buf_size == 0)
559 if (compression_types[s->compression].algorithm == ALGO_NOP) 556 if (compression_types[s->compression].algorithm == ALGO_NOP)
560 { 557 {
561 memcpy(s->frame.data[0], s->prev_frame.data[0], 558 memcpy(s->frame.data[0], s->prev_frame.data[0],
562 s->frame.linesize[0] * s->avctx->height); 559 s->frame.linesize[0] * s->avctx->height);
563 } else if (compression_types[s->compression].algorithm == ALGO_RGB24H) { 560 } else if (compression_types[s->compression].algorithm == ALGO_RGB24H) {
564 printf (" 24-bit Duck TrueMotion decoding not yet implemented\n"); 561 av_log(s->avctx, AV_LOG_ERROR, "24bit compression not yet supported\n");
565 } else { 562 } else {
566 truemotion1_decode_16bit(s); 563 truemotion1_decode_16bit(s);
567 } 564 }
568 565
569 if (s->prev_frame.data[0]) 566 if (s->prev_frame.data[0])