67 7, 7, 2, 7, 3, 4, 5, 6, 7, 7, 7, 7, 7, 6, 7, 4, 5, 7, 7, 7, 7,
68 5, 6, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 7, 7, 6, 7, 7, 7, 7, 7, 7, 7,
69 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
73 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x05,
74 0x08, 0x09, 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x10, 0x11, 0x12, 0x13,
75 0x13, 0x13, 0x14, 0x15, 0x20, 0x21, 0x22, 0x23, 0x23, 0x24, 0x25,
76 0x28, 0x29, 0x2A, 0x2B, 0x2B, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
77 0x48, 0x49, 0x4A, 0x4B, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55,
81 20, 12, 0, 12, 1, 2, 4, 7, 7, 28, 4, 25, 17,
82 10, 17, 3, 6, 2, 23, 15, 15, 5, 9, 10, 31, 1, 22,
83 14, 14, 8, 9, 30, 6, 27, 19, 11, 19, 0, 21, 13, 13,
84 8, 29, 5, 26, 18, 18, 3, 24, 16, 16, 11, 32,
104 uint64_t ret = (1ULL << 52) / denom;
105 uint64_t err = (1ULL << 52) - ret * denom;
109 return ret + err / denom;
122 uint64_t l = x * (mantissa & 0xffffffff);
123 uint64_t
h = x * (mantissa >> 32);
133 return (x * 2) ^ (x >> 7);
144 }
else if (
bits == 0) {
159 int i, j, scale_factor;
160 unsigned prob, cumulative_target;
161 unsigned cumul_prob = 0;
162 unsigned scaled_cumul_prob = 0;
166 rac->
prob[257] = UINT_MAX;
168 for (
i = 1;
i < 257;
i++) {
173 if ((uint64_t)cumul_prob + rac->
prob[
i] > UINT_MAX) {
177 cumul_prob += rac->
prob[
i];
185 for (j = 0; j <
prob; j++)
202 scale_factor =
av_log2(cumul_prob);
204 if (cumul_prob & (cumul_prob - 1)) {
206 for (
i = 1;
i <= 128;
i++) {
208 scaled_cumul_prob += rac->
prob[
i];
210 if (scaled_cumul_prob <= 0) {
214 for (;
i < 257;
i++) {
216 scaled_cumul_prob += rac->
prob[
i];
220 if (scale_factor >= 32U)
222 cumulative_target = 1U << scale_factor;
224 if (scaled_cumul_prob > cumulative_target) {
226 "Scaled probabilities are larger than target!\n");
230 scaled_cumul_prob = cumulative_target - scaled_cumul_prob;
232 for (
i = 1; scaled_cumul_prob;
i = (
i & 0x7f) + 1) {
251 if (scale_factor > 23)
254 rac->
scale = scale_factor;
257 for (
i = 1;
i < 257;
i++)
277 for (
i = 0;
i <
w;
i++) {
329 const int HEAD = is_luma ? 4 : 2;
333 TL = buf[HEAD -
stride - 1];
334 for (
i = 0;
i < HEAD;
i++) {
364 memset(
dst +
i, 0, count);
379 if (l->
zeros == esc_count) {
393 const uint8_t *
src,
const uint8_t *src_end,
394 int width,
int esc_count)
398 uint8_t zero_run = 0;
399 const uint8_t *src_start =
src;
400 uint8_t mask1 = -(esc_count < 2);
401 uint8_t mask2 = -(esc_count < 3);
411 if (end -
dst < count) {
416 memset(
dst, 0, count);
423 while (!zero_run &&
dst +
i < end) {
425 if (
i+2 >= src_end -
src)
428 !(
src[
i] | (
src[
i + 1] & mask1) | (
src[
i + 2] & mask2));
448 return src - src_start;
455 const uint8_t *
src,
int src_size)
464 const uint8_t *src_end =
src + src_size;
499 "Output more bytes than length (%d of %"PRIu32
")\n",
read,
501 }
else if (esc_count < 8) {
509 src_end,
width, esc_count);
523 }
else if (esc_count == 0xff) {
533 "Invalid zero run escape code! (%#x)\n", esc_count);
564 const uint8_t *buf = avpkt->
data;
565 unsigned int buf_size = avpkt->
size;
568 uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9;
597 memset(p->data[0] +
i * p->linesize[0], buf[2], avctx->
width);
598 memset(p->data[1] +
i * p->linesize[1], buf[1], avctx->
width);
599 memset(p->data[2] +
i * p->linesize[2], buf[3], avctx->
width);
600 memset(p->data[3] +
i * p->linesize[3], buf[4], avctx->
width);
604 for (j = 0; j <
planes; j++)
605 memset(p->data[j] +
i * p->linesize[j], buf[1], avctx->
width);
620 memset(p->data[0] +
i * p->linesize[0], buf[2], avctx->
width);
621 memset(p->data[1] +
i * p->linesize[1], buf[1], avctx->
width);
622 memset(p->data[2] +
i * p->linesize[2], buf[3], avctx->
width);
624 memset(p->data[3] +
i * p->linesize[3], 0xFFu, avctx->
width);
646 srcs[
i] = p->data[
i] + (avctx->
height - 1) * p->linesize[
i];
648 if (buf_size <= offs[
i]) {
650 "Invalid frame offsets\n");
657 -p->linesize[
i], buf + offs[
i],
666 FFSWAP(uint8_t*, p->data[0], p->data[1]);
667 FFSWAP(
int, p->linesize[0], p->linesize[1]);
668 FFSWAP(uint8_t*, p->data[2], p->data[1]);
669 FFSWAP(
int, p->linesize[2], p->linesize[1]);
677 if (offset_ry >= buf_size ||
678 offset_gu >= buf_size ||
679 offset_bv >= buf_size) {
681 "Invalid frame offsets\n");
686 p->linesize[0], buf + offset_ry,
687 buf_size - offset_ry);
691 avctx->
height, p->linesize[1],
692 buf + offset_gu, buf_size - offset_gu);
696 avctx->
height, p->linesize[2],
697 buf + offset_bv, buf_size - offset_bv);
705 if (offset_ry >= buf_size ||
706 offset_gu >= buf_size ||
707 offset_bv >= buf_size) {
709 "Invalid frame offsets\n");
714 p->linesize[0], buf + offset_ry,
715 buf_size - offset_ry);
719 (avctx->
height + 1) / 2, p->linesize[2],
720 buf + offset_gu, buf_size - offset_gu);
724 (avctx->
height + 1) / 2, p->linesize[1],
725 buf + offset_bv, buf_size - offset_bv);
729 "Unsupported Lagarith frame type: %#"PRIx8
"\n", frametype);
754 .p.name =
"lagarith",
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
const FFCodec ff_lagarith_decoder
Libavcodec external API header.
static uint32_t BS_FUNC read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
#define prob(name, subs,...)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
int(* init)(AVBSFContext *ctx)
static const uint8_t bits[8]
bitstream reader API header.
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void add_lag_median_prediction(uint8_t *dst, uint8_t *src1, uint8_t *diff, int w, int *left, int *left_top)
static av_cold void lag_init_static_data(void)
static int lag_decode_line(LagarithContext *l, lag_rac *rac, uint8_t *dst, int width, int stride, int esc_count)
static int lag_decode_prob(GetBitContext *gb, uint32_t *value)
static const uint8_t lag_bits[]
static uint8_t lag_calc_zero_run(int8_t x)
static const uint8_t lag_codes[]
static int lag_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
Decode a frame.
static void lag_pred_line_yuy2(LagarithContext *l, uint8_t *buf, int width, int stride, int line, int is_luma)
static int lag_read_prob_header(lag_rac *rac, GetBitContext *gb)
static VLCElem lag_tab[1<< VLC_BITS]
static uint32_t softfloat_mul(uint32_t x, uint64_t mantissa)
(uint32_t)(x*f), where f has the given mantissa, and exponent 0 Used in combination with softfloat_re...
static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst, const uint8_t *src, const uint8_t *src_end, int width, int esc_count)
static av_cold int lag_decode_init(AVCodecContext *avctx)
static void lag_pred_line(LagarithContext *l, uint8_t *buf, int width, int stride, int line)
static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst, int width, int height, int stride, const uint8_t *src, int src_size)
static const uint8_t lag_symbols[]
static uint64_t softfloat_reciprocal(uint32_t denom)
Compute the 52-bit mantissa of 1/(double)denom.
@ FRAME_ARITH_RGB24
arithmetic coded RGB24
@ FRAME_SOLID_COLOR
solid non-grayscale color frame
@ FRAME_SOLID_GRAY
solid grayscale color frame
@ FRAME_OLD_ARITH_RGB
obsolete arithmetic coded RGB (no longer encoded by upstream since version 1.1.0)
@ FRAME_ARITH_YUY2
arithmetic coded YUY2
@ FRAME_SOLID_RGBA
solid RGBA color frame
@ FRAME_ARITH_YV12
arithmetic coded YV12
@ FRAME_REDUCED_RES
reduced resolution YV12 frame
@ FRAME_U_RGB24
unaligned RGB24
@ FRAME_ARITH_RGBA
arithmetic coded RGBA
void ff_lag_rac_init(lag_rac *l, GetBitContext *gb, int length)
static uint8_t lag_get_rac(lag_rac *l)
Decode a single byte from the compressed plane described by *l.
static int shift(int a, int b)
Multithreading API for decoders.
Macro definitions for various function/variable attributes.
static int ff_thread_once(char *control, void(*routine)(void))
static const struct @257111027162314367033347246032313251342043035002 planes[]
av_cold void ff_llviddsp_init(LLVidDSPContext *c)
#define FFSWAP(type, a, b)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
void(* add_bytes)(uint8_t *dst, uint8_t *src, ptrdiff_t w)
int(* add_left_pred)(uint8_t *dst, const uint8_t *src, ptrdiff_t w, int left)
void(* add_median_pred)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, ptrdiff_t w, int *left, int *left_top)
int zeros_rem
number of zero bytes remaining to output
int zeros
number of consecutive zero bytes encountered
unsigned scale
Number of bits of precision in range.
uint32_t prob[258]
Table of cumulative probability for each symbol.
#define avpriv_request_sample(...)
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
#define VLC_INIT_STATIC_SPARSE_TABLE(vlc_table, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, symbols, symbols_wrap, symbols_size, flags)