54 int tid, wt, maxtab, i, j;
94 else if ((5 + wt*(s->
maxval+1)) < 65535)
97 maxtab = 65530/wt - 1;
126 for (j=0; j<wt; j++) {
127 pal[k] |=
get_bits(&s->
gb, 8) << (8*(wt-j-1));
152 for (k = 0; (state->
N[Q] << k) < state->
A[Q]; k++)
163 ret = -(ret + 1 >> 1);
168 if (!state->
near && !k && (2 * state->
B[Q] <= -state->
N[Q]))
180 int RItype,
int limit_add)
183 int Q = 365 + RItype;
187 temp += state->
N[Q] >> 1;
189 for (k = 0; (state->
N[Q] << k) < temp; k++)
201 if (!k && (RItype || ret) && (2 * state->
B[Q] < state->
N[Q]))
206 ret = map - (ret + 1 >> 1);
212 if(
FFABS(ret) > 0xFFFF)
215 state->
A[Q] +=
FFABS(ret) - RItype;
226 void *last,
void *dst,
int last2,
int w,
240 Ra = x ?
R(dst, x - stride) :
R(last, x);
242 Rc = x ?
R(last, x - stride) : last2;
243 Rd = (x >= w -
stride) ?
R(last, x) :
R(last, x + stride);
258 if (x + r * stride > w)
259 r = (w - x) / stride;
260 for (i = 0; i <
r; i++) {
276 if (x + r * stride > w) {
277 r = (w - x) / stride;
279 for (i = 0; i <
r; i++) {
292 RItype = (
FFABS(Ra - Rb) <= state->
near) ? 1 : 0;
298 if (state->
near && RItype) {
312 pred =
mid_pred(Ra, Ra + Rb - Rc, Rb);
322 pred = av_clip(pred - state->
C[context], 0, state->
maxval);
325 pred = av_clip(pred + state->
C[context], 0, state->
maxval);
333 if (pred < -state->near)
337 pred = av_clip(pred, 0, state->
maxval);
347 int point_transform,
int ilv)
377 shift = point_transform + (8 - s->
bits);
379 shift = point_transform + (16 - s->
bits);
388 "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
389 "RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
391 state->
T1, state->
T2, state->
T3,
409 for (i = 0; i < s->
height; i++) {
415 t = *((uint16_t *)last);
425 }
else if (ilv == 1) {
427 int Rc[3] = { 0, 0, 0 };
431 for (i = 0; i < s->
height; i++) {
432 for (j = 0; j <
stride; j++) {
434 Rc[j],
width, stride, j, 8);
445 }
else if (ilv == 2) {
463 for (i = 0; i < s->
height; i++) {
466 for (x = off; x < w; x += 3) {
467 src[x ] += src[x+1] + 128;
468 src[x+2] += src[x+1] + 128;
472 for (x = off; x < w; x += 3) {
473 src[x ] += src[x+1] + 128;
474 src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
478 for (x = off; x < w; x += 3) {
479 int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
480 src[x+0] = src[x+2] + g + 128;
481 src[x+2] = src[x+1] + g + 128;
486 for (x = off; x < w; x += 3) {
487 int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
488 int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
489 int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);
490 src[x+0] = av_clip_uint8(r);
491 src[x+1] = av_clip_uint8(g);
492 src[x+2] = av_clip_uint8(b);
510 for (i = 0; i < s->
height; i++) {
511 for (x = off; x < w; x +=
stride)
519 for (x = 0; x < w; x++)
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
const uint8_t ff_log2_run[41]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int shift(int a, int b)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_cold int init(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len)
read unsigned golomb rice code (jpegls).
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
MJPEG encoder and decoder.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
8 bits with AV_PIX_FMT_RGB32 palette
#define FF_DEBUG_PICT_INFO
static av_cold int end(AVCodecContext *avctx)
bitstream reader API header.
static int get_bits_left(GetBitContext *gb)
int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
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)
int ff_jpegls_decode_lse(MJpegDecodeContext *s)
Decode LSE block with initialization parameters.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const float pred[4]
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Libavcodec external API header.
static void ls_decode_line(JLSState *state, MJpegDecodeContext *s, void *last, void *dst, int last2, int w, int stride, int comp, int bits)
Decode one line of image.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static unsigned int get_bits1(GetBitContext *s)
int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv)
static void skip_bits(GetBitContext *s, int n)
static int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q)
Get context-dependent Golomb code, decode it and update context.
int reset
context halfing interval ?rename
const VDPAUPixFmtMap * map
AVCodec ff_jpegls_decoder
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
GLint GLenum GLboolean GLsizei stride
common internal api header.
static int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RItype, int limit_add)
Get Golomb code, decode it and update state for run termination.
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
static const uint8_t * align_get_bits(GetBitContext *s)
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static void ff_jpegls_downscale_state(JLSState *state, int Q)