FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
rpzaenc.c File Reference

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

#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "avcodec.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
 
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

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

Definition at line 64 of file rpzaenc.c.

Referenced by diff_colors().

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

Definition at line 67 of file rpzaenc.c.

Referenced by calc_lsq_max_fit_error(), leastsquares(), match_color(), and rpza_encode_stream().

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

Definition at line 68 of file rpzaenc.c.

Referenced by get_max_component_diff(), max_component_diff(), and update_block_stats().

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

Definition at line 69 of file rpzaenc.c.

Referenced by get_max_component_diff(), max_component_diff(), and update_block_stats().

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

Definition at line 70 of file rpzaenc.c.

Referenced by get_max_component_diff(), max_component_diff(), and update_block_stats().

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

Definition at line 828 of file rpzaenc.c.

Definition at line 829 of file rpzaenc.c.

Enumeration Type Documentation

Enumerator
RED 
GREEN 
BLUE 

Definition at line 52 of file rpzaenc.c.

Function Documentation

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

Definition at line 86 of file rpzaenc.c.

Referenced by encode_four_color_block().

static int get_block_info ( BlockInfo bi,
int  block 
)
static

Definition at line 115 of file rpzaenc.c.

Referenced by rpza_encode_stream().

static uint16_t rgb24_to_rgb555 ( uint8_t rgb24)
static

Definition at line 137 of file rpzaenc.c.

Referenced by encode_four_color_block(), and rpza_encode_stream().

static int diff_colors ( uint8_t colorA,
uint8_t colorB 
)
static

Definition at line 156 of file rpzaenc.c.

Referenced by match_color().

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

Definition at line 170 of file rpzaenc.c.

Referenced by compare_blocks().

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 194 of file rpzaenc.c.

Referenced by rpza_encode_stream().

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

Definition at line 244 of file rpzaenc.c.

Referenced by rpza_encode_stream().

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 264 of file rpzaenc.c.

Referenced by rpza_encode_stream().

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 317 of file rpzaenc.c.

Referenced by rpza_encode_stream().

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

Definition at line 358 of file rpzaenc.c.

Referenced by 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 385 of file rpzaenc.c.

Referenced by rpza_encode_stream().

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 417 of file rpzaenc.c.

Referenced by rpza_encode_stream().

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 443 of file rpzaenc.c.

Referenced by rpza_encode_stream().

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

Definition at line 547 of file rpzaenc.c.

Referenced by rpza_encode_frame().

static int rpza_encode_init ( AVCodecContext avctx)
static

Definition at line 759 of file rpzaenc.c.

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

Definition at line 773 of file rpzaenc.c.

static int rpza_encode_end ( AVCodecContext avctx)
static

Definition at line 819 of file rpzaenc.c.

Variable Documentation

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 },
}
#define NULL
Definition: coverity.c:32
#define VE
Definition: rpzaenc.c:829
#define OFFSET(x)
Definition: rpzaenc.c:828

Definition at line 830 of file rpzaenc.c.

const AVClass rpza_class
static
Initial value:
= {
.class_name = "rpza",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
static const AVOption options[]
Definition: rpzaenc.c:830

Definition at line 838 of file rpzaenc.c.

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,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#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:40
static int rpza_encode_init(AVCodecContext *avctx)
Definition: rpzaenc.c:759
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:153
static int rpza_encode_end(AVCodecContext *avctx)
Definition: rpzaenc.c:819
static const AVClass rpza_class
Definition: rpzaenc.c:838
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:300
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:387
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
static int rpza_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: rpzaenc.c:773

Definition at line 845 of file rpzaenc.c.