39 #define PALETTE_COUNT 256 40 #define CHECK_STREAM_PTR(n) \ 41 if ((stream_ptr + n) > s->size ) { \ 42 av_log(s->avctx, AV_LOG_ERROR, " MS Video-1 warning: stream_ptr out of bounds (%d >= %d)\n", \ 43 stream_ptr + n, s->size); \ 52 const unsigned char *
buf;
82 int block_ptr, pixel_ptr;
86 int blocks_wide, blocks_high;
92 unsigned char byte_a, byte_b;
95 unsigned char colors[8];
103 total_blocks = blocks_wide * blocks_high;
105 row_dec = stride + 4;
107 for (block_y = blocks_high; block_y > 0; block_y--) {
108 block_ptr = ((block_y * 4) - 1) *
stride;
109 for (block_x = blocks_wide; block_x > 0; block_x--) {
112 block_ptr += block_inc;
118 pixel_ptr = block_ptr;
122 byte_a = s->
buf[stream_ptr++];
123 byte_b = s->
buf[stream_ptr++];
126 if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0))
128 else if ((byte_b & 0xFC) == 0x84) {
130 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
131 }
else if (byte_b < 0x80) {
133 flags = (byte_b << 8) | byte_a;
136 colors[0] = s->
buf[stream_ptr++];
137 colors[1] = s->
buf[stream_ptr++];
139 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
140 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
141 pixels[pixel_ptr++] = colors[(flags & 0
x1) ^ 1];
142 pixel_ptr -= row_dec;
144 }
else if (byte_b >= 0x90) {
146 flags = (byte_b << 8) | byte_a;
149 memcpy(colors, &s->
buf[stream_ptr], 8);
152 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
153 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
154 pixels[pixel_ptr++] =
155 colors[((pixel_y & 0
x2) << 1) +
156 (pixel_x & 0x2) + ((flags & 0
x1) ^ 1)];
157 pixel_ptr -= row_dec;
163 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
164 for (pixel_x = 0; pixel_x < 4; pixel_x++)
165 pixels[pixel_ptr++] = colors[0];
166 pixel_ptr -= row_dec;
170 block_ptr += block_inc;
182 int block_ptr, pixel_ptr;
184 int pixel_x, pixel_y;
185 int block_x, block_y;
186 int blocks_wide, blocks_high;
192 unsigned char byte_a, byte_b;
193 unsigned short flags;
195 unsigned short colors[8];
196 unsigned short *pixels = (
unsigned short *)s->
frame.
data[0];
203 total_blocks = blocks_wide * blocks_high;
207 for (block_y = blocks_high; block_y > 0; block_y--) {
208 block_ptr = ((block_y * 4) - 1) *
stride;
209 for (block_x = blocks_wide; block_x > 0; block_x--) {
212 block_ptr += block_inc;
218 pixel_ptr = block_ptr;
222 byte_a = s->
buf[stream_ptr++];
223 byte_b = s->
buf[stream_ptr++];
226 if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0)) {
228 }
else if ((byte_b & 0xFC) == 0x84) {
230 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
231 }
else if (byte_b < 0x80) {
233 flags = (byte_b << 8) | byte_a;
241 if (colors[0] & 0x8000) {
257 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
258 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
259 pixels[pixel_ptr++] =
260 colors[((pixel_y & 0
x2) << 1) +
261 (pixel_x & 0x2) + ((flags & 0
x1) ^ 1)];
262 pixel_ptr -= row_dec;
266 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
267 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
268 pixels[pixel_ptr++] = colors[(flags & 0
x1) ^ 1];
269 pixel_ptr -= row_dec;
274 colors[0] = (byte_b << 8) | byte_a;
276 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
277 for (pixel_x = 0; pixel_x < 4; pixel_x++)
278 pixels[pixel_ptr++] = colors[0];
279 pixel_ptr -= row_dec;
283 block_ptr += block_inc;
290 void *
data,
int *got_frame,
294 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.
static av_cold int init(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_cold int msvideo1_decode_end(AVCodecContext *avctx)
8 bit with PIX_FMT_RGB32 palette
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
const unsigned char * buf
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * name
Name of the codec implementation.
AVCodec ff_msvideo1_decoder
static void msvideo1_decode_16bit(Msvideo1Context *s)
common internal API header
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.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static void close(AVCodecParserContext *s)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
int palette_has_changed
Tell user application that palette has changed from previous frame.
static void msvideo1_decode_8bit(Msvideo1Context *s)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define CHECK_STREAM_PTR(n)
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.
static av_cold int msvideo1_decode_init(AVCodecContext *avctx)
common internal api header.
#define AV_PIX_FMT_RGB555
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)
This structure stores compressed data.
struct Msvideo1Context Msvideo1Context