28 #define BITSTREAM_READER_LE
43 if (src_size < avctx->
width * avctx->
height * (int64_t)bpp) {
53 for (h = 0; h < avctx->
height; h++) {
54 memcpy(dst, src, avctx->
width * bpp);
55 src += avctx->
width * bpp;
84 for (h = 0; h < avctx->
height; h += 4) {
85 for (w = 0; w < avctx->
width; w += 4) {
90 U[w >> 2] = src[16] + 0x80;
91 V[w >> 2] = src[17] + 0x80;
125 for (h = 0; h < avctx->
height; h += 2) {
126 for (w = 0; w < avctx->
width; w += 2) {
129 U[w >> 1] = src[4] + 0x80;
130 V[w >> 1] = src[5] + 0x80;
149 if (src_size < avctx->
width * avctx->
height * 3LL) {
161 for (h = 0; h < avctx->
height; h++) {
162 for (w = 0; w < avctx->
width; w++) {
164 U[
w] = *src++ ^ 0x80;
165 V[
w] = *src++ ^ 0x80;
175 static const uint8_t def_lru[8] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xFF };
186 memmove(lru + 1, lru,
sizeof(*lru) * (8 - 1));
189 memmove(lru + 1, lru,
sizeof(*lru) * (c - 1));
198 int slice_size,
int off)
202 if (slice_size > src_size - off) {
204 "invalid slice size %d (only %d bytes left)\n",
205 slice_size, src_size - off);
208 if (slice_size <= 16) {
214 cur_slice_size =
AV_RL32(src + off);
215 if (cur_slice_size != slice_size - 16) {
217 "Slice sizes mismatch: got %d instead of %d\n",
218 cur_slice_size, slice_size - 16);
227 int *nslices,
int *off)
230 *nslices = bytestream2_get_le16(gb);
231 *off =
FFALIGN(*nslices * 4 + 2, 16);
232 if (src_size < *off) {
254 memmove(lru + 1, lru,
sizeof(*lru) * (6 - 1));
257 memmove(lru + 1, lru,
sizeof(*lru) * (c - 1));
277 int nslices, slice,
line = 0;
278 uint32_t off, slice_size;
282 ret =
load_buffer(avctx, src, src_size, &gb, &nslices, &off);
290 for (slice = 0; slice < nslices; slice++) {
291 slice_size = bytestream2_get_le32(&gb);
299 if ((ret =
init_get_bits8(&gb2, src + off + 16, slice_size - 16)) < 0)
307 if (avctx->
height - line) {
325 for (y = 0; y < left && get_bits_left(gb) > 6 *
width; y++) {
326 for (x = 0; x <
width; x++) {
330 dst[x * 3 + 0] = (r << 3) | (r >> 2);
331 dst[x * 3 + 1] = is_565 ? (g << 2) | (g >> 4) : (g << 3) | (g >> 2);
332 dst[x * 3 + 2] = (b << 3) | (b >> 2);
391 for (y = 0; y < left && get_bits_left(gb) > 6 *
width; y++) {
392 for (x = 0; x <
width; x++) {
408 for (i = 0; i < 3; i++)
437 for (x = 0; x <
width; x += 4) {
438 for (j = 0; j < 4; j++)
439 for (i = 0; i < 4; i++)
440 Y[x + i + j * ystride] =
decode_sym(gb, lru[0]);
481 for (x = 0; x <
width; x += 2) {
482 Y[x + 0 + 0 * ystride] =
decode_sym(gb, lru[0]);
483 Y[x + 1 + 0 * ystride] =
decode_sym(gb, lru[0]);
484 Y[x + 0 + 1 * ystride] =
decode_sym(gb, lru[0]);
485 Y[x + 1 + 1 * ystride] =
decode_sym(gb, lru[0]);
523 for (y = 0; y < left && get_bits_left(gb) > 6 *
width; y++) {
524 for (x = 0; x <
width; x++) {
554 if (avpkt->
size < 16) {
static int dxtory_decode_v2_rgb(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size)
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void(* setup_lru_func)(uint8_t lru[3][8])
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
packed RGB 8:8:8, 24bpp, RGBRGB...
static int decode_slice(AVCodecContext *c, void *arg)
static void default_setup_lru(uint8_t lru[3][8])
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
static const uint8_t def_lru_555[8]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static int dxtory_decode_v2_420(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size)
static int dx2_decode_slice_565(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static int dxtory_decode_v2_444(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size)
static int dxtory_decode_v1_420(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
static av_always_inline int dx2_decode_slice_5x5(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8], int is_565)
static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size)
bitstream reader API header.
static int dxtory_decode_v1_444(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size)
static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, decode_slice_func decode_slice, setup_lru_func setup_lru, enum AVPixelFormat fmt)
int(* decode_slice_func)(GetBitContext *gb, AVFrame *frame, int line, int height, uint8_t lru[3][8])
static int get_bits_left(GetBitContext *gb)
static const uint8_t def_lru[8]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void setup_lru_555(uint8_t lru[3][8])
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int dx2_decode_slice_420(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
const char * name
Name of the codec implementation.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static int dx2_decode_slice_410(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
static int dx2_decode_slice_rgb(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
packed RGB 8:8:8, 24bpp, BGRBGR...
static int dx2_decode_slice_555(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
static uint8_t decode_sym(GetBitContext *gb, uint8_t lru[8])
static int dxtory_decode_v2_410(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size)
static int load_buffer(AVCodecContext *avctx, const uint8_t *src, int src_size, GetByteContext *gb, int *nslices, int *off)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
AVCodec ff_dxtory_decoder
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int dxtory_decode_v2_565(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, int is_565)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static int check_slice_size(AVCodecContext *avctx, const uint8_t *src, int src_size, int slice_size, int off)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const uint8_t def_lru_565[8]
GLint GLenum GLboolean GLsizei stride
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
common internal and external API header
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
static int dx2_decode_slice_444(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
int key_frame
1 -> keyframe, 0-> not
static int dxtory_decode_v1_rgb(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, int id, int bpp)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
AVPixelFormat
Pixel format.
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static uint8_t decode_sym_565(GetBitContext *gb, uint8_t lru[8], int bits)
static void setup_lru_565(uint8_t lru[3][8])
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)