Go to the documentation of this file.
61 #define SKIP_PREFIX 0x8400
62 #define SKIPS_MAX 0x03FF
63 #define MKRGB555(in, off) (((in)[off] << 10) | ((in)[(off) + 1] << 5) | ((in)[(off) + 2]))
65 static const int remap[16] = { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15 };
68 const AVFrame *pict,
int *got_packet)
77 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];
122 1, 1,
c->output, &
c->rnd, 0);
127 for(j = 0; j < 4; j++){
128 for(
i = 0;
i < 4;
i++){
129 for(k = 0; k < 3; k++){
130 int t =
c->avg[k] -
c->block[(
i+j*4)*3+k];
137 if(score < bestscore){
144 2, 1,
c->output, &
c->rnd, 0);
149 for(
i = 0;
i < 3;
i++)
150 FFSWAP(uint8_t,
c->codebook[
i],
c->codebook[
i+3]);
151 for(
i = 0;
i < 16;
i++)
154 for(j = 0; j < 4; j++){
155 for(
i = 0;
i < 4;
i++){
156 for(k = 0; k < 3; k++){
157 int t =
c->codebook[
c->output[
i+j*4]*3 + k] -
c->block[
i*3+k+j*4*3];
164 if(score < bestscore){
170 for(
i = 0;
i < 4;
i++){
172 c->codebook2 +
i * 2 * 3, 2, 1,
173 c->output2 +
i * 4, &
c->rnd, 0);
179 for(
i = 0;
i < 3;
i++)
180 FFSWAP(uint8_t,
c->codebook2[
i+18],
c->codebook2[
i+21]);
181 for(
i = 12;
i < 16;
i++)
184 for(j = 0; j < 4; j++){
185 for(
i = 0;
i < 4;
i++){
186 for(k = 0; k < 3; k++){
187 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];
194 if(score < bestscore){
210 bytestream_put_le16(&dst,
MKRGB555(
c->avg,0) | 0x8000);
211 for(j = 0; j < 4; j++)
212 for(
i = 0;
i < 4;
i++)
213 for(k = 0; k < 3; k++)
214 prevptr[x*3 +
i*3 + k - j*3*avctx->
width] =
c->avg[k];
217 for(j = 0; j < 4; j++){
218 for(
i = 0;
i < 4;
i++){
219 flags |= (
c->output[
i + j*4]^1) << (
i + j*4);
220 for(k = 0; k < 3; k++)
221 prevptr[x*3 +
i*3 + k - j*3*avctx->
width] =
c->codebook[
c->output[
i + j*4]*3 + k];
224 bytestream_put_le16(&dst,
flags);
225 bytestream_put_le16(&dst,
MKRGB555(
c->codebook, 0));
226 bytestream_put_le16(&dst,
MKRGB555(
c->codebook, 3));
229 for(j = 0; j < 4; j++){
230 for(
i = 0;
i < 4;
i++){
232 for(k = 0; k < 3; k++)
233 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];
236 bytestream_put_le16(&dst,
flags);
237 bytestream_put_le16(&dst,
MKRGB555(
c->codebook2, 0) | 0x8000);
238 for(
i = 3;
i < 24;
i += 3)
239 bytestream_put_le16(&dst,
MKRGB555(
c->codebook2,
i));
244 prevptr -= avctx->
width * 3 * 4;
249 bytestream_put_byte(&dst, 0);
250 bytestream_put_byte(&dst, 0);
306 .
p.
name =
"msvideo1",
AVPixelFormat
Pixel format.
int keyint_min
minimum GOP size
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
This structure describes decoded (raw) audio or video data.
const FFCodec ff_msvideo1_encoder
#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.
AVCodec p
The public AVCodec.
static double val(void *priv, double ch)
#define FF_CODEC_ENCODE_CB(func)
int avpriv_elbg_do(ELBGContext **elbgp, int *points, int dim, int numpoints, int *codebook, int num_cb, int max_steps, int *closest_cb, AVLFG *rand_state, uintptr_t flags)
Implementation of the Enhanced LBG Algorithm Based on the paper "Neural Networks 14:1219-1237" that c...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_INPUT_BUFFER_MIN_SIZE
#define CODEC_LONG_NAME(str)
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.
av_cold void avpriv_elbg_free(ELBGContext **elbgp)
Free an ELBGContext and reset the pointer to it.
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)
#define AV_PIX_FMT_RGB555
const char * name
Name of the codec implementation.
#define FFSWAP(type, a, b)
static av_cold int encode_init(AVCodecContext *avctx)
init encoder
main external API structure.
struct ELBGContext * elbg
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, a positive or negative value, which is typically indicating the size in bytes of each pict...
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_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.