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];
115 bestscore /= quality;
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);
static double val(void *priv, double ch)
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
#define flags(name, subs,...)
#define FFSWAP(type, a, b)
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.
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...
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define AV_INPUT_BUFFER_MIN_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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...
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
AVCodec ff_msvideo1_encoder
static const int remap[16]
static av_cold int encode_init(AVCodecContext *avctx)
init encoder
#define MKRGB555(in, off)
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
static av_cold int encode_end(AVCodecContext *avctx)
Uninit encoder.
AVPixelFormat
Pixel format.
#define AV_PIX_FMT_RGB555
main external API structure.
int width
picture width / height.
int keyint_min
minimum GOP size
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Context structure for the Lagged Fibonacci PRNG.
This structure stores compressed data.
int flags
A combination of AV_PKT_FLAG values.