38 #define PALETTE_COUNT 256
39 #define CHECK_STREAM_PTR(n) \
40 if ((stream_ptr + n) > s->size ) { \
41 av_log(s->avctx, AV_LOG_ERROR, " MS Video-1 warning: stream_ptr out of bounds (%d >= %d)\n", \
42 stream_ptr + n, s->size); \
51 const unsigned char *
buf;
81 int block_ptr, pixel_ptr;
85 int blocks_wide, blocks_high;
91 unsigned char byte_a, byte_b;
94 unsigned char colors[8];
102 total_blocks = blocks_wide * blocks_high;
104 row_dec = stride + 4;
106 for (block_y = blocks_high; block_y > 0; block_y--) {
107 block_ptr = ((block_y * 4) - 1) *
stride;
108 for (block_x = blocks_wide; block_x > 0; block_x--) {
111 block_ptr += block_inc;
117 pixel_ptr = block_ptr;
121 byte_a = s->
buf[stream_ptr++];
122 byte_b = s->
buf[stream_ptr++];
125 if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0))
127 else if ((byte_b & 0xFC) == 0x84) {
129 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
130 }
else if (byte_b < 0x80) {
132 flags = (byte_b << 8) | byte_a;
135 colors[0] = s->
buf[stream_ptr++];
136 colors[1] = s->
buf[stream_ptr++];
138 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
139 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
140 pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
141 pixel_ptr -= row_dec;
143 }
else if (byte_b >= 0x90) {
145 flags = (byte_b << 8) | byte_a;
148 memcpy(colors, &s->
buf[stream_ptr], 8);
151 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
152 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
153 pixels[pixel_ptr++] =
154 colors[((pixel_y & 0x2) << 1) +
155 (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
156 pixel_ptr -= row_dec;
162 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
163 for (pixel_x = 0; pixel_x < 4; pixel_x++)
164 pixels[pixel_ptr++] = colors[0];
165 pixel_ptr -= row_dec;
169 block_ptr += block_inc;
181 int block_ptr, pixel_ptr;
183 int pixel_x, pixel_y;
184 int block_x, block_y;
185 int blocks_wide, blocks_high;
191 unsigned char byte_a, byte_b;
192 unsigned short flags;
194 unsigned short colors[8];
195 unsigned short *pixels = (
unsigned short *)s->
frame.
data[0];
202 total_blocks = blocks_wide * blocks_high;
206 for (block_y = blocks_high; block_y > 0; block_y--) {
207 block_ptr = ((block_y * 4) - 1) *
stride;
208 for (block_x = blocks_wide; block_x > 0; block_x--) {
211 block_ptr += block_inc;
217 pixel_ptr = block_ptr;
221 byte_a = s->
buf[stream_ptr++];
222 byte_b = s->
buf[stream_ptr++];
225 if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0)) {
227 }
else if ((byte_b & 0xFC) == 0x84) {
229 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
230 }
else if (byte_b < 0x80) {
232 flags = (byte_b << 8) | byte_a;
240 if (colors[0] & 0x8000) {
256 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
257 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
258 pixels[pixel_ptr++] =
259 colors[((pixel_y & 0x2) << 1) +
260 (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
261 pixel_ptr -= row_dec;
265 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
266 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
267 pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
268 pixel_ptr -= row_dec;
273 colors[0] = (byte_b << 8) | byte_a;
275 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
276 for (pixel_x = 0; pixel_x < 4; pixel_x++)
277 pixels[pixel_ptr++] = colors[0];
278 pixel_ptr -= row_dec;
282 block_ptr += block_inc;
289 void *
data,
int *got_frame,
293 int buf_size = avpkt->
size;
static int msvideo1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
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.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static av_cold int msvideo1_decode_end(AVCodecContext *avctx)
8 bit with PIX_FMT_RGB32 palette
#define AV_PIX_FMT_RGB555
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static int init(AVCodecParserContext *s)
const unsigned char * buf
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. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
AVCodec ff_msvideo1_decoder
static void msvideo1_decode_16bit(Msvideo1Context *s)
common internal API header
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
int palette_has_changed
Tell user application that palette has changed from previous frame.
static void msvideo1_decode_8bit(Msvideo1Context *s)
#define FF_BUFFER_HINTS_REUSABLE
#define CHECK_STREAM_PTR(n)
#define FF_BUFFER_HINTS_PRESERVE
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int msvideo1_decode_init(AVCodecContext *avctx)
#define FF_BUFFER_HINTS_VALID
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
This structure stores compressed data.
struct Msvideo1Context Msvideo1Context