46 #if FF_API_PRIVATE_OPT
56 return (aa->
len - bb->len)*256 + aa->
sym - bb->sym;
63 return aa->
sym - bb->sym;
72 for (
i = 0;
i < 4;
i++)
81 int i, subsampled_height;
82 uint32_t original_format;
85 c->frame_info_size = 4;
103 "4:2:0 video requires even width and height.\n");
114 if (avctx->
width & 1) {
116 "4:2:2 video requires even width.\n");
143 #if FF_API_PRIVATE_OPT
148 "Prediction method %d is not supported in Ut Video.\n",
155 "Plane prediction is not supported in Ut Video.\n");
176 "Slice count %d is not supported in Ut Video (theoretical range is 0-256).\n",
183 if (avctx->
slices > subsampled_height) {
185 "Slice count %d is larger than the subsampling-applied height %d.\n",
186 avctx->
slices, subsampled_height);
202 for (
i = 0;
i <
c->planes;
i++) {
205 if (!
c->slice_buffer[
i]) {
235 c->slices = subsampled_height / 120;
239 else if (
c->slices > 256)
255 c->flags = (
c->slices - 1U) << 24;
257 c->flags |=
c->compression;
269 int k = 2 * dst_stride;
276 for (j = 0; j <
height; j++) {
282 dst[1][k] = sb[
i] -
g;
283 dst[2][k] = sr[
i] -
g;
291 dst[1][k] = sb[
i] -
g;
292 dst[2][k] = sr[
i] -
g;
298 k += dst_stride -
width;
319 *dst++ =
src[
i] - prev;
335 for (j = 1; j <
height; j++) {
344 int height, uint64_t *counts)
348 for (j = 0; j <
height; j++) {
365 while (he[last].
len == 255 && last)
369 for (
i = last;
i >= 0;
i--) {
371 code += 0x80000000u >> (he[
i].
len - 1);
388 for (j = 0; j <
height; j++) {
416 uint64_t counts[256] = { 0 };
420 uint32_t
offset = 0, slice_len = 0;
422 int i, sstart, send = 0;
427 switch (
c->frame_pred) {
429 for (
i = 0;
i <
c->slices;
i++) {
431 send =
height * (
i + 1) /
c->slices & cmask;
434 width, send - sstart);
438 for (
i = 0;
i <
c->slices;
i++) {
440 send =
height * (
i + 1) /
c->slices & cmask;
445 for (
i = 0;
i <
c->slices;
i++) {
447 send =
height * (
i + 1) /
c->slices & cmask;
462 for (symbol = 0; symbol < 256; symbol++) {
464 if (counts[symbol]) {
471 for (
i = 0;
i < 256;
i++) {
473 bytestream2_put_byte(pb, 0);
475 bytestream2_put_byte(pb, 0xFF);
479 for (
i = 0;
i <
c->slices;
i++)
480 bytestream2_put_le32(pb, 0);
498 for (
i = 0;
i < 256;
i++) {
499 bytestream2_put_byte(pb, lengths[
i]);
501 he[
i].
len = lengths[
i];
509 for (
i = 0;
i <
c->slices;
i++) {
511 send =
height * (
i + 1) /
c->slices & cmask;
519 send - sstart, he) >> 3;
521 slice_len =
offset - slice_len;
524 c->bdsp.bswap_buf((uint32_t *)
c->slice_bits,
525 (uint32_t *)
c->slice_bits,
529 bytestream2_put_le32(pb,
offset);
533 offset - slice_len, SEEK_CUR);
552 const AVFrame *pic,
int *got_packet)
577 if (!
c->slice_bits) {
591 for (
i = 0;
i <
c->planes;
i++) {
593 c->slice_buffer[
i],
c->slice_stride,
i,
603 for (
i = 0;
i <
c->planes;
i++) {
614 for (
i = 0;
i <
c->planes;
i++) {
625 for (
i = 0;
i <
c->planes;
i++) {
647 frame_info =
c->frame_pred << 8;
648 bytestream2_put_le32(&pb, frame_info);
654 #if FF_API_CODED_FRAME
670 #define OFFSET(x) offsetof(UtvideoContext, x)
671 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
static av_always_inline int bytestream2_seek_p(PutByteContext *p, int offset, int whence)
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
#define MKTAG(a, b, c, d)
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
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...
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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.
@ AV_PICTURE_TYPE_I
Intra.
#define LIBAVUTIL_VERSION_INT
int ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats, int stats_size, int skip0)
huffman tree builder and VLC generator
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
static enum AVPixelFormat pix_fmts[]
static const struct @322 planes[]
av_cold void ff_llvidencdsp_init(LLVidEncDSPContext *c)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static int put_bits_count(PutBitContext *s)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
enum AVColorSpace colorspace
YUV colorspace type.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
attribute_deprecated int prediction_method
int slices
Number of slices.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int key_frame
1 -> keyframe, 0-> not
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
int flags
A combination of AV_PKT_FLAG values.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVCodec ff_utvideo_encoder
static void calculate_codes(HuffEntry *he)
static const AVOption options[]
static int huff_cmp_sym(const void *a, const void *b)
static int encode_plane(AVCodecContext *avctx, uint8_t *src, uint8_t *dst, ptrdiff_t stride, int plane_no, int width, int height, PutByteContext *pb)
static void count_usage(uint8_t *src, int width, int height, uint64_t *counts)
static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet)
static const AVClass utvideo_class
static void median_predict(UtvideoContext *c, uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
static av_cold int utvideo_encode_close(AVCodecContext *avctx)
static const int ut_pred_order[5]
static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size, int width, int height, HuffEntry *he)
static int ut_huff_cmp_len(const void *a, const void *b)
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)
static av_cold int utvideo_encode_init(AVCodecContext *avctx)
static const uint8_t offset[127][2]