26 #define BITSTREAM_READER_LE 74 #define HISTORY_SIZE (64 * 1024) 80 unsigned reference_pos, match_length,
delta,
pos = 0;
84 uint8_t token = bytestream2_get_byte(gb);
85 unsigned num_literals = token >> 4;
87 if (num_literals == 15) {
88 unsigned char current;
90 current = bytestream2_get_byte(gb);
91 num_literals += current;
92 }
while (current == 255);
99 while (num_literals-- > 0) {
100 history[pos++] = bytestream2_get_byte(gb);
111 delta = bytestream2_get_le16(gb);
114 match_length = 4 + (token & 0x0F);
115 if (match_length == 4 + 0x0F) {
119 current = bytestream2_get_byte(gb);
120 match_length += current;
121 }
while (current == 255);
125 if (pos >= reference_pos + match_length || reference_pos >= pos + match_length) {
126 memcpy(history + pos, history + reference_pos, match_length);
129 while (match_length-- > 0)
130 history[pos++] = history[reference_pos++];
133 while (match_length-- > 0) {
134 history[pos++] = history[reference_pos++];
155 int ylinesize, ulinesize, vlinesize, alinesize;
156 uint16_t *dsty, *dstu, *dstv, *dsta;
212 s->
data_end = bytestream2_get_le32(gb);
213 if (s->
data_end > uncompressed_size)
235 dsty = (uint16_t *)p->
data[0];
236 dsta = (uint16_t *)p->
data[3];
240 for (
int y = 0; y < avctx->
height; y += 4) {
241 const unsigned row_offset = bytestream2_get_le32(&rgb);
246 for (
int x = 0; x < avctx->
width; x += 4) {
247 unsigned item = bytestream2_get_le32(gb);
248 unsigned y_min = item & 4095;
249 unsigned y_max = (item >> 12) & 4095;
250 unsigned y_diff = y_max - y_min;
253 control[0] = (item >> 24) & 3;
254 control[1] = (item >> 26) & 3;
255 control[2] = (item >> 28) & 3;
256 control[3] = (item >> 30) & 3;
258 for (
int i = 0;
i < 4;
i++) {
259 const int nb_bits = control[
i] + 1;
260 const int div = (1 << nb_bits) - 1;
261 const int add = div - 1;
270 dsty += 4 * ylinesize;
277 for (
int y = 0; y < avctx->
height; y++) {
278 for (
int x = 0; x < avctx->
width; x++)
286 for (
int y = 0; y < avctx->
height; y += 16) {
287 for (
int x = 0; x < avctx->
width; x += 16) {
288 unsigned m = bytestream2_get_le32(gb);
289 unsigned offset = bytestream2_get_le32(gb);
290 unsigned alpha0, alpha1;
293 if (offset >= UINT_MAX / 4)
300 control = bytestream2_get_le64(&dgb);
301 alpha0 = control & 0xFF;
302 alpha1 = (control >> 8) & 0xFF;
303 control = control >> 16;
305 for (
int by = 0; by < 4; by++) {
306 for (
int bx = 0; bx < 4; bx++) {
309 for (
int i = 0;
i < 4;
i++) {
310 for (
int j = 0; j < 4; j++) {
311 dsta[x + (
i + by * 4) * alinesize + bx * 4 + j] = 0;
316 for (
int i = 0;
i < 4;
i++) {
317 for (
int j = 0; j < 4; j++) {
318 dsta[x + (
i + by * 4) * alinesize + bx * 4 + j] = 4095;
323 for (
int i = 0;
i < 4;
i++) {
324 for (
int j = 0; j < 4; j++) {
325 dsta[x + (
i + by * 4) * alinesize + bx * 4 + j] = (alpha0 + (alpha1 - alpha0) * (control & 7)) << 4;
339 dsta += 16 * alinesize;
345 dstu = (uint16_t *)p->
data[1];
346 dstv = (uint16_t *)p->
data[2];
350 for (
int y = 0; y < avctx->
height; y += 16) {
351 for (
int x = 0; x < avctx->
width; x += 16) {
352 unsigned offset = bytestream2_get_le32(&rgb) * 4;
353 int u[16][16] = { 0 }, v[16][16] = { 0 };
354 int u0,
v0, u1, v1, udif, vdif;
355 unsigned escape, is8x8, loc;
359 is8x8 = bytestream2_get_le16(&dgb);
360 escape = bytestream2_get_le16(&dgb);
362 if (escape == 0 && is8x8 == 0) {
363 u0 = bytestream2_get_byte(&dgb);
364 v0 = bytestream2_get_byte(&dgb);
365 u1 = bytestream2_get_byte(&dgb);
366 v1 = bytestream2_get_byte(&dgb);
367 loc = bytestream2_get_le32(&dgb);
368 u0 = (u0 << 4) | (u0 & 0xF);
369 v0 = (v0 << 4) | (v0 & 0xF);
370 u1 = (u1 << 4) | (u1 & 0xF);
371 v1 = (v1 << 4) | (v1 & 0xF);
375 for (
int i = 0;
i < 16;
i += 4) {
376 for (
int j = 0; j < 16; j += 4) {
377 for (
int ii = 0; ii < 4; ii++) {
378 for (
int jj = 0; jj < 4; jj++) {
379 u[
i + ii][j + jj] = u0 + ((udif * (
int)(loc & 3) + 2) / 3);
380 v[
i + ii][j + jj] = v0 + ((vdif * (
int)(loc & 3) + 2) / 3);
388 for (
int i = 0;
i < 16;
i += 8) {
389 for (
int j = 0; j < 16; j += 8) {
391 u0 = bytestream2_get_byte(&dgb);
392 v0 = bytestream2_get_byte(&dgb);
393 u1 = bytestream2_get_byte(&dgb);
394 v1 = bytestream2_get_byte(&dgb);
395 loc = bytestream2_get_le32(&dgb);
396 u0 = (u0 << 4) | (u0 & 0xF);
397 v0 = (v0 << 4) | (v0 & 0xF);
398 u1 = (u1 << 4) | (u1 & 0xF);
399 v1 = (v1 << 4) | (v1 & 0xF);
403 for (
int ii = 0; ii < 8; ii += 2) {
404 for (
int jj = 0; jj < 8; jj += 2) {
405 for (
int iii = 0; iii < 2; iii++) {
406 for (
int jjj = 0; jjj < 2; jjj++) {
407 u[
i + ii + iii][j + jj + jjj] = u0 + ((udif * (
int)(loc & 3) + 2) / 3);
408 v[
i + ii + iii][j + jj + jjj] = v0 + ((vdif * (
int)(loc & 3) + 2) / 3);
416 for (
int ii = 0; ii < 8; ii += 4) {
417 for (
int jj = 0; jj < 8; jj += 4) {
418 u0 = bytestream2_get_byte(&dgb);
419 v0 = bytestream2_get_byte(&dgb);
420 u1 = bytestream2_get_byte(&dgb);
421 v1 = bytestream2_get_byte(&dgb);
422 loc = bytestream2_get_le32(&dgb);
423 u0 = (u0 << 4) | (u0 & 0xF);
424 v0 = (v0 << 4) | (v0 & 0xF);
425 u1 = (u1 << 4) | (u1 & 0xF);
426 v1 = (v1 << 4) | (v1 & 0xF);
430 for (
int iii = 0; iii < 4; iii++) {
431 for (
int jjj = 0; jjj < 4; jjj++) {
432 u[
i + ii + iii][j + jj + jjj] = u0 + ((udif * (
int)(loc & 3) + 2) / 3);
433 v[
i + ii + iii][j + jj + jjj] = v0 + ((vdif * (
int)(loc & 3) + 2) / 3);
447 for (
int i = 0;
i < 16;
i++) {
448 for (
int j = 0; j < 16; j++) {
449 dstu[x +
i * ulinesize + j] = u[
i][j];
450 dstv[x +
i * vlinesize + j] = v[
i][j];
455 dstu += 16 * ulinesize;
456 dstv += 16 * vlinesize;
463 void *
data,
int *got_frame,
474 if (avpkt->
size <= 40)
479 if (bytestream2_get_le32(gb) !=
MKBETAG(
'N',
'L',
'C',
'1'))
482 uncompressed_size = bytestream2_get_le32(gb);
484 s->
format = bytestream2_get_le32(gb);
494 if (uncompressed_size > s->
lzf_size)
498 }
else if (s->
format == 1) {
510 if (ret != uncompressed_size)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
unsigned a_control_word_offset
ptrdiff_t const GLvoid * data
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
unsigned uncompressed_size
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 av_cold int init(AVCodecContext *avctx)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
unsigned y_data_row_offsets
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)
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
static av_cold int decode_init(AVCodecContext *avctx)
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
AVCodec ff_notchlc_decoder
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Multithreading support functions.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define u(width, name, range_min, range_max)
unsigned y_control_data_offset
bitstream reader API header.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
#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_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
const char * name
Name of the codec implementation.
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in AVCodec caps_internal and use ff_thread_get_buffer() to allocate frames.The frames must then be freed with ff_thread_release_buffer().Otherwise decode directly into the user-supplied frames.Call ff_thread_report_progress() after some part of the current picture has decoded.A good place to put this is where draw_horiz_band() is called-add this if it isn't called anywhere
enum AVPictureType pict_type
Picture type of the frame.
static int decode_blocks(AVCodecContext *avctx, AVFrame *p, ThreadFrame *frame, unsigned uncompressed_size)
#define AV_PIX_FMT_YUVA444P12
int width
picture width / height.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static av_always_inline int bytestream2_tell(GetByteContext *g)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
static av_cold int decode_end(AVCodecContext *avctx)
enum AVColorSpace colorspace
YUV colorspace type.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
static const SheerTable rgb[2]
uint8_t * uncompressed_buffer
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
IEC 61966-2-1 (sRGB or sYCC)
common internal api header.
static int lz4_decompress(AVCodecContext *avctx, GetByteContext *gb, PutByteContext *pb)
#define bit(string, value)
unsigned uv_offset_data_offset
#define MKBETAG(a, b, c, d)
int key_frame
1 -> keyframe, 0-> not
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
static float add(float src0, float src1)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.