Go to the documentation of this file.
53 int tid, wt, maxtab,
i, j;
71 s->maxval,
s->t1,
s->t2,
s->t3,
s->reset);
93 else if ((5 + wt*(
s->maxval+1)) < 65535)
96 maxtab = 65530/wt - 1;
99 av_log(
s->avctx,
AV_LOG_DEBUG,
"LSE palette %d tid:%d wt:%d maxtab:%d\n",
id, tid, wt, maxtab);
105 maxtab =
FFMIN(maxtab, (
len - 5) / wt +
s->palette_index);
107 if (
s->palette_index > maxtab)
112 uint32_t *pal = (uint32_t *)
s->picture_ptr->data[1];
115 if (
s->avctx->bits_per_raw_sample > 0 &&
s->avctx->bits_per_raw_sample < 8) {
116 maxtab =
FFMIN(maxtab, (1<<
s->avctx->bits_per_raw_sample)-1);
117 shift = 8 -
s->avctx->bits_per_raw_sample;
122 if (
s->force_pal8 > 1)
127 for (
i=
s->palette_index;
i<=maxtab;
i++) {
129 pal[k] = wt < 4 ? 0xFF000000 : 0;
130 for (j=0; j<wt; j++) {
131 pal[k] |=
get_bits(&
s->gb, 8) << (8*(wt-j-1));
134 s->palette_index =
i;
144 ff_dlog(
s->avctx,
"ID=%i, T=%i,%i,%i\n",
id,
s->t1,
s->t2,
s->t3);
156 for (k = 0; ((unsigned)
state->N[
Q] << k) <
state->A[
Q]; k++)
184 int RItype,
int limit_add)
187 int Q = 365 + RItype;
193 for (k = 0; ((unsigned)
state->N[
Q] << k) <
temp; k++)
232 void *last,
void *dst,
int last2,
int w,
246 Ra = x ?
R(dst, x -
stride) :
R(last, x);
248 Rc = x ?
R(last, x -
stride) : last2;
266 for (
i = 0;
i <
r;
i++) {
285 for (
i = 0;
i <
r;
i++) {
298 RItype = (
FFABS(Ra - Rb) <=
state->near) ? 1 : 0;
304 if (
state->near && RItype) {
339 if (pred < -state->near)
355 int point_transform,
int ilv)
358 uint8_t *
zero, *last, *cur;
361 int decoded_height = 0;
373 cur =
s->picture_ptr->data[0];
378 state->bpp = (
s->bits < 2) ? 2 :
s->bits;
379 state->maxval =
s->maxval;
401 shift = point_transform + (8 -
s->bits);
403 shift = point_transform + (16 -
s->bits);
412 "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
413 "RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
418 ilv, point_transform,
s->bits,
s->cur_scan);
425 if (
s->cur_scan >
s->nb_components) {
429 stride = (
s->nb_components > 1) ? 3 : 1;
433 for (
i = 0;
i <
s->height;
i++) {
440 t = *((uint16_t *)last);
445 cur +=
s->picture_ptr->linesize[0];
447 if (
s->restart_interval && !--
s->restart_count) {
453 }
else if (ilv == 1) {
455 int Rc[3] = { 0, 0, 0 };
456 stride = (
s->nb_components > 1) ? 3 : 1;
457 memset(cur, 0,
s->picture_ptr->linesize[0]);
459 for (
i = 0;
i <
s->height;
i++) {
461 for (j = 0; j <
stride; j++) {
468 if (
s->restart_interval && !--
s->restart_count) {
476 cur +=
s->picture_ptr->linesize[0];
479 }
else if (ilv == 2) {
489 if (
s->xfrm &&
s->nb_components == 3) {
492 w =
s->width *
s->nb_components;
495 uint8_t *
src =
s->picture_ptr->data[0];
497 for (
i = 0;
i <
s->height;
i++) {
500 for (x = off; x + 2 <
w; x += 3) {
501 src[x ] +=
src[x+1] + 128;
502 src[x+2] +=
src[x+1] + 128;
506 for (x = off; x + 2 <
w; x += 3) {
507 src[x ] +=
src[x+1] + 128;
508 src[x+2] += ((
src[x ] +
src[x+1])>>1) + 128;
512 for (x = off; x + 2 <
w; x += 3) {
513 int g =
src[x+0] - ((
src[x+2]+
src[x+1])>>2) + 64;
520 for (x = off; x + 2 <
w; x += 3) {
521 int r =
src[x+0] - (( 359 * (
src[x+2]-128) + 490) >> 8);
522 int g =
src[x+0] - (( 88 * (
src[x+1]-128) - 183 * (
src[x+2]-128) + 30) >> 8);
523 int b =
src[x+0] + ((454 * (
src[x+1]-128) + 574) >> 8);
530 src +=
s->picture_ptr->linesize[0];
539 w =
s->width *
s->nb_components;
542 uint8_t *
src =
s->picture_ptr->data[0];
544 for (
i = 0;
i < decoded_height;
i++) {
545 for (x = off; x <
w; x +=
stride)
547 src +=
s->picture_ptr->linesize[0];
550 uint16_t *
src = (uint16_t *)
s->picture_ptr->data[0];
552 for (
i = 0;
i < decoded_height;
i++) {
553 for (x = 0; x <
w; x++)
555 src +=
s->picture_ptr->linesize[0] / 2;
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
static int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q)
Get context-dependent Golomb code, decode it and update context.
#define FF_DEBUG_PICT_INFO
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodec p
The public AVCodec.
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len)
read unsigned golomb rice code (jpegls).
#define FF_CODEC_DECODE_CB(func)
const FFCodec ff_jpegls_decoder
int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int 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.
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
#define CODEC_LONG_NAME(str)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your context
static void ff_jpegls_downscale_state(JLSState *state, int Q)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static unsigned int get_bits1(GetBitContext *s)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
int ff_jpegls_decode_lse(MJpegDecodeContext *s)
Decode LSE block with initialization parameters.
static int shift(int a, int b)
int ff_mjpeg_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
#define i(width, name, range_min, range_max)
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
static int ff_jpegls_update_state_regular(JLSState *state, int Q, int err)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
static const float pred[4]
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 const uint8_t * align_get_bits(GetBitContext *s)
void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
Calculate JPEG-LS codec values.
#define avpriv_request_sample(...)
const VDPAUPixFmtMap * map
const uint8_t ff_log2_run[41]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.