25 #define BITSTREAM_READER_LE
42 if (src_size < avctx->
width * avctx->
height * (int64_t)bpp) {
52 for (h = 0; h < avctx->
height; h++) {
53 memcpy(dst, src, avctx->
width * bpp);
54 src += avctx->
width * bpp;
83 for (h = 0; h < avctx->
height; h += 4) {
84 for (w = 0; w < avctx->
width; w += 4) {
89 U[w >> 2] = src[16] + 0x80;
90 V[w >> 2] = src[17] + 0x80;
124 for (h = 0; h < avctx->
height; h += 2) {
125 for (w = 0; w < avctx->
width; w += 2) {
128 U[w >> 1] = src[4] + 0x80;
129 V[w >> 1] = src[5] + 0x80;
148 if (src_size < avctx->
width * avctx->
height * 3LL) {
160 for (h = 0; h < avctx->
height; h++) {
161 for (w = 0; w < avctx->
width; w++) {
163 U[w] = *src++ ^ 0x80;
164 V[w] = *src++ ^ 0x80;
174 static const uint8_t def_lru[8] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xFF };
185 memmove(lru + 1, lru,
sizeof(*lru) * (8 - 1));
188 memmove(lru + 1, lru,
sizeof(*lru) * (c - 1));
197 int slice_size,
int off)
201 if (slice_size > src_size - off) {
203 "invalid slice size %"PRIu32
" (only %"PRIu32
" bytes left)\n",
204 slice_size, src_size - off);
207 if (slice_size <= 16) {
213 cur_slice_size =
AV_RL32(src + off);
214 if (cur_slice_size != slice_size - 16) {
216 "Slice sizes mismatch: got %"PRIu32
" instead of %"PRIu32
"\n",
217 cur_slice_size, slice_size - 16);
226 int *nslices,
int *off)
229 *nslices = bytestream2_get_le16(gb);
230 *off =
FFALIGN(*nslices * 4 + 2, 16);
231 if (src_size < *off) {
253 memmove(lru + 1, lru,
sizeof(*lru) * (6 - 1));
256 memmove(lru + 1, lru,
sizeof(*lru) * (c - 1));
276 int nslices, slice,
line = 0;
277 uint32_t off, slice_size;
281 ret =
load_buffer(avctx, src, src_size, &gb, &nslices, &off);
289 for (slice = 0; slice < nslices; slice++) {
290 slice_size = bytestream2_get_le32(&gb);
298 if ((ret =
init_get_bits8(&gb2, src + off + 16, slice_size - 16)) < 0)
306 if (avctx->
height - line) {
308 "Not enough slice data available, "
309 "cropping the frame by %d pixels\n",
328 for (y = 0; y < left && get_bits_left(gb) > 16; y++) {
329 for (x = 0; x <
width; x++) {
333 dst[x * 3 + 0] = (r << 3) | (r >> 2);
334 dst[x * 3 + 1] = is_565 ? (g << 2) | (g >> 4) : (g << 3) | (g >> 2);
335 dst[x * 3 + 2] = (b << 3) | (b >> 2);
394 for (y = 0; y < left && get_bits_left(gb) > 16; y++) {
395 for (x = 0; x <
width; x++) {
411 for (i = 0; i < 3; i++)
439 for (y = 0; y < left - 3 &&
get_bits_left(gb) > 16; y += 4) {
440 for (x = 0; x <
width; x += 4) {
441 for (j = 0; j < 4; j++)
442 for (i = 0; i < 4; i++)
443 Y[x + i + j * ystride] =
decode_sym(gb, lru[0]);
483 for (y = 0; y < left - 1 &&
get_bits_left(gb) > 16; y += 2) {
484 for (x = 0; x <
width; x += 2) {
485 Y[x + 0 + 0 * ystride] =
decode_sym(gb, lru[0]);
486 Y[x + 1 + 0 * ystride] =
decode_sym(gb, lru[0]);
487 Y[x + 0 + 1 * ystride] =
decode_sym(gb, lru[0]);
488 Y[x + 1 + 1 * ystride] =
decode_sym(gb, lru[0]);
526 for (y = 0; y < left && get_bits_left(gb) > 16; y++) {
527 for (x = 0; x <
width; x++) {
557 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.
#define AV_LOG_VERBOSE
Detailed information.
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]
int width
width and height of the video frame
#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)