FFmpeg  4.0
Data Structures | Macros | Enumerations | Functions | Variables
magicyuvenc.c File Reference
#include <stdlib.h>
#include <string.h>
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/qsort.h"
#include "avcodec.h"
#include "bytestream.h"
#include "put_bits.h"
#include "internal.h"
#include "thread.h"
#include "lossless_videoencdsp.h"

Go to the source code of this file.

Data Structures

struct  HuffEntry
 
struct  PTable
 Used to assign a occurrence count or "probability" to an input value. More...
 
struct  MagicYUVContext
 
struct  PackageMergerList
 Used to store intermediate lists in the package merge algorithm. More...
 

Macros

#define OFFSET(x)   offsetof(MagicYUVContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  Prediction {
  LEFT = 1, GRADIENT, MEDIAN, LEFT = 1,
  GRADIENT, MEDIAN
}
 

Functions

static void left_predict (MagicYUVContext *s, uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
 
static void gradient_predict (MagicYUVContext *s, uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
 
static void median_predict (MagicYUVContext *s, uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
 
static av_cold int magy_encode_init (AVCodecContext *avctx)
 
static int magy_huff_cmp_len (const void *a, const void *b)
 
static int huff_cmp_sym (const void *a, const void *b)
 
static void calculate_codes (HuffEntry *he)
 
static void count_usage (uint8_t *src, int width, int height, PTable *counts)
 
static int compare_by_prob (const void *a, const void *b)
 
static void magy_huffman_compute_bits (PTable *prob_table, HuffEntry *distincts, int size, int max_length)
 
static int encode_table (AVCodecContext *avctx, uint8_t *dst, int width, int height, PutBitContext *pb, HuffEntry *he)
 
static int encode_slice (uint8_t *src, uint8_t *dst, int dst_size, int width, int height, HuffEntry *he, int prediction)
 
static int magy_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static av_cold int magy_encode_close (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass magicyuv_class
 
AVCodec ff_magicyuv_encoder
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(MagicYUVContext, x)

Definition at line 525 of file magicyuvenc.c.

◆ VE

Definition at line 526 of file magicyuvenc.c.

Enumeration Type Documentation

◆ Prediction

enum Prediction
Enumerator
LEFT 
GRADIENT 
MEDIAN 
LEFT 
GRADIENT 
MEDIAN 

Definition at line 36 of file magicyuvenc.c.

Function Documentation

◆ left_predict()

static void left_predict ( MagicYUVContext s,
uint8_t src,
uint8_t dst,
ptrdiff_t  stride,
int  width,
int  height 
)
static

Definition at line 75 of file magicyuvenc.c.

Referenced by magy_encode_init().

◆ gradient_predict()

static void gradient_predict ( MagicYUVContext s,
uint8_t src,
uint8_t dst,
ptrdiff_t  stride,
int  width,
int  height 
)
static

Definition at line 99 of file magicyuvenc.c.

Referenced by magy_encode_init().

◆ median_predict()

static void median_predict ( MagicYUVContext s,
uint8_t src,
uint8_t dst,
ptrdiff_t  stride,
int  width,
int  height 
)
static

Definition at line 127 of file magicyuvenc.c.

Referenced by magy_encode_init().

◆ magy_encode_init()

static av_cold int magy_encode_init ( AVCodecContext avctx)
static

Definition at line 148 of file magicyuvenc.c.

◆ magy_huff_cmp_len()

static int magy_huff_cmp_len ( const void a,
const void b 
)
static

Definition at line 220 of file magicyuvenc.c.

Referenced by calculate_codes().

◆ huff_cmp_sym()

static int huff_cmp_sym ( const void a,
const void b 
)
static

Definition at line 226 of file magicyuvenc.c.

Referenced by calculate_codes().

◆ calculate_codes()

static void calculate_codes ( HuffEntry he)
static

Definition at line 232 of file magicyuvenc.c.

Referenced by encode_table().

◆ count_usage()

static void count_usage ( uint8_t src,
int  width,
int  height,
PTable counts 
)
static

Definition at line 248 of file magicyuvenc.c.

Referenced by encode_table().

◆ compare_by_prob()

static int compare_by_prob ( const void a,
const void b 
)
static

Definition at line 268 of file magicyuvenc.c.

Referenced by magy_huffman_compute_bits().

◆ magy_huffman_compute_bits()

static void magy_huffman_compute_bits ( PTable prob_table,
HuffEntry distincts,
int  size,
int  max_length 
)
static

Definition at line 275 of file magicyuvenc.c.

Referenced by encode_table().

◆ encode_table()

static int encode_table ( AVCodecContext avctx,
uint8_t dst,
int  width,
int  height,
PutBitContext pb,
HuffEntry he 
)
static

Definition at line 336 of file magicyuvenc.c.

Referenced by magy_encode_frame().

◆ encode_slice()

static int encode_slice ( uint8_t src,
uint8_t dst,
int  dst_size,
int  width,
int  height,
HuffEntry he,
int  prediction 
)
static

Definition at line 362 of file magicyuvenc.c.

Referenced by magy_encode_frame().

◆ magy_encode_frame()

static int magy_encode_frame ( AVCodecContext avctx,
AVPacket pkt,
const AVFrame frame,
int got_packet 
)
static

Definition at line 395 of file magicyuvenc.c.

◆ magy_encode_close()

static av_cold int magy_encode_close ( AVCodecContext avctx)
static

Definition at line 514 of file magicyuvenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "pred", "Prediction method", OFFSET(frame_pred), AV_OPT_TYPE_INT, {.i64=LEFT}, LEFT, MEDIAN, VE, "pred" },
{ "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LEFT }, 0, 0, VE, "pred" },
{ "gradient", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = GRADIENT }, 0, 0, VE, "pred" },
{ "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MEDIAN }, 0, 0, VE, "pred" },
{ NULL},
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: magicyuvenc.c:525
#define VE
Definition: magicyuvenc.c:526

Definition at line 527 of file magicyuvenc.c.

◆ magicyuv_class

const AVClass magicyuv_class
static
Initial value:
= {
.class_name = "magicyuv",
.item_name = av_default_item_name,
.option = options,
}
static const AVOption options[]
Definition: magicyuvenc.c:527
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191

Definition at line 535 of file magicyuvenc.c.

◆ ff_magicyuv_encoder

AVCodec ff_magicyuv_encoder
Initial value:
= {
.name = "magicyuv",
.long_name = NULL_IF_CONFIG_SMALL("MagicYUV video"),
.priv_data_size = sizeof(MagicYUVContext),
.priv_class = &magicyuv_class,
.encode2 = magy_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) {
},
}
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:164
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: avcodec.h:1007
#define AV_CODEC_CAP_INTRA_ONLY
Codec is intra only.
Definition: avcodec.h:1045
static av_cold int magy_encode_init(AVCodecContext *avctx)
Definition: magicyuvenc.c:148
static av_cold int magy_encode_close(AVCodecContext *avctx)
Definition: magicyuvenc.c:514
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1015
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: magicyuvenc.c:395
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:173
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
Y , 8bpp.
Definition: pixfmt.h:70
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:211
static const AVClass magicyuv_class
Definition: magicyuvenc.c:535
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60

Definition at line 542 of file magicyuvenc.c.