30 #define UNCHECKED_BITSTREAM_READER 1 53 for (i = 0; i < 1024; i++) {
65 while (he[last].len == 255 && last)
68 if (he[last].len > 32) {
73 for (i = last; i >= 0; i--) {
74 codes[i] = code >> (32 - he[i].
len);
77 code += 0x80000000
u >> (he[i].
len - 1);
81 bits,
sizeof(*bits),
sizeof(*bits),
82 codes,
sizeof(*codes),
sizeof(*codes),
83 syms,
sizeof(*syms),
sizeof(*syms), 0);
97 for (i = 0; i < 256; i++) {
109 while (he[last].len == 255 && last)
112 if (he[last].len > 32)
116 for (i = last; i >= 0; i--) {
117 codes[i] = code >> (32 - he[i].
len);
120 code += 0x80000000
u >> (he[i].
len - 1);
124 bits,
sizeof(*bits),
sizeof(*bits),
125 codes,
sizeof(*codes),
sizeof(*codes),
126 syms,
sizeof(*syms),
sizeof(*syms), 0);
130 uint16_t *dst,
int step, ptrdiff_t
stride,
135 int i, j, slice, pix, ret;
147 for (slice = 0; slice < c->
slices; slice++) {
151 send = (height * (slice + 1) / c->
slices);
152 dest = dst + sstart *
stride;
155 for (j = sstart; j < send; j++) {
156 for (i = 0; i < width * step; i += step) {
172 for (slice = 0; slice < c->
slices; slice++) {
174 int slice_data_start, slice_data_end, slice_size;
177 send = (height * (slice + 1) / c->
slices);
178 dest = dst + sstart *
stride;
181 slice_data_start = slice ?
AV_RL32(src + slice * 4 - 4) : 0;
182 slice_data_end =
AV_RL32(src + slice * 4);
183 slice_size = slice_data_end - slice_data_start;
187 "yet a slice has a length of zero.\n");
193 (uint32_t *)(src + slice_data_start + c->
slices * 4),
194 (slice_data_end - slice_data_start + 3) >> 2);
198 for (j = sstart; j < send; j++) {
199 int ws = width * step;
200 for (i = 0; i < ws; i += step) {
216 "Slice decoding ran out of bits\n");
238 int i, j, slice, pix;
251 for (slice = 0; slice < c->
slices; slice++) {
255 send = (height * (slice + 1) / c->
slices) & cmask;
256 dest = dst + sstart *
stride;
259 for (j = sstart; j < send; j++) {
260 for (i = 0; i < width * step; i += step) {
263 prev += (unsigned)pix;
277 for (slice = 0; slice < c->
slices; slice++) {
279 int slice_data_start, slice_data_end, slice_size;
282 send = (height * (slice + 1) / c->
slices) & cmask;
283 dest = dst + sstart *
stride;
286 slice_data_start = slice ?
AV_RL32(src + slice * 4 - 4) : 0;
287 slice_data_end =
AV_RL32(src + slice * 4);
288 slice_size = slice_data_end - slice_data_start;
292 "yet a slice has a length of zero.\n");
298 (uint32_t *)(src + slice_data_start + c->
slices * 4),
299 (slice_data_end - slice_data_start + 3) >> 2);
303 for (j = sstart; j < send; j++) {
304 int ws = width * step;
305 for (i = 0; i < ws; i += step) {
319 "Slice decoding ran out of bits\n");
347 int slice_start, slice_height;
348 const int cmask = ~rmode;
350 for (slice = 0; slice < slices; slice++) {
351 slice_start = ((slice *
height) / slices) & cmask;
352 slice_height = ((((slice + 1) * height) / slices) & cmask) -
357 bsrc = src + slice_start *
stride;
363 if (slice_height <= 1)
369 for (i = 1; i <
width; i++) {
377 for (j = 2; j < slice_height; j++) {
379 bsrc, width, &A, &B);
395 int slice_start, slice_height;
396 const int cmask = ~(rmode ? 3 : 1);
397 const ptrdiff_t stride2 = stride << 1;
399 for (slice = 0; slice < slices; slice++) {
400 slice_start = ((slice *
height) / slices) & cmask;
401 slice_height = ((((slice + 1) * height) / slices) & cmask) -
407 bsrc = src + slice_start *
stride;
414 if (slice_height <= 1)
420 for (i = 1; i <
width; i++) {
421 B = bsrc[i - stride2];
427 bsrc + stride, width, &A, &B);
430 for (j = 2; j < slice_height; j++) {
432 bsrc, width, &A, &B);
434 bsrc + stride, width, &A, &B);
446 int slice_start, slice_height;
447 const int cmask = ~rmode;
449 for (slice = 0; slice < slices; slice++) {
450 slice_start = ((slice *
height) / slices) & cmask;
451 slice_height = ((((slice + 1) * height) / slices) & cmask) -
456 bsrc = src + slice_start *
stride;
462 if (slice_height <= 1)
464 for (j = 1; j < slice_height; j++) {
466 bsrc[0] = (bsrc[0] + bsrc[-
stride]) & 0xFF;
467 for (i = 1; i <
width; i++) {
469 B = bsrc[i - (stride + 1)];
471 bsrc[i] = (A - B + C + bsrc[i]) & 0xFF;
484 int slice_start, slice_height;
485 const int cmask = ~(rmode ? 3 : 1);
486 const ptrdiff_t stride2 = stride << 1;
488 for (slice = 0; slice < slices; slice++) {
489 slice_start = ((slice *
height) / slices) & cmask;
490 slice_height = ((((slice + 1) * height) / slices) & cmask) -
496 bsrc = src + slice_start *
stride;
503 if (slice_height <= 1)
505 for (j = 1; j < slice_height; j++) {
507 bsrc[0] = (bsrc[0] + bsrc[-stride2]) & 0xFF;
508 for (i = 1; i <
width; i++) {
509 A = bsrc[i - stride2];
510 B = bsrc[i - (stride2 + 1)];
512 bsrc[i] = (A - B + C + bsrc[i]) & 0xFF;
515 B = bsrc[-(1 + stride + stride -
width)];
518 for (i = 1; i <
width; i++) {
520 B = bsrc[i - (1 +
stride)];
522 bsrc[i +
stride] = (A - B + C + bsrc[i +
stride]) & 0xFF;
533 int buf_size = avpkt->
size;
537 int plane_size, max_slice_size = 0, slice_start,
slice_end, slice_size;
554 for (i = 0; i < c->
planes; i++) {
555 plane_start[i] = gb.
buffer;
562 for (j = 0; j < c->
slices; j++) {
563 slice_end = bytestream2_get_le32u(&gb);
564 if (slice_end < 0 || slice_end < slice_start ||
569 slice_size = slice_end - slice_start;
571 max_slice_size =
FFMAX(max_slice_size, slice_size);
579 for (i = 0; i < c->
planes; i++) {
580 plane_start[i] = gb.
buffer;
588 for (j = 0; j < c->
slices; j++) {
589 slice_end = bytestream2_get_le32u(&gb);
590 if (slice_end < 0 || slice_end < slice_start ||
595 slice_size = slice_end - slice_start;
597 max_slice_size =
FFMAX(max_slice_size, slice_size);
614 max_slice_size += 4*avctx->
width;
627 for (i = 0; i < c->
planes; i++) {
630 avctx->
height, plane_start[i],
664 for (i = 0; i < c->
planes; i++) {
667 avctx->
height, plane_start[i],
668 plane_start[i + 1] - 1024,
678 for (i = 0; i < 3; i++) {
710 for (i = 0; i < 3; i++) {
740 for (i = 0; i < 3; i++) {
770 for (i = 0; i < 3; i++) {
793 int h_shift, v_shift;
804 case MKTAG(
'U',
'L',
'R',
'G'):
808 case MKTAG(
'U',
'L',
'R',
'A'):
812 case MKTAG(
'U',
'L',
'Y',
'0'):
817 case MKTAG(
'U',
'L',
'Y',
'2'):
822 case MKTAG(
'U',
'L',
'Y',
'4'):
827 case MKTAG(
'U',
'Q',
'Y',
'2'):
832 case MKTAG(
'U',
'Q',
'R',
'G'):
837 case MKTAG(
'U',
'Q',
'R',
'A'):
842 case MKTAG(
'U',
'L',
'H',
'0'):
847 case MKTAG(
'U',
'L',
'H',
'2'):
852 case MKTAG(
'U',
'L',
'H',
'4'):
864 if ((avctx->
width & ((1<<h_shift)-1)) ||
865 (avctx->
height & ((1<<v_shift)-1))) {
895 "Insufficient extradata size %d, should be at least 16\n",
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(* add_left_pred)(uint8_t *dst, const uint8_t *src, ptrdiff_t w, int left)
int ff_ut10_huff_cmp_len(const void *a, const void *b)
#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)
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
#define avpriv_request_sample(...)
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
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)
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)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
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.
void(* add_median_pred)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, ptrdiff_t w, int *left, int *left_top)
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)
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
#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.
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)
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.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
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)
#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.
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)
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
#define MKTAG(a, b, c, d)
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.
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)