45 for(k = 0; (state->
N[Q] << k) < state->
A[Q]; k++);
47 map = !state->
near && !k && (2 * state->
B[Q] <= -state->
N[Q]);
51 if(err >= ((state->
range + 1) >> 1)) {
53 val = 2 *
FFABS(err) - 1 - map;
73 temp += state->
N[Q] >> 1;
74 for(k = 0; (state->
N[Q] << k) < temp; k++);
76 if(!k && err && (2 * state->
B[Q] < state->
N[Q]))
80 val = - (2 * err) - 1 - RItype + map;
82 val = 2 * err - RItype - map;
87 state->
A[Q] += (val + 1 - RItype) >> 1;
124 Ra = x ?
R(cur, x - stride) :
R(last, x);
126 Rc = x ?
R(last, x - stride) : last2;
127 Rd = (x >= w -
stride) ?
R(last, x) :
R(last, x + stride);
134 int RUNval, RItype,
run;
138 while(x < w && (
FFABS(
R(cur, x) - RUNval) <= state->
near)){
147 RItype = (
FFABS(Ra - Rb) <= state->
near);
148 pred = RItype ? Ra : Rb;
149 err =
R(cur, x) -
pred;
151 if(!RItype && Ra > Rb)
160 if(RItype || (Rb >= Ra))
168 if(err >= ((state->
range + 1) >> 1))
179 pred =
mid_pred(Ra, Ra + Rb - Rc, Rb);
184 pred = av_clip(pred - state->
C[context], 0, state->
maxval);
185 err = pred -
R(cur, x);
188 pred = av_clip(pred + state->
C[context], 0, state->
maxval);
189 err =
R(cur, x) -
pred;
213 memset(&state2, 0,
sizeof(
JLSState));
217 if(state->
T1 == state2.
T1 && state->
T2 == state2.
T2 && state->
T3 == state2.
T3 && state->
reset == state2.
reset)
237 uint8_t *buf2, *
zero, *cur, *last;
264 for(i = 1; i <= comps; i++) {
273 for(i = 1; i <= comps; i++) {
278 put_bits(&pb, 8, (comps > 1) ? 1 : 0);
296 for(i = 0; i < avctx->
height; i++) {
305 for(i = 0; i < avctx->
height; i++) {
307 t = *((uint16_t*)last);
313 int Rc[3] = {0, 0, 0};
315 width = avctx->
width * 3;
316 for(i = 0; i < avctx->
height; i++) {
317 for(j = 0; j < 3; j++) {
326 int Rc[3] = {0, 0, 0};
328 width = avctx->
width * 3;
329 for(i = 0; i < avctx->
height; i++) {
330 for(j = 2; j >= 0; j--) {
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
const uint8_t ff_log2_run[41]
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
AVCodec ff_jpegls_encoder
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
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
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
MJPEG encoder and decoder.
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 int init(AVCodecParserContext *s)
static void ls_encode_run(JLSState *state, PutBitContext *pb, int run, int comp, int trail)
Encode run value as specified by JPEG-LS standard.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
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. ...
static int encode_picture_ls(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data)
void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
Calculate JPEG-LS codec values.
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static int ff_jpegls_update_state_regular(JLSState *state, int Q, int err)
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
static int put_bits_count(PutBitContext *s)
static av_always_inline void emms_c(void)
Empty mmx state.
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
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.
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]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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)
packed RGB 8:8:8, 24bpp, BGRBGR...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
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 void put_marker(PutBitContext *p, int code)
packed RGB 8:8:8, 24bpp, RGBRGB...
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
JPEG-LS extension parameters.
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.
static void ff_jpegls_downscale_state(JLSState *state, int Q)
struct JpeglsContext JpeglsContext