comparison smc.c @ 1927:d7505fbe66cb libavcodec

conversion to av_log
author alex
date Wed, 07 Apr 2004 13:26:47 +0000
parents 39ad6cd5d4a6
children bcc91fa67694
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 #define CPAIR 2 39 #define CPAIR 2
43 #define CQUAD 4 40 #define CQUAD 4
44 #define COCTET 8 41 #define COCTET 8
45 42
46 #define COLORS_PER_TABLE 256 43 #define COLORS_PER_TABLE 256
73 row_ptr += stride * 4; \ 70 row_ptr += stride * 4; \
74 } \ 71 } \
75 total_blocks--; \ 72 total_blocks--; \
76 if (total_blocks < 0) \ 73 if (total_blocks < 0) \
77 { \ 74 { \
78 printf("warning: block counter just went negative (this should not happen)\n"); \ 75 av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \
79 return; \ 76 return; \
80 } \ 77 } \
81 } 78 }
82 79
83 static void smc_decode_stream(SmcContext *s) 80 static void smc_decode_stream(SmcContext *s)
122 } 119 }
123 120
124 chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF; 121 chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF;
125 stream_ptr += 4; 122 stream_ptr += 4;
126 if (chunk_size != s->size) 123 if (chunk_size != s->size)
127 printf("warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n", 124 av_log(s->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
128 chunk_size, s->size); 125 chunk_size, s->size);
129 126
130 chunk_size = s->size; 127 chunk_size = s->size;
131 total_blocks = (s->avctx->width * s->avctx->height) / (4 * 4); 128 total_blocks = (s->avctx->width * s->avctx->height) / (4 * 4);
132 129
133 /* traverse through the blocks */ 130 /* traverse through the blocks */
134 while (total_blocks) { 131 while (total_blocks) {
135 /* sanity checks */ 132 /* sanity checks */
136 /* make sure stream ptr hasn't gone out of bounds */ 133 /* make sure stream ptr hasn't gone out of bounds */
137 if (stream_ptr > chunk_size) { 134 if (stream_ptr > chunk_size) {
138 printf("SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n", 135 av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n",
139 stream_ptr, chunk_size); 136 stream_ptr, chunk_size);
140 return; 137 return;
141 } 138 }
142 /* make sure the row pointer hasn't gone wild */ 139 /* make sure the row pointer hasn't gone wild */
143 if (row_ptr >= image_size) { 140 if (row_ptr >= image_size) {
144 printf("SMC decoder just went out of bounds (row ptr = %d, height = %d)\n", 141 av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (row ptr = %d, height = %d)\n",
145 row_ptr, image_size); 142 row_ptr, image_size);
146 return; 143 return;
147 } 144 }
148 145
149 opcode = s->buf[stream_ptr++]; 146 opcode = s->buf[stream_ptr++];
162 case 0x30: 159 case 0x30:
163 n_blocks = GET_BLOCK_COUNT(); 160 n_blocks = GET_BLOCK_COUNT();
164 161
165 /* sanity check */ 162 /* sanity check */
166 if ((row_ptr == 0) && (pixel_ptr == 0)) { 163 if ((row_ptr == 0) && (pixel_ptr == 0)) {
167 printf("encountered repeat block opcode (%02X) but no blocks rendered yet\n", 164 av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but no blocks rendered yet\n",
168 opcode & 0xF0); 165 opcode & 0xF0);
169 break; 166 break;
170 } 167 }
171 168
172 /* figure out where the previous block started */ 169 /* figure out where the previous block started */
196 n_blocks = GET_BLOCK_COUNT(); 193 n_blocks = GET_BLOCK_COUNT();
197 n_blocks *= 2; 194 n_blocks *= 2;
198 195
199 /* sanity check */ 196 /* sanity check */
200 if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) { 197 if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) {
201 printf("encountered repeat block opcode (%02X) but not enough blocks rendered yet\n", 198 av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
202 opcode & 0xF0); 199 opcode & 0xF0);
203 break; 200 break;
204 } 201 }
205 202
206 /* figure out where the previous 2 blocks started */ 203 /* figure out where the previous 2 blocks started */
423 ADVANCE_BLOCK(); 420 ADVANCE_BLOCK();
424 } 421 }
425 break; 422 break;
426 423
427 case 0xF0: 424 case 0xF0:
428 printf("0xF0 opcode seen in SMC chunk (xine developers would like to know)\n"); 425 av_log(s->avctx, AV_LOG_INFO, "0xF0 opcode seen in SMC chunk (contact the developers)\n");
429 break; 426 break;
430 } 427 }
431 } 428 }
432 } 429 }
433 430
460 457
461 s->frame.reference = 1; 458 s->frame.reference = 1;
462 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | 459 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
463 FF_BUFFER_HINTS_REUSABLE | FF_BUFFER_HINTS_READABLE; 460 FF_BUFFER_HINTS_REUSABLE | FF_BUFFER_HINTS_READABLE;
464 if (avctx->reget_buffer(avctx, &s->frame)) { 461 if (avctx->reget_buffer(avctx, &s->frame)) {
465 printf ("reget_buffer() failed\n"); 462 av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
466 return -1; 463 return -1;
467 } 464 }
468 465
469 smc_decode_stream(s); 466 smc_decode_stream(s);
470 467