54 for (k = 0; (state->
N[Q] << k) < state->
A[Q]; k++)
57 map = !state->
near && !k && (2 * state->
B[Q] <= -state->
N[Q]);
61 if (err >= (state->
range + 1 >> 1)) {
76 int RItype,
int err,
int limit_add)
85 temp += state->
N[Q] >> 1;
86 for (k = 0; (state->
N[Q] << k) < temp; k++)
89 if (!k && err && (2 * state->
B[Q] < state->
N[Q]))
93 val = -(2 * err) - 1 - RItype + map;
95 val = 2 * err - RItype -
map;
100 state->
A[Q] += (val + 1 - RItype) >> 1;
131 void *last,
void *cur,
int last2,
int w,
142 Ra = x ?
R(cur, x - stride) :
R(last, x);
144 Rc = x ?
R(last, x - stride) : last2;
145 Rd = (x >= w -
stride) ?
R(last, x) :
R(last, x + stride);
154 int RUNval, RItype,
run;
158 while (x < w && (
FFABS(
R(cur, x) - RUNval) <= state->
near)) {
168 pred = RItype ? Ra : Rb;
169 err =
R(cur, x) -
pred;
171 if (!RItype && Ra > Rb)
180 if (RItype || (Rb >= Ra))
188 if (err >= state->
range + 1 >> 1)
202 pred =
mid_pred(Ra, Ra + Rb - Rc, Rb);
208 err = pred -
R(cur, x);
212 err =
R(cur, x) -
pred;
240 if (state->
T1 == state2.
T1 &&
241 state->
T2 == state2.
T2 &&
242 state->
T3 == state2.
T3 &&
257 const AVFrame *pict,
int *got_packet)
271 #if FF_API_PRIVATE_OPT 303 for (i = 1; i <= comps; i++) {
312 for (i = 1; i <= comps; i++) {
317 put_bits(&pb, 8, (comps > 1) ? 1 : 0);
340 for (i = 0; i < avctx->
height; i++) {
349 for (i = 0; i < avctx->
height; i++) {
351 t = *((uint16_t *)last);
357 int Rc[3] = { 0, 0, 0 };
359 width = avctx->
width * 3;
360 for (i = 0; i < avctx->
height; i++) {
361 for (j = 0; j < 3; j++) {
371 int Rc[3] = { 0, 0, 0 };
373 width = avctx->
width * 3;
374 for (i = 0; i < avctx->
height; i++) {
375 for (j = 2; j >= 0; j--) {
429 #if FF_API_CODED_FRAME 441 "Only grayscale and RGB24/BGR24 images are supported\n");
447 #define OFFSET(x) offsetof(JPEGLSContext, x) 448 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 471 .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]
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
This structure describes decoded (raw) audio or video data.
AVCodec ff_jpegls_encoder
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define LIBAVUTIL_VERSION_INT
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.
static av_cold int init(AVCodecContext *avctx)
const char * av_default_item_name(void *ptr)
Return the context name.
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...
MJPEG encoder and decoder.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#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)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
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.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
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 void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
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.
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.
GLint GLenum GLboolean GLsizei stride
#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.
#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
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
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
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 local context
AVPixelFormat
Pixel format.
static double val(void *priv, double ch)
This structure stores compressed data.
static void ff_jpegls_downscale_state(JLSState *state, int Q)