27 #define CACHED_BITSTREAM_READER !ARCH_X86_32
58 Node *nodes,
int node,
59 uint32_t pfx,
int pl,
int *
pos)
67 xlat[*
pos] =
s + (pl == 0);
87 int cur_node,
i, j,
pos = 0;
91 for (
i = 0;
i <
s->nb_symbols;
i++) {
99 cur_node =
s->nb_symbols;
104 int first_node = cur_node;
105 int second_node = cur_node;
108 nodes[cur_node].
count = -1;
112 if (
val && (
val < nodes[first_node].count)) {
113 if (
val >= nodes[second_node].count) {
114 first_node = new_node;
116 first_node = second_node;
117 second_node = new_node;
121 }
while (new_node != cur_node);
123 if (first_node == cur_node)
126 nd = nodes[second_node].
count;
127 st = nodes[first_node].
count;
128 nodes[second_node].
count = 0;
129 nodes[first_node].
count = 0;
130 if (nd >= UINT32_MAX - st) {
134 nodes[cur_node].
count = nd + st;
135 nodes[cur_node].
sym = -1;
136 nodes[cur_node].
n0 = cur_node;
137 nodes[cur_node].
l = first_node;
138 nodes[cur_node].
r = second_node;
142 }
while (cur_node -
s->nb_symbols == j);
146 return ff_init_vlc_sparse(vlc, 12,
pos, lens, 2, 2,
bits, 4, 4, xlat, 1, 1, 0);
150 void *
data,
int *got_frame,
158 if (avpkt->
size <= 8)
164 if (size < 1 || size >= avpkt->
size)
171 ret = inflateReset(&
s->zstream);
177 s->zstream.next_in = avpkt->
data + 8;
178 s->zstream.avail_in = avpkt->
size - 8;
180 for (
int p = 0; p < 3; p++) {
181 for (
int y = 0; y < avctx->
height; y++) {
183 s->zstream.avail_out = avctx->
width >> (p > 0);
185 ret =
inflate(&
s->zstream, Z_SYNC_FLUSH);
186 if (ret != Z_OK && ret != Z_STREAM_END) {
190 if (
s->zstream.avail_out > 0)
191 memset(
s->zstream.next_out, 0,
s->zstream.avail_out);
194 }
else if (
type ==
MKTAG(
'H',
'U',
'F',
'Y')) {
196 int first_symbol, symbol;
207 symbol = first_symbol;
208 for (
int i = 0;
i <
s->nb_symbols; symbol++) {
231 for (
int p = 0; p < 3; p++) {
237 for (
int y = 0; y < avctx->
height; y++) {
240 for (
int x = 0; x <
width; x++) {
241 int v =
get_vlc2(gb,
s->vlc.table,
s->vlc.bits, 3);
255 for (
int p = 0; p < 3; p++) {
262 s->llviddsp.add_left_pred(dst, dst,
width, 0);
265 lefttop = left = dst[0];
266 for (
int y = 1; y < avctx->
height; y++) {
267 s->llviddsp.add_median_pred(dst, dst +
stride, dst,
width, &left, &lefttop);
268 lefttop = left = dst[0];
288 s->zstream.zalloc = Z_NULL;
289 s->zstream.zfree = Z_NULL;
290 s->zstream.opaque = Z_NULL;
291 zret = inflateInit(&
s->zstream);
306 inflateEnd(&
s->zstream);
static double val(void *priv, double ch)
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
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 ff_free_vlc(VLC *vlc)
#define prob(name, subs,...)
#define MKTAG(a, b, c, d)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
bitstream reader API header.
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void ff_llviddsp_init(LLVidDSPContext *c)
static av_cold int decode_close(AVCodecContext *avctx)
static int build_vlc(AVCodecContext *avctx, VLC *vlc)
static av_cold int decode_init(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat, Node *nodes, int node, uint32_t pfx, int pl, int *pos)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int key_frame
1 -> keyframe, 0-> not
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)