*/
//#define JLS_BROKEN
-typedef struct JpegLSDecodeContext {
- MJpegDecodeContext mjpeg;
- JLSState state;
-} JpegLSDecodeContext;
-
/**
* Decode LSE block with initialization parameters
*/
if (s->palette_index > maxtab)
return AVERROR_INVALIDDATA;
- if ((s->avctx->pix_fmt == AV_PIX_FMT_GRAY8 || s->avctx->pix_fmt == AV_PIX_FMT_PAL8) &&
- (s->picture_ptr->format == AV_PIX_FMT_GRAY8 || s->picture_ptr->format == AV_PIX_FMT_PAL8)) {
- uint32_t *pal = (uint32_t *)s->picture_ptr->data[1];
+ if (s->avctx->pix_fmt == AV_PIX_FMT_GRAY8 || s->avctx->pix_fmt == AV_PIX_FMT_PAL8) {
+ uint32_t *pal = s->palette;
int shift = 0;
if (s->avctx->bits_per_raw_sample > 0 && s->avctx->bits_per_raw_sample < 8) {
shift = 8 - s->avctx->bits_per_raw_sample;
}
- s->picture_ptr->format =
s->avctx->pix_fmt = AV_PIX_FMT_PAL8;
for (i=s->palette_index; i<=maxtab; i++) {
uint8_t k = i << shift;
{
int i, t = 0;
uint8_t *zero, *last, *cur;
- JLSState *const state = &((JpegLSDecodeContext*)s)->state;
+ JLSState *state = s->jls_state;
int off = 0, stride = 1, width, shift, ret = 0;
int decoded_height = 0;
+ if (!state) {
+ state = av_malloc(sizeof(*state));
+ if (!state)
+ return AVERROR(ENOMEM);
+ s->jls_state = state;
+ }
zero = av_mallocz(s->picture_ptr->linesize[0]);
if (!zero)
return AVERROR(ENOMEM);
return ret;
}
-AVCodec ff_jpegls_decoder = {
+const AVCodec ff_jpegls_decoder = {
.name = "jpegls",
.long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_JPEGLS,
- .priv_data_size = sizeof(JpegLSDecodeContext),
+ .priv_data_size = sizeof(MJpegDecodeContext),
.init = ff_mjpeg_decode_init,
.close = ff_mjpeg_decode_end,
.receive_frame = ff_mjpeg_receive_frame,