34 #define CHARSET_CHARS 256
36 #define CROP_SCREENS 1
39 static const int mc_colors[5]={0x0,0xb,0xc,0xf,0x1};
47 int blockx, blocky, x, y;
51 uint8_t *src = p->
data[0];
53 for (blocky = 0; blocky <
C64YRES; blocky += 8) {
54 for (blockx = 0; blockx <
C64XRES; blockx += 8) {
55 for (y = blocky; y < blocky + 8 && y <
C64YRES; y++) {
56 for (x = blockx; x < blockx + 8 && x <
C64XRES; x += 2) {
57 if(x < width && y < height) {
59 luma = (src[(x + 0 + y * p->
linesize[0])] +
60 src[(x + 1 + y * p->
linesize[0])]) / 2;
79 int lowdiff, highdiff;
81 static uint8_t index1[256];
82 static uint8_t index2[256];
83 static uint8_t
dither[256];
89 for (a=0; a < 256; a++) {
90 if(i < c->mc_pal_size -1 && a == c->
mc_luma_vals[i + 1]) {
106 for (y = 0; y < 8; y++) {
108 for (x = 0; x < 4; x++) {
109 pix = best_cb[y * 4 + x];
112 if (index1[pix] >= 3)
122 row1 |= 3-(index2[pix] & 3);
124 row1 |= 3-(index1[pix] & 3);
127 row2 |= 3-(index2[pix] & 3);
129 row2 |= 3-(index1[pix] & 3);
133 row1 |= 3-(index2[pix] & 3);
135 row1 |= 3-(index1[pix] & 3);
138 charset[y+0x000] = row1;
142 if (highdiff > 0 && lowdiff > 0 && c->
mc_use_5col) {
143 if (lowdiff > highdiff) {
144 for (x = 0; x < 32; x++)
147 for (x = 0; x < 32; x++)
158 colrammap[charpos] = (highdiff > 0);
233 for (a = 0; a < 256; a++) {
234 temp = colram[charmap[a + 0x000]] << 0;
235 temp |= colram[charmap[a + 0x100]] << 1;
236 temp |= colram[charmap[a + 0x200]] << 2;
237 if (a < 0xe8) temp |= colram[charmap[a + 0x300]] << 3;
243 int buf_size,
void *
data)
269 screen_size = b_width * b_height;
313 memcpy(buf,charset, charset_size);
317 charset += charset_size;
318 req_size += charset_size;
321 else memset(buf, 0, charset_size);
326 for (y = 0; y < b_height; y++) {
327 for (x = 0; x < b_width; x++) {
328 buf[y * b_width + x] = charmap[y * b_width + x];
333 req_size += screen_size;
340 req_size += colram_size;
354 if (req_size > buf_size) {
355 av_log(avctx,
AV_LOG_ERROR,
"buf size too small (need %d, got %d)\n", req_size, buf_size);
385 .long_name =
NULL_IF_CONFIG_SMALL(
"Multicolor charset for Commodore 64, extended with 5th color (colram)"),
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVCodec ff_a64multi_encoder
AVFrame * coded_frame
the picture in the bitstream
struct A64Context A64Context
static av_cold int a64multi_init_encoder(AVCodecContext *avctx)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int init(AVCodecParserContext *s)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int a64multi_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data)
a64 video encoder - tables used by a64 encoders
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)
static float distance(float x, float y, int band)
void ff_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...
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
static void a64_compress_colram(unsigned char *buf, int *charmap, uint8_t *colram)
int width
picture width / height.
static const uint16_t dither[8][8]
static void render_charset(AVCodecContext *avctx, uint8_t *charset, uint8_t *colrammap)
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
a64 video encoder - c64 colors in rgb
static const int mc_colors[5]
a64 video encoder - basic headers
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
void ff_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 global_quality
Global quality for codecs which cannot change it per frame.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVCodec ff_a64multi5_encoder
void av_cold av_lfg_init(AVLFG *c, unsigned int seed)
static const uint8_t a64_palette[16][3]
static const uint8_t interlaced_dither_patterns[9][8][4]
int key_frame
1 -> keyframe, 0-> not
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
static av_cold int a64multi_close_encoder(AVCodecContext *avctx)
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
static const uint8_t multi_dither_patterns[9][4][4]
dither patterns used vor rendering the multicolor charset