37 #define PALETTE_COUNT 256
38 #define CHECK_STREAM_PTR(n) \
39 if ((stream_ptr + n) > s->size ) { \
40 av_log(s->avctx, AV_LOG_ERROR, " MS Video-1 warning: stream_ptr out of bounds (%d >= %d)\n", \
41 stream_ptr + n, s->size); \
50 const unsigned char *
buf;
80 int block_ptr, pixel_ptr;
84 int blocks_wide, blocks_high;
90 unsigned char byte_a, byte_b;
93 unsigned char colors[8];
101 total_blocks = blocks_wide * blocks_high;
103 row_dec = stride + 4;
105 for (block_y = blocks_high; block_y > 0; block_y--) {
106 block_ptr = ((block_y * 4) - 1) *
stride;
107 for (block_x = blocks_wide; block_x > 0; block_x--) {
110 block_ptr += block_inc;
116 pixel_ptr = block_ptr;
120 byte_a = s->
buf[stream_ptr++];
121 byte_b = s->
buf[stream_ptr++];
124 if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0))
126 else if ((byte_b & 0xFC) == 0x84) {
128 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
129 }
else if (byte_b < 0x80) {
131 flags = (byte_b << 8) | byte_a;
134 colors[0] = s->
buf[stream_ptr++];
135 colors[1] = s->
buf[stream_ptr++];
137 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
138 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
139 pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
140 pixel_ptr -= row_dec;
142 }
else if (byte_b >= 0x90) {
144 flags = (byte_b << 8) | byte_a;
147 memcpy(colors, &s->
buf[stream_ptr], 8);
150 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
151 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
152 pixels[pixel_ptr++] =
153 colors[((pixel_y & 0x2) << 1) +
154 (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
155 pixel_ptr -= row_dec;
161 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
162 for (pixel_x = 0; pixel_x < 4; pixel_x++)
163 pixels[pixel_ptr++] = colors[0];
164 pixel_ptr -= row_dec;
168 block_ptr += block_inc;
180 int block_ptr, pixel_ptr;
182 int pixel_x, pixel_y;
183 int block_x, block_y;
184 int blocks_wide, blocks_high;
190 unsigned char byte_a, byte_b;
191 unsigned short flags;
193 unsigned short colors[8];
194 unsigned short *pixels = (
unsigned short *)s->
frame.
data[0];
201 total_blocks = blocks_wide * blocks_high;
205 for (block_y = blocks_high; block_y > 0; block_y--) {
206 block_ptr = ((block_y * 4) - 1) *
stride;
207 for (block_x = blocks_wide; block_x > 0; block_x--) {
210 block_ptr += block_inc;
216 pixel_ptr = block_ptr;
220 byte_a = s->
buf[stream_ptr++];
221 byte_b = s->
buf[stream_ptr++];
224 if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0)) {
226 }
else if ((byte_b & 0xFC) == 0x84) {
228 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
229 }
else if (byte_b < 0x80) {
231 flags = (byte_b << 8) | byte_a;
239 if (colors[0] & 0x8000) {
255 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
256 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
257 pixels[pixel_ptr++] =
258 colors[((pixel_y & 0x2) << 1) +
259 (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
260 pixel_ptr -= row_dec;
264 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
265 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
266 pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
267 pixel_ptr -= row_dec;
272 colors[0] = (byte_b << 8) | byte_a;
274 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
275 for (pixel_x = 0; pixel_x < 4; pixel_x++)
276 pixels[pixel_ptr++] = colors[0];
277 pixel_ptr -= row_dec;
281 block_ptr += block_inc;
288 void *
data,
int *data_size,
291 const uint8_t *buf = avpkt->
data;
292 int buf_size = avpkt->
size;
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
#define FF_BUFFER_HINTS_VALID
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.
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)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static int init(AVCodecParserContext *s)
const unsigned char * buf
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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)
int width
picture width / height.
struct AVFrame AVFrame
Audio Video Frame.
static int msvideo1_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
#define FF_BUFFER_HINTS_REUSABLE
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
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)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_BUFFER_HINTS_PRESERVE
int palette_has_changed
Tell user application that palette has changed from previous frame.
static void msvideo1_decode_8bit(Msvideo1Context *s)
#define CHECK_STREAM_PTR(n)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int msvideo1_decode_init(AVCodecContext *avctx)
8 bit with PIX_FMT_RGB32 palette
struct Msvideo1Context Msvideo1Context