50 |
*************************************************************************/ |
*************************************************************************/ |
51 |
|
|
52 |
#include <stdlib.h> |
#include <stdlib.h> |
53 |
#include <string.h> // memcpy, memset |
#include <string.h> /* memcpy, memset */ |
54 |
#include <math.h> |
#include <math.h> |
55 |
|
|
56 |
#include "../portab.h" |
#include "../portab.h" |
57 |
#include "../global.h" // XVID_CSP_XXX's |
#include "../global.h" /* XVID_CSP_XXX's */ |
58 |
#include "../xvid.h" // XVID_CSP_XXX's |
#include "../xvid.h" /* XVID_CSP_XXX's */ |
59 |
#include "image.h" |
#include "image.h" |
60 |
#include "colorspace.h" |
#include "colorspace.h" |
61 |
#include "interpolate8x8.h" |
#include "interpolate8x8.h" |
62 |
#include "reduced.h" |
#include "reduced.h" |
63 |
#include "../utils/mem_align.h" |
#include "../utils/mem_align.h" |
64 |
|
|
65 |
#include "font.h" // XXX: remove later |
#include "font.h" /* XXX: remove later */ |
66 |
|
|
67 |
#define SAFETY 64 |
#define SAFETY 64 |
68 |
#define EDGE_SIZE2 (EDGE_SIZE/2) |
#define EDGE_SIZE2 (EDGE_SIZE/2) |
191 |
} |
} |
192 |
|
|
193 |
|
|
194 |
//U |
/* U */ |
195 |
dst = image->u - (EDGE_SIZE2 + EDGE_SIZE2 * edged_width2); |
dst = image->u - (EDGE_SIZE2 + EDGE_SIZE2 * edged_width2); |
196 |
src = image->u; |
src = image->u; |
197 |
|
|
219 |
} |
} |
220 |
|
|
221 |
|
|
222 |
// V |
/* V */ |
223 |
dst = image->v - (EDGE_SIZE2 + EDGE_SIZE2 * edged_width2); |
dst = image->v - (EDGE_SIZE2 + EDGE_SIZE2 * edged_width2); |
224 |
src = image->v; |
src = image->v; |
225 |
|
|
247 |
} |
} |
248 |
} |
} |
249 |
|
|
250 |
// bframe encoding requires image-based u,v interpolation |
/* bframe encoding requires image-based u,v interpolation */ |
251 |
void |
void |
252 |
image_interpolate(const IMAGE * refn, |
image_interpolate(const IMAGE * refn, |
253 |
IMAGE * refh, |
IMAGE * refh, |
258 |
uint32_t quarterpel, |
uint32_t quarterpel, |
259 |
uint32_t rounding) |
uint32_t rounding) |
260 |
{ |
{ |
261 |
const uint32_t offset = EDGE_SIZE2 * (edged_width + 1); // we only interpolate half of the edge area |
const uint32_t offset = EDGE_SIZE2 * (edged_width + 1); /* we only interpolate half of the edge area */ |
262 |
const uint32_t stride_add = 7 * edged_width; |
const uint32_t stride_add = 7 * edged_width; |
263 |
/* |
#if 0 |
|
#ifdef BFRAMES |
|
264 |
const uint32_t edged_width2 = edged_width / 2; |
const uint32_t edged_width2 = edged_width / 2; |
265 |
const uint32_t edged_height2 = edged_height / 2; |
const uint32_t edged_height2 = edged_height / 2; |
266 |
const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1); |
const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1); |
267 |
const uint32_t stride_add2 = 7 * edged_width2; |
const uint32_t stride_add2 = 7 * edged_width2; |
268 |
#endif |
#endif |
|
*/ |
|
269 |
uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr; |
uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr; |
270 |
uint32_t x, y; |
uint32_t x, y; |
271 |
|
|
559 |
const int edged_width2 = edged_width/2; |
const int edged_width2 = edged_width/2; |
560 |
const int width2 = width/2; |
const int width2 = width/2; |
561 |
const int height2 = height/2; |
const int height2 = height/2; |
562 |
//const int height_signed = (csp & XVID_CSP_VFLIP) ? -height : height; |
#if 0 |
563 |
|
const int height_signed = (csp & XVID_CSP_VFLIP) ? -height : height; |
564 |
|
#endif |
565 |
|
|
566 |
switch (csp & ~XVID_CSP_VFLIP) { |
switch (csp & ~XVID_CSP_VFLIP) { |
567 |
case XVID_CSP_RGB555: |
case XVID_CSP_RGB555: |
790 |
interlacing?yv12_to_yuyvi_c:yv12_to_yuyv_c, 2); |
interlacing?yv12_to_yuyvi_c:yv12_to_yuyv_c, 2); |
791 |
return 0; |
return 0; |
792 |
|
|
793 |
case XVID_CSP_YVYU: // u,v swapped |
case XVID_CSP_YVYU: /* u,v swapped */ |
794 |
safe_packed_conv( |
safe_packed_conv( |
795 |
dst[0], dst_stride[0], image->y, image->v, image->u, |
dst[0], dst_stride[0], image->y, image->v, image->u, |
796 |
edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP), |
edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP), |
813 |
width, height, (csp & XVID_CSP_VFLIP)); |
width, height, (csp & XVID_CSP_VFLIP)); |
814 |
return 0; |
return 0; |
815 |
|
|
816 |
case XVID_CSP_YV12: // u,v swapped |
case XVID_CSP_YV12: /* u,v swapped */ |
817 |
yv12_to_yv12(dst[0], dst[0] + dst_stride[0]*height, dst[0] + dst_stride[0]*height + (dst_stride[0]/2)*height2, |
yv12_to_yv12(dst[0], dst[0] + dst_stride[0]*height, dst[0] + dst_stride[0]*height + (dst_stride[0]/2)*height2, |
818 |
dst_stride[0], dst_stride[0]/2, |
dst_stride[0], dst_stride[0]/2, |
819 |
image->y, image->v, image->u, edged_width, edged_width2, |
image->y, image->v, image->u, edged_width, edged_width2, |
820 |
width, height, (csp & XVID_CSP_VFLIP)); |
width, height, (csp & XVID_CSP_VFLIP)); |
821 |
return 0; |
return 0; |
822 |
|
|
823 |
case XVID_CSP_USER : // u,v swapped |
case XVID_CSP_USER : /* u,v swapped */ |
824 |
yv12_to_yv12(dst[0], dst[1], dst[2], |
yv12_to_yv12(dst[0], dst[1], dst[2], |
825 |
dst_stride[0], dst_stride[1], /* v: dst_stride[2] */ |
dst_stride[0], dst_stride[1], /* v: dst_stride[2] */ |
826 |
image->y, image->v, image->u, edged_width, edged_width2, |
image->y, image->v, image->u, edged_width, edged_width2, |
883 |
if (sse==0) |
if (sse==0) |
884 |
return 99.99F; |
return 99.99F; |
885 |
|
|
886 |
return 48.131F - 10*(float)log10((float)sse/(float)(pixels)); // log10(255*255)=4.8131 |
return 48.131F - 10*(float)log10((float)sse/(float)(pixels)); /* log10(255*255)=4.8131 */ |
887 |
|
|
888 |
} |
} |
889 |
|
|
907 |
return sse; |
return sse; |
908 |
} |
} |
909 |
|
|
910 |
/* |
#if 0 |
911 |
|
|
912 |
#include <stdio.h> |
#include <stdio.h> |
913 |
#include <string.h> |
#include <string.h> |
931 |
} |
} |
932 |
|
|
933 |
|
|
934 |
// dump image+edges to yuv pgm files |
/* dump image+edges to yuv pgm files */ |
935 |
|
|
936 |
int image_dump(IMAGE * image, uint32_t edged_width, uint32_t edged_height, char * path, int number) |
int image_dump(IMAGE * image, uint32_t edged_width, uint32_t edged_height, char * path, int number) |
937 |
{ |
{ |
954 |
|
|
955 |
return 0; |
return 0; |
956 |
} |
} |
957 |
*/ |
#endif |
958 |
|
|
959 |
|
|
960 |
|
|