28 #define BITSTREAM_READER_LE
94 int id,
int bpp, uint32_t vflipped)
114 memcpy(dst,
src, avctx->
width * bpp);
164 U[
w >> 2] =
src[16] + 0x80;
165 V[
w >> 2] =
src[17] + 0x80;
169 for (
w = 0;
w < hmargin;
w++) {
176 U[huvborder] =
src[0] + 0x80;
177 V[huvborder] =
src[1] + 0x80;
196 U[
w >> 2] =
src[0] + 0x80;
197 V[
w >> 2] =
src[1] + 0x80;
201 for (
w = 0;
w < hmargin;
w++) {
209 U[huvborder] =
src[0] + 0x80;
210 V[huvborder] =
src[1] + 0x80;
256 U[
w >> 1] =
src[4] + 0x80;
257 V[
w >> 1] =
src[5] + 0x80;
263 U[huvborder] =
src[2] + 0x80;
264 V[huvborder] =
src[3] + 0x80;
276 U[
w >> 1] =
src[0] + 0x80;
277 V[
w >> 1] =
src[1] + 0x80;
282 U[huvborder] =
src[1] + 0x80;
283 V[huvborder] =
src[2] + 0x80;
317 for (
w = 0;
w < avctx->
width;
w++) {
319 U[
w] = *
src++ ^ 0x80;
320 V[
w] = *
src++ ^ 0x80;
332 static const uint8_t def_lru[8] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xFF };
343 memmove(lru + 1, lru,
sizeof(*lru) * (8 - 1));
346 memmove(lru + 1, lru,
sizeof(*lru) * (
c - 1));
355 int slice_size,
int off)
359 if (slice_size > src_size - off) {
361 "invalid slice size %d (only %d bytes left)\n",
362 slice_size, src_size - off);
365 if (slice_size <= 16) {
372 if (cur_slice_size != slice_size - 16) {
374 "Slice sizes mismatch: got %d instead of %d\n",
375 cur_slice_size, slice_size - 16);
384 int *nslices,
int *off)
387 *nslices = bytestream2_get_le16(gb);
388 *off =
FFALIGN(*nslices * 4 + 2, 16);
389 if (src_size < *off) {
411 memmove(lru + 1, lru,
sizeof(*lru) * (6 - 1));
414 memmove(lru + 1, lru,
sizeof(*lru) * (
c - 1));
436 int nslices, slice,
line = 0;
437 uint32_t off, slice_size;
448 for (slice = 0; slice < nslices; slice++) {
449 slice_size = bytestream2_get_le32(&gb_check);
451 if (slice_size <= 16 + (avctx->
height * avctx->
width / (8 * nslices)))
453 off_check += slice_size;
465 for (slice = 0; slice < nslices; slice++) {
466 slice_size = bytestream2_get_le32(&gb);
503 for (x = 0; x <
width; x++) {
507 dst[x * 3 + 0] = (
r << 3) | (
r >> 2);
508 dst[x * 3 + 1] = is_565 ? (
g << 2) | (
g >> 4) : (
g << 3) | (
g >> 2);
509 dst[x * 3 + 2] = (
b << 3) | (
b >> 2);
570 for (x = 0; x <
width; x++) {
586 for (
i = 0;
i < 3;
i++)
615 int h,
w, hmargin, vmargin;
624 for (y = 0; y < left - 3 &&
get_bits_left(gb) >= 18 *
w / 4 + hmargin * 4 + (!!hmargin * 2); y += 4) {
625 for (x = 0; x <
w; x += 4) {
626 for (j = 0; j < 4; j++)
627 for (
i = 0;
i < 4;
i++)
633 for (j = 0; j < 4; j++)
634 for (
i = 0;
i < hmargin;
i++)
645 if (vmargin && y + vmargin == left) {
646 for (x = 0; x <
width; x += 4) {
647 for (j = 0; j < vmargin; j++)
648 for (
i = 0;
i < 4;
i++)
654 for (j = 0; j < vmargin; j++) {
655 for (
i = 0;
i < hmargin;
i++)
695 int h,
w, hmargin, vmargin;
704 for (y = 0; y < left - 1 &&
get_bits_left(gb) >= 3 *
w + hmargin * 4; y += 2) {
705 for (x = 0; x <
w; x += 2) {
726 for (x = 0; x <
width; x += 2) {
768 for (x = 0; x <
width; x++) {
800 if (avpkt->
size < 16) {
806 vflipped = !!(
type & 0x20);
static double val(void *priv, double ch)
Libavcodec external API header.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
static int dxtory_decode_v1_420(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, uint32_t vflipped)
static int dx2_decode_slice_420(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
static int dxtory_decode_v1_rgb(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, int id, int bpp, uint32_t vflipped)
int(* decode_slice_func)(GetBitContext *gb, AVFrame *frame, int line, int height, uint8_t lru[3][8])
static int load_buffer(AVCodecContext *avctx, const uint8_t *src, int src_size, GetByteContext *gb, int *nslices, int *off)
static const uint8_t def_lru_565[8]
static int64_t get_raw_size(enum AVPixelFormat fmt, int width, int height)
AVCodec ff_dxtory_decoder
static int dxtory_decode_v2_565(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, int is_565, uint32_t vflipped)
static void setup_lru_555(uint8_t lru[3][8])
static const uint8_t def_lru[8]
static int dx2_decode_slice_555(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
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, uint32_t vflipped)
static int dxtory_decode_v2_444(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, uint32_t vflipped)
static void default_setup_lru(uint8_t lru[3][8])
static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, uint32_t vflipped)
static uint8_t decode_sym(GetBitContext *gb, uint8_t lru[8])
static uint8_t decode_sym_565(GetBitContext *gb, uint8_t lru[8], int bits)
void(* setup_lru_func)(uint8_t lru[3][8])
static int dxtory_decode_v2_410(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, uint32_t vflipped)
static int dx2_decode_slice_410(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
static const uint8_t def_lru_555[8]
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 void do_vflip(AVCodecContext *avctx, AVFrame *pic, int vflip)
static int dxtory_decode_v1_444(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, uint32_t vflipped)
static int check_slice_size(AVCodecContext *avctx, const uint8_t *src, int src_size, int slice_size, int off)
static int dx2_decode_slice_444(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static void setup_lru_565(uint8_t lru[3][8])
static int dxtory_decode_v2_420(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, uint32_t vflipped)
static int dxtory_decode_v2_rgb(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, uint32_t vflipped)
static int dx2_decode_slice_rgb(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
static int dx2_decode_slice_565(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8])
static int decode_slice(AVCodecContext *c, void *arg)
bitstream reader API header.
static int get_bits_left(GetBitContext *gb)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
@ AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
FF_ENABLE_DEPRECATION_WARNINGS int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
typedef void(RENAME(mix_any_func_type))
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int discard_damaged_percentage
The percentage of damaged samples to discard a frame.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int key_frame
1 -> keyframe, 0-> not
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
#define avpriv_request_sample(...)
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.