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 "codec_internal.h"
#include "encode.h"
#include "mathops.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))
 
#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 (const uint8_t *min, const uint8_t *max, uint8_t color4[4][3])
 
static int get_block_info (BlockInfo *bi, int block, int prev_frame)
 
static uint16_t rgb24_to_rgb555 (const uint8_t *rgb24)
 
static int diff_colors (const uint8_t *colorA, const uint8_t *colorB)
 
static int max_component_diff (const uint16_t *colorA, const uint16_t *colorB)
 
static void get_max_component_diff (const BlockInfo *bi, const uint16_t *block_ptr, uint8_t *min, uint8_t *max, channel_offset *chan)
 
static int compare_blocks (const uint16_t *block1, const uint16_t *block2, const BlockInfo *bi, int thresh)
 
static int leastsquares (const uint16_t *block_ptr, const BlockInfo *bi, channel_offset xchannel, channel_offset ychannel, int *slope, int *y_intercept, int *correlation_coef)
 
static int calc_lsq_max_fit_error (const uint16_t *block_ptr, const BlockInfo *bi, int min, int max, int tmp_min, int tmp_max, channel_offset xchannel, channel_offset ychannel)
 
static int match_color (const uint16_t *color, uint8_t colors[4][3])
 
static int encode_four_color_block (const uint8_t *min_color, const uint8_t *max_color, PutBitContext *pb, const uint16_t *block_ptr, const 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, const BlockInfo *bi, const 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 *pict, int *got_packet)
 
static int rpza_encode_end (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass rpza_class
 
const FFCodec 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 66 of file rpzaenc.c.

◆ GET_CHAN

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

Definition at line 69 of file rpzaenc.c.

◆ R

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

Definition at line 70 of file rpzaenc.c.

◆ G

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

Definition at line 71 of file rpzaenc.c.

◆ B

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

Definition at line 72 of file rpzaenc.c.

◆ OFFSET

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

Definition at line 859 of file rpzaenc.c.

◆ VE

Definition at line 860 of file rpzaenc.c.

Enumeration Type Documentation

◆ channel_offset

Enumerator
RED 
GREEN 
BLUE 

Definition at line 54 of file rpzaenc.c.

Function Documentation

◆ get_colors()

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

Definition at line 89 of file rpzaenc.c.

Referenced by encode_four_color_block().

◆ get_block_info()

static int get_block_info ( BlockInfo bi,
int  block,
int  prev_frame 
)
static

Definition at line 118 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ rgb24_to_rgb555()

static uint16_t rgb24_to_rgb555 ( const uint8_t *  rgb24)
static

Definition at line 140 of file rpzaenc.c.

Referenced by encode_four_color_block(), and rpza_encode_stream().

◆ diff_colors()

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

Definition at line 159 of file rpzaenc.c.

Referenced by match_color().

◆ max_component_diff()

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

Definition at line 173 of file rpzaenc.c.

Referenced by compare_blocks().

◆ get_max_component_diff()

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

Definition at line 197 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ compare_blocks()

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

Definition at line 247 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ leastsquares()

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

Definition at line 268 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ calc_lsq_max_fit_error()

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

Definition at line 321 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ match_color()

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

Definition at line 362 of file rpzaenc.c.

Referenced by encode_four_color_block().

◆ encode_four_color_block()

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

Definition at line 389 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 431 of file rpzaenc.c.

Referenced by rpza_encode_stream().

◆ update_block_stats()

static int update_block_stats ( RpzaContext s,
const BlockInfo bi,
const 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 460 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 564 of file rpzaenc.c.

Referenced by rpza_encode_frame().

◆ rpza_encode_init()

static int rpza_encode_init ( AVCodecContext avctx)
static

Definition at line 791 of file rpzaenc.c.

◆ rpza_encode_frame()

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

Definition at line 805 of file rpzaenc.c.

◆ rpza_encode_end()

static int rpza_encode_end ( AVCodecContext avctx)
static

Definition at line 850 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 861 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 869 of file rpzaenc.c.

◆ ff_rpza_encoder

const FFCodec ff_rpza_encoder
Initial value:
= {
.p.name = "rpza",
CODEC_LONG_NAME("QuickTime video (RPZA)"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(RpzaContext),
.p.priv_class = &rpza_class,
.close = rpza_encode_end,
.p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB555,
}

Definition at line 876 of file rpzaenc.c.

OFFSET
#define OFFSET(x)
Definition: rpzaenc.c:859
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
RpzaContext
Definition: rpza.c:45
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:320
rpza_encode_end
static int rpza_encode_end(AVCodecContext *avctx)
Definition: rpzaenc.c:850
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
rpza_encode_init
static int rpza_encode_init(AVCodecContext *avctx)
Definition: rpzaenc.c:791
rpza_encode_frame
static int rpza_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: rpzaenc.c:805
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h: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:869
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
VE
#define VE
Definition: rpzaenc.c:860
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_PIX_FMT_RGB555
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:475
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
options
static const AVOption options[]
Definition: rpzaenc.c:861
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_CODEC_ID_RPZA
@ AV_CODEC_ID_RPZA
Definition: codec_id.h:94