FFmpeg
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 void calculate_codes (HuffEntry *he, uint16_t codes_count[33])
 
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, uint16_t codes_counts[33], 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
 
const AVCodec ff_magicyuv_encoder
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 542 of file magicyuvenc.c.

◆ VE

Definition at line 543 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 73 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 97 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 125 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 146 of file magicyuvenc.c.

◆ calculate_codes()

static void calculate_codes ( HuffEntry he,
uint16_t  codes_count[33] 
)
static

Definition at line 247 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 261 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 281 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,
uint16_t  codes_counts[33],
int  size,
int  max_length 
)
static

Definition at line 288 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 350 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 377 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 408 of file magicyuvenc.c.

◆ magy_encode_close()

static av_cold int magy_encode_close ( AVCodecContext avctx)
static

Definition at line 531 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},
}

Definition at line 544 of file magicyuvenc.c.

◆ magicyuv_class

const AVClass magicyuv_class
static
Initial value:
= {
.class_name = "magicyuv",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 552 of file magicyuvenc.c.

◆ ff_magicyuv_encoder

const AVCodec ff_magicyuv_encoder
Initial value:

Definition at line 559 of file magicyuvenc.c.

GRADIENT
@ GRADIENT
Definition: magicyuvenc.c:38
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:41
VE
#define VE
Definition: magicyuvenc.c:543
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
MagicYUVContext
Definition: magicyuv.c:53
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
magy_encode_frame
static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: magicyuvenc.c:408
magicyuv_class
static const AVClass magicyuv_class
Definition: magicyuvenc.c:552
OFFSET
#define OFFSET(x)
Definition: magicyuvenc.c:542
MEDIAN
@ MEDIAN
Definition: magicyuvenc.c:39
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:289
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:108
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_CODEC_ID_MAGICYUV
@ AV_CODEC_ID_MAGICYUV
Definition: codec_id.h:268
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
options
static const AVOption options[]
Definition: magicyuvenc.c:544
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
magy_encode_close
static av_cold int magy_encode_close(AVCodecContext *avctx)
Definition: magicyuvenc.c:531
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:49
LEFT
@ LEFT
Definition: magicyuvenc.c:37
magy_encode_init
static av_cold int magy_encode_init(AVCodecContext *avctx)
Definition: magicyuvenc.c:146
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234