#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
+
#include "avcodec.h"
-#include "get_bits.h"
+#include "bitstream.h"
#include "internal.h"
#define BIT_PLANAR 0x00
#define BIT_LINE 0x80
#define BYTE_LINE 0xC0
-typedef struct {
+typedef struct CDXLVideoContext {
AVCodecContext *avctx;
- AVFrame frame;
int bpp;
int format;
int padded_bits;
static void bitplanar2chunky(CDXLVideoContext *c, int linesize, uint8_t *out)
{
- GetBitContext gb;
+ BitstreamContext bc;
int x, y, plane;
- init_get_bits(&gb, c->video, c->video_size * 8);
+ bitstream_init8(&bc, c->video, c->video_size);
for (plane = 0; plane < c->bpp; plane++) {
for (y = 0; y < c->avctx->height; y++) {
for (x = 0; x < c->avctx->width; x++)
- out[linesize * y + x] |= get_bits1(&gb) << plane;
- skip_bits(&gb, c->padded_bits);
+ out[linesize * y + x] |= bitstream_read_bit(&bc) << plane;
+ bitstream_skip(&bc, c->padded_bits);
}
}
}
static void bitline2chunky(CDXLVideoContext *c, int linesize, uint8_t *out)
{
- GetBitContext gb;
+ BitstreamContext bc;
int x, y, plane;
- init_get_bits(&gb, c->video, c->video_size * 8);
+ bitstream_init8(&bc, c->video, c->video_size);
for (y = 0; y < c->avctx->height; y++) {
for (plane = 0; plane < c->bpp; plane++) {
for (x = 0; x < c->avctx->width; x++)
- out[linesize * y + x] |= get_bits1(&gb) << plane;
- skip_bits(&gb, c->padded_bits);
+ out[linesize * y + x] |= bitstream_read_bit(&bc) << plane;
+ bitstream_skip(&bc, c->padded_bits);
}
}
}
return AVERROR_PATCHWELCOME;
}
- if ((ret = av_image_check_size(w, h, 0, avctx)) < 0)
+ if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
return ret;
- if (w != avctx->width || h != avctx->height)
- avcodec_set_dimensions(avctx, w, h);
aligned_width = FFALIGN(c->avctx->width, 16);
c->padded_bits = aligned_width - c->avctx->width;
if (encoding) {
av_fast_padded_malloc(&c->new_video, &c->new_video_size,
- h * w + FF_INPUT_BUFFER_PADDING_SIZE);
+ h * w + AV_INPUT_BUFFER_PADDING_SIZE);
if (!c->new_video)
return AVERROR(ENOMEM);
if (c->bpp == 8)
.init = cdxl_decode_init,
.close = cdxl_decode_end,
.decode = cdxl_decode_frame,
- .capabilities = CODEC_CAP_DR1,
+ .capabilities = AV_CODEC_CAP_DR1,
};