53 for (k = 0; (state->
N[Q] << k) < state->
A[Q]; k++)
56 map = !state->
near && !k && (2 * state->
B[Q] <= -state->
N[Q]);
60 if (err >= (state->
range + 1 >> 1)) {
75 int RItype,
int err,
int limit_add)
84 temp += state->
N[Q] >> 1;
85 for (k = 0; (state->
N[Q] << k) < temp; k++)
88 if (!k && err && (2 * state->
B[Q] < state->
N[Q]))
92 val = -(2 * err) - 1 - RItype + map;
94 val = 2 * err - RItype -
map;
99 state->
A[Q] += (val + 1 - RItype) >> 1;
130 void *last,
void *cur,
int last2,
int w,
141 Ra = x ?
R(cur, x - stride) :
R(last, x);
143 Rc = x ?
R(last, x - stride) : last2;
144 Rd = (x >= w -
stride) ?
R(last, x) :
R(last, x + stride);
153 int RUNval, RItype,
run;
157 while (x < w && (
FFABS(
R(cur, x) - RUNval) <= state->
near)) {
167 pred = RItype ? Ra : Rb;
168 err =
R(cur, x) -
pred;
170 if (!RItype && Ra > Rb)
179 if (RItype || (Rb >= Ra))
187 if (err >= state->
range + 1 >> 1)
201 pred =
mid_pred(Ra, Ra + Rb - Rc, Rb);
206 pred = av_clip(pred - state->
C[context], 0, state->
maxval);
207 err = pred -
R(cur, x);
210 pred = av_clip(pred + state->
C[context], 0, state->
maxval);
211 err =
R(cur, x) -
pred;
239 if (state->
T1 == state2.
T1 &&
240 state->
T2 == state2.
T2 &&
241 state->
T3 == state2.
T3 &&
256 const AVFrame *pict,
int *got_packet)
270 #if FF_API_PRIVATE_OPT 304 for (i = 1; i <= comps; i++) {
313 for (i = 1; i <= comps; i++) {
318 put_bits(&pb, 8, (comps > 1) ? 1 : 0);
341 for (i = 0; i < avctx->
height; i++) {
350 for (i = 0; i < avctx->
height; i++) {
352 t = *((uint16_t *)last);
358 int Rc[3] = { 0, 0, 0 };
360 width = avctx->
width * 3;
361 for (i = 0; i < avctx->
height; i++) {
362 for (j = 0; j < 3; j++) {
372 int Rc[3] = { 0, 0, 0 };
374 width = avctx->
width * 3;
375 for (i = 0; i < avctx->
height; i++) {
376 for (j = 2; j >= 0; j--) {
431 #if FF_API_CODED_FRAME 443 "Only grayscale and RGB24/BGR24 images are supported\n");
449 #define OFFSET(x) offsetof(JPEGLSContext, x) 450 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 473 .priv_class = &jpegls_class,
#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]
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
This structure describes decoded (raw) audio or video data.
AVCodec ff_jpegls_encoder
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.
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
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.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static const AVOption options[]
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.
#define AV_INPUT_BUFFER_MIN_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
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.
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)
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
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
int width
picture width / height.
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
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).
Libavcodec external API header.
attribute_deprecated int prediction_method
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Describe the class of an AVClass context structure.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static const AVClass jpegls_class
const VDPAUPixFmtMap * map
static av_cold int encode_init_ls(AVCodecContext *ctx)
static enum AVPixelFormat pix_fmts[]
JPEG-LS extension parameters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static av_cold int init(AVCodecParserContext *s)
#define FF_ENABLE_DEPRECATION_WARNINGS
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)