Originally committed as revision 2975 to svn://svn.ffmpeg.org/ffmpeg/trunk
Alex Beregszaszi authored on 2004/04/07 22:26:47... | ... |
@@ -36,9 +36,6 @@ |
36 | 36 |
#include "avcodec.h" |
37 | 37 |
#include "dsputil.h" |
38 | 38 |
|
39 |
-#define printf(...) {} //(f)printf() usage is forbidden in libavcodec, use av_log |
|
40 |
-#define fprintf(...) {} |
|
41 |
- |
|
42 | 39 |
#define CPAIR 2 |
43 | 40 |
#define CQUAD 4 |
44 | 41 |
#define COCTET 8 |
... | ... |
@@ -75,7 +72,7 @@ typedef struct SmcContext { |
75 | 75 |
total_blocks--; \ |
76 | 76 |
if (total_blocks < 0) \ |
77 | 77 |
{ \ |
78 |
- printf("warning: block counter just went negative (this should not happen)\n"); \ |
|
78 |
+ av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \ |
|
79 | 79 |
return; \ |
80 | 80 |
} \ |
81 | 81 |
} |
... | ... |
@@ -124,7 +121,7 @@ static void smc_decode_stream(SmcContext *s) |
124 | 124 |
chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF; |
125 | 125 |
stream_ptr += 4; |
126 | 126 |
if (chunk_size != s->size) |
127 |
- printf("warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n", |
|
127 |
+ av_log(s->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n", |
|
128 | 128 |
chunk_size, s->size); |
129 | 129 |
|
130 | 130 |
chunk_size = s->size; |
... | ... |
@@ -135,13 +132,13 @@ static void smc_decode_stream(SmcContext *s) |
135 | 135 |
/* sanity checks */ |
136 | 136 |
/* make sure stream ptr hasn't gone out of bounds */ |
137 | 137 |
if (stream_ptr > chunk_size) { |
138 |
- printf("SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n", |
|
138 |
+ av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n", |
|
139 | 139 |
stream_ptr, chunk_size); |
140 | 140 |
return; |
141 | 141 |
} |
142 | 142 |
/* make sure the row pointer hasn't gone wild */ |
143 | 143 |
if (row_ptr >= image_size) { |
144 |
- printf("SMC decoder just went out of bounds (row ptr = %d, height = %d)\n", |
|
144 |
+ av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (row ptr = %d, height = %d)\n", |
|
145 | 145 |
row_ptr, image_size); |
146 | 146 |
return; |
147 | 147 |
} |
... | ... |
@@ -164,7 +161,7 @@ static void smc_decode_stream(SmcContext *s) |
164 | 164 |
|
165 | 165 |
/* sanity check */ |
166 | 166 |
if ((row_ptr == 0) && (pixel_ptr == 0)) { |
167 |
- printf("encountered repeat block opcode (%02X) but no blocks rendered yet\n", |
|
167 |
+ av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but no blocks rendered yet\n", |
|
168 | 168 |
opcode & 0xF0); |
169 | 169 |
break; |
170 | 170 |
} |
... | ... |
@@ -198,7 +195,7 @@ static void smc_decode_stream(SmcContext *s) |
198 | 198 |
|
199 | 199 |
/* sanity check */ |
200 | 200 |
if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) { |
201 |
- printf("encountered repeat block opcode (%02X) but not enough blocks rendered yet\n", |
|
201 |
+ av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n", |
|
202 | 202 |
opcode & 0xF0); |
203 | 203 |
break; |
204 | 204 |
} |
... | ... |
@@ -425,7 +422,7 @@ static void smc_decode_stream(SmcContext *s) |
425 | 425 |
break; |
426 | 426 |
|
427 | 427 |
case 0xF0: |
428 |
- printf("0xF0 opcode seen in SMC chunk (xine developers would like to know)\n"); |
|
428 |
+ av_log(s->avctx, AV_LOG_INFO, "0xF0 opcode seen in SMC chunk (contact the developers)\n"); |
|
429 | 429 |
break; |
430 | 430 |
} |
431 | 431 |
} |
... | ... |
@@ -462,7 +459,7 @@ static int smc_decode_frame(AVCodecContext *avctx, |
462 | 462 |
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | |
463 | 463 |
FF_BUFFER_HINTS_REUSABLE | FF_BUFFER_HINTS_READABLE; |
464 | 464 |
if (avctx->reget_buffer(avctx, &s->frame)) { |
465 |
- printf ("reget_buffer() failed\n"); |
|
465 |
+ av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); |
|
466 | 466 |
return -1; |
467 | 467 |
} |
468 | 468 |
|
... | ... |
@@ -36,9 +36,6 @@ |
36 | 36 |
#include "avcodec.h" |
37 | 37 |
#include "dsputil.h" |
38 | 38 |
|
39 |
-#define printf(...) {} //(f)printf() usage is forbidden in libavcodec, use av_log |
|
40 |
-#define fprintf(...) {} |
|
41 |
- |
|
42 | 39 |
#include "truemotion1data.h" |
43 | 40 |
|
44 | 41 |
typedef struct TrueMotion1Context { |
... | ... |
@@ -232,7 +229,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) |
232 | 232 |
header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f; |
233 | 233 |
if (s->buf[0] < 0x10) |
234 | 234 |
{ |
235 |
- printf("invalid header size\n"); |
|
235 |
+ av_log(s->avctx, AV_LOG_ERROR, "invalid header size\n"); |
|
236 | 236 |
return -1; |
237 | 237 |
} |
238 | 238 |
|
... | ... |
@@ -282,7 +279,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) |
282 | 282 |
} |
283 | 283 |
|
284 | 284 |
if (header.compression > 17) { |
285 |
- printf("invalid compression type (%d)\n", header.compression); |
|
285 |
+ av_log(s->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", header.compression); |
|
286 | 286 |
return -1; |
287 | 287 |
} |
288 | 288 |
|
... | ... |
@@ -296,7 +293,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) |
296 | 296 |
if (header.vectable < 4) |
297 | 297 |
sel_vector_table = tables[header.vectable - 1]; |
298 | 298 |
else { |
299 |
- printf("invalid vector table id (%d)\n", header.vectable); |
|
299 |
+ av_log(s->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", header.vectable); |
|
300 | 300 |
return -1; |
301 | 301 |
} |
302 | 302 |
} |
... | ... |
@@ -305,7 +302,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) |
305 | 305 |
{ |
306 | 306 |
if (compression_types[header.compression].algorithm == ALGO_RGB24H) |
307 | 307 |
{ |
308 |
- printf("24bit compression not yet supported\n"); |
|
308 |
+ av_log(s->avctx, AV_LOG_ERROR, "24bit compression not yet supported\n"); |
|
309 | 309 |
} |
310 | 310 |
else |
311 | 311 |
gen_vector_table(s, sel_vector_table); |
... | ... |
@@ -354,7 +351,7 @@ static int truemotion1_decode_init(AVCodecContext *avctx) |
354 | 354 |
#define GET_NEXT_INDEX() \ |
355 | 355 |
{\ |
356 | 356 |
if (index_stream_index >= s->index_stream_size) { \ |
357 |
- printf (" help! truemotion1 decoder went out of bounds\n"); \ |
|
357 |
+ av_log(s->avctx, AV_LOG_INFO, " help! truemotion1 decoder went out of bounds\n"); \ |
|
358 | 358 |
return; \ |
359 | 359 |
} \ |
360 | 360 |
index = s->index_stream[index_stream_index++] * 4; \ |
... | ... |
@@ -542,7 +539,7 @@ static int truemotion1_decode_frame(AVCodecContext *avctx, |
542 | 542 |
|
543 | 543 |
s->frame.reference = 1; |
544 | 544 |
if (avctx->get_buffer(avctx, &s->frame) < 0) { |
545 |
- fprintf(stderr, "truemotion1: get_buffer() failed\n"); |
|
545 |
+ av_log(s->avctx, AV_LOG_ERROR, "truemotion1: get_buffer() failed\n"); |
|
546 | 546 |
return -1; |
547 | 547 |
} |
548 | 548 |
|
... | ... |
@@ -561,7 +558,7 @@ static int truemotion1_decode_frame(AVCodecContext *avctx, |
561 | 561 |
memcpy(s->frame.data[0], s->prev_frame.data[0], |
562 | 562 |
s->frame.linesize[0] * s->avctx->height); |
563 | 563 |
} else if (compression_types[s->compression].algorithm == ALGO_RGB24H) { |
564 |
- printf (" 24-bit Duck TrueMotion decoding not yet implemented\n"); |
|
564 |
+ av_log(s->avctx, AV_LOG_ERROR, "24bit compression not yet supported\n"); |
|
565 | 565 |
} else { |
566 | 566 |
truemotion1_decode_16bit(s); |
567 | 567 |
} |
... | ... |
@@ -47,9 +47,6 @@ |
47 | 47 |
#include "avcodec.h" |
48 | 48 |
#include "dsputil.h" |
49 | 49 |
|
50 |
-#define printf(...) {} //(f)printf() usage is forbidden in libavcodec, use av_log |
|
51 |
-#define fprintf(...) {} |
|
52 |
- |
|
53 | 50 |
#define VMD_HEADER_SIZE 0x330 |
54 | 51 |
#define PALETTE_COUNT 256 |
55 | 52 |
|
... | ... |
@@ -245,7 +242,7 @@ static void vmd_decode(VmdVideoContext *s) |
245 | 245 |
} |
246 | 246 |
} while (ofs < frame_width); |
247 | 247 |
if (ofs > frame_width) { |
248 |
- printf (" VMD video: offset > width (%d > %d)\n", |
|
248 |
+ av_log(s->avctx, AV_LOG_ERROR, "VMD video: offset > width (%d > %d)\n", |
|
249 | 249 |
ofs, frame_width); |
250 | 250 |
break; |
251 | 251 |
} |
... | ... |
@@ -283,7 +280,7 @@ static void vmd_decode(VmdVideoContext *s) |
283 | 283 |
} |
284 | 284 |
} while (ofs < frame_width); |
285 | 285 |
if (ofs > frame_width) { |
286 |
- printf (" VMD video: offset > width (%d > %d)\n", |
|
286 |
+ av_log(s->avctx, AV_LOG_ERROR, "VMD video: offset > width (%d > %d)\n", |
|
287 | 287 |
ofs, frame_width); |
288 | 288 |
} |
289 | 289 |
dp += s->frame.linesize[0]; |
... | ... |
@@ -311,7 +308,7 @@ static int vmdvideo_decode_init(AVCodecContext *avctx) |
311 | 311 |
|
312 | 312 |
/* make sure the VMD header made it */ |
313 | 313 |
if (s->avctx->extradata_size != VMD_HEADER_SIZE) { |
314 |
- printf(" VMD video: expected extradata size of %d\n", |
|
314 |
+ av_log(s->avctx, AV_LOG_ERROR, "VMD video: expected extradata size of %d\n", |
|
315 | 315 |
VMD_HEADER_SIZE); |
316 | 316 |
return -1; |
317 | 317 |
} |
... | ... |
@@ -350,7 +347,7 @@ static int vmdvideo_decode_frame(AVCodecContext *avctx, |
350 | 350 |
|
351 | 351 |
s->frame.reference = 1; |
352 | 352 |
if (avctx->get_buffer(avctx, &s->frame)) { |
353 |
- printf (" VMD Video: get_buffer() failed\n"); |
|
353 |
+ av_log(s->avctx, AV_LOG_ERROR, "VMD Video: get_buffer() failed\n"); |
|
354 | 354 |
return -1; |
355 | 355 |
} |
356 | 356 |
|
... | ... |
@@ -389,6 +386,7 @@ static int vmdvideo_decode_end(AVCodecContext *avctx) |
389 | 389 |
*/ |
390 | 390 |
|
391 | 391 |
typedef struct VmdAudioContext { |
392 |
+ AVCodecContext *avctx; |
|
392 | 393 |
int channels; |
393 | 394 |
int bits; |
394 | 395 |
int block_align; |
... | ... |
@@ -403,12 +401,13 @@ static int vmdaudio_decode_init(AVCodecContext *avctx) |
403 | 403 |
VmdAudioContext *s = (VmdAudioContext *)avctx->priv_data; |
404 | 404 |
int i; |
405 | 405 |
|
406 |
+ s->avctx = avctx; |
|
406 | 407 |
s->channels = avctx->channels; |
407 | 408 |
s->bits = avctx->bits_per_sample; |
408 | 409 |
s->block_align = avctx->block_align; |
409 | 410 |
|
410 |
-printf (" %d channels, %d bits/sample, block align = %d, sample rate = %d\n", |
|
411 |
- s->channels, s->bits, s->block_align, avctx->sample_rate); |
|
411 |
+ av_log(s->avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, block align = %d, sample rate = %d\n", |
|
412 |
+ s->channels, s->bits, s->block_align, avctx->sample_rate); |
|
412 | 413 |
|
413 | 414 |
/* set up the steps8 and steps16 tables */ |
414 | 415 |
for (i = 0; i < 8; i++) { |
... | ... |
@@ -465,8 +464,8 @@ static int vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data, |
465 | 465 |
int bytes_decoded = 0; |
466 | 466 |
int i; |
467 | 467 |
|
468 |
-if (silence) |
|
469 |
- printf (" silent block!\n"); |
|
468 |
+ if (silence) |
|
469 |
+ av_log(s->avctx, AV_LOG_INFO, "silent block!\n"); |
|
470 | 470 |
if (s->channels == 2) { |
471 | 471 |
|
472 | 472 |
/* stereo handling */ |
... | ... |
@@ -520,7 +519,6 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, |
520 | 520 |
unsigned char *p = buf + 16; |
521 | 521 |
unsigned char *p_end = buf + buf_size; |
522 | 522 |
|
523 |
-printf (" processing audio frame with %d bytes\n", buf_size); |
|
524 | 523 |
if (buf_size < 16) |
525 | 524 |
return buf_size; |
526 | 525 |
|
... | ... |
@@ -529,7 +527,6 @@ printf (" processing audio frame with %d bytes\n", buf_size); |
529 | 529 |
/* the chunk contains audio */ |
530 | 530 |
*data_size = vmdaudio_loadsound(s, output_samples, p, 0); |
531 | 531 |
} else if (buf[6] == 2) { |
532 |
-printf (" hey! audio case #2\n"); |
|
533 | 532 |
/* the chunk contains audio and silence mixed together */ |
534 | 533 |
sound_flags = LE_32(p); |
535 | 534 |
p += 4; |
... | ... |
@@ -549,13 +546,10 @@ printf (" hey! audio case #2\n"); |
549 | 549 |
sound_flags >>= 1; |
550 | 550 |
} |
551 | 551 |
} else if (buf[6] == 3) { |
552 |
-printf (" hey! audio case #3\n"); |
|
553 | 552 |
/* silent chunk */ |
554 | 553 |
*data_size = vmdaudio_loadsound(s, output_samples, p, 1); |
555 | 554 |
} |
556 | 555 |
|
557 |
-printf (" final sample count = %d, byte count = %d\n", (*data_size) / 2, |
|
558 |
- *data_size); |
|
559 | 556 |
return buf_size; |
560 | 557 |
} |
561 | 558 |
|