44 #define COLORS_PER_TABLE 256 61 #define GET_BLOCK_COUNT() \ 62 (opcode & 0x10) ? (1 + bytestream2_get_byte(&s->gb)) : 1 + (opcode & 0x0F); 64 #define ADVANCE_BLOCK() \ 67 if (pixel_ptr >= width) \ 70 row_ptr += stride * 4; \ 73 if (total_blocks < 0) \ 75 av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \ 90 unsigned int color_flags;
91 unsigned int color_flags_a;
92 unsigned int color_flags_b;
93 unsigned int flag_mask;
100 int pixel_x, pixel_y;
101 int row_inc = stride - 4;
104 int prev_block_ptr1, prev_block_ptr2;
107 int color_table_index;
110 int color_pair_index = 0;
111 int color_quad_index = 0;
112 int color_octet_index = 0;
118 chunk_size = bytestream2_get_be24(&s->
gb);
119 if (chunk_size != buf_size)
120 av_log(s->
avctx,
AV_LOG_INFO,
"warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
121 chunk_size, buf_size);
123 chunk_size = buf_size;
127 while (total_blocks) {
130 if (row_ptr >= image_size) {
132 row_ptr, image_size);
136 opcode = bytestream2_get_byte(&s->
gb);
137 switch (opcode & 0xF0) {
153 if ((row_ptr == 0) && (pixel_ptr == 0)) {
164 prev_block_ptr1 = row_ptr + pixel_ptr - 4;
167 block_ptr = row_ptr + pixel_ptr;
168 prev_block_ptr = prev_block_ptr1;
169 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
170 for (pixel_x = 0; pixel_x < 4; pixel_x++) {
171 pixels[block_ptr++] = pixels[prev_block_ptr++];
173 block_ptr += row_inc;
174 prev_block_ptr += row_inc;
187 if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) {
188 av_log(s->
avctx,
AV_LOG_INFO,
"encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
195 prev_block_ptr1 = (row_ptr - s->
avctx->
width * 4) +
197 else if (pixel_ptr == 4)
198 prev_block_ptr1 = (row_ptr - s->
avctx->
width * 4) + row_inc;
200 prev_block_ptr1 = row_ptr + pixel_ptr - 4 * 2;
203 prev_block_ptr2 = (row_ptr - s->
avctx->
width * 4) + row_inc;
205 prev_block_ptr2 = row_ptr + pixel_ptr - 4;
209 block_ptr = row_ptr + pixel_ptr;
211 prev_block_ptr = prev_block_ptr2;
213 prev_block_ptr = prev_block_ptr1;
214 prev_block_flag = !prev_block_flag;
216 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
217 for (pixel_x = 0; pixel_x < 4; pixel_x++) {
218 pixels[block_ptr++] = pixels[prev_block_ptr++];
220 block_ptr += row_inc;
221 prev_block_ptr += row_inc;
231 pixel = bytestream2_get_byte(&s->
gb);
234 block_ptr = row_ptr + pixel_ptr;
235 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
236 for (pixel_x = 0; pixel_x < 4; pixel_x++) {
237 pixels[block_ptr++] =
pixel;
239 block_ptr += row_inc;
248 n_blocks = (opcode & 0x0F) + 1;
251 if ((opcode & 0xF0) == 0x80) {
254 for (i = 0; i <
CPAIR; i++) {
255 pixel = bytestream2_get_byte(&s->
gb);
256 color_table_index = CPAIR * color_pair_index +
i;
260 color_table_index = CPAIR * color_pair_index;
264 color_pair_index = 0;
266 color_table_index =
CPAIR * bytestream2_get_byte(&s->
gb);
269 color_flags = bytestream2_get_be16(&s->
gb);
271 block_ptr = row_ptr + pixel_ptr;
272 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
273 for (pixel_x = 0; pixel_x < 4; pixel_x++) {
274 if (color_flags & flag_mask)
275 pixel = color_table_index + 1;
277 pixel = color_table_index;
281 block_ptr += row_inc;
290 n_blocks = (opcode & 0x0F) + 1;
293 if ((opcode & 0xF0) == 0xA0) {
296 for (i = 0; i <
CQUAD; i++) {
297 pixel = bytestream2_get_byte(&s->
gb);
298 color_table_index = CQUAD * color_quad_index +
i;
302 color_table_index = CQUAD * color_quad_index;
306 color_quad_index = 0;
308 color_table_index =
CQUAD * bytestream2_get_byte(&s->
gb);
311 color_flags = bytestream2_get_be32(&s->
gb);
314 block_ptr = row_ptr + pixel_ptr;
315 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
316 for (pixel_x = 0; pixel_x < 4; pixel_x++) {
317 pixel = color_table_index +
318 ((color_flags >> flag_mask) & 0x03);
322 block_ptr += row_inc;
331 n_blocks = (opcode & 0x0F) + 1;
334 if ((opcode & 0xF0) == 0xC0) {
337 for (i = 0; i <
COCTET; i++) {
338 pixel = bytestream2_get_byte(&s->
gb);
339 color_table_index = COCTET * color_octet_index +
i;
343 color_table_index = COCTET * color_octet_index;
347 color_octet_index = 0;
349 color_table_index =
COCTET * bytestream2_get_byte(&s->
gb);
359 int val1 = bytestream2_get_be16(&s->
gb);
360 int val2 = bytestream2_get_be16(&s->
gb);
361 int val3 = bytestream2_get_be16(&s->
gb);
362 color_flags_a = ((val1 & 0xFFF0) << 8) | (val2 >> 4);
363 color_flags_b = ((val3 & 0xFFF0) << 8) |
364 ((val1 & 0x0F) << 8) | ((val2 & 0x0F) << 4) | (val3 & 0x0F);
366 color_flags = color_flags_a;
369 block_ptr = row_ptr + pixel_ptr;
370 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
373 color_flags = color_flags_b;
376 for (pixel_x = 0; pixel_x < 4; pixel_x++) {
377 pixel = color_table_index +
378 ((color_flags >> flag_mask) & 0x07);
382 block_ptr += row_inc;
390 n_blocks = (opcode & 0x0F) + 1;
393 block_ptr = row_ptr + pixel_ptr;
394 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
395 for (pixel_x = 0; pixel_x < 4; pixel_x++) {
396 pixels[block_ptr++] = bytestream2_get_byte(&s->
gb);
398 block_ptr += row_inc;
426 void *
data,
int *got_frame,
430 int buf_size = avpkt->
size;
static av_cold int smc_decode_init(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
static av_cold int init(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int smc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
unsigned char color_quads[COLORS_PER_TABLE *CQUAD]
8 bit with PIX_FMT_RGB32 palette
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_always_inline int bytestream2_size(GetByteContext *g)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
unsigned char color_pairs[COLORS_PER_TABLE *CPAIR]
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
int width
picture width / height.
static av_cold int smc_decode_end(AVCodecContext *avctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
unsigned char color_octets[COLORS_PER_TABLE *COCTET]
main external API structure.
static void close(AVCodecParserContext *s)
BYTE int const BYTE int int int height
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
synthesis window for stochastic i
int palette_has_changed
Tell user application that palette has changed from previous frame.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
static void smc_decode_stream(SmcContext *s)
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by an given frame.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Synth Windw Norm while(pin< pend)%Until the end...%---Analysis x_w
common internal api header.
#define GET_BLOCK_COUNT()
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
struct SmcContext SmcContext
This structure stores compressed data.