46 for(k = 0; (state->
N[Q] << k) < state->
A[Q]; k++);
48 map = !state->
near && !k && (2 * state->
B[Q] <= -state->
N[Q]);
52 if(err >= ((state->
range + 1) >> 1)) {
54 val = 2 *
FFABS(err) - 1 - map;
74 temp += state->
N[Q] >> 1;
75 for(k = 0; (state->
N[Q] << k) < temp; k++);
77 if(!k && err && (2 * state->
B[Q] < state->
N[Q]))
81 val = - (2 * err) - 1 - RItype + map;
83 val = 2 * err - RItype - map;
88 state->
A[Q] += (val + 1 - RItype) >> 1;
125 Ra = x ?
R(cur, x - stride) :
R(last, x);
127 Rc = x ?
R(last, x - stride) : last2;
128 Rd = (x >= w -
stride) ?
R(last, x) :
R(last, x + stride);
135 int RUNval, RItype,
run;
139 while(x < w && (
FFABS(
R(cur, x) - RUNval) <= state->
near)){
148 RItype = (
FFABS(Ra - Rb) <= state->
near);
149 pred = RItype ? Ra : Rb;
150 err =
R(cur, x) -
pred;
152 if(!RItype && Ra > Rb)
161 if(RItype || (Rb >= Ra))
169 if(err >= ((state->
range + 1) >> 1))
180 pred =
mid_pred(Ra, Ra + Rb - Rc, Rb);
185 pred = av_clip(pred - state->
C[context], 0, state->
maxval);
186 err = pred -
R(cur, x);
189 pred = av_clip(pred + state->
C[context], 0, state->
maxval);
190 err =
R(cur, x) -
pred;
217 if(state->
T1 == state2.
T1 && state->
T2 == state2.
T2 && state->
T3 == state2.
T3 && state->
reset == state2.
reset)
231 const AVFrame *pict,
int *got_packet)
271 for(i = 1; i <= comps; i++) {
280 for(i = 1; i <= comps; i++) {
285 put_bits(&pb, 8, (comps > 1) ? 1 : 0);
303 for(i = 0; i < avctx->
height; i++) {
312 for(i = 0; i < avctx->
height; i++) {
314 t = *((uint16_t*)last);
320 int Rc[3] = {0, 0, 0};
322 width = avctx->
width * 3;
323 for(i = 0; i < avctx->
height; i++) {
324 for(j = 0; j < 3; j++) {
325 ls_encode_line(state, &pb2, last + j, cur + j, Rc[j], width, 3, j, 8);
333 int Rc[3] = {0, 0, 0};
335 width = avctx->
width * 3;
336 for(i = 0; i < avctx->
height; i++) {
337 for(j = 2; j >= 0; j--) {
338 ls_encode_line(state, &pb2, last + j, cur + j, Rc[j], width, 3, j, 8);
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.
AVFrame * coded_frame
the picture in the bitstream
#define AV_PIX_FMT_GRAY16
#define FF_MIN_BUFFER_SIZE
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.
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. ...
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 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)
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
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).
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.
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)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
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)
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.
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)
struct JpeglsContext JpeglsContext