30 #define UNCHECKED_BITSTREAM_READER 1
52 for (i = 0; i < 1024; i++) {
64 while (he[last].len == 255 && last)
67 if (he[last].len > 32) {
72 for (i = last; i >= 0; i--) {
73 codes[i] = code >> (32 - he[i].
len);
76 code += 0x80000000
u >> (he[i].
len - 1);
80 bits,
sizeof(*bits),
sizeof(*bits),
81 codes,
sizeof(*codes),
sizeof(*codes),
82 syms,
sizeof(*syms),
sizeof(*syms), 0);
96 for (i = 0; i < 256; i++) {
108 while (he[last].len == 255 && last)
111 if (he[last].len > 32)
115 for (i = last; i >= 0; i--) {
116 codes[i] = code >> (32 - he[i].
len);
119 code += 0x80000000
u >> (he[i].
len - 1);
123 bits,
sizeof(*bits),
sizeof(*bits),
124 codes,
sizeof(*codes),
sizeof(*codes),
125 syms,
sizeof(*syms),
sizeof(*syms), 0);
129 uint16_t *dst,
int step, ptrdiff_t
stride,
134 int i, j, slice, pix, ret;
146 for (slice = 0; slice < c->
slices; slice++) {
150 send = (height * (slice + 1) / c->
slices);
151 dest = dst + sstart *
stride;
154 for (j = sstart; j < send; j++) {
155 for (i = 0; i < width * step; i += step) {
171 for (slice = 0; slice < c->
slices; slice++) {
173 int slice_data_start, slice_data_end, slice_size;
176 send = (height * (slice + 1) / c->
slices);
177 dest = dst + sstart *
stride;
180 slice_data_start = slice ?
AV_RL32(src + slice * 4 - 4) : 0;
181 slice_data_end =
AV_RL32(src + slice * 4);
182 slice_size = slice_data_end - slice_data_start;
186 "yet a slice has a length of zero.\n");
192 (uint32_t *)(src + slice_data_start + c->
slices * 4),
193 (slice_data_end - slice_data_start + 3) >> 2);
197 for (j = sstart; j < send; j++) {
198 int ws = width * step;
199 for (i = 0; i < ws; i += step) {
215 "Slice decoding ran out of bits\n");
237 int i, j, slice, pix;
250 for (slice = 0; slice < c->
slices; slice++) {
254 send = (height * (slice + 1) / c->
slices) & cmask;
255 dest = dst + sstart *
stride;
258 for (j = sstart; j < send; j++) {
259 for (i = 0; i < width * step; i += step) {
276 for (slice = 0; slice < c->
slices; slice++) {
278 int slice_data_start, slice_data_end, slice_size;
281 send = (height * (slice + 1) / c->
slices) & cmask;
282 dest = dst + sstart *
stride;
285 slice_data_start = slice ?
AV_RL32(src + slice * 4 - 4) : 0;
286 slice_data_end =
AV_RL32(src + slice * 4);
287 slice_size = slice_data_end - slice_data_start;
291 "yet a slice has a length of zero.\n");
297 (uint32_t *)(src + slice_data_start + c->
slices * 4),
298 (slice_data_end - slice_data_start + 3) >> 2);
302 for (j = sstart; j < send; j++) {
303 int ws = width * step;
304 for (i = 0; i < ws; i += step) {
318 "Slice decoding ran out of bits\n");
346 int slice_start, slice_height;
347 const int cmask = ~rmode;
349 for (slice = 0; slice < slices; slice++) {
350 slice_start = ((slice *
height) / slices) & cmask;
351 slice_height = ((((slice + 1) * height) / slices) & cmask) -
356 bsrc = src + slice_start *
stride;
362 if (slice_height <= 1)
368 for (i = 1; i <
width; i++) {
376 for (j = 2; j < slice_height; j++) {
378 bsrc, width, &A, &B);
394 int slice_start, slice_height;
395 const int cmask = ~(rmode ? 3 : 1);
396 const ptrdiff_t stride2 = stride << 1;
398 for (slice = 0; slice < slices; slice++) {
399 slice_start = ((slice *
height) / slices) & cmask;
400 slice_height = ((((slice + 1) * height) / slices) & cmask) -
406 bsrc = src + slice_start *
stride;
413 if (slice_height <= 1)
419 for (i = 1; i <
width; i++) {
420 B = bsrc[i - stride2];
426 bsrc + stride, width, &A, &B);
429 for (j = 2; j < slice_height; j++) {
431 bsrc, width, &A, &B);
433 bsrc + stride, width, &A, &B);
445 int slice_start, slice_height;
446 const int cmask = ~rmode;
448 for (slice = 0; slice < slices; slice++) {
449 slice_start = ((slice *
height) / slices) & cmask;
450 slice_height = ((((slice + 1) * height) / slices) & cmask) -
455 bsrc = src + slice_start *
stride;
461 if (slice_height <= 1)
463 for (j = 1; j < slice_height; j++) {
465 bsrc[0] = (bsrc[0] + bsrc[-
stride]) & 0xFF;
466 for (i = 1; i <
width; i++) {
468 B = bsrc[i - (stride + 1)];
470 bsrc[i] = (A - B + C + bsrc[i]) & 0xFF;
483 int slice_start, slice_height;
484 const int cmask = ~(rmode ? 3 : 1);
485 const ptrdiff_t stride2 = stride << 1;
487 for (slice = 0; slice < slices; slice++) {
488 slice_start = ((slice *
height) / slices) & cmask;
489 slice_height = ((((slice + 1) * height) / slices) & cmask) -
495 bsrc = src + slice_start *
stride;
502 if (slice_height <= 1)
504 for (j = 1; j < slice_height; j++) {
506 bsrc[0] = (bsrc[0] + bsrc[-stride2]) & 0xFF;
507 for (i = 1; i <
width; i++) {
508 A = bsrc[i - stride2];
509 B = bsrc[i - (stride2 + 1)];
511 bsrc[i] = (A - B + C + bsrc[i]) & 0xFF;
514 B = bsrc[-(1 + stride + stride -
width)];
517 for (i = 1; i <
width; i++) {
519 B = bsrc[i - (1 +
stride)];
521 bsrc[i +
stride] = (A - B + C + bsrc[i +
stride]) & 0xFF;
532 int buf_size = avpkt->
size;
536 int plane_size, max_slice_size = 0, slice_start,
slice_end, slice_size;
553 for (i = 0; i < c->
planes; i++) {
554 plane_start[i] = gb.
buffer;
561 for (j = 0; j < c->
slices; j++) {
562 slice_end = bytestream2_get_le32u(&gb);
563 if (slice_end < 0 || slice_end < slice_start ||
568 slice_size = slice_end - slice_start;
570 max_slice_size =
FFMAX(max_slice_size, slice_size);
578 for (i = 0; i < c->
planes; i++) {
579 plane_start[i] = gb.
buffer;
587 for (j = 0; j < c->
slices; j++) {
588 slice_end = bytestream2_get_le32u(&gb);
589 if (slice_end < 0 || slice_end < slice_start ||
594 slice_size = slice_end - slice_start;
596 max_slice_size =
FFMAX(max_slice_size, slice_size);
613 max_slice_size += 4*avctx->
width;
626 for (i = 0; i < c->
planes; i++) {
629 avctx->
height, plane_start[i],
663 for (i = 0; i < c->
planes; i++) {
666 avctx->
height, plane_start[i],
667 plane_start[i + 1] - 1024,
677 for (i = 0; i < 3; i++) {
709 for (i = 0; i < 3; i++) {
739 for (i = 0; i < 3; i++) {
769 for (i = 0; i < 3; i++) {
825 "Insufficient extradata size %d, should be at least 16\n",
833 case MKTAG(
'U',
'L',
'R',
'G'):
837 case MKTAG(
'U',
'L',
'R',
'A'):
841 case MKTAG(
'U',
'L',
'Y',
'0'):
846 case MKTAG(
'U',
'L',
'Y',
'2'):
851 case MKTAG(
'U',
'L',
'Y',
'4'):
856 case MKTAG(
'U',
'Q',
'Y',
'2'):
860 case MKTAG(
'U',
'Q',
'R',
'G'):
864 case MKTAG(
'U',
'Q',
'R',
'A'):
868 case MKTAG(
'U',
'L',
'H',
'0'):
873 case MKTAG(
'U',
'L',
'H',
'2'):
878 case MKTAG(
'U',
'L',
'H',
'4'):
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
static void restore_median_planar_il(UtvideoContext *c, uint8_t *src, ptrdiff_t stride, int width, int height, int slices, int rmode)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ff_ut10_huff_cmp_len(const void *a, const void *b)
ptrdiff_t const GLvoid * data
#define AV_PIX_FMT_GBRAP10
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_cold int init(AVCodecContext *avctx)
void(* restore_rgb_planes)(uint8_t *src_r, uint8_t *src_g, uint8_t *src_b, ptrdiff_t linesize_r, ptrdiff_t linesize_g, ptrdiff_t linesize_b, int width, int height)
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
#define AV_PIX_FMT_GBRP10
static av_cold int decode_end(AVCodecContext *avctx)
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 void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static int decode_plane(UtvideoContext *c, int plane_no, uint8_t *dst, int step, ptrdiff_t stride, int width, int height, const uint8_t *src, int use_pred)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static void restore_gradient_planar(UtvideoContext *c, uint8_t *src, ptrdiff_t stride, int width, int height, int slices, int rmode)
static void restore_gradient_planar_il(UtvideoContext *c, uint8_t *src, ptrdiff_t stride, int width, int height, int slices, int rmode)
Multithreading support functions.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
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 void bytestream2_skipu(GetByteContext *g, unsigned int size)
bitstream reader API header.
int interlaced_frame
The content of the picture is interlaced.
av_cold void ff_utvideodsp_init(UTVideoDSPContext *c)
static int build_huff(const uint8_t *src, VLC *vlc, int *fsym)
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold int decode_init(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const char * name
Name of the codec implementation.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
static void restore_median_planar(UtvideoContext *c, uint8_t *src, ptrdiff_t stride, int width, int height, int slices, int rmode)
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
void ff_llviddsp_init(LLVidDSPContext *c)
enum AVColorSpace colorspace
YUV colorspace type.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static int build_huff10(const uint8_t *src, VLC *vlc, int *fsym)
void(* restore_rgb_planes10)(uint16_t *src_r, uint16_t *src_g, uint16_t *src_b, ptrdiff_t linesize_r, ptrdiff_t linesize_g, ptrdiff_t linesize_b, int width, int height)
#define AV_PIX_FMT_YUV422P10
int ff_ut_huff_cmp_len(const void *a, const void *b)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
GLint GLenum GLboolean GLsizei stride
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
planar GBRA 4:4:4:4 32bpp
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
int(* add_left_pred)(uint8_t *dst, const uint8_t *src, ptrdiff_t w, int left)
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
#define MKTAG(a, b, c, d)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
AVCodec ff_utvideo_decoder
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
void(* add_median_pred)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, ptrdiff_t w, int *left, int *left_top)
static int decode_plane10(UtvideoContext *c, int plane_no, uint16_t *dst, int step, ptrdiff_t stride, int width, int height, const uint8_t *src, const uint8_t *huff, int use_pred)