FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
rpzaenc.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "encode.h"
#include "internal.h"
#include "put_bits.h"

Go to the source code of this file.

Data Structures

struct  RpzaContext
 
struct  rgb
 
struct  BlockInfo
 

Macros

#define SQR(x)   ((x) * (x))
 
#define GET_CHAN(color, chan)   (((color) >> ((chan) * 5) & 0x1F) * 8)
 
#define R(color)   GET_CHAN(color, RED)
 
#define G(color)   GET_CHAN(color, GREEN)
 
#define B(color)   GET_CHAN(color, BLUE)
 
#define OFFSET(x)   offsetof(RpzaContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  channel_offset { RED = 2, GREEN = 1, BLUE = 0 }
 

Functions

static void get_colors (uint8_t *min, uint8_t *max, uint8_t color4[4][3])
 
static int get_block_info (BlockInfo *bi, int block)
 
static uint16_t rgb24_to_rgb555 (uint8_t *rgb24)
 
static int diff_colors (uint8_t *colorA, uint8_t *colorB)
 
static int max_component_diff (uint16_t *colorA, uint16_t *colorB)
 
static void get_max_component_diff (BlockInfo *bi, uint16_t *block_ptr, uint8_t *min, uint8_t *max, channel_offset *chan)
 
static int compare_blocks (uint16_t *block1, uint16_t *block2, BlockInfo *bi, int thresh)
 
static int leastsquares (uint16_t *block_ptr, BlockInfo *bi, channel_offset xchannel, channel_offset ychannel, double *slope, double *y_intercept, double *correlation_coef)
 
static int calc_lsq_max_fit_error (uint16_t *block_ptr, BlockInfo *bi, int min, int max, int tmp_min, int tmp_max, channel_offset xchannel, channel_offset ychannel)
 
static int match_color (uint16_t *color, uint8_t colors[4][3])
 
static int encode_four_color_block (uint8_t *min_color, uint8_t *max_color, PutBitContext *pb, uint16_t *block_ptr, BlockInfo *bi)
 
static void update_block_in_prev_frame (const uint16_t *src_pixels, uint16_t *dest_pixels, const BlockInfo *bi, int block_counter)
 
static int update_block_stats (RpzaContext *s, BlockInfo *bi, uint16_t *block, uint8_t min_color[3], uint8_t max_color[3], int *total_rgb, int *total_pixels, uint8_t avg_color[3], int first_block)
 
static void rpza_encode_stream (RpzaContext *s, const AVFrame *pict)
 
static int rpza_encode_init (AVCodecContext *avctx)
 
static int rpza_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static int rpza_encode_end (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass rpza_class
 
const AVCodec ff_rpza_encoder
 

Detailed Description

QT RPZA Video Encoder by Todd Kirby doubl.nosp@m.esho.nosp@m.t@pac.nosp@m.bell.nosp@m..net and David Adler

Definition in file rpzaenc.c.

Macro Definition Documentation

◆ SQR

#define SQR (   x)    ((x) * (x))

Definition at line 65 of file rpzaenc.c.

◆ GET_CHAN

#define GET_CHAN (   color,
  chan 
)    (((color) >> ((chan) * 5) & 0x1F) * 8)

Definition at line 68 of file rpzaenc.c.

◆ R

#define R (   color)    GET_CHAN(color, RED)

Definition at line 69 of file rpzaenc.c.

◆ G

#define G (   color)    GET_CHAN(color, GREEN)

Definition at line 70 of file rpzaenc.c.

◆ B

#define B (   color)    GET_CHAN(color, BLUE)

Definition at line 71 of file rpzaenc.c.

◆ OFFSET

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

Definition at line 829 of file rpzaenc.c.

◆ VE

Definition at line 830 of file rpzaenc.c.

Enumeration Type Documentation

◆ channel_offset

Enumerator
RED 
GREEN 
BLUE 

Definition at line 53 of file rpzaenc.c.

Function Documentation

◆ get_colors()

static void get_colors ( uint8_t *  min,
uint8_t *  max,
uint8_t  color4[4][3] 
)
static

Definition at line 87 of file rpzaenc.c.

Referenced by encode_four_color_block().

◆ get_block_info()

static int get_block_info ( BlockInfo bi,
int  block 
)
static

Definition at line 116 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ rgb24_to_rgb555()

static uint16_t rgb24_to_rgb555 ( uint8_t *  rgb24)
static

Definition at line 138 of file rpzaenc.c.

Referenced by encode_four_color_block(), and rpza_encode_stream().

◆ diff_colors()

static int diff_colors ( uint8_t *  colorA,
uint8_t *  colorB 
)
static

Definition at line 157 of file rpzaenc.c.

Referenced by match_color().

◆ max_component_diff()

static int max_component_diff ( uint16_t *  colorA,
uint16_t *  colorB 
)
static

