28#define UNCHECKED_BITSTREAM_READER 1
54 bytestream2_put_byteu(pb, 0xff);
55 bytestream2_put_byteu(pb,
code);
75 if (err >= (
state->range + 1 >> 1)) {
90 int RItype,
int err,
int limit_add)
107 val = -(2 * err) - 1 - RItype +
map;
109 val = 2 * err - RItype -
map;
145 void *
tmp,
const void *in,
int last2,
int w,
149 int Ra =
R(
tmp, 0), Rb, Rc = last2, Rd;
166 int RUNval, RItype,
run;
170 while (x <
w && (
FFABS(
R(in, x) - RUNval) <=
state->near)) {
180 pred = RItype ? Ra : Rb;
181 err =
R(in, x) -
pred;
183 if (!RItype && Ra > Rb)
192 if (RItype || (Rb >= Ra))
202 if (err >=
state->range + 1 >> 1)
222 err =
pred -
R(in, x);
226 err =
R(in, x) -
pred;
263 bytestream2_put_be16u(pb, 13);
264 bytestream2_put_byteu(pb, 1);
265 bytestream2_put_be16u(pb,
state->maxval);
266 bytestream2_put_be16u(pb,
state->T1);
267 bytestream2_put_be16u(pb,
state->T2);
268 bytestream2_put_be16u(pb,
state->T3);
269 bytestream2_put_be16u(pb,
state->reset);
273 const AVFrame *pict,
int *got_packet)
281 uint8_t *last =
NULL;
284 int i, ret, size_in_bits;
308 in += p->linesize[0];
314 int last0 = *((uint16_t *)last);
317 in += p->linesize[0];
321 int Rc[3] = { 0, 0, 0 };
325 for (j = 0; j < 3; j++) {
331 in += p->linesize[0];
335 int Rc[3] = { 0, 0, 0 };
339 for (j = 2; j >= 0; j--) {
345 in += p->linesize[0];
364 size = size_in_bits * 2U / 15;
365 size += 2 + 2 + 2 + 1 + 2 + 2 + 1 + comps * (1 + 1 + 1) + 2 + 2 + 1
366 + comps * (1 + 1) + 1 + 1 + 1;
367 size += 2 + 2 + 1 + 2 + 2 + 2 + 2 + 2;
377 bytestream2_put_be16u(&pb, 8 + comps * 3);
379 bytestream2_put_be16u(&pb, avctx->
height);
380 bytestream2_put_be16u(&pb, avctx->
width);
381 bytestream2_put_byteu(&pb, comps);
382 for (
i = 1;
i <= comps;
i++) {
383 bytestream2_put_byteu(&pb,
i);
384 bytestream2_put_byteu(&pb, 0x11);
385 bytestream2_put_byteu(&pb, 0);
389 bytestream2_put_be16u(&pb, 6 + comps * 2);
390 bytestream2_put_byteu(&pb, comps);
391 for (
i = 1;
i <= comps;
i++) {
392 bytestream2_put_byteu(&pb,
i);
393 bytestream2_put_byteu(&pb, 0);
395 bytestream2_put_byteu(&pb,
ctx->pred);
396 bytestream2_put_byteu(&pb, (comps > 1) ? 1 : 0);
397 bytestream2_put_byteu(&pb, 0);
407 bytestream2_put_byteu(&pb, v);
410 bytestream2_put_byteu(&pb, v);
457#define OFFSET(x) offsetof(JPEGLSContext, x)
458#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
469 .class_name =
"jpegls",
static double val(void *priv, double ch)
const FFCodec ff_jpegls_encoder
static AVFormatContext * ctx
Libavcodec external API header.
static av_always_inline int bytestream2_tell_p(const PutByteContext *p)
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
#define i(width, name, range_min, range_max)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define EOI
End Of Image marker.
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
#define FF_INPUT_BUFFER_MIN_SIZE
Used by some encoders as upper bound for the length of headers.
static struct @346255127015250356166251341105367306144006377143 state
static const uint8_t bits[8]
bitstream reader API header.
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#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 AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
const VDPAUPixFmtMap * map
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
Calculate JPEG-LS codec values.
static int ff_jpegls_update_state_regular(JLSState *state, int Q, int err)
static void ff_jpegls_downscale_state(JLSState *state, int Q)
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
static void ls_encode_run(JLSState *state, PutBitContext *pb, int run, int comp, int trail)
Encode run value as specified by JPEG-LS standard.
static void ls_store_lse(JLSState *state, PutByteContext *pb)
static av_cold int encode_jpegls_close(AVCodecContext *avctx)
static const AVClass jpegls_class
static void ls_encode_runterm(JLSState *state, PutBitContext *pb, int RItype, int err, int limit_add)
Encode error from run termination.
static void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q, int err)
Encode error from regular symbol.
static void put_marker_byteu(PutByteContext *pb, enum JpegMarker code)
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
static av_cold int encode_jpegls_init(AVCodecContext *avctx)
static void ls_encode_line(JLSState *state, PutBitContext *pb, void *tmp, const void *in, int last2, int w, int stride, int comp, int bits)
Encode one line of image.
const uint8_t ff_log2_run[41]
Memory handling functions.
MJPEG encoder and decoder.
@ LSE
JPEG-LS extension parameters.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
#define AV_PIX_FMT_GRAY16
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static int put_bits_count(PutBitContext *s)
static int put_bytes_count(const PutBitContext *s, int round_up)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
exp golomb vlc writing stuff
static void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int limit, int esc_len)
write unsigned golomb rice code (jpegls).
static const float pred[4]
Describe the class of an AVClass context structure.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.