Go to the documentation of this file.
68 return (aa->
len - bb->len)*256 + aa->
sym - bb->sym;
75 return aa->
sym - bb->sym;
84 for (
i = 0;
i < 4;
i++)
93 int i, subsampled_height;
94 uint32_t original_format;
96 c->frame_info_size = 4;
114 "4:2:0 video requires even width and height.\n");
125 if (avctx->
width & 1) {
127 "4:2:2 video requires even width.\n");
165 "Slice count %d is not supported in Ut Video (theoretical range is 0-256).\n",
172 if (avctx->
slices > subsampled_height) {
174 "Slice count %d is larger than the subsampling-applied height %d.\n",
175 avctx->
slices, subsampled_height);
190 for (
i = 0;
i <
c->planes;
i++) {
193 if (!
c->slice_buffer[
i]) {
222 c->slices = subsampled_height / 120;
226 else if (
c->slices > 256)
242 c->flags = (
c->slices - 1
U) << 24;
244 c->flags |=
c->compression;
256 int k = 2 * dst_stride;
257 const uint8_t *sg =
src[0];
258 const uint8_t *sb =
src[1];
259 const uint8_t *sr =
src[2];
260 const uint8_t *sa =
src[3];
263 for (j = 0; j <
height; j++) {
269 dst[1][k] = sb[
i] -
g;
270 dst[2][k] = sr[
i] -
g;
278 dst[1][k] = sb[
i] -
g;
279 dst[2][k] = sr[
i] -
g;
285 k += dst_stride -
width;
322 for (j = 1; j <
height; j++) {
331 int height, uint64_t *counts)
335 for (j = 0; j <
height; j++) {
352 while (he[last].
len == 255 && last)
356 for (
i = last;
i >= 0;
i--) {
375 for (j = 0; j <
height; j++) {
396 uint8_t *
dst, ptrdiff_t
stride,
int plane_no,
400 uint8_t lengths[256];
401 uint64_t counts[256] = { 0 };
405 uint32_t
offset = 0, slice_len = 0;
407 int i, sstart, send = 0;
412 switch (
c->frame_pred) {
414 for (
i = 0;
i <
c->slices;
i++) {
416 send =
height * (
i + 1) /
c->slices & cmask;
419 width, send - sstart);
423 for (
i = 0;
i <
c->slices;
i++) {
425 send =
height * (
i + 1) /
c->slices & cmask;
430 for (
i = 0;
i <
c->slices;
i++) {
432 send =
height * (
i + 1) /
c->slices & cmask;
447 for (symbol = 0; symbol < 256; symbol++) {
449 if (counts[symbol]) {
456 for (
i = 0;
i < 256;
i++) {
458 bytestream2_put_byte(pb, 0);
460 bytestream2_put_byte(pb, 0xFF);
464 for (
i = 0;
i <
c->slices;
i++)
465 bytestream2_put_le32(pb, 0);
483 for (
i = 0;
i < 256;
i++) {
484 bytestream2_put_byte(pb, lengths[
i]);
486 he[
i].
len = lengths[
i];
494 for (
i = 0;
i <
c->slices;
i++) {
496 send =
height * (
i + 1) /
c->slices & cmask;
506 slice_len =
offset - slice_len;
509 c->bdsp.bswap_buf((uint32_t *)
c->slice_bits,
510 (uint32_t *)
c->slice_bits,
514 bytestream2_put_le32(pb,
offset);
518 offset - slice_len, SEEK_CUR);
537 const AVFrame *pic,
int *got_packet)
562 if (!
c->slice_bits) {
576 for (
i = 0;
i <
c->planes;
i++) {
578 c->slice_buffer[
i],
c->slice_stride,
i,
588 for (
i = 0;
i <
c->planes;
i++) {
599 for (
i = 0;
i <
c->planes;
i++) {
610 for (
i = 0;
i <
c->planes;
i++) {
632 frame_info =
c->frame_pred << 8;
633 bytestream2_put_le32(&pb, frame_info);
643 #define OFFSET(x) offsetof(UtvideoContext, x)
644 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
AVPixelFormat
Pixel format.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVColorSpace colorspace
YUV colorspace type.
static int put_bytes_output(const PutBitContext *s)
#define u(width, name, range_min, range_max)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
This structure describes decoded (raw) audio or video data.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static void count_usage(uint8_t *src, int width, int height, uint64_t *counts)
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
static const struct @467 planes[]
static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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.
static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size, int width, int height, HuffEntry *he)
AVCodec p
The public AVCodec.
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
#define AVERROR_OPTION_NOT_FOUND
Option not found.
#define FF_CODEC_ENCODE_CB(func)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
static int huff_cmp_sym(const void *a, const void *b)
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
static void mangle_rgb_planes(uint8_t *dst[4], ptrdiff_t dst_stride, uint8_t *const src[4], int planes, const int stride[4], int width, int height)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
const FFCodec ff_utvideo_encoder
#define CODEC_LONG_NAME(str)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
const char * av_default_item_name(void *ptr)
Return the context name.
int ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats, int stats_size, int skip0)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static av_cold int utvideo_encode_init(AVCodecContext *avctx)
av_cold void ff_llvidencdsp_init(LLVidEncDSPContext *c)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static av_cold int utvideo_encode_close(AVCodecContext *avctx)
static int ut_huff_cmp_len(const void *a, const void *b)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static const AVOption options[]
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
static int put_bits_count(PutBitContext *s)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
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...
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
static void median_predict(UtvideoContext *c, const uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_INPUT_BUFFER_PADDING_SIZE
LLVidEncDSPContext llvidencdsp
uint8_t * slice_buffer[4]
main external API structure.
static av_always_inline int bytestream2_seek_p(PutByteContext *p, int offset, int whence)
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static int encode_plane(AVCodecContext *avctx, const uint8_t *src, uint8_t *dst, ptrdiff_t stride, int plane_no, int width, int height, PutByteContext *pb)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
static const AVClass utvideo_class
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int slices
Number of slices.
This structure stores compressed data.
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static void calculate_codes(HuffEntry *he)