49 s->blocks = (
s->width / 8) * (
s->height / 8);
72 { 0, 0, 0, 4, 4, 4, 4, 0};
78 { 0x10, 0x13, 0x17, 0x1A, 0x1E, 0x21, 0x25, 0x28,
79 0x2C, 0x2F, 0x33, 0x36, 0x3A, 0x3D, 0x41, 0x44,
80 0x48, 0x4B, 0x4F, 0x52, 0x56, 0x59, 0x5C, 0x60,
81 0x63, 0x67, 0x6A, 0x6E, 0x71, 0x75, 0x78, 0x7C,
82 0x7F, 0x83, 0x86, 0x8A, 0x8D, 0x91, 0x94, 0x98,
83 0x9B, 0x9F, 0xA2, 0xA5, 0xA9, 0xAC, 0xB0, 0xB3,
84 0xB7, 0xBA, 0xBE, 0xC1, 0xC5, 0xC8, 0xCC, 0xCF,
85 0xD3, 0xD6, 0xDA, 0xDD, 0xE1, 0xE4, 0xE8, 0xEB};
88 { 0x60, 0x67, 0x6D, 0x73, 0x7A, 0x80, 0x86, 0x8D,
89 0x93, 0x99, 0xA0, 0xA6, 0xAC, 0xB3, 0xB9, 0xC0};
96 uint8_t *y_plane, *cr_plane, *cb_plane;
99 y_plane =
frame->data[0] + x + y *
frame->linesize[0];
100 cr_plane =
frame->data[1] + (x / 4) + (y / 4) *
frame->linesize[1];
101 cb_plane =
frame->data[2] + (x / 4) + (y / 4) *
frame->linesize[2];
108 for(
i = 0;
i < 16;
i++){
111 y_plane +=
frame->linesize[0];
118 int f0,
int f1,
int Y0,
int Y1,
int chroma)
155 Luma[0] =
Y[0]; Luma[1] =
Y[1]; Luma[2] =
Y[2]; Luma[3] =
Y[3];
156 Luma[4] =
Y[0]; Luma[5] =
Y[1]; Luma[6] =
Y[2]; Luma[7] =
Y[3];
157 Luma[8] =
Y[0]; Luma[9] =
Y[1]; Luma[10] =
Y[2]; Luma[11] =
Y[3];
158 Luma[12] =
Y[0]; Luma[13] =
Y[1]; Luma[14] =
Y[2]; Luma[15] =
Y[3];
161 Luma[0] =
Y[1]; Luma[1] =
Y[2]; Luma[2] =
Y[3]; Luma[3] =
Y[3];
162 Luma[4] =
Y[0]; Luma[5] =
Y[1]; Luma[6] =
Y[2]; Luma[7] =
Y[3];
163 Luma[8] =
Y[0]; Luma[9] =
Y[1]; Luma[10] =
Y[2]; Luma[11] =
Y[3];
164 Luma[12] =
Y[0]; Luma[13] =
Y[0]; Luma[14] =
Y[1]; Luma[15] =
Y[2];
167 Luma[0] =
Y[1]; Luma[1] =
Y[2]; Luma[2] =
Y[3]; Luma[3] =
Y[3];
168 Luma[4] =
Y[1]; Luma[5] =
Y[2]; Luma[6] =
Y[2]; Luma[7] =
Y[3];
169 Luma[8] =
Y[0]; Luma[9] =
Y[1]; Luma[10] =
Y[1]; Luma[11] =
Y[2];
170 Luma[12] =
Y[0]; Luma[13] =
Y[0]; Luma[14] =
Y[1]; Luma[15] =
Y[2];
173 Luma[0] =
Y[2]; Luma[1] =
Y[3]; Luma[2] =
Y[3]; Luma[3] =
Y[3];
174 Luma[4] =
Y[1]; Luma[5] =
Y[2]; Luma[6] =
Y[2]; Luma[7] =
Y[3];
175 Luma[8] =
Y[0]; Luma[9] =
Y[1]; Luma[10] =
Y[1]; Luma[11] =
Y[2];
176 Luma[12] =
Y[0]; Luma[13] =
Y[0]; Luma[14] =
Y[0]; Luma[15] =
Y[1];
179 Luma[0] =
Y[3]; Luma[1] =
Y[3]; Luma[2] =
Y[3]; Luma[3] =
Y[3];
180 Luma[4] =
Y[2]; Luma[5] =
Y[2]; Luma[6] =
Y[2]; Luma[7] =
Y[2];
181 Luma[8] =
Y[1]; Luma[9] =
Y[1]; Luma[10] =
Y[1]; Luma[11] =
Y[1];
182 Luma[12] =
Y[0]; Luma[13] =
Y[0]; Luma[14] =
Y[0]; Luma[15] =
Y[0];
185 Luma[0] =
Y[3]; Luma[1] =
Y[3]; Luma[2] =
Y[3]; Luma[3] =
Y[2];
186 Luma[4] =
Y[3]; Luma[5] =
Y[2]; Luma[6] =
Y[2]; Luma[7] =
Y[1];
187 Luma[8] =
Y[2]; Luma[9] =
Y[1]; Luma[10] =
Y[1]; Luma[11] =
Y[0];
188 Luma[12] =
Y[1]; Luma[13] =
Y[0]; Luma[14] =
Y[0]; Luma[15] =
Y[0];
191 Luma[0] =
Y[3]; Luma[1] =
Y[3]; Luma[2] =
Y[2]; Luma[3] =
Y[2];
192 Luma[4] =
Y[3]; Luma[5] =
Y[2]; Luma[6] =
Y[1]; Luma[7] =
Y[1];
193 Luma[8] =
Y[2]; Luma[9] =
Y[2]; Luma[10] =
Y[1]; Luma[11] =
Y[0];
194 Luma[12] =
Y[1]; Luma[13] =
Y[1]; Luma[14] =
Y[0]; Luma[15] =
Y[0];
197 Luma[0] =
Y[3]; Luma[1] =
Y[3]; Luma[2] =
Y[2]; Luma[3] =
Y[1];
198 Luma[4] =
Y[3]; Luma[5] =
Y[2]; Luma[6] =
Y[1]; Luma[7] =
Y[0];
199 Luma[8] =
Y[3]; Luma[9] =
Y[2]; Luma[10] =
Y[1]; Luma[11] =
Y[0];
200 Luma[12] =
Y[2]; Luma[13] =
Y[1]; Luma[14] =
Y[0]; Luma[15] =
Y[0];
203 Luma[0] =
Y[0]; Luma[1] =
Y[0]; Luma[2] =
Y[1]; Luma[3] =
Y[1];
204 Luma[4] =
Y[0]; Luma[5] =
Y[0]; Luma[6] =
Y[1]; Luma[7] =
Y[1];
205 Luma[8] =
Y[2]; Luma[9] =
Y[2]; Luma[10] =
Y[3]; Luma[11] =
Y[3];
206 Luma[12] =
Y[2]; Luma[13] =
Y[2]; Luma[14] =
Y[3]; Luma[15] =
Y[3];
216 const uint8_t *buf = avpkt->
data;
217 int buf_size = avpkt->
size;
236 if(blocks >=
s->blocks || y >=
s->height)
241 idx = bytestream2_get_byteu(&
s->gb);
242 if((idx & 0xF8) == 0x70) {
245 modifier = bytestream2_get_byte(&
s->gb);
247 av_log(avctx,
AV_LOG_INFO,
"warning: modifier must be 0 or 1, got %i\n", modifier);
259 skip = bytestream2_get_byte(&
s->gb);
260 if ((blocks +
skip) >=
s->blocks)
264 while(x >=
s->width) {
286 chroma = bytestream2_get_byte(&
s->gb);
289 for (
i = 0;
i < 4;
i++) {
290 code = (idx >> (6 -
i*2)) & 3;
294 chroma = bytestream2_get_byte(&
s->gb);
300 tmp = bytestream2_get_byte(&
s->gb);
320 tmp = bytestream2_get_be24(&
s->gb);
322 Y[0] = (
tmp >> 18) & 0x3F;
323 Y[1] = (
tmp >> 12) & 0x3F;
324 Y[2] = (
tmp >> 6) & 0x3F;
328 tmp = bytestream2_get_be16(&
s->gb);
330 angle = (
tmp >> 12) & 0xF;
333 Y[0] =
s->ulti_codebook[
tmp];
334 Y[1] =
s->ulti_codebook[
tmp + 1];
335 Y[2] =
s->ulti_codebook[
tmp + 2];
336 Y[3] =
s->ulti_codebook[
tmp + 3];
346 tmp = bytestream2_get_be24u(&
s->gb);
347 Luma[0] = (
tmp >> 18) & 0x3F;
348 Luma[1] = (
tmp >> 12) & 0x3F;
349 Luma[2] = (
tmp >> 6) & 0x3F;
350 Luma[3] =
tmp & 0x3F;
352 tmp = bytestream2_get_be24u(&
s->gb);
353 Luma[4] = (
tmp >> 18) & 0x3F;
354 Luma[5] = (
tmp >> 12) & 0x3F;
355 Luma[6] = (
tmp >> 6) & 0x3F;
356 Luma[7] =
tmp & 0x3F;
358 tmp = bytestream2_get_be24u(&
s->gb);
359 Luma[8] = (
tmp >> 18) & 0x3F;
360 Luma[9] = (
tmp >> 12) & 0x3F;
361 Luma[10] = (
tmp >> 6) & 0x3F;
362 Luma[11] =
tmp & 0x3F;
364 tmp = bytestream2_get_be24u(&
s->gb);
365 Luma[12] = (
tmp >> 18) & 0x3F;
366 Luma[13] = (
tmp >> 12) & 0x3F;
367 Luma[14] = (
tmp >> 6) & 0x3F;
368 Luma[15] =
tmp & 0x3F;
374 tmp = bytestream2_get_byteu(&
s->gb);
376 angle = (
tmp >> 4) & 0x7;
377 tmp = (
tmp << 8) + bytestream2_get_byteu(&
s->gb);
378 Y[0] = (
tmp >> 6) & 0x3F;
380 Y[2] = bytestream2_get_byteu(&
s->gb) & 0x3F;
381 Y[3] = bytestream2_get_byteu(&
s->gb) & 0x3F;
385 int f1 = bytestream2_get_byteu(&
s->gb);
386 Y[0] = bytestream2_get_byteu(&
s->gb) & 0x3F;
387 Y[1] = bytestream2_get_byteu(&
s->gb) & 0x3F;
413 "Insufficient data\n");
418 .p.name =
"ultimotion",
const FFCodec ff_ulti_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
const uint8_t * ulti_codebook
static const uint8_t ulti_chromas[16]
static const int angle_by_index[4]
static const int block_coords[8]
static int ulti_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static av_cold int ulti_decode_init(AVCodecContext *avctx)
static void ulti_pattern(AVFrame *frame, int x, int y, int f0, int f1, int Y0, int Y1, int chroma)
static av_cold int ulti_decode_end(AVCodecContext *avctx)
static void ulti_grad(AVFrame *frame, int x, int y, uint8_t *Y, int chroma, int angle)
static void ulti_convert_yuv(AVFrame *frame, int x, int y, uint8_t *luma, int chroma)
static const uint8_t ulti_lumas[64]
static const unsigned char ulti_codebook[16384]