Definition at line 171 of file rpzaenc.c.

Referenced by compare_blocks().

◆ get_max_component_diff()

static void get_max_component_diff ( BlockInfo bi,
uint16_t *  block_ptr,
uint8_t *  min,
uint8_t *  max,
channel_offset chan 
)
static

Definition at line 195 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ compare_blocks()

static int compare_blocks ( uint16_t *  block1,
uint16_t *  block2,
BlockInfo bi,
int  thresh 
)
static

Definition at line 245 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ leastsquares()

static int leastsquares ( uint16_t *  block_ptr,
BlockInfo bi,
channel_offset  xchannel,
channel_offset  ychannel,
double *  slope,
double *  y_intercept,
double *  correlation_coef 
)
static

Definition at line 265 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ calc_lsq_max_fit_error()

static int calc_lsq_max_fit_error ( uint16_t *  block_ptr,
BlockInfo bi,
int  min,
int  max,
int  tmp_min,
int  tmp_max,
channel_offset  xchannel,
channel_offset  ychannel 
)
static

Definition at line 318 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ match_color()

static int match_color ( uint16_t *  color,
uint8_t  colors[4][3] 
)
static

Definition at line 359 of file rpzaenc.c.

Referenced by encode_four_color_block().

◆ encode_four_color_block()

static int encode_four_color_block ( uint8_t *  min_color,
uint8_t *  max_color,
PutBitContext pb,
uint16_t *  block_ptr,
BlockInfo bi 
)
static

Definition at line 386 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ update_block_in_prev_frame()

static void update_block_in_prev_frame ( const uint16_t *  src_pixels,
uint16_t *  dest_pixels,
const BlockInfo bi,
int  block_counter 
)
static

Definition at line 418 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ update_block_stats()

static int update_block_stats ( RpzaContext s,
BlockInfo bi,
uint16_t *  block,
uint8_t  min_color[3],
uint8_t  max_color[3],
int total_rgb,
int total_pixels,
uint8_t  avg_color[3],
int  first_block 
)
static

Definition at line 444 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ rpza_encode_stream()

static void rpza_encode_stream ( RpzaContext s,
const AVFrame pict 
)
static

Definition at line 548 of file rpzaenc.c.

Referenced by rpza_encode_frame().

◆ rpza_encode_init()

static int rpza_encode_init ( AVCodecContext avctx)
static

Definition at line 760 of file rpzaenc.c.

◆ rpza_encode_frame()

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

Definition at line 774 of file rpzaenc.c.

◆ rpza_encode_end()

static int rpza_encode_end ( AVCodecContext avctx)
static

Definition at line 820 of file rpzaenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "skip_frame_thresh", NULL, OFFSET(skip_frame_thresh), AV_OPT_TYPE_INT, {.i64=1}, 0, 24, VE},
{ "start_one_color_thresh", NULL, OFFSET(start_one_color_thresh), AV_OPT_TYPE_INT, {.i64=1}, 0, 24, VE},
{ "continue_one_color_thresh", NULL, OFFSET(continue_one_color_thresh), AV_OPT_TYPE_INT, {.i64=0}, 0, 24, VE},
{ "sixteen_color_thresh", NULL, OFFSET(sixteen_color_thresh), AV_OPT_TYPE_INT, {.i64=1}, 0, 24, VE},
{ NULL },
}

Definition at line 831 of file rpzaenc.c.

◆ rpza_class

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

Definition at line 839 of file rpzaenc.c.

◆ ff_rpza_encoder

const AVCodec ff_rpza_encoder
Initial value:
= {
.name = "rpza",
.long_name = NULL_IF_CONFIG_SMALL("QuickTime video (RPZA)"),
.priv_data_size = sizeof(RpzaContext),
.priv_class = &rpza_class,
.encode2 = rpza_encode_frame,
.close = rpza_encode_end,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}

Definition at line 846 of file rpzaenc.c.

OFFSET
#define OFFSET(x)
Definition: rpzaenc.c:829
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:42
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
RpzaContext
Definition: rpza.c:47
init
static int init
Definition: av_tx.c:47
rpza_encode_end
static int rpza_encode_end(AVCodecContext *avctx)
Definition: rpzaenc.c:820
rpza_encode_init
static int rpza_encode_init(AVCodecContext *avctx)
Definition: rpzaenc.c:760
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
rpza_class
static const AVClass rpza_class
Definition: rpzaenc.c:839
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
VE
#define VE
Definition: rpzaenc.c:830
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
AV_PIX_FMT_RGB555
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:392
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
options
static const AVOption options[]
Definition: rpzaenc.c:831
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_CODEC_ID_RPZA
@ AV_CODEC_ID_RPZA
Definition: codec_id.h:92
rpza_encode_frame
static int rpza_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: rpzaenc.c:774