23 #define BITSTREAM_READER_LE
29 #include "libavutil/common.h"
30 #include "libavutil/intreadwrite.h"
39 if (src_size < avctx->
width * avctx->
height * 3 / 2) {
52 for (h = 0; h < avctx->
height; h += 2) {
53 for (w = 0; w < avctx->
width; w += 2) {
56 U[w >> 1] = src[4] + 0x80;
57 V[w >> 1] = src[5] + 0x80;
69 static const uint8_t def_lru[8] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xFF };
78 memmove(lru + 1, lru,
sizeof(*lru) * (8 - 1));
81 memmove(lru + 1, lru,
sizeof(*lru) * (c - 1));
90 int ystride,
int ustride,
int vstride)
95 for (i = 0; i < 3; i++)
98 for (y = 0; y <
height; y+=2) {
99 for (x = 0; x <
width; x += 2) {
100 Y[x + 0 + 0 * ystride] =
decode_sym(gb, lru[0]);
101 Y[x + 1 + 0 * ystride] =
decode_sym(gb, lru[0]);
102 Y[x + 0 + 1 * ystride] =
decode_sym(gb, lru[0]);
103 Y[x + 1 + 1 * ystride] =
decode_sym(gb, lru[0]);
121 int nslices, slice, slice_height;
122 uint32_t
off, slice_size;
127 nslices = bytestream2_get_le16(&gb);
128 off =
FFALIGN(nslices * 4 + 2, 16);
129 if (src_size < off) {
134 if (!nslices || avctx->
height % nslices) {
140 slice_height = avctx->
height / nslices;
141 if ((avctx->
width & 1) || (slice_height & 1)) {
143 avctx->
width, slice_height);
154 for (slice = 0; slice < nslices; slice++) {
155 slice_size = bytestream2_get_le32(&gb);
156 if (slice_size > src_size - off) {
158 "invalid slice size %d (only %d bytes left)\n",
159 slice_size, src_size - off);
162 if (slice_size <= 16) {
167 if (
AV_RL32(src + off) != slice_size - 16) {
169 "Slice sizes mismatch: got %d instead of %d\n",
170 AV_RL32(src + off), slice_size - 16);
176 Y += pic->
linesize[0] * slice_height;
177 U += pic->
linesize[1] * (slice_height >> 1);
178 V += pic->
linesize[2] * (slice_height >> 1);
192 if (avpkt->
size < 16) {
const char const char void * val
#define AVERROR_PATCHWELCOME
This structure describes decoded (raw) audio or video data.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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)
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(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size)
const char * name
Name of the codec implementation.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
bitstream reader API header.
static const uint8_t def_lru[8]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Libavcodec external API header.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static int dx2_decode_slice(GetBitContext *gb, int width, int height, uint8_t *Y, uint8_t *U, uint8_t *V, int ystride, int ustride, int vstride)
static uint8_t decode_sym(GetBitContext *gb, uint8_t lru[8])
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
AVCodec ff_dxtory_decoder
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
BYTE int const BYTE int int int height
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int dxtory_decode_v1(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size)
common internal api header.
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
#define AVERROR_INVALIDDATA
int key_frame
1 -> keyframe, 0-> not
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)