2007-05-13 23:16:56 +00:00
|
|
|
/*
|
|
|
|
* JPEG-LS decoder
|
|
|
|
* Copyright (c) 2003 Michael Niedermayer
|
|
|
|
* Copyright (c) 2006 Konstantin Shishkov
|
|
|
|
*
|
2011-03-18 17:35:10 +00:00
|
|
|
* This file is part of Libav.
|
2007-05-13 23:16:56 +00:00
|
|
|
*
|
2011-03-18 17:35:10 +00:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2007-05-13 23:16:56 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2011-03-18 17:35:10 +00:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2007-05-13 23:16:56 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2011-03-18 17:35:10 +00:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2007-05-13 23:16:56 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-04-20 14:45:34 +00:00
|
|
|
* @file
|
2007-05-13 23:16:56 +00:00
|
|
|
* JPEG-LS decoder.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "avcodec.h"
|
2009-04-13 16:20:26 +00:00
|
|
|
#include "get_bits.h"
|
2007-05-13 23:16:56 +00:00
|
|
|
#include "golomb.h"
|
2009-01-18 22:57:40 +00:00
|
|
|
#include "mathops.h"
|
2007-05-13 23:16:56 +00:00
|
|
|
#include "mjpeg.h"
|
2007-05-19 14:31:57 +00:00
|
|
|
#include "mjpegdec.h"
|
2007-05-13 23:16:56 +00:00
|
|
|
#include "jpegls.h"
|
|
|
|
#include "jpeglsdec.h"
|
|
|
|
|
|
|
|
/*
|
2013-05-15 17:03:53 +00:00
|
|
|
* Uncomment this to significantly speed up decoding of broken JPEG-LS
|
|
|
|
* (or test broken JPEG-LS decoder) and slow down ordinary decoding a bit.
|
|
|
|
*
|
|
|
|
* There is no Golomb code with length >= 32 bits possible, so check and
|
|
|
|
* avoid situation of 32 zeros, Libav Golomb decoder is painfully slow
|
|
|
|
* on this errors.
|
|
|
|
*/
|
2007-05-13 23:16:56 +00:00
|
|
|
//#define JLS_BROKEN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decode LSE block with initialization parameters
|
|
|
|
*/
|
|
|
|
int ff_jpegls_decode_lse(MJpegDecodeContext *s)
|
|
|
|
{
|
2012-04-19 12:55:49 +00:00
|
|
|
int id;
|
2007-05-13 23:16:56 +00:00
|
|
|
|
2012-04-19 12:55:49 +00:00
|
|
|
skip_bits(&s->gb, 16); /* length: FIXME: verify field validity */
|
2007-05-13 23:16:56 +00:00
|
|
|
id = get_bits(&s->gb, 8);
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
switch (id) {
|
2007-05-13 23:16:56 +00:00
|
|
|
case 1:
|
2013-05-15 17:03:53 +00:00
|
|
|
s->maxval = get_bits(&s->gb, 16);
|
|
|
|
s->t1 = get_bits(&s->gb, 16);
|
|
|
|
s->t2 = get_bits(&s->gb, 16);
|
|
|
|
s->t3 = get_bits(&s->gb, 16);
|
|
|
|
s->reset = get_bits(&s->gb, 16);
|
2007-05-13 23:16:56 +00:00
|
|
|
|
|
|
|
// ff_jpegls_reset_coding_parameters(s, 0);
|
|
|
|
//FIXME quant table?
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
av_log(s->avctx, AV_LOG_ERROR, "palette not supported\n");
|
2013-05-17 10:36:06 +00:00
|
|
|
return AVERROR(ENOSYS);
|
2007-05-13 23:16:56 +00:00
|
|
|
case 4:
|
|
|
|
av_log(s->avctx, AV_LOG_ERROR, "oversize image not supported\n");
|
2013-05-17 10:36:06 +00:00
|
|
|
return AVERROR(ENOSYS);
|
2007-05-13 23:16:56 +00:00
|
|
|
default:
|
|
|
|
av_log(s->avctx, AV_LOG_ERROR, "invalid id %d\n", id);
|
2013-05-17 10:36:06 +00:00
|
|
|
return AVERROR_INVALIDDATA;
|
2007-05-13 23:16:56 +00:00
|
|
|
}
|
2012-08-21 10:41:40 +00:00
|
|
|
av_dlog(s->avctx, "ID=%i, T=%i,%i,%i\n", id, s->t1, s->t2, s->t3);
|
2007-05-13 23:16:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get context-dependent Golomb code, decode it and update context
|
|
|
|
*/
|
2013-05-15 17:03:53 +00:00
|
|
|
static inline int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q)
|
|
|
|
{
|
2007-05-13 23:16:56 +00:00
|
|
|
int k, ret;
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
for (k = 0; (state->N[Q] << k) < state->A[Q]; k++)
|
|
|
|
;
|
2007-05-13 23:16:56 +00:00
|
|
|
|
|
|
|
#ifdef JLS_BROKEN
|
2013-05-15 17:03:53 +00:00
|
|
|
if (!show_bits_long(gb, 32))
|
|
|
|
return -1;
|
2007-05-13 23:16:56 +00:00
|
|
|
#endif
|
|
|
|
ret = get_ur_golomb_jpegls(gb, k, state->limit, state->qbpp);
|
|
|
|
|
|
|
|
/* decode mapped error */
|
2013-05-15 17:03:53 +00:00
|
|
|
if (ret & 1)
|
2013-05-15 17:55:09 +00:00
|
|
|
ret = -(ret + 1 >> 1);
|
2007-05-13 23:16:56 +00:00
|
|
|
else
|
|
|
|
ret >>= 1;
|
|
|
|
|
|
|
|
/* for NEAR=0, k=0 and 2*B[Q] <= - N[Q] mapping is reversed */
|
2013-05-15 17:03:53 +00:00
|
|
|
if (!state->near && !k && (2 * state->B[Q] <= -state->N[Q]))
|
2007-05-13 23:16:56 +00:00
|
|
|
ret = -(ret + 1);
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
ret = ff_jpegls_update_state_regular(state, Q, ret);
|
2007-05-13 23:16:56 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Golomb code, decode it and update state for run termination
|
|
|
|
*/
|
2013-05-15 17:03:53 +00:00
|
|
|
static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state,
|
|
|
|
int RItype, int limit_add)
|
|
|
|
{
|
2007-05-13 23:16:56 +00:00
|
|
|
int k, ret, temp, map;
|
|
|
|
int Q = 365 + RItype;
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
temp = state->A[Q];
|
|
|
|
if (RItype)
|
2007-05-13 23:16:56 +00:00
|
|
|
temp += state->N[Q] >> 1;
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
for (k = 0; (state->N[Q] << k) < temp; k++)
|
|
|
|
;
|
2007-05-13 23:16:56 +00:00
|
|
|
|
|
|
|
#ifdef JLS_BROKEN
|
2013-05-15 17:03:53 +00:00
|
|
|
if (!show_bits_long(gb, 32))
|
|
|
|
return -1;
|
2007-05-13 23:16:56 +00:00
|
|
|
#endif
|
2013-05-15 17:03:53 +00:00
|
|
|
ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1,
|
|
|
|
state->qbpp);
|
2007-05-13 23:16:56 +00:00
|
|
|
|
|
|
|
/* decode mapped error */
|
|
|
|
map = 0;
|
2013-05-15 17:03:53 +00:00
|
|
|
if (!k && (RItype || ret) && (2 * state->B[Q] < state->N[Q]))
|
2007-05-13 23:16:56 +00:00
|
|
|
map = 1;
|
|
|
|
ret += RItype + map;
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
if (ret & 1) {
|
2013-05-15 17:55:09 +00:00
|
|
|
ret = map - (ret + 1 >> 1);
|
2007-05-13 23:16:56 +00:00
|
|
|
state->B[Q]++;
|
|
|
|
} else {
|
|
|
|
ret = ret >> 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update state */
|
|
|
|
state->A[Q] += FFABS(ret) - RItype;
|
2013-05-15 17:03:53 +00:00
|
|
|
ret *= state->twonear;
|
2007-05-13 23:16:56 +00:00
|
|
|
ff_jpegls_downscale_state(state, Q);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decode one line of image
|
|
|
|
*/
|
2013-05-15 17:03:53 +00:00
|
|
|
static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s,
|
|
|
|
void *last, void *dst, int last2, int w,
|
|
|
|
int stride, int comp, int bits)
|
|
|
|
{
|
2007-05-13 23:16:56 +00:00
|
|
|
int i, x = 0;
|
|
|
|
int Ra, Rb, Rc, Rd;
|
|
|
|
int D0, D1, D2;
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
while (x < w) {
|
2007-05-13 23:16:56 +00:00
|
|
|
int err, pred;
|
|
|
|
|
|
|
|
/* compute gradients */
|
|
|
|
Ra = x ? R(dst, x - stride) : R(last, x);
|
|
|
|
Rb = R(last, x);
|
|
|
|
Rc = x ? R(last, x - stride) : last2;
|
|
|
|
Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
|
|
|
|
D0 = Rd - Rb;
|
|
|
|
D1 = Rb - Rc;
|
|
|
|
D2 = Rc - Ra;
|
|
|
|
/* run mode */
|
2013-05-15 17:03:53 +00:00
|
|
|
if ((FFABS(D0) <= state->near) &&
|
|
|
|
(FFABS(D1) <= state->near) &&
|
|
|
|
(FFABS(D2) <= state->near)) {
|
2007-05-13 23:16:56 +00:00
|
|
|
int r;
|
|
|
|
int RItype;
|
|
|
|
|
|
|
|
/* decode full runs while available */
|
2013-05-15 17:03:53 +00:00
|
|
|
while (get_bits1(&s->gb)) {
|
2007-05-13 23:16:56 +00:00
|
|
|
int r;
|
|
|
|
r = 1 << ff_log2_run[state->run_index[comp]];
|
2013-05-15 17:03:53 +00:00
|
|
|
if (x + r * stride > w)
|
2007-05-13 23:16:56 +00:00
|
|
|
r = (w - x) / stride;
|
2013-05-15 17:03:53 +00:00
|
|
|
for (i = 0; i < r; i++) {
|
2007-05-13 23:16:56 +00:00
|
|
|
W(dst, x, Ra);
|
|
|
|
x += stride;
|
|
|
|
}
|
|
|
|
/* if EOL reached, we stop decoding */
|
2013-05-15 17:55:09 +00:00
|
|
|
if (r != 1 << ff_log2_run[state->run_index[comp]])
|
2007-05-13 23:16:56 +00:00
|
|
|
return;
|
2013-05-15 17:03:53 +00:00
|
|
|
if (state->run_index[comp] < 31)
|
2007-05-13 23:16:56 +00:00
|
|
|
state->run_index[comp]++;
|
2013-05-15 17:03:53 +00:00
|
|
|
if (x + stride > w)
|
2007-05-13 23:16:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* decode aborted run */
|
|
|
|
r = ff_log2_run[state->run_index[comp]];
|
2013-05-15 17:03:53 +00:00
|
|
|
if (r)
|
2007-05-13 23:16:56 +00:00
|
|
|
r = get_bits_long(&s->gb, r);
|
2013-05-15 17:03:53 +00:00
|
|
|
for (i = 0; i < r; i++) {
|
2007-05-13 23:16:56 +00:00
|
|
|
W(dst, x, Ra);
|
|
|
|
x += stride;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* decode run termination value */
|
2013-05-15 17:03:53 +00:00
|
|
|
Rb = R(last, x);
|
2007-05-13 23:16:56 +00:00
|
|
|
RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
|
2013-05-15 17:03:53 +00:00
|
|
|
err = ls_get_code_runterm(&s->gb, state, RItype,
|
|
|
|
ff_log2_run[state->run_index[comp]]);
|
|
|
|
if (state->run_index[comp])
|
2007-05-13 23:16:56 +00:00
|
|
|
state->run_index[comp]--;
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
if (state->near && RItype) {
|
2007-05-13 23:16:56 +00:00
|
|
|
pred = Ra + err;
|
|
|
|
} else {
|
2013-05-15 17:03:53 +00:00
|
|
|
if (Rb < Ra)
|
2007-05-13 23:16:56 +00:00
|
|
|
pred = Rb - err;
|
|
|
|
else
|
|
|
|
pred = Rb + err;
|
|
|
|
}
|
|
|
|
} else { /* regular mode */
|
|
|
|
int context, sign;
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
context = ff_jpegls_quantize(state, D0) * 81 +
|
|
|
|
ff_jpegls_quantize(state, D1) * 9 +
|
|
|
|
ff_jpegls_quantize(state, D2);
|
|
|
|
pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
|
2007-05-13 23:16:56 +00:00
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
if (context < 0) {
|
2007-05-13 23:16:56 +00:00
|
|
|
context = -context;
|
2013-05-15 17:03:53 +00:00
|
|
|
sign = 1;
|
|
|
|
} else {
|
2007-05-13 23:16:56 +00:00
|
|
|
sign = 0;
|
|
|
|
}
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
if (sign) {
|
2007-05-13 23:16:56 +00:00
|
|
|
pred = av_clip(pred - state->C[context], 0, state->maxval);
|
2013-05-15 17:03:53 +00:00
|
|
|
err = -ls_get_code_regular(&s->gb, state, context);
|
2007-05-13 23:16:56 +00:00
|
|
|
} else {
|
|
|
|
pred = av_clip(pred + state->C[context], 0, state->maxval);
|
2013-05-15 17:03:53 +00:00
|
|
|
err = ls_get_code_regular(&s->gb, state, context);
|
2007-05-13 23:16:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* we have to do something more for near-lossless coding */
|
|
|
|
pred += err;
|
|
|
|
}
|
2013-05-15 17:03:53 +00:00
|
|
|
if (state->near) {
|
|
|
|
if (pred < -state->near)
|
2007-05-13 23:16:56 +00:00
|
|
|
pred += state->range * state->twonear;
|
2013-05-15 17:03:53 +00:00
|
|
|
else if (pred > state->maxval + state->near)
|
2007-05-13 23:16:56 +00:00
|
|
|
pred -= state->range * state->twonear;
|
|
|
|
pred = av_clip(pred, 0, state->maxval);
|
|
|
|
}
|
|
|
|
|
|
|
|
pred &= state->maxval;
|
|
|
|
W(dst, x, pred);
|
|
|
|
x += stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
|
|
|
|
int point_transform, int ilv)
|
|
|
|
{
|
2007-05-13 23:16:56 +00:00
|
|
|
int i, t = 0;
|
|
|
|
uint8_t *zero, *last, *cur;
|
|
|
|
JLSState *state;
|
|
|
|
int off = 0, stride = 1, width, shift;
|
|
|
|
|
2011-03-27 20:16:25 +00:00
|
|
|
zero = av_mallocz(s->picture_ptr->linesize[0]);
|
2007-05-13 23:16:56 +00:00
|
|
|
last = zero;
|
2013-05-15 17:03:53 +00:00
|
|
|
cur = s->picture_ptr->data[0];
|
2007-05-13 23:16:56 +00:00
|
|
|
|
|
|
|
state = av_mallocz(sizeof(JLSState));
|
|
|
|
/* initialize JPEG-LS state from JPEG parameters */
|
2013-05-15 17:03:53 +00:00
|
|
|
state->near = near;
|
|
|
|
state->bpp = (s->bits < 2) ? 2 : s->bits;
|
2007-05-13 23:16:56 +00:00
|
|
|
state->maxval = s->maxval;
|
2013-05-15 17:03:53 +00:00
|
|
|
state->T1 = s->t1;
|
|
|
|
state->T2 = s->t2;
|
|
|
|
state->T3 = s->t3;
|
|
|
|
state->reset = s->reset;
|
2007-05-13 23:16:56 +00:00
|
|
|
ff_jpegls_reset_coding_parameters(state, 0);
|
|
|
|
ff_jpegls_init_state(state);
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
if (s->bits <= 8)
|
2007-05-13 23:16:56 +00:00
|
|
|
shift = point_transform + (8 - s->bits);
|
|
|
|
else
|
|
|
|
shift = point_transform + (16 - s->bits);
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
av_dlog(s->avctx,
|
|
|
|
"JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
|
|
|
|
"RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
|
2012-08-21 10:41:40 +00:00
|
|
|
s->width, s->height, state->near, state->maxval,
|
|
|
|
state->T1, state->T2, state->T3,
|
|
|
|
state->reset, state->limit, state->qbpp, state->range);
|
|
|
|
av_dlog(s->avctx, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n",
|
|
|
|
ilv, point_transform, s->bits, s->cur_scan);
|
2013-05-15 17:03:53 +00:00
|
|
|
if (ilv == 0) { /* separate planes */
|
|
|
|
off = s->cur_scan - 1;
|
2007-05-13 23:16:56 +00:00
|
|
|
stride = (s->nb_components > 1) ? 3 : 1;
|
2013-05-15 17:03:53 +00:00
|
|
|
width = s->width * stride;
|
|
|
|
cur += off;
|
|
|
|
for (i = 0; i < s->height; i++) {
|
|
|
|
if (s->bits <= 8) {
|
|
|
|
ls_decode_line(state, s, last, cur, t, width, stride, off, 8);
|
2007-05-13 23:16:56 +00:00
|
|
|
t = last[0];
|
2013-05-15 17:03:53 +00:00
|
|
|
} else {
|
2007-05-13 23:16:56 +00:00
|
|
|
ls_decode_line(state, s, last, cur, t, width, stride, off, 16);
|
2013-05-15 17:03:53 +00:00
|
|
|
t = *((uint16_t *)last);
|
2007-05-13 23:16:56 +00:00
|
|
|
}
|
|
|
|
last = cur;
|
2011-03-27 20:16:25 +00:00
|
|
|
cur += s->picture_ptr->linesize[0];
|
2007-05-13 23:16:56 +00:00
|
|
|
|
|
|
|
if (s->restart_interval && !--s->restart_count) {
|
|
|
|
align_get_bits(&s->gb);
|
|
|
|
skip_bits(&s->gb, 16); /* skip RSTn */
|
|
|
|
}
|
|
|
|
}
|
2013-05-15 17:03:53 +00:00
|
|
|
} else if (ilv == 1) { /* line interleaving */
|
2007-05-13 23:16:56 +00:00
|
|
|
int j;
|
2013-05-15 17:03:53 +00:00
|
|
|
int Rc[3] = { 0, 0, 0 };
|
2011-03-27 20:16:25 +00:00
|
|
|
memset(cur, 0, s->picture_ptr->linesize[0]);
|
2007-05-13 23:16:56 +00:00
|
|
|
width = s->width * 3;
|
2013-05-15 17:03:53 +00:00
|
|
|
for (i = 0; i < s->height; i++) {
|
|
|
|
for (j = 0; j < 3; j++) {
|
|
|
|
ls_decode_line(state, s, last + j, cur + j,
|
|
|
|
Rc[j], width, 3, j, 8);
|
2007-05-13 23:16:56 +00:00
|
|
|
Rc[j] = last[j];
|
|
|
|
|
|
|
|
if (s->restart_interval && !--s->restart_count) {
|
|
|
|
align_get_bits(&s->gb);
|
|
|
|
skip_bits(&s->gb, 16); /* skip RSTn */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
last = cur;
|
2011-03-27 20:16:25 +00:00
|
|
|
cur += s->picture_ptr->linesize[0];
|
2007-05-13 23:16:56 +00:00
|
|
|
}
|
2013-05-15 17:03:53 +00:00
|
|
|
} else if (ilv == 2) { /* sample interleaving */
|
2013-05-17 10:36:06 +00:00
|
|
|
avpriv_report_missing_feature(s->avctx, "Sample interleaved images");
|
2007-05-13 23:16:56 +00:00
|
|
|
av_free(state);
|
|
|
|
av_free(zero);
|
2013-05-17 10:36:06 +00:00
|
|
|
return AVERROR_PATCHWELCOME;
|
2007-05-13 23:16:56 +00:00
|
|
|
}
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
if (shift) { /* we need to do point transform or normalize samples */
|
2007-05-13 23:16:56 +00:00
|
|
|
int x, w;
|
|
|
|
|
|
|
|
w = s->width * s->nb_components;
|
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
if (s->bits <= 8) {
|
2011-03-27 20:16:25 +00:00
|
|
|
uint8_t *src = s->picture_ptr->data[0];
|
2007-05-13 23:16:56 +00:00
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
for (i = 0; i < s->height; i++) {
|
|
|
|
for (x = off; x < w; x += stride)
|
2007-05-13 23:16:56 +00:00
|
|
|
src[x] <<= shift;
|
2011-03-27 20:16:25 +00:00
|
|
|
src += s->picture_ptr->linesize[0];
|
2007-05-13 23:16:56 +00:00
|
|
|
}
|
2013-05-15 17:03:53 +00:00
|
|
|
} else {
|
|
|
|
uint16_t *src = (uint16_t *)s->picture_ptr->data[0];
|
2007-05-13 23:16:56 +00:00
|
|
|
|
2013-05-15 17:03:53 +00:00
|
|
|
for (i = 0; i < s->height; i++) {
|
|
|
|
for (x = 0; x < w; x++)
|
2007-05-13 23:16:56 +00:00
|
|
|
src[x] <<= shift;
|
2013-05-15 17:03:53 +00:00
|
|
|
src += s->picture_ptr->linesize[0] / 2;
|
2007-05-13 23:16:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
av_free(state);
|
|
|
|
av_free(zero);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-05-19 14:31:57 +00:00
|
|
|
|
2011-01-25 21:40:11 +00:00
|
|
|
AVCodec ff_jpegls_decoder = {
|
2011-07-17 10:54:31 +00:00
|
|
|
.name = "jpegls",
|
2013-05-15 17:03:53 +00:00
|
|
|
.long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
|
2011-07-17 10:54:31 +00:00
|
|
|
.type = AVMEDIA_TYPE_VIDEO,
|
2012-08-05 09:11:04 +00:00
|
|
|
.id = AV_CODEC_ID_JPEGLS,
|
2011-07-17 10:54:31 +00:00
|
|
|
.priv_data_size = sizeof(MJpegDecodeContext),
|
|
|
|
.init = ff_mjpeg_decode_init,
|
|
|
|
.close = ff_mjpeg_decode_end,
|
|
|
|
.decode = ff_mjpeg_decode_frame,
|
|
|
|
.capabilities = CODEC_CAP_DR1,
|
2007-05-19 14:31:57 +00:00
|
|
|
};
|