48 for (k = 0; (state->
N[Q] << k) < state->
A[Q]; k++)
51 map = !state->
near && !k && (2 * state->
B[Q] <= -state->
N[Q]);
55 if (err >= (state->
range + 1 >> 1)) {
57 val = 2 *
FFABS(err) - 1 - map;
70 int RItype,
int err,
int limit_add)
79 temp += state->
N[Q] >> 1;
80 for (k = 0; (state->
N[Q] << k) < temp; k++)
83 if (!k && err && (2 * state->
B[Q] < state->
N[Q]))
87 val = -(2 * err) - 1 - RItype + map;
89 val = 2 * err - RItype - map;
94 state->
A[Q] += (val + 1 - RItype) >> 1;
125 void *last,
void *cur,
int last2,
int w,
136 Ra = x ?
R(cur, x - stride) :
R(last, x);
138 Rc = x ?
R(last, x - stride) : last2;
139 Rd = (x >= w -
stride) ?
R(last, x) :
R(last, x + stride);
148 int RUNval, RItype,
run;
152 while (x < w && (
FFABS(
R(cur, x) - RUNval) <= state->
near)) {
162 pred = RItype ? Ra : Rb;
163 err =
R(cur, x) -
pred;
165 if (!RItype && Ra > Rb)
174 if (RItype || (Rb >= Ra))
182 if (err >= state->
range + 1 >> 1)
196 pred =
mid_pred(Ra, Ra + Rb - Rc, Rb);
201 pred = av_clip(pred - state->
C[context], 0, state->
maxval);
202 err = pred -
R(cur, x);
205 pred = av_clip(pred + state->
C[context], 0, state->
maxval);
206 err =
R(cur, x) -
pred;
234 if (state->
T1 == state2.
T1 &&
235 state->
T2 == state2.
T2 &&
236 state->
T3 == state2.
T3 &&
251 const AVFrame *pict,
int *got_packet)
290 for (i = 1; i <= comps; i++) {
299 for (i = 1; i <= comps; i++) {
304 put_bits(&pb, 8, (comps > 1) ? 1 : 0);
327 for (i = 0; i < avctx->
height; i++) {
336 for (i = 0; i < avctx->
height; i++) {
338 t = *((uint16_t *)last);
344 int Rc[3] = { 0, 0, 0 };
346 width = avctx->
width * 3;
347 for (i = 0; i < avctx->
height; i++) {
348 for (j = 0; j < 3; j++) {
358 int Rc[3] = { 0, 0, 0 };
360 width = avctx->
width * 3;
361 for (i = 0; i < avctx->
height; i++) {
362 for (j = 2; j >= 0; j--) {
435 "Only grayscale and RGB24/BGR24 images are supported\n");
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
const uint8_t ff_log2_run[41]
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data.
const char const char void * val
void av_free_packet(AVPacket *pkt)
Free a packet.
This structure describes decoded (raw) audio or video data.
AVCodec ff_jpegls_encoder
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
packed RGB 8:8:8, 24bpp, RGBRGB...
static void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q, int err)
Encode error from regular symbol.
AVFrame * coded_frame
the picture in the bitstream
static av_cold int encode_close(AVCodecContext *avctx)
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
MJPEG encoder and decoder.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define CODEC_CAP_INTRA_ONLY
Codec is intra only.
static int get_bits_count(const GetBitContext *s)
static void ls_encode_line(JLSState *state, PutBitContext *pb, void *last, void *cur, int last2, int w, int stride, int comp, int bits)
Encode one line of image.
bitstream reader API header.
static void ls_encode_run(JLSState *state, PutBitContext *pb, int run, int comp, int trail)
Encode run value as specified by JPEG-LS standard.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static void ls_store_lse(JLSState *state, PutBitContext *pb)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
Calculate JPEG-LS codec values.
const char * name
Name of the codec implementation.
static int ff_jpegls_update_state_regular(JLSState *state, int Q, int err)
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Libavcodec external API header.
int flags
A combination of AV_PKT_FLAG values.
static int put_bits_count(PutBitContext *s)
static void put_marker(PutBitContext *p, enum JpegMarker code)
enum AVPictureType pict_type
Picture type of the frame.
#define AV_PIX_FMT_GRAY16
#define FF_MIN_BUFFER_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
int width
picture width / height.
static void ls_encode_runterm(JLSState *state, PutBitContext *pb, int RItype, int err, int limit_add)
Encode error from run termination.
packed RGB 8:8:8, 24bpp, BGRBGR...
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]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static av_cold int encode_init_ls(AVCodecContext *ctx)
JPEG-LS extension parameters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
GLint GLenum GLboolean GLsizei stride
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
int prediction_method
prediction method (needed for huffyuv)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
int key_frame
1 -> keyframe, 0-> not
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
AVPixelFormat
Pixel format.
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static void ff_jpegls_downscale_state(JLSState *state, int Q)