30 #include "libavutil/lfg.h"
32 #include "libavutil/imgutils.h"
60 #define SKIP_PREFIX 0x8400
61 #define SKIPS_MAX 0x0FFF
62 #define MKRGB555(in, off) ((in[off] << 10) | (in[off + 1] << 5) | (in[off + 2]))
64 static const int remap[16] = { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15 };
67 const AVFrame *pict,
int *got_packet)
76 int i, j, k, x,
y,
ret;
93 for(y = 0; y < avctx->
height; y += 4){
94 for(x = 0; x < avctx->
width; x += 4){
96 int bestscore = INT_MAX;
100 for(j = 0; j < 4; j++){
101 for(i = 0; i < 4; i++){
103 for(k = 0; k < 3; k++){
104 c->
block[(i + j*4)*3 + k] =
105 c->
block2[
remap[i + j*4]*3 + k] = (val >> (10-k*5)) & 0x1F;
111 for(j = 0; j < 4; j++){
112 for(i = 0; i < 4*3; i++){
113 int t = prevptr[x*3 + i - j*3*avctx->
width] - c->
block[i + j*4*3];
125 for(j = 0; j < 4; j++){
126 for(i = 0; i < 4; i++){
127 for(k = 0; k < 3; k++){
128 int t = c->
avg[k] - c->
block[(i+j*4)*3+k];
135 if(score < bestscore){
145 for(i = 0; i < 3; i++)
147 for(i = 0; i < 16; i++)
150 for(j = 0; j < 4; j++){
151 for(i = 0; i < 4; i++){
152 for(k = 0; k < 3; k++){
160 if(score < bestscore){
166 for(i = 0; i < 4; i++){
172 for(i = 0; i < 3; i++)
174 for(i = 12; i < 16; i++)
177 for(j = 0; j < 4; j++){
178 for(i = 0; i < 4; i++){
179 for(k = 0; k < 3; k++){
187 if(score < bestscore){
203 bytestream_put_le16(&dst,
MKRGB555(c->
avg,0) | 0x8000);
204 for(j = 0; j < 4; j++)
205 for(i = 0; i < 4; i++)
206 for(k = 0; k < 3; k++)
207 prevptr[x*3 + i*3 + k - j*3*avctx->
width] = c->
avg[k];
210 for(j = 0; j < 4; j++){
211 for(i = 0; i < 4; i++){
212 flags |= (c->
output[i + j*4]^1) << (i + j*4);
213 for(k = 0; k < 3; k++)
217 bytestream_put_le16(&dst, flags);
222 for(j = 0; j < 4; j++){
223 for(i = 0; i < 4; i++){
225 for(k = 0; k < 3; k++)
229 bytestream_put_le16(&dst, flags);
231 for(i = 3; i < 24; i += 3)
237 prevptr -= avctx->
width * 3 * 4;
242 bytestream_put_byte(&dst, 0);
243 bytestream_put_byte(&dst, 0);
static av_cold int encode_init(AVCodecContext *avctx)
init encoder
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data.
const char const char void * val
This structure describes decoded (raw) audio or video data.
static av_cold int init(AVCodecContext *avctx)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
#define AV_PIX_FMT_RGB555
const char * name
Name of the codec implementation.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define FFSWAP(type, a, b)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Libavcodec external API header.
AVPixelFormat
Pixel format.
int flags
A combination of AV_PKT_FLAG values.
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...
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
enum AVPictureType pict_type
Picture type of the frame.
#define FF_MIN_BUFFER_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
int width
picture width / height.
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
int AC3_NAME() encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
void av_lfg_init(AVLFG *c, unsigned int seed)
static const int remap[16]
static av_cold int encode_end(AVCodecContext *avctx)
Uninit encoder.
main external API structure.
static void close(AVCodecParserContext *s)
AVCodec ff_msvideo1_encoder
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
AVFrame * coded_frame
the picture in the bitstream
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
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.
common internal api header.
int key_frame
1 -> keyframe, 0-> not
#define MKRGB555(in, off)
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int keyint_min
minimum GOP size