43 return aa->
sym - bb->sym;
53 for (i = 0; i < 4; i++)
62 int i, subsampled_height;
63 uint32_t original_format;
83 "4:2:0 video requires even width and height.\n");
94 if (avctx->
width & 1) {
96 "4:2:2 video requires even width.\n");
118 "Prediction method %d is not supported in Ut Video.\n",
125 "Plane prediction is not supported in Ut Video.\n");
143 "Slice count %d is not supported in Ut Video (theoretical range is 0-256).\n",
150 if (avctx->
slices > subsampled_height) {
152 "Slice count %d is larger than the subsampling-applied height %d.\n",
153 avctx->
slices, subsampled_height);
177 for (i = 0; i < c->
planes; i++) {
210 c->
slices = subsampled_height / 120;
243 int k = 2 * dst_stride;
246 for (j = 0; j <
height; j++) {
248 for (i = 0; i < width * step; i += step) {
252 dst[1][k] = src[i + 2] -
g;
253 dst[2][k] = src[i + 0] -
g;
257 for (i = 0; i < width * step; i += step) {
261 dst[1][k] = src[i + 2] -
g;
262 dst[2][k] = src[i + 0] -
g;
263 dst[3][k] = src[i + 3];
267 k += dst_stride -
width;
280 for (j = 0; j <
height; j++) {
281 for (i = 0; i <
width; i++) {
282 *dst++ = src[i] - prev;
299 for (i = 0; i <
width; i++) {
300 *dst++ = src[i] - prev;
316 for (j = 1; j <
height; j++) {
325 int height, uint64_t *counts)
329 for (j = 0; j <
height; j++) {
330 for (i = 0; i <
width; i++) {
346 while (he[last].
len == 255 && last)
350 for (i = last; i >= 0; i--) {
351 he[i].
code = code >> (32 - he[i].
len);
352 code += 0x80000000
u >> (he[i].
len - 1);
369 for (j = 0; j <
height; j++) {
370 for (i = 0; i <
width; i++)
397 uint64_t counts[256] = { 0 };
401 uint32_t
offset = 0, slice_len = 0;
403 int i, sstart, send = 0;
410 for (i = 0; i < c->
slices; i++) {
412 send = height * (i + 1) / c->
slices & cmask;
414 src + sstart * stride, stride,
415 width, send - sstart);
419 for (i = 0; i < c->
slices; i++) {
421 send = height * (i + 1) / c->
slices & cmask;
422 left_predict(src + sstart * stride, dst + sstart * width,
423 stride, width, send - sstart);
427 for (i = 0; i < c->
slices; i++) {
429 send = height * (i + 1) / c->
slices & cmask;
431 stride, width, send - sstart);
444 for (symbol = 0; symbol < 256; symbol++) {
446 if (counts[symbol]) {
448 if (counts[symbol] == width * (int64_t)height) {
453 for (i = 0; i < 256; i++) {
455 bytestream2_put_byte(pb, 0);
457 bytestream2_put_byte(pb, 0xFF);
461 for (i = 0; i < c->
slices; i++)
462 bytestream2_put_le32(pb, 0);
480 for (i = 0; i < 256; i++) {
481 bytestream2_put_byte(pb, lengths[i]);
483 he[i].
len = lengths[i];
491 for (i = 0; i < c->
slices; i++) {
493 send = height * (i + 1) / c->
slices & cmask;
500 width * height + 4, width,
501 send - sstart, he) >> 3;
503 slice_len = offset - slice_len;
511 bytestream2_put_le32(pb, offset);
515 offset - slice_len, SEEK_CUR);
534 const AVFrame *pic,
int *got_packet)
573 for (i = 0; i < c->
planes; i++) {
585 for (i = 0; i < c->
planes; i++) {
587 pic->
linesize[i], i, width >> !!i, height, &pb);
596 for (i = 0; i < c->
planes; i++) {
598 pic->
linesize[i], i, width >> !!i, height >> !!i,
619 bytestream2_put_le32(&pb, frame_info);
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
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data.
#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 void mangle_rgb_planes(uint8_t *dst[4], int dst_stride, uint8_t *src, int step, int stride, int width, int height)
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.
static int huff_cmp_sym(const void *a, const void *b)
packed RGB 8:8:8, 24bpp, RGBRGB...
AVFrame * coded_frame
the picture in the bitstream
static av_cold int init(AVCodecContext *avctx)
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
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 FF_INPUT_BUFFER_PADDING_SIZE at the end w...
void(* sub_hfyu_median_pred)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top)
Subtract HuffYUV's variant of median prediction.
av_cold void ff_huffyuvencdsp_init(HuffYUVEncDSPContext *c)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define CODEC_CAP_INTRA_ONLY
Codec is intra only.
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)
static void left_predict(uint8_t *src, uint8_t *dst, int stride, int width, int height)
#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.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
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)
Libavcodec external API header.
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)
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
static void median_predict(UtvideoContext *c, uint8_t *src, uint8_t *dst, int stride, int width, int height)
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static int encode_plane(AVCodecContext *avctx, uint8_t *src, uint8_t *dst, int stride, int plane_no, int width, int height, PutByteContext *pb)
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)
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').
BYTE int const BYTE int int int height
enum AVColorSpace colorspace
YUV colorspace type.
huffman tree builder and VLC generator
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)
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
int prediction_method
prediction method (needed for huffyuv)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
int slices
Number of slices.
HuffYUVEncDSPContext hdsp
uint8_t * slice_buffer[4]
#define AVERROR_OPTION_NOT_FOUND
Option not found.
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.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...