44 return aa->
sym - bb->sym;
53 for (i = 0; i < 4; i++)
62 int i, subsampled_height;
63 uint32_t original_format;
84 "4:2:0 video requires even width and height.\n");
95 if (avctx->
width & 1) {
97 "4:2:2 video requires even width.\n");
124 #if FF_API_PRIVATE_OPT
129 "Prediction method %d is not supported in Ut Video.\n",
136 "Plane prediction is not supported in Ut Video.\n");
157 "Slice count %d is not supported in Ut Video (theoretical range is 0-256).\n",
164 if (avctx->
slices > subsampled_height) {
166 "Slice count %d is larger than the subsampling-applied height %d.\n",
167 avctx->
slices, subsampled_height);
183 for (i = 0; i < c->
planes; i++) {
216 c->
slices = subsampled_height / 120;
250 int k = 2 * dst_stride;
253 for (j = 0; j <
height; j++) {
255 for (i = 0; i < width * step; i += step) {
259 dst[1][k] = src[i + 2] -
g;
260 dst[2][k] = src[i + 0] -
g;
264 for (i = 0; i < width * step; i += step) {
268 dst[1][k] = src[i + 2] -
g;
269 dst[2][k] = src[i + 0] -
g;
270 dst[3][k] = src[i + 3];
274 k += dst_stride -
width;
287 for (j = 0; j <
height; j++) {
288 for (i = 0; i <
width; i++) {
289 *dst++ = src[i] - prev;
309 for (i = 0; i <
width; i++) {
310 *dst++ = src[i] - prev;
326 for (j = 1; j <
height; j++) {
335 int height, uint64_t *counts)
339 for (j = 0; j <
height; j++) {
340 for (i = 0; i <
width; i++) {
356 while (he[last].
len == 255 && last)
360 for (i = last; i >= 0; i--) {
361 he[i].
code = code >> (32 - he[i].
len);
362 code += 0x80000000
u >> (he[i].
len - 1);
379 for (j = 0; j <
height; j++) {
380 for (i = 0; i <
width; i++)
407 uint64_t counts[256] = { 0 };
411 uint32_t
offset = 0, slice_len = 0;
413 int i, sstart, send = 0;
420 for (i = 0; i < c->
slices; i++) {
422 send = height * (i + 1) / c->
slices & cmask;
424 src + sstart * stride, stride,
425 width, send - sstart);
429 for (i = 0; i < c->
slices; i++) {
431 send = height * (i + 1) / c->
slices & cmask;
432 left_predict(src + sstart * stride, dst + sstart * width,
433 stride, width, send - sstart);
437 for (i = 0; i < c->
slices; i++) {
439 send = height * (i + 1) / c->
slices & cmask;
441 stride, width, send - sstart);
454 for (symbol = 0; symbol < 256; symbol++) {
456 if (counts[symbol]) {
458 if (counts[symbol] == width * (int64_t)height) {
463 for (i = 0; i < 256; i++) {
465 bytestream2_put_byte(pb, 0);
467 bytestream2_put_byte(pb, 0xFF);
471 for (i = 0; i < c->
slices; i++)
472 bytestream2_put_le32(pb, 0);
490 for (i = 0; i < 256; i++) {
491 bytestream2_put_byte(pb, lengths[i]);
493 he[i].
len = lengths[i];
501 for (i = 0; i < c->
slices; i++) {
503 send = height * (i + 1) / c->
slices & cmask;
510 width * height + 4, width,
511 send - sstart, he) >> 3;
513 slice_len = offset - slice_len;
521 bytestream2_put_le32(pb, offset);
525 offset - slice_len, SEEK_CUR);
544 const AVFrame *pic,
int *got_packet)
583 for (i = 0; i < c->
planes; i++) {
595 for (i = 0; i < c->
planes; i++) {
597 pic->
linesize[i], i, width, height, &pb);
606 for (i = 0; i < c->
planes; i++) {
608 pic->
linesize[i], i, width >> !!i, height, &pb);
617 for (i = 0; i < c->
planes; i++) {
619 pic->
linesize[i], i, width >> !!i, height >> !!i,
640 bytestream2_put_le32(&pb, frame_info);
646 #if FF_API_CODED_FRAME
662 #define OFFSET(x) offsetof(UtvideoContext, x)
663 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
687 .priv_class = &utvideo_class,
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
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
static int encode_plane(AVCodecContext *avctx, uint8_t *src, uint8_t *dst, ptrdiff_t stride, int plane_no, int width, int height, PutByteContext *pb)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
static int huff_cmp_sym(const void *a, const void *b)
packed RGB 8:8:8, 24bpp, RGBRGB...
static av_cold int init(AVCodecContext *avctx)
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
LLVidEncDSPContext llvidencdsp
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_cold int utvideo_encode_init(AVCodecContext *avctx)
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
static void median_predict(UtvideoContext *c, uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define AV_CODEC_CAP_INTRA_ONLY
Codec is intra only.
av_cold void ff_llvidencdsp_init(LLVidEncDSPContext *c)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVCodec ff_utvideo_encoder
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
const int ff_ut_pred_order[5]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static void mangle_rgb_planes(uint8_t *dst[4], ptrdiff_t dst_stride, uint8_t *src, int step, ptrdiff_t stride, int width, int height)
const char * name
Name of the codec implementation.
static const uint8_t offset[127][2]
static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size, int width, int height, HuffEntry *he)
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int flags
A combination of AV_PKT_FLAG values.
static int put_bits_count(PutBitContext *s)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void(* sub_median_pred)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, intptr_t w, int *left, int *left_top)
Subtract HuffYUV's variant of median prediction.
static const AVOption options[]
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static const AVClass utvideo_class
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
static av_always_inline int bytestream2_seek_p(PutByteContext *p, int offset, int whence)
int ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats, int stats_size, int skip0)
Libavcodec external API header.
attribute_deprecated int prediction_method
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static void left_predict(uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
Describe the class of an AVClass context structure.
enum AVColorSpace colorspace
YUV colorspace type.
huffman tree builder and VLC generator
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
static enum AVPixelFormat pix_fmts[]
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.
static void calculate_codes(HuffEntry *he)
static void count_usage(uint8_t *src, int width, int height, uint64_t *counts)
GLint GLenum GLboolean GLsizei stride
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int slices
Number of slices.
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
uint8_t * slice_buffer[4]
#define AVERROR_OPTION_NOT_FOUND
Option not found.
#define FF_ENABLE_DEPRECATION_WARNINGS
int key_frame
1 -> keyframe, 0-> not
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
#define MKTAG(a, b, c, d)
AVPixelFormat
Pixel format.
static av_cold int utvideo_encode_close(AVCodecContext *avctx)
This structure stores compressed data.