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;
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];
117 bestscore /= quality;
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++){
153 int t =
c->codebook[
c->output[
i+j*4]*3 + k] -
c->block[
i*3+k+j*4*3];
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++){
180 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];
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++)
214 prevptr[x*3 +
i*3 + k - j*3*avctx->
width] =
c->codebook[
c->output[
i + j*4]*3 + k];
217 bytestream_put_le16(&dst,
flags);
218 bytestream_put_le16(&dst,
MKRGB555(
c->codebook, 0));
219 bytestream_put_le16(&dst,
MKRGB555(
c->codebook, 3));
222 for(j = 0; j < 4; j++){
223 for(
i = 0;
i < 4;
i++){
225 for(k = 0; k < 3; k++)
226 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];
229 bytestream_put_le16(&dst,
flags);
230 bytestream_put_le16(&dst,
MKRGB555(
c->codebook2, 0) | 0x8000);
231 for(
i = 3;
i < 24;
i += 3)
232 bytestream_put_le16(&dst,
MKRGB555(
c->codebook2,
i));
237 prevptr -= avctx->
width * 3 * 4;
242 bytestream_put_byte(&dst, 0);
243 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.