56 #define BS_8BIT_PEL (1 << 1) 57 #define BS_KEYFRAME (1 << 2)
58 #define BS_MV_Y_HALF (1 << 4)
59 #define BS_MV_X_HALF (1 << 5)
60 #define BS_NONREF (1 << 8)
64 typedef struct Plane {
72 #define CELL_STACK_MAX 20 121 static int8_t offsets[8] = { 1, 1, 2, -3, -3, 3, 4, 4 };
122 static int8_t deltas [8] = { 0, 1, 0, 4, 4, 1, 0, 1 };
126 for (i = 0; i < 8; i++) {
128 for (j = 0; j < 128; j++)
129 requant_tab[i][j] = (j + offsets[i]) / step * step + deltas[
i];
154 int p, chroma_width, chroma_height;
155 int luma_pitch, chroma_pitch, luma_size, chroma_size;
157 if (luma_width < 16 || luma_width > 640 ||
158 luma_height < 16 || luma_height > 480 ||
159 luma_width & 3 || luma_height & 3) {
161 luma_width, luma_height);
165 ctx->
width = luma_width ;
166 ctx->
height = luma_height;
168 chroma_width =
FFALIGN(luma_width >> 2, 4);
169 chroma_height =
FFALIGN(luma_height >> 2, 4);
171 luma_pitch =
FFALIGN(luma_width, 16);
172 chroma_pitch =
FFALIGN(chroma_width, 16);
176 luma_size = luma_pitch * (luma_height + 1);
180 chroma_size = chroma_pitch * (chroma_height + 1);
183 for (p = 0; p < 3; p++) {
184 ctx->
planes[p].
pitch = !p ? luma_pitch : chroma_pitch;
185 ctx->
planes[p].
width = !p ? luma_width : chroma_width;
186 ctx->
planes[p].
height = !p ? luma_height : chroma_height;
213 for (p = 0; p < 3; p++) {
231 int h,
w, mv_x, mv_y,
offset, offset_dst;
235 offset_dst = (cell->
ypos << 2) * plane->
pitch + (cell->
xpos << 2);
244 if ((cell->
ypos << 2) + mv_y < -1 || (cell->
xpos << 2) + mv_x < 0 ||
248 "Motion vectors point out of the frame.\n");
252 offset = offset_dst + mv_y * plane->
pitch + mv_x;
257 for (w = cell->
width; w > 0;) {
259 if (!((cell->
xpos << 2) & 15) && w >= 4) {
260 for (; w >= 4; src += 16, dst += 16, w -= 4)
265 if (!((cell->
xpos << 2) & 7) && w >= 2) {
285 #define AVG_32(dst, src, ref) \ 286 AV_WN32A(dst, ((AV_RN32A(src) + AV_RN32A(ref)) >> 1) & 0x7F7F7F7FUL) 288 #define AVG_64(dst, src, ref) \ 289 AV_WN64A(dst, ((AV_RN64A(src) + AV_RN64A(ref)) >> 1) & 0x7F7F7F7F7F7F7F7FULL) 298 a &= 0xFF00FF00FF00FF00ULL;
301 a &= 0x00FF00FF00FF00FFULL;
323 for (; n > 0; dst += row_offset, n--)
339 #define BUFFER_PRECHECK \ 340 if (*data_ptr >= last_ptr) \ 341 return IV3_OUT_OF_DATA; \ 343 #define RLE_BLOCK_COPY \ 344 if (cell->mv_ptr || !skip_flag) \ 345 copy_block4(dst, ref, row_offset, row_offset, 4 << v_zoom) 347 #define RLE_BLOCK_COPY_8 \ 348 pix64 = AV_RN64A(ref);\ 350 pix64 = replicate64(pix64);\ 351 fill_64(dst + row_offset, pix64, 7, row_offset);\ 352 AVG_64(dst, ref, dst + row_offset);\ 354 fill_64(dst, pix64, 8, row_offset) 356 #define RLE_LINES_COPY \ 357 copy_block4(dst, ref, row_offset, row_offset, num_lines << v_zoom) 359 #define RLE_LINES_COPY_M10 \ 360 pix64 = AV_RN64A(ref);\ 361 if (is_top_of_cell) {\ 362 pix64 = replicate64(pix64);\ 363 fill_64(dst + row_offset, pix64, (num_lines << 1) - 1, row_offset);\ 364 AVG_64(dst, ref, dst + row_offset);\ 366 fill_64(dst, pix64, num_lines << 1, row_offset) 368 #define APPLY_DELTA_4 \ 369 AV_WN16A(dst + line_offset ,\ 370 (AV_RN16A(ref ) + delta_tab->deltas[dyad1]) & 0x7F7F);\ 371 AV_WN16A(dst + line_offset + 2,\ 372 (AV_RN16A(ref + 2) + delta_tab->deltas[dyad2]) & 0x7F7F);\ 374 if (is_top_of_cell && !cell->ypos) {\ 375 AV_COPY32(dst, dst + row_offset);\ 377 AVG_32(dst, ref, dst + row_offset);\ 381 #define APPLY_DELTA_8 \ 383 if (is_top_of_cell) { \ 384 AV_WN32A(dst + row_offset , \ 385 (replicate32(AV_RN32A(ref )) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\ 386 AV_WN32A(dst + row_offset + 4, \ 387 (replicate32(AV_RN32A(ref + 4)) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\ 389 AV_WN32A(dst + row_offset , \ 390 (AV_RN32A(ref ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\ 391 AV_WN32A(dst + row_offset + 4, \ 392 (AV_RN32A(ref + 4) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\ 397 if (is_top_of_cell && !cell->ypos) {\ 398 AV_COPY64(dst, dst + row_offset);\ 400 AVG_64(dst, ref, dst + row_offset); 403 #define APPLY_DELTA_1011_INTER \ 406 (AV_RN32A(dst ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\ 408 (AV_RN32A(dst + 4 ) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\ 409 AV_WN32A(dst + row_offset , \ 410 (AV_RN32A(dst + row_offset ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\ 411 AV_WN32A(dst + row_offset + 4, \ 412 (AV_RN32A(dst + row_offset + 4) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\ 415 (AV_RN16A(dst ) + delta_tab->deltas[dyad1]) & 0x7F7F);\ 417 (AV_RN16A(dst + 2 ) + delta_tab->deltas[dyad2]) & 0x7F7F);\ 418 AV_WN16A(dst + row_offset , \ 419 (AV_RN16A(dst + row_offset ) + delta_tab->deltas[dyad1]) & 0x7F7F);\ 420 AV_WN16A(dst + row_offset + 2, \ 421 (AV_RN16A(dst + row_offset + 2) + delta_tab->deltas[dyad2]) & 0x7F7F);\ 427 int pitch,
int h_zoom,
int v_zoom,
int mode,
431 int x,
y,
line, num_lines;
435 unsigned int dyad1, dyad2;
437 int skip_flag = 0, is_top_of_cell, is_first_row = 1;
438 int row_offset, blk_row_offset, line_offset;
441 blk_row_offset = (row_offset << (2 + v_zoom)) - (cell->
width << 2);
442 line_offset = v_zoom ? row_offset : 0;
447 for (y = 0; y < cell->
height; is_first_row = 0, y += 1 + v_zoom) {
448 for (x = 0; x < cell->
width; x += 1 + h_zoom) {
452 if (rle_blocks > 0) {
455 }
else if (mode == 10 && !cell->
mv_ptr) {
460 for (line = 0; line < 4;) {
462 is_top_of_cell = is_first_row && !
line;
466 delta_tab = delta[line & 1];
468 delta_tab = delta[1];
470 code = bytestream_get_byte(data_ptr);
472 if (code < delta_tab->num_dyads) {
474 dyad1 = bytestream_get_byte(data_ptr);
476 if (dyad1 >= delta_tab->
num_dyads || dyad1 >= 248)
483 if (swap_quads[line & 1])
484 FFSWAP(
unsigned int, dyad1, dyad2);
488 }
else if (mode == 10 && !cell->
mv_ptr) {
504 num_lines = 257 - code -
line;
509 }
else if (mode == 10 && !cell->
mv_ptr) {
515 code = bytestream_get_byte(data_ptr);
516 rle_blocks = (code & 0x1F) - 1;
517 if (code >= 64 || rle_blocks < 0)
519 skip_flag = code & 0x20;
520 num_lines = 4 -
line;
521 if (mode >= 10 || (cell->
mv_ptr || !skip_flag)) {
524 }
else if (mode == 10 && !cell->
mv_ptr) {
540 }
else if (mode == 10 && !cell->
mv_ptr) {
551 ref += row_offset * (num_lines << v_zoom);
552 dst += row_offset * (num_lines << v_zoom);
557 block += 4 << h_zoom;
558 ref_block += 4 << h_zoom;
562 ref_block += blk_row_offset;
563 block += blk_row_offset;
586 int x, mv_x, mv_y,
mode, vq_index, prim_indx, second_indx;
588 int offset, error = 0, swap_quads[2];
591 const uint8_t *data_start = data_ptr;
596 vq_index = code & 0xF;
599 offset = (cell->
ypos << 2) * plane->
pitch + (cell->
xpos << 2);
604 ref_block = block - plane->
pitch;
605 }
else if (mode >= 10) {
617 if ((cell->
ypos << 2) + mv_y < -1 || (cell->
xpos << 2) + mv_x < 0 ||
621 "Motion vectors point out of the frame.\n");
625 offset += mv_y * plane->
pitch + mv_x;
632 if (mode == 1 || mode == 4) {
634 prim_indx = (code >> 4) + ctx->
cb_offset;
635 second_indx = (code & 0xF) + ctx->
cb_offset;
638 prim_indx = second_indx = vq_index;
641 if (prim_indx >= 24 || second_indx >= 24) {
642 av_log(avctx,
AV_LOG_ERROR,
"Invalid VQ table indexes! Primary: %d, secondary: %d!\n",
643 prim_indx, second_indx);
647 delta[0] = &
vq_tab[second_indx];
648 delta[1] = &
vq_tab[prim_indx];
649 swap_quads[0] = second_indx >= 16;
650 swap_quads[1] = prim_indx >= 16;
654 if (vq_index >= 8 && ref_block) {
655 for (x = 0; x < cell->
width << 2; x++)
656 ref_block[x] =
requant_tab[vq_index & 7][ref_block[x] & 127];
666 if (mode >= 3 && cell->
mv_ptr) {
671 zoom_fac = mode >= 3;
673 0, zoom_fac, mode, delta, swap_quads,
674 &data_ptr, last_ptr);
678 if (mode == 10 && !cell->
mv_ptr) {
680 1, 1, mode, delta, swap_quads,
681 &data_ptr, last_ptr);
683 if (mode == 11 && !cell->
mv_ptr) {
688 zoom_fac = mode == 10;
690 zoom_fac, 1, mode, delta, swap_quads,
691 &data_ptr, last_ptr);
701 av_log(avctx,
AV_LOG_ERROR,
"Mode %d: RLE code %X is not allowed at the current line\n",
711 av_log(avctx,
AV_LOG_ERROR,
"Mode %d: unsupported RLE code: %X\n", mode, data_ptr[-1]);
718 return data_ptr - data_start;
731 #define SPLIT_CELL(size, new_size) (new_size) = ((size) > 2) ? ((((size) + 2) >> 2) << 1) : 1 733 #define UPDATE_BITPOS(n) \ 734 ctx->skip_bits += (n); \ 737 #define RESYNC_BITSTREAM \ 738 if (ctx->need_resync && !(get_bits_count(&ctx->gb) & 7)) { \ 739 skip_bits_long(&ctx->gb, ctx->skip_bits); \ 740 ctx->skip_bits = 0; \ 741 ctx->need_resync = 0; \ 745 if (curr_cell.xpos + curr_cell.width > (plane->width >> 2) || \ 746 curr_cell.ypos + curr_cell.height > (plane->height >> 2)) { \ 747 av_log(avctx, AV_LOG_ERROR, "Invalid cell: x=%d, y=%d, w=%d, h=%d\n", \ 748 curr_cell.xpos, curr_cell.ypos, curr_cell.width, curr_cell.height); \ 749 return AVERROR_INVALIDDATA; \ 755 const int depth,
const int strip_width)
765 curr_cell = *ref_cell;
773 if (curr_cell.
width > strip_width) {
775 curr_cell.
width = (curr_cell.
width <= (strip_width << 1) ? 1 : 2) * strip_width;
780 if (ref_cell->
width <= 0 || curr_cell.
width <= 0)
789 if (
parse_bintree(ctx, avctx, plane, code, &curr_cell, depth - 1, strip_width))
793 if (!curr_cell.
tree) {
815 if (!curr_cell.
tree) {
837 bytes_used =
decode_cell(ctx, avctx, plane, &curr_cell,
859 unsigned num_vectors;
863 num_vectors = bytestream_get_le32(&data); data_size -= 4;
864 if (num_vectors > 256) {
866 "Read invalid number of motion vectors %d\n", num_vectors);
869 if (num_vectors * 2 > data_size)
876 init_get_bits(&ctx->
gb, &data[num_vectors * 2], (data_size - num_vectors * 2) << 3);
883 curr_cell.
xpos = curr_cell.
ypos = 0;
893 #define OS_HDR_ID MKBETAG('F', 'R', 'M', 'H') 900 uint32_t frame_num, word2, check_sum, data_size;
901 uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
908 frame_num = bytestream2_get_le32(&gb);
909 word2 = bytestream2_get_le32(&gb);
910 check_sum = bytestream2_get_le32(&gb);
911 data_size = bytestream2_get_le32(&gb);
913 if ((frame_num ^ word2 ^ data_size ^
OS_HDR_ID) != check_sum) {
921 if (bytestream2_get_le16(&gb) != 32) {
928 ctx->
data_size = (bytestream2_get_le32(&gb) + 7) >> 3;
929 ctx->
cb_offset = bytestream2_get_byte(&gb);
938 height = bytestream2_get_le16(&gb);
939 width = bytestream2_get_le16(&gb);
943 if (width != ctx->
width || height != ctx->
height) {
946 av_dlog(avctx,
"Frame dimensions changed!\n");
948 if (width < 16 || width > 640 ||
949 height < 16 || height > 480 ||
950 width & 3 || height & 3) {
952 "Invalid picture dimensions: %d x %d!\n", width, height);
961 y_offset = bytestream2_get_le32(&gb);
962 v_offset = bytestream2_get_le32(&gb);
963 u_offset = bytestream2_get_le32(&gb);
968 starts[0] = y_offset;
969 starts[1] = v_offset;
970 starts[2] = u_offset;
972 for (j = 0; j < 3; j++) {
974 for (i = 2; i >= 0; i--)
975 if (starts[i] < ends[j] && starts[i] > starts[j])
983 FFMIN3(y_offset, v_offset, u_offset) < gb.
buffer - bs_hdr + 16 ||
1031 for (y = 0; y < dst_height; y++) {
1033 for (x = 0; x < plane->
width >> 2; x++) {
1039 for (x <<= 2; x < plane->
width; x++)
1040 *dst++ = *src++ << 1;
1042 src += pitch - plane->
width;
1043 dst += dst_pitch - plane->
width;
1068 int buf_size = avpkt->
size;
1114 (avctx->
height + 3) >> 2);
1117 (avctx->
height + 3) >> 2);
static int decode_cell(Indeo3DecodeContext *ctx, AVCodecContext *avctx, Plane *plane, Cell *cell, const uint8_t *data_ptr, const uint8_t *last_ptr)
Decode a vector-quantized cell.
discard all frames except keyframes
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
#define BS_8BIT_PEL
8bit pixel bitdepth indicator
const uint8_t * next_cell_data
FIXME Range Coding of cr are ref
static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx, Plane *plane, const uint8_t *data, int32_t data_size, int32_t strip_width)
int16_t xpos
cell coordinates in 4x4 blocks
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
const uint8_t * y_data_ptr
static av_cold int init(AVCodecContext *avctx)
int16_t height
cell height in 4x4 blocks
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
uint8_t quad_exp
log2 of four-pixel deltas
uint8_t num_dyads
number of two-pixel deltas
const uint8_t * v_data_ptr
#define RLE_LINES_COPY_M10
#define BS_BUFFER
indicates which of two frame buffers should be used
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_cold void free_frame_buffers(Indeo3DecodeContext *ctx)
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
uint32_t frame_num
current frame number (zero-based)
uint8_t buf_sel
active frame buffer: 0 - primary, 1 -secondary
output residual component w
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
struct Indeo3DecodeContext Indeo3DecodeContext
enum AVDiscard skip_frame
Skip decoding for selected frames.
#define BS_KEYFRAME
intra frame indicator
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
same as RLE_ESC_FD + do the same with next block
static av_cold int decode_close(AVCodecContext *avctx)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx, const uint8_t *buf, int buf_size)
static uint64_t replicate64(uint64_t a)
INTRA: skip block, INTER: copy data from reference.
const uint8_t * last_byte
static int get_bits_left(GetBitContext *gb)
apply null delta to N blocks / skip N blocks
static void output_plane(const Plane *plane, int buf_sel, uint8_t *dst, int dst_pitch, int dst_height)
Convert and output the current plane.
uint16_t frame_flags
frame properties
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
uint8_t cb_offset
needed for selecting VQ tables
static const vqEntry vq_tab[24]
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
apply null delta to all lines up to the 3rd line
static const uint8_t offset[127][2]
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
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...
#define BS_NONREF
nonref (discardable) frame indicator
uint8_t * pixels[2]
pointer to the actual pixel data of the buffers above
int width
picture width / height.
#define BS_MV_X_HALF
horizontal mv halfpel resolution indicator
const uint8_t * alt_quant
secondary VQ table set for the modes 1 and 4
static uint32_t replicate32(uint32_t a)
apply null delta to all remaining lines of this block
same as RLE_ESC_FA + do the same with next block
const int8_t * mv_ptr
ptr to the motion vector if any
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
or the Software in violation of any applicable export control laws in any jurisdiction Except as provided by mandatorily applicable UPF has no obligation to provide you with source code to the Software In the event Software contains any source code
static void fill_64(uint8_t *dst, const uint64_t pix, int32_t n, int32_t row_offset)
static int copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell)
Copy pixels of the cell(x + mv_x, y + mv_y) from the previous frame into the cell(x, y) in the current frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
const int8_t * mc_vectors
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define SPLIT_CELL(size, new_size)
op_pixels_func put_no_rnd_pixels_tab[4][4]
Halfpel motion compensation with no rounding (a+b)>>1.
synthesis window for stochastic i
int16_t width
cell width in 4x4 blocks
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static av_cold int decode_init(AVCodecContext *avctx)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx, Plane *plane, int code, Cell *ref_cell, const int depth, const int strip_width)
static av_cold int allocate_frame_buffers(Indeo3DecodeContext *ctx, AVCodecContext *avctx, int luma_width, int luma_height)
static av_cold void build_requant_tab(void)
discard all non reference
static uint8_t requant_tab[8][128]
common internal api header.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
unsigned num_vectors
number of motion vectors in mc_vectors
uint32_t data_size
size of the frame data in bytes
#define BS_MV_Y_HALF
vertical mv halfpel resolution indicator
static void copy_block4(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
else dst[i][x+y *dst_stride[i]]
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip please avoid problems through this extra level of scrutiny For cosmetics only commits you should e g by running git config global user name My Name git config global user email my email which is either set in your personal configuration file through git config core editor or set by one of the following environment VISUAL or EDITOR Log messages should be concise but descriptive Explain why you made a what you did will be obvious from the changes themselves most of the time Saying just bug fix or is bad Remember that people of varying skill levels look at and educate themselves while reading through your code Don t include filenames in log Git provides that information Possibly make the commit message have a descriptive first line
AVCodec ff_indeo3_decoder
apply null delta to all lines up to the 2nd line
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int decode_cell_data(Indeo3DecodeContext *ctx, Cell *cell, uint8_t *block, uint8_t *ref_block, int pitch, int h_zoom, int v_zoom, int mode, const vqEntry *delta[2], int swap_quads[2], const uint8_t **data_ptr, const uint8_t *last_ptr)
const uint8_t * u_data_ptr
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
uint8_t tree
tree id: 0- MC tree, 1 - VQ tree
In the ELBG jargon, a cell is the set of points that are closest to a codebook entry.
#define FFSWAP(type, a, b)
This structure stores compressed data.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
#define APPLY_DELTA_1011_INTER