Go to the documentation of this file.
36 #define PIXLET_MAGIC 0xDEADBEEF
97 if (!
ctx->filter[0] || !
ctx->filter[1] || !
ctx->prediction)
100 for (plane = 0; plane < 3; plane++) {
101 unsigned shift = plane > 0;
116 ctx->band[plane][
i + 1].x = (
w >>
scale) * (((
i + 1) % 3) != 2);
117 ctx->band[plane][
i + 1].y = (
h >>
scale) * (((
i + 1) % 3) != 1);
129 unsigned cnt1, nbits, k, j = 0,
i = 0;
131 int rlen, escape,
flag = 0;
141 escape = ((1 << nbits) - 1) * cnt1;
144 escape =
value + ((1 << nbits) - 1) * cnt1 - 1;
151 dst[j++] =
value * ((escape +
flag + 1) >> 1);
172 rlen =
value + escape * cnt1 - 1;
175 rlen = escape * cnt1;
183 for (k = 0; k < rlen; k++) {
192 flag = rlen < 0xFFFF ? 1 : 0;
205 unsigned cnt1, shbits, rlen, nbits, length,
i = 0, j = 0, k;
224 if (((
state >> 8) + 3) & 0xFFFFFFF)
230 if (cnt1 >= length) {
236 cnt1 *= (1 << pfx) - 1;
249 if (
flag + cnt1 == 0) {
274 if (pfx < 1 || pfx > 25)
280 rlen =
value + escape * cnt1 - 1;
283 rlen = escape * cnt1;
291 rlen =
value + 8 * escape;
294 if (rlen > 0xFFFF ||
i + rlen >
size)
298 for (k = 0; k < rlen; k++) {
307 flag = rlen < 0xFFFF ? 1 : 0;
321 for (
i = 0;
i <
ctx->levels * 3;
i++) {
326 int16_t *dest = (int16_t *)
frame->
data[plane] +
327 ctx->band[plane][
i + 1].x +
329 unsigned size =
ctx->band[plane][
i + 1].size;
330 uint32_t magic = bytestream2_get_be32(&
ctx->gb);
334 "wrong magic number: 0x%08"PRIX32
" for plane %d, band %d\n",
347 "error in highpass coefficients for plane %d, band %d\n",
368 for (j = 1; j <
width; j++) {
379 int16_t *low, *high, *ll, *lh, *hl, *hh;
385 high = &low[hsize + 8];
387 memcpy(low, dest,
size);
388 memcpy(high, dest + hsize,
size);
394 for (
i = 4, j = 2;
i;
i--, j++, ll--, hh++, lh++, hl--) {
395 low[
i - 5] = low[j - 1];
397 high[
i - 5] = high[j - 2];
401 for (
i = 0;
i < hsize;
i++) {
403 (
int64_t) low [
i + 0] * INT64_C(3687786320) +
404 (
int64_t) low [
i - 1] * -INT64_C(325392907) +
405 (
int64_t) high[
i + 0] * INT64_C(1518500249) +
406 (
int64_t) high[
i - 1] * INT64_C(1518500249);
410 for (
i = 0;
i < hsize;
i++) {
412 (
int64_t) low [
i + 1] * INT64_C(1583578880) +
413 (
int64_t) low [
i + 0] * INT64_C(1583578880) +
414 (
int64_t) low [
i - 1] * -INT64_C(65078576) +
415 (
int64_t) high[
i + 1] * INT64_C(303700064) +
416 (
int64_t) high[
i + 0] * -INT64_C(3644400640) +
417 (
int64_t) high[
i - 1] * INT64_C(303700064);
427 unsigned scaled_width, scaled_height;
442 for (j = 0; j < scaled_height; j++) {
443 filterfn(ptr,
ctx->filter[1], scaled_width, scale_v);
447 for (j = 0; j < scaled_width; j++) {
449 for (k = 0; k < scaled_height; k++) {
457 for (k = 0; k < scaled_height; k++) {
468 int max = (1 << depth) - 1;
470 if (
ctx->depth == depth)
479 int w,
int h,
int depth)
482 uint16_t *dsty = (uint16_t *)
frame->
data[0];
483 int16_t *srcy = (int16_t *)
frame->
data[0];
485 uint16_t *lut =
ctx->lut;
488 for (j = 0; j <
h; j++) {
489 for (
i = 0;
i <
w;
i++) {
492 else if (srcy[
i] > ((1 << depth) - 1))
495 dsty[
i] = lut[srcy[
i]];
504 uint16_t *dstu = (uint16_t *)
frame->
data[1];
505 uint16_t *dstv = (uint16_t *)
frame->
data[2];
506 int16_t *srcu = (int16_t *)
frame->
data[1];
507 int16_t *srcv = (int16_t *)
frame->
data[2];
510 const unsigned add = 1 << (depth - 1);
511 const unsigned shift = 16 - depth;
514 for (j = 0; j <
h; j++) {
515 for (
i = 0;
i <
w;
i++) {
531 unsigned shift = plane > 0;
535 for (
i =
ctx->levels - 1;
i >= 0;
i--) {
542 ctx->scaling[plane][
H][
i] = (1000000ULL << 32) /
h;
543 ctx->scaling[plane][
V][
i] = (1000000ULL << 32) / v;
557 ctx->band[plane][0].width - 1, 0);
560 "error in lowpass coefficients for plane %d, top row\n", plane);
565 ctx->band[plane][0].height - 1, 1,
stride);
568 "error in lowpass coefficients for plane %d, left column\n",
574 (
ctx->band[plane][0].width - 1) * (
ctx->band[plane][0].height - 1),
578 "error in lowpass coefficients for plane %d, rest\n", plane);
597 ctx->scaling[plane][
V]);
607 uint32_t pktsize, depth;
611 pktsize = bytestream2_get_be32(&
ctx->gb);
622 if (bytestream2_get_be32(&
ctx->gb) != 1)
626 width = bytestream2_get_be32(&
ctx->gb);
636 ctx->levels = bytestream2_get_be32(&
ctx->gb);
639 depth = bytestream2_get_be32(&
ctx->gb);
640 if (depth < 8 || depth > 15) {
677 for (
i = 0;
i < 3;
i++) {
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static void free_buffers(AVCodecContext *avctx)
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
#define u(width, name, range_min, range_max)
static int pixlet_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
static int get_bits_count(const GetBitContext *s)
This structure describes decoded (raw) audio or video data.
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
Clip a signed integer to an unsigned power of two range.
@ AVCOL_RANGE_JPEG
Full range content.
static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size, int width, ptrdiff_t stride)
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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 FFCodec caps_internal and use ff_thread_get_buffer() to allocate frames. 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
static void skip_bits(GetBitContext *s, int n)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodec p
The public AVCodec.
static int read_high_coeffs(AVCodecContext *avctx, const uint8_t *src, int16_t *dst, int size, int c, int a, int d, int width, ptrdiff_t stride)
int flags
AV_CODEC_FLAG_*.
static double val(void *priv, double ch)
static void filterfn(int16_t *dest, int16_t *tmp, unsigned size, int64_t scale)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
#define FF_CODEC_DECODE_CB(func)
static int decode_plane(AVCodecContext *avctx, int plane, const AVPacket *avpkt, AVFrame *frame)
#define AV_PIX_FMT_YUV420P16
#define CODEC_LONG_NAME(str)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Describe the class of an AVClass context structure.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
static void postprocess_chroma(AVFrame *frame, int w, int h, int depth)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline int bytestream2_tell(GetByteContext *g)
static void build_luma_lut(AVCodecContext *avctx, int depth)
enum AVPictureType pict_type
Picture type of the frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static int shift(int a, int b)
SubBand band[4][NB_LEVELS *3+1]
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static av_cold int pixlet_init(AVCodecContext *avctx)
static void postprocess_luma(AVCodecContext *avctx, AVFrame *frame, int w, int h, int depth)
#define i(width, name, range_min, range_max)
static void lowpass_prediction(int16_t *dst, int16_t *pred, int width, int height, ptrdiff_t stride)
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define av_malloc_array(a, b)
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 default value
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_cold int pixlet_close(AVCodecContext *avctx)
static const float pred[4]
static const uint8_t * align_get_bits(GetBitContext *s)
static void reconstruction(AVCodecContext *avctx, int16_t *dest, unsigned width, unsigned height, ptrdiff_t stride, int64_t *scaling_h, int64_t *scaling_v)
const FFCodec ff_pixlet_decoder
main external API structure.
static av_const int sign_extend(int val, unsigned bits)
#define avpriv_request_sample(...)
This structure stores compressed data.
int64_t scaling[4][2][NB_LEVELS]
int width
picture width / height.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
static int read_highpass(AVCodecContext *avctx, const uint8_t *ptr, int plane, AVFrame *frame)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int init_decoder(AVCodecContext *avctx)