36 #define CHARSET_CHARS 256 38 #define CROP_SCREENS 1 41 static const int mc_colors[5]={0x0,0xb,0xc,0xf,0x1};
50 int blockx, blocky, x, y;
56 for (blocky = 0; blocky <
C64YRES; blocky += 8) {
57 for (blockx = 0; blockx <
C64XRES; blockx += 8) {
58 for (y = blocky; y < blocky + 8 && y <
C64YRES; y++) {
59 for (x = blockx; x < blockx + 8 && x <
C64XRES; x += 2) {
60 if(x < width && y < height) {
62 luma = (src[(x + 0 + y * p->
linesize[0])] +
63 src[(x + 1 + y * p->
linesize[0])]) / 2;
82 int lowdiff, highdiff;
92 for (a=0; a < 256; a++) {
93 if(i < c->mc_pal_size -1 && a == c->
mc_luma_vals[i + 1]) {
109 for (y = 0; y < 8; y++) {
111 for (x = 0; x < 4; x++) {
112 pix = best_cb[y * 4 + x];
115 if (index1[pix] >= 3)
125 row1 |= 3-(index2[pix] & 3);
127 row1 |= 3-(index1[pix] & 3);
130 row2 |= 3-(index2[pix] & 3);
132 row2 |= 3-(index1[pix] & 3);
136 row1 |= 3-(index2[pix] & 3);
138 row1 |= 3-(index1[pix] & 3);
141 charset[y+0x000] = row1;
145 if (highdiff > 0 && lowdiff > 0 && c->
mc_use_5col) {
146 if (lowdiff > highdiff) {
147 for (x = 0; x < 32; x++)
150 for (x = 0; x < 32; x++)
161 colrammap[charpos] = (highdiff > 0);
220 #if FF_API_CODED_FRAME 240 for (a = 0; a < 256; a++) {
241 temp = colram[charmap[a + 0x000]] << 0;
242 temp |= colram[charmap[a + 0x100]] << 1;
243 temp |= colram[charmap[a + 0x200]] << 2;
244 if (a < 0xe8) temp |= colram[charmap[a + 0x300]] << 3;
250 const AVFrame *pict,
int *got_packet)
275 screen_size = b_width * b_height;
296 #if FF_API_CODED_FRAME 316 req_size = charset_size + c->
mc_lifetime*(screen_size + colram_size);
337 memcpy(buf, charset, charset_size);
341 charset += charset_size;
347 for (y = 0; y < b_height; y++) {
348 for (x = 0; x < b_width; x++) {
349 buf[y * b_width + x] = charmap[y * b_width + x];
354 req_size += screen_size;
361 req_size += colram_size;
378 pkt->
size = req_size;
380 *got_packet = !!req_size;
400 .long_name =
NULL_IF_CONFIG_SMALL(
"Multicolor charset for Commodore 64, extended with 5th color (colram)"),
const struct AVCodec * codec
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
This structure describes decoded (raw) audio or video data.
AVCodec ff_a64multi_encoder
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int 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.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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. ...
a64 video encoder - tables used by a64 encoders
const char * name
Name of the codec implementation.
int flags
A combination of AV_PKT_FLAG values.
static float distance(float x, float y, int band)
enum AVPictureType pict_type
Picture type of the frame.
unsigned mc_frame_counter
static void a64_compress_colram(unsigned char *buf, int *charmap, uint8_t *colram)
int width
picture width / height.
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
static const uint16_t dither[8][8]
#define AV_LOG_INFO
Standard information.
static void render_charset(AVCodecContext *avctx, uint8_t *charset, uint8_t *colrammap)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static void to_meta_with_crop(AVCodecContext *avctx, const AVFrame *p, int *dest)
a64 video encoder - c64 colors in rgb
static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
static const int mc_colors[5]
a64 video encoder - basic headers
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
int 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...
static enum AVPixelFormat pix_fmts[]
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
static av_cold int a64multi_encode_init(AVCodecContext *avctx)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
common internal and external API header
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
static av_cold int init(AVCodecParserContext *s)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static const uint8_t a64_palette[16][3]
#define FF_ENABLE_DEPRECATION_WARNINGS
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)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
AVPixelFormat
Pixel format.
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
static const uint8_t multi_dither_patterns[9][4][4]
dither patterns used vor rendering the multicolor charset