Go to the documentation of this file.
59 #define SKIP_PREFIX 0x8400
60 #define SKIPS_MAX 0x03FF
61 #define MKRGB555(in, off) (((in)[off] << 10) | ((in)[(off) + 1] << 5) | ((in)[(off) + 2]))
63 static const int remap[16] = { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15 };
66 const AVFrame *pict,
int *got_packet)
75 int i, j, k, x, y,
ret;
91 for(y = 0; y < avctx->
height; y += 4){
92 for(x = 0; x < avctx->
width; x += 4){
94 int bestscore = INT_MAX;
98 for(j = 0; j < 4; j++){
99 for(
i = 0;
i < 4;
i++){
101 for(k = 0; k < 3; k++){
102 c->block[(
i + j*4)*3 + k] =
103 c->block2[
remap[
i + j*4]*3 + k] = (
val >> (10-k*5)) & 0x1F;
109 for(j = 0; j < 4; j++){
110 for(
i = 0;
i < 4*3;
i++){
111 int t = prevptr[x*3 +
i - j*3*avctx->
width] -
c->block[
i + j*4*3];
123 for(j = 0; j < 4; j++){
124 for(
i = 0;
i < 4;
i++){
125 for(k = 0; k < 3; k++){
126 int t =
c->avg[k] -
c->block[(
i+j*4)*3+k];
133 if(score < bestscore){
143 for(
i = 0;
i < 3;
i++)
145 for(
i = 0;
i < 16;
i++)
148 for(j = 0; j < 4; j++){
149 for(
i = 0;
i < 4;
i++){
150 for(k = 0; k < 3; k++){
151 int t =
c->codebook[
c->output[
i+j*4]*3 + k] -
c->block[
i*3+k+j*4*3];
158 if(score < bestscore){
164 for(
i = 0;
i < 4;
i++){
170 for(
i = 0;
i < 3;
i++)
172 for(
i = 12;
i < 16;
i++)
175 for(j = 0; j < 4; j++){
176 for(
i = 0;
i < 4;
i++){
177 for(k = 0; k < 3; k++){
178 int t =
c->codebook2[(
c->output2[
remap[
i+j*4]] + (
i&2) + (j&2)*2)*3+k] -
c->block[
i*3+k + j*4*3];
185 if(score < bestscore){
201 bytestream_put_le16(&dst,
MKRGB555(
c->avg,0) | 0x8000);
202 for(j = 0; j < 4; j++)
203 for(
i = 0;
i < 4;
i++)
204 for(k = 0; k < 3; k++)
205 prevptr[x*3 +
i*3 + k - j*3*avctx->
width] =
c->avg[k];
208 for(j = 0; j < 4; j++){
209 for(
i = 0;
i < 4;
i++){
210 flags |= (
c->output[
i + j*4]^1) << (
i + j*4);
211 for(k = 0; k < 3; k++)
212 prevptr[x*3 +
i*3 + k - j*3*avctx->
width] =
c->codebook[
c->output[
i + j*4]*3 + k];
215 bytestream_put_le16(&dst,
flags);
216 bytestream_put_le16(&dst,
MKRGB555(
c->codebook, 0));
217 bytestream_put_le16(&dst,
MKRGB555(
c->codebook, 3));
220 for(j = 0; j < 4; j++){
221 for(
i = 0;
i < 4;
i++){
223 for(k = 0; k < 3; k++)
224 prevptr[x*3 +
i*3 + k - j*3*avctx->
width] =
c->codebook2[(
c->output2[
remap[
i+j*4]] + (
i&2) + (j&2)*2)*3 + k];
227 bytestream_put_le16(&dst,
flags);
228 bytestream_put_le16(&dst,
MKRGB555(
c->codebook2, 0) | 0x8000);
229 for(
i = 3;
i < 24;
i += 3)
230 bytestream_put_le16(&dst,
MKRGB555(
c->codebook2,
i));
235 prevptr -= avctx->
width * 3 * 4;
240 bytestream_put_byte(&dst, 0);
241 bytestream_put_byte(&dst, 0);
AVPixelFormat
Pixel format.
int keyint_min
minimum GOP size
static av_cold int init(AVCodecContext *avctx)
#define FFSWAP(type, a, b)
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
This structure describes decoded (raw) audio or video data.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about quality
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static double val(void *priv, double ch)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static enum AVPixelFormat pix_fmts[]
#define AV_INPUT_BUFFER_MIN_SIZE
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.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Context structure for the Lagged Fibonacci PRNG.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const int remap[16]
int flags
A combination of AV_PKT_FLAG values.
static av_cold int encode_end(AVCodecContext *avctx)
Uninit encoder.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define i(width, name, range_min, range_max)
AVCodec ff_msvideo1_encoder
#define AV_PIX_FMT_RGB555
const char * name
Name of the codec implementation.
static av_cold int encode_init(AVCodecContext *avctx)
init encoder
main external API structure.
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
#define MKRGB555(in, off)
This structure stores compressed data.
int width
picture width / height.
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
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...
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
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...