46 |
#include "../utils/emms.h" |
#include "../utils/emms.h" |
47 |
#include "../dct/fdct.h" |
#include "../dct/fdct.h" |
48 |
|
|
49 |
|
/***************************************************************************** |
50 |
|
* Modified rounding tables -- declared in motion.h |
51 |
|
* Original tables see ISO spec tables 7-6 -> 7-9 |
52 |
|
****************************************************************************/ |
53 |
|
|
54 |
|
const uint32_t roundtab[16] = |
55 |
|
{0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 }; |
56 |
|
|
57 |
|
/* K = 4 */ |
58 |
|
const uint32_t roundtab_76[16] = |
59 |
|
{ 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1 }; |
60 |
|
|
61 |
|
/* K = 2 */ |
62 |
|
const uint32_t roundtab_78[8] = |
63 |
|
{ 0, 0, 1, 1, 0, 0, 0, 1 }; |
64 |
|
|
65 |
|
/* K = 1 */ |
66 |
|
const uint32_t roundtab_79[4] = |
67 |
|
{ 0, 1, 0, 0 }; |
68 |
|
|
69 |
#define INITIAL_SKIP_THRESH (10) |
#define INITIAL_SKIP_THRESH (10) |
70 |
#define FINAL_SKIP_THRESH (50) |
#define FINAL_SKIP_THRESH (50) |
71 |
#define MAX_SAD00_FOR_SKIP (20) |
#define MAX_SAD00_FOR_SKIP (20) |
74 |
#define CHECK_CANDIDATE(X,Y,D) { \ |
#define CHECK_CANDIDATE(X,Y,D) { \ |
75 |
CheckCandidate((X),(Y), (D), &iDirection, data ); } |
CheckCandidate((X),(Y), (D), &iDirection, data ); } |
76 |
|
|
77 |
|
/***************************************************************************** |
78 |
|
* Code |
79 |
|
****************************************************************************/ |
80 |
|
|
81 |
static __inline uint32_t |
static __inline uint32_t |
82 |
d_mv_bits(int x, int y, const VECTOR pred, const uint32_t iFcode, const int qpel, const int rrv) |
d_mv_bits(int x, int y, const VECTOR pred, const uint32_t iFcode, const int qpel, const int rrv) |
83 |
{ |
{ |
2303 |
|
|
2304 |
// filter mask of all blocks |
// filter mask of all blocks |
2305 |
|
|
2306 |
for (my = 1; my < MBh-1; my++) |
for (my = 1; my < (uint32_t)MBh-1; my++) |
2307 |
for (mx = 1; mx < MBw-1; mx++) |
for (mx = 1; mx < (uint32_t)MBw-1; mx++) |
2308 |
{ |
{ |
2309 |
const int mbnum = mx + my * MBw; |
const int mbnum = mx + my * MBw; |
2310 |
const MACROBLOCK *pMB = &pMBs[mbnum]; |
const MACROBLOCK *pMB = &pMBs[mbnum]; |
2320 |
MBmask[mbnum]=1; |
MBmask[mbnum]=1; |
2321 |
} |
} |
2322 |
|
|
2323 |
for (my = 1; my < MBh-1; my++) |
for (my = 1; my < (uint32_t)MBh-1; my++) |
2324 |
for (mx = 1; mx < MBw-1; mx++) |
for (mx = 1; mx < (uint32_t)MBw-1; mx++) |
2325 |
{ |
{ |
2326 |
const uint8_t *const pCur = current->image.y + 16*my*pParam->edged_width + 16*mx; |
const uint8_t *const pCur = current->image.y + 16*my*pParam->edged_width + 16*mx; |
2327 |
|
|
2329 |
if (!MBmask[mbnum]) |
if (!MBmask[mbnum]) |
2330 |
continue; |
continue; |
2331 |
|
|
2332 |
if (sad16 ( pCur, pCur+1 , pParam->edged_width, 65536) <= grad ) |
if (sad16 ( pCur, pCur+1 , pParam->edged_width, 65536) <= (uint32_t)grad ) |
2333 |
MBmask[mbnum] = 0; |
MBmask[mbnum] = 0; |
2334 |
if (sad16 ( pCur, pCur+pParam->edged_width, pParam->edged_width, 65536) <= grad ) |
if (sad16 ( pCur, pCur+pParam->edged_width, pParam->edged_width, 65536) <= (uint32_t)grad ) |
2335 |
MBmask[mbnum] = 0; |
MBmask[mbnum] = 0; |
2336 |
|
|
2337 |
} |
} |
2342 |
|
|
2343 |
a = b = c = n = 0; |
a = b = c = n = 0; |
2344 |
DtimesF[0] = DtimesF[1] = DtimesF[2] = DtimesF[3] = 0.; |
DtimesF[0] = DtimesF[1] = DtimesF[2] = DtimesF[3] = 0.; |
2345 |
for (my = 0; my < MBh; my++) |
for (my = 0; my < (uint32_t)MBh; my++) |
2346 |
for (mx = 0; mx < MBw; mx++) |
for (mx = 0; mx < (uint32_t)MBw; mx++) |
2347 |
{ |
{ |
2348 |
const int mbnum = mx + my * MBw; |
const int mbnum = mx + my * MBw; |
2349 |
const MACROBLOCK *pMB = &pMBs[mbnum]; |
const MACROBLOCK *pMB = &pMBs[mbnum]; |
2380 |
|
|
2381 |
meanx = meany = 0.; |
meanx = meany = 0.; |
2382 |
oldnum = 0; |
oldnum = 0; |
2383 |
for (my = 0; my < MBh; my++) |
for (my = 0; my < (uint32_t)MBh; my++) |
2384 |
for (mx = 0; mx < MBw; mx++) |
for (mx = 0; mx < (uint32_t)MBw; mx++) |
2385 |
{ |
{ |
2386 |
const int mbnum = mx + my * MBw; |
const int mbnum = mx + my * MBw; |
2387 |
const MACROBLOCK *pMB = &pMBs[mbnum]; |
const MACROBLOCK *pMB = &pMBs[mbnum]; |
2409 |
fprintf(stderr,"meanx = %8.5f meany = %8.5f %d\n",meanx,meany, oldnum); |
fprintf(stderr,"meanx = %8.5f meany = %8.5f %d\n",meanx,meany, oldnum); |
2410 |
*/ |
*/ |
2411 |
num = 0; |
num = 0; |
2412 |
for (my = 0; my < MBh; my++) |
for (my = 0; my < (uint32_t)MBh; my++) |
2413 |
for (mx = 0; mx < MBw; mx++) |
for (mx = 0; mx < (uint32_t)MBw; mx++) |
2414 |
{ |
{ |
2415 |
const int mbnum = mx + my * MBw; |
const int mbnum = mx + my * MBw; |
2416 |
const MACROBLOCK *pMB = &pMBs[mbnum]; |
const MACROBLOCK *pMB = &pMBs[mbnum]; |