82 #define CVID_HEADER_SIZE 10 
   83 #define STRIP_HEADER_SIZE 12 
   84 #define CHUNK_HEADER_SIZE 4 
   86 #define MB_SIZE 4           //4x4 MBs 
   87 #define MB_AREA (MB_SIZE*MB_SIZE) 
   89 #define VECTOR_MAX 6        //six or four entries per vector depending on format 
   90 #define CODEBOOK_MAX 256    //size of a codebook 
   92 #define MAX_STRIPS  32      //Note: having fewer choices regarding the number of strips speeds up encoding (obviously) 
   93 #define MIN_STRIPS  1       //Note: having more strips speeds up encoding the frame (this is less obvious) 
  155 #ifdef CINEPAKENC_DEBUG 
  157     int num_v1_mode, num_v4_mode, num_mc_mode;
 
  158     int num_v1_encs, num_v4_encs, num_skips;
 
  168 #define OFFSET(x) offsetof(CinepakEncContext, x) 
  169 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 
  171     { 
"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 },
 
  172     { 
"skip_empty_cb", 
"Avoid wasting bytes, ignore vintage MacOS decoder", 
OFFSET(skip_empty_cb), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, 
VE },
 
  173     { 
"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 },
 
  174     { 
"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 },
 
  175     { 
"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 },
 
  189     int x, mb_count, strip_buf_size, frame_buf_size;
 
  192         av_log(avctx, 
AV_LOG_ERROR, 
"width and height must be multiples of four (got %ix%i)\n",
 
  198         av_log(avctx, 
AV_LOG_ERROR, 
"minimal number of strips can not exceed maximal (got %i and %i)\n",
 
  242 #ifdef CINEPAKENC_DEBUG 
  287 #ifdef CINEPAKENC_DEBUG 
  288     s->num_v1_mode = s->num_v4_mode = s->num_mc_mode = s->num_v1_encs = s->num_v4_encs = s->num_skips = 0;
 
  304 #ifdef CINEPAKENC_DEBUG 
  315 #ifdef CINEPAK_REPORT_SERR
 
  325     int64_t score1, score2, score3;
 
  332 #ifdef CINEPAK_REPORT_SERR 
  339         ret += s->
lambda * 8 * mb_count;
 
  342         for(x = 0; x < mb_count; x++) {
 
  345 #ifdef CINEPAK_REPORT_SERR 
  358             *training_set_v1_shrunk = *training_set_v4_shrunk = 0;
 
  359             for(x = 0; x < mb_count; x++) {
 
  367 #ifdef CINEPAK_REPORT_SERR 
  372             for(x = 0; x < mb_count; x++) {
 
  377                 if(score1 <= score2) {
 
  379 #ifdef CINEPAK_REPORT_SERR 
  385 #ifdef CINEPAK_REPORT_SERR 
  397             int v1_shrunk = 0, v4_shrunk = 0;
 
  398             for(x = 0; x < mb_count; x++) {
 
  405 #ifdef CINEPAK_REPORT_SERR 
  413 #ifdef CINEPAK_REPORT_SERR 
  418 #ifdef CINEPAK_REPORT_SERR 
  427 #ifdef CINEPAK_REPORT_SERR 
  432 #ifdef CINEPAK_REPORT_SERR 
  438             *training_set_v1_shrunk = v1_shrunk;
 
  439             *training_set_v4_shrunk = v4_shrunk;
 
  441             for(x = 0; x < mb_count; x++) {
 
  447                 if(score1 <= score2 && score1 <= score3) {
 
  449 #ifdef CINEPAK_REPORT_SERR 
  453                 } 
else if(score2 <= score3) {
 
  455 #ifdef CINEPAK_REPORT_SERR 
  461 #ifdef CINEPAK_REPORT_SERR 
  485     int incremental_codebook_replacement_mode = 0; 
 
  490            chunk_type_yuv+(incremental_codebook_replacement_mode?1:0) :
 
  491            chunk_type_gray+(incremental_codebook_replacement_mode?1:0),
 
  493            + (incremental_codebook_replacement_mode?(size+31)/32*4:0) );
 
  500     if(incremental_codebook_replacement_mode) {
 
  503         for(x = 0; x < 
size; x++) {
 
  509                 flags = ((flags>>1) | 0x80000000);
 
  510             for(y = 0; y < entry_size; y++)
 
  511                 buf[ret++] = codebook[y + x*entry_size] ^ (y >= 4 ? 0x80 : 0);
 
  512             if((flags&0xffffffff) == 0xffffffff) {
 
  513                 AV_WB32(&buf[flagsind], flags);
 
  518             AV_WB32(&buf[flagsind], flags);
 
  520         for(x = 0; x < 
size; x++)
 
  521             for(y = 0; y < entry_size; y++)
 
  522                 buf[ret++] = codebook[y + x*entry_size] ^ (y >= 4 ? 0x80 : 0);
 
  547     sub_pict->
data[0][0] =
 
  548             sub_pict->
data[0][1] =
 
  552     sub_pict->
data[0][2] =
 
  553             sub_pict->
data[0][3] =
 
  568         sub_pict->
data[1][0] =
 
  569             sub_pict->
data[1][1] =
 
  573         sub_pict->
data[2][0] =
 
  574             sub_pict->
data[2][1] =
 
  585     for(i = y = 0; y < 4; y += 2) {
 
  586         for(x = 0; x < 4; x += 2, i++) {
 
  610         for(p = 1; p <= 2; p++) {
 
  611             for(y = 0; y < MB_SIZE/2; y++) {
 
  623     int needs_extra_bit, should_write_temp;
 
  624     unsigned char temp[64]; 
 
  626     AVPicture sub_scratch = {{0}}, sub_last = {{0}};
 
  639     for(z = y = 0; y < 
h; y += 
MB_SIZE) {
 
  640         for(x = 0; x < s->
w; x += 
MB_SIZE, z++) {
 
  647                 copy_mb(s, &sub_scratch, &sub_last);
 
  660         for(x = 0; x < mb_count; x++)
 
  669         for(x = 0; x < mb_count; x += 32) {
 
  671             for(y = x; y < 
FFMIN(x+32, mb_count); y++)
 
  673                     flags |= 1 << (31 - y + x);
 
  678             for(y = x; y < 
FFMIN(x+32, mb_count); y++) {
 
  684                     for(z = 0; z < 4; z++)
 
  696         flags = bits = temp_size = 0;
 
  698         for(x = 0; x < mb_count; x++) {
 
  702             should_write_temp = 0;
 
  717                     memcpy(&buf[ret], temp, temp_size);
 
  721                     should_write_temp = 1;
 
  724             if(needs_extra_bit) {
 
  732                 for(z = 0; z < 4; z++)
 
  735             if(should_write_temp) {
 
  736                 memcpy(&buf[ret], temp, temp_size);
 
  745             memcpy(&buf[ret], temp, temp_size);
 
  760     int x, 
y, p, d, 
ret = 0;
 
  770         for(p = 1; p <= 2; p++) {
 
  771             for(y = 0; y < MB_SIZE/2; y++) {
 
  772                 for(x = 0; x < MB_SIZE/2; x++) {
 
  784 #define CERTAIN(x) ((x)!=ENC_UNCERTAIN) 
  789     int x, 
y, i, j, k, x2, y2, x3, y3, 
plane, 
shift, mbn;
 
  793     int64_t total_error = 0;
 
  797     for(mbn = i = y = 0; y < 
h; y += 
MB_SIZE) {
 
  798         for(x = 0; x < s->
w; x += 
MB_SIZE, ++mbn) {
 
  809                 for(j = y2 = 0; y2 < entry_size; y2 += 2) {
 
  810                     for(x2 = 0; x2 < 4; x2 += 2, j++) {
 
  811                         plane = y2 < 4 ? 0 : 1 + (x2 >> 1);
 
  812                         shift = y2 < 4 ? 0 : 1;
 
  817                                    pict->
data[
plane][((x+x3) >> shift) +     (((y+y3) >> shift) + 1) * pict->
linesize[plane]] +
 
  823                 for(j = y2 = 0; y2 < 
MB_SIZE; y2 += 2) {
 
  824                     for(x2 = 0; x2 < 
MB_SIZE; x2 += 2) {
 
  825                         for(k = 0; k < entry_size; k++, j++) {
 
  826                             plane = k >= 4 ? k - 3 : 0;
 
  832                                 x3 = x + x2 + (k & 1);
 
  833                                 y3 = y + y2 + (k >> 1);
 
  859     vq_pict.data[0] = vq_pict_buf;
 
  861     vq_pict.data[1] = &vq_pict_buf[
MB_AREA];
 
  862     vq_pict.data[2] = vq_pict.data[1] + (
MB_AREA >> 2);
 
  863     vq_pict.linesize[1] = vq_pict.linesize[2] = 
MB_SIZE >> 1;
 
  866     for(i = j = y = 0; y < 
h; y += 
MB_SIZE) {
 
  867         for(x = 0; x < s->
w; x += 
MB_SIZE, j++) {
 
  885                 for(k = 0; k < 4; k++)
 
  910     for(i = y = 0; y < 
h; y += 
MB_SIZE) {
 
  911         for(x = 0; x < s->
w; x += 
MB_SIZE, i++) {
 
  927     buf[0] = keyframe ? 0x10: 0x11;
 
  939 #ifdef CINEPAK_REPORT_SERR
 
  945 #ifdef CINEPAK_REPORT_SERR 
  951     int v1enough, v1_size, v4enough, v4_size;
 
  952     int new_v1_size, new_v4_size;
 
  953     int v1shrunk, v4shrunk;
 
  962 #define SMALLEST_CODEBOOK 1 
  964         for(v4enough = 0, v4_size = 0; v4_size <= v1_size && !v4enough; v4_size = v4_size ? v4_size << 2 : v1_size >= SMALLEST_CODEBOOK << 2 ? v1_size >> 2 : 
SMALLEST_CODEBOOK) {
 
  998 #ifdef CINEPAK_REPORT_SERR
 
 1009                     if(new_v1_size < info.
v1_size){
 
 1016                     if(new_v4_size < info.
v4_size) {
 
 1026                                                      &v1shrunk, &v4shrunk
 
 1027 #ifdef CINEPAK_REPORT_SERR
 
 1032                         if((!v1shrunk && !v4shrunk) || !extra_iterations_limit--) 
break;
 
 1037                             if(new_v1_size < info.
v1_size){
 
 1045                             if(new_v4_size < info.
v4_size) {
 
 1055                 if(best_size == 0 || score < *best_score) {
 
 1057                     *best_score = score;
 
 1058 #ifdef CINEPAK_REPORT_SERR 
 1065 #ifdef CINEPAK_REPORT_SERR 
 1069 #ifdef CINEPAKENC_DEBUG 
 1071                     memcpy(s->best_mb, s->
mb, mb_count*
sizeof(
mb_info));
 
 1082 #ifdef CINEPAKENC_DEBUG 
 1094         for(x = 0; x < s->
w*h/
MB_AREA; x++)
 
 1095             if(s->best_mb[x].best_encoding == 
ENC_V1)
 
 1097             else if(s->best_mb[x].best_encoding == 
ENC_V4)
 
 1112     buf[0] = isakeyframe ? 0 : 1;
 
 1123     int num_strips, strip, i, 
y, nexty, 
size, temp_size;
 
 1124     AVPicture last_pict, pict, scratch_pict;
 
 1125     int64_t best_score = 0, score, score_temp;
 
 1126 #ifdef CINEPAK_REPORT_SERR 
 1127     int64_t best_serr = 0, serr, serr_temp;
 
 1130     int best_nstrips = -1, best_size = -1; 
 
 1135         for(y = 0; y < s->
h; y += 2) {
 
 1136             for(x = 0; x < s->
w; x += 2) {
 
 1139                 ir[1] = ir[0] + ((
AVPicture*)frame)->linesize[0];
 
 1142                 for(i=0; i<4; ++i) {
 
 1144                     i1 = (i&1); i2 = (i>=2);
 
 1145                     rr = ir[i2][i1*3+0];
 
 1146                     gg = ir[i2][i1*3+1];
 
 1147                     bb = ir[i2][i1*3+2];
 
 1148                     r += rr; g += gg; b += bb;
 
 1152                     rr = (2396625*rr + 4793251*gg + 1198732*bb) >> 23;
 
 1154                     else if (rr > 255) rr = 255;
 
 1155                     scratch_pict.
data[0][i1 + i2*scratch_pict.
linesize[0]] = rr;
 
 1161                 rr = (-299683*r - 599156*g + 898839*
b) >> 23;
 
 1162                 if(      rr < -128) rr = -128;
 
 1163                 else if (rr >  127) rr =  127;
 
 1164                 scratch_pict.
data[1][0] = rr + 128; 
 
 1167                 rr = (748893*r - 599156*g - 149737*
b) >> 23;
 
 1168                 if(      rr < -128) rr = -128;
 
 1169                 else if (rr >  127) rr =  127;
 
 1170                 scratch_pict.
data[2][0] = rr + 128; 
 
 1177     for(num_strips = s->
min_strips; num_strips <= s->max_strips && num_strips <= s->
h / 
MB_SIZE; num_strips++) {
 
 1180 #ifdef CINEPAK_REPORT_SERR 
 1184         for(y = 0, strip = 1; y < s->
h; strip++, y = nexty) {
 
 1187             nexty = strip * s->
h / num_strips; 
 
 1190                 nexty += 4 - (nexty & 3);
 
 1192             strip_height = nexty - 
y;
 
 1193             if(strip_height <= 0) { 
 
 1206 #ifdef CINEPAK_REPORT_SERR
 
 1212             score += score_temp;
 
 1213 #ifdef CINEPAK_REPORT_SERR 
 1221         if(best_score == 0 || score < best_score) {
 
 1223 #ifdef CINEPAK_REPORT_SERR 
 1228 #ifdef CINEPAK_REPORT_SERR 
 1229             av_log(s->
avctx, 
AV_LOG_INFO, 
"best number of strips so far: %2i, %12lli, %i B\n", num_strips, (
long long int)serr, best_size);
 
 1234             best_nstrips = num_strips;
 
 1238         if(num_strips - best_nstrips > 4)
 
 1242     av_assert0(best_nstrips >= 0 && best_size >= 0);
 
 1309 #ifdef CINEPAKENC_DEBUG 
 1316 #ifdef CINEPAKENC_DEBUG 
 1317     av_log(avctx, 
AV_LOG_INFO, 
"strip coding stats: %i V1 mode, %i V4 mode, %i MC mode (%i V1 encs, %i V4 encs, %i skips)\n",
 
 1318         s->num_v1_mode, s->num_v4_mode, s->num_mc_mode, s->num_v1_encs, s->num_v4_encs, s->num_skips);
 
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data. 
 
static enum AVPixelFormat pix_fmt
 
static int shift(int a, int b)
 
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line 
 
This structure describes decoded (raw) audio or video data. 
 
#define LIBAVUTIL_VERSION_INT
 
packed RGB 8:8:8, 24bpp, RGBRGB... 
 
static void get_sub_picture(CinepakEncContext *s, int x, int y, AVPicture *in, AVPicture *out)
 
static av_cold int init(AVCodecContext *avctx)
 
static int cinepak_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static void write_strip_header(CinepakEncContext *s, int y, int h, int keyframe, unsigned char *buf, int strip_size)
 
int strip_number_delta_range
 
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx. 
 
int v1_codebook[CODEBOOK_MAX *VECTOR_MAX]
 
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
 
#define av_assert0(cond)
assert() equivalent, that is always enabled. 
 
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values. 
 
uint8_t * data[AV_NUM_DATA_POINTERS]
pointers to the image data planes 
 
#define CHUNK_HEADER_SIZE
 
int avpriv_do_elbg(int *points, int dim, int numpoints, int *codebook, int numCB, int max_steps, int *closest_cb, AVLFG *rand_state)
Implementation of the Enhanced LBG Algorithm Based on the paper "Neural Networks 14:1219-1237" that c...
 
#define SMALLEST_CODEBOOK
 
int v4_codebook[CODEBOOK_MAX *VECTOR_MAX]
 
static int encode_mode(CinepakEncContext *s, int h, AVPicture *scratch_pict, AVPicture *last_pict, strip_info *info, unsigned char *buf)
 
static void decode_v4_vector(CinepakEncContext *s, AVPicture *sub_pict, int *v4_vector, strip_info *info)
 
static const AVOption options[]
 
#define AV_PKT_FLAG_KEY
The packet contains a keyframe. 
 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
 
unsigned char * frame_buf
 
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g. 
 
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
 
static int rd_strip(CinepakEncContext *s, int y, int h, int keyframe, AVPicture *last_pict, AVPicture *pict, AVPicture *scratch_pict, unsigned char *buf, int64_t *best_score)
 
simple assert() macros that are a bit more flexible than ISO C assert(). 
 
const char * name
Name of the codec implementation. 
 
Libavcodec external API header. 
 
int flags
A combination of AV_PKT_FLAG values. 
 
static void decode_v1_vector(CinepakEncContext *s, AVPicture *sub_pict, int v1_vector, strip_info *info)
 
static void calculate_skip_errors(CinepakEncContext *s, int h, AVPicture *last_pict, AVPicture *pict, strip_info *info)
 
static int compute_mb_distortion(CinepakEncContext *s, AVPicture *a, AVPicture *b)
 
static av_cold int cinepak_encode_init(AVCodecContext *avctx)
 
int width
picture width / height. 
 
static int write_chunk_header(unsigned char *buf, int chunk_type, int chunk_size)
 
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad)) 
 
static int quantize(CinepakEncContext *s, int h, AVPicture *pict, int v1mode, strip_info *info, mb_encoding encoding)
 
#define AV_LOG_INFO
Standard information. 
 
mb_encoding best_encoding
 
int avpriv_init_elbg(int *points, int dim, int numpoints, int *codebook, int numCB, int max_steps, int *closest_cb, AVLFG *rand_state)
Initialize the **codebook vector for the elbg algorithm. 
 
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line. 
 
main external API structure. 
 
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
 
AVCodec ff_cinepak_encoder
 
Describe the class of an AVClass context structure. 
 
#define STRIP_HEADER_SIZE
 
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
 
static int encode_codebook(CinepakEncContext *s, int *codebook, int size, int chunk_type_yuv, int chunk_type_gray, unsigned char *buf)
 
static const AVClass cinepak_class
 
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes. 
 
int max_extra_cb_iterations
 
common internal api header. 
 
static void copy_mb(CinepakEncContext *s, AVPicture *a, AVPicture *b)
 
unsigned char * strip_buf
 
unsigned char * pict_bufs[4]
 
static int rd_frame(CinepakEncContext *s, const AVFrame *frame, int isakeyframe, unsigned char *buf, int buf_size)
 
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
 
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)
 
#define av_malloc_array(a, b)
 
#define FFSWAP(type, a, b)
 
AVPixelFormat
Pixel format. 
 
This structure stores compressed data. 
 
enum AVPixelFormat pix_fmt
 
static av_cold int cinepak_encode_end(AVCodecContext *avctx)
 
static int write_cvid_header(CinepakEncContext *s, unsigned char *buf, int num_strips, int data_size, int isakeyframe)
 
int keyint_min
minimum GOP size