FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
cinepakenc.c File Reference
#include <string.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/lfg.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "elbg.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  mb_info
 
struct  strip_info
 
struct  CinepakEncContext
 

Macros

#define CVID_HEADER_SIZE   10
 
#define STRIP_HEADER_SIZE   12
 
#define CHUNK_HEADER_SIZE   4
 
#define MB_SIZE   4
 
#define MB_AREA   (MB_SIZE * MB_SIZE)
 
#define VECTOR_MAX   6
 
#define CODEBOOK_MAX   256
 
#define MAX_STRIPS   32
 
#define MIN_STRIPS   1
 
#define OFFSET(x)   offsetof(CinepakEncContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
#define CERTAIN(x)   ((x) != ENC_UNCERTAIN)
 
#define SMALLEST_CODEBOOK   1
 

Enumerations

enum  CinepakMode { MODE_V1_ONLY = 0, MODE_V1_V4, MODE_MC, MODE_COUNT }
 
enum  mb_encoding { ENC_V1, ENC_V4, ENC_SKIP, ENC_UNCERTAIN }
 

Functions

static av_cold int cinepak_encode_init (AVCodecContext *avctx)
 
static int64_t calculate_mode_score (CinepakEncContext *s, int h, strip_info *info, int report, int *training_set_v1_shrunk, int *training_set_v4_shrunk)
 
static int write_chunk_header (unsigned char *buf, int chunk_type, int chunk_size)
 
static int encode_codebook (CinepakEncContext *s, int *codebook, int size, int chunk_type_yuv, int chunk_type_gray, unsigned char *buf)
 
static void get_sub_picture (CinepakEncContext *s, int x, int y, uint8_t *in_data[4], int in_linesize[4], uint8_t *out_data[4], int out_linesize[4])
 
static void decode_v1_vector (CinepakEncContext *s, uint8_t *data[4], int linesize[4], int v1_vector, strip_info *info)
 
static void decode_v4_vector (CinepakEncContext *s, uint8_t *data[4], int linesize[4], int *v4_vector, strip_info *info)
 
static void copy_mb (CinepakEncContext *s, uint8_t *a_data[4], int a_linesize[4], uint8_t *b_data[4], int b_linesize[4])
 
static int encode_mode (CinepakEncContext *s, int h, uint8_t *scratch_data[4], int scratch_linesize[4], uint8_t *last_data[4], int last_linesize[4], strip_info *info, unsigned char *buf)
 
static int compute_mb_distortion (CinepakEncContext *s, uint8_t *a_data[4], int a_linesize[4], uint8_t *b_data[4], int b_linesize[4])
 
static int quantize (CinepakEncContext *s, int h, uint8_t *data[4], int linesize[4], int v1mode, strip_info *info, mb_encoding encoding)
 
static void calculate_skip_errors (CinepakEncContext *s, int h, uint8_t *last_data[4], int last_linesize[4], uint8_t *data[4], int linesize[4], strip_info *info)
 
static void write_strip_header (CinepakEncContext *s, int y, int h, int keyframe, unsigned char *buf, int strip_size)
 
static int rd_strip (CinepakEncContext *s, int y, int h, int keyframe, uint8_t *last_data[4], int last_linesize[4], uint8_t *data[4], int linesize[4], uint8_t *scratch_data[4], int scratch_linesize[4], unsigned char *buf, int64_t *best_score)
 
static int write_cvid_header (CinepakEncContext *s, unsigned char *buf, int num_strips, int data_size, int isakeyframe)
 
static int rd_frame (CinepakEncContext *s, const AVFrame *frame, int isakeyframe, unsigned char *buf, int buf_size)
 
