43 #define EPIC_PIX_STACK_SIZE 1024
44 #define EPIC_PIX_STACK_MAX (EPIC_PIX_STACK_SIZE - 1)
61 8, 6, 5, 8, 12, 20, 26, 31,
62 6, 6, 7, 10, 13, 29, 30, 28,
63 7, 7, 8, 12, 20, 29, 35, 28,
64 7, 9, 11, 15, 26, 44, 40, 31,
65 9, 11, 19, 28, 34, 55, 52, 39,
66 12, 18, 28, 32, 41, 52, 57, 46,
67 25, 32, 39, 44, 52, 61, 60, 51,
68 36, 46, 48, 49, 56, 50, 52, 50
72 9, 9, 12, 24, 50, 50, 50, 50,
73 9, 11, 13, 33, 50, 50, 50, 50,
74 12, 13, 28, 50, 50, 50, 50, 50,
75 24, 33, 50, 50, 50, 50, 50, 50,
76 50, 50, 50, 50, 50, 50, 50, 50,
77 50, 50, 50, 50, 50, 50, 50, 50,
78 50, 50, 50, 50, 50, 50, 50, 50,
79 50, 50, 50, 50, 50, 50, 50, 50,
93 #define EPIC_HASH_SIZE 256
161 const uint8_t *val_table,
int nb_codes,
164 uint8_t huff_size[256] = { 0 };
165 uint16_t huff_code[256];
166 uint16_t huff_sym[256];
171 for (i = 0; i < 256; i++)
172 huff_sym[i] = i + 16 * is_ac;
175 huff_sym[0] = 16 * 256;
178 huff_code, 2, 2, huff_sym, 2, 2, 0);
214 for (i = 0; i < 2; i++) {
225 const uint8_t *src_end = src + src_size;
228 while (src < src_end) {
233 if (x == 0xFF && !*src)
236 *dst_size = dst - dst_start;
243 const int is_chroma = !!
plane;
278 out[ridx] = av_clip_uint8(Y + (91881 * V + 32768 >> 16));
279 out[1] = av_clip_uint8(Y + (-22554 * U - 46802 * V + 32768 >> 16));
280 out[2 - ridx] = av_clip_uint8(Y + (116130 * U + 32768 >> 16));
290 int mb_w, mb_h, mb_x, mb_y, i, j;
294 const int ridx = swapuv ? 2 : 0;
306 mb_h = (height + 15) >> 4;
309 num_mbs = mb_w * mb_h * 4;
311 for (i = 0; i < 3; i++)
316 for (mb_y = 0; mb_y < mb_h; mb_y++) {
317 for (mb_x = 0; mb_x < mb_w; mb_x++) {
318 if (mask && !mask[mb_x * 2] && !mask[mb_x * 2 + 1] &&
319 !mask[mb_x * 2 + mask_stride] &&
320 !mask[mb_x * 2 + 1 + mask_stride]) {
324 for (j = 0; j < 2; j++) {
325 for (i = 0; i < 2; i++) {
326 if (mask && !mask[mb_x * 2 + i + j * mask_stride])
330 c->
block[i + j * 2])) != 0)
335 for (i = 1; i < 3; i++) {
341 for (j = 0; j < 16; j++) {
342 uint8_t *
out = dst + bx * 3 + (by + j) * dst_stride;
343 for (i = 0; i < 16; i++) {
346 Y = c->
block[(j >> 3) * 2 + (i >> 3)][(i & 7) + (j & 7) * 8];
347 U = c->
block[4][(i >> 1) + (j >> 1) * 8] - 128;
348 V = c->
block[5][(i >> 1) + (j >> 1) * 8] - 128;
349 yuv2rgb(out + i * 3, ridx, Y, U, V);
360 mask += mask_stride * 2;
366 #define LOAD_NEIGHBOURS(x) \
367 W = curr_row[(x) - 1]; \
368 N = above_row[(x)]; \
369 WW = curr_row[(x) - 2]; \
370 NW = above_row[(x) - 1]; \
371 NE = above_row[(x) + 1]; \
372 NN = above2_row[(x)]; \
373 NNW = above2_row[(x) - 1]; \
374 NWW = above_row[(x) - 2]; \
375 NNE = above2_row[(x) + 1]
377 #define UPDATE_NEIGHBOURS(x) \
383 NE = above_row[(x) + 1]; \
384 NNE = above2_row[(x) + 1]
395 h = (h * 33) ^ ((key >> 24) & 0xFF);
396 h = (h * 33) ^ ((key >> 16) & 0xFF);
397 h = (h * 33) ^ ((key >> 8) & 0xFF);
398 h = (h * 33) ^ (key & 0xFF);
405 memset(hash, 0,
sizeof(*hash));
414 if (bucket[i].pix_id == key)
433 hash->
bucket[idx] = bucket;
438 memset(ret, 0,
sizeof(*ret));
457 new_elem->
pixel = pix;
459 hash_elem->
list = new_elem;
499 if (dc->
stack[i] == pix)
505 #define TOSIGNED(val) (((val) >> 1) ^ -((val) & 1))
508 int N,
int W,
int NW)
515 const uint32_t *curr_row,
516 const uint32_t *above_row)
520 int GN, GW, GNW,
R,
G,
B;
525 NW = above_row[x - 1];
536 ((NW >>
R_shift) & 0xFF) - GNW);
541 ((NW >>
B_shift) & 0xFF) - GNW);
544 pred = curr_row[x - 1];
558 if (R<0 || G<0 || B<0) {
567 uint32_t *pPix, uint32_t pix)
578 const uint32_t *curr_row,
579 const uint32_t *above_row, uint32_t *pPix)
592 pix = curr_row[x - 1];
609 const uint32_t *curr_row,
610 const uint32_t *above_row,
611 const uint32_t *above2_row,
612 uint32_t *pPix,
int *pRun)
614 int idx, got_pixel = 0, WWneW, old_WWneW = 0;
615 uint32_t
W, WW,
N, NN, NW, NE, NWW, NNW, NNE;
625 idx = (WW !=
W) << 7 |
648 NWneW = *pRun ? NWneW : NW !=
W;
651 switch (((NW != N) << 2) | (NWneW << 1) | WWneW) {
660 (*pRun ? old_WWneW : WW !=
W) << 7 |
685 if (x + *pRun >= tile_width - 1)
690 if (!NWneW && NW == N && N == NE) {
692 int start_pos = x + *pRun;
695 uint32_t pix = above_row[start_pos + 1];
696 for (pos = start_pos + 2; pos < tile_width; pos++)
697 if (!(above_row[pos] == pix))
699 run = pos - start_pos - 1;
700 idx = av_ceil_log2(run);
706 for (pos = idx - 1, rle = 0, flag = 0; pos >= 0; pos--) {
707 if ((1 << pos) + rle < run &&
718 if (x + *pRun >= tile_width - 1)
742 uint32_t *pPix, uint32_t pix)
753 int tile_width,
const uint32_t *curr_row,
754 const uint32_t *above_row, uint32_t *pPix)
760 uint32_t NW = above_row[x - 1];
769 if (pos < tile_width - 1 && y) {
770 uint32_t NE = above_row[pos + 1];
785 if (!hash_elem || !hash_elem->
list)
788 list = hash_elem->
list;
793 if (list != hash_elem->
list) {
796 hash_elem->
list = list;
810 int tile_width,
int stride)
814 uint32_t *curr_row =
NULL, *above_row =
NULL, *above2_row;
816 for (y = 0; y < tile_height; y++, out +=
stride) {
817 above2_row = above_row;
818 above_row = curr_row;
819 curr_row = (uint32_t *) out;
825 pix = curr_row[x - 1];
827 if (y >= 1 && x >= 2 &&
828 pix != curr_row[x - 2] && pix != above_row[x - 1] &&
829 pix != above_row[x - 2] && pix != above_row[x] &&
837 if (y < 2 || x < 2 || x == tile_width - 1) {
843 above2_row, &pix, &run);
846 tile_width, curr_row,
848 uint32_t ref_pix = curr_row[x - 1];
860 for (; run > 0; x++, run--)
874 int extrabytes, tile_width, tile_height, awidth, aheight;
884 for (extrabytes = 0; (prefix &
mask) && (extrabytes < 7); extrabytes++)
886 if (extrabytes > 3 || src_size < extrabytes) {
891 els_dsize = prefix & ((0x80 >> extrabytes) - 1);
892 while (extrabytes-- > 0) {
893 els_dsize = (els_dsize << 8) | *src++;
897 if (src_size < els_dsize) {
899 els_dsize, src_size);
905 awidth =
FFALIGN(tile_width, 16);
906 aheight =
FFALIGN(tile_height, 16);
913 memset(&c->
ec, 0,
sizeof(c->
ec));
923 "ePIC: couldn't decode transparency pixel!\n");
935 "ePIC: tile decoding failed, frame=%d, tile_x=%d, tile_y=%d\n",
944 for (j = 0; j < tile_height; j++) {
946 in = (uint32_t *) buf;
947 for (i = 0; i < tile_width; i++) {
948 out[0] = (in[i] >>
R_shift) & 0xFF;
949 out[1] = (in[i] >>
G_shift) & 0xFF;
950 out[2] = (in[i] >>
B_shift) & 0xFF;
957 if (src_size > els_dsize) {
960 int bstride =
FFALIGN(tile_width, 16) >> 3;
965 src_size -= els_dsize;
971 (aheight >> 3) * bstride *
sizeof(*c->
kempf_flags));
972 for (j = 0; j < tile_height; j += 8) {
973 for (i = 0; i < tile_width; i += 8) {
975 for (k = 0; k < 8 * 8; k++) {
976 if (in[i + (k & 7) + (k >> 3) * estride] == tr) {
995 for (j = 0; j < tile_height; j++) {
996 for (i = 0; i < tile_width; i++)
998 memcpy(dst + i * 3, jpg + i * 3, 3);
1016 const uint8_t *jpeg_tile,
int tile_stride,
1018 const uint8_t *pal,
int npal,
int tidx)
1023 int align_width =
FFALIGN(width, 16);
1028 if (npal <= 2) nb = 1;
1029 else if (npal <= 4) nb = 2;
1030 else if (npal <= 16) nb = 4;
1033 for (j = 0; j <
height; j++, dst +=
stride, jpeg_tile += tile_stride) {
1036 for (i = 0; i <
width; i++) {
1039 memcpy(dst + i * 3, pal + col * 3, 3);
1041 memcpy(dst + i * 3, jpeg_tile + i * 3, 3);
1053 int hdr, zsize, npal, tidx = -1, ret;
1055 const uint8_t *src_end = src + src_size;
1059 int nblocks, cblocks, bstride;
1060 int bits, bitbuf, coded;
1071 sub_type = hdr >> 5;
1072 if (sub_type == 0) {
1074 memcpy(transp, src, 3);
1077 for (i = 0; i <
width; i++)
1078 memcpy(dst + i * 3, transp, 3);
1080 }
else if (sub_type == 1) {
1085 if (sub_type != 2) {
1086 memcpy(transp, src, 3);
1090 if (src_end - src < npal * 3)
1092 memcpy(pal, src, npal * 3);
1094 if (sub_type != 2) {
1095 for (i = 0; i < npal; i++) {
1096 if (!memcmp(pal + i * 3, transp, 3)) {
1103 if (src_end - src < 2)
1105 zsize = (src[0] << 8) | src[1];
1108 if (src_end - src < zsize + (sub_type != 2))
1111 ret = uncompress(c->
kempf_buf, &dlen, src, zsize);
1116 if (sub_type == 2) {
1118 NULL, 0, width, height, pal, npal, tidx);
1122 nblocks = *src++ + 1;
1124 bstride =
FFALIGN(width, 16) >> 3;
1127 for (i = 0; i < (FFALIGN(height, 16) >> 4); i++) {
1128 for (j = 0; j < (FFALIGN(width, 16) >> 4); j++) {
1139 if (cblocks > nblocks)
1144 c->
kempf_flags[j * 2 + 1 + (i * 2 + 1) * bstride] = coded;
1155 width, height, pal, npal, tidx);
1166 aligned_height = c->
height + 15;
1210 uint32_t cur_size, cursor_w, cursor_h, cursor_stride;
1211 uint32_t cursor_hot_x, cursor_hot_y;
1212 int cursor_fmt, err;
1214 cur_size = bytestream2_get_be32(gb);
1215 cursor_w = bytestream2_get_byte(gb);
1216 cursor_h = bytestream2_get_byte(gb);
1217 cursor_hot_x = bytestream2_get_byte(gb);
1218 cursor_hot_y = bytestream2_get_byte(gb);
1219 cursor_fmt = bytestream2_get_byte(gb);
1221 cursor_stride =
FFALIGN(cursor_w, cursor_fmt==1 ? 32 : 1) * 4;
1223 if (cursor_w < 1 || cursor_w > 256 ||
1224 cursor_h < 1 || cursor_h > 256) {
1226 cursor_w, cursor_h);
1229 if (cursor_hot_x > cursor_w || cursor_hot_y > cursor_h) {
1231 cursor_hot_x, cursor_hot_y);
1232 cursor_hot_x =
FFMIN(cursor_hot_x, cursor_w - 1);
1233 cursor_hot_y =
FFMIN(cursor_hot_y, cursor_h - 1);
1241 if (cursor_fmt != 1 && cursor_fmt != 32) {
1262 for (j = 0; j < c->
cursor_h; j++) {
1263 for (i = 0; i < c->
cursor_w; i += 32) {
1264 bits = bytestream2_get_be32(gb);
1265 for (k = 0; k < 32; k++) {
1266 dst[0] = !!(bits & 0x80000000);
1274 for (j = 0; j < c->
cursor_h; j++) {
1275 for (i = 0; i < c->
cursor_w; i += 32) {
1276 bits = bytestream2_get_be32(gb);
1277 for (k = 0; k < 32; k++) {
1278 int mask_bit = !!(bits & 0x80000000);
1279 switch (dst[0] * 2 + mask_bit) {
1307 for (j = 0; j < c->
cursor_h; j++) {
1308 for (i = 0; i < c->
cursor_w; i++) {
1309 int val = bytestream2_get_be32(gb);
1323 #define APPLY_ALPHA(src, new, alpha) \
1324 src = (src * (256 - alpha) + new * alpha) >> 8
1342 if (x + w > c->
width)
1361 for (j = 0; j <
h; j++) {
1362 for (i = 0; i < w; i++) {
1364 APPLY_ALPHA(dst[i * 3 + 0], cursor[i * 4 + 1], alpha);
1365 APPLY_ALPHA(dst[i * 3 + 1], cursor[i * 4 + 2], alpha);
1366 APPLY_ALPHA(dst[i * 3 + 2], cursor[i * 4 + 3], alpha);
1374 int *got_picture_ptr,
AVPacket *avpkt)
1377 int buf_size = avpkt->
size;
1383 uint32_t chunk_size, r_mask, g_mask, b_mask;
1388 if (buf_size < 12) {
1390 "Frame should have at least 12 bytes, got %d instead\n",
1397 magic = bytestream2_get_be32(&bc);
1398 if ((magic & ~0xF) !=
MKBETAG(
'G',
'2',
'M',
'0') ||
1399 (magic & 0xF) < 2 || (magic & 0xF) > 5) {
1407 chunk_size = bytestream2_get_le32(&bc) - 1;
1408 chunk_type = bytestream2_get_byte(&bc);
1412 chunk_size, chunk_type);
1415 switch (chunk_type) {
1419 if (chunk_size < 21) {
1424 c->
width = bytestream2_get_be32(&bc);
1425 c->
height = bytestream2_get_be32(&bc);
1429 "Invalid frame dimensions %dx%d\n",
1442 "Unknown compression method %d\n",
1454 "Invalid tile dimensions %dx%d\n",
1461 c->
bpp = bytestream2_get_byte(&bc);
1464 (chunk_size - 21) < 16) {
1466 "Display info: missing bitmasks!\n");
1470 r_mask = bytestream2_get_be32(&bc);
1471 g_mask = bytestream2_get_be32(&bc);
1472 b_mask = bytestream2_get_be32(&bc);
1473 if (r_mask != 0xFF0000 || g_mask != 0xFF00 || b_mask != 0xFF) {
1475 "Invalid or unsupported bitmasks: R=%"PRIX32
", G=%"PRIX32
", B=%"PRIX32
"\n",
1476 r_mask, g_mask, b_mask);
1494 "No display info - skipping tile\n");
1497 if (chunk_size < 2) {
1502 c->
tile_x = bytestream2_get_byte(&bc);
1503 c->
tile_y = bytestream2_get_byte(&bc);
1506 "Invalid tile pos %d,%d (in %dx%d grid)\n",
1515 chunk_size - 2, avctx);
1528 if (chunk_size < 5) {
1533 c->
cursor_x = bytestream2_get_be16(&bc);
1534 c->
cursor_y = bytestream2_get_be16(&bc);
1537 if (chunk_size < 8) {
1567 for (i = 0; i < avctx->
height; i++)
1573 *got_picture_ptr = 1;
#define LOAD_NEIGHBOURS(x)
static int epic_predict_from_NW_NE(ePICContext *dc, int x, int y, int run, int tile_width, const uint32_t *curr_row, const uint32_t *above_row, uint32_t *pPix)
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int epic_handle_edges(ePICContext *dc, int x, int y, const uint32_t *curr_row, const uint32_t *above_row, uint32_t *pPix)
static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y, const uint8_t *src, int src_size)
static int epic_add_pixel_to_cache(ePICPixHash *hash, uint32_t key, uint32_t pix)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
void(* clear_block)(int16_t *block)
static av_cold void jpg_free_context(JPGContext *ctx)
static int chunk_start(AVFormatContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 8:8:8, 24bpp, RGBRGB...
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static int epic_predict_pixel(ePICContext *dc, uint8_t *rung, uint32_t *pPix, uint32_t pix)
static void skip_bits_long(GetBitContext *s, int n)
static av_cold int init(AVCodecContext *avctx)
uint8_t nw_pred_rung[256]
Entropy Logarithmic-Scale binary arithmetic coder.
static void yuv2rgb(uint8_t *out, int ridx, int Y, int U, int V)
static int epic_decode_tile(ePICContext *dc, uint8_t *out, int tile_height, int tile_width, int stride)
uint32_t stack[EPIC_PIX_STACK_SIZE]
int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
void(* clear_blocks)(int16_t *blocks)
#define DECLARE_ALIGNED(n, t, v)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static int g2m_init_buffers(G2MContext *c)
MJPEG encoder and decoder.
static void jpg_unescape(const uint8_t *src, int src_size, uint8_t *dst, int *dst_size)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table)
static int epic_cache_entries_for_pixel(const ePICPixHash *hash, uint32_t pix)
static ePICPixHashElem * epic_hash_find(const ePICPixHash *hash, uint32_t key)
static int epic_decode_component_pred(ePICContext *dc, int N, int W, int NW)
static int is_pixel_on_stack(const ePICContext *dc, uint32_t pix)
const uint8_t avpriv_mjpeg_bits_dc_luminance[17]
struct ePICPixListElem * list
int av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
bitstream reader API header.
static void epic_free_pixel_cache(ePICPixHash *hash)
static av_cold int g2m_decode_init(AVCodecContext *avctx)
static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c)
static double alpha(void *priv, double x, double y)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
ElsUnsignedRung unsigned_rung
static const uint16_t mask[17]
static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c, GetByteContext *gb)
static av_cold int g2m_decode_end(AVCodecContext *avctx)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
const uint8_t avpriv_mjpeg_bits_dc_chrominance[17]
uint8_t runlen_zeroes[14]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int epic_jb_decode_tile(G2MContext *c, int tile_x, int tile_y, const uint8_t *src, size_t src_size, AVCodecContext *avctx)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const char * name
Name of the codec implementation.
void ff_els_decoder_init(ElsDecCtx *ctx, const uint8_t *in, size_t data_size)
static ePICPixHashElem * epic_hash_add(ePICPixHash *hash, uint32_t key)
Libavcodec external API header.
static int jpg_decode_block(JPGContext *c, GetBitContext *gb, int plane, int16_t *block)
uint8_t prev_row_rung[14]
enum AVPictureType pict_type
Picture type of the frame.
static int jpg_decode_data(JPGContext *c, int width, int height, const uint8_t *src, int src_size, uint8_t *dst, int dst_stride, const uint8_t *mask, int mask_stride, int num_mbs, int swapuv)
static int g2m_decode_frame(AVCodecContext *avctx, void *data, int *got_picture_ptr, AVPacket *avpkt)
int width
picture width / height.
static int epic_predict_pixel2(ePICContext *dc, uint8_t *rung, uint32_t *pPix, uint32_t pix)
static void g2m_paint_cursor(G2MContext *c, uint8_t *dst, int stride)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
uint8_t idct_permutation[64]
IDCT input permutation.
uint8_t ne_pred_rung[256]
static const float pred[4]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static uint32_t epic_decode_pixel_pred(ePICContext *dc, int x, int y, const uint32_t *curr_row, const uint32_t *above_row)
static av_always_inline int bytestream2_tell(GetByteContext *g)
static struct AVHashContext * hash
#define EPIC_PIX_STACK_MAX
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
static int kempf_restore_buf(const uint8_t *src, int len, uint8_t *dst, int stride, const uint8_t *jpeg_tile, int tile_stride, int width, int height, const uint8_t *pal, int npal, int tidx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define APPLY_ALPHA(src, new, alpha)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
int bucket_size[EPIC_HASH_SIZE]
main external API structure.
static av_cold int build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table, int nb_codes, int is_ac)
static int get_xbits(GetBitContext *s, int n)
read mpeg1 dc style vlc (sign bit + mantissa with no MSB).
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
const uint8_t avpriv_mjpeg_val_dc[12]
BYTE int const BYTE int int int height
static int djb2_hash(uint32_t key)
const uint8_t ff_zigzag_direct[64]
ePICPixHashElem * bucket[EPIC_HASH_SIZE]
const uint8_t avpriv_mjpeg_bits_ac_chrominance[17]
unsigned ff_els_decode_unsigned(ElsDecCtx *ctx, ElsUnsignedRung *ur)
static const uint8_t chroma_quant[64]
const uint8_t avpriv_mjpeg_val_ac_chrominance[]
static int epic_decode_from_cache(ePICContext *dc, uint32_t W, uint32_t *pPix)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
struct ePICPixListElem * next
int bucket_fill[EPIC_HASH_SIZE]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void epic_hash_init(ePICPixHash *hash)
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
GLint GLenum GLboolean GLsizei stride
common internal api header.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
static const uint8_t luma_quant[64]
#define MKBETAG(a, b, c, d)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
const uint8_t avpriv_mjpeg_bits_ac_luminance[17]
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
#define UPDATE_NEIGHBOURS(x)
const uint8_t avpriv_mjpeg_val_ac_luminance[]
#define EPIC_PIX_STACK_SIZE
VLC_TYPE(* table)[2]
code, bits
void ff_els_decoder_uninit(ElsUnsignedRung *rung)
int key_frame
1 -> keyframe, 0-> not
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
int ff_els_decode_bit(ElsDecCtx *ctx, uint8_t *rung)
static void * av_mallocz_array(size_t nmemb, size_t size)
int frame_number
Frame counter, set by libavcodec.
static int epic_decode_run_length(ePICContext *dc, int x, int y, int tile_width, const uint32_t *curr_row, const uint32_t *above_row, const uint32_t *above2_row, uint32_t *pPix, int *pRun)
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
void(* idct)(int16_t *block)