43 if (*x + run >= s->
width) {
44 int n = s->
width - *x;
45 memset(d + *x, value, n);
52 memset(d + *x, value, run);
60 int *x,
int *y,
int *plane,
int bits_per_plane)
63 int shift = *plane * bits_per_plane;
64 int mask = ((1 << bits_per_plane) - 1) << shift;
69 for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {
71 d[*x] |= (value >> j) & mask;
79 value <<= bits_per_plane;
80 mask <<= bits_per_plane;
94 [3] = { 0, 11, 13, 15 },
95 [4] = { 0, 10, 12, 14 },
96 [5] = { 0, 11, 12, 15 },
100 void *
data,
int *data_size,
105 int bits_per_plane, bpp, etype, esize, npal, pos_after_pal;
106 int i, x, y, plane, tmp;
113 if (bytestream2_get_le16u(&s->
g) != 0x1234)
116 s->
width = bytestream2_get_le16u(&s->
g);
117 s->
height = bytestream2_get_le16u(&s->
g);
119 tmp = bytestream2_get_byteu(&s->
g);
120 bits_per_plane = tmp & 0xF;
123 if (bits_per_plane > 8 || bpp < 1 || bpp > 32) {
128 if (bytestream2_peek_byte(&s->
g) == 0xFF) {
130 etype = bytestream2_get_le16(&s->
g);
131 esize = bytestream2_get_le16(&s->
g);
159 if (etype == 1 && esize > 1 && bytestream2_peek_byte(&s->
g) < 6) {
160 int idx = bytestream2_get_byte(&s->
g);
162 for (i = 0; i < npal; i++)
164 }
else if (etype == 2) {
165 npal =
FFMIN(esize, 16);
166 for (i = 0; i < npal; i++) {
167 int pal_idx = bytestream2_get_byte(&s->
g);
170 }
else if (etype == 3) {
171 npal =
FFMIN(esize, 16);
172 for (i = 0; i < npal; i++) {
173 int pal_idx = bytestream2_get_byte(&s->
g);
176 }
else if (etype == 4 || etype == 5) {
177 npal =
FFMIN(esize / 3, 256);
178 for (i = 0; i < npal; i++)
179 palette[i] = bytestream2_get_be24(&s->
g) << 2;
183 palette[0] = 0x000000;
184 palette[1] = 0xFFFFFF;
185 }
else if (bpp == 2) {
187 for (i = 0; i < npal; i++)
202 if (bytestream2_get_le16(&s->
g)) {
204 int stop_size, marker,
t1,
t2;
207 t2 = bytestream2_get_le16(&s->
g);
208 stop_size = t1 -
FFMIN(t1, t2);
211 marker = bytestream2_get_byte(&s->
g);
213 while (plane < s->nb_planes &&
216 int val = bytestream2_get_byte(&s->
g);
218 run = bytestream2_get_byte(&s->
g);
220 run = bytestream2_get_le16(&s->
g);
221 val = bytestream2_get_byte(&s->
g);
226 if (bits_per_plane == 8) {
231 picmemset(s, val, run, &x, &y, &plane, bits_per_plane);
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static const uint8_t cga_mode45_index[6][4]
static av_cold int decode_end(AVCodecContext *avctx)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static const uint16_t mask[17]
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static void picmemset(PicContext *s, int value, int run, int *x, int *y, int *plane, int bits_per_plane)
static void picmemset_8bpp(PicContext *s, int value, int run, int *x, int *y)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
int width
picture width / height.
struct AVFrame AVFrame
Audio Video Frame.
static av_always_inline int bytestream2_tell(GetByteContext *g)
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
void av_log_ask_for_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message asking for a sample.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVCodec ff_pictor_decoder
int palette_has_changed
Tell user application that palette has changed from previous frame.
const uint32_t ff_cga_palette[16]
const uint32_t ff_ega_palette[64]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
8 bit with PIX_FMT_RGB32 palette
struct PicContext PicContext
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)