static int cinepak_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static av_cold int cinepak_encode_end (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass cinepak_class
 
AVCodec ff_cinepak_encoder
 

Macro Definition Documentation

#define CVID_HEADER_SIZE   10

Definition at line 50 of file cinepakenc.c.

Referenced by cinepak_encode_init(), rd_frame(), and write_cvid_header().

#define STRIP_HEADER_SIZE   12

Definition at line 51 of file cinepakenc.c.

Referenced by cinepak_encode_init(), rd_strip(), and write_strip_header().

#define CHUNK_HEADER_SIZE   4
#define MB_SIZE   4
#define MB_AREA   (MB_SIZE * MB_SIZE)

Definition at line 55 of file cinepakenc.c.

Referenced by calculate_mode_score(), cinepak_encode_init(), encode_mode(), and quantize().

#define VECTOR_MAX   6

Definition at line 57 of file cinepakenc.c.

Referenced by cinepak_encode_init().

#define CODEBOOK_MAX   256

Definition at line 58 of file cinepakenc.c.

Referenced by cinepak_encode_init(), and rd_strip().

#define MAX_STRIPS   32

Definition at line 60 of file cinepakenc.c.

#define MIN_STRIPS   1

Definition at line 61 of file cinepakenc.c.

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

Definition at line 131 of file cinepakenc.c.

Definition at line 132 of file cinepakenc.c.

#define CERTAIN (   x)    ((x) != ENC_UNCERTAIN)

Definition at line 713 of file cinepakenc.c.

Referenced by quantize().

#define SMALLEST_CODEBOOK   1

Referenced by rd_strip().

Enumeration Type Documentation

Enumerator
MODE_V1_ONLY 
MODE_V1_V4 
MODE_MC 
MODE_COUNT 

Definition at line 71 of file cinepakenc.c.

Enumerator
ENC_V1 
ENC_V4 
ENC_SKIP 
ENC_UNCERTAIN 

Definition at line 79 of file cinepakenc.c.

Function Documentation

static av_cold int cinepak_encode_init ( AVCodecContext avctx)
static

Definition at line 154 of file cinepakenc.c.

static int64_t calculate_mode_score ( CinepakEncContext s,
int  h,
strip_info info,
int  report,
int training_set_v1_shrunk,
int training_set_v4_shrunk 
)
static

Definition at line 274 of file cinepakenc.c.

Referenced by rd_strip().

static int write_chunk_header ( unsigned char *  buf,
int  chunk_type,
int  chunk_size 
)
static

Definition at line 392 of file cinepakenc.c.

Referenced by encode_codebook(), and encode_mode().

static int encode_codebook ( CinepakEncContext s,
int codebook,
int  size,
int  chunk_type_yuv,
int  chunk_type_gray,
unsigned char *  buf 
)
static

Definition at line 399 of file cinepakenc.c.

Referenced by encode_mode().

static void get_sub_picture ( CinepakEncContext s,
int  x,
int  y,
uint8_t in_data[4],
int  in_linesize[4],
uint8_t out_data[4],
int  out_linesize[4] 
)
static

Definition at line 447 of file cinepakenc.c.

Referenced by calculate_skip_errors(), encode_mode(), quantize(), and rd_frame().

static void decode_v1_vector ( CinepakEncContext s,
uint8_t data[4],
int  linesize[4],
int  v1_vector,
strip_info info 
)
static

Definition at line 464 of file cinepakenc.c.

Referenced by encode_mode(), and quantize().

static void decode_v4_vector ( CinepakEncContext s,
uint8_t data[4],
int  linesize[4],
int v4_vector,
strip_info info 
)
static

Definition at line 503 of file cinepakenc.c.

Referenced by encode_mode(), and quantize().

static void copy_mb ( CinepakEncContext s,
uint8_t a_data[4],
int  a_linesize[4],
uint8_t b_data[4],
int  b_linesize[4] 
)
static

Definition at line 523 of file cinepakenc.c.

Referenced by encode_mode(), and mjpeg_decode_scan().

static int encode_mode ( CinepakEncContext s,
int  h,
uint8_t scratch_data[4],
int  scratch_linesize[4],
uint8_t last_data[4],
int  last_linesize[4],
strip_info info,
unsigned char *  buf 
)
static

Definition at line 542 of file cinepakenc.c.

Referenced by rd_strip().

static int compute_mb_distortion ( CinepakEncContext s,
uint8_t a_data[4],
int  a_linesize[4],
uint8_t b_data[4],
int  b_linesize[4] 
)
static

Definition at line 687 of file cinepakenc.c.

Referenced by calculate_skip_errors(), and quantize().

static int quantize ( CinepakEncContext s,
int  h,
uint8_t data[4],
int  linesize[4],
int  v1mode,
strip_info info,
mb_encoding  encoding 
)
static

Definition at line 714 of file cinepakenc.c.

Referenced by rd_strip().

static void calculate_skip_errors ( CinepakEncContext s,
int  h,
uint8_t last_data[4],
int  last_linesize[4],
uint8_t data[4],
int  linesize[4],
strip_info info 
)
static

Definition at line 829 of file cinepakenc.c.

Referenced by rd_strip().

static void write_strip_header ( CinepakEncContext s,
int  y,
int  h,
int  keyframe,
unsigned char *  buf,
int  strip_size 
)
static

Definition at line 852 of file cinepakenc.c.

Referenced by rd_strip().

static int rd_strip ( CinepakEncContext s,
int  y,
int  h,
int  keyframe,
uint8_t last_data[4],
int  last_linesize[4],
uint8_t data[4],
int  linesize[4],
uint8_t scratch_data[4],
int  scratch_linesize[4],
unsigned char *  buf,
int64_t *  best_score 
)
static

Definition at line 870 of file cinepakenc.c.

Referenced by rd_frame().

static int write_cvid_header ( CinepakEncContext s,
unsigned char *  buf,
int  num_strips,
int  data_size,
int  isakeyframe 
)
static

Definition at line 990 of file cinepakenc.c.

Referenced by rd_frame().

static int rd_frame ( CinepakEncContext s,
const AVFrame frame,
int  isakeyframe,
unsigned char *  buf,
int  buf_size 
)
static

Definition at line 1002 of file cinepakenc.c.

Referenced by cinepak_encode_frame().

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

Definition at line 1151 of file cinepakenc.c.

static av_cold int cinepak_encode_end ( AVCodecContext avctx)
static

Definition at line 1175 of file cinepakenc.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "max_extra_cb_iterations", "Max extra codebook recalculation passes, more is better and slower",
OFFSET(max_extra_cb_iterations), AV_OPT_TYPE_INT, { .i64 = 2 }, 0, INT_MAX, VE },
{ "skip_empty_cb", "Avoid wasting bytes, ignore vintage MacOS decoder",
OFFSET(skip_empty_cb), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "max_strips", "Limit strips/frame, vintage compatible is 1..3, otherwise the more the better",
OFFSET(max_max_strips), AV_OPT_TYPE_INT, { .i64 = 3 }, MIN_STRIPS, MAX_STRIPS, VE },
{ "min_strips", "Enforce min strips/frame, more is worse and faster, must be <= max_strips",
OFFSET(min_min_strips), AV_OPT_TYPE_INT, { .i64 = MIN_STRIPS }, MIN_STRIPS, MAX_STRIPS, VE },
{ "strip_number_adaptivity", "How fast the strip number adapts, more is slightly better, much slower",
OFFSET(strip_number_delta_range), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_STRIPS - MIN_STRIPS, VE },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define MIN_STRIPS
Definition: cinepakenc.c:61
#define VE
Definition: cinepakenc.c:132
#define MAX_STRIPS
Definition: cinepakenc.c:60
#define OFFSET(x)
Definition: cinepakenc.c:131

Definition at line 133 of file cinepakenc.c.

const AVClass cinepak_class
static
Initial value:
= {
.class_name = "cinepak",
.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:193
static const AVOption options[]
Definition: cinepakenc.c:133

Definition at line 147 of file cinepakenc.c.

AVCodec ff_cinepak_encoder
Initial value:
= {
.name = "cinepak",
.long_name = NULL_IF_CONFIG_SMALL("Cinepak"),
.priv_data_size = sizeof(CinepakEncContext),
.priv_class = &cinepak_class,
}
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:64
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static int cinepak_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: cinepakenc.c:1151
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static av_cold int cinepak_encode_init(AVCodecContext *avctx)
Definition: cinepakenc.c:154
static const AVClass cinepak_class
Definition: cinepakenc.c:147
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
Y , 8bpp.
Definition: pixfmt.h:70
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
static av_cold int cinepak_encode_end(AVCodecContext *avctx)
Definition: cinepakenc.c:1175

Definition at line 1197 of file cinepakenc.c.