Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp94
-rw-r--r--src/filters/source/D2VSource/MPEG2Dec.cpp7619
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/simple_idct_mmx.c400
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libswscale/swscale_template.c4288
-rw-r--r--src/filters/transform/MpaDecFilter/libflac/src/libFLAC/ia32/nasm.h161
5 files changed, 6229 insertions, 6333 deletions
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp
index 1863a8f4d..c6c542467 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp
@@ -2,8 +2,8 @@
///
/// Win32 version of the x86 CPU detect routine.
///
-/// This file is to be compiled in Windows platform with Microsoft Visual C++
-/// Compiler. Please see 'cpu_detect_x86_gcc.cpp' for the gcc compiler version
+/// This file is to be compiled in Windows platform with Microsoft Visual C++
+/// Compiler. Please see 'cpu_detect_x86_gcc.cpp' for the gcc compiler version
/// for all GNU platforms.
///
/// Author : Copyright (c) Olli Parviainen
@@ -69,85 +69,61 @@ uint detectCPUextensions(void)
{
uint res = 0;
- if(_dwDisabledISA == 0xffffffff) return 0;
+ if (_dwDisabledISA == 0xffffffff) return 0;
- _asm
+ _asm
{
+ ; check if 'cpuid' instructions is available by toggling eflags bit 21
;
- check if 'cpuid' instructions is available by toggling eflags bit 21
- ;
- xor esi, esi ;
- clear esi = result register
-
- pushfd ;
- save eflags to stack
- mov eax, dword ptr [esp] ;
- load eax from stack(with eflags)
- mov ecx, eax ;
- save the original eflags values to ecx
- xor eax, 0x00200000 ;
- toggle bit 21
- mov dword ptr [esp], eax ;
- store toggled eflags to stack
- popfd ;
- load eflags from stack
-
- pushfd ;
- save updated eflags to stack
- mov eax, dword ptr [esp] ;
- load eax from stack
- popfd ;
- pop stack to restore stack pointer
-
- xor edx, edx ;
- clear edx for defaulting no mmx
- cmp eax, ecx ;
- compare to original eflags values
- jz end ;
- jumps to 'end' if cpuid not present
+ xor esi, esi ; clear esi = result register
- ;
- cpuid instruction available, test for presence of mmx instructions
+ pushfd ; save eflags to stack
+ mov eax,dword ptr [esp] ; load eax from stack (with eflags)
+ mov ecx, eax ; save the original eflags values to ecx
+ xor eax, 0x00200000 ; toggle bit 21
+ mov dword ptr [esp],eax ; store toggled eflags to stack
+ popfd ; load eflags from stack
+
+ pushfd ; save updated eflags to stack
+ mov eax,dword ptr [esp] ; load eax from stack
+ popfd ; pop stack to restore stack pointer
+
+ xor edx, edx ; clear edx for defaulting no mmx
+ cmp eax, ecx ; compare to original eflags values
+ jz end ; jumps to 'end' if cpuid not present
+
+ ; cpuid instruction available, test for presence of mmx instructions
mov eax, 1
cpuid
test edx, 0x00800000
- jz end ;
- branch if MMX not available
+ jz end ; branch if MMX not available
- or esi, SUPPORT_MMX ;
- otherwise add MMX support bit
+ or esi, SUPPORT_MMX ; otherwise add MMX support bit
- test edx, 0x02000000
- jz test3DNow ;
- branch if SSE not available
+ test edx, 0x02000000
+ jz test3DNow ; branch if SSE not available
- or esi, SUPPORT_SSE ;
- otherwise add SSE support bit
+ or esi, SUPPORT_SSE ; otherwise add SSE support bit
test3DNow:
- ;
- test for precense of AMD extensions
+ ; test for precense of AMD extensions
mov eax, 0x80000000
cpuid
cmp eax, 0x80000000
- jbe end ;
- branch if no AMD extensions detected
+ jbe end ; branch if no AMD extensions detected
- ;
- test for precense of 3DNow! extension
+ ; test for precense of 3DNow! extension
mov eax, 0x80000001
cpuid
test edx, 0x80000000
- jz end ;
- branch if 3DNow! not detected
+ jz end ; branch if 3DNow! not detected
- or esi, SUPPORT_3DNOW ;
- otherwise add 3DNow support bit
+ or esi, SUPPORT_3DNOW ; otherwise add 3DNow support bit
end:
- mov res, esi
-}
+ mov res, esi
+ }
-return res & ~_dwDisabledISA;
+ return res & ~_dwDisabledISA;
}
diff --git a/src/filters/source/D2VSource/MPEG2Dec.cpp b/src/filters/source/D2VSource/MPEG2Dec.cpp
index c8c4758ed..4be664c00 100644
--- a/src/filters/source/D2VSource/MPEG2Dec.cpp
+++ b/src/filters/source/D2VSource/MPEG2Dec.cpp
@@ -3,40 +3,39 @@
int testint;
-struct CPU
-{
- BOOL mmx;
- BOOL _3dnow;
- BOOL ssemmx;
- BOOL ssefpu;
+struct CPU {
+ BOOL mmx;
+ BOOL _3dnow;
+ BOOL ssemmx;
+ BOOL ssefpu;
} cpu;
void CheckCPU()
{
- __asm
- {
- mov eax, 1
- cpuid
- test edx, 0x00800000 // STD MMX
- jz TEST_SSE
- mov [cpu.mmx], 1
- TEST_SSE:
- test edx, 0x02000000 // STD SSE
- jz TEST_3DNOW
- mov [cpu.ssemmx], 1
- mov [cpu.ssefpu], 1
- TEST_3DNOW:
- mov eax, 0x80000001
- cpuid
- test edx, 0x80000000 // 3D NOW
- jz TEST_SSEMMX
- mov [cpu._3dnow], 1
- TEST_SSEMMX:
- test edx, 0x00400000 // SSE MMX
- jz TEST_END
- mov [cpu.ssemmx], 1
- TEST_END:
- }
+ __asm
+ {
+ mov eax, 1
+ cpuid
+ test edx, 0x00800000 // STD MMX
+ jz TEST_SSE
+ mov [cpu.mmx], 1
+TEST_SSE:
+ test edx, 0x02000000 // STD SSE
+ jz TEST_3DNOW
+ mov [cpu.ssemmx], 1
+ mov [cpu.ssefpu], 1
+TEST_3DNOW:
+ mov eax, 0x80000001
+ cpuid
+ test edx, 0x80000000 // 3D NOW
+ jz TEST_SSEMMX
+ mov [cpu._3dnow], 1
+TEST_SSEMMX:
+ test edx, 0x00400000 // SSE MMX
+ jz TEST_END
+ mov [cpu.ssemmx], 1
+TEST_END:
+ }
}
#pragma warning(disable:4799) // no EMMS
@@ -52,170 +51,168 @@ extern void REF_IDCT(short *block);
/* default intra quantization matrix */
static unsigned char default_intra_quantizer_matrix[64] =
{
- 8, 16, 19, 22, 26, 27, 29, 34,
- 16, 16, 22, 24, 27, 29, 34, 37,
- 19, 22, 26, 27, 29, 34, 34, 38,
- 22, 22, 26, 27, 29, 34, 37, 40,
- 22, 26, 27, 29, 32, 35, 40, 48,
- 26, 27, 29, 32, 35, 40, 48, 58,
- 26, 27, 29, 34, 38, 46, 56, 69,
- 27, 29, 35, 38, 46, 56, 69, 83
+ 8, 16, 19, 22, 26, 27, 29, 34,
+ 16, 16, 22, 24, 27, 29, 34, 37,
+ 19, 22, 26, 27, 29, 34, 34, 38,
+ 22, 22, 26, 27, 29, 34, 37, 40,
+ 22, 26, 27, 29, 32, 35, 40, 48,
+ 26, 27, 29, 32, 35, 40, 48, 58,
+ 26, 27, 29, 34, 38, 46, 56, 69,
+ 27, 29, 35, 38, 46, 56, 69, 83
};
/* zig-zag and alternate scan patterns */
static unsigned char scan[2][64] =
{
- { /* Zig-Zag scan pattern */
- 0, 1, 8, 16, 9, 2, 3, 10,
- 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34,
- 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36,
- 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46,
- 53, 60, 61, 54, 47, 55, 62, 63
- }
- ,
- { /* Alternate scan pattern */
- 0, 8, 16, 24, 1, 9, 2, 10,
- 17, 25, 32, 40, 48, 56, 57, 49,
- 41, 33, 26, 18, 3, 11, 4, 12,
- 19, 27, 34, 42, 50, 58, 35, 43,
- 51, 59, 20, 28, 5, 13, 6, 14,
- 21, 29, 36, 44, 52, 60, 37, 45,
- 53, 61, 22, 30, 7, 15, 23, 31,
- 38, 46, 54, 62, 39, 47, 55, 63
- }
+ { /* Zig-Zag scan pattern */
+ 0, 1, 8, 16, 9, 2, 3, 10,
+ 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34,
+ 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36,
+ 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46,
+ 53, 60, 61, 54, 47, 55, 62, 63
+ }
+ ,
+ { /* Alternate scan pattern */
+ 0, 8, 16, 24, 1, 9, 2, 10,
+ 17, 25, 32, 40, 48, 56, 57, 49,
+ 41, 33, 26, 18, 3, 11, 4, 12,
+ 19, 27, 34, 42, 50, 58, 35, 43,
+ 51, 59, 20, 28, 5, 13, 6, 14,
+ 21, 29, 36, 44, 52, 60, 37, 45,
+ 53, 61, 22, 30, 7, 15, 23, 31,
+ 38, 46, 54, 62, 39, 47, 55, 63
+ }
};
/* non-linear quantization coefficient table */
static unsigned char Non_Linear_quantizer_scale[32] =
{
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 10, 12, 14, 16, 18, 20, 22,
- 24, 28, 32, 36, 40, 44, 48, 52,
- 56, 64, 72, 80, 88, 96, 104, 112
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 10, 12, 14, 16, 18, 20, 22,
+ 24, 28, 32, 36, 40, 44, 48, 52,
+ 56, 64, 72, 80, 88, 96, 104, 112
};
#define ERROR_VALUE (-1)
-typedef struct
-{
- char run, level, len;
+typedef struct {
+ char run, level, len;
} DCTtab;
-typedef struct
-{
- char val, len;
+typedef struct {
+ char val, len;
} VLCtab;
/* Table B-10, motion_code, codes 0001 ... 01xx */
static VLCtab MVtab0[8] =
{
- {ERROR_VALUE, 0}, {3, 3}, {2, 2}, {2, 2}, {1, 1}, {1, 1}, {1, 1}, {1, 1}
+ {ERROR_VALUE,0}, {3,3}, {2,2}, {2,2}, {1,1}, {1,1}, {1,1}, {1,1}
};
/* Table B-10, motion_code, codes 0000011 ... 000011x */
static VLCtab MVtab1[8] =
{
- {ERROR_VALUE, 0}, {ERROR_VALUE, 0}, {ERROR_VALUE, 0}, {7, 6}, {6, 6}, {5, 6}, {4, 5}, {4, 5}
+ {ERROR_VALUE,0}, {ERROR_VALUE,0}, {ERROR_VALUE,0}, {7,6}, {6,6}, {5,6}, {4,5}, {4,5}
};
/* Table B-10, motion_code, codes 0000001100 ... 000001011x */
static VLCtab MVtab2[12] =
{
- {16, 9}, {15, 9}, {14, 9}, {13, 9},
- {12, 9}, {11, 9}, {10, 8}, {10, 8},
- {9, 8}, {9, 8}, {8, 8}, {8, 8}
+ {16,9}, {15,9}, {14,9}, {13,9},
+ {12,9}, {11,9}, {10,8}, {10,8},
+ {9,8}, {9,8}, {8,8}, {8,8}
};
/* Table B-9, coded_block_pattern, codes 01000 ... 111xx */
static VLCtab CBPtab0[32] =
{
- {ERROR_VALUE, 0}, {ERROR_VALUE, 0}, {ERROR_VALUE, 0}, {ERROR_VALUE, 0},
- {ERROR_VALUE, 0}, {ERROR_VALUE, 0}, {ERROR_VALUE, 0}, {ERROR_VALUE, 0},
- {62, 5}, {2, 5}, {61, 5}, {1, 5}, {56, 5}, {52, 5}, {44, 5}, {28, 5},
- {40, 5}, {20, 5}, {48, 5}, {12, 5}, {32, 4}, {32, 4}, {16, 4}, {16, 4},
- {8, 4}, {8, 4}, {4, 4}, {4, 4}, {60, 3}, {60, 3}, {60, 3}, {60, 3}
+ {ERROR_VALUE,0}, {ERROR_VALUE,0}, {ERROR_VALUE,0}, {ERROR_VALUE,0},
+ {ERROR_VALUE,0}, {ERROR_VALUE,0}, {ERROR_VALUE,0}, {ERROR_VALUE,0},
+ {62,5}, {2,5}, {61,5}, {1,5}, {56,5}, {52,5}, {44,5}, {28,5},
+ {40,5}, {20,5}, {48,5}, {12,5}, {32,4}, {32,4}, {16,4}, {16,4},
+ {8,4}, {8,4}, {4,4}, {4,4}, {60,3}, {60,3}, {60,3}, {60,3}
};
/* Table B-9, coded_block_pattern, codes 00000100 ... 001111xx */
static VLCtab CBPtab1[64] =
{
- {ERROR_VALUE, 0}, {ERROR_VALUE, 0}, {ERROR_VALUE, 0}, {ERROR_VALUE, 0},
- {58, 8}, {54, 8}, {46, 8}, {30, 8},
- {57, 8}, {53, 8}, {45, 8}, {29, 8}, {38, 8}, {26, 8}, {37, 8}, {25, 8},
- {43, 8}, {23, 8}, {51, 8}, {15, 8}, {42, 8}, {22, 8}, {50, 8}, {14, 8},
- {41, 8}, {21, 8}, {49, 8}, {13, 8}, {35, 8}, {19, 8}, {11, 8}, {7, 8},
- {34, 7}, {34, 7}, {18, 7}, {18, 7}, {10, 7}, {10, 7}, {6, 7}, {6, 7},
- {33, 7}, {33, 7}, {17, 7}, {17, 7}, {9, 7}, {9, 7}, {5, 7}, {5, 7},
- {63, 6}, {63, 6}, {63, 6}, {63, 6}, {3, 6}, {3, 6}, {3, 6}, {3, 6},
- {36, 6}, {36, 6}, {36, 6}, {36, 6}, {24, 6}, {24, 6}, {24, 6}, {24, 6}
+ {ERROR_VALUE,0}, {ERROR_VALUE,0}, {ERROR_VALUE,0}, {ERROR_VALUE,0},
+ {58,8}, {54,8}, {46,8}, {30,8},
+ {57,8}, {53,8}, {45,8}, {29,8}, {38,8}, {26,8}, {37,8}, {25,8},
+ {43,8}, {23,8}, {51,8}, {15,8}, {42,8}, {22,8}, {50,8}, {14,8},
+ {41,8}, {21,8}, {49,8}, {13,8}, {35,8}, {19,8}, {11,8}, {7,8},
+ {34,7}, {34,7}, {18,7}, {18,7}, {10,7}, {10,7}, {6,7}, {6,7},
+ {33,7}, {33,7}, {17,7}, {17,7}, {9,7}, {9,7}, {5,7}, {5,7},
+ {63,6}, {63,6}, {63,6}, {63,6}, {3,6}, {3,6}, {3,6}, {3,6},
+ {36,6}, {36,6}, {36,6}, {36,6}, {24,6}, {24,6}, {24,6}, {24,6}
};
/* Table B-9, coded_block_pattern, codes 000000001 ... 000000111 */
static VLCtab CBPtab2[8] =
{
- {ERROR_VALUE, 0}, {0, 9}, {39, 9}, {27, 9}, {59, 9}, {55, 9}, {47, 9}, {31, 9}
+ {ERROR_VALUE,0}, {0,9}, {39,9}, {27,9}, {59,9}, {55,9}, {47,9}, {31,9}
};
/* Table B-1, macroblock_address_increment, codes 00010 ... 011xx */
static VLCtab MBAtab1[16] =
{
- {ERROR_VALUE, 0}, {ERROR_VALUE, 0}, {7, 5}, {6, 5}, {5, 4}, {5, 4}, {4, 4},
- {4, 4}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}
+ {ERROR_VALUE,0}, {ERROR_VALUE,0}, {7,5}, {6,5}, {5,4}, {5,4}, {4,4},
+ {4,4}, {3,3}, {3,3}, {3,3}, {3,3}, {2,3}, {2,3}, {2,3}, {2,3}
};
/* Table B-1, macroblock_address_increment, codes 00000011000 ... 0000111xxxx */
static VLCtab MBAtab2[104] =
{
- {33, 11}, {32, 11}, {31, 11}, {30, 11}, {29, 11}, {28, 11}, {27, 11}, {26, 11},
- {25, 11}, {24, 11}, {23, 11}, {22, 11}, {21, 10}, {21, 10}, {20, 10}, {20, 10},
- {19, 10}, {19, 10}, {18, 10}, {18, 10}, {17, 10}, {17, 10}, {16, 10}, {16, 10},
- {15, 8}, {15, 8}, {15, 8}, {15, 8}, {15, 8}, {15, 8}, {15, 8}, {15, 8},
- {14, 8}, {14, 8}, {14, 8}, {14, 8}, {14, 8}, {14, 8}, {14, 8}, {14, 8},
- {13, 8}, {13, 8}, {13, 8}, {13, 8}, {13, 8}, {13, 8}, {13, 8}, {13, 8},
- {12, 8}, {12, 8}, {12, 8}, {12, 8}, {12, 8}, {12, 8}, {12, 8}, {12, 8},
- {11, 8}, {11, 8}, {11, 8}, {11, 8}, {11, 8}, {11, 8}, {11, 8}, {11, 8},
- {10, 8}, {10, 8}, {10, 8}, {10, 8}, {10, 8}, {10, 8}, {10, 8}, {10, 8},
- {9, 7}, {9, 7}, {9, 7}, {9, 7}, {9, 7}, {9, 7}, {9, 7}, {9, 7},
- {9, 7}, {9, 7}, {9, 7}, {9, 7}, {9, 7}, {9, 7}, {9, 7}, {9, 7},
- {8, 7}, {8, 7}, {8, 7}, {8, 7}, {8, 7}, {8, 7}, {8, 7}, {8, 7},
- {8, 7}, {8, 7}, {8, 7}, {8, 7}, {8, 7}, {8, 7}, {8, 7}, {8, 7}
+ {33,11}, {32,11}, {31,11}, {30,11}, {29,11}, {28,11}, {27,11}, {26,11},
+ {25,11}, {24,11}, {23,11}, {22,11}, {21,10}, {21,10}, {20,10}, {20,10},
+ {19,10}, {19,10}, {18,10}, {18,10}, {17,10}, {17,10}, {16,10}, {16,10},
+ {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8},
+ {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8},
+ {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8},
+ {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8},
+ {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8},
+ {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8},
+ {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7},
+ {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7},
+ {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7},
+ {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}
};
/* Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110 */
static VLCtab DClumtab0[32] =
{
- {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
- {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
- {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
- {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}, {ERROR_VALUE, 0}
+ {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
+ {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
+ {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
+ {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}, {ERROR_VALUE, 0}
};
/* Table B-12, dct_dc_size_luminance, codes 111110xxx ... 111111111 */
static VLCtab DClumtab1[16] =
{
- {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6},
- {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10, 9}, {11, 9}
+ {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6},
+ {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10,9}, {11,9}
};
/* Table B-13, dct_dc_size_chrominance, codes 00xxx ... 11110 */
static VLCtab DCchromtab0[32] =
{
- {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
- {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
- {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
- {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}, {ERROR_VALUE, 0}
+ {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
+ {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
+ {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
+ {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}, {ERROR_VALUE, 0}
};
/* Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */
static VLCtab DCchromtab1[32] =
{
- {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
- {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
- {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7},
- {8, 8}, {8, 8}, {8, 8}, {8, 8}, {9, 9}, {9, 9}, {10, 10}, {11, 10}
+ {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
+ {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
+ {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7},
+ {8, 8}, {8, 8}, {8, 8}, {8, 8}, {9, 9}, {9, 9}, {10,10}, {11,10}
};
/* Table B-14, DCT coefficients table zero,
@@ -223,9 +220,9 @@ static VLCtab DCchromtab1[32] =
*/
static DCTtab DCTtabfirst[12] =
{
- {0, 2, 4}, {2, 1, 4}, {1, 1, 3}, {1, 1, 3},
- {0, 1, 1}, {0, 1, 1}, {0, 1, 1}, {0, 1, 1},
- {0, 1, 1}, {0, 1, 1}, {0, 1, 1}, {0, 1, 1}
+ {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3},
+ {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1},
+ {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1}
};
/* Table B-14, DCT coefficients table zero,
@@ -233,9 +230,9 @@ static DCTtab DCTtabfirst[12] =
*/
static DCTtab DCTtabnext[12] =
{
- {0, 2, 4}, {2, 1, 4}, {1, 1, 3}, {1, 1, 3},
- {64, 0, 2}, {64, 0, 2}, {64, 0, 2}, {64, 0, 2}, /* EOB */
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2}
+ {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3},
+ {64,0,2}, {64,0,2}, {64,0,2}, {64,0,2}, /* EOB */
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}
};
/* Table B-14, DCT coefficients table zero,
@@ -243,21 +240,21 @@ static DCTtab DCTtabnext[12] =
*/
static DCTtab DCTtab0[60] =
{
- {65, 0, 6}, {65, 0, 6}, {65, 0, 6}, {65, 0, 6}, /* Escape */
- {2, 2, 7}, {2, 2, 7}, {9, 1, 7}, {9, 1, 7},
- {0, 4, 7}, {0, 4, 7}, {8, 1, 7}, {8, 1, 7},
- {7, 1, 6}, {7, 1, 6}, {7, 1, 6}, {7, 1, 6},
- {6, 1, 6}, {6, 1, 6}, {6, 1, 6}, {6, 1, 6},
- {1, 2, 6}, {1, 2, 6}, {1, 2, 6}, {1, 2, 6},
- {5, 1, 6}, {5, 1, 6}, {5, 1, 6}, {5, 1, 6},
- {13, 1, 8}, {0, 6, 8}, {12, 1, 8}, {11, 1, 8},
- {3, 2, 8}, {1, 3, 8}, {0, 5, 8}, {10, 1, 8},
- {0, 3, 5}, {0, 3, 5}, {0, 3, 5}, {0, 3, 5},
- {0, 3, 5}, {0, 3, 5}, {0, 3, 5}, {0, 3, 5},
- {4, 1, 5}, {4, 1, 5}, {4, 1, 5}, {4, 1, 5},
- {4, 1, 5}, {4, 1, 5}, {4, 1, 5}, {4, 1, 5},
- {3, 1, 5}, {3, 1, 5}, {3, 1, 5}, {3, 1, 5},
- {3, 1, 5}, {3, 1, 5}, {3, 1, 5}, {3, 1, 5}
+ {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */
+ {2,2,7}, {2,2,7}, {9,1,7}, {9,1,7},
+ {0,4,7}, {0,4,7}, {8,1,7}, {8,1,7},
+ {7,1,6}, {7,1,6}, {7,1,6}, {7,1,6},
+ {6,1,6}, {6,1,6}, {6,1,6}, {6,1,6},
+ {1,2,6}, {1,2,6}, {1,2,6}, {1,2,6},
+ {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6},
+ {13,1,8}, {0,6,8}, {12,1,8}, {11,1,8},
+ {3,2,8}, {1,3,8}, {0,5,8}, {10,1,8},
+ {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5},
+ {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5},
+ {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5},
+ {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5},
+ {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
+ {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}
};
/* Table B-15, DCT coefficients table one,
@@ -265,69 +262,69 @@ static DCTtab DCTtab0[60] =
*/
static DCTtab DCTtab0a[252] =
{
- {65, 0, 6}, {65, 0, 6}, {65, 0, 6}, {65, 0, 6}, /* Escape */
- {7, 1, 7}, {7, 1, 7}, {8, 1, 7}, {8, 1, 7},
- {6, 1, 7}, {6, 1, 7}, {2, 2, 7}, {2, 2, 7},
- {0, 7, 6}, {0, 7, 6}, {0, 7, 6}, {0, 7, 6},
- {0, 6, 6}, {0, 6, 6}, {0, 6, 6}, {0, 6, 6},
- {4, 1, 6}, {4, 1, 6}, {4, 1, 6}, {4, 1, 6},
- {5, 1, 6}, {5, 1, 6}, {5, 1, 6}, {5, 1, 6},
- {1, 5, 8}, {11, 1, 8}, {0, 11, 8}, {0, 10, 8},
- {13, 1, 8}, {12, 1, 8}, {3, 2, 8}, {1, 4, 8},
- {2, 1, 5}, {2, 1, 5}, {2, 1, 5}, {2, 1, 5},
- {2, 1, 5}, {2, 1, 5}, {2, 1, 5}, {2, 1, 5},
- {1, 2, 5}, {1, 2, 5}, {1, 2, 5}, {1, 2, 5},
- {1, 2, 5}, {1, 2, 5}, {1, 2, 5}, {1, 2, 5},
- {3, 1, 5}, {3, 1, 5}, {3, 1, 5}, {3, 1, 5},
- {3, 1, 5}, {3, 1, 5}, {3, 1, 5}, {3, 1, 5},
- {1, 1, 3}, {1, 1, 3}, {1, 1, 3}, {1, 1, 3},
- {1, 1, 3}, {1, 1, 3}, {1, 1, 3}, {1, 1, 3},
- {1, 1, 3}, {1, 1, 3}, {1, 1, 3}, {1, 1, 3},
- {1, 1, 3}, {1, 1, 3}, {1, 1, 3}, {1, 1, 3},
- {1, 1, 3}, {1, 1, 3}, {1, 1, 3}, {1, 1, 3},
- {1, 1, 3}, {1, 1, 3}, {1, 1, 3}, {1, 1, 3},
- {1, 1, 3}, {1, 1, 3}, {1, 1, 3}, {1, 1, 3},
- {1, 1, 3}, {1, 1, 3}, {1, 1, 3}, {1, 1, 3},
- {64, 0, 4}, {64, 0, 4}, {64, 0, 4}, {64, 0, 4}, /* EOB */
- {64, 0, 4}, {64, 0, 4}, {64, 0, 4}, {64, 0, 4},
- {64, 0, 4}, {64, 0, 4}, {64, 0, 4}, {64, 0, 4},
- {64, 0, 4}, {64, 0, 4}, {64, 0, 4}, {64, 0, 4},
- {0, 3, 4}, {0, 3, 4}, {0, 3, 4}, {0, 3, 4},
- {0, 3, 4}, {0, 3, 4}, {0, 3, 4}, {0, 3, 4},
- {0, 3, 4}, {0, 3, 4}, {0, 3, 4}, {0, 3, 4},
- {0, 3, 4}, {0, 3, 4}, {0, 3, 4}, {0, 3, 4},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 2},
- {0, 2, 3}, {0, 2, 3}, {0, 2, 3}, {0, 2, 3},
- {0, 2, 3}, {0, 2, 3}, {0, 2, 3}, {0, 2, 3},
- {0, 2, 3}, {0, 2, 3}, {0, 2, 3}, {0, 2, 3},
- {0, 2, 3}, {0, 2, 3}, {0, 2, 3}, {0, 2, 3},
- {0, 2, 3}, {0, 2, 3}, {0, 2, 3}, {0, 2, 3},
- {0, 2, 3}, {0, 2, 3}, {0, 2, 3}, {0, 2, 3},
- {0, 2, 3}, {0, 2, 3}, {0, 2, 3}, {0, 2, 3},
- {0, 2, 3}, {0, 2, 3}, {0, 2, 3}, {0, 2, 3},
- {0, 4, 5}, {0, 4, 5}, {0, 4, 5}, {0, 4, 5},
- {0, 4, 5}, {0, 4, 5}, {0, 4, 5}, {0, 4, 5},
- {0, 5, 5}, {0, 5, 5}, {0, 5, 5}, {0, 5, 5},
- {0, 5, 5}, {0, 5, 5}, {0, 5, 5}, {0, 5, 5},
- {9, 1, 7}, {9, 1, 7}, {1, 3, 7}, {1, 3, 7},
- {10, 1, 7}, {10, 1, 7}, {0, 8, 7}, {0, 8, 7},
- {0, 9, 7}, {0, 9, 7}, {0, 12, 8}, {0, 13, 8},
- {2, 3, 8}, {4, 2, 8}, {0, 14, 8}, {0, 15, 8}
+ {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */
+ {7,1,7}, {7,1,7}, {8,1,7}, {8,1,7},
+ {6,1,7}, {6,1,7}, {2,2,7}, {2,2,7},
+ {0,7,6}, {0,7,6}, {0,7,6}, {0,7,6},
+ {0,6,6}, {0,6,6}, {0,6,6}, {0,6,6},
+ {4,1,6}, {4,1,6}, {4,1,6}, {4,1,6},
+ {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6},
+ {1,5,8}, {11,1,8}, {0,11,8}, {0,10,8},
+ {13,1,8}, {12,1,8}, {3,2,8}, {1,4,8},
+ {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5},
+ {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5},
+ {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5},
+ {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5},
+ {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
+ {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
+ {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
+ {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
+ {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
+ {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
+ {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
+ {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
+ {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
+ {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
+ {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, /* EOB */
+ {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
+ {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
+ {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
+ {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
+ {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
+ {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
+ {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
+ {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
+ {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
+ {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
+ {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
+ {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
+ {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
+ {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
+ {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
+ {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5},
+ {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5},
+ {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5},
+ {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5},
+ {9,1,7}, {9,1,7}, {1,3,7}, {1,3,7},
+ {10,1,7}, {10,1,7}, {0,8,7}, {0,8,7},
+ {0,9,7}, {0,9,7}, {0,12,8}, {0,13,8},
+ {2,3,8}, {4,2,8}, {0,14,8}, {0,15,8}
};
/* Table B-14, DCT coefficients table zero,
@@ -335,8 +332,8 @@ static DCTtab DCTtab0a[252] =
*/
static DCTtab DCTtab1[8] =
{
- {16, 1, 10}, {5, 2, 10}, {0, 7, 10}, {2, 3, 10},
- {1, 4, 10}, {15, 1, 10}, {14, 1, 10}, {4, 2, 10}
+ {16,1,10}, {5,2,10}, {0,7,10}, {2,3,10},
+ {1,4,10}, {15,1,10}, {14,1,10}, {4,2,10}
};
/* Table B-15, DCT coefficients table one,
@@ -344,8 +341,8 @@ static DCTtab DCTtab1[8] =
*/
static DCTtab DCTtab1a[8] =
{
- {5, 2, 9}, {5, 2, 9}, {14, 1, 9}, {14, 1, 9},
- {2, 4, 10}, {16, 1, 10}, {15, 1, 9}, {15, 1, 9}
+ {5,2,9}, {5,2,9}, {14,1,9}, {14,1,9},
+ {2,4,10}, {16,1,10}, {15,1,9}, {15,1,9}
};
/* Table B-14/15, DCT coefficients table zero / one,
@@ -353,10 +350,10 @@ static DCTtab DCTtab1a[8] =
*/
static DCTtab DCTtab2[16] =
{
- {0, 11, 12}, {8, 2, 12}, {4, 3, 12}, {0, 10, 12},
- {2, 4, 12}, {7, 2, 12}, {21, 1, 12}, {20, 1, 12},
- {0, 9, 12}, {19, 1, 12}, {18, 1, 12}, {1, 5, 12},
- {3, 3, 12}, {0, 8, 12}, {6, 2, 12}, {17, 1, 12}
+ {0,11,12}, {8,2,12}, {4,3,12}, {0,10,12},
+ {2,4,12}, {7,2,12}, {21,1,12}, {20,1,12},
+ {0,9,12}, {19,1,12}, {18,1,12}, {1,5,12},
+ {3,3,12}, {0,8,12}, {6,2,12}, {17,1,12}
};
/* Table B-14/15, DCT coefficients table zero / one,
@@ -364,10 +361,10 @@ static DCTtab DCTtab2[16] =
*/
static DCTtab DCTtab3[16] =
{
- {10, 2, 13}, {9, 2, 13}, {5, 3, 13}, {3, 4, 13},
- {2, 5, 13}, {1, 7, 13}, {1, 6, 13}, {0, 15, 13},
- {0, 14, 13}, {0, 13, 13}, {0, 12, 13}, {26, 1, 13},
- {25, 1, 13}, {24, 1, 13}, {23, 1, 13}, {22, 1, 13}
+ {10,2,13}, {9,2,13}, {5,3,13}, {3,4,13},
+ {2,5,13}, {1,7,13}, {1,6,13}, {0,15,13},
+ {0,14,13}, {0,13,13}, {0,12,13}, {26,1,13},
+ {25,1,13}, {24,1,13}, {23,1,13}, {22,1,13}
};
/* Table B-14/15, DCT coefficients table zero / one,
@@ -375,10 +372,10 @@ static DCTtab DCTtab3[16] =
*/
static DCTtab DCTtab4[16] =
{
- {0, 31, 14}, {0, 30, 14}, {0, 29, 14}, {0, 28, 14},
- {0, 27, 14}, {0, 26, 14}, {0, 25, 14}, {0, 24, 14},
- {0, 23, 14}, {0, 22, 14}, {0, 21, 14}, {0, 20, 14},
- {0, 19, 14}, {0, 18, 14}, {0, 17, 14}, {0, 16, 14}
+ {0,31,14}, {0,30,14}, {0,29,14}, {0,28,14},
+ {0,27,14}, {0,26,14}, {0,25,14}, {0,24,14},
+ {0,23,14}, {0,22,14}, {0,21,14}, {0,20,14},
+ {0,19,14}, {0,18,14}, {0,17,14}, {0,16,14}
};
/* Table B-14/15, DCT coefficients table zero / one,
@@ -386,10 +383,10 @@ static DCTtab DCTtab4[16] =
*/
static DCTtab DCTtab5[16] =
{
- {0, 40, 15}, {0, 39, 15}, {0, 38, 15}, {0, 37, 15},
- {0, 36, 15}, {0, 35, 15}, {0, 34, 15}, {0, 33, 15},
- {0, 32, 15}, {1, 14, 15}, {1, 13, 15}, {1, 12, 15},
- {1, 11, 15}, {1, 10, 15}, {1, 9, 15}, {1, 8, 15}
+ {0,40,15}, {0,39,15}, {0,38,15}, {0,37,15},
+ {0,36,15}, {0,35,15}, {0,34,15}, {0,33,15},
+ {0,32,15}, {1,14,15}, {1,13,15}, {1,12,15},
+ {1,11,15}, {1,10,15}, {1,9,15}, {1,8,15}
};
/* Table B-14/15, DCT coefficients table zero / one,
@@ -397,66 +394,66 @@ static DCTtab DCTtab5[16] =
*/
static DCTtab DCTtab6[16] =
{
- {1, 18, 16}, {1, 17, 16}, {1, 16, 16}, {1, 15, 16},
- {6, 3, 16}, {16, 2, 16}, {15, 2, 16}, {14, 2, 16},
- {13, 2, 16}, {12, 2, 16}, {11, 2, 16}, {31, 1, 16},
- {30, 1, 16}, {29, 1, 16}, {28, 1, 16}, {27, 1, 16}
+ {1,18,16}, {1,17,16}, {1,16,16}, {1,15,16},
+ {6,3,16}, {16,2,16}, {15,2,16}, {14,2,16},
+ {13,2,16}, {12,2,16}, {11,2,16}, {31,1,16},
+ {30,1,16}, {29,1,16}, {28,1,16}, {27,1,16}
};
/* Table B-3, macroblock_type in P-pictures, codes 001..1xx */
static VLCtab PMBtab0[8] =
{
- {ERROR_VALUE, 0},
- {MACROBLOCK_MOTION_FORWARD, 3},
- {MACROBLOCK_PATTERN, 2}, {MACROBLOCK_PATTERN, 2},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_PATTERN, 1},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_PATTERN, 1},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_PATTERN, 1},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_PATTERN, 1}
+ {ERROR_VALUE,0},
+ {MACROBLOCK_MOTION_FORWARD,3},
+ {MACROBLOCK_PATTERN,2}, {MACROBLOCK_PATTERN,2},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1}
};
/* Table B-3, macroblock_type in P-pictures, codes 000001..00011x */
static VLCtab PMBtab1[8] =
{
- {ERROR_VALUE, 0},
- {MACROBLOCK_QUANT | MACROBLOCK_INTRA, 6},
- {MACROBLOCK_QUANT | MACROBLOCK_PATTERN, 5}, {MACROBLOCK_QUANT | MACROBLOCK_PATTERN, 5},
- {MACROBLOCK_QUANT | MACROBLOCK_MOTION_FORWARD | MACROBLOCK_PATTERN, 5}, {MACROBLOCK_QUANT | MACROBLOCK_MOTION_FORWARD | MACROBLOCK_PATTERN, 5},
- {MACROBLOCK_INTRA, 5}, {MACROBLOCK_INTRA, 5}
+ {ERROR_VALUE,0},
+ {MACROBLOCK_QUANT|MACROBLOCK_INTRA,6},
+ {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,5}, {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,5},
+ {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,5}, {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,5},
+ {MACROBLOCK_INTRA,5}, {MACROBLOCK_INTRA,5}
};
/* Table B-4, macroblock_type in B-pictures, codes 0010..11xx */
static VLCtab BMBtab0[16] =
{
- {ERROR_VALUE, 0},
- {ERROR_VALUE, 0},
- {MACROBLOCK_MOTION_FORWARD, 4},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_PATTERN, 4},
- {MACROBLOCK_MOTION_BACKWARD, 3},
- {MACROBLOCK_MOTION_BACKWARD, 3},
- {MACROBLOCK_MOTION_BACKWARD | MACROBLOCK_PATTERN, 3},
- {MACROBLOCK_MOTION_BACKWARD | MACROBLOCK_PATTERN, 3},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD, 2},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD, 2},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD, 2},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD, 2},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD | MACROBLOCK_PATTERN, 2},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD | MACROBLOCK_PATTERN, 2},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD | MACROBLOCK_PATTERN, 2},
- {MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD | MACROBLOCK_PATTERN, 2}
+ {ERROR_VALUE,0},
+ {ERROR_VALUE,0},
+ {MACROBLOCK_MOTION_FORWARD,4},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,4},
+ {MACROBLOCK_MOTION_BACKWARD,3},
+ {MACROBLOCK_MOTION_BACKWARD,3},
+ {MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,3},
+ {MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,3},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2},
+ {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2}
};
/* Table B-4, macroblock_type in B-pictures, codes 000001..00011x */
static VLCtab BMBtab1[8] =
{
- {ERROR_VALUE, 0},
- {MACROBLOCK_QUANT | MACROBLOCK_INTRA, 6},
- {MACROBLOCK_QUANT | MACROBLOCK_MOTION_BACKWARD | MACROBLOCK_PATTERN, 6},
- {MACROBLOCK_QUANT | MACROBLOCK_MOTION_FORWARD | MACROBLOCK_PATTERN, 6},
- {MACROBLOCK_QUANT | MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD | MACROBLOCK_PATTERN, 5},
- {MACROBLOCK_QUANT | MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD | MACROBLOCK_PATTERN, 5},
- {MACROBLOCK_INTRA, 5},
- {MACROBLOCK_INTRA, 5}
+ {ERROR_VALUE,0},
+ {MACROBLOCK_QUANT|MACROBLOCK_INTRA,6},
+ {MACROBLOCK_QUANT|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,6},
+ {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,6},
+ {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,5},
+ {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,5},
+ {MACROBLOCK_INTRA,5},
+ {MACROBLOCK_INTRA,5}
};
//
@@ -465,251 +462,251 @@ static VLCtab BMBtab1[8] =
void CMPEG2Dec::Initialize_Buffer()
{
- Rdptr = Rdbfr + BUFFER_SIZE;
- Rdmax = Rdptr;
+ Rdptr = Rdbfr + BUFFER_SIZE;
+ Rdmax = Rdptr;
- if(SystemStream_Flag)
- {
- if(Rdptr >= Rdmax)
- Next_Packet();
- CurrentBfr = *Rdptr++ << 24;
+ if (SystemStream_Flag)
+ {
+ if (Rdptr >= Rdmax)
+ Next_Packet();
+ CurrentBfr = *Rdptr++ << 24;
- if(Rdptr >= Rdmax)
- Next_Packet();
- CurrentBfr += *Rdptr++ << 16;
+ if (Rdptr >= Rdmax)
+ Next_Packet();
+ CurrentBfr += *Rdptr++ << 16;
- if(Rdptr >= Rdmax)
- Next_Packet();
- CurrentBfr += *Rdptr++ << 8;
+ if (Rdptr >= Rdmax)
+ Next_Packet();
+ CurrentBfr += *Rdptr++ << 8;
- if(Rdptr >= Rdmax)
- Next_Packet();
- CurrentBfr += *Rdptr++;
+ if (Rdptr >= Rdmax)
+ Next_Packet();
+ CurrentBfr += *Rdptr++;
- Fill_Next();
- }
- else
- {
- Fill_Buffer();
+ Fill_Next();
+ }
+ else
+ {
+ Fill_Buffer();
- CurrentBfr = (*Rdptr << 24) + (*(Rdptr + 1) << 16) + (*(Rdptr + 2) << 8) + *(Rdptr + 3);
- Rdptr += 4;
+ CurrentBfr = (*Rdptr << 24) + (*(Rdptr+1) << 16) + (*(Rdptr+2) << 8) + *(Rdptr+3);
+ Rdptr += 4;
- Fill_Next();
- }
+ Fill_Next();
+ }
- BitsLeft = 32;
+ BitsLeft = 32;
}
unsigned int CMPEG2Dec::Get_Bits_All(unsigned int N)
{
- N -= BitsLeft;
- Val = (CurrentBfr << (32 - BitsLeft)) >> (32 - BitsLeft);
+ N -= BitsLeft;
+ Val = (CurrentBfr << (32 - BitsLeft)) >> (32 - BitsLeft);
- if(N != 0)
- Val = (Val << N) + (NextBfr >> (32 - N));
+ if (N != 0)
+ Val = (Val << N) + (NextBfr >> (32 - N));
- CurrentBfr = NextBfr;
- BitsLeft = 32 - N;
- Fill_Next();
+ CurrentBfr = NextBfr;
+ BitsLeft = 32 - N;
+ Fill_Next();
- return Val;
+ return Val;
}
void CMPEG2Dec::Flush_Buffer_All(unsigned int N)
{
- CurrentBfr = NextBfr;
- BitsLeft = BitsLeft + 32 - N;
- Fill_Next();
+ CurrentBfr = NextBfr;
+ BitsLeft = BitsLeft + 32 - N;
+ Fill_Next();
}
void CMPEG2Dec::Next_Packet()
{
- unsigned int code, Packet_Length, Packet_Header_Length;
-
- for(;;)
- {
- code = Get_Short();
- code = (code << 16) + Get_Short();
-
- // remove system layer byte stuffing
- while((code & 0xffffff00) != 0x00000100)
- code = (code << 8) + Get_Byte();
-
- switch(code)
- {
- case PACK_START_CODE:
- Rdptr += 8;
- break;
-
- case VIDEO_ELEMENTARY_STREAM:
- Packet_Length = Get_Short();
- Rdmax = Rdptr + Packet_Length;
-
- code = Get_Byte();
-
- if((code & 0xc0) == 0x80)
- {
- code = Get_Byte();
- Packet_Header_Length = Get_Byte();
-
- Rdptr += Packet_Header_Length;
- return;
- }
- else
- Rdptr += Packet_Length - 1;
- break;
-
- default:
- if(code >= SYSTEM_START_CODE)
- {
- code = Get_Short();
- Rdptr += code;
- }
- break;
- }
- }
+ unsigned int code, Packet_Length, Packet_Header_Length;
+
+ for (;;)
+ {
+ code = Get_Short();
+ code = (code<<16) + Get_Short();
+
+ // remove system layer byte stuffing
+ while ((code & 0xffffff00) != 0x00000100)
+ code = (code<<8) + Get_Byte();
+
+ switch (code)
+ {
+ case PACK_START_CODE:
+ Rdptr += 8;
+ break;
+
+ case VIDEO_ELEMENTARY_STREAM:
+ Packet_Length = Get_Short();
+ Rdmax = Rdptr + Packet_Length;
+
+ code = Get_Byte();
+
+ if ((code & 0xc0)==0x80)
+ {
+ code = Get_Byte();
+ Packet_Header_Length = Get_Byte();
+
+ Rdptr += Packet_Header_Length;
+ return;
+ }
+ else
+ Rdptr += Packet_Length-1;
+ break;
+
+ default:
+ if (code>=SYSTEM_START_CODE)
+ {
+ code = Get_Short();
+ Rdptr += code;
+ }
+ break;
+ }
+ }
}
void CMPEG2Dec::Fill_Buffer()
{
- Read = _read(Infile[File_Flag], Rdbfr, BUFFER_SIZE);
+ Read = _read(Infile[File_Flag], Rdbfr, BUFFER_SIZE);
- if(Read < BUFFER_SIZE)
- Next_File();
+ if (Read < BUFFER_SIZE)
+ Next_File();
- if(KeyOp_Flag && (Rdbfr[20] & 0x10))
- {
- BufferOp(Rdbfr, lfsr0, lfsr1);
- Rdbfr[20] &= ~0x10;
- }
+ if (KeyOp_Flag && (Rdbfr[20] & 0x10))
+ {
+ BufferOp(Rdbfr, lfsr0, lfsr1);
+ Rdbfr[20] &= ~0x10;
+ }
- Rdptr = Rdbfr;
+ Rdptr = Rdbfr;
- if(SystemStream_Flag)
- Rdmax -= BUFFER_SIZE;
+ if (SystemStream_Flag)
+ Rdmax -= BUFFER_SIZE;
}
void CMPEG2Dec::Next_File()
{
- if(File_Flag < File_Limit - 1)
- File_Flag ++;
+ if (File_Flag < File_Limit-1)
+ File_Flag ++;
- _lseeki64(Infile[File_Flag], 0, SEEK_SET);
- _read(Infile[File_Flag], Rdbfr + Read, BUFFER_SIZE - Read);
+ _lseeki64(Infile[File_Flag], 0, SEEK_SET);
+ _read(Infile[File_Flag], Rdbfr + Read, BUFFER_SIZE - Read);
}
unsigned int CMPEG2Dec::Show_Bits(unsigned int N)
{
- if(N <= BitsLeft)
- return (CurrentBfr << (32 - BitsLeft)) >> (32 - N);
- else
- {
- N -= BitsLeft;
- return (((CurrentBfr << (32 - BitsLeft)) >> (32 - BitsLeft)) << N) + (NextBfr >> (32 - N));
- }
+ if (N <= BitsLeft)
+ return (CurrentBfr << (32 - BitsLeft)) >> (32 - N);
+ else
+ {
+ N -= BitsLeft;
+ return (((CurrentBfr << (32 - BitsLeft)) >> (32 - BitsLeft)) << N) + (NextBfr >> (32 - N));
+ }
}
unsigned int CMPEG2Dec::Get_Bits(unsigned int N)
{
- if(N < BitsLeft)
- {
- Val = (CurrentBfr << (32 - BitsLeft)) >> (32 - N);
- BitsLeft -= N;
- return Val;
- }
- else
- return Get_Bits_All(N);
+ if (N < BitsLeft)
+ {
+ Val = (CurrentBfr << (32 - BitsLeft)) >> (32 - N);
+ BitsLeft -= N;
+ return Val;
+ }
+ else
+ return Get_Bits_All(N);
}
void CMPEG2Dec::Flush_Buffer(unsigned int N)
{
- if(N < BitsLeft)
- BitsLeft -= N;
- else
- Flush_Buffer_All(N);
+ if (N < BitsLeft)
+ BitsLeft -= N;
+ else
+ Flush_Buffer_All(N);
}
void CMPEG2Dec::Fill_Next()
{
- if(SystemStream_Flag && Rdptr >= Rdmax - 4)
- {
- if(Rdptr >= Rdmax)
- Next_Packet();
- NextBfr = Get_Byte() << 24;
-
- if(Rdptr >= Rdmax)
- Next_Packet();
- NextBfr += Get_Byte() << 16;
-
- if(Rdptr >= Rdmax)
- Next_Packet();
- NextBfr += Get_Byte() << 8;
-
- if(Rdptr >= Rdmax)
- Next_Packet();
- NextBfr += Get_Byte();
- }
- else if(Rdptr < Rdbfr + BUFFER_SIZE - 4)
- {
- NextBfr = (*Rdptr << 24) + (*(Rdptr + 1) << 16) + (*(Rdptr + 2) << 8) + *(Rdptr + 3);
- Rdptr += 4;
- }
- else
- {
- if(Rdptr >= Rdbfr + BUFFER_SIZE)
- Fill_Buffer();
- NextBfr = *Rdptr++ << 24;
-
- if(Rdptr >= Rdbfr + BUFFER_SIZE)
- Fill_Buffer();
- NextBfr += *Rdptr++ << 16;
-
- if(Rdptr >= Rdbfr + BUFFER_SIZE)
- Fill_Buffer();
- NextBfr += *Rdptr++ << 8;
-
- if(Rdptr >= Rdbfr + BUFFER_SIZE)
- Fill_Buffer();
- NextBfr += *Rdptr++;
- }
+ if (SystemStream_Flag && Rdptr>=Rdmax-4)
+ {
+ if (Rdptr >= Rdmax)
+ Next_Packet();
+ NextBfr = Get_Byte() << 24;
+
+ if (Rdptr >= Rdmax)
+ Next_Packet();
+ NextBfr += Get_Byte() << 16;
+
+ if (Rdptr >= Rdmax)
+ Next_Packet();
+ NextBfr += Get_Byte() << 8;
+
+ if (Rdptr >= Rdmax)
+ Next_Packet();
+ NextBfr += Get_Byte();
+ }
+ else if (Rdptr < Rdbfr+BUFFER_SIZE-4)
+ {
+ NextBfr = (*Rdptr << 24) + (*(Rdptr+1) << 16) + (*(Rdptr+2) << 8) + *(Rdptr+3);
+ Rdptr += 4;
+ }
+ else
+ {
+ if (Rdptr >= Rdbfr+BUFFER_SIZE)
+ Fill_Buffer();
+ NextBfr = *Rdptr++ << 24;
+
+ if (Rdptr >= Rdbfr+BUFFER_SIZE)
+ Fill_Buffer();
+ NextBfr += *Rdptr++ << 16;
+
+ if (Rdptr >= Rdbfr+BUFFER_SIZE)
+ Fill_Buffer();
+ NextBfr += *Rdptr++ << 8;
+
+ if (Rdptr >= Rdbfr+BUFFER_SIZE)
+ Fill_Buffer();
+ NextBfr += *Rdptr++;
+ }
}
unsigned int CMPEG2Dec::Get_Byte()
{
- while(Rdptr >= (Rdbfr + BUFFER_SIZE))
- {
- Read = _read(Infile[File_Flag], Rdbfr, BUFFER_SIZE);
+ while (Rdptr >= (Rdbfr + BUFFER_SIZE))
+ {
+ Read = _read(Infile[File_Flag], Rdbfr, BUFFER_SIZE);
- if(Read < BUFFER_SIZE)
- Next_File();
+ if (Read < BUFFER_SIZE)
+ Next_File();
- if(KeyOp_Flag && (Rdbfr[20] & 0x10))
- {
- BufferOp(Rdbfr, lfsr0, lfsr1);
- Rdbfr[20] &= ~0x10;
- }
+ if (KeyOp_Flag && (Rdbfr[20] & 0x10))
+ {
+ BufferOp(Rdbfr, lfsr0, lfsr1);
+ Rdbfr[20] &= ~0x10;
+ }
- Rdptr -= BUFFER_SIZE;
- Rdmax -= BUFFER_SIZE;
- }
+ Rdptr -= BUFFER_SIZE;
+ Rdmax -= BUFFER_SIZE;
+ }
- return *Rdptr++;
+ return *Rdptr++;
}
unsigned int CMPEG2Dec::Get_Short()
{
- unsigned int i = Get_Byte();
- return (i << 8) + Get_Byte();
+ unsigned int i = Get_Byte();
+ return (i<<8) + Get_Byte();
}
void CMPEG2Dec::next_start_code()
{
- Flush_Buffer(BitsLeft & 7);
+ Flush_Buffer(BitsLeft & 7);
- while(Show_Bits(24) != 1)
- Flush_Buffer(8);
+ while (Show_Bits(24) != 1)
+ Flush_Buffer(8);
}
//
@@ -718,402 +715,402 @@ void CMPEG2Dec::next_start_code()
int CMPEG2Dec::Get_Hdr()
{
- for(;;)
- {
- /* look for next_start_code */
- next_start_code();
-
- switch(Get_Bits(32))
- {
- case SEQUENCE_HEADER_CODE:
- sequence_header();
- break;
-
- case GROUP_START_CODE:
- group_of_pictures_header();
- break;
-
- case PICTURE_START_CODE:
- picture_header();
- return 1;
- }
- }
+ for (;;)
+ {
+ /* look for next_start_code */
+ next_start_code();
+
+ switch (Get_Bits(32))
+ {
+ case SEQUENCE_HEADER_CODE:
+ sequence_header();
+ break;
+
+ case GROUP_START_CODE:
+ group_of_pictures_header();
+ break;
+
+ case PICTURE_START_CODE:
+ picture_header();
+ return 1;
+ }
+ }
}
/* decode group of pictures header */
/* ISO/IEC 13818-2 section 6.2.2.6 */
void CMPEG2Dec::group_of_pictures_header()
{
- int gop_hour;
- int gop_minute;
- int gop_sec;
- int gop_frame;
-
- int drop_flag;
- int closed_gop;
- int broken_link;
-
- drop_flag = Get_Bits(1);
- gop_hour = Get_Bits(5);
- gop_minute = Get_Bits(6);
- Flush_Buffer(1); // marker bit
- gop_sec = Get_Bits(6);
- gop_frame = Get_Bits(6);
- closed_gop = Get_Bits(1);
- broken_link = Get_Bits(1);
-
- extension_and_user_data();
+ int gop_hour;
+ int gop_minute;
+ int gop_sec;
+ int gop_frame;
+
+ int drop_flag;
+ int closed_gop;
+ int broken_link;
+
+ drop_flag = Get_Bits(1);
+ gop_hour = Get_Bits(5);
+ gop_minute = Get_Bits(6);
+ Flush_Buffer(1); // marker bit
+ gop_sec = Get_Bits(6);
+ gop_frame = Get_Bits(6);
+ closed_gop = Get_Bits(1);
+ broken_link = Get_Bits(1);
+
+ extension_and_user_data();
}
/* decode picture header */
/* ISO/IEC 13818-2 section 6.2.3 */
void CMPEG2Dec::picture_header()
{
- int vbv_delay;
- int full_pel_forward_vector;
- int forward_f_code;
- int full_pel_backward_vector;
- int backward_f_code;
- int Extra_Information_Byte_Count;
-
- temporal_reference = Get_Bits(10);
- picture_coding_type = Get_Bits(3);
- vbv_delay = Get_Bits(16);
-
- if(picture_coding_type == P_TYPE || picture_coding_type == B_TYPE)
- {
- full_pel_forward_vector = Get_Bits(1);
- forward_f_code = Get_Bits(3);
- }
-
- if(picture_coding_type == B_TYPE)
- {
- full_pel_backward_vector = Get_Bits(1);
- backward_f_code = Get_Bits(3);
- }
-
- Extra_Information_Byte_Count = extra_bit_information();
- extension_and_user_data();
+ int vbv_delay;
+ int full_pel_forward_vector;
+ int forward_f_code;
+ int full_pel_backward_vector;
+ int backward_f_code;
+ int Extra_Information_Byte_Count;
+
+ temporal_reference = Get_Bits(10);
+ picture_coding_type = Get_Bits(3);
+ vbv_delay = Get_Bits(16);
+
+ if (picture_coding_type==P_TYPE || picture_coding_type==B_TYPE)
+ {
+ full_pel_forward_vector = Get_Bits(1);
+ forward_f_code = Get_Bits(3);
+ }
+
+ if (picture_coding_type==B_TYPE)
+ {
+ full_pel_backward_vector = Get_Bits(1);
+ backward_f_code = Get_Bits(3);
+ }
+
+ Extra_Information_Byte_Count = extra_bit_information();
+ extension_and_user_data();
}
/* decode sequence header */
void CMPEG2Dec::sequence_header()
{
- int frame_rate_code;
- int vbv_buffer_size;
- int aspect_ratio_information;
- int bit_rate_value;
-
- int constrained_parameters_flag;
- int i;
-
- horizontal_size = Get_Bits(12);
- vertical_size = Get_Bits(12);
- aspect_ratio_information = Get_Bits(4);
- frame_rate_code = Get_Bits(4);
- bit_rate_value = Get_Bits(18);
- Flush_Buffer(1); // marker bit
- vbv_buffer_size = Get_Bits(10);
- constrained_parameters_flag = Get_Bits(1);
-
- if(load_intra_quantizer_matrix = Get_Bits(1))
- {
- for(i = 0; i < 64; i++)
- intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
- }
- else
- {
- for(i = 0; i < 64; i++)
- intra_quantizer_matrix[i] = default_intra_quantizer_matrix[i];
- }
-
- if(load_non_intra_quantizer_matrix = Get_Bits(1))
- {
- for(i = 0; i < 64; i++)
- non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
- }
- else
- {
- for(i = 0; i < 64; i++)
- non_intra_quantizer_matrix[i] = 16;
- }
-
- /* copy luminance to chrominance matrices */
- for(i = 0; i < 64; i++)
- {
- chroma_intra_quantizer_matrix[i] = intra_quantizer_matrix[i];
- chroma_non_intra_quantizer_matrix[i] = non_intra_quantizer_matrix[i];
- }
- extension_and_user_data();
+ int frame_rate_code;
+ int vbv_buffer_size;
+ int aspect_ratio_information;
+ int bit_rate_value;
+
+ int constrained_parameters_flag;
+ int i;
+
+ horizontal_size = Get_Bits(12);
+ vertical_size = Get_Bits(12);
+ aspect_ratio_information = Get_Bits(4);
+ frame_rate_code = Get_Bits(4);
+ bit_rate_value = Get_Bits(18);
+ Flush_Buffer(1); // marker bit
+ vbv_buffer_size = Get_Bits(10);
+ constrained_parameters_flag = Get_Bits(1);
+
+ if (load_intra_quantizer_matrix = Get_Bits(1))
+ {
+ for (i=0; i<64; i++)
+ intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
+ }
+ else
+ {
+ for (i=0; i<64; i++)
+ intra_quantizer_matrix[i] = default_intra_quantizer_matrix[i];
+ }
+
+ if (load_non_intra_quantizer_matrix = Get_Bits(1))
+ {
+ for (i=0; i<64; i++)
+ non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
+ }
+ else
+ {
+ for (i=0; i<64; i++)
+ non_intra_quantizer_matrix[i] = 16;
+ }
+
+ /* copy luminance to chrominance matrices */
+ for (i=0; i<64; i++)
+ {
+ chroma_intra_quantizer_matrix[i] = intra_quantizer_matrix[i];
+ chroma_non_intra_quantizer_matrix[i] = non_intra_quantizer_matrix[i];
+ }
+ extension_and_user_data();
}
/* decode slice header */
/* ISO/IEC 13818-2 section 6.2.4 */
int CMPEG2Dec::slice_header()
{
- int slice_vertical_position_extension;
- int quantizer_scale_code;
- int slice_picture_id_enable = 0;
- int slice_picture_id = 0;
- int extra_information_slice = 0;
+ int slice_vertical_position_extension;
+ int quantizer_scale_code;
+ int slice_picture_id_enable = 0;
+ int slice_picture_id = 0;
+ int extra_information_slice = 0;
- slice_vertical_position_extension = vertical_size > 2800 ? Get_Bits(3) : 0;
+ slice_vertical_position_extension = vertical_size>2800 ? Get_Bits(3) : 0;
- quantizer_scale_code = Get_Bits(5);
- quantizer_scale = q_scale_type ? Non_Linear_quantizer_scale[quantizer_scale_code] : quantizer_scale_code << 1;
+ quantizer_scale_code = Get_Bits(5);
+ quantizer_scale = q_scale_type ? Non_Linear_quantizer_scale[quantizer_scale_code] : quantizer_scale_code<<1;
- /* slice_id introduced in March 1995 as part of the video corridendum
- (after the IS was drafted in November 1994) */
- if(Get_Bits(1))
- {
- Get_Bits(1); // intra slice
+ /* slice_id introduced in March 1995 as part of the video corridendum
+ (after the IS was drafted in November 1994) */
+ if (Get_Bits(1))
+ {
+ Get_Bits(1); // intra slice
- slice_picture_id_enable = Get_Bits(1);
- slice_picture_id = Get_Bits(6);
+ slice_picture_id_enable = Get_Bits(1);
+ slice_picture_id = Get_Bits(6);
- extra_information_slice = extra_bit_information();
- }
+ extra_information_slice = extra_bit_information();
+ }
- return slice_vertical_position_extension;
+ return slice_vertical_position_extension;
}
/* decode extension and user data */
/* ISO/IEC 13818-2 section 6.2.2.2 */
void CMPEG2Dec::extension_and_user_data()
{
- int code, ext_ID;
-
- next_start_code();
-
- while((code = Show_Bits(32)) == EXTENSION_START_CODE || code == USER_DATA_START_CODE)
- {
- if(code == EXTENSION_START_CODE)
- {
- Flush_Buffer(32);
- ext_ID = Get_Bits(4);
-
- switch(ext_ID)
- {
- case SEQUENCE_EXTENSION_ID:
- sequence_extension();
- break;
-
- case SEQUENCE_DISPLAY_EXTENSION_ID:
- sequence_display_extension();
- break;
-
- case QUANT_MATRIX_EXTENSION_ID:
- quant_matrix_extension();
- break;
-
- case PICTURE_DISPLAY_EXTENSION_ID:
- picture_display_extension();
- break;
-
- case PICTURE_CODING_EXTENSION_ID:
- picture_coding_extension();
- break;
-
- case COPYRIGHT_EXTENSION_ID:
- copyright_extension();
- break;
- }
- next_start_code();
- }
- else
- {
- Flush_Buffer(32);
- next_start_code();
- }
- }
+ int code, ext_ID;
+
+ next_start_code();
+
+ while ((code = Show_Bits(32))==EXTENSION_START_CODE || code==USER_DATA_START_CODE)
+ {
+ if (code==EXTENSION_START_CODE)
+ {
+ Flush_Buffer(32);
+ ext_ID = Get_Bits(4);
+
+ switch (ext_ID)
+ {
+ case SEQUENCE_EXTENSION_ID:
+ sequence_extension();
+ break;
+
+ case SEQUENCE_DISPLAY_EXTENSION_ID:
+ sequence_display_extension();
+ break;
+
+ case QUANT_MATRIX_EXTENSION_ID:
+ quant_matrix_extension();
+ break;
+
+ case PICTURE_DISPLAY_EXTENSION_ID:
+ picture_display_extension();
+ break;
+
+ case PICTURE_CODING_EXTENSION_ID:
+ picture_coding_extension();
+ break;
+
+ case COPYRIGHT_EXTENSION_ID:
+ copyright_extension();
+ break;
+ }
+ next_start_code();
+ }
+ else
+ {
+ Flush_Buffer(32);
+ next_start_code();
+ }
+ }
}
/* decode sequence extension */
/* ISO/IEC 13818-2 section 6.2.2.3 */
void CMPEG2Dec::sequence_extension()
{
- int profile_and_level_indication;
- int low_delay;
- int frame_rate_extension_n;
- int frame_rate_extension_d;
-
- int horizontal_size_extension;
- int vertical_size_extension;
- int bit_rate_extension;
- int vbv_buffer_size_extension;
-
- profile_and_level_indication = Get_Bits(8);
- progressive_sequence = Get_Bits(1);
- chroma_format = Get_Bits(2);
- horizontal_size_extension = Get_Bits(2);
- vertical_size_extension = Get_Bits(2);
- bit_rate_extension = Get_Bits(12);
- Flush_Buffer(1); // marker bit
- vbv_buffer_size_extension = Get_Bits(8);
- low_delay = Get_Bits(1);
-
- frame_rate_extension_n = Get_Bits(2);
- frame_rate_extension_d = Get_Bits(5);
-
- horizontal_size = (horizontal_size_extension << 12) | (horizontal_size & 0x0fff);
- vertical_size = (vertical_size_extension << 12) | (vertical_size & 0x0fff);
+ int profile_and_level_indication;
+ int low_delay;
+ int frame_rate_extension_n;
+ int frame_rate_extension_d;
+
+ int horizontal_size_extension;
+ int vertical_size_extension;
+ int bit_rate_extension;
+ int vbv_buffer_size_extension;
+
+ profile_and_level_indication = Get_Bits(8);
+ progressive_sequence = Get_Bits(1);
+ chroma_format = Get_Bits(2);
+ horizontal_size_extension = Get_Bits(2);
+ vertical_size_extension = Get_Bits(2);
+ bit_rate_extension = Get_Bits(12);
+ Flush_Buffer(1); // marker bit
+ vbv_buffer_size_extension = Get_Bits(8);
+ low_delay = Get_Bits(1);
+
+ frame_rate_extension_n = Get_Bits(2);
+ frame_rate_extension_d = Get_Bits(5);
+
+ horizontal_size = (horizontal_size_extension<<12) | (horizontal_size&0x0fff);
+ vertical_size = (vertical_size_extension<<12) | (vertical_size&0x0fff);
}
/* decode sequence display extension */
void CMPEG2Dec::sequence_display_extension()
{
- int video_format;
- int color_description;
- int color_primaries;
- int transfer_characteristics;
- int matrix_coefficients;
- int display_horizontal_size;
- int display_vertical_size;
-
- video_format = Get_Bits(3);
- color_description = Get_Bits(1);
-
- if(color_description)
- {
- color_primaries = Get_Bits(8);
- transfer_characteristics = Get_Bits(8);
- matrix_coefficients = Get_Bits(8);
- }
-
- display_horizontal_size = Get_Bits(14);
- Flush_Buffer(1); // marker bit
- display_vertical_size = Get_Bits(14);
+ int video_format;
+ int color_description;
+ int color_primaries;
+ int transfer_characteristics;
+ int matrix_coefficients;
+ int display_horizontal_size;
+ int display_vertical_size;
+
+ video_format = Get_Bits(3);
+ color_description = Get_Bits(1);
+
+ if (color_description)
+ {
+ color_primaries = Get_Bits(8);
+ transfer_characteristics = Get_Bits(8);
+ matrix_coefficients = Get_Bits(8);
+ }
+
+ display_horizontal_size = Get_Bits(14);
+ Flush_Buffer(1); // marker bit
+ display_vertical_size = Get_Bits(14);
}
/* decode quant matrix entension */
/* ISO/IEC 13818-2 section 6.2.3.2 */
void CMPEG2Dec::quant_matrix_extension()
{
- int i;
+ int i;
- if(load_intra_quantizer_matrix = Get_Bits(1))
- for(i = 0; i < 64; i++)
- chroma_intra_quantizer_matrix[scan[ZIG_ZAG][i]]
- = intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
+ if (load_intra_quantizer_matrix = Get_Bits(1))
+ for (i=0; i<64; i++)
+ chroma_intra_quantizer_matrix[scan[ZIG_ZAG][i]]
+ = intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
- if(load_non_intra_quantizer_matrix = Get_Bits(1))
- for(i = 0; i < 64; i++)
- chroma_non_intra_quantizer_matrix[scan[ZIG_ZAG][i]]
- = non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
+ if (load_non_intra_quantizer_matrix = Get_Bits(1))
+ for (i=0; i<64; i++)
+ chroma_non_intra_quantizer_matrix[scan[ZIG_ZAG][i]]
+ = non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
- if(load_chroma_intra_quantizer_matrix = Get_Bits(1))
- for(i = 0; i < 64; i++)
- chroma_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
+ if (load_chroma_intra_quantizer_matrix = Get_Bits(1))
+ for (i=0; i<64; i++)
+ chroma_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
- if(load_chroma_non_intra_quantizer_matrix = Get_Bits(1))
- for(i = 0; i < 64; i++)
- chroma_non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
+ if (load_chroma_non_intra_quantizer_matrix = Get_Bits(1))
+ for (i=0; i<64; i++)
+ chroma_non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8);
}
/* decode picture display extension */
/* ISO/IEC 13818-2 section 6.2.3.3. */
void CMPEG2Dec::picture_display_extension()
{
- int frame_center_horizontal_offset[3];
- int frame_center_vertical_offset[3];
-
- int i;
- int number_of_frame_center_offsets;
-
- /* based on ISO/IEC 13818-2 section 6.3.12
- (November 1994) Picture display extensions */
-
- /* derive number_of_frame_center_offsets */
- if(progressive_sequence)
- {
- if(repeat_first_field)
- {
- if(top_field_first)
- number_of_frame_center_offsets = 3;
- else
- number_of_frame_center_offsets = 2;
- }
- else
- number_of_frame_center_offsets = 1;
- }
- else
- {
- if(picture_structure != FRAME_PICTURE)
- number_of_frame_center_offsets = 1;
- else
- {
- if(repeat_first_field)
- number_of_frame_center_offsets = 3;
- else
- number_of_frame_center_offsets = 2;
- }
- }
-
- /* now parse */
- for(i = 0; i < number_of_frame_center_offsets; i++)
- {
- frame_center_horizontal_offset[i] = Get_Bits(16);
- Flush_Buffer(1); // marker bit
-
- frame_center_vertical_offset[i] = Get_Bits(16);
- Flush_Buffer(1); // marker bit
- }
+ int frame_center_horizontal_offset[3];
+ int frame_center_vertical_offset[3];
+
+ int i;
+ int number_of_frame_center_offsets;
+
+ /* based on ISO/IEC 13818-2 section 6.3.12
+ (November 1994) Picture display extensions */
+
+ /* derive number_of_frame_center_offsets */
+ if (progressive_sequence)
+ {
+ if (repeat_first_field)
+ {
+ if (top_field_first)
+ number_of_frame_center_offsets = 3;
+ else
+ number_of_frame_center_offsets = 2;
+ }
+ else
+ number_of_frame_center_offsets = 1;
+ }
+ else
+ {
+ if (picture_structure!=FRAME_PICTURE)
+ number_of_frame_center_offsets = 1;
+ else
+ {
+ if (repeat_first_field)
+ number_of_frame_center_offsets = 3;
+ else
+ number_of_frame_center_offsets = 2;
+ }
+ }
+
+ /* now parse */
+ for (i=0; i<number_of_frame_center_offsets; i++)
+ {
+ frame_center_horizontal_offset[i] = Get_Bits(16);
+ Flush_Buffer(1); // marker bit
+
+ frame_center_vertical_offset[i] = Get_Bits(16);
+ Flush_Buffer(1); // marker bit
+ }
}
/* decode picture coding extension */
void CMPEG2Dec::picture_coding_extension()
{
- int chroma_420_type;
- int composite_display_flag;
- int v_axis;
- int field_sequence;
- int sub_carrier;
- int burst_amplitude;
- int sub_carrier_phase;
-
- f_code[0][0] = Get_Bits(4);
- f_code[0][1] = Get_Bits(4);
- f_code[1][0] = Get_Bits(4);
- f_code[1][1] = Get_Bits(4);
-
- intra_dc_precision = Get_Bits(2);
- picture_structure = Get_Bits(2);
- top_field_first = Get_Bits(1);
- frame_pred_frame_dct = Get_Bits(1);
- concealment_motion_vectors = Get_Bits(1);
- q_scale_type = Get_Bits(1);
- intra_vlc_format = Get_Bits(1);
- alternate_scan = Get_Bits(1);
- repeat_first_field = Get_Bits(1);
- chroma_420_type = Get_Bits(1);
- progressive_frame = Get_Bits(1);
- composite_display_flag = Get_Bits(1);
-
- pf_current = progressive_frame;
-
- if(composite_display_flag)
- {
- v_axis = Get_Bits(1);
- field_sequence = Get_Bits(3);
- sub_carrier = Get_Bits(1);
- burst_amplitude = Get_Bits(7);
- sub_carrier_phase = Get_Bits(8);
- }
+ int chroma_420_type;
+ int composite_display_flag;
+ int v_axis;
+ int field_sequence;
+ int sub_carrier;
+ int burst_amplitude;
+ int sub_carrier_phase;
+
+ f_code[0][0] = Get_Bits(4);
+ f_code[0][1] = Get_Bits(4);
+ f_code[1][0] = Get_Bits(4);
+ f_code[1][1] = Get_Bits(4);
+
+ intra_dc_precision = Get_Bits(2);
+ picture_structure = Get_Bits(2);
+ top_field_first = Get_Bits(1);
+ frame_pred_frame_dct = Get_Bits(1);
+ concealment_motion_vectors = Get_Bits(1);
+ q_scale_type = Get_Bits(1);
+ intra_vlc_format = Get_Bits(1);
+ alternate_scan = Get_Bits(1);
+ repeat_first_field = Get_Bits(1);
+ chroma_420_type = Get_Bits(1);
+ progressive_frame = Get_Bits(1);
+ composite_display_flag = Get_Bits(1);
+
+ pf_current = progressive_frame;
+
+ if (composite_display_flag)
+ {
+ v_axis = Get_Bits(1);
+ field_sequence = Get_Bits(3);
+ sub_carrier = Get_Bits(1);
+ burst_amplitude = Get_Bits(7);
+ sub_carrier_phase = Get_Bits(8);
+ }
}
/* decode extra bit information */
/* ISO/IEC 13818-2 section 6.2.3.4. */
int CMPEG2Dec::extra_bit_information()
{
- int Byte_Count = 0;
+ int Byte_Count = 0;
- while(Get_Bits(1))
- {
- Flush_Buffer(8);
- Byte_Count ++;
- }
+ while (Get_Bits(1))
+ {
+ Flush_Buffer(8);
+ Byte_Count ++;
+ }
- return(Byte_Count);
+ return(Byte_Count);
}
/* Copyright extension */
@@ -1121,119 +1118,118 @@ int CMPEG2Dec::extra_bit_information()
/* (header added in November, 1994 to the IS document) */
void CMPEG2Dec::copyright_extension()
{
- int copyright_flag;
- int copyright_identifier;
- int original_or_copy;
- int copyright_number_1;
- int copyright_number_2;
- int copyright_number_3;
-
- int reserved_data;
-
- copyright_flag = Get_Bits(1);
- copyright_identifier = Get_Bits(8);
- original_or_copy = Get_Bits(1);
-
- /* reserved */
- reserved_data = Get_Bits(7);
-
- Flush_Buffer(1); // marker bit
- copyright_number_1 = Get_Bits(20);
- Flush_Buffer(1); // marker bit
- copyright_number_2 = Get_Bits(22);
- Flush_Buffer(1); // marker bit
- copyright_number_3 = Get_Bits(22);
+ int copyright_flag;
+ int copyright_identifier;
+ int original_or_copy;
+ int copyright_number_1;
+ int copyright_number_2;
+ int copyright_number_3;
+
+ int reserved_data;
+
+ copyright_flag = Get_Bits(1);
+ copyright_identifier = Get_Bits(8);
+ original_or_copy = Get_Bits(1);
+
+ /* reserved */
+ reserved_data = Get_Bits(7);
+
+ Flush_Buffer(1); // marker bit
+ copyright_number_1 = Get_Bits(20);
+ Flush_Buffer(1); // marker bit
+ copyright_number_2 = Get_Bits(22);
+ Flush_Buffer(1); // marker bit
+ copyright_number_3 = Get_Bits(22);
}
//
// getpic
//
-static const unsigned char cc_table[12] =
-{
- 0, 0, 0, 0, 1, 2, 1, 2, 1, 2, 1, 2
+static const unsigned char cc_table[12] = {
+ 0, 0, 0, 0, 1, 2, 1, 2, 1, 2, 1, 2
};
void CMPEG2Dec::Decode_Picture(int ref, unsigned char *dst, int pitch)
{
- if(picture_structure == FRAME_PICTURE && Second_Field)
- Second_Field = 0;
+ if (picture_structure==FRAME_PICTURE && Second_Field)
+ Second_Field = 0;
- if(picture_coding_type != B_TYPE)
- {
- pf_forward = pf_backward;
- pf_backward = pf_current;
- }
+ if (picture_coding_type!=B_TYPE)
+ {
+ pf_forward = pf_backward;
+ pf_backward = pf_current;
+ }
- Update_Picture_Buffers();
+ Update_Picture_Buffers();
- picture_data();
+ picture_data();
- if(ref && (picture_structure == FRAME_PICTURE || Second_Field))
- {
- if(picture_coding_type == B_TYPE)
- assembleFrame(auxframe, pf_current, dst, pitch);
- else
- assembleFrame(forward_reference_frame, pf_forward, dst, pitch);
- }
+ if (ref && (picture_structure==FRAME_PICTURE || Second_Field))
+ {
+ if (picture_coding_type==B_TYPE)
+ assembleFrame(auxframe, pf_current, dst, pitch);
+ else
+ assembleFrame(forward_reference_frame, pf_forward, dst, pitch);
+ }
- if(picture_structure != FRAME_PICTURE)
- Second_Field = !Second_Field;
+ if (picture_structure!=FRAME_PICTURE)
+ Second_Field = !Second_Field;
}
/* reuse old picture buffers as soon as they are no longer needed */
void CMPEG2Dec::Update_Picture_Buffers()
-{
- int cc; /* color component index */
- unsigned char *tmp; /* temporary swap pointer */
-
- for(cc = 0; cc < 3; cc++)
- {
- /* B pictures do not need to be save for future reference */
- if(picture_coding_type == B_TYPE)
- current_frame[cc] = auxframe[cc];
- else
- {
- if(!Second_Field)
- {
- /* only update at the beginning of the coded frame */
- tmp = forward_reference_frame[cc];
-
- /* the previously decoded reference frame is stored coincident with the
- location where the backward reference frame is stored (backwards
- prediction is not needed in P pictures) */
- forward_reference_frame[cc] = backward_reference_frame[cc];
-
- /* update pointer for potential future B pictures */
- backward_reference_frame[cc] = tmp;
- }
-
- /* can erase over old backward reference frame since it is not used
- in a P picture, and since any subsequent B pictures will use the
- previously decoded I or P frame as the backward_reference_frame */
- current_frame[cc] = backward_reference_frame[cc];
- }
-
- if(picture_structure == BOTTOM_FIELD)
- current_frame[cc] += (cc == 0) ? Coded_Picture_Width : Chroma_Width;
- }
+{
+ int cc; /* color component index */
+ unsigned char *tmp; /* temporary swap pointer */
+
+ for (cc=0; cc<3; cc++)
+ {
+ /* B pictures do not need to be save for future reference */
+ if (picture_coding_type==B_TYPE)
+ current_frame[cc] = auxframe[cc];
+ else
+ {
+ if (!Second_Field)
+ {
+ /* only update at the beginning of the coded frame */
+ tmp = forward_reference_frame[cc];
+
+ /* the previously decoded reference frame is stored coincident with the
+ location where the backward reference frame is stored (backwards
+ prediction is not needed in P pictures) */
+ forward_reference_frame[cc] = backward_reference_frame[cc];
+
+ /* update pointer for potential future B pictures */
+ backward_reference_frame[cc] = tmp;
+ }
+
+ /* can erase over old backward reference frame since it is not used
+ in a P picture, and since any subsequent B pictures will use the
+ previously decoded I or P frame as the backward_reference_frame */
+ current_frame[cc] = backward_reference_frame[cc];
+ }
+
+ if (picture_structure==BOTTOM_FIELD)
+ current_frame[cc] += (cc==0) ? Coded_Picture_Width : Chroma_Width;
+ }
}
/* decode all macroblocks of the current picture */
/* stages described in ISO/IEC 13818-2 section 7 */
void CMPEG2Dec::picture_data()
{
- int MBAmax;
+ int MBAmax;
- /* number of macroblocks per picture */
- MBAmax = mb_width * mb_height;
+ /* number of macroblocks per picture */
+ MBAmax = mb_width*mb_height;
- if(picture_structure != FRAME_PICTURE)
- MBAmax >>= 1;
+ if (picture_structure!=FRAME_PICTURE)
+ MBAmax>>=1;
- for(;;)
- if(slice(MBAmax) < 0)
- return;
+ for (;;)
+ if (slice(MBAmax)<0)
+ return;
}
/* decode all macroblocks of the current picture */
@@ -1242,110 +1238,109 @@ void CMPEG2Dec::picture_data()
/* return -1: go to next picture */
int CMPEG2Dec::slice(int MBAmax)
{
- int MBA = 0, MBAinc = 0, macroblock_type, motion_type, dct_type, ret;
- int dc_dct_pred[3], PMV[2][2][2], motion_vertical_field_select[2][2], dmvector[2];
-
- if((ret = start_of_slice(&MBA, &MBAinc, dc_dct_pred, PMV)) != 1)
- return ret;
-
- for(;;)
- {
- /* this is how we properly exit out of picture */
- if(MBA >= MBAmax) return -1; // all macroblocks decoded
-
- if(MBAinc == 0)
- {
- if(!Show_Bits(23) || Fault_Flag) // next_start_code or fault
- {
- resync:
- Fault_Flag = 0;
- return 0; // trigger: go to next slice
- }
- else /* neither next_start_code nor Fault_Flag */
- {
- /* decode macroblock address increment */
- MBAinc = Get_macroblock_address_increment();
- if(Fault_Flag) goto resync;
- }
- }
-
- if(MBAinc == 1) /* not skipped */
- {
- if(!decode_macroblock(&macroblock_type, &motion_type, &dct_type, PMV,
- dc_dct_pred, motion_vertical_field_select, dmvector))
- goto resync;
- }
- else /* MBAinc!=1: skipped macroblock */
- /* ISO/IEC 13818-2 section 7.6.6 */
- skipped_macroblock(dc_dct_pred, PMV, &motion_type, motion_vertical_field_select, &macroblock_type);
-
- /* ISO/IEC 13818-2 section 7.6 */
- motion_compensation(MBA, macroblock_type, motion_type, PMV,
- motion_vertical_field_select, dmvector, dct_type);
-
- /* advance to next macroblock */
- MBA++;
- MBAinc--;
-
- if(MBA >= MBAmax) return -1; // all macroblocks decoded
- }
+ int MBA = 0, MBAinc =0, macroblock_type, motion_type, dct_type, ret;
+ int dc_dct_pred[3], PMV[2][2][2], motion_vertical_field_select[2][2], dmvector[2];
+
+ if ((ret=start_of_slice(&MBA, &MBAinc, dc_dct_pred, PMV))!=1)
+ return ret;
+
+ for (;;)
+ {
+ /* this is how we properly exit out of picture */
+ if (MBA>=MBAmax) return -1; // all macroblocks decoded
+
+ if (MBAinc==0)
+ {
+ if (!Show_Bits(23) || Fault_Flag) // next_start_code or fault
+ {
+resync:
+ Fault_Flag = 0;
+ return 0; // trigger: go to next slice
+ }
+ else /* neither next_start_code nor Fault_Flag */
+ {
+ /* decode macroblock address increment */
+ MBAinc = Get_macroblock_address_increment();
+ if (Fault_Flag) goto resync;
+ }
+ }
+
+ if (MBAinc==1) /* not skipped */
+ {
+ if (!decode_macroblock(&macroblock_type, &motion_type, &dct_type, PMV,
+ dc_dct_pred, motion_vertical_field_select, dmvector))
+ goto resync;
+ }
+ else /* MBAinc!=1: skipped macroblock */
+ /* ISO/IEC 13818-2 section 7.6.6 */
+ skipped_macroblock(dc_dct_pred, PMV, &motion_type, motion_vertical_field_select, &macroblock_type);
+
+ /* ISO/IEC 13818-2 section 7.6 */
+ motion_compensation(MBA, macroblock_type, motion_type, PMV,
+ motion_vertical_field_select, dmvector, dct_type);
+
+ /* advance to next macroblock */
+ MBA++; MBAinc--;
+
+ if (MBA>=MBAmax) return -1; // all macroblocks decoded
+ }
}
/* ISO/IEC 13818-2 section 6.3.17.1: Macroblock modes */
void CMPEG2Dec::macroblock_modes(int *pmacroblock_type, int *pmotion_type,
- int *pmotion_vector_count, int *pmv_format,
- int *pdmv, int *pmvscale, int *pdct_type)
+ int *pmotion_vector_count, int *pmv_format,
+ int *pdmv, int *pmvscale, int *pdct_type)
{
- int macroblock_type, motion_type = 0, motion_vector_count;
- int mv_format, dmv, mvscale, dct_type;
-
- /* get macroblock_type */
- macroblock_type = Get_macroblock_type();
- if(Fault_Flag) return;
-
- /* get frame/field motion type */
- if(macroblock_type & (MACROBLOCK_MOTION_FORWARD | MACROBLOCK_MOTION_BACKWARD))
- {
- if(picture_structure == FRAME_PICTURE)
- motion_type = frame_pred_frame_dct ? MC_FRAME : Get_Bits(2);
- else
- motion_type = Get_Bits(2);
+ int macroblock_type, motion_type = 0, motion_vector_count;
+ int mv_format, dmv, mvscale, dct_type;
+
+ /* get macroblock_type */
+ macroblock_type = Get_macroblock_type();
+ if (Fault_Flag) return;
+
+ /* get frame/field motion type */
+ if (macroblock_type & (MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD))
+ {
+ if (picture_structure==FRAME_PICTURE)
+ motion_type = frame_pred_frame_dct ? MC_FRAME : Get_Bits(2);
+ else
+ motion_type = Get_Bits(2);
}
- else if((macroblock_type & MACROBLOCK_INTRA) && concealment_motion_vectors)
- motion_type = (picture_structure == FRAME_PICTURE) ? MC_FRAME : MC_FIELD;
-
- /* derive motion_vector_count, mv_format and dmv, (table 6-17, 6-18) */
- if(picture_structure == FRAME_PICTURE)
- {
- motion_vector_count = (motion_type == MC_FIELD) ? 2 : 1;
- mv_format = (motion_type == MC_FRAME) ? MV_FRAME : MV_FIELD;
- }
- else
- {
- motion_vector_count = (motion_type == MC_16X8) ? 2 : 1;
- mv_format = MV_FIELD;
- }
-
- dmv = (motion_type == MC_DMV); /* dual prime */
-
- /*
- field mv predictions in frame pictures have to be scaled
- ISO/IEC 13818-2 section 7.6.3.1 Decoding the motion vectors
- */
- mvscale = (mv_format == MV_FIELD && picture_structure == FRAME_PICTURE);
-
- /* get dct_type (frame DCT / field DCT) */
- dct_type = (picture_structure == FRAME_PICTURE) && (!frame_pred_frame_dct)
- && (macroblock_type & (MACROBLOCK_PATTERN | MACROBLOCK_INTRA)) ? Get_Bits(1) : 0;
-
- /* return values */
- *pmacroblock_type = macroblock_type;
- *pmotion_type = motion_type;
- *pmotion_vector_count = motion_vector_count;
- *pmv_format = mv_format;
- *pdmv = dmv;
- *pmvscale = mvscale;
- *pdct_type = dct_type;
+ else if ((macroblock_type & MACROBLOCK_INTRA) && concealment_motion_vectors)
+ motion_type = (picture_structure==FRAME_PICTURE) ? MC_FRAME : MC_FIELD;
+
+ /* derive motion_vector_count, mv_format and dmv, (table 6-17, 6-18) */
+ if (picture_structure==FRAME_PICTURE)
+ {
+ motion_vector_count = (motion_type==MC_FIELD) ? 2 : 1;
+ mv_format = (motion_type==MC_FRAME) ? MV_FRAME : MV_FIELD;
+ }
+ else
+ {
+ motion_vector_count = (motion_type==MC_16X8) ? 2 : 1;
+ mv_format = MV_FIELD;
+ }
+
+ dmv = (motion_type==MC_DMV); /* dual prime */
+
+ /*
+ field mv predictions in frame pictures have to be scaled
+ ISO/IEC 13818-2 section 7.6.3.1 Decoding the motion vectors
+ */
+ mvscale = (mv_format==MV_FIELD && picture_structure==FRAME_PICTURE);
+
+ /* get dct_type (frame DCT / field DCT) */
+ dct_type = (picture_structure==FRAME_PICTURE) && (!frame_pred_frame_dct)
+ && (macroblock_type & (MACROBLOCK_PATTERN|MACROBLOCK_INTRA)) ? Get_Bits(1) : 0;
+
+ /* return values */
+ *pmacroblock_type = macroblock_type;
+ *pmotion_type = motion_type;
+ *pmotion_vector_count = motion_vector_count;
+ *pmv_format = mv_format;
+ *pdmv = dmv;
+ *pmvscale = mvscale;
+ *pdct_type = dct_type;
}
/* move/add 8x8-Block from block[comp] to backward_reference_frame */
@@ -1357,792 +1352,791 @@ void CMPEG2Dec::macroblock_modes(int *pmacroblock_type, int *pmotion_type,
*/
void CMPEG2Dec::Add_Block(int count, int bx, int by, int dct_type, int addflag)
{
- static const __int64 mmmask_128 = 0x0080008000800080;
-
- int comp, cc, iincr, bxh, byh;
- unsigned char *rfp;
- short *Block_Ptr;
-
- for(comp = 0; comp < count; comp++)
- {
- Block_Ptr = block[comp];
- cc = cc_table[comp];
-
- bxh = bx;
- byh = by;
-
- if(cc == 0)
- {
- if(picture_structure == FRAME_PICTURE)
- {
- if(dct_type)
- {
- rfp = current_frame[0] + Coded_Picture_Width * (by + ((comp & 2) >> 1)) + bx + ((comp & 1) << 3);
- iincr = Coded_Picture_Width << 1;
- }
- else
- {
- rfp = current_frame[0] + Coded_Picture_Width * (by + ((comp & 2) << 2)) + bx + ((comp & 1) << 3);
- iincr = Coded_Picture_Width;
- }
- }
- else
- {
- rfp = current_frame[0] + (Coded_Picture_Width << 1) * (by + ((comp & 2) << 2)) + bx + ((comp & 1) << 3);
- iincr = Coded_Picture_Width << 1;
- }
- }
- else
- {
- if(chroma_format != CHROMA444)
- bxh >>= 1;
- if(chroma_format == CHROMA420)
- byh >>= 1;
-
- if(picture_structure == FRAME_PICTURE)
- {
- if(dct_type && chroma_format != CHROMA420)
- {
- /* field DCT coding */
- rfp = current_frame[cc] + Chroma_Width * (byh + ((comp & 2) >> 1)) + bxh + (comp & 8);
- iincr = Chroma_Width << 1;
- }
- else
- {
- /* frame DCT coding */
- rfp = current_frame[cc] + Chroma_Width * (byh + ((comp & 2) << 2)) + bxh + (comp & 8);
- iincr = Chroma_Width;
- }
- }
- else
- {
- /* field picture */
- rfp = current_frame[cc] + (Chroma_Width << 1) * (byh + ((comp & 2) << 2)) + bxh + (comp & 8);
- iincr = Chroma_Width << 1;
- }
- }
-
- if(addflag)
- {
- __asm
- {
- pxor mm0, mm0
- mov eax, [rfp]
- mov ebx, [Block_Ptr]
- mov edi, 8
- addon:
- movq mm2, [ebx+8]
-
- movq mm3, [eax]
- movq mm4, mm3
-
- movq mm1, [ebx]
- punpckhbw mm3, mm0
-
- paddsw mm3, mm2
- packuswb mm3, mm0
-
- punpcklbw mm4, mm0
- psllq mm3, 32
-
- paddsw mm4, mm1
- packuswb mm4, mm0
-
- por mm3, mm4
- add ebx, 16
-
- dec edi
- movq [eax], mm3
-
- add eax, [iincr]
- cmp edi, 0x00
- jg addon
- }
- }
- else
- {
- __asm
- {
- mov eax, [rfp]
- mov ebx, [Block_Ptr]
- mov edi, 8
-
- pxor mm0, mm0
- movq mm7, [mmmask_128]
- addoff:
- movq mm3, [ebx+8]
- movq mm4, [ebx]
-
- paddsw mm3, mm7
- paddsw mm4, mm7
-
- packuswb mm3, mm0
- packuswb mm4, mm0
-
- psllq mm3, 32
- por mm3, mm4
-
- add ebx, 16
- dec edi
-
- movq [eax], mm3
-
- add eax, [iincr]
- cmp edi, 0x00
- jg addoff
- }
- }
- }
+ static const __int64 mmmask_128 = 0x0080008000800080;
+
+ int comp, cc, iincr, bxh, byh;
+ unsigned char *rfp;
+ short *Block_Ptr;
+
+ for (comp=0; comp<count; comp++)
+ {
+ Block_Ptr = block[comp];
+ cc = cc_table[comp];
+
+ bxh = bx; byh = by;
+
+ if (cc==0)
+ {
+ if (picture_structure==FRAME_PICTURE)
+ {
+ if (dct_type)
+ {
+ rfp = current_frame[0] + Coded_Picture_Width*(by+((comp&2)>>1)) + bx + ((comp&1)<<3);
+ iincr = Coded_Picture_Width<<1;
+ }
+ else
+ {
+ rfp = current_frame[0] + Coded_Picture_Width*(by+((comp&2)<<2)) + bx + ((comp&1)<<3);
+ iincr = Coded_Picture_Width;
+ }
+ }
+ else
+ {
+ rfp = current_frame[0] + (Coded_Picture_Width<<1)*(by+((comp&2)<<2)) + bx + ((comp&1)<<3);
+ iincr = Coded_Picture_Width<<1;
+ }
+ }
+ else
+ {
+ if (chroma_format!=CHROMA444)
+ bxh >>= 1;
+ if (chroma_format==CHROMA420)
+ byh >>= 1;
+
+ if (picture_structure==FRAME_PICTURE)
+ {
+ if (dct_type && chroma_format!=CHROMA420)
+ {
+ /* field DCT coding */
+ rfp = current_frame[cc] + Chroma_Width*(byh+((comp&2)>>1)) + bxh + (comp&8);
+ iincr = Chroma_Width<<1;
+ }
+ else
+ {
+ /* frame DCT coding */
+ rfp = current_frame[cc] + Chroma_Width*(byh+((comp&2)<<2)) + bxh + (comp&8);
+ iincr = Chroma_Width;
+ }
+ }
+ else
+ {
+ /* field picture */
+ rfp = current_frame[cc] + (Chroma_Width<<1)*(byh+((comp&2)<<2)) + bxh + (comp&8);
+ iincr = Chroma_Width<<1;
+ }
+ }
+
+ if (addflag)
+ {
+ __asm
+ {
+ pxor mm0, mm0
+ mov eax, [rfp]
+ mov ebx, [Block_Ptr]
+ mov edi, 8
+addon:
+ movq mm2, [ebx+8]
+
+ movq mm3, [eax]
+ movq mm4, mm3
+
+ movq mm1, [ebx]
+ punpckhbw mm3, mm0
+
+ paddsw mm3, mm2
+ packuswb mm3, mm0
+
+ punpcklbw mm4, mm0
+ psllq mm3, 32
+
+ paddsw mm4, mm1
+ packuswb mm4, mm0
+
+ por mm3, mm4
+ add ebx, 16
+
+ dec edi
+ movq [eax], mm3
+
+ add eax, [iincr]
+ cmp edi, 0x00
+ jg addon
+ }
+ }
+ else
+ {
+ __asm
+ {
+ mov eax, [rfp]
+ mov ebx, [Block_Ptr]
+ mov edi, 8
+
+ pxor mm0, mm0
+ movq mm7, [mmmask_128]
+addoff:
+ movq mm3, [ebx+8]
+ movq mm4, [ebx]
+
+ paddsw mm3, mm7
+ paddsw mm4, mm7
+
+ packuswb mm3, mm0
+ packuswb mm4, mm0
+
+ psllq mm3, 32
+ por mm3, mm4
+
+ add ebx, 16
+ dec edi
+
+ movq [eax], mm3
+
+ add eax, [iincr]
+ cmp edi, 0x00
+ jg addoff
+ }
+ }
+ }
}
/* set scratch pad macroblock to zero */
void CMPEG2Dec::Clear_Block(int count)
{
- int comp;
- short *Block_Ptr;
-
- for(comp = 0; comp < count; comp++)
- {
- Block_Ptr = block[comp];
-
- __asm
- {
- mov eax, [Block_Ptr];
- pxor mm0, mm0;
- movq [eax+0 ], mm0;
- movq [eax+8 ], mm0;
- movq [eax+16], mm0;
- movq [eax+24], mm0;
- movq [eax+32], mm0;
- movq [eax+40], mm0;
- movq [eax+48], mm0;
- movq [eax+56], mm0;
- movq [eax+64], mm0;
- movq [eax+72], mm0;
- movq [eax+80], mm0;
- movq [eax+88], mm0;
- movq [eax+96], mm0;
- movq [eax+104], mm0;
- movq [eax+112], mm0;
- movq [eax+120], mm0;
- }
- }
+ int comp;
+ short *Block_Ptr;
+
+ for (comp=0; comp<count; comp++)
+ {
+ Block_Ptr = block[comp];
+
+ __asm
+ {
+ mov eax, [Block_Ptr];
+ pxor mm0, mm0;
+ movq [eax+0 ], mm0;
+ movq [eax+8 ], mm0;
+ movq [eax+16], mm0;
+ movq [eax+24], mm0;
+ movq [eax+32], mm0;
+ movq [eax+40], mm0;
+ movq [eax+48], mm0;
+ movq [eax+56], mm0;
+ movq [eax+64], mm0;
+ movq [eax+72], mm0;
+ movq [eax+80], mm0;
+ movq [eax+88], mm0;
+ movq [eax+96], mm0;
+ movq [eax+104],mm0;
+ movq [eax+112],mm0;
+ movq [eax+120],mm0;
+ }
+ }
}
/* ISO/IEC 13818-2 section 7.6 */
-void CMPEG2Dec::motion_compensation(int MBA, int macroblock_type, int motion_type,
- int PMV[2][2][2], int motion_vertical_field_select[2][2],
- int dmvector[2], int dct_type)
+void CMPEG2Dec::motion_compensation(int MBA, int macroblock_type, int motion_type,
+ int PMV[2][2][2], int motion_vertical_field_select[2][2],
+ int dmvector[2], int dct_type)
{
- int bx, by;
- int comp;
-
- /* derive current macroblock position within picture */
- /* ISO/IEC 13818-2 section 6.3.1.6 and 6.3.1.7 */
- bx = 16 * (MBA % mb_width);
- by = 16 * (MBA / mb_width);
-
- /* motion compensation */
- if(!(macroblock_type & MACROBLOCK_INTRA))
- form_predictions(bx, by, macroblock_type, motion_type, PMV,
- motion_vertical_field_select, dmvector);
-
- switch(IDCT_Flag)
- {
- case IDCT_MMX:
- for(comp = 0; comp < block_count; comp++)
- MMX_IDCT(block[comp]);
- break;
-
- case IDCT_SSEMMX:
- for(comp = 0; comp < block_count; comp++)
- SSEMMX_IDCT(block[comp]);
- break;
-
- case IDCT_FPU:
- __asm emms;
- for(comp = 0; comp < block_count; comp++)
- FPU_IDCT(block[comp]);
- break;
-
- case IDCT_REF:
- __asm emms;
- for(comp = 0; comp < block_count; comp++)
- REF_IDCT(block[comp]);
- break;
- }
-
- Add_Block(block_count, bx, by, dct_type, (macroblock_type & MACROBLOCK_INTRA) == 0);
+ int bx, by;
+ int comp;
+
+ /* derive current macroblock position within picture */
+ /* ISO/IEC 13818-2 section 6.3.1.6 and 6.3.1.7 */
+ bx = 16*(MBA%mb_width);
+ by = 16*(MBA/mb_width);
+
+ /* motion compensation */
+ if (!(macroblock_type & MACROBLOCK_INTRA))
+ form_predictions(bx, by, macroblock_type, motion_type, PMV,
+ motion_vertical_field_select, dmvector);
+
+ switch (IDCT_Flag)
+ {
+ case IDCT_MMX:
+ for (comp=0; comp<block_count; comp++)
+ MMX_IDCT(block[comp]);
+ break;
+
+ case IDCT_SSEMMX:
+ for (comp=0; comp<block_count; comp++)
+ SSEMMX_IDCT(block[comp]);
+ break;
+
+ case IDCT_FPU:
+ __asm emms;
+ for (comp=0; comp<block_count; comp++)
+ FPU_IDCT(block[comp]);
+ break;
+
+ case IDCT_REF:
+ __asm emms;
+ for (comp=0; comp<block_count; comp++)
+ REF_IDCT(block[comp]);
+ break;
+ }
+
+ Add_Block(block_count, bx, by, dct_type, (macroblock_type & MACROBLOCK_INTRA)==0);
}
/* ISO/IEC 13818-2 section 7.6.6 */
-void CMPEG2Dec::skipped_macroblock(int dc_dct_pred[3], int PMV[2][2][2], int *motion_type,
- int motion_vertical_field_select[2][2], int *macroblock_type)
+void CMPEG2Dec::skipped_macroblock(int dc_dct_pred[3], int PMV[2][2][2], int *motion_type,
+ int motion_vertical_field_select[2][2], int *macroblock_type)
{
- Clear_Block(block_count);
-
- /* reset intra_dc predictors */
- /* ISO/IEC 13818-2 section 7.2.1: DC coefficients in intra blocks */
- dc_dct_pred[0] = dc_dct_pred[1] = dc_dct_pred[2] = 0;
-
- /* reset motion vector predictors */
- /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */
- if(picture_coding_type == P_TYPE)
- PMV[0][0][0] = PMV[0][0][1] = PMV[1][0][0] = PMV[1][0][1] = 0;
-
- /* derive motion_type */
- if(picture_structure == FRAME_PICTURE)
- *motion_type = MC_FRAME;
- else
- {
- *motion_type = MC_FIELD;
- motion_vertical_field_select[0][0] = motion_vertical_field_select[0][1] =
- (picture_structure == BOTTOM_FIELD);
- }
-
- /* clear MACROBLOCK_INTRA */
- *macroblock_type &= ~MACROBLOCK_INTRA;
+ Clear_Block(block_count);
+
+ /* reset intra_dc predictors */
+ /* ISO/IEC 13818-2 section 7.2.1: DC coefficients in intra blocks */
+ dc_dct_pred[0]=dc_dct_pred[1]=dc_dct_pred[2]=0;
+
+ /* reset motion vector predictors */
+ /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */
+ if (picture_coding_type==P_TYPE)
+ PMV[0][0][0]=PMV[0][0][1]=PMV[1][0][0]=PMV[1][0][1]=0;
+
+ /* derive motion_type */
+ if (picture_structure==FRAME_PICTURE)
+ *motion_type = MC_FRAME;
+ else
+ {
+ *motion_type = MC_FIELD;
+ motion_vertical_field_select[0][0] = motion_vertical_field_select[0][1] =
+ (picture_structure==BOTTOM_FIELD);
+ }
+
+ /* clear MACROBLOCK_INTRA */
+ *macroblock_type&= ~MACROBLOCK_INTRA;
}
/* return==-1 means go to next picture */
/* the expression "start of slice" is used throughout the normative
body of the MPEG specification */
int CMPEG2Dec::start_of_slice(int *MBA, int *MBAinc,
- int dc_dct_pred[3], int PMV[2][2][2])
+ int dc_dct_pred[3], int PMV[2][2][2])
{
- unsigned int code;
- int slice_vert_pos_ext;
-
- next_start_code();
- code = Get_Bits(32);
-
- if(code < SLICE_START_CODE_MIN || code > SLICE_START_CODE_MAX)
- {
- // only slice headers are allowed in picture_data
- Fault_Flag = 10;
- return -1;
- }
-
- /* decode slice header (may change quantizer_scale) */
- slice_vert_pos_ext = slice_header();
-
- /* decode macroblock address increment */
- *MBAinc = Get_macroblock_address_increment();
- if(Fault_Flag) return -1;
-
- /* set current location */
- /* NOTE: the arithmetic used to derive macroblock_address below is
- equivalent to ISO/IEC 13818-2 section 6.3.17: Macroblock */
- *MBA = ((slice_vert_pos_ext << 7) + (code & 255) - 1) * mb_width + *MBAinc - 1;
- *MBAinc = 1; // first macroblock in slice: not skipped
-
- /* reset all DC coefficient and motion vector predictors */
- /* ISO/IEC 13818-2 section 7.2.1: DC coefficients in intra blocks */
- dc_dct_pred[0] = dc_dct_pred[1] = dc_dct_pred[2] = 0;
-
- /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */
- PMV[0][0][0] = PMV[0][0][1] = PMV[1][0][0] = PMV[1][0][1] = 0;
- PMV[0][1][0] = PMV[0][1][1] = PMV[1][1][0] = PMV[1][1][1] = 0;
-
- /* successfull: trigger decode macroblocks in slice */
- return 1;
+ unsigned int code;
+ int slice_vert_pos_ext;
+
+ next_start_code();
+ code = Get_Bits(32);
+
+ if (code<SLICE_START_CODE_MIN || code>SLICE_START_CODE_MAX)
+ {
+ // only slice headers are allowed in picture_data
+ Fault_Flag = 10;
+ return -1;
+ }
+
+ /* decode slice header (may change quantizer_scale) */
+ slice_vert_pos_ext = slice_header();
+
+ /* decode macroblock address increment */
+ *MBAinc = Get_macroblock_address_increment();
+ if (Fault_Flag) return -1;
+
+ /* set current location */
+ /* NOTE: the arithmetic used to derive macroblock_address below is
+ equivalent to ISO/IEC 13818-2 section 6.3.17: Macroblock */
+ *MBA = ((slice_vert_pos_ext<<7) + (code&255) - 1)*mb_width + *MBAinc - 1;
+ *MBAinc = 1; // first macroblock in slice: not skipped
+
+ /* reset all DC coefficient and motion vector predictors */
+ /* ISO/IEC 13818-2 section 7.2.1: DC coefficients in intra blocks */
+ dc_dct_pred[0]=dc_dct_pred[1]=dc_dct_pred[2]=0;
+
+ /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */
+ PMV[0][0][0]=PMV[0][0][1]=PMV[1][0][0]=PMV[1][0][1]=0;
+ PMV[0][1][0]=PMV[0][1][1]=PMV[1][1][0]=PMV[1][1][1]=0;
+
+ /* successfull: trigger decode macroblocks in slice */
+ return 1;
}
/* ISO/IEC 13818-2 sections 7.2 through 7.5 */
int CMPEG2Dec::decode_macroblock(int *macroblock_type, int *motion_type, int *dct_type,
- int PMV[2][2][2], int dc_dct_pred[3],
- int motion_vertical_field_select[2][2], int dmvector[2])
+ int PMV[2][2][2], int dc_dct_pred[3],
+ int motion_vertical_field_select[2][2], int dmvector[2])
{
- int quantizer_scale_code, comp, motion_vector_count, mv_format;
- int dmv, mvscale, coded_block_pattern;
-
- /* ISO/IEC 13818-2 section 6.3.17.1: Macroblock modes */
- macroblock_modes(macroblock_type, motion_type, &motion_vector_count, &mv_format,
- &dmv, &mvscale, dct_type);
- if(Fault_Flag) return 0; // trigger: go to next slice
-
- if(*macroblock_type & MACROBLOCK_QUANT)
- {
- quantizer_scale_code = Get_Bits(5);
-
- /* ISO/IEC 13818-2 section 7.4.2.2: Quantizer scale factor */
- quantizer_scale = q_scale_type ?
- Non_Linear_quantizer_scale[quantizer_scale_code] : (quantizer_scale_code << 1);
- }
-
- /* ISO/IEC 13818-2 section 6.3.17.2: Motion vectors */
- /* decode forward motion vectors */
- if((*macroblock_type & MACROBLOCK_MOTION_FORWARD)
- || ((*macroblock_type & MACROBLOCK_INTRA) && concealment_motion_vectors))
- motion_vectors(PMV, dmvector, motion_vertical_field_select, 0,
- motion_vector_count, mv_format, f_code[0][0] - 1, f_code[0][1] - 1, dmv, mvscale);
- if(Fault_Flag) return 0; // trigger: go to next slice
-
- /* decode backward motion vectors */
- if(*macroblock_type & MACROBLOCK_MOTION_BACKWARD)
- motion_vectors(PMV, dmvector, motion_vertical_field_select, 1,
- motion_vector_count, mv_format, f_code[1][0] - 1, f_code[1][1] - 1, 0, mvscale);
- if(Fault_Flag) return 0; // trigger: go to next slice
-
- if((*macroblock_type & MACROBLOCK_INTRA) && concealment_motion_vectors)
- Flush_Buffer(1); // marker bit
-
- /* macroblock_pattern */
- /* ISO/IEC 13818-2 section 6.3.17.4: Coded block pattern */
- if(*macroblock_type & MACROBLOCK_PATTERN)
- {
- coded_block_pattern = Get_coded_block_pattern();
-
- if(chroma_format == CHROMA422)
- coded_block_pattern = (coded_block_pattern << 2) | Get_Bits(2);
- else if(chroma_format == CHROMA444)
- coded_block_pattern = (coded_block_pattern << 6) | Get_Bits(6);
- }
- else
- coded_block_pattern = (*macroblock_type & MACROBLOCK_INTRA) ? (1 << block_count) - 1 : 0;
-
- if(Fault_Flag) return 0; // trigger: go to next slice
-
- Clear_Block(block_count);
-
- /* decode blocks */
- for(comp = 0; comp < block_count; comp++)
- {
- if(coded_block_pattern & (1 << (block_count - 1 - comp)))
- {
- if(*macroblock_type & MACROBLOCK_INTRA)
- Decode_MPEG2_Intra_Block(comp, dc_dct_pred);
- else
- Decode_MPEG2_Non_Intra_Block(comp);
- if(Fault_Flag) return 0; // trigger: go to next slice
- }
- }
-
- /* reset intra_dc predictors */
- /* ISO/IEC 13818-2 section 7.2.1: DC coefficients in intra blocks */
- if(!(*macroblock_type & MACROBLOCK_INTRA))
- dc_dct_pred[0] = dc_dct_pred[1] = dc_dct_pred[2] = 0;
-
- /* reset motion vector predictors */
- if((*macroblock_type & MACROBLOCK_INTRA) && !concealment_motion_vectors)
- {
- /* intra mb without concealment motion vectors */
- /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */
- PMV[0][0][0] = PMV[0][0][1] = PMV[1][0][0] = PMV[1][0][1] = 0;
- PMV[0][1][0] = PMV[0][1][1] = PMV[1][1][0] = PMV[1][1][1] = 0;
- }
-
- /* special "No_MC" macroblock_type case */
- /* ISO/IEC 13818-2 section 7.6.3.5: Prediction in P pictures */
- if((picture_coding_type == P_TYPE)
- && !(*macroblock_type & (MACROBLOCK_MOTION_FORWARD | MACROBLOCK_INTRA)))
- {
- /* non-intra mb without forward mv in a P picture */
- /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */
- PMV[0][0][0] = PMV[0][0][1] = PMV[1][0][0] = PMV[1][0][1] = 0;
-
- /* derive motion_type */
- /* ISO/IEC 13818-2 section 6.3.17.1: Macroblock modes, frame_motion_type */
- if(picture_structure == FRAME_PICTURE)
- *motion_type = MC_FRAME;
- else
- {
- *motion_type = MC_FIELD;
- motion_vertical_field_select[0][0] = (picture_structure == BOTTOM_FIELD);
- }
- }
- /* successfully decoded macroblock */
- return 1 ;
+ int quantizer_scale_code, comp, motion_vector_count, mv_format;
+ int dmv, mvscale, coded_block_pattern;
+
+ /* ISO/IEC 13818-2 section 6.3.17.1: Macroblock modes */
+ macroblock_modes(macroblock_type, motion_type, &motion_vector_count, &mv_format,
+ &dmv, &mvscale, dct_type);
+ if (Fault_Flag) return 0; // trigger: go to next slice
+
+ if (*macroblock_type & MACROBLOCK_QUANT)
+ {
+ quantizer_scale_code = Get_Bits(5);
+
+ /* ISO/IEC 13818-2 section 7.4.2.2: Quantizer scale factor */
+ quantizer_scale = q_scale_type ?
+ Non_Linear_quantizer_scale[quantizer_scale_code] : (quantizer_scale_code << 1);
+ }
+
+ /* ISO/IEC 13818-2 section 6.3.17.2: Motion vectors */
+ /* decode forward motion vectors */
+ if ((*macroblock_type & MACROBLOCK_MOTION_FORWARD)
+ || ((*macroblock_type & MACROBLOCK_INTRA) && concealment_motion_vectors))
+ motion_vectors(PMV, dmvector, motion_vertical_field_select, 0,
+ motion_vector_count, mv_format, f_code[0][0]-1, f_code[0][1]-1, dmv, mvscale);
+ if (Fault_Flag) return 0; // trigger: go to next slice
+
+ /* decode backward motion vectors */
+ if (*macroblock_type & MACROBLOCK_MOTION_BACKWARD)
+ motion_vectors(PMV, dmvector, motion_vertical_field_select, 1,
+ motion_vector_count,mv_format, f_code[1][0]-1, f_code[1][1]-1, 0, mvscale);
+ if (Fault_Flag) return 0; // trigger: go to next slice
+
+ if ((*macroblock_type & MACROBLOCK_INTRA) && concealment_motion_vectors)
+ Flush_Buffer(1); // marker bit
+
+ /* macroblock_pattern */
+ /* ISO/IEC 13818-2 section 6.3.17.4: Coded block pattern */
+ if (*macroblock_type & MACROBLOCK_PATTERN)
+ {
+ coded_block_pattern = Get_coded_block_pattern();
+
+ if (chroma_format==CHROMA422)
+ coded_block_pattern = (coded_block_pattern<<2) | Get_Bits(2);
+ else if (chroma_format==CHROMA444)
+ coded_block_pattern = (coded_block_pattern<<6) | Get_Bits(6);
+ }
+ else
+ coded_block_pattern = (*macroblock_type & MACROBLOCK_INTRA) ? (1<<block_count)-1 : 0;
+
+ if (Fault_Flag) return 0; // trigger: go to next slice
+
+ Clear_Block(block_count);
+
+ /* decode blocks */
+ for (comp=0; comp<block_count; comp++)
+ {
+ if (coded_block_pattern & (1<<(block_count-1-comp)))
+ {
+ if (*macroblock_type & MACROBLOCK_INTRA)
+ Decode_MPEG2_Intra_Block(comp, dc_dct_pred);
+ else
+ Decode_MPEG2_Non_Intra_Block(comp);
+ if (Fault_Flag) return 0; // trigger: go to next slice
+ }
+ }
+
+ /* reset intra_dc predictors */
+ /* ISO/IEC 13818-2 section 7.2.1: DC coefficients in intra blocks */
+ if (!(*macroblock_type & MACROBLOCK_INTRA))
+ dc_dct_pred[0]=dc_dct_pred[1]=dc_dct_pred[2]=0;
+
+ /* reset motion vector predictors */
+ if ((*macroblock_type & MACROBLOCK_INTRA) && !concealment_motion_vectors)
+ {
+ /* intra mb without concealment motion vectors */
+ /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */
+ PMV[0][0][0]=PMV[0][0][1]=PMV[1][0][0]=PMV[1][0][1]=0;
+ PMV[0][1][0]=PMV[0][1][1]=PMV[1][1][0]=PMV[1][1][1]=0;
+ }
+
+ /* special "No_MC" macroblock_type case */
+ /* ISO/IEC 13818-2 section 7.6.3.5: Prediction in P pictures */
+ if ((picture_coding_type==P_TYPE)
+ && !(*macroblock_type & (MACROBLOCK_MOTION_FORWARD|MACROBLOCK_INTRA)))
+ {
+ /* non-intra mb without forward mv in a P picture */
+ /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */
+ PMV[0][0][0]=PMV[0][0][1]=PMV[1][0][0]=PMV[1][0][1]=0;
+
+ /* derive motion_type */
+ /* ISO/IEC 13818-2 section 6.3.17.1: Macroblock modes, frame_motion_type */
+ if (picture_structure==FRAME_PICTURE)
+ *motion_type = MC_FRAME;
+ else
+ {
+ *motion_type = MC_FIELD;
+ motion_vertical_field_select[0][0] = (picture_structure==BOTTOM_FIELD);
+ }
+ }
+ /* successfully decoded macroblock */
+ return 1 ;
}
/* decode one intra coded MPEG-2 block */
void CMPEG2Dec::Decode_MPEG2_Intra_Block(int comp, int dc_dct_pred[])
{
- int val, i, j, sign, *qmat;
- unsigned int code;
- DCTtab *tab;
- short *bp;
-
- bp = block[comp];
- qmat = (comp < 4 || chroma_format == CHROMA420)
- ? intra_quantizer_matrix : chroma_intra_quantizer_matrix;
-
- /* ISO/IEC 13818-2 section 7.2.1: decode DC coefficients */
- switch(cc_table[comp])
- {
- case 0:
- val = (dc_dct_pred[0] += Get_Luma_DC_dct_diff());
- break;
-
- case 1:
- val = (dc_dct_pred[1] += Get_Chroma_DC_dct_diff());
- break;
-
- case 2:
- val = (dc_dct_pred[2] += Get_Chroma_DC_dct_diff());
- break;
- }
-
- bp[0] = val << (3 - intra_dc_precision);
-
- /* decode AC coefficients */
- for(i = 1; ; i++)
- {
- code = Show_Bits(16);
-
- if(code >= 16384 && !intra_vlc_format)
- tab = &DCTtabnext[(code>>12)-4];
- else if(code >= 1024)
- {
- if(intra_vlc_format)
- tab = &DCTtab0a[(code>>8)-4];
- else
- tab = &DCTtab0[(code>>8)-4];
- }
- else if(code >= 512)
- {
- if(intra_vlc_format)
- tab = &DCTtab1a[(code>>6)-8];
- else
- tab = &DCTtab1[(code>>6)-8];
- }
- else if(code >= 256)
- tab = &DCTtab2[(code>>4)-16];
- else if(code >= 128)
- tab = &DCTtab3[(code>>3)-16];
- else if(code >= 64)
- tab = &DCTtab4[(code>>2)-16];
- else if(code >= 32)
- tab = &DCTtab5[(code>>1)-16];
- else if(code >= 16)
- tab = &DCTtab6[code-16];
- else
- {
- Fault_Flag = 1;
- return;
- }
-
- Flush_Buffer(tab->len);
-
- if(tab->run < 64)
- {
- i += tab->run;
- val = tab->level;
- sign = Get_Bits(1);
- }
- else if(tab->run == 64) /* end_of_block */
- return;
- else /* escape */
- {
- i += Get_Bits(6);
- val = Get_Bits(12);
-
- if(sign = (val >= 2048))
- val = 4096 - val;
- }
-
- j = scan[alternate_scan][i];
-
- val = (val * quantizer_scale * qmat[j]) >> 4;
- bp[j] = sign ? -val : val;
- }
+ int val, i, j, sign, *qmat;
+ unsigned int code;
+ DCTtab *tab;
+ short *bp;
+
+ bp = block[comp];
+ qmat = (comp<4 || chroma_format==CHROMA420)
+ ? intra_quantizer_matrix : chroma_intra_quantizer_matrix;
+
+ /* ISO/IEC 13818-2 section 7.2.1: decode DC coefficients */
+ switch (cc_table[comp])
+ {
+ case 0:
+ val = (dc_dct_pred[0]+= Get_Luma_DC_dct_diff());
+ break;
+
+ case 1:
+ val = (dc_dct_pred[1]+= Get_Chroma_DC_dct_diff());
+ break;
+
+ case 2:
+ val = (dc_dct_pred[2]+= Get_Chroma_DC_dct_diff());
+ break;
+ }
+
+ bp[0] = val << (3-intra_dc_precision);
+
+ /* decode AC coefficients */
+ for (i=1; ; i++)
+ {
+ code = Show_Bits(16);
+
+ if (code>=16384 && !intra_vlc_format)
+ tab = &DCTtabnext[(code>>12)-4];
+ else if (code>=1024)
+ {
+ if (intra_vlc_format)
+ tab = &DCTtab0a[(code>>8)-4];
+ else
+ tab = &DCTtab0[(code>>8)-4];
+ }
+ else if (code>=512)
+ {
+ if (intra_vlc_format)
+ tab = &DCTtab1a[(code>>6)-8];
+ else
+ tab = &DCTtab1[(code>>6)-8];
+ }
+ else if (code>=256)
+ tab = &DCTtab2[(code>>4)-16];
+ else if (code>=128)
+ tab = &DCTtab3[(code>>3)-16];
+ else if (code>=64)
+ tab = &DCTtab4[(code>>2)-16];
+ else if (code>=32)
+ tab = &DCTtab5[(code>>1)-16];
+ else if (code>=16)
+ tab = &DCTtab6[code-16];
+ else
+ {
+ Fault_Flag = 1;
+ return;
+ }
+
+ Flush_Buffer(tab->len);
+
+ if (tab->run<64)
+ {
+ i+= tab->run;
+ val = tab->level;
+ sign = Get_Bits(1);
+ }
+ else if (tab->run==64) /* end_of_block */
+ return;
+ else /* escape */
+ {
+ i+= Get_Bits(6);
+ val = Get_Bits(12);
+
+ if (sign = (val>=2048))
+ val = 4096 - val;
+ }
+
+ j = scan[alternate_scan][i];
+
+ val = (val * quantizer_scale * qmat[j]) >> 4;
+ bp[j] = sign ? -val : val;
+ }
}
/* decode one non-intra coded MPEG-2 block */
void CMPEG2Dec::Decode_MPEG2_Non_Intra_Block(int comp)
{
- int val, i, j, sign, *qmat;
- unsigned int code;
- DCTtab *tab;
- short *bp;
-
- bp = block[comp];
- qmat = (comp < 4 || chroma_format == CHROMA420)
- ? non_intra_quantizer_matrix : chroma_non_intra_quantizer_matrix;
-
- /* decode AC coefficients */
- for(i = 0; ; i++)
- {
- code = Show_Bits(16);
-
- if(code >= 16384)
- {
- if(i == 0)
- tab = &DCTtabfirst[(code>>12)-4];
- else
- tab = &DCTtabnext[(code>>12)-4];
- }
- else if(code >= 1024)
- tab = &DCTtab0[(code>>8)-4];
- else if(code >= 512)
- tab = &DCTtab1[(code>>6)-8];
- else if(code >= 256)
- tab = &DCTtab2[(code>>4)-16];
- else if(code >= 128)
- tab = &DCTtab3[(code>>3)-16];
- else if(code >= 64)
- tab = &DCTtab4[(code>>2)-16];
- else if(code >= 32)
- tab = &DCTtab5[(code>>1)-16];
- else if(code >= 16)
- tab = &DCTtab6[code-16];
- else
- {
- Fault_Flag = 1;
- return;
- }
-
- Flush_Buffer(tab->len);
-
- if(tab->run < 64)
- {
- i += tab->run;
- val = tab->level;
- sign = Get_Bits(1);
- }
- else if(tab->run == 64) /* end_of_block */
- return;
- else /* escape */
- {
- i += Get_Bits(6);
- val = Get_Bits(12);
-
- if(sign = (val >= 2048))
- val = 4096 - val;
- }
-
- j = scan[alternate_scan][i];
-
- val = (((val << 1) + 1) * quantizer_scale * qmat[j]) >> 5;
- bp[j] = sign ? -val : val;
- }
+ int val, i, j, sign, *qmat;
+ unsigned int code;
+ DCTtab *tab;
+ short *bp;
+
+ bp = block[comp];
+ qmat = (comp<4 || chroma_format==CHROMA420)
+ ? non_intra_quantizer_matrix : chroma_non_intra_quantizer_matrix;
+
+ /* decode AC coefficients */
+ for (i=0; ; i++)
+ {
+ code = Show_Bits(16);
+
+ if (code>=16384)
+ {
+ if (i==0)
+ tab = &DCTtabfirst[(code>>12)-4];
+ else
+ tab = &DCTtabnext[(code>>12)-4];
+ }
+ else if (code>=1024)
+ tab = &DCTtab0[(code>>8)-4];
+ else if (code>=512)
+ tab = &DCTtab1[(code>>6)-8];
+ else if (code>=256)
+ tab = &DCTtab2[(code>>4)-16];
+ else if (code>=128)
+ tab = &DCTtab3[(code>>3)-16];
+ else if (code>=64)
+ tab = &DCTtab4[(code>>2)-16];
+ else if (code>=32)
+ tab = &DCTtab5[(code>>1)-16];
+ else if (code>=16)
+ tab = &DCTtab6[code-16];
+ else
+ {
+ Fault_Flag = 1;
+ return;
+ }
+
+ Flush_Buffer(tab->len);
+
+ if (tab->run<64)
+ {
+ i+= tab->run;
+ val = tab->level;
+ sign = Get_Bits(1);
+ }
+ else if (tab->run==64) /* end_of_block */
+ return;
+ else /* escape */
+ {
+ i+= Get_Bits(6);
+ val = Get_Bits(12);
+
+ if (sign = (val>=2048))
+ val = 4096 - val;
+ }
+
+ j = scan[alternate_scan][i];
+
+ val = (((val<<1)+1) * quantizer_scale * qmat[j]) >> 5;
+ bp[j] = sign ? -val : val;
+ }
}
int CMPEG2Dec::Get_macroblock_type()
{
- int macroblock_type;
+ int macroblock_type;
- switch(picture_coding_type)
- {
- case I_TYPE:
- macroblock_type = Get_I_macroblock_type();
- break;
+ switch (picture_coding_type)
+ {
+ case I_TYPE:
+ macroblock_type = Get_I_macroblock_type();
+ break;
- case P_TYPE:
- macroblock_type = Get_P_macroblock_type();
- break;
+ case P_TYPE:
+ macroblock_type = Get_P_macroblock_type();
+ break;
- case B_TYPE:
- macroblock_type = Get_B_macroblock_type();
- break;
- }
+ case B_TYPE:
+ macroblock_type = Get_B_macroblock_type();
+ break;
+ }
- return macroblock_type;
+ return macroblock_type;
}
int CMPEG2Dec::Get_I_macroblock_type()
{
- if(Get_Bits(1))
- return 1;
+ if (Get_Bits(1))
+ return 1;
- if(!Get_Bits(1))
- Fault_Flag = 2;
+ if (!Get_Bits(1))
+ Fault_Flag = 2;
- return 17;
+ return 17;
}
int CMPEG2Dec::Get_P_macroblock_type()
{
- int code;
+ int code;
- if((code = Show_Bits(6)) >= 8)
- {
- code >>= 3;
- Flush_Buffer(PMBtab0[code].len);
+ if ((code = Show_Bits(6))>=8)
+ {
+ code >>= 3;
+ Flush_Buffer(PMBtab0[code].len);
- return PMBtab0[code].val;
- }
+ return PMBtab0[code].val;
+ }
- if(code == 0)
- {
- Fault_Flag = 2;
- return 0;
- }
+ if (code==0)
+ {
+ Fault_Flag = 2;
+ return 0;
+ }
- Flush_Buffer(PMBtab1[code].len);
+ Flush_Buffer(PMBtab1[code].len);
- return PMBtab1[code].val;
+ return PMBtab1[code].val;
}
int CMPEG2Dec::Get_B_macroblock_type()
{
- int code;
+ int code;
- if((code = Show_Bits(6)) >= 8)
- {
- code >>= 2;
- Flush_Buffer(BMBtab0[code].len);
+ if ((code = Show_Bits(6))>=8)
+ {
+ code >>= 2;
+ Flush_Buffer(BMBtab0[code].len);
- return BMBtab0[code].val;
- }
+ return BMBtab0[code].val;
+ }
- if(code == 0)
- {
- Fault_Flag = 2;
- return 0;
- }
+ if (code==0)
+ {
+ Fault_Flag = 2;
+ return 0;
+ }
- Flush_Buffer(BMBtab1[code].len);
+ Flush_Buffer(BMBtab1[code].len);
- return BMBtab1[code].val;
+ return BMBtab1[code].val;
}
int CMPEG2Dec::Get_coded_block_pattern()
{
- int code;
+ int code;
- if((code = Show_Bits(9)) >= 128)
- {
- code >>= 4;
- Flush_Buffer(CBPtab0[code].len);
+ if ((code = Show_Bits(9))>=128)
+ {
+ code >>= 4;
+ Flush_Buffer(CBPtab0[code].len);
- return CBPtab0[code].val;
- }
+ return CBPtab0[code].val;
+ }
- if(code >= 8)
- {
- code >>= 1;
- Flush_Buffer(CBPtab1[code].len);
+ if (code>=8)
+ {
+ code >>= 1;
+ Flush_Buffer(CBPtab1[code].len);
- return CBPtab1[code].val;
- }
+ return CBPtab1[code].val;
+ }
- if(code < 1)
- {
- Fault_Flag = 3;
- return 0;
- }
+ if (code<1)
+ {
+ Fault_Flag = 3;
+ return 0;
+ }
- Flush_Buffer(CBPtab2[code].len);
+ Flush_Buffer(CBPtab2[code].len);
- return CBPtab2[code].val;
+ return CBPtab2[code].val;
}
int CMPEG2Dec::Get_macroblock_address_increment()
{
- int code, val;
-
- val = 0;
-
- while((code = Show_Bits(11)) < 24)
- {
- if(code != 15) /* if not macroblock_stuffing */
- {
- if(code == 8) /* if macroblock_escape */
- val += 33;
- else
- {
- Fault_Flag = 4;
- return 1;
- }
- }
- Flush_Buffer(11);
- }
-
- /* macroblock_address_increment == 1 */
- /* ('1' is in the MSB position of the lookahead) */
- if(code >= 1024)
- {
- Flush_Buffer(1);
- return val + 1;
- }
-
- /* codes 00010 ... 011xx */
- if(code >= 128)
- {
- /* remove leading zeros */
- code >>= 6;
- Flush_Buffer(MBAtab1[code].len);
-
- return val + MBAtab1[code].val;
- }
-
- /* codes 00000011000 ... 0000111xxxx */
- code -= 24; /* remove common base */
- Flush_Buffer(MBAtab2[code].len);
-
- return val + MBAtab2[code].val;
+ int code, val;
+
+ val = 0;
+
+ while ((code = Show_Bits(11))<24)
+ {
+ if (code!=15) /* if not macroblock_stuffing */
+ {
+ if (code==8) /* if macroblock_escape */
+ val+= 33;
+ else
+ {
+ Fault_Flag = 4;
+ return 1;
+ }
+ }
+ Flush_Buffer(11);
+ }
+
+ /* macroblock_address_increment == 1 */
+ /* ('1' is in the MSB position of the lookahead) */
+ if (code>=1024)
+ {
+ Flush_Buffer(1);
+ return val + 1;
+ }
+
+ /* codes 00010 ... 011xx */
+ if (code>=128)
+ {
+ /* remove leading zeros */
+ code >>= 6;
+ Flush_Buffer(MBAtab1[code].len);
+
+ return val + MBAtab1[code].val;
+ }
+
+ /* codes 00000011000 ... 0000111xxxx */
+ code-= 24; /* remove common base */
+ Flush_Buffer(MBAtab2[code].len);
+
+ return val + MBAtab2[code].val;
}
/*
parse VLC and perform dct_diff arithmetic.
- MPEG-2: ISO/IEC 13818-2 section 7.2.1
+ MPEG-2: ISO/IEC 13818-2 section 7.2.1
Note: the arithmetic here is presented more elegantly than
the spec, yet the results, dct_diff, are the same.
*/
int CMPEG2Dec::Get_Luma_DC_dct_diff()
{
- int code, size, dct_diff;
-
- /* decode length */
- code = Show_Bits(5);
-
- if(code < 31)
- {
- size = DClumtab0[code].val;
- Flush_Buffer(DClumtab0[code].len);
- }
- else
- {
- code = Show_Bits(9) - 0x1f0;
- size = DClumtab1[code].val;
- Flush_Buffer(DClumtab1[code].len);
- }
-
- if(size == 0)
- dct_diff = 0;
- else
- {
- dct_diff = Get_Bits(size);
-
- if((dct_diff & (1 << (size - 1))) == 0)
- dct_diff -= (1 << size) - 1;
- }
-
- return dct_diff;
+ int code, size, dct_diff;
+
+ /* decode length */
+ code = Show_Bits(5);
+
+ if (code<31)
+ {
+ size = DClumtab0[code].val;
+ Flush_Buffer(DClumtab0[code].len);
+ }
+ else
+ {
+ code = Show_Bits(9) - 0x1f0;
+ size = DClumtab1[code].val;
+ Flush_Buffer(DClumtab1[code].len);
+ }
+
+ if (size==0)
+ dct_diff = 0;
+ else
+ {
+ dct_diff = Get_Bits(size);
+
+ if ((dct_diff & (1<<(size-1)))==0)
+ dct_diff-= (1<<size) - 1;
+ }
+
+ return dct_diff;
}
int CMPEG2Dec::Get_Chroma_DC_dct_diff()
{
- int code, size, dct_diff;
-
- /* decode length */
- code = Show_Bits(5);
-
- if(code < 31)
- {
- size = DCchromtab0[code].val;
- Flush_Buffer(DCchromtab0[code].len);
- }
- else
- {
- code = Show_Bits(10) - 0x3e0;
- size = DCchromtab1[code].val;
- Flush_Buffer(DCchromtab1[code].len);
- }
-
- if(size == 0)
- dct_diff = 0;
- else
- {
- dct_diff = Get_Bits(size);
-
- if((dct_diff & (1 << (size - 1))) == 0)
- dct_diff -= (1 << size) - 1;
- }
-
- return dct_diff;
+ int code, size, dct_diff;
+
+ /* decode length */
+ code = Show_Bits(5);
+
+ if (code<31)
+ {
+ size = DCchromtab0[code].val;
+ Flush_Buffer(DCchromtab0[code].len);
+ }
+ else
+ {
+ code = Show_Bits(10) - 0x3e0;
+ size = DCchromtab1[code].val;
+ Flush_Buffer(DCchromtab1[code].len);
+ }
+
+ if (size==0)
+ dct_diff = 0;
+ else
+ {
+ dct_diff = Get_Bits(size);
+
+ if ((dct_diff & (1<<(size-1)))==0)
+ dct_diff-= (1<<size) - 1;
+ }
+
+ return dct_diff;
}
/*
@@ -2153,697 +2147,691 @@ static int stw;
*/
void CMPEG2Dec::form_predictions(int bx, int by, int macroblock_type, int motion_type,
- int PMV[2][2][2], int motion_vertical_field_select[2][2],
- int dmvector[2])
+ int PMV[2][2][2], int motion_vertical_field_select[2][2],
+ int dmvector[2])
{
- int currentfield;
- unsigned char **predframe;
- int DMV[2][2];
- int stw;
-
- stw = 0;
-
- if((macroblock_type & MACROBLOCK_MOTION_FORWARD) || (picture_coding_type == P_TYPE))
- {
- if(picture_structure == FRAME_PICTURE)
- {
- if((motion_type == MC_FRAME) || !(macroblock_type & MACROBLOCK_MOTION_FORWARD))
- {
- /* frame-based prediction (broken into top and bottom halves
- for spatial scalability prediction purposes) */
- form_prediction(forward_reference_frame, 0, current_frame, 0, Coded_Picture_Width,
- Coded_Picture_Width << 1, 16, 8, bx, by, PMV[0][0][0], PMV[0][0][1], stw);
-
- form_prediction(forward_reference_frame, 1, current_frame, 1, Coded_Picture_Width,
- Coded_Picture_Width << 1, 16, 8, bx, by, PMV[0][0][0], PMV[0][0][1], stw);
- }
- else if(motion_type == MC_FIELD) /* field-based prediction */
- {
- /* top field prediction */
- form_prediction(forward_reference_frame, motion_vertical_field_select[0][0],
- current_frame, 0, Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8,
- bx, by >> 1, PMV[0][0][0], PMV[0][0][1] >> 1, stw);
-
- /* bottom field prediction */
- form_prediction(forward_reference_frame, motion_vertical_field_select[1][0],
- current_frame, 1, Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8,
- bx, by >> 1, PMV[1][0][0], PMV[1][0][1] >> 1, stw);
- }
- else if(motion_type == MC_DMV) /* dual prime prediction */
- {
- /* calculate derived motion vectors */
- Dual_Prime_Arithmetic(DMV, dmvector, PMV[0][0][0], PMV[0][0][1] >> 1);
-
- /* predict top field from top field */
- form_prediction(forward_reference_frame, 0, current_frame, 0,
- Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8, bx, by>>1,
- PMV[0][0][0], PMV[0][0][1] >> 1, 0);
-
- /* predict and add to top field from bottom field */
- form_prediction(forward_reference_frame, 1, current_frame, 0,
- Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8, bx, by>>1,
- DMV[0][0], DMV[0][1], 1);
-
- /* predict bottom field from bottom field */
- form_prediction(forward_reference_frame, 1, current_frame, 1,
- Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8, bx, by>>1,
- PMV[0][0][0], PMV[0][0][1] >> 1, 0);
-
- /* predict and add to bottom field from top field */
- form_prediction(forward_reference_frame, 0, current_frame, 1,
- Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8, bx, by>>1,
- DMV[1][0], DMV[1][1], 1);
- }
- else
- Fault_Flag = 5;
- }
- else
- {
- /* field picture */
- currentfield = (picture_structure == BOTTOM_FIELD);
-
- /* determine which frame to use for prediction */
- if(picture_coding_type == P_TYPE && Second_Field && currentfield != motion_vertical_field_select[0][0])
- predframe = backward_reference_frame;
- else
- predframe = forward_reference_frame;
-
- if((motion_type == MC_FIELD) || !(macroblock_type & MACROBLOCK_MOTION_FORWARD))
- {
- form_prediction(predframe, motion_vertical_field_select[0][0], current_frame, 0,
- Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 16, bx, by,
- PMV[0][0][0], PMV[0][0][1], stw);
- }
- else if(motion_type == MC_16X8)
- {
- form_prediction(predframe, motion_vertical_field_select[0][0], current_frame, 0,
- Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8, bx, by,
- PMV[0][0][0], PMV[0][0][1], stw);
-
- if(picture_coding_type == P_TYPE && Second_Field && currentfield != motion_vertical_field_select[1][0])
- predframe = backward_reference_frame;
- else
- predframe = forward_reference_frame;
-
- form_prediction(predframe, motion_vertical_field_select[1][0], current_frame,
- 0, Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8, bx, by + 8,
- PMV[1][0][0], PMV[1][0][1], stw);
- }
- else if(motion_type == MC_DMV)
- {
- if(Second_Field)
- predframe = backward_reference_frame;
- else
- predframe = forward_reference_frame;
-
- /* calculate derived motion vectors */
- Dual_Prime_Arithmetic(DMV, dmvector, PMV[0][0][0], PMV[0][0][1]);
-
- /* predict from field of same parity */
- form_prediction(forward_reference_frame, currentfield, current_frame, 0,
- Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 16, bx, by,
- PMV[0][0][0], PMV[0][0][1], 0);
-
- /* predict from field of opposite parity */
- form_prediction(predframe, !currentfield, current_frame, 0,
- Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 16, bx, by,
- DMV[0][0], DMV[0][1], 1);
- }
- else
- Fault_Flag = 5;
- }
-
- stw = 1;
- }
-
- if(macroblock_type & MACROBLOCK_MOTION_BACKWARD)
- {
- if(picture_structure == FRAME_PICTURE)
- {
- if(motion_type == MC_FRAME)
- {
- /* frame-based prediction */
- form_prediction(backward_reference_frame, 0, current_frame, 0,
- Coded_Picture_Width, Coded_Picture_Width << 1, 16, 8, bx, by,
- PMV[0][1][0], PMV[0][1][1], stw);
-
- form_prediction(backward_reference_frame, 1, current_frame, 1,
- Coded_Picture_Width, Coded_Picture_Width << 1, 16, 8, bx, by,
- PMV[0][1][0], PMV[0][1][1], stw);
- }
- else /* field-based prediction */
- {
- /* top field prediction */
- form_prediction(backward_reference_frame, motion_vertical_field_select[0][1],
- current_frame, 0, Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8,
- bx, by >> 1, PMV[0][1][0], PMV[0][1][1] >> 1, stw);
-
- /* bottom field prediction */
- form_prediction(backward_reference_frame, motion_vertical_field_select[1][1],
- current_frame, 1, Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8,
- bx, by >> 1, PMV[1][1][0], PMV[1][1][1] >> 1, stw);
- }
- }
- else
- {
- /* field picture */
- if(motion_type == MC_FIELD)
- {
- /* field-based prediction */
- form_prediction(backward_reference_frame, motion_vertical_field_select[0][1],
- current_frame, 0, Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 16,
- bx, by, PMV[0][1][0], PMV[0][1][1], stw);
- }
- else if(motion_type == MC_16X8)
- {
- form_prediction(backward_reference_frame, motion_vertical_field_select[0][1],
- current_frame, 0, Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8,
- bx, by, PMV[0][1][0], PMV[0][1][1], stw);
-
- form_prediction(backward_reference_frame, motion_vertical_field_select[1][1],
- current_frame, 0, Coded_Picture_Width << 1, Coded_Picture_Width << 1, 16, 8,
- bx, by + 8, PMV[1][1][0], PMV[1][1][1], stw);
- }
- else
- Fault_Flag = 5;
- }
- }
+ int currentfield;
+ unsigned char **predframe;
+ int DMV[2][2];
+ int stw;
+
+ stw = 0;
+
+ if ((macroblock_type & MACROBLOCK_MOTION_FORWARD) || (picture_coding_type==P_TYPE))
+ {
+ if (picture_structure==FRAME_PICTURE)
+ {
+ if ((motion_type==MC_FRAME) || !(macroblock_type & MACROBLOCK_MOTION_FORWARD))
+ {
+ /* frame-based prediction (broken into top and bottom halves
+ for spatial scalability prediction purposes) */
+ form_prediction(forward_reference_frame, 0, current_frame, 0, Coded_Picture_Width,
+ Coded_Picture_Width<<1, 16, 8, bx, by, PMV[0][0][0], PMV[0][0][1], stw);
+
+ form_prediction(forward_reference_frame, 1, current_frame, 1, Coded_Picture_Width,
+ Coded_Picture_Width<<1, 16, 8, bx, by, PMV[0][0][0], PMV[0][0][1], stw);
+ }
+ else if (motion_type==MC_FIELD) /* field-based prediction */
+ {
+ /* top field prediction */
+ form_prediction(forward_reference_frame, motion_vertical_field_select[0][0],
+ current_frame, 0, Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8,
+ bx, by>>1, PMV[0][0][0], PMV[0][0][1]>>1, stw);
+
+ /* bottom field prediction */
+ form_prediction(forward_reference_frame, motion_vertical_field_select[1][0],
+ current_frame, 1, Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8,
+ bx, by>>1, PMV[1][0][0], PMV[1][0][1]>>1, stw);
+ }
+ else if (motion_type==MC_DMV) /* dual prime prediction */
+ {
+ /* calculate derived motion vectors */
+ Dual_Prime_Arithmetic(DMV, dmvector, PMV[0][0][0], PMV[0][0][1]>>1);
+
+ /* predict top field from top field */
+ form_prediction(forward_reference_frame, 0, current_frame, 0,
+ Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8, bx, by>>1,
+ PMV[0][0][0], PMV[0][0][1]>>1, 0);
+
+ /* predict and add to top field from bottom field */
+ form_prediction(forward_reference_frame, 1, current_frame, 0,
+ Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8, bx, by>>1,
+ DMV[0][0], DMV[0][1], 1);
+
+ /* predict bottom field from bottom field */
+ form_prediction(forward_reference_frame, 1, current_frame, 1,
+ Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8, bx, by>>1,
+ PMV[0][0][0], PMV[0][0][1]>>1, 0);
+
+ /* predict and add to bottom field from top field */
+ form_prediction(forward_reference_frame, 0, current_frame, 1,
+ Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8, bx, by>>1,
+ DMV[1][0], DMV[1][1], 1);
+ }
+ else
+ Fault_Flag = 5;
+ }
+ else
+ {
+ /* field picture */
+ currentfield = (picture_structure==BOTTOM_FIELD);
+
+ /* determine which frame to use for prediction */
+ if (picture_coding_type==P_TYPE && Second_Field && currentfield!=motion_vertical_field_select[0][0])
+ predframe = backward_reference_frame;
+ else
+ predframe = forward_reference_frame;
+
+ if ((motion_type==MC_FIELD) || !(macroblock_type & MACROBLOCK_MOTION_FORWARD))
+ {
+ form_prediction(predframe, motion_vertical_field_select[0][0], current_frame, 0,
+ Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 16, bx, by,
+ PMV[0][0][0], PMV[0][0][1], stw);
+ }
+ else if (motion_type==MC_16X8)
+ {
+ form_prediction(predframe, motion_vertical_field_select[0][0], current_frame, 0,
+ Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8, bx, by,
+ PMV[0][0][0], PMV[0][0][1], stw);
+
+ if (picture_coding_type==P_TYPE && Second_Field && currentfield!=motion_vertical_field_select[1][0])
+ predframe = backward_reference_frame;
+ else
+ predframe = forward_reference_frame;
+
+ form_prediction(predframe, motion_vertical_field_select[1][0], current_frame,
+ 0, Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8, bx, by+8,
+ PMV[1][0][0], PMV[1][0][1], stw);
+ }
+ else if (motion_type==MC_DMV)
+ {
+ if (Second_Field)
+ predframe = backward_reference_frame;
+ else
+ predframe = forward_reference_frame;
+
+ /* calculate derived motion vectors */
+ Dual_Prime_Arithmetic(DMV, dmvector, PMV[0][0][0], PMV[0][0][1]);
+
+ /* predict from field of same parity */
+ form_prediction(forward_reference_frame, currentfield, current_frame, 0,
+ Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 16, bx, by,
+ PMV[0][0][0], PMV[0][0][1], 0);
+
+ /* predict from field of opposite parity */
+ form_prediction(predframe, !currentfield, current_frame, 0,
+ Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 16, bx, by,
+ DMV[0][0], DMV[0][1], 1);
+ }
+ else
+ Fault_Flag = 5;
+ }
+
+ stw = 1;
+ }
+
+ if (macroblock_type & MACROBLOCK_MOTION_BACKWARD)
+ {
+ if (picture_structure==FRAME_PICTURE)
+ {
+ if (motion_type==MC_FRAME)
+ {
+ /* frame-based prediction */
+ form_prediction(backward_reference_frame, 0, current_frame, 0,
+ Coded_Picture_Width, Coded_Picture_Width<<1, 16, 8, bx, by,
+ PMV[0][1][0], PMV[0][1][1], stw);
+
+ form_prediction(backward_reference_frame, 1, current_frame, 1,
+ Coded_Picture_Width, Coded_Picture_Width<<1, 16, 8, bx, by,
+ PMV[0][1][0], PMV[0][1][1], stw);
+ }
+ else /* field-based prediction */
+ {
+ /* top field prediction */
+ form_prediction(backward_reference_frame, motion_vertical_field_select[0][1],
+ current_frame, 0, Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8,
+ bx, by>>1, PMV[0][1][0], PMV[0][1][1]>>1, stw);
+
+ /* bottom field prediction */
+ form_prediction(backward_reference_frame, motion_vertical_field_select[1][1],
+ current_frame, 1, Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8,
+ bx, by>>1, PMV[1][1][0], PMV[1][1][1]>>1, stw);
+ }
+ }
+ else
+ {
+ /* field picture */
+ if (motion_type==MC_FIELD)
+ {
+ /* field-based prediction */
+ form_prediction(backward_reference_frame, motion_vertical_field_select[0][1],
+ current_frame, 0, Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 16,
+ bx, by, PMV[0][1][0], PMV[0][1][1], stw);
+ }
+ else if (motion_type==MC_16X8)
+ {
+ form_prediction(backward_reference_frame, motion_vertical_field_select[0][1],
+ current_frame, 0, Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8,
+ bx, by, PMV[0][1][0], PMV[0][1][1], stw);
+
+ form_prediction(backward_reference_frame, motion_vertical_field_select[1][1],
+ current_frame, 0, Coded_Picture_Width<<1, Coded_Picture_Width<<1, 16, 8,
+ bx, by+8, PMV[1][1][0], PMV[1][1][1], stw);
+ }
+ else
+ Fault_Flag = 5;
+ }
+ }
}
void CMPEG2Dec::form_prediction(unsigned char *src[], int sfield, unsigned char *dst[],
- int dfield, int lx, int lx2, int w, int h, int x, int y,
- int dx, int dy, int average_flag)
+ int dfield, int lx, int lx2, int w, int h, int x, int y,
+ int dx, int dy, int average_flag)
{
- form_component_prediction(src[0] + (sfield ? lx2 >> 1 : 0), dst[0] + (dfield ? lx2 >> 1 : 0),
- lx, lx2, w, h, x, y, dx, dy, average_flag);
-
- if(chroma_format != CHROMA444)
- {
- lx >>= 1;
- lx2 >>= 1;
- w >>= 1;
- x >>= 1;
- dx /= 2;
- }
-
- if(chroma_format == CHROMA420)
- {
- h >>= 1;
- y >>= 1;
- dy /= 2;
- }
-
- /* Cb */
- form_component_prediction(src[1] + (sfield ? lx2 >> 1 : 0), dst[1] + (dfield ? lx2 >> 1 : 0),
- lx, lx2, w, h, x, y, dx, dy, average_flag);
-
- /* Cr */
- form_component_prediction(src[2] + (sfield ? lx2 >> 1 : 0), dst[2] + (dfield ? lx2 >> 1 : 0),
- lx, lx2, w, h, x, y, dx, dy, average_flag);
+ form_component_prediction(src[0]+(sfield?lx2>>1:0), dst[0]+(dfield?lx2>>1:0),
+ lx, lx2, w, h, x, y, dx, dy, average_flag);
+
+ if (chroma_format!=CHROMA444)
+ {
+ lx>>=1; lx2>>=1; w>>=1; x>>=1; dx/=2;
+ }
+
+ if (chroma_format==CHROMA420)
+ {
+ h>>=1; y>>=1; dy/=2;
+ }
+
+ /* Cb */
+ form_component_prediction(src[1]+(sfield?lx2>>1:0), dst[1]+(dfield?lx2>>1:0),
+ lx, lx2, w, h, x, y, dx, dy, average_flag);
+
+ /* Cr */
+ form_component_prediction(src[2]+(sfield?lx2>>1:0), dst[2]+(dfield?lx2>>1:0),
+ lx, lx2, w, h, x, y, dx, dy, average_flag);
}
/* ISO/IEC 13818-2 section 7.6.4: Forming predictions */
void CMPEG2Dec::form_component_prediction(unsigned char *src, unsigned char *dst,
- int lx, int lx2, int w, int h, int x, int y,
- int dx, int dy, int average_flag)
+ int lx, int lx2, int w, int h, int x, int y,
+ int dx, int dy, int average_flag)
{
- static const __int64 mmmask_0001 = 0x0001000100010001;
- static const __int64 mmmask_0002 = 0x0002000200020002;
- static const __int64 mmmask_0003 = 0x0003000300030003;
- static const __int64 mmmask_0006 = 0x0006000600060006;
-
- unsigned char *s = src + lx * (y + (dy >> 1)) + x + (dx >> 1);
- unsigned char *d = dst + lx * y + x;
- int flag = (average_flag << 2) + ((dx & 1) << 1) + (dy & 1);
-
- switch(flag)
- {
- case 0:
- // d[i] = s[i];
- __asm
- {
- mov eax, [s]
- mov ebx, [d]
- mov esi, 0x00
- mov edi, [h]
- mc0:
- movq mm1, [eax+esi]
- add esi, 0x08
- cmp esi, [w]
- movq [ebx+esi-8], mm1
- jl mc0
-
- add eax, [lx2]
- add ebx, [lx2]
- dec edi
- mov esi, 0x00
- cmp edi, 0x00
- jg mc0
- }
- break;
-
- case 1:
- // d[i] = (s[i]+s[i+lx]+1)>>1;
- __asm
- {
- pxor mm0, mm0
- movq mm7, [mmmask_0001]
- mov eax, [s]
- mov ebx, [d]
- mov ecx, eax
- add ecx, [lx]
- mov esi, 0x00
- mov edi, [h]
- mc1:
- movq mm1, [eax+esi]
- movq mm2, [ecx+esi]
-
- movq mm3, mm1
- movq mm4, mm2
-
- punpcklbw mm1, mm0
- punpckhbw mm3, mm0
- punpcklbw mm2, mm0
- punpckhbw mm4, mm0
-
- paddsw mm1, mm2
- paddsw mm3, mm4
-
- paddsw mm1, mm7
- paddsw mm3, mm7
-
- psrlw mm1, 1
- psrlw mm3, 1
-
- packuswb mm1, mm0
- packuswb mm3, mm0
-
- psllq mm3, 32
- por mm1, mm3
-
- add esi, 0x08
- cmp esi, [w]
- movq [ebx+esi-8], mm1
- jl mc1
-
- add eax, [lx2]
- add ebx, [lx2]
- add ecx, [lx2]
- dec edi
- mov esi, 0x00
- cmp edi, 0x00
- jg mc1
- }
- break;
-
- case 2:
- // d[i] = (s[i]+s[i+1]+1)>>1;
- __asm
- {
- pxor mm0, mm0
- movq mm7, [mmmask_0001]
- mov eax, [s]
- mov ebx, [d]
- mov esi, 0x00
- mov edi, [h]
- mc2:
- movq mm1, [eax+esi]
- movq mm2, [eax+esi+1]
-
- movq mm3, mm1
- movq mm4, mm2
-
- punpcklbw mm1, mm0
- punpckhbw mm3, mm0
-
- punpcklbw mm2, mm0
- punpckhbw mm4, mm0
-
- paddsw mm1, mm2
- paddsw mm3, mm4
-
- paddsw mm1, mm7
- paddsw mm3, mm7
-
- psrlw mm1, 1
- psrlw mm3, 1
-
- packuswb mm1, mm0
- packuswb mm3, mm0
-
- psllq mm3, 32
- por mm1, mm3
-
- add esi, 0x08
- cmp esi, [w]
- movq [ebx+esi-8], mm1
- jl mc2
-
- add eax, [lx2]
- add ebx, [lx2]
- dec edi
- mov esi, 0x00
- cmp edi, 0x00
- jg mc2
- }
- break;
-
- case 3:
- // d[i] = (s[i]+s[i+1]+s[i+lx]+s[i+lx+1]+2)>>2;
- __asm
- {
- pxor mm0, mm0
- movq mm7, [mmmask_0002]
- mov eax, [s]
- mov ebx, [d]
- mov ecx, eax
- add ecx, [lx]
- mov esi, 0x00
- mov edi, [h]
- mc3:
- movq mm1, [eax+esi]
- movq mm2, [eax+esi+1]
- movq mm3, mm1
- movq mm4, mm2
-
- punpcklbw mm1, mm0
- punpckhbw mm3, mm0
-
- punpcklbw mm2, mm0
- punpckhbw mm4, mm0
-
- paddsw mm1, mm2
- paddsw mm3, mm4
-
- movq mm5, [ecx+esi]
- paddsw mm1, mm7
-
- movq mm6, [ecx+esi+1]
- paddsw mm3, mm7
-
- movq mm2, mm5
- movq mm4, mm6
-
- punpcklbw mm2, mm0
- punpckhbw mm5, mm0
-
- punpcklbw mm4, mm0
- punpckhbw mm6, mm0
-
- paddsw mm2, mm4
- paddsw mm5, mm6
-
- paddsw mm1, mm2
- paddsw mm3, mm5
-
- psrlw mm1, 2
- psrlw mm3, 2
-
- packuswb mm1, mm0
- packuswb mm3, mm0
-
- psllq mm3, 32
- por mm1, mm3
-
- add esi, 0x08
- cmp esi, [w]
- movq [ebx+esi-8], mm1
- jl mc3
-
- add eax, [lx2]
- add ebx, [lx2]
- add ecx, [lx2]
- dec edi
- mov esi, 0x00
- cmp edi, 0x00
- jg mc3
- }
- break;
-
- case 4:
- // d[i] = (s[i]+d[i]+1)>>1;
- __asm
- {
- pxor mm0, mm0
- movq mm7, [mmmask_0001]
- mov eax, [s]
- mov ebx, [d]
- mov esi, 0x00
- mov edi, [h]
- mc4:
- movq mm1, [eax+esi]
- movq mm2, [ebx+esi]
- movq mm3, mm1
- movq mm4, mm2
-
- punpcklbw mm1, mm0
- punpckhbw mm3, mm0
-
- punpcklbw mm2, mm0
- punpckhbw mm4, mm0
-
- paddsw mm1, mm2
- paddsw mm3, mm4
-
- paddsw mm1, mm7
- paddsw mm3, mm7
-
- psrlw mm1, 1
- psrlw mm3, 1
-
- packuswb mm1, mm0
- packuswb mm3, mm0
-
- psllq mm3, 32
- por mm1, mm3
-
- add esi, 0x08
- cmp esi, [w]
- movq [ebx+esi-8], mm1
- jl mc4
-
- add eax, [lx2]
- add ebx, [lx2]
- dec edi
- mov esi, 0x00
- cmp edi, 0x00
- jg mc4
- }
- break;
-
- case 5:
- // d[i] = ((d[i]<<1) + s[i]+s[i+lx] + 3)>>2;
- __asm
- {
- pxor mm0, mm0
- movq mm7, [mmmask_0003]
- mov eax, [s]
- mov ebx, [d]
- mov ecx, eax
- add ecx, [lx]
- mov esi, 0x00
- mov edi, [h]
- mc5:
- movq mm1, [eax+esi]
- movq mm2, [ecx+esi]
- movq mm3, mm1
- movq mm4, mm2
-
- punpcklbw mm1, mm0
- punpckhbw mm3, mm0
-
- punpcklbw mm2, mm0
- punpckhbw mm4, mm0
-
- paddsw mm1, mm2
- paddsw mm3, mm4
-
- movq mm5, [ebx+esi]
-
- paddsw mm1, mm7
- paddsw mm3, mm7
-
- movq mm6, mm5
- punpcklbw mm5, mm0
- punpckhbw mm6, mm0
-
- psllw mm5, 1
- psllw mm6, 1
-
- paddsw mm1, mm5
- paddsw mm3, mm6
-
- psrlw mm1, 2
- psrlw mm3, 2
-
- packuswb mm1, mm0
- packuswb mm3, mm0
-
- psllq mm3, 32
- por mm1, mm3
-
- add esi, 0x08
- cmp esi, [w]
- movq [ebx+esi-8], mm1
- jl mc5
-
- add eax, [lx2]
- add ebx, [lx2]
- add ecx, [lx2]
- dec edi
- mov esi, 0x00
- cmp edi, 0x00
- jg mc5
- }
- break;
-
- case 6:
- // d[i] = ((d[i]<<1) + s[i]+s[i+1] + 3) >> 2;
- __asm
- {
- pxor mm0, mm0
- movq mm7, [mmmask_0003]
- mov eax, [s]
- mov ebx, [d]
- mov esi, 0x00
- mov edi, [h]
- mc6:
- movq mm1, [eax+esi]
- movq mm2, [eax+esi+1]
- movq mm3, mm1
- movq mm4, mm2
-
- punpcklbw mm1, mm0
- punpckhbw mm3, mm0
-
- punpcklbw mm2, mm0
- punpckhbw mm4, mm0
-
- paddsw mm1, mm2
- paddsw mm3, mm4
-
- movq mm5, [ebx+esi]
-
- paddsw mm1, mm7
- paddsw mm3, mm7
-
- movq mm6, mm5
- punpcklbw mm5, mm0
- punpckhbw mm6, mm0
-
- psllw mm5, 1
- psllw mm6, 1
-
- paddsw mm1, mm5
- paddsw mm3, mm6
-
- psrlw mm1, 2
- psrlw mm3, 2
-
- packuswb mm1, mm0
- packuswb mm3, mm0
-
- psllq mm3, 32
- por mm1, mm3
-
- add esi, 0x08
- cmp esi, [w]
- movq [ebx+esi-8], mm1
- jl mc6
-
- add eax, [lx2]
- add ebx, [lx2]
- dec edi
- mov esi, 0x00
- cmp edi, 0x00
- jg mc6
- }
- break;
-
- case 7:
- // d[i] = ((d[i]<<2) + s[i]+s[i+1]+s[i+lx]+s[i+lx+1] + 6)>>3;
- __asm
- {
- pxor mm0, mm0
- movq mm7, [mmmask_0006]
- mov eax, [s]
- mov ebx, [d]
- mov ecx, eax
- add ecx, [lx]
- mov esi, 0x00
- mov edi, [h]
- mc7:
- movq mm1, [eax+esi]
- movq mm2, [eax+esi+1]
- movq mm3, mm1
- movq mm4, mm2
-
- punpcklbw mm1, mm0
- punpckhbw mm3, mm0
-
- punpcklbw mm2, mm0
- punpckhbw mm4, mm0
-
- paddsw mm1, mm2
- paddsw mm3, mm4
-
- movq mm5, [ecx+esi]
- paddsw mm1, mm7
-
- movq mm6, [ecx+esi+1]
- paddsw mm3, mm7
-
- movq mm2, mm5
- movq mm4, mm6
-
- punpcklbw mm2, mm0
- punpckhbw mm5, mm0
-
- punpcklbw mm4, mm0
- punpckhbw mm6, mm0
-
- paddsw mm2, mm4
- paddsw mm5, mm6
-
- paddsw mm1, mm2
- paddsw mm3, mm5
-
- movq mm6, [ebx+esi]
-
- movq mm4, mm6
- punpcklbw mm4, mm0
- punpckhbw mm6, mm0
-
- psllw mm4, 2
- psllw mm6, 2
-
- paddsw mm1, mm4
- paddsw mm3, mm6
-
- psrlw mm1, 3
- psrlw mm3, 3
-
- packuswb mm1, mm0
- packuswb mm3, mm0
-
- psllq mm3, 32
- por mm1, mm3
-
- add esi, 0x08
- cmp esi, [w]
- movq [ebx+esi-8], mm1
- jl mc7
-
- add eax, [lx2]
- add ebx, [lx2]
- add ecx, [lx2]
- dec edi
- mov esi, 0x00
- cmp edi, 0x00
- jg mc7
- }
- break;
- }
+ static const __int64 mmmask_0001 = 0x0001000100010001;
+ static const __int64 mmmask_0002 = 0x0002000200020002;
+ static const __int64 mmmask_0003 = 0x0003000300030003;
+ static const __int64 mmmask_0006 = 0x0006000600060006;
+
+ unsigned char *s = src + lx * (y + (dy>>1)) + x + (dx>>1);
+ unsigned char *d = dst + lx * y + x;
+ int flag = (average_flag<<2) + ((dx & 1)<<1) + (dy & 1);
+
+ switch (flag)
+ {
+ case 0:
+ // d[i] = s[i];
+ __asm
+ {
+ mov eax, [s]
+ mov ebx, [d]
+ mov esi, 0x00
+ mov edi, [h]
+mc0:
+ movq mm1, [eax+esi]
+ add esi, 0x08
+ cmp esi, [w]
+ movq [ebx+esi-8], mm1
+ jl mc0
+
+ add eax, [lx2]
+ add ebx, [lx2]
+ dec edi
+ mov esi, 0x00
+ cmp edi, 0x00
+ jg mc0
+ }
+ break;
+
+ case 1:
+ // d[i] = (s[i]+s[i+lx]+1)>>1;
+ __asm
+ {
+ pxor mm0, mm0
+ movq mm7, [mmmask_0001]
+ mov eax, [s]
+ mov ebx, [d]
+ mov ecx, eax
+ add ecx, [lx]
+ mov esi, 0x00
+ mov edi, [h]
+mc1:
+ movq mm1, [eax+esi]
+ movq mm2, [ecx+esi]
+
+ movq mm3, mm1
+ movq mm4, mm2
+
+ punpcklbw mm1, mm0
+ punpckhbw mm3, mm0
+ punpcklbw mm2, mm0
+ punpckhbw mm4, mm0
+
+ paddsw mm1, mm2
+ paddsw mm3, mm4
+
+ paddsw mm1, mm7
+ paddsw mm3, mm7
+
+ psrlw mm1, 1
+ psrlw mm3, 1
+
+ packuswb mm1, mm0
+ packuswb mm3, mm0
+
+ psllq mm3, 32
+ por mm1, mm3
+
+ add esi, 0x08
+ cmp esi, [w]
+ movq [ebx+esi-8], mm1
+ jl mc1
+
+ add eax, [lx2]
+ add ebx, [lx2]
+ add ecx, [lx2]
+ dec edi
+ mov esi, 0x00
+ cmp edi, 0x00
+ jg mc1
+ }
+ break;
+
+ case 2:
+ // d[i] = (s[i]+s[i+1]+1)>>1;
+ __asm
+ {
+ pxor mm0, mm0
+ movq mm7, [mmmask_0001]
+ mov eax, [s]
+ mov ebx, [d]
+ mov esi, 0x00
+ mov edi, [h]
+mc2:
+ movq mm1, [eax+esi]
+ movq mm2, [eax+esi+1]
+
+ movq mm3, mm1
+ movq mm4, mm2
+
+ punpcklbw mm1, mm0
+ punpckhbw mm3, mm0
+
+ punpcklbw mm2, mm0
+ punpckhbw mm4, mm0
+
+ paddsw mm1, mm2
+ paddsw mm3, mm4
+
+ paddsw mm1, mm7
+ paddsw mm3, mm7
+
+ psrlw mm1, 1
+ psrlw mm3, 1
+
+ packuswb mm1, mm0
+ packuswb mm3, mm0
+
+ psllq mm3, 32
+ por mm1, mm3
+
+ add esi, 0x08
+ cmp esi, [w]
+ movq [ebx+esi-8], mm1
+ jl mc2
+
+ add eax, [lx2]
+ add ebx, [lx2]
+ dec edi
+ mov esi, 0x00
+ cmp edi, 0x00
+ jg mc2
+ }
+ break;
+
+ case 3:
+ // d[i] = (s[i]+s[i+1]+s[i+lx]+s[i+lx+1]+2)>>2;
+ __asm
+ {
+ pxor mm0, mm0
+ movq mm7, [mmmask_0002]
+ mov eax, [s]
+ mov ebx, [d]
+ mov ecx, eax
+ add ecx, [lx]
+ mov esi, 0x00
+ mov edi, [h]
+mc3:
+ movq mm1, [eax+esi]
+ movq mm2, [eax+esi+1]
+ movq mm3, mm1
+ movq mm4, mm2
+
+ punpcklbw mm1, mm0
+ punpckhbw mm3, mm0
+
+ punpcklbw mm2, mm0
+ punpckhbw mm4, mm0
+
+ paddsw mm1, mm2
+ paddsw mm3, mm4
+
+ movq mm5, [ecx+esi]
+ paddsw mm1, mm7
+
+ movq mm6, [ecx+esi+1]
+ paddsw mm3, mm7
+
+ movq mm2, mm5
+ movq mm4, mm6
+
+ punpcklbw mm2, mm0
+ punpckhbw mm5, mm0
+
+ punpcklbw mm4, mm0
+ punpckhbw mm6, mm0
+
+ paddsw mm2, mm4
+ paddsw mm5, mm6
+
+ paddsw mm1, mm2
+ paddsw mm3, mm5
+
+ psrlw mm1, 2
+ psrlw mm3, 2
+
+ packuswb mm1, mm0
+ packuswb mm3, mm0
+
+ psllq mm3, 32
+ por mm1, mm3
+
+ add esi, 0x08
+ cmp esi, [w]
+ movq [ebx+esi-8], mm1
+ jl mc3
+
+ add eax, [lx2]
+ add ebx, [lx2]
+ add ecx, [lx2]
+ dec edi
+ mov esi, 0x00
+ cmp edi, 0x00
+ jg mc3
+ }
+ break;
+
+ case 4:
+ // d[i] = (s[i]+d[i]+1)>>1;
+ __asm
+ {
+ pxor mm0, mm0
+ movq mm7, [mmmask_0001]
+ mov eax, [s]
+ mov ebx, [d]
+ mov esi, 0x00
+ mov edi, [h]
+mc4:
+ movq mm1, [eax+esi]
+ movq mm2, [ebx+esi]
+ movq mm3, mm1
+ movq mm4, mm2
+
+ punpcklbw mm1, mm0
+ punpckhbw mm3, mm0
+
+ punpcklbw mm2, mm0
+ punpckhbw mm4, mm0
+
+ paddsw mm1, mm2
+ paddsw mm3, mm4
+
+ paddsw mm1, mm7
+ paddsw mm3, mm7
+
+ psrlw mm1, 1
+ psrlw mm3, 1
+
+ packuswb mm1, mm0
+ packuswb mm3, mm0
+
+ psllq mm3, 32
+ por mm1, mm3
+
+ add esi, 0x08
+ cmp esi, [w]
+ movq [ebx+esi-8], mm1
+ jl mc4
+
+ add eax, [lx2]
+ add ebx, [lx2]
+ dec edi
+ mov esi, 0x00
+ cmp edi, 0x00
+ jg mc4
+ }
+ break;
+
+ case 5:
+ // d[i] = ((d[i]<<1) + s[i]+s[i+lx] + 3)>>2;
+ __asm
+ {
+ pxor mm0, mm0
+ movq mm7, [mmmask_0003]
+ mov eax, [s]
+ mov ebx, [d]
+ mov ecx, eax
+ add ecx, [lx]
+ mov esi, 0x00
+ mov edi, [h]
+mc5:
+ movq mm1, [eax+esi]
+ movq mm2, [ecx+esi]
+ movq mm3, mm1
+ movq mm4, mm2
+
+ punpcklbw mm1, mm0
+ punpckhbw mm3, mm0
+
+ punpcklbw mm2, mm0
+ punpckhbw mm4, mm0
+
+ paddsw mm1, mm2
+ paddsw mm3, mm4
+
+ movq mm5, [ebx+esi]
+
+ paddsw mm1, mm7
+ paddsw mm3, mm7
+
+ movq mm6, mm5
+ punpcklbw mm5, mm0
+ punpckhbw mm6, mm0
+
+ psllw mm5, 1
+ psllw mm6, 1
+
+ paddsw mm1, mm5
+ paddsw mm3, mm6
+
+ psrlw mm1, 2
+ psrlw mm3, 2
+
+ packuswb mm1, mm0
+ packuswb mm3, mm0
+
+ psllq mm3, 32
+ por mm1, mm3
+
+ add esi, 0x08
+ cmp esi, [w]
+ movq [ebx+esi-8], mm1
+ jl mc5
+
+ add eax, [lx2]
+ add ebx, [lx2]
+ add ecx, [lx2]
+ dec edi
+ mov esi, 0x00
+ cmp edi, 0x00
+ jg mc5
+ }
+ break;
+
+ case 6:
+ // d[i] = ((d[i]<<1) + s[i]+s[i+1] + 3) >> 2;
+ __asm
+ {
+ pxor mm0, mm0
+ movq mm7, [mmmask_0003]
+ mov eax, [s]
+ mov ebx, [d]
+ mov esi, 0x00
+ mov edi, [h]
+mc6:
+ movq mm1, [eax+esi]
+ movq mm2, [eax+esi+1]
+ movq mm3, mm1
+ movq mm4, mm2
+
+ punpcklbw mm1, mm0
+ punpckhbw mm3, mm0
+
+ punpcklbw mm2, mm0
+ punpckhbw mm4, mm0
+
+ paddsw mm1, mm2
+ paddsw mm3, mm4
+
+ movq mm5, [ebx+esi]
+
+ paddsw mm1, mm7
+ paddsw mm3, mm7
+
+ movq mm6, mm5
+ punpcklbw mm5, mm0
+ punpckhbw mm6, mm0
+
+ psllw mm5, 1
+ psllw mm6, 1
+
+ paddsw mm1, mm5
+ paddsw mm3, mm6
+
+ psrlw mm1, 2
+ psrlw mm3, 2
+
+ packuswb mm1, mm0
+ packuswb mm3, mm0
+
+ psllq mm3, 32
+ por mm1, mm3
+
+ add esi, 0x08
+ cmp esi, [w]
+ movq [ebx+esi-8], mm1
+ jl mc6
+
+ add eax, [lx2]
+ add ebx, [lx2]
+ dec edi
+ mov esi, 0x00
+ cmp edi, 0x00
+ jg mc6
+ }
+ break;
+
+ case 7:
+ // d[i] = ((d[i]<<2) + s[i]+s[i+1]+s[i+lx]+s[i+lx+1] + 6)>>3;
+ __asm
+ {
+ pxor mm0, mm0
+ movq mm7, [mmmask_0006]
+ mov eax, [s]
+ mov ebx, [d]
+ mov ecx, eax
+ add ecx, [lx]
+ mov esi, 0x00
+ mov edi, [h]
+mc7:
+ movq mm1, [eax+esi]
+ movq mm2, [eax+esi+1]
+ movq mm3, mm1
+ movq mm4, mm2
+
+ punpcklbw mm1, mm0
+ punpckhbw mm3, mm0
+
+ punpcklbw mm2, mm0
+ punpckhbw mm4, mm0
+
+ paddsw mm1, mm2
+ paddsw mm3, mm4
+
+ movq mm5, [ecx+esi]
+ paddsw mm1, mm7
+
+ movq mm6, [ecx+esi+1]
+ paddsw mm3, mm7
+
+ movq mm2, mm5
+ movq mm4, mm6
+
+ punpcklbw mm2, mm0
+ punpckhbw mm5, mm0
+
+ punpcklbw mm4, mm0
+ punpckhbw mm6, mm0
+
+ paddsw mm2, mm4
+ paddsw mm5, mm6
+
+ paddsw mm1, mm2
+ paddsw mm3, mm5
+
+ movq mm6, [ebx+esi]
+
+ movq mm4, mm6
+ punpcklbw mm4, mm0
+ punpckhbw mm6, mm0
+
+ psllw mm4, 2
+ psllw mm6, 2
+
+ paddsw mm1, mm4
+ paddsw mm3, mm6
+
+ psrlw mm1, 3
+ psrlw mm3, 3
+
+ packuswb mm1, mm0
+ packuswb mm3, mm0
+
+ psllq mm3, 32
+ por mm1, mm3
+
+ add esi, 0x08
+ cmp esi, [w]
+ movq [ebx+esi-8], mm1
+ jl mc7
+
+ add eax, [lx2]
+ add ebx, [lx2]
+ add ecx, [lx2]
+ dec edi
+ mov esi, 0x00
+ cmp edi, 0x00
+ jg mc7
+ }
+ break;
+ }
}
//
@@ -2851,175 +2839,175 @@ void CMPEG2Dec::form_component_prediction(unsigned char *src, unsigned char *dst
//
/* ISO/IEC 13818-2 sections 6.2.5.2, 6.3.17.2, and 7.6.3: Motion vectors */
-void CMPEG2Dec::motion_vectors(int PMV[2][2][2], int dmvector[2],
- int motion_vertical_field_select[2][2], int s,
- int motion_vector_count, int mv_format, int h_r_size,
- int v_r_size, int dmv, int mvscale)
+void CMPEG2Dec::motion_vectors(int PMV[2][2][2],int dmvector[2],
+ int motion_vertical_field_select[2][2], int s,
+ int motion_vector_count, int mv_format, int h_r_size,
+ int v_r_size, int dmv, int mvscale)
{
- if(motion_vector_count == 1)
- {
- if(mv_format == MV_FIELD && !dmv)
- motion_vertical_field_select[1][s] =
- motion_vertical_field_select[0][s] = Get_Bits(1);
-
- motion_vector(PMV[0][s], dmvector, h_r_size, v_r_size, dmv, mvscale, 0);
-
- /* update other motion vector predictors */
- PMV[1][s][0] = PMV[0][s][0];
- PMV[1][s][1] = PMV[0][s][1];
- }
- else
- {
- motion_vertical_field_select[0][s] = Get_Bits(1);
- motion_vector(PMV[0][s], dmvector, h_r_size, v_r_size, dmv, mvscale, 0);
- motion_vertical_field_select[1][s] = Get_Bits(1);
- motion_vector(PMV[1][s], dmvector, h_r_size, v_r_size, dmv, mvscale, 0);
- }
+ if (motion_vector_count==1)
+ {
+ if (mv_format==MV_FIELD && !dmv)
+ motion_vertical_field_select[1][s] =
+ motion_vertical_field_select[0][s] = Get_Bits(1);
+
+ motion_vector(PMV[0][s],dmvector,h_r_size,v_r_size,dmv,mvscale,0);
+
+ /* update other motion vector predictors */
+ PMV[1][s][0] = PMV[0][s][0];
+ PMV[1][s][1] = PMV[0][s][1];
+ }
+ else
+ {
+ motion_vertical_field_select[0][s] = Get_Bits(1);
+ motion_vector(PMV[0][s],dmvector,h_r_size,v_r_size,dmv,mvscale,0);
+ motion_vertical_field_select[1][s] = Get_Bits(1);
+ motion_vector(PMV[1][s],dmvector,h_r_size,v_r_size,dmv,mvscale,0);
+ }
}
/* ISO/IEC 13818-2 section 7.6.3.6: Dual prime additional arithmetic */
-void CMPEG2Dec::Dual_Prime_Arithmetic(int DMV[][2], int *dmvector, int mvx, int mvy)
+void CMPEG2Dec::Dual_Prime_Arithmetic(int DMV[][2],int *dmvector, int mvx,int mvy)
{
- if(picture_structure == FRAME_PICTURE)
- {
- if(top_field_first)
- {
- /* vector for prediction of top field from bottom field */
- DMV[0][0] = ((mvx + (mvx > 0)) >> 1) + dmvector[0];
- DMV[0][1] = ((mvy + (mvy > 0)) >> 1) + dmvector[1] - 1;
-
- /* vector for prediction of bottom field from top field */
- DMV[1][0] = ((3 * mvx + (mvx > 0)) >> 1) + dmvector[0];
- DMV[1][1] = ((3 * mvy + (mvy > 0)) >> 1) + dmvector[1] + 1;
- }
- else
- {
- /* vector for prediction of top field from bottom field */
- DMV[0][0] = ((3 * mvx + (mvx > 0)) >> 1) + dmvector[0];
- DMV[0][1] = ((3 * mvy + (mvy > 0)) >> 1) + dmvector[1] - 1;
-
- /* vector for prediction of bottom field from top field */
- DMV[1][0] = ((mvx + (mvx > 0)) >> 1) + dmvector[0];
- DMV[1][1] = ((mvy + (mvy > 0)) >> 1) + dmvector[1] + 1;
- }
- }
- else
- {
- /* vector for prediction from field of opposite 'parity' */
- DMV[0][0] = ((mvx + (mvx > 0)) >> 1) + dmvector[0];
- DMV[0][1] = ((mvy + (mvy > 0)) >> 1) + dmvector[1];
-
- /* correct for vertical field shift */
- if(picture_structure == TOP_FIELD)
- DMV[0][1]--;
- else
- DMV[0][1]++;
- }
+ if (picture_structure==FRAME_PICTURE)
+ {
+ if (top_field_first)
+ {
+ /* vector for prediction of top field from bottom field */
+ DMV[0][0] = ((mvx +(mvx>0))>>1) + dmvector[0];
+ DMV[0][1] = ((mvy +(mvy>0))>>1) + dmvector[1] - 1;
+
+ /* vector for prediction of bottom field from top field */
+ DMV[1][0] = ((3*mvx+(mvx>0))>>1) + dmvector[0];
+ DMV[1][1] = ((3*mvy+(mvy>0))>>1) + dmvector[1] + 1;
+ }
+ else
+ {
+ /* vector for prediction of top field from bottom field */
+ DMV[0][0] = ((3*mvx+(mvx>0))>>1) + dmvector[0];
+ DMV[0][1] = ((3*mvy+(mvy>0))>>1) + dmvector[1] - 1;
+
+ /* vector for prediction of bottom field from top field */
+ DMV[1][0] = ((mvx +(mvx>0))>>1) + dmvector[0];
+ DMV[1][1] = ((mvy +(mvy>0))>>1) + dmvector[1] + 1;
+ }
+ }
+ else
+ {
+ /* vector for prediction from field of opposite 'parity' */
+ DMV[0][0] = ((mvx+(mvx>0))>>1) + dmvector[0];
+ DMV[0][1] = ((mvy+(mvy>0))>>1) + dmvector[1];
+
+ /* correct for vertical field shift */
+ if (picture_structure==TOP_FIELD)
+ DMV[0][1]--;
+ else
+ DMV[0][1]++;
+ }
}
/* get and decode motion vector and differential motion vector for one prediction */
void CMPEG2Dec::motion_vector(int *PMV, int *dmvector, int h_r_size, int v_r_size,
- int dmv, int mvscale, int full_pel_vector)
+ int dmv, int mvscale, int full_pel_vector)
{
- int motion_code, motion_residual;
+ int motion_code, motion_residual;
- /* horizontal component */
- /* ISO/IEC 13818-2 Table B-10 */
- motion_code = Get_motion_code();
+ /* horizontal component */
+ /* ISO/IEC 13818-2 Table B-10 */
+ motion_code = Get_motion_code();
- motion_residual = (h_r_size != 0 && motion_code != 0) ? Get_Bits(h_r_size) : 0;
+ motion_residual = (h_r_size!=0 && motion_code!=0) ? Get_Bits(h_r_size) : 0;
- decode_motion_vector(&PMV[0], h_r_size, motion_code, motion_residual, full_pel_vector);
+ decode_motion_vector(&PMV[0],h_r_size,motion_code,motion_residual,full_pel_vector);
- if(dmv)
- dmvector[0] = Get_dmvector();
+ if (dmv)
+ dmvector[0] = Get_dmvector();
- /* vertical component */
- motion_code = Get_motion_code();
- motion_residual = (v_r_size != 0 && motion_code != 0) ? Get_Bits(v_r_size) : 0;
+ /* vertical component */
+ motion_code = Get_motion_code();
+ motion_residual = (v_r_size!=0 && motion_code!=0) ? Get_Bits(v_r_size) : 0;
- if(mvscale)
- PMV[1] >>= 1; /* DIV 2 */
+ if (mvscale)
+ PMV[1] >>= 1; /* DIV 2 */
- decode_motion_vector(&PMV[1], v_r_size, motion_code, motion_residual, full_pel_vector);
+ decode_motion_vector(&PMV[1],v_r_size,motion_code,motion_residual,full_pel_vector);
- if(mvscale)
- PMV[1] <<= 1;
+ if (mvscale)
+ PMV[1] <<= 1;
- if(dmv)
- dmvector[1] = Get_dmvector();
+ if (dmv)
+ dmvector[1] = Get_dmvector();
}
/* calculate motion vector component */
/* ISO/IEC 13818-2 section 7.6.3.1: Decoding the motion vectors */
-/* Note: the arithmetic here is more elegant than that which is shown
+/* Note: the arithmetic here is more elegant than that which is shown
in 7.6.3.1. The end results (PMV[][][]) should, however, be the same. */
void CMPEG2Dec::decode_motion_vector(int *pred, int r_size, int motion_code,
- int motion_residual, int full_pel_vector)
+ int motion_residual, int full_pel_vector)
{
- int lim, vec;
-
- lim = 16 << r_size;
- vec = full_pel_vector ? (*pred >> 1) : (*pred);
-
- if(motion_code > 0)
- {
- vec += ((motion_code - 1) << r_size) + motion_residual + 1;
- if(vec >= lim)
- vec -= lim + lim;
- }
- else if(motion_code < 0)
- {
- vec -= ((-motion_code - 1) << r_size) + motion_residual + 1;
- if(vec < -lim)
- vec += lim + lim;
- }
-
- *pred = full_pel_vector ? (vec << 1) : vec;
+ int lim, vec;
+
+ lim = 16<<r_size;
+ vec = full_pel_vector ? (*pred >> 1) : (*pred);
+
+ if (motion_code>0)
+ {
+ vec+= ((motion_code-1)<<r_size) + motion_residual + 1;
+ if (vec>=lim)
+ vec-= lim + lim;
+ }
+ else if (motion_code<0)
+ {
+ vec-= ((-motion_code-1)<<r_size) + motion_residual + 1;
+ if (vec<-lim)
+ vec+= lim + lim;
+ }
+
+ *pred = full_pel_vector ? (vec<<1) : vec;
}
int CMPEG2Dec::Get_motion_code()
{
- int code;
+ int code;
- if(Get_Bits(1))
- return 0;
+ if (Get_Bits(1))
+ return 0;
- if((code = Show_Bits(9)) >= 64)
- {
- code >>= 6;
- Flush_Buffer(MVtab0[code].len);
+ if ((code = Show_Bits(9))>=64)
+ {
+ code >>= 6;
+ Flush_Buffer(MVtab0[code].len);
- return Get_Bits(1) ? -MVtab0[code].val : MVtab0[code].val;
- }
+ return Get_Bits(1)?-MVtab0[code].val:MVtab0[code].val;
+ }
- if(code >= 24)
- {
- code >>= 3;
- Flush_Buffer(MVtab1[code].len);
+ if (code>=24)
+ {
+ code >>= 3;
+ Flush_Buffer(MVtab1[code].len);
- return Get_Bits(1) ? -MVtab1[code].val : MVtab1[code].val;
- }
+ return Get_Bits(1)?-MVtab1[code].val:MVtab1[code].val;
+ }
- if((code -= 12) < 0)
- {
- Fault_Flag = 10;
- return 0;
- }
+ if ((code-=12)<0)
+ {
+ Fault_Flag = 10;
+ return 0;
+ }
- Flush_Buffer(MVtab2[code].len);
+ Flush_Buffer(MVtab2[code].len);
- return Get_Bits(1) ? -MVtab2[code].val : MVtab2[code].val;
+ return Get_Bits(1) ? -MVtab2[code].val : MVtab2[code].val;
}
/* get differential motion vector (for dual prime prediction) */
int CMPEG2Dec::Get_dmvector()
{
- if(Get_Bits(1))
- return Get_Bits(1) ? -1 : 1;
- else
- return 0;
+ if (Get_Bits(1))
+ return Get_Bits(1) ? -1 : 1;
+ else
+ return 0;
}
//
@@ -3038,1478 +3026,1465 @@ static const __int64 mmmask_0128 = 0x0080008000800080;
void CMPEG2Dec::assembleFrame(unsigned char *src[], int pf, unsigned char *dst, int pitch)
{
- unsigned char *y444;
-
- if(Fault_Flag)
- Fault_Flag = 0;
-
- if(Luminance_Flag)
- {
- Luminance_Filter(src[0], lum);
- y444 = lum;
- }
- else
- y444 = src[0];
-
- if(chroma_format == CHROMA420)
- {
- conv420to422(src[1], u422, pf);
- conv420to422(src[2], v422, pf);
-
- if(!dstYUY2())
- {
- conv422to444(u422, u444);
- conv422to444(v422, v444);
- }
- }
- else if(!dstYUY2())
- {
- conv422to444(src[1], u444);
- conv422to444(src[2], v444);
- }
-
- if(dstYUY2())
- conv422toYUY2(y444, u422, v422, dst, pitch);
- else
- conv444toRGB24(y444, u444, v444, dst, pitch);
+ unsigned char *y444;
+
+ if (Fault_Flag)
+ Fault_Flag = 0;
+
+ if (Luminance_Flag)
+ {
+ Luminance_Filter(src[0], lum);
+ y444 = lum;
+ }
+ else
+ y444 = src[0];
+
+ if (chroma_format==CHROMA420)
+ {
+ conv420to422(src[1], u422, pf);
+ conv420to422(src[2], v422, pf);
+
+ if (!dstYUY2())
+ {
+ conv422to444(u422, u444);
+ conv422to444(v422, v444);
+ }
+ }
+ else if (!dstYUY2())
+ {
+ conv422to444(src[1], u444);
+ conv422to444(src[2], v444);
+ }
+
+ if (dstYUY2())
+ conv422toYUY2(y444, u422, v422, dst, pitch);
+ else
+ conv444toRGB24(y444, u444, v444, dst, pitch);
}
void CMPEG2Dec::Luminance_Filter(unsigned char *src, unsigned char *dst)
{
- src += CLIP_AREA;
- dst += CLIP_AREA;
-
- __asm
- {
- mov edx, this
- mov eax, [src]
- mov ebx, [dst]
- mov esi, 0x00
- mov edi, [edx].LUM_AREA
- pxor mm0, mm0
- movq mm5, [edx].LumOffsetMask
- movq mm6, [edx].LumGainMask
- movq mm7, mmmask_0040
-
- lumconv:
- movq mm1, [eax+esi]
- movq mm2, mm1
-
- punpcklbw mm1, mm0
- punpckhbw mm2, mm0
-
- pmullw mm1, mm6
- pmullw mm2, mm6
-
- paddw mm1, mm7
- paddw mm2, mm7
-
- psrlw mm1, 7
- psrlw mm2, 7
-
- paddw mm1, mm5
- paddw mm2, mm5
-
- packuswb mm1, mm0
- packuswb mm2, mm0
-
- add esi, 0x08
- cmp esi, edi
- movq [ebx+esi-8], mm1
- movq [ebx+esi-4], mm2
- jl lumconv
- }
+ src += CLIP_AREA;
+ dst += CLIP_AREA;
+
+ __asm
+ {
+ mov edx, this
+ mov eax, [src]
+ mov ebx, [dst]
+ mov esi, 0x00
+ mov edi, [edx].LUM_AREA
+ pxor mm0, mm0
+ movq mm5, [edx].LumOffsetMask
+ movq mm6, [edx].LumGainMask
+ movq mm7, mmmask_0040
+
+lumconv:
+ movq mm1, [eax+esi]
+ movq mm2, mm1
+
+ punpcklbw mm1, mm0
+ punpckhbw mm2, mm0
+
+ pmullw mm1, mm6
+ pmullw mm2, mm6
+
+ paddw mm1, mm7
+ paddw mm2, mm7
+
+ psrlw mm1, 7
+ psrlw mm2, 7
+
+ paddw mm1, mm5
+ paddw mm2, mm5
+
+ packuswb mm1, mm0
+ packuswb mm2, mm0
+
+ add esi, 0x08
+ cmp esi, edi
+ movq [ebx+esi-8], mm1
+ movq [ebx+esi-4], mm2
+ jl lumconv
+ }
}
void CMPEG2Dec::conv422to444(unsigned char *src, unsigned char *dst)
{
- src += HALF_CLIP_AREA;
- dst += CLIP_AREA;
+ src += HALF_CLIP_AREA;
+ dst += CLIP_AREA;
- __asm
- {
- mov edx, this
- mov eax, [src]
- mov ebx, [dst]
- mov edi, [edx].Clip_Height
+ __asm
+ {
+ mov edx, this
+ mov eax, [src]
+ mov ebx, [dst]
+ mov edi, [edx].Clip_Height
- movq mm1, [mmmask_0001]
- pxor mm0, mm0
+ movq mm1, [mmmask_0001]
+ pxor mm0, mm0
- convyuv444init:
- movq mm7, [eax]
- mov esi, 0x00
+convyuv444init:
+ movq mm7, [eax]
+ mov esi, 0x00
- convyuv444:
- movq mm2, mm7
- movq mm7, [eax+esi+8]
- movq mm3, mm2
- movq mm4, mm7
+convyuv444:
+ movq mm2, mm7
+ movq mm7, [eax+esi+8]
+ movq mm3, mm2
+ movq mm4, mm7
- psrlq mm3, 8
- psllq mm4, 56
- por mm3, mm4
+ psrlq mm3, 8
+ psllq mm4, 56
+ por mm3, mm4
- movq mm4, mm2
- movq mm5, mm3
+ movq mm4, mm2
+ movq mm5, mm3
- punpcklbw mm4, mm0
- punpcklbw mm5, mm0
+ punpcklbw mm4, mm0
+ punpcklbw mm5, mm0
- movq mm6, mm4
- paddusw mm4, mm1
- paddusw mm4, mm5
- psrlw mm4, 1
- psllq mm4, 8
- por mm4, mm6
+ movq mm6, mm4
+ paddusw mm4, mm1
+ paddusw mm4, mm5
+ psrlw mm4, 1
+ psllq mm4, 8
+ por mm4, mm6
- punpckhbw mm2, mm0
- punpckhbw mm3, mm0
+ punpckhbw mm2, mm0
+ punpckhbw mm3, mm0
- movq mm6, mm2
- paddusw mm2, mm1
- paddusw mm2, mm3
+ movq mm6, mm2
+ paddusw mm2, mm1
+ paddusw mm2, mm3
- movq [ebx+esi*2], mm4
+ movq [ebx+esi*2], mm4
- psrlw mm2, 1
- psllq mm2, 8
- por mm2, mm6
+ psrlw mm2, 1
+ psllq mm2, 8
+ por mm2, mm6
- add esi, 0x08
- cmp esi, [edx].HALF_WIDTH_D8
- movq [ebx+esi*2-8], mm2
- jl convyuv444
+ add esi, 0x08
+ cmp esi, [edx].HALF_WIDTH_D8
+ movq [ebx+esi*2-8], mm2
+ jl convyuv444
- movq mm2, mm7
- punpcklbw mm2, mm0
- movq mm3, mm2
+ movq mm2, mm7
+ punpcklbw mm2, mm0
+ movq mm3, mm2
- psllq mm2, 8
- por mm2, mm3
+ psllq mm2, 8
+ por mm2, mm3
- movq [ebx+esi*2], mm2
+ movq [ebx+esi*2], mm2
- punpckhbw mm7, mm0
- movq mm6, mm7
+ punpckhbw mm7, mm0
+ movq mm6, mm7
- psllq mm6, 8
- por mm6, mm7
+ psllq mm6, 8
+ por mm6, mm7
- movq [ebx+esi*2+8], mm6
+ movq [ebx+esi*2+8], mm6
- add eax, [edx].HALF_WIDTH
- add ebx, [edx].Coded_Picture_Width
- dec edi
- cmp edi, 0x00
- jg convyuv444init
- }
+ add eax, [edx].HALF_WIDTH
+ add ebx, [edx].Coded_Picture_Width
+ dec edi
+ cmp edi, 0x00
+ jg convyuv444init
+ }
}
void CMPEG2Dec::conv420to422(unsigned char *src, unsigned char *dst, int frame_type)
{
- if(frame_type)
- {
- __asm
- {
- push ebp
- mov eax, [src]
- mov ebx, [dst]
- mov ebp, this
- mov ecx, ebx
- add ecx, ds:[ebp].HALF_WIDTH
- mov esi, 0x00
- movq mm3, [mmmask_0003]
- pxor mm0, mm0
- movq mm4, [mmmask_0002]
-
- mov edx, eax
- add edx, ds:[ebp].HALF_WIDTH
- convyuv422topp:
- movd mm1, [eax+esi]
- movd mm2, [edx+esi]
- movd [ebx+esi], mm1
- punpcklbw mm1, mm0
- pmullw mm1, mm3
- paddusw mm1, mm4
- punpcklbw mm2, mm0
- paddusw mm2, mm1
- psrlw mm2, 0x02
- packuswb mm2, mm0
-
- add esi, 0x04
- cmp esi, ds:[ebp].HALF_WIDTH
- movd [ecx+esi-4], mm2
- jl convyuv422topp
-
- add eax, ds:[ebp].HALF_WIDTH
- add ebx, ds:[ebp].Coded_Picture_Width
- add ecx, ds:[ebp].Coded_Picture_Width
- mov esi, 0x00
-
- mov edi, ds:[ebp].PROGRESSIVE_HEIGHT
- convyuv422p:
- movd mm1, [eax+esi]
-
- punpcklbw mm1, mm0
- mov edx, eax
-
- pmullw mm1, mm3
- sub edx, ds:[ebp].HALF_WIDTH
-
- movd mm5, [edx+esi]
- movd mm2, [edx+esi]
-
- punpcklbw mm5, mm0
- punpcklbw mm2, mm0
- paddusw mm5, mm1
- paddusw mm2, mm1
- paddusw mm5, mm4
- paddusw mm2, mm4
- psrlw mm5, 0x02
- psrlw mm2, 0x02
- packuswb mm5, mm0
- packuswb mm2, mm0
-
- mov edx, eax
- add edx, ds:[ebp].HALF_WIDTH
- add esi, 0x04
- cmp esi, ds:[ebp].HALF_WIDTH
- movd [ebx+esi-4], mm5
- movd [ecx+esi-4], mm2
-
- jl convyuv422p
-
- add eax, ds:[ebp].HALF_WIDTH
- add ebx, ds:[ebp].Coded_Picture_Width
- add ecx, ds:[ebp].Coded_Picture_Width
- mov esi, 0x00
- dec edi
- cmp edi, 0x00
- jg convyuv422p
-
- mov edx, eax
- sub edx, ds:[ebp].HALF_WIDTH
- convyuv422bottomp:
- movd mm1, [eax+esi]
- movd mm5, [edx+esi]
- punpcklbw mm5, mm0
- movd [ecx+esi], mm1
-
- punpcklbw mm1, mm0
- pmullw mm1, mm3
- paddusw mm5, mm1
- paddusw mm5, mm4
- psrlw mm5, 0x02
- packuswb mm5, mm0
-
- add esi, 0x04
- cmp esi, ds:[ebp].HALF_WIDTH
- movd [ebx+esi-4], mm5
- jl convyuv422bottomp
- pop ebp
- }
- }
- else
- {
- __asm
- {
- push ebp
- mov eax, [src]
- mov ecx, [dst]
- mov ebp, this
- mov esi, 0x00
- pxor mm0, mm0
- movq mm3, [mmmask_0003]
- movq mm4, [mmmask_0004]
- movq mm5, [mmmask_0005]
-
- convyuv422topi:
- movd mm1, [eax+esi]
- mov ebx, eax
- add ebx, ds:[ebp].HALF_WIDTH
- movd mm2, [ebx+esi]
- movd [ecx+esi], mm1
- punpcklbw mm1, mm0
- movq mm6, mm1
- pmullw mm1, mm3
-
- punpcklbw mm2, mm0
- movq mm7, mm2
- pmullw mm2, mm5
- paddusw mm2, mm1
- paddusw mm2, mm4
- psrlw mm2, 0x03
- packuswb mm2, mm0
-
- mov edx, ecx
- add edx, ds:[ebp].HALF_WIDTH
- pmullw mm6, mm5
- movd [edx+esi], mm2
-
- add ebx, ds:[ebp].HALF_WIDTH
- movd mm2, [ebx+esi]
- punpcklbw mm2, mm0
- pmullw mm2, mm3
- paddusw mm2, mm6
- paddusw mm2, mm4
- psrlw mm2, 0x03
- packuswb mm2, mm0
-
- add edx, ds:[ebp].HALF_WIDTH
- add ebx, ds:[ebp].HALF_WIDTH
- pmullw mm7, [mmmask_0007]
- movd [edx+esi], mm2
-
- movd mm2, [ebx+esi]
- punpcklbw mm2, mm0
- paddusw mm2, mm7
- paddusw mm2, mm4
- psrlw mm2, 0x03
- packuswb mm2, mm0
-
- add edx, ds:[ebp].HALF_WIDTH
- add esi, 0x04
- cmp esi, ds:[ebp].HALF_WIDTH
- movd [edx+esi-4], mm2
-
- jl convyuv422topi
-
- add eax, ds:[ebp].Coded_Picture_Width
- add ecx, ds:[ebp].DOUBLE_WIDTH
- mov esi, 0x00
-
- mov edi, ds:[ebp].INTERLACED_HEIGHT
- convyuv422i:
- movd mm1, [eax+esi]
- punpcklbw mm1, mm0
- movq mm6, mm1
- mov ebx, eax
- sub ebx, ds:[ebp].Coded_Picture_Width
- movd mm3, [ebx+esi]
- pmullw mm1, [mmmask_0007]
- punpcklbw mm3, mm0
- paddusw mm3, mm1
- paddusw mm3, mm4
- psrlw mm3, 0x03
- packuswb mm3, mm0
-
- add ebx, ds:[ebp].HALF_WIDTH
- movq mm1, [ebx+esi]
- add ebx, ds:[ebp].Coded_Picture_Width
- movd [ecx+esi], mm3
-
- movq mm3, [mmmask_0003]
- movd mm2, [ebx+esi]
-
- punpcklbw mm1, mm0
- pmullw mm1, mm3
- punpcklbw mm2, mm0
- movq mm7, mm2
- pmullw mm2, mm5
- paddusw mm2, mm1
- paddusw mm2, mm4
- psrlw mm2, 0x03
- packuswb mm2, mm0
-
- pmullw mm6, mm5
- mov edx, ecx
- add edx, ds:[ebp].HALF_WIDTH
- movd [edx+esi], mm2
-
- add ebx, ds:[ebp].HALF_WIDTH
- movd mm2, [ebx+esi]
- punpcklbw mm2, mm0
- pmullw mm2, mm3
- paddusw mm2, mm6
- paddusw mm2, mm4
- psrlw mm2, 0x03
- packuswb mm2, mm0
-
- pmullw mm7, [mmmask_0007]
- add edx, ds:[ebp].HALF_WIDTH
- add ebx, ds:[ebp].HALF_WIDTH
- movd [edx+esi], mm2
-
- movd mm2, [ebx+esi]
- punpcklbw mm2, mm0
- paddusw mm2, mm7
- paddusw mm2, mm4
- psrlw mm2, 0x03
- packuswb mm2, mm0
-
- add edx, ds:[ebp].HALF_WIDTH
- add esi, 0x04
- cmp esi, ds:[ebp].HALF_WIDTH
- movd [edx+esi-4], mm2
-
- jl convyuv422i
- add eax, ds:[ebp].Coded_Picture_Width
- add ecx, ds:[ebp].DOUBLE_WIDTH
- mov esi, 0x00
- dec edi
- cmp edi, 0x00
- jg convyuv422i
-
- convyuv422bottomi:
- movd mm1, [eax+esi]
- movq mm6, mm1
- punpcklbw mm1, mm0
- mov ebx, eax
- sub ebx, ds:[ebp].Coded_Picture_Width
- movd mm3, [ebx+esi]
- punpcklbw mm3, mm0
- pmullw mm1, [mmmask_0007]
- paddusw mm3, mm1
- paddusw mm3, mm4
- psrlw mm3, 0x03
- packuswb mm3, mm0
-
- add ebx, ds:[ebp].HALF_WIDTH
- movq mm1, [ebx+esi]
- punpcklbw mm1, mm0
- movd [ecx+esi], mm3
-
- pmullw mm1, [mmmask_0003]
- add ebx, ds:[ebp].Coded_Picture_Width
- movd mm2, [ebx+esi]
- punpcklbw mm2, mm0
- movq mm7, mm2
- pmullw mm2, mm5
- paddusw mm2, mm1
- paddusw mm2, mm4
- psrlw mm2, 0x03
- packuswb mm2, mm0
-
- mov edx, ecx
- add edx, ds:[ebp].HALF_WIDTH
- pmullw mm7, [mmmask_0007]
- movd [edx+esi], mm2
-
- add edx, ds:[ebp].HALF_WIDTH
- movd [edx+esi], mm6
-
- punpcklbw mm6, mm0
- paddusw mm6, mm7
- paddusw mm6, mm4
- psrlw mm6, 0x03
- packuswb mm6, mm0
-
- add edx, ds:[ebp].HALF_WIDTH
- add esi, 0x04
- cmp esi, ds:[ebp].HALF_WIDTH
- movd [edx+esi-4], mm6
-
- jl convyuv422bottomi
- pop ebp
- }
- }
+ if (frame_type)
+ {
+ __asm
+ {
+ push ebp
+ mov eax, [src]
+ mov ebx, [dst]
+ mov ebp, this
+ mov ecx, ebx
+ add ecx, ds:[ebp].HALF_WIDTH
+ mov esi, 0x00
+ movq mm3, [mmmask_0003]
+ pxor mm0, mm0
+ movq mm4, [mmmask_0002]
+
+ mov edx, eax
+ add edx, ds:[ebp].HALF_WIDTH
+convyuv422topp:
+ movd mm1, [eax+esi]
+ movd mm2, [edx+esi]
+ movd [ebx+esi], mm1
+ punpcklbw mm1, mm0
+ pmullw mm1, mm3
+ paddusw mm1, mm4
+ punpcklbw mm2, mm0
+ paddusw mm2, mm1
+ psrlw mm2, 0x02
+ packuswb mm2, mm0
+
+ add esi, 0x04
+ cmp esi, ds:[ebp].HALF_WIDTH
+ movd [ecx+esi-4], mm2
+ jl convyuv422topp
+
+ add eax, ds:[ebp].HALF_WIDTH
+ add ebx, ds:[ebp].Coded_Picture_Width
+ add ecx, ds:[ebp].Coded_Picture_Width
+ mov esi, 0x00
+
+ mov edi, ds:[ebp].PROGRESSIVE_HEIGHT
+convyuv422p:
+ movd mm1, [eax+esi]
+
+ punpcklbw mm1, mm0
+ mov edx, eax
+
+ pmullw mm1, mm3
+ sub edx, ds:[ebp].HALF_WIDTH
+
+ movd mm5, [edx+esi]
+ movd mm2, [edx+esi]
+
+ punpcklbw mm5, mm0
+ punpcklbw mm2, mm0
+ paddusw mm5, mm1
+ paddusw mm2, mm1
+ paddusw mm5, mm4
+ paddusw mm2, mm4
+ psrlw mm5, 0x02
+ psrlw mm2, 0x02
+ packuswb mm5, mm0
+ packuswb mm2, mm0
+
+ mov edx, eax
+ add edx, ds:[ebp].HALF_WIDTH
+ add esi, 0x04
+ cmp esi, ds:[ebp].HALF_WIDTH
+ movd [ebx+esi-4], mm5
+ movd [ecx+esi-4], mm2
+
+ jl convyuv422p
+
+ add eax, ds:[ebp].HALF_WIDTH
+ add ebx, ds:[ebp].Coded_Picture_Width
+ add ecx, ds:[ebp].Coded_Picture_Width
+ mov esi, 0x00
+ dec edi
+ cmp edi, 0x00
+ jg convyuv422p
+
+ mov edx, eax
+ sub edx, ds:[ebp].HALF_WIDTH
+convyuv422bottomp:
+ movd mm1, [eax+esi]
+ movd mm5, [edx+esi]
+ punpcklbw mm5, mm0
+ movd [ecx+esi], mm1
+
+ punpcklbw mm1, mm0
+ pmullw mm1, mm3
+ paddusw mm5, mm1
+ paddusw mm5, mm4
+ psrlw mm5, 0x02
+ packuswb mm5, mm0
+
+ add esi, 0x04
+ cmp esi, ds:[ebp].HALF_WIDTH
+ movd [ebx+esi-4], mm5
+ jl convyuv422bottomp
+ pop ebp
+ }
+ }
+ else
+ {
+ __asm
+ {
+ push ebp
+ mov eax, [src]
+ mov ecx, [dst]
+ mov ebp, this
+ mov esi, 0x00
+ pxor mm0, mm0
+ movq mm3, [mmmask_0003]
+ movq mm4, [mmmask_0004]
+ movq mm5, [mmmask_0005]
+
+convyuv422topi:
+ movd mm1, [eax+esi]
+ mov ebx, eax
+ add ebx, ds:[ebp].HALF_WIDTH
+ movd mm2, [ebx+esi]
+ movd [ecx+esi], mm1
+ punpcklbw mm1, mm0
+ movq mm6, mm1
+ pmullw mm1, mm3
+
+ punpcklbw mm2, mm0
+ movq mm7, mm2
+ pmullw mm2, mm5
+ paddusw mm2, mm1
+ paddusw mm2, mm4
+ psrlw mm2, 0x03
+ packuswb mm2, mm0
+
+ mov edx, ecx
+ add edx, ds:[ebp].HALF_WIDTH
+ pmullw mm6, mm5
+ movd [edx+esi], mm2
+
+ add ebx, ds:[ebp].HALF_WIDTH
+ movd mm2, [ebx+esi]
+ punpcklbw mm2, mm0
+ pmullw mm2, mm3
+ paddusw mm2, mm6
+ paddusw mm2, mm4
+ psrlw mm2, 0x03
+ packuswb mm2, mm0
+
+ add edx, ds:[ebp].HALF_WIDTH
+ add ebx, ds:[ebp].HALF_WIDTH
+ pmullw mm7, [mmmask_0007]
+ movd [edx+esi], mm2
+
+ movd mm2, [ebx+esi]
+ punpcklbw mm2, mm0
+ paddusw mm2, mm7
+ paddusw mm2, mm4
+ psrlw mm2, 0x03
+ packuswb mm2, mm0
+
+ add edx, ds:[ebp].HALF_WIDTH
+ add esi, 0x04
+ cmp esi, ds:[ebp].HALF_WIDTH
+ movd [edx+esi-4], mm2
+
+ jl convyuv422topi
+
+ add eax, ds:[ebp].Coded_Picture_Width
+ add ecx, ds:[ebp].DOUBLE_WIDTH
+ mov esi, 0x00
+
+ mov edi, ds:[ebp].INTERLACED_HEIGHT
+convyuv422i:
+ movd mm1, [eax+esi]
+ punpcklbw mm1, mm0
+ movq mm6, mm1
+ mov ebx, eax
+ sub ebx, ds:[ebp].Coded_Picture_Width
+ movd mm3, [ebx+esi]
+ pmullw mm1, [mmmask_0007]
+ punpcklbw mm3, mm0
+ paddusw mm3, mm1
+ paddusw mm3, mm4
+ psrlw mm3, 0x03
+ packuswb mm3, mm0
+
+ add ebx, ds:[ebp].HALF_WIDTH
+ movq mm1, [ebx+esi]
+ add ebx, ds:[ebp].Coded_Picture_Width
+ movd [ecx+esi], mm3
+
+ movq mm3, [mmmask_0003]
+ movd mm2, [ebx+esi]
+
+ punpcklbw mm1, mm0
+ pmullw mm1, mm3
+ punpcklbw mm2, mm0
+ movq mm7, mm2
+ pmullw mm2, mm5
+ paddusw mm2, mm1
+ paddusw mm2, mm4
+ psrlw mm2, 0x03
+ packuswb mm2, mm0
+
+ pmullw mm6, mm5
+ mov edx, ecx
+ add edx, ds:[ebp].HALF_WIDTH
+ movd [edx+esi], mm2
+
+ add ebx, ds:[ebp].HALF_WIDTH
+ movd mm2, [ebx+esi]
+ punpcklbw mm2, mm0
+ pmullw mm2, mm3
+ paddusw mm2, mm6
+ paddusw mm2, mm4
+ psrlw mm2, 0x03
+ packuswb mm2, mm0
+
+ pmullw mm7, [mmmask_0007]
+ add edx, ds:[ebp].HALF_WIDTH
+ add ebx, ds:[ebp].HALF_WIDTH
+ movd [edx+esi], mm2
+
+ movd mm2, [ebx+esi]
+ punpcklbw mm2, mm0
+ paddusw mm2, mm7
+ paddusw mm2, mm4
+ psrlw mm2, 0x03
+ packuswb mm2, mm0
+
+ add edx, ds:[ebp].HALF_WIDTH
+ add esi, 0x04
+ cmp esi, ds:[ebp].HALF_WIDTH
+ movd [edx+esi-4], mm2
+
+ jl convyuv422i
+ add eax, ds:[ebp].Coded_Picture_Width
+ add ecx, ds:[ebp].DOUBLE_WIDTH
+ mov esi, 0x00
+ dec edi
+ cmp edi, 0x00
+ jg convyuv422i
+
+convyuv422bottomi:
+ movd mm1, [eax+esi]
+ movq mm6, mm1
+ punpcklbw mm1, mm0
+ mov ebx, eax
+ sub ebx, ds:[ebp].Coded_Picture_Width
+ movd mm3, [ebx+esi]
+ punpcklbw mm3, mm0
+ pmullw mm1, [mmmask_0007]
+ paddusw mm3, mm1
+ paddusw mm3, mm4
+ psrlw mm3, 0x03
+ packuswb mm3, mm0
+
+ add ebx, ds:[ebp].HALF_WIDTH
+ movq mm1, [ebx+esi]
+ punpcklbw mm1, mm0
+ movd [ecx+esi], mm3
+
+ pmullw mm1, [mmmask_0003]
+ add ebx, ds:[ebp].Coded_Picture_Width
+ movd mm2, [ebx+esi]
+ punpcklbw mm2, mm0
+ movq mm7, mm2
+ pmullw mm2, mm5
+ paddusw mm2, mm1
+ paddusw mm2, mm4
+ psrlw mm2, 0x03
+ packuswb mm2, mm0
+
+ mov edx, ecx
+ add edx, ds:[ebp].HALF_WIDTH
+ pmullw mm7, [mmmask_0007]
+ movd [edx+esi], mm2
+
+ add edx, ds:[ebp].HALF_WIDTH
+ movd [edx+esi], mm6
+
+ punpcklbw mm6, mm0
+ paddusw mm6, mm7
+ paddusw mm6, mm4
+ psrlw mm6, 0x03
+ packuswb mm6, mm0
+
+ add edx, ds:[ebp].HALF_WIDTH
+ add esi, 0x04
+ cmp esi, ds:[ebp].HALF_WIDTH
+ movd [edx+esi-4], mm6
+
+ jl convyuv422bottomi
+ pop ebp
+ }
+ }
}
void CMPEG2Dec::conv444toRGB24(unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, int pitch)
{
- int PWIDTH = pitch - DSTBYTES;
-
- py += CLIP_STEP;
- pu += CLIP_STEP;
- pv += CLIP_STEP;
-
- int Clip_Height = this->Clip_Height;
- __int64 RGB_Offset = this->RGB_Offset;
- __int64 RGB_Scale = this->RGB_Scale;
- __int64 RGB_CBU = this->RGB_CBU;
- __int64 RGB_CRV = this->RGB_CRV;
- __int64 RGB_CGX = this->RGB_CGX;
- int Clip_Width = this->Clip_Width;
- int Coded_Picture_Width = this->Coded_Picture_Width;
-
- __asm
- {
- mov eax, [py]
- mov ebx, [pu]
- mov ecx, [pv]
- mov edx, [dst]
- mov edi, Clip_Height
- mov esi, 0x00
- pxor mm0, mm0
-
- convRGB24:
- movd mm1, [eax+esi]
- movd mm3, [ebx+esi]
- punpcklbw mm1, mm0
- punpcklbw mm3, mm0
- movd mm5, [ecx+esi]
- punpcklbw mm5, mm0
- movq mm7, [mmmask_0128]
- psubw mm3, mm7
- psubw mm5, mm7
-
- psubw mm1, RGB_Offset
- movq mm2, mm1
- movq mm7, [mmmask_0001]
- punpcklwd mm1, mm7
- punpckhwd mm2, mm7
- movq mm7, RGB_Scale
- pmaddwd mm1, mm7
- pmaddwd mm2, mm7
-
- movq mm4, mm3
- punpcklwd mm3, mm0
- punpckhwd mm4, mm0
- movq mm7, RGB_CBU
- pmaddwd mm3, mm7
- pmaddwd mm4, mm7
- paddd mm3, mm1
- paddd mm4, mm2
- psrld mm3, 13
- psrld mm4, 13
- packuswb mm3, mm0
- packuswb mm4, mm0
-
- movq mm6, mm5
- punpcklwd mm5, mm0
- punpckhwd mm6, mm0
- movq mm7, RGB_CRV
- pmaddwd mm5, mm7
- pmaddwd mm6, mm7
- paddd mm5, mm1
- paddd mm6, mm2
- psrld mm5, 13
- psrld mm6, 13
- packuswb mm5, mm0
- packuswb mm6, mm0
-
- punpcklbw mm3, mm5
- punpcklbw mm4, mm6
- movq mm5, mm3
- movq mm6, mm4
- psrlq mm5, 16
- psrlq mm6, 16
- por mm3, mm5
- por mm4, mm6
-
- movd mm5, [ebx+esi]
- movd mm6, [ecx+esi]
- punpcklbw mm5, mm0
- punpcklbw mm6, mm0
- movq mm7, [mmmask_0128]
- psubw mm5, mm7
- psubw mm6, mm7
-
- movq mm7, mm6
- punpcklwd mm6, mm5
- punpckhwd mm7, mm5
- movq mm5, RGB_CGX
- pmaddwd mm6, mm5
- pmaddwd mm7, mm5
- paddd mm6, mm1
- paddd mm7, mm2
-
- psrld mm6, 13
- psrld mm7, 13
- packuswb mm6, mm0
- packuswb mm7, mm0
-
- punpcklbw mm3, mm6
- punpcklbw mm4, mm7
-
- movq mm1, mm3
- movq mm5, mm4
- movq mm6, mm4
-
- psrlq mm1, 32
- psllq mm1, 24
- por mm1, mm3
-
- psrlq mm3, 40
- psllq mm6, 16
- por mm3, mm6
- movd [edx], mm1
-
- psrld mm4, 16
- psrlq mm5, 24
- por mm5, mm4
- movd [edx+4], mm3
-
- add edx, 0x0c
- add esi, 0x04
- cmp esi, Clip_Width
- movd [edx-4], mm5
-
- jl convRGB24
-
- add eax, Coded_Picture_Width
- add ebx, Coded_Picture_Width
- add ecx, Coded_Picture_Width
- add edx, PWIDTH
- mov esi, 0x00
- dec edi
- cmp edi, 0x00
- jg convRGB24
-
- emms
- }
+ int PWIDTH = pitch - DSTBYTES;
+
+ py += CLIP_STEP;
+ pu += CLIP_STEP;
+ pv += CLIP_STEP;
+
+ int Clip_Height = this->Clip_Height;
+ __int64 RGB_Offset = this->RGB_Offset;
+ __int64 RGB_Scale = this->RGB_Scale;
+ __int64 RGB_CBU = this->RGB_CBU;
+ __int64 RGB_CRV = this->RGB_CRV;
+ __int64 RGB_CGX = this->RGB_CGX;
+ int Clip_Width = this->Clip_Width;
+ int Coded_Picture_Width = this->Coded_Picture_Width;
+
+ __asm
+ {
+ mov eax, [py]
+ mov ebx, [pu]
+ mov ecx, [pv]
+ mov edx, [dst]
+ mov edi, Clip_Height
+ mov esi, 0x00
+ pxor mm0, mm0
+
+convRGB24:
+ movd mm1, [eax+esi]
+ movd mm3, [ebx+esi]
+ punpcklbw mm1, mm0
+ punpcklbw mm3, mm0
+ movd mm5, [ecx+esi]
+ punpcklbw mm5, mm0
+ movq mm7, [mmmask_0128]
+ psubw mm3, mm7
+ psubw mm5, mm7
+
+ psubw mm1, RGB_Offset
+ movq mm2, mm1
+ movq mm7, [mmmask_0001]
+ punpcklwd mm1, mm7
+ punpckhwd mm2, mm7
+ movq mm7, RGB_Scale
+ pmaddwd mm1, mm7
+ pmaddwd mm2, mm7
+
+ movq mm4, mm3
+ punpcklwd mm3, mm0
+ punpckhwd mm4, mm0
+ movq mm7, RGB_CBU
+ pmaddwd mm3, mm7
+ pmaddwd mm4, mm7
+ paddd mm3, mm1
+ paddd mm4, mm2
+ psrld mm3, 13
+ psrld mm4, 13
+ packuswb mm3, mm0
+ packuswb mm4, mm0
+
+ movq mm6, mm5
+ punpcklwd mm5, mm0
+ punpckhwd mm6, mm0
+ movq mm7, RGB_CRV
+ pmaddwd mm5, mm7
+ pmaddwd mm6, mm7
+ paddd mm5, mm1
+ paddd mm6, mm2
+ psrld mm5, 13
+ psrld mm6, 13
+ packuswb mm5, mm0
+ packuswb mm6, mm0
+
+ punpcklbw mm3, mm5
+ punpcklbw mm4, mm6
+ movq mm5, mm3
+ movq mm6, mm4
+ psrlq mm5, 16
+ psrlq mm6, 16
+ por mm3, mm5
+ por mm4, mm6
+
+ movd mm5, [ebx+esi]
+ movd mm6, [ecx+esi]
+ punpcklbw mm5, mm0
+ punpcklbw mm6, mm0
+ movq mm7, [mmmask_0128]
+ psubw mm5, mm7
+ psubw mm6, mm7
+
+ movq mm7, mm6
+ punpcklwd mm6, mm5
+ punpckhwd mm7, mm5
+ movq mm5, RGB_CGX
+ pmaddwd mm6, mm5
+ pmaddwd mm7, mm5
+ paddd mm6, mm1
+ paddd mm7, mm2
+
+ psrld mm6, 13
+ psrld mm7, 13
+ packuswb mm6, mm0
+ packuswb mm7, mm0
+
+ punpcklbw mm3, mm6
+ punpcklbw mm4, mm7
+
+ movq mm1, mm3
+ movq mm5, mm4
+ movq mm6, mm4
+
+ psrlq mm1, 32
+ psllq mm1, 24
+ por mm1, mm3
+
+ psrlq mm3, 40
+ psllq mm6, 16
+ por mm3, mm6
+ movd [edx], mm1
+
+ psrld mm4, 16
+ psrlq mm5, 24
+ por mm5, mm4
+ movd [edx+4], mm3
+
+ add edx, 0x0c
+ add esi, 0x04
+ cmp esi, Clip_Width
+ movd [edx-4], mm5
+
+ jl convRGB24
+
+ add eax, Coded_Picture_Width
+ add ebx, Coded_Picture_Width
+ add ecx, Coded_Picture_Width
+ add edx, PWIDTH
+ mov esi, 0x00
+ dec edi
+ cmp edi, 0x00
+ jg convRGB24
+
+ emms
+ }
}
// YUV 4:2:2 Format:
// YUYV YUYV ...
void CMPEG2Dec::conv422toYUY2(unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, int pitch)
{
- py += CLIP_STEP;
- pu += CLIP_STEP;
- pv += CLIP_STEP;
-
- int y = this->Clip_Height;
- int Clip_Width_2 = this->Clip_Width / 2;
- int Coded_Picture_Width = this->Coded_Picture_Width;
- int Coded_Picture_Width_2 = this->Coded_Picture_Width / 2;
-
- __asm
- {
- emms
- mov eax, [py]
- mov ebx, [pu]
- mov ecx, [pv]
- mov edx, [dst]
- mov edi, Clip_Width_2
- yloop:
- xor esi, esi
- xloop:
- movd mm1, [eax+esi*2] ;
- 0000YYYY
- movd mm2, [ebx+esi] ;
- 0000UUUU
- movd mm3, [ecx+esi] ;
- 0000VVVV
- ;
- interleave this to VYUYVYUY
- punpcklbw mm2, mm3 ;
- VUVUVUVU
- punpcklbw mm1, mm2 ;
- VYUYVYUY
- movq [edx+esi*4], mm1
- movd mm1, [eax+esi*2+4] ;
- 0000YYYY
- punpckhdq mm2, mm2 ;
- xxxxVUVU
- punpcklbw mm1, mm2 ;
- VYUYVYUY
- movq [edx+esi*4+8], mm1
- add esi, 4
- cmp esi, edi
- jb xloop
- add edx, pitch
- add eax, Coded_Picture_Width
- add ebx, Coded_Picture_Width_2
- add ecx, Coded_Picture_Width_2
- dec y
- jnz yloop
- emms
- }
+ py += CLIP_STEP;
+ pu += CLIP_STEP;
+ pv += CLIP_STEP;
+
+ int y = this->Clip_Height;
+ int Clip_Width_2 = this->Clip_Width / 2;
+ int Coded_Picture_Width = this->Coded_Picture_Width;
+ int Coded_Picture_Width_2 = this->Coded_Picture_Width / 2;
+
+ __asm
+ {
+ emms
+ mov eax, [py]
+ mov ebx, [pu]
+ mov ecx, [pv]
+ mov edx, [dst]
+ mov edi, Clip_Width_2
+ yloop:
+ xor esi, esi
+ xloop:
+ movd mm1, [eax+esi*2] ;0000YYYY
+ movd mm2, [ebx+esi] ;0000UUUU
+ movd mm3, [ecx+esi] ;0000VVVV
+ ;interleave this to VYUYVYUY
+ punpcklbw mm2, mm3 ;VUVUVUVU
+ punpcklbw mm1, mm2 ;VYUYVYUY
+ movq [edx+esi*4], mm1
+ movd mm1, [eax+esi*2+4] ;0000YYYY
+ punpckhdq mm2, mm2 ;xxxxVUVU
+ punpcklbw mm1, mm2 ;VYUYVYUY
+ movq [edx+esi*4+8], mm1
+ add esi, 4
+ cmp esi, edi
+ jb xloop
+ add edx, pitch
+ add eax, Coded_Picture_Width
+ add ebx, Coded_Picture_Width_2
+ add ecx, Coded_Picture_Width_2
+ dec y
+ jnz yloop
+ emms
+ }
}
//
// codec
//
-static const int ChromaFormat[4] =
-{
- 0, 6, 8, 12
+static const int ChromaFormat[4] = {
+ 0, 6, 8, 12
};
CMPEG2Dec::CMPEG2Dec()
{
- VF_File = 0;
- VF_FrameLimit = VF_FrameBound = VF_GOPLimit = VF_GOPNow = VF_GOPSize =
- VF_OldFrame = VF_OldRef = 0;
- VF_FrameSize = VF_FrameRate = 0;
- memset(Rdbfr, 0, sizeof(Rdbfr));
- Rdptr = Rdmax = 0;
- CurrentBfr = NextBfr = BitsLeft = Val = Read = 0;
- Fault_Flag = File_Flag = File_Limit = FO_Flag = IDCT_Flag = SystemStream_Flag = 0;
- Luminance_Flag = Resize_Flag = KeyOp_Flag = lfsr0 = lfsr1 = 0;
- BufferOp = 0;
- memset(intra_quantizer_matrix, 0, sizeof(intra_quantizer_matrix));
- memset(non_intra_quantizer_matrix, 0, sizeof(non_intra_quantizer_matrix));
- memset(chroma_intra_quantizer_matrix, 0, sizeof(chroma_intra_quantizer_matrix));
- memset(chroma_non_intra_quantizer_matrix, 0, sizeof(chroma_non_intra_quantizer_matrix));
- load_intra_quantizer_matrix =
- load_non_intra_quantizer_matrix =
- load_chroma_intra_quantizer_matrix =
- load_chroma_non_intra_quantizer_matrix = 0;
- q_scale_type =
- alternate_scan =
- quantizer_scale = 0;
-
- int i;
- for(i = 0; i < MAX_FILE_NUMBER; i++) Infilename[i] = NULL;
- for(i = 0; i < 8; i++) p_block[i] = block[i] = NULL;
- p_fTempArray = fTempArray = NULL;
- for(i = 0; i < 3; i++) backward_reference_frame[i] = forward_reference_frame[i] = auxframe[i] = NULL;
- lum = NULL;
- u422 = v422 = u444 = v444 = dstFrame = NULL;
- hLibrary = NULL;
-
- CheckCPU();
+ VF_File = 0;
+ VF_FrameLimit = VF_FrameBound = VF_GOPLimit = VF_GOPNow = VF_GOPSize =
+ VF_OldFrame = VF_OldRef = 0;
+ VF_FrameSize = VF_FrameRate = 0;
+ memset(Rdbfr, 0, sizeof(Rdbfr));
+ Rdptr = Rdmax = 0;
+ CurrentBfr = NextBfr = BitsLeft = Val = Read = 0;
+ Fault_Flag = File_Flag = File_Limit = FO_Flag = IDCT_Flag = SystemStream_Flag = 0;
+ Luminance_Flag = Resize_Flag = KeyOp_Flag = lfsr0 = lfsr1 = 0;
+ BufferOp = 0;
+ memset(intra_quantizer_matrix, 0, sizeof(intra_quantizer_matrix));
+ memset(non_intra_quantizer_matrix, 0, sizeof(non_intra_quantizer_matrix));
+ memset(chroma_intra_quantizer_matrix, 0, sizeof(chroma_intra_quantizer_matrix));
+ memset(chroma_non_intra_quantizer_matrix, 0, sizeof(chroma_non_intra_quantizer_matrix));
+ load_intra_quantizer_matrix =
+ load_non_intra_quantizer_matrix =
+ load_chroma_intra_quantizer_matrix =
+ load_chroma_non_intra_quantizer_matrix = 0;
+ q_scale_type =
+ alternate_scan =
+ quantizer_scale = 0;
+
+ int i;
+ for (i=0; i<MAX_FILE_NUMBER; i++) Infilename[i] = NULL;
+ for (i=0; i<8; i++) p_block[i] = block[i] = NULL;
+ p_fTempArray = fTempArray = NULL;
+ for (i=0; i<3; i++) backward_reference_frame[i] = forward_reference_frame[i] = auxframe[i] = NULL;
+ lum = NULL;
+ u422 = v422 = u444 = v444 = dstFrame = NULL;
+ hLibrary = NULL;
+
+ CheckCPU();
}
static char* myfgets(char* buff, int len, FILE* file)
{
- char* ret = buff;
+ char* ret = buff;
- ret[0] = 0;
+ ret[0] = 0;
+
+ while(ret = fgets(buff, len, file))
+ {
+ while(isspace(*ret)) ret++;
+ if(*ret) break;
+ }
- while(ret = fgets(buff, len, file))
- {
- while(isspace(*ret)) ret++;
- if(*ret) break;
- }
-
- return(ret);
+ return(ret);
}
int CMPEG2Dec::Open(LPCTSTR path, DstFormat dstFormat)
{
- m_dstFormat = dstFormat;
- char ID[19], PASS[19] = "DVD2AVIProjectFile";
- DWORD i, j, size, code, type, tff, rff, film, ntsc, gop, top, bottom, mapping;
- int repeat_on, repeat_off, repeat_init;
- int Clip_Top, Clip_Bottom, Clip_Left, Clip_Right, Squeeze_Width, Squeeze_Height;
-
- HKEY key;
- DWORD value = REG_SZ;
- DWORD length = 256;
- char *ext, buffer[256];
-
- CMPEG2Dec* out = this;
-
- out->VF_File = _tfopen(path, _T("r"));
- if(out->VF_File == NULL)
- return 0;
- if(fgets(ID, 19, out->VF_File) == NULL)
- return 0;
- if(strcmp(ID, PASS))
- return 0;
-
- // load DLL
- if(RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\VFPlugin", 0, KEY_ALL_ACCESS, &key) == ERROR_SUCCESS)
- {
- RegQueryValueExA(key, "DVD2AVI", NULL, &value, (unsigned char*)buffer, &length);
-
- ext = strrchr(buffer, '\\');
- sprintf(buffer + (int)(ext - buffer) + 1, "OpenDVD.dll");
- RegCloseKey(key);
- }
-
- if((hLibrary = LoadLibraryA(buffer)) != NULL)
- BufferOp = (PBufferOp) GetProcAddress(hLibrary, "BufferOp");
-
- for(i = 0; i < MAX_FILE_NUMBER; i++)
- Infilename[i] = DNew char[_MAX_PATH];
-
- if(1 != fscanf(out->VF_File, "%d", &File_Limit))
- return 0;
-
- i = File_Limit;
- while(i)
- {
- if(1 != fscanf(out->VF_File, "%d ", &j))
- return 0;
- fgets(Infilename[File_Limit-i], j + 1, out->VF_File);
- if((Infile[File_Limit-i] = _open(Infilename[File_Limit-i], _O_RDONLY | _O_BINARY)) == -1)
- return 0;
- i--;
- }
-
- if(3 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "\nStream_Type=%d,%X,%X\n", &SystemStream_Flag, &lfsr0, &lfsr1))
- return 0;
- if(lfsr0 || lfsr1)
- KeyOp_Flag = 1;
- else
- KeyOp_Flag = 0;
-
- if(1 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "iDCT_Algorithm=%d\n", &IDCT_Flag))
- return 0;
-
- switch(IDCT_Flag)
- {
- case IDCT_SSEMMX:
- if(!cpu.ssemmx)
- IDCT_Flag = IDCT_MMX;
- break;
-
- case IDCT_FPU:
- Initialize_FPU_IDCT();
- break;
-
- case IDCT_REF:
- Initialize_REF_IDCT();
- break;
- }
-
- File_Flag = 0;
- _lseeki64(Infile[0], 0, SEEK_SET);
- Initialize_Buffer();
-
- do
- {
- next_start_code();
- code = Get_Bits(32);
- }
- while(code != SEQUENCE_HEADER_CODE);
-
- sequence_header();
-
- mb_width = (horizontal_size + 15) / 16;
- mb_height = progressive_sequence ? (vertical_size + 15) / 16 : 2 * ((vertical_size + 31) / 32);
-
- Coded_Picture_Width = 16 * mb_width;
- Coded_Picture_Height = 16 * mb_height;
-
- Chroma_Width = (chroma_format == CHROMA444) ? Coded_Picture_Width : Coded_Picture_Width >> 1;
- Chroma_Height = (chroma_format != CHROMA420) ? Coded_Picture_Height : Coded_Picture_Height >> 1;
-
- block_count = ChromaFormat[chroma_format];
-
- for(i = 0; i < 8; i++)
- {
- p_block[i] = (short *)DNew BYTE[sizeof(short)*64 + 64];
- block[i] = (short *)((long)p_block[i] + 64 - (long)p_block[i] % 64);
- }
-
- p_fTempArray = (void *)DNew BYTE[sizeof(float)*128 + 64];
- fTempArray = (void *)((long)p_fTempArray + 64 - (long)p_fTempArray % 64);
-
- for(i = 0; i < 3; i++)
- {
- if(i == 0)
- size = Coded_Picture_Width * Coded_Picture_Height;
- else
- size = Chroma_Width * Chroma_Height;
-
- backward_reference_frame[i] = DNew unsigned char[size];
- forward_reference_frame[i] = DNew unsigned char[size];
- auxframe[i] = DNew unsigned char[size];
- }
-
- if(1 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "YUVRGB_Scale=%d\n", &i))
- return 0;
-
- if(i)
- {
- RGB_Scale = 0x1000254310002543;
- RGB_Offset = 0x0010001000100010;
- RGB_CBU = 0x0000408D0000408D;
- RGB_CGX = 0xF377E5FCF377E5FC;
- RGB_CRV = 0x0000331300003313;
- }
- else
- {
- RGB_Scale = 0x1000200010002000;
- RGB_Offset = 0x0000000000000000;
- RGB_CBU = 0x000038B4000038B4;
- RGB_CGX = 0xF4FDE926F4FDE926;
- RGB_CRV = 0x00002CDD00002CDD;
- }
-
- char* tmp = myfgets(buffer, sizeof(buffer), out->VF_File);
- if(2 != sscanf(tmp, "Luminance=%d,%d\n", &i, &j))
- {
- if(2 != sscanf(tmp, "Luminance_Filter=%d,%d\n", &i, &j))
- return 0;
- i = 128;
- j = 0;
- }
-
- if(i == 128 && j == 0)
- Luminance_Flag = 0;
- else
- {
- Luminance_Flag = 1;
- LumGainMask = ((__int64)i << 48) + ((__int64)i << 32) + ((__int64)i << 16) + (__int64)i;
- LumOffsetMask = ((__int64)j << 48) + ((__int64)j << 32) + ((__int64)j << 16) + (__int64)j;
-
- lum = DNew unsigned char[Coded_Picture_Width * Coded_Picture_Height];
- }
-
- if(6 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "Picture_Size=%d,%d,%d,%d,%d,%d\n",
- &Clip_Top, &Clip_Bottom, &Clip_Left, &Clip_Right, &Squeeze_Width, &Squeeze_Height))
- return 0;
-
- Resize_Flag = 0;
- Resize_Width = Clip_Width = Coded_Picture_Width;
- Resize_Height = Clip_Height = Coded_Picture_Height;
- CLIP_AREA = HALF_CLIP_AREA = CLIP_STEP = 0;
-
- if(Clip_Top || Clip_Bottom || Clip_Left || Clip_Right)
- {
- Clip_Width -= Clip_Left + Clip_Right;
- Clip_Height -= Clip_Top + Clip_Bottom;
- Resize_Width = Clip_Width;
- Resize_Height = Clip_Height;
-
- CLIP_AREA = Coded_Picture_Width * Clip_Top;
- HALF_CLIP_AREA = (Coded_Picture_Width >> 1) * Clip_Top;
- CLIP_STEP = Coded_Picture_Width * Clip_Top + Clip_Left;
- }
-
- if(Squeeze_Width || Squeeze_Height)
- {
- Resize_Flag = 1;
- Resize_Width -= Squeeze_Width;
- Resize_Height -= Squeeze_Height;
- }
-
- DSTBYTES = Clip_Width * (dstRGB24() ? 3 : 2);
- DSTBYTES2 = DSTBYTES * 2;
- LUM_AREA = Coded_Picture_Width * Clip_Height;
- PROGRESSIVE_HEIGHT = (Coded_Picture_Height >> 1) - 2;
- INTERLACED_HEIGHT = (Coded_Picture_Height >> 2) - 2;
- HALF_WIDTH = Coded_Picture_Width >> 1;
- HALF_WIDTH_D8 = (Coded_Picture_Width >> 1) - 8;
- DOUBLE_WIDTH = Coded_Picture_Width << 1;
-
- u422 = DNew unsigned char[Coded_Picture_Width * Coded_Picture_Height / 2];
- v422 = DNew unsigned char[Coded_Picture_Width * Coded_Picture_Height / 2];
- u444 = DNew unsigned char[Coded_Picture_Width * Coded_Picture_Height];
- v444 = DNew unsigned char[Coded_Picture_Width * Coded_Picture_Height];
- dstFrame = DNew unsigned char[Clip_Width * Clip_Height * 4]; // max value (super set)
-
- if(1 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "Field_Operation=%d\n", &FO_Flag))
- return 0;
- if(1 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "Frame_Rate=%d\n", &(out->VF_FrameRate)))
- return 0;
- if(4 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "Location=%d,%X,%d,%X\n", &i, &j, &i, &j))
- return 0;
-
- ntsc = film = top = bottom = gop = mapping = repeat_on = repeat_off = repeat_init = 0;
-
- while(1 == fscanf(out->VF_File, "%d", &type) && type < 9)
- {
- if(type == 7) // I frame
- {
- GOPList[gop] = reinterpret_cast<GOPLIST*>(calloc(1, sizeof(GOPLIST)));
- GOPList[gop]->number = film;
- if(2 != fscanf(out->VF_File, "%d %X", &(GOPList[gop]->file), &j))
- break;
-
- GOPList[gop]->position = (__int64)j * BUFFER_SIZE;
- gop ++;
-
- if(1 != fscanf(out->VF_File, "%d", &j))
- break;
-
- tff = j >> 1;
- rff = j & 1;
- }
- else // P, B frame
- {
- tff = type >> 1;
- rff = type & 1;
- }
-
- if(!film)
- {
- if(tff)
- Field_Order = 1;
- else
- Field_Order = 0;
- }
-
- if(FO_Flag == FO_FILM)
- {
- if(rff)
- repeat_on++;
- else
- repeat_off++;
-
- if(repeat_init)
- {
- if(repeat_off - repeat_on == 5)
- {
- repeat_on = repeat_off = 0;
- }
- else
- {
- FrameList[mapping] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
- FrameList[mapping]->top = FrameList[mapping]->bottom = film;
- mapping ++;
- }
-
- if(repeat_on - repeat_off == 5)
- {
- repeat_on = repeat_off = 0;
- FrameList[mapping] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
- FrameList[mapping]->top = FrameList[mapping]->bottom = film;
- mapping ++;
- }
- }
- else
- {
- if(repeat_off - repeat_on == 3)
- {
- repeat_on = repeat_off = 0;
- repeat_init = 1;
- }
- else
- {
- FrameList[mapping] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
- FrameList[mapping]->top = FrameList[mapping]->bottom = film;
- mapping ++;
- }
-
- if(repeat_on - repeat_off == 3)
- {
- repeat_on = repeat_off = 0;
- repeat_init = 1;
-
- FrameList[mapping] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
- FrameList[mapping]->top = FrameList[mapping]->bottom = film;
- mapping ++;
- }
- }
- }
- else
- {
- if(top)
- {
- FrameList[ntsc]->bottom = film;
- ntsc ++;
- FrameList[ntsc] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
- FrameList[ntsc]->top = film;
- }
- else if(bottom)
- {
- FrameList[ntsc]->top = film;
- ntsc ++;
- FrameList[ntsc] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
- FrameList[ntsc]->bottom = film;
- }
- else
- {
- FrameList[ntsc] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
- FrameList[ntsc]->top = film;
- FrameList[ntsc]->bottom = film;
- ntsc ++;
- }
-
- if(rff)
- {
- if(!top && !bottom)
- FrameList[ntsc] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
-
- if(tff)
- {
- FrameList[ntsc]->top = film;
- top = 1;
- }
- else
- {
- FrameList[ntsc]->bottom = film;
- bottom = 1;
- }
-
- if(top && bottom)
- {
- top = bottom = 0;
- ntsc ++;
- }
- }
- }
-
- film ++;
- }
-
- out->VF_FrameBound = film;
- film -= 2;
-
- if(FO_Flag == FO_FILM)
- {
- while(FrameList[mapping-1]->top >= film)
- mapping --;
-
- out->VF_FrameLimit = mapping;
- }
- else
- {
- if(FO_Flag == FO_SWAP)
- {
- Field_Order = !Field_Order;
-
- if(Field_Order)
- for(i = 0; i < ntsc - 1; i++)
- FrameList[i]->bottom = FrameList[i+1]->bottom;
- else
- for(i = 0; i < ntsc - 1; i++)
- FrameList[i]->top = FrameList[i+1]->top;
- }
-
- while((FrameList[ntsc-1]->top >= film) || (FrameList[ntsc-1]->bottom >= film))
- ntsc --;
-
- out->VF_FrameLimit = ntsc;
-
- for(i = 0; i < out->VF_FrameLimit - 1; i++)
- if(FrameList[i]->top == FrameList[i+1]->top || FrameList[i]->top == FrameList[i+1]->bottom ||
- FrameList[i]->bottom == FrameList[i+1]->top || FrameList[i]->bottom == FrameList[i+1]->bottom)
- {
- FrameList[i]->forward = 1;
- FrameList[i+1]->backward = 1;
- }
- }
-
- Full_Frame = 1;
- for(i = 0; i < out->VF_FrameLimit; i++)
- if(FrameList[i]->top != FrameList[i]->bottom)
- {
- Full_Frame = 0;
- break;
- }
-
- out->VF_GOPNow = out->VF_GOPLimit = gop;
- out->VF_OldFrame = out->VF_FrameLimit;
- out->VF_FrameSize = Clip_Width * Clip_Height * 3;
-
- return 1;
+ m_dstFormat = dstFormat;
+ char ID[19], PASS[19] = "DVD2AVIProjectFile";
+ DWORD i, j, size, code, type, tff, rff, film, ntsc, gop, top, bottom, mapping;
+ int repeat_on, repeat_off, repeat_init;
+ int Clip_Top, Clip_Bottom, Clip_Left, Clip_Right, Squeeze_Width, Squeeze_Height;
+
+ HKEY key; DWORD value = REG_SZ; DWORD length = 256;
+ char *ext, buffer[256];
+
+ CMPEG2Dec* out = this;
+
+ out->VF_File = _tfopen(path, _T("r"));
+ if (out->VF_File==NULL)
+ return 0;
+ if (fgets(ID, 19, out->VF_File)==NULL)
+ return 0;
+ if (strcmp(ID, PASS))
+ return 0;
+
+ // load DLL
+ if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\VFPlugin", 0, KEY_ALL_ACCESS, &key)==ERROR_SUCCESS)
+ {
+ RegQueryValueExA(key, "DVD2AVI", NULL, &value, (unsigned char*)buffer, &length);
+
+ ext = strrchr(buffer, '\\');
+ sprintf(buffer + (int)(ext-buffer) + 1, "OpenDVD.dll");
+ RegCloseKey(key);
+ }
+
+ if ((hLibrary = LoadLibraryA(buffer)) != NULL)
+ BufferOp = (PBufferOp) GetProcAddress(hLibrary, "BufferOp");
+
+ for (i=0; i<MAX_FILE_NUMBER; i++)
+ Infilename[i] = DNew char[_MAX_PATH];
+
+ if(1 != fscanf(out->VF_File, "%d", &File_Limit))
+ return 0;
+
+ i = File_Limit;
+ while (i)
+ {
+ if(1 != fscanf(out->VF_File, "%d ", &j))
+ return 0;
+ fgets(Infilename[File_Limit-i], j+1, out->VF_File);
+ if ((Infile[File_Limit-i] = _open(Infilename[File_Limit-i], _O_RDONLY | _O_BINARY))==-1)
+ return 0;
+ i--;
+ }
+
+ if(3 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "\nStream_Type=%d,%X,%X\n", &SystemStream_Flag, &lfsr0, &lfsr1))
+ return 0;
+ if (lfsr0 || lfsr1)
+ KeyOp_Flag = 1;
+ else
+ KeyOp_Flag = 0;
+
+ if(1 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "iDCT_Algorithm=%d\n", &IDCT_Flag))
+ return 0;
+
+ switch (IDCT_Flag)
+ {
+ case IDCT_SSEMMX:
+ if (!cpu.ssemmx)
+ IDCT_Flag = IDCT_MMX;
+ break;
+
+ case IDCT_FPU:
+ Initialize_FPU_IDCT();
+ break;
+
+ case IDCT_REF:
+ Initialize_REF_IDCT();
+ break;
+ }
+
+ File_Flag = 0;
+ _lseeki64(Infile[0], 0, SEEK_SET);
+ Initialize_Buffer();
+
+ do
+ {
+ next_start_code();
+ code = Get_Bits(32);
+ }
+ while (code!=SEQUENCE_HEADER_CODE);
+
+ sequence_header();
+
+ mb_width = (horizontal_size+15)/16;
+ mb_height = progressive_sequence ? (vertical_size+15)/16 : 2*((vertical_size+31)/32);
+
+ Coded_Picture_Width = 16 * mb_width;
+ Coded_Picture_Height = 16 * mb_height;
+
+ Chroma_Width = (chroma_format==CHROMA444) ? Coded_Picture_Width : Coded_Picture_Width>>1;
+ Chroma_Height = (chroma_format!=CHROMA420) ? Coded_Picture_Height : Coded_Picture_Height>>1;
+
+ block_count = ChromaFormat[chroma_format];
+
+ for (i=0; i<8; i++)
+ {
+ p_block[i] = (short *)DNew BYTE[sizeof(short)*64 + 64];
+ block[i] = (short *)((long)p_block[i] + 64 - (long)p_block[i]%64);
+ }
+
+ p_fTempArray = (void *)DNew BYTE[sizeof(float)*128 + 64];
+ fTempArray = (void *)((long)p_fTempArray + 64 - (long)p_fTempArray%64);
+
+ for (i=0; i<3; i++)
+ {
+ if (i==0)
+ size = Coded_Picture_Width * Coded_Picture_Height;
+ else
+ size = Chroma_Width * Chroma_Height;
+
+ backward_reference_frame[i] = DNew unsigned char[size];
+ forward_reference_frame[i] = DNew unsigned char[size];
+ auxframe[i] = DNew unsigned char[size];
+ }
+
+ if(1 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "YUVRGB_Scale=%d\n", &i))
+ return 0;
+
+ if (i)
+ {
+ RGB_Scale = 0x1000254310002543;
+ RGB_Offset = 0x0010001000100010;
+ RGB_CBU = 0x0000408D0000408D;
+ RGB_CGX = 0xF377E5FCF377E5FC;
+ RGB_CRV = 0x0000331300003313;
+ }
+ else
+ {
+ RGB_Scale = 0x1000200010002000;
+ RGB_Offset = 0x0000000000000000;
+ RGB_CBU = 0x000038B4000038B4;
+ RGB_CGX = 0xF4FDE926F4FDE926;
+ RGB_CRV = 0x00002CDD00002CDD;
+ }
+
+ char* tmp = myfgets(buffer, sizeof(buffer), out->VF_File);
+ if(2 != sscanf(tmp, "Luminance=%d,%d\n", &i, &j))
+ {
+ if(2 != sscanf(tmp, "Luminance_Filter=%d,%d\n", &i, &j))
+ return 0;
+ i=128; j=0;
+ }
+
+ if (i==128 && j==0)
+ Luminance_Flag = 0;
+ else
+ {
+ Luminance_Flag = 1;
+ LumGainMask = ((__int64)i<<48) + ((__int64)i<<32) + ((__int64)i<<16) + (__int64)i;
+ LumOffsetMask = ((__int64)j<<48) + ((__int64)j<<32) + ((__int64)j<<16) + (__int64)j;
+
+ lum = DNew unsigned char[Coded_Picture_Width * Coded_Picture_Height];
+ }
+
+ if(6 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "Picture_Size=%d,%d,%d,%d,%d,%d\n",
+ &Clip_Top, &Clip_Bottom, &Clip_Left, &Clip_Right, &Squeeze_Width, &Squeeze_Height))
+ return 0;
+
+ Resize_Flag = 0;
+ Resize_Width = Clip_Width = Coded_Picture_Width;
+ Resize_Height = Clip_Height = Coded_Picture_Height;
+ CLIP_AREA = HALF_CLIP_AREA = CLIP_STEP = 0;
+
+ if (Clip_Top || Clip_Bottom || Clip_Left || Clip_Right)
+ {
+ Clip_Width -= Clip_Left+Clip_Right;
+ Clip_Height -= Clip_Top+Clip_Bottom;
+ Resize_Width = Clip_Width;
+ Resize_Height = Clip_Height;
+
+ CLIP_AREA = Coded_Picture_Width * Clip_Top;
+ HALF_CLIP_AREA = (Coded_Picture_Width>>1) * Clip_Top;
+ CLIP_STEP = Coded_Picture_Width * Clip_Top + Clip_Left;
+ }
+
+ if (Squeeze_Width || Squeeze_Height)
+ {
+ Resize_Flag = 1;
+ Resize_Width -= Squeeze_Width;
+ Resize_Height -= Squeeze_Height;
+ }
+
+ DSTBYTES = Clip_Width * (dstRGB24() ? 3 : 2);
+ DSTBYTES2 = DSTBYTES * 2;
+ LUM_AREA = Coded_Picture_Width * Clip_Height;
+ PROGRESSIVE_HEIGHT = (Coded_Picture_Height>>1) - 2;
+ INTERLACED_HEIGHT = (Coded_Picture_Height>>2) - 2;
+ HALF_WIDTH = Coded_Picture_Width>>1;
+ HALF_WIDTH_D8 = (Coded_Picture_Width>>1) - 8;
+ DOUBLE_WIDTH = Coded_Picture_Width<<1;
+
+ u422 = DNew unsigned char[Coded_Picture_Width * Coded_Picture_Height / 2];
+ v422 = DNew unsigned char[Coded_Picture_Width * Coded_Picture_Height / 2];
+ u444 = DNew unsigned char[Coded_Picture_Width * Coded_Picture_Height];
+ v444 = DNew unsigned char[Coded_Picture_Width * Coded_Picture_Height];
+ dstFrame = DNew unsigned char[Clip_Width * Clip_Height * 4]; // max value (super set)
+
+ if(1 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "Field_Operation=%d\n", &FO_Flag))
+ return 0;
+ if(1 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "Frame_Rate=%d\n", &(out->VF_FrameRate)))
+ return 0;
+ if(4 != sscanf(myfgets(buffer, sizeof(buffer), out->VF_File), "Location=%d,%X,%d,%X\n", &i, &j, &i, &j))
+ return 0;
+
+ ntsc = film = top = bottom = gop = mapping = repeat_on = repeat_off = repeat_init = 0;
+
+ while (1 == fscanf(out->VF_File, "%d", &type) && type<9)
+ {
+ if (type==7) // I frame
+ {
+ GOPList[gop] = reinterpret_cast<GOPLIST*>(calloc(1, sizeof(GOPLIST)));
+ GOPList[gop]->number = film;
+ if(2 != fscanf(out->VF_File, "%d %X", &(GOPList[gop]->file), &j))
+ break;
+
+ GOPList[gop]->position = (__int64)j*BUFFER_SIZE;
+ gop ++;
+
+ if(1 != fscanf(out->VF_File, "%d", &j))
+ break;
+
+ tff = j>>1;
+ rff = j & 1;
+ }
+ else // P, B frame
+ {
+ tff = type>>1;
+ rff = type & 1;
+ }
+
+ if (!film)
+ {
+ if (tff)
+ Field_Order = 1;
+ else
+ Field_Order = 0;
+ }
+
+ if (FO_Flag==FO_FILM)
+ {
+ if (rff)
+ repeat_on++;
+ else
+ repeat_off++;
+
+ if (repeat_init)
+ {
+ if (repeat_off-repeat_on == 5)
+ {
+ repeat_on = repeat_off = 0;
+ }
+ else
+ {
+ FrameList[mapping] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
+ FrameList[mapping]->top = FrameList[mapping]->bottom = film;
+ mapping ++;
+ }
+
+ if (repeat_on-repeat_off == 5)
+ {
+ repeat_on = repeat_off = 0;
+ FrameList[mapping] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
+ FrameList[mapping]->top = FrameList[mapping]->bottom = film;
+ mapping ++;
+ }
+ }
+ else
+ {
+ if (repeat_off-repeat_on == 3)
+ {
+ repeat_on = repeat_off = 0;
+ repeat_init = 1;
+ }
+ else
+ {
+ FrameList[mapping] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
+ FrameList[mapping]->top = FrameList[mapping]->bottom = film;
+ mapping ++;
+ }
+
+ if (repeat_on-repeat_off == 3)
+ {
+ repeat_on = repeat_off = 0;
+ repeat_init = 1;
+
+ FrameList[mapping] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
+ FrameList[mapping]->top = FrameList[mapping]->bottom = film;
+ mapping ++;
+ }
+ }
+ }
+ else
+ {
+ if (top)
+ {
+ FrameList[ntsc]->bottom = film;
+ ntsc ++;
+ FrameList[ntsc] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
+ FrameList[ntsc]->top = film;
+ }
+ else if (bottom)
+ {
+ FrameList[ntsc]->top = film;
+ ntsc ++;
+ FrameList[ntsc] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
+ FrameList[ntsc]->bottom = film;
+ }
+ else
+ {
+ FrameList[ntsc] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
+ FrameList[ntsc]->top = film;
+ FrameList[ntsc]->bottom = film;
+ ntsc ++;
+ }
+
+ if (rff)
+ {
+ if (!top && !bottom)
+ FrameList[ntsc] = reinterpret_cast<FRAMELIST*>(calloc(1, sizeof(FRAMELIST)));
+
+ if (tff)
+ {
+ FrameList[ntsc]->top = film;
+ top = 1;
+ }
+ else
+ {
+ FrameList[ntsc]->bottom = film;
+ bottom = 1;
+ }
+
+ if (top && bottom)
+ {
+ top = bottom = 0;
+ ntsc ++;
+ }
+ }
+ }
+
+ film ++;
+ }
+
+ out->VF_FrameBound = film;
+ film -= 2;
+
+ if (FO_Flag==FO_FILM)
+ {
+ while (FrameList[mapping-1]->top >= film)
+ mapping --;
+
+ out->VF_FrameLimit = mapping;
+ }
+ else
+ {
+ if (FO_Flag==FO_SWAP)
+ {
+ Field_Order = !Field_Order;
+
+ if (Field_Order)
+ for (i=0; i<ntsc-1; i++)
+ FrameList[i]->bottom = FrameList[i+1]->bottom;
+ else
+ for (i=0; i<ntsc-1; i++)
+ FrameList[i]->top = FrameList[i+1]->top;
+ }
+
+ while ((FrameList[ntsc-1]->top >= film) || (FrameList[ntsc-1]->bottom >= film))
+ ntsc --;
+
+ out->VF_FrameLimit = ntsc;
+
+ for (i=0; i<out->VF_FrameLimit-1; i++)
+ if (FrameList[i]->top==FrameList[i+1]->top || FrameList[i]->top==FrameList[i+1]->bottom ||
+ FrameList[i]->bottom==FrameList[i+1]->top || FrameList[i]->bottom==FrameList[i+1]->bottom)
+ {
+ FrameList[i]->forward = 1;
+ FrameList[i+1]->backward = 1;
+ }
+ }
+
+ Full_Frame = 1;
+ for (i=0; i<out->VF_FrameLimit; i++)
+ if (FrameList[i]->top!=FrameList[i]->bottom)
+ {
+ Full_Frame = 0;
+ break;
+ }
+
+ out->VF_GOPNow = out->VF_GOPLimit = gop;
+ out->VF_OldFrame = out->VF_FrameLimit;
+ out->VF_FrameSize = Clip_Width * Clip_Height * 3;
+
+ return 1;
}
void CMPEG2Dec::Decode(unsigned char *dst, DWORD frame, int pitch)
{
- DWORD i, now, size, origin, ref, fo;
- int remain;
-
- CMPEG2Dec* in = this;
-
- if(FO_Flag == FO_FILM)
- {
- fo = 0;
- frame = FrameList[frame]->top;
- }
-
- origin = frame;
-
- if(FO_Flag != FO_FILM)
- {
- if(FrameList[frame]->top == FrameList[frame]->bottom)
- {
- fo = 0;
- frame = FrameList[frame]->top;
- }
- else if(FrameList[frame]->top < FrameList[frame]->bottom)
- {
- fo = 1;
- frame = FrameList[frame]->top;
- }
- else
- {
- fo = 2;
- frame = FrameList[frame]->bottom;
- }
- }
-
- ref = frame;
-
- if(frame >= GOPList[in->VF_GOPLimit-1]->number)
- {
- now = in->VF_GOPLimit - 1;
- ref -= GOPList[in->VF_GOPLimit-1]->number;
- size = in->VF_FrameBound - GOPList[in->VF_GOPLimit-1]->number + 1;
- }
- else
- for(now = 0; now < (in->VF_GOPLimit - 1); now++)
- {
- if(frame >= GOPList[now]->number && frame < GOPList[now+1]->number)
- {
- ref -= GOPList[now]->number;
- size = GOPList[now+1]->number - GOPList[now]->number + 1;
- break;
- }
- }
-
- if(fo)
- ref ++;
-
- if(now != in->VF_GOPNow)
- {
- if((in->VF_OldFrame + 1) == origin)
- {
- if(Full_Frame)
- {
- Get_Hdr();
- Decode_Picture(1, dst, pitch);
-
- if(picture_structure != FRAME_PICTURE)
- {
- Get_Hdr();
- Decode_Picture(1, dst, pitch);
- }
- }
- else
- switch(fo)
- {
- case 0:
- if(!FrameList[origin]->backward)
- {
- Get_Hdr();
- Decode_Picture(1, dst, pitch);
-
- if(picture_structure != FRAME_PICTURE)
- {
- Get_Hdr();
- Decode_Picture(1, dst, pitch);
- }
-
- if(FrameList[origin]->forward)
- {
- if(Field_Order)
- Copyodd(dst, dstFrame, pitch, 1);
- else
- Copyeven(dst, dstFrame, pitch, 1);
- }
- }
- else
- {
- Copyodd(dstFrame, dst, pitch, 0);
- Copyeven(dstFrame, dst, pitch, 0);
- }
- break;
-
- case 1:
- Copyodd(dstFrame, dst, pitch, 0);
-
- Get_Hdr();
- Decode_Picture(1, dstFrame, DSTBYTES);
-
- if(picture_structure != FRAME_PICTURE)
- {
- Get_Hdr();
- Decode_Picture(1, dstFrame, DSTBYTES);
- }
-
- Copyeven(dstFrame, dst, pitch, 0);
- break;
-
- case 2:
- Copyeven(dstFrame, dst, pitch, 0);
-
- Get_Hdr();
- Decode_Picture(1, dstFrame, DSTBYTES);
-
- if(picture_structure != FRAME_PICTURE)
- {
- Get_Hdr();
- Decode_Picture(1, dstFrame, DSTBYTES);
- }
-
- Copyodd(dstFrame, dst, pitch, 0);
- break;
- }
-
- if(in->VF_GOPSize)
- {
- for(i = 0; i < in->VF_GOPSize; i++)
- free(GOPBuffer[i]);
-
- in->VF_GOPSize = 0;
- }
-
- in->VF_GOPNow = in->VF_GOPLimit;
- in->VF_OldFrame = origin;
- return;
- }
-
- remain = ref;
- in->VF_OldRef = ref;
- in->VF_GOPNow = now;
- Second_Field = 0;
-
- if(size < in->VF_GOPSize)
- for(i = 0; i < (in->VF_GOPSize - size); i++)
- free(GOPBuffer[size+i]);
- else if(size > in->VF_GOPSize)
- for(i = 0; i < (size - in->VF_GOPSize); i++)
- GOPBuffer[in->VF_GOPSize+i] = reinterpret_cast<unsigned char*>(malloc(in->VF_FrameSize));
-
- in->VF_GOPSize = size;
-
- File_Flag = GOPList[now]->file;
- _lseeki64(Infile[GOPList[now]->file], GOPList[now]->position, SEEK_SET);
- Initialize_Buffer();
-
- while(Get_Hdr() && picture_coding_type != I_TYPE);
-
- Decode_Picture(0, dst, pitch);
-
- while(Get_Hdr() && picture_coding_type == B_TYPE);
-
- if(picture_structure != FRAME_PICTURE)
- {
- Decode_Picture(0, dst, pitch);
- Get_Hdr();
- }
-
- Decode_Picture(1, dst, pitch);
-
- if(picture_structure != FRAME_PICTURE)
- {
- Get_Hdr();
- Decode_Picture(1, dst, pitch);
- }
-
- Copyodd(dst, GOPBuffer[0], pitch, 1);
- Copyeven(dst, GOPBuffer[0], pitch, 1);
-
- while(remain && Get_Hdr())
- {
- Decode_Picture(1, dst, pitch);
-
- if(picture_structure != FRAME_PICTURE)
- {
- Get_Hdr();
- Decode_Picture(1, dst, pitch);
- }
-
- Copyodd(dst, GOPBuffer[ref - remain + 1], pitch, 1);
- Copyeven(dst, GOPBuffer[ref - remain + 1], pitch, 1);
-
- remain--;
- }
-
- if(!Full_Frame && ref >= (size - 2))
- {
- Copyodd(dst, dstFrame, pitch, 1);
- Copyeven(dst, dstFrame, pitch, 1);
- }
- }
- else
- {
- remain = ref - in->VF_OldRef;
-
- if(remain > 0)
- {
- in->VF_OldRef = ref;
-
- while(remain && Get_Hdr())
- {
- Decode_Picture(1, dst, pitch);
-
- if(picture_structure != FRAME_PICTURE)
- {
- Get_Hdr();
- Decode_Picture(1, dst, pitch);
- }
-
- Copyodd(dst, GOPBuffer[ref - remain + 1], pitch, 1);
- Copyeven(dst, GOPBuffer[ref - remain + 1], pitch, 1);
-
- remain--;
- }
-
- if(!Full_Frame && ref >= (size - 2))
- {
- Copyodd(dst, dstFrame, pitch, 1);
- Copyeven(dst, dstFrame, pitch, 1);
- }
- }
- }
-
- switch(fo)
- {
- case 0:
- Copyodd(GOPBuffer[ref], dst, pitch, 0);
- Copyeven(GOPBuffer[ref], dst, pitch, 0);
- break;
-
- case 1:
- Copyodd(GOPBuffer[ref-1], dst, pitch, 0);
- Copyeven(GOPBuffer[ref], dst, pitch, 0);
- break;
-
- case 2:
- Copyodd(GOPBuffer[ref], dst, pitch, 0);
- Copyeven(GOPBuffer[ref-1], dst, pitch, 0);
- break;
- }
-
- in->VF_OldFrame = origin;
+ DWORD i, now, size, origin, ref, fo;
+ int remain;
+
+ CMPEG2Dec* in = this;
+
+ if (FO_Flag==FO_FILM)
+ {
+ fo = 0;
+ frame = FrameList[frame]->top;
+ }
+
+ origin = frame;
+
+ if (FO_Flag!=FO_FILM)
+ {
+ if (FrameList[frame]->top == FrameList[frame]->bottom)
+ {
+ fo = 0;
+ frame = FrameList[frame]->top;
+ }
+ else if (FrameList[frame]->top < FrameList[frame]->bottom)
+ {
+ fo = 1;
+ frame = FrameList[frame]->top;
+ }
+ else
+ {
+ fo = 2;
+ frame = FrameList[frame]->bottom;
+ }
+ }
+
+ ref = frame;
+
+ if (frame >= GOPList[in->VF_GOPLimit-1]->number)
+ {
+ now = in->VF_GOPLimit-1;
+ ref -= GOPList[in->VF_GOPLimit-1]->number;
+ size = in->VF_FrameBound - GOPList[in->VF_GOPLimit-1]->number + 1;
+ }
+ else
+ for (now = 0; now < (in->VF_GOPLimit-1); now++)
+ {
+ if (frame>=GOPList[now]->number && frame<GOPList[now+1]->number)
+ {
+ ref -= GOPList[now]->number;
+ size = GOPList[now+1]->number - GOPList[now]->number + 1;
+ break;
+ }
+ }
+
+ if (fo)
+ ref ++;
+
+ if (now != in->VF_GOPNow)
+ {
+ if ((in->VF_OldFrame + 1)==origin)
+ {
+ if (Full_Frame)
+ {
+ Get_Hdr();
+ Decode_Picture(1, dst, pitch);
+
+ if (picture_structure!=FRAME_PICTURE)
+ {
+ Get_Hdr();
+ Decode_Picture(1, dst, pitch);
+ }
+ }
+ else
+ switch (fo)
+ {
+ case 0:
+ if (!FrameList[origin]->backward)
+ {
+ Get_Hdr();
+ Decode_Picture(1, dst, pitch);
+
+ if (picture_structure!=FRAME_PICTURE)
+ {
+ Get_Hdr();
+ Decode_Picture(1, dst, pitch);
+ }
+
+ if (FrameList[origin]->forward)
+ {
+ if (Field_Order)
+ Copyodd(dst, dstFrame, pitch, 1);
+ else
+ Copyeven(dst, dstFrame, pitch, 1);
+ }
+ }
+ else
+ {
+ Copyodd(dstFrame, dst, pitch, 0);
+ Copyeven(dstFrame, dst, pitch, 0);
+ }
+ break;
+
+ case 1:
+ Copyodd(dstFrame, dst, pitch, 0);
+
+ Get_Hdr();
+ Decode_Picture(1, dstFrame, DSTBYTES);
+
+ if (picture_structure!=FRAME_PICTURE)
+ {
+ Get_Hdr();
+ Decode_Picture(1, dstFrame, DSTBYTES);
+ }
+
+ Copyeven(dstFrame, dst, pitch, 0);
+ break;
+
+ case 2:
+ Copyeven(dstFrame, dst, pitch, 0);
+
+ Get_Hdr();
+ Decode_Picture(1, dstFrame, DSTBYTES);
+
+ if (picture_structure!=FRAME_PICTURE)
+ {
+ Get_Hdr();
+ Decode_Picture(1, dstFrame, DSTBYTES);
+ }
+
+ Copyodd(dstFrame, dst, pitch, 0);
+ break;
+ }
+
+ if (in->VF_GOPSize)
+ {
+ for (i=0; i < in->VF_GOPSize; i++)
+ free(GOPBuffer[i]);
+
+ in->VF_GOPSize = 0;
+ }
+
+ in->VF_GOPNow = in->VF_GOPLimit;
+ in->VF_OldFrame = origin;
+ return;
+ }
+
+ remain = ref;
+ in->VF_OldRef = ref;
+ in->VF_GOPNow = now;
+ Second_Field = 0;
+
+ if (size < in->VF_GOPSize)
+ for (i=0; i < (in->VF_GOPSize - size); i++)
+ free(GOPBuffer[size+i]);
+ else if (size > in->VF_GOPSize)
+ for (i=0; i < (size - in->VF_GOPSize); i++)
+ GOPBuffer[in->VF_GOPSize+i] = reinterpret_cast<unsigned char*>(malloc(in->VF_FrameSize));
+
+ in->VF_GOPSize = size;
+
+ File_Flag = GOPList[now]->file;
+ _lseeki64(Infile[GOPList[now]->file], GOPList[now]->position, SEEK_SET);
+ Initialize_Buffer();
+
+ while (Get_Hdr() && picture_coding_type!=I_TYPE);
+
+ Decode_Picture(0, dst, pitch);
+
+ while (Get_Hdr() && picture_coding_type==B_TYPE);
+
+ if (picture_structure!=FRAME_PICTURE)
+ {
+ Decode_Picture(0, dst, pitch);
+ Get_Hdr();
+ }
+
+ Decode_Picture(1, dst, pitch);
+
+ if (picture_structure!=FRAME_PICTURE)
+ {
+ Get_Hdr();
+ Decode_Picture(1, dst, pitch);
+ }
+
+ Copyodd(dst, GOPBuffer[0], pitch, 1);
+ Copyeven(dst, GOPBuffer[0], pitch, 1);
+
+ while (remain && Get_Hdr())
+ {
+ Decode_Picture(1, dst, pitch);
+
+ if (picture_structure!=FRAME_PICTURE)
+ {
+ Get_Hdr();
+ Decode_Picture(1, dst, pitch);
+ }
+
+ Copyodd(dst, GOPBuffer[ref - remain + 1], pitch, 1);
+ Copyeven(dst, GOPBuffer[ref - remain + 1], pitch, 1);
+
+ remain--;
+ }
+
+ if (!Full_Frame && ref>=(size-2))
+ {
+ Copyodd(dst, dstFrame, pitch, 1);
+ Copyeven(dst, dstFrame, pitch, 1);
+ }
+ }
+ else
+ {
+ remain = ref - in->VF_OldRef;
+
+ if (remain > 0)
+ {
+ in->VF_OldRef = ref;
+
+ while (remain && Get_Hdr())
+ {
+ Decode_Picture(1, dst, pitch);
+
+ if (picture_structure!=FRAME_PICTURE)
+ {
+ Get_Hdr();
+ Decode_Picture(1, dst, pitch);
+ }
+
+ Copyodd(dst, GOPBuffer[ref - remain + 1], pitch, 1);
+ Copyeven(dst, GOPBuffer[ref - remain + 1], pitch, 1);
+
+ remain--;
+ }
+
+ if (!Full_Frame && ref>=(size-2))
+ {
+ Copyodd(dst, dstFrame, pitch, 1);
+ Copyeven(dst, dstFrame, pitch, 1);
+ }
+ }
+ }
+
+ switch (fo)
+ {
+ case 0:
+ Copyodd(GOPBuffer[ref], dst, pitch, 0);
+ Copyeven(GOPBuffer[ref], dst, pitch, 0);
+ break;
+
+ case 1:
+ Copyodd(GOPBuffer[ref-1], dst, pitch, 0);
+ Copyeven(GOPBuffer[ref], dst, pitch, 0);
+ break;
+
+ case 2:
+ Copyodd(GOPBuffer[ref], dst, pitch, 0);
+ Copyeven(GOPBuffer[ref-1], dst, pitch, 0);
+ break;
+ }
+
+ in->VF_OldFrame = origin;
}
void CMPEG2Dec::Close()
{
- int i;
+ int i;
- for(i = 0; i < VF_GOPLimit; i++) free(GOPList[i]);
- for(i = 0; i < VF_FrameLimit; i++) free(FrameList[i]);
+ for(i = 0; i < VF_GOPLimit; i++) free(GOPList[i]);
+ for(i = 0; i < VF_FrameLimit; i++) free(FrameList[i]);
- if(VF_File != NULL)
- fclose(VF_File);
+ if (VF_File != NULL)
+ fclose(VF_File);
- while(VF_GOPSize)
- {
- VF_GOPSize--;
- free(GOPBuffer[VF_GOPSize]);
- }
+ while (VF_GOPSize)
+ {
+ VF_GOPSize--;
+ free(GOPBuffer[VF_GOPSize]);
+ }
- while(File_Limit)
- {
- File_Limit--;
- _close(Infile[File_Limit]);
- }
+ while (File_Limit)
+ {
+ File_Limit--;
+ _close(Infile[File_Limit]);
+ }
- for(i = 0; i < MAX_FILE_NUMBER; i++)
- delete [] Infilename[i];
+ for (i=0; i<MAX_FILE_NUMBER; i++)
+ delete [] Infilename[i];
- for(i = 0; i < 3; i++)
- {
- delete [] backward_reference_frame[i];
- delete [] forward_reference_frame[i];
- delete [] auxframe[i];
- }
+ for (i=0; i<3; i++)
+ {
+ delete [] backward_reference_frame[i];
+ delete [] forward_reference_frame[i];
+ delete [] auxframe[i];
+ }
- delete [] u422;
- delete [] v422;
- delete [] u444;
- delete [] v444;
- delete [] dstFrame;
+ delete [] u422;
+ delete [] v422;
+ delete [] u444;
+ delete [] v444;
+ delete [] dstFrame;
- if(Luminance_Flag)
- delete [] lum;
+ if(Luminance_Flag)
+ delete [] lum;
- for(i = 0; i < 8; i++)
- delete [] p_block[i];
+ for (i=0; i<8; i++)
+ delete [] p_block[i];
- delete [] p_fTempArray;
+ delete [] p_fTempArray;
- if(hLibrary)
- FreeLibrary(hLibrary);
+ if (hLibrary)
+ FreeLibrary(hLibrary);
}
void CMPEG2Dec::Copyodd(unsigned char *src, unsigned char *dst, int pitch, int forward)
{
- int i;
- int PWIDTH = forward ? (pitch << 1) : DSTBYTES2;
- int QWIDTH = forward ? DSTBYTES2 : (pitch << 1);
-
- for(i = 0; i<(Clip_Height >> 1); i++)
- {
- memcpy(dst, src, DSTBYTES);
- src += PWIDTH;
- dst += QWIDTH;
- }
+ int i;
+ int PWIDTH = forward ? (pitch<<1) : DSTBYTES2;
+ int QWIDTH = forward ? DSTBYTES2 : (pitch<<1);
+
+ for (i=0; i<(Clip_Height>>1); i++)
+ {
+ memcpy (dst, src, DSTBYTES);
+ src += PWIDTH;
+ dst += QWIDTH;
+ }
}
void CMPEG2Dec::Copyeven(unsigned char *src, unsigned char *dst, int pitch, int forward)
{
- int i;
- int PWIDTH = forward ? (pitch << 1) : DSTBYTES2;
- int QWIDTH = forward ? DSTBYTES2 : (pitch << 1);
- src += forward ? pitch : DSTBYTES;
- dst += forward ? DSTBYTES : pitch;
-
- for(i = 0; i<(Clip_Height >> 1); i++)
- {
- memcpy(dst, src, DSTBYTES);
- src += PWIDTH;
- dst += QWIDTH;
- }
+ int i;
+ int PWIDTH = forward ? (pitch<<1) : DSTBYTES2;
+ int QWIDTH = forward ? DSTBYTES2 : (pitch<<1);
+ src += forward ? pitch : DSTBYTES;
+ dst += forward ? DSTBYTES : pitch;
+
+ for (i=0; i<(Clip_Height>>1); i++)
+ {
+ memcpy (dst, src, DSTBYTES);
+ src += PWIDTH;
+ dst += QWIDTH;
+ }
}
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/simple_idct_mmx.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/simple_idct_mmx.c
index f6437ab00..e32b8f0b4 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/simple_idct_mmx.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/simple_idct_mmx.c
@@ -49,46 +49,45 @@
#define ROW_SHIFT 11
#define COL_SHIFT 20 // 6
-DECLARE_ASM_CONST(8, uint64_t, wm1010) = 0xFFFF0000FFFF0000ULL;
-DECLARE_ASM_CONST(8, uint64_t, d40000) = 0x0000000000040000ULL;
+DECLARE_ASM_CONST(8, uint64_t, wm1010)= 0xFFFF0000FFFF0000ULL;
+DECLARE_ASM_CONST(8, uint64_t, d40000)= 0x0000000000040000ULL;
-DECLARE_ALIGNED(8, static const int16_t, coeffs)[] =
-{
- 1 << (ROW_SHIFT - 1), 0, 1 << (ROW_SHIFT - 1), 0,
+DECLARE_ALIGNED(8, static const int16_t, coeffs)[]= {
+ 1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0,
// 1<<(COL_SHIFT-1), 0, 1<<(COL_SHIFT-1), 0,
// 0, 1<<(COL_SHIFT-1-16), 0, 1<<(COL_SHIFT-1-16),
- 1 << (ROW_SHIFT - 1), 1, 1 << (ROW_SHIFT - 1), 0,
- // the 1 = ((1<<(COL_SHIFT-1))/C4)<<ROW_SHIFT :)
+ 1<<(ROW_SHIFT-1), 1, 1<<(ROW_SHIFT-1), 0,
+ // the 1 = ((1<<(COL_SHIFT-1))/C4)<<ROW_SHIFT :)
// 0, 0, 0, 0,
// 0, 0, 0, 0,
- C4, C4, C4, C4,
- C4, -C4, C4, -C4,
+ C4, C4, C4, C4,
+ C4, -C4, C4, -C4,
- C2, C6, C2, C6,
- C6, -C2, C6, -C2,
+ C2, C6, C2, C6,
+ C6, -C2, C6, -C2,
- C1, C3, C1, C3,
- C5, C7, C5, C7,
+ C1, C3, C1, C3,
+ C5, C7, C5, C7,
- C3, -C7, C3, -C7,
- -C1, -C5, -C1, -C5,
+ C3, -C7, C3, -C7,
+-C1, -C5, -C1, -C5,
- C5, -C1, C5, -C1,
- C7, C3, C7, C3,
+ C5, -C1, C5, -C1,
+ C7, C3, C7, C3,
- C7, -C5, C7, -C5,
- C3, -C1, C3, -C1
+ C7, -C5, C7, -C5,
+ C3, -C1, C3, -C1
};
#if 0
static void unused_var_killer(void)
{
- int a = wm1010 + d40000;
- temp[0] = a;
+ int a= wm1010 + d40000;
+ temp[0]=a;
}
-static void inline idctCol(int16_t * col, int16_t *input)
+static void inline idctCol (int16_t * col, int16_t *input)
{
#undef C0
#undef C1
@@ -98,78 +97,107 @@ static void inline idctCol(int16_t * col, int16_t *input)
#undef C5
#undef C6
#undef C7
- int a0, a1, a2, a3, b0, b1, b2, b3;
- const int C0 = 23170; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C1 = 22725; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C2 = 21407; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C3 = 19266; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C4 = 16383; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C5 = 12873; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C6 = 8867; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C7 = 4520; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- /*
- if( !(col[8*1] | col[8*2] |col[8*3] |col[8*4] |col[8*5] |col[8*6] | col[8*7])) {
- col[8*0] = col[8*1] = col[8*2] = col[8*3] = col[8*4] =
- col[8*5] = col[8*6] = col[8*7] = col[8*0]<<3;
- return;
- }*/
-
- col[8*0] = input[8*0 + 0];
- col[8*1] = input[8*2 + 0];
- col[8*2] = input[8*0 + 1];
- col[8*3] = input[8*2 + 1];
- col[8*4] = input[8*4 + 0];
- col[8*5] = input[8*6 + 0];
- col[8*6] = input[8*4 + 1];
- col[8*7] = input[8*6 + 1];
-
- a0 = C4 * col[8*0] + C2 * col[8*2] + C4 * col[8*4] + C6 * col[8*6] + (1 << (COL_SHIFT - 1));
- a1 = C4 * col[8*0] + C6 * col[8*2] - C4 * col[8*4] - C2 * col[8*6] + (1 << (COL_SHIFT - 1));
- a2 = C4 * col[8*0] - C6 * col[8*2] - C4 * col[8*4] + C2 * col[8*6] + (1 << (COL_SHIFT - 1));
- a3 = C4 * col[8*0] - C2 * col[8*2] + C4 * col[8*4] - C6 * col[8*6] + (1 << (COL_SHIFT - 1));
-
- b0 = C1 * col[8*1] + C3 * col[8*3] + C5 * col[8*5] + C7 * col[8*7];
- b1 = C3 * col[8*1] - C7 * col[8*3] - C1 * col[8*5] - C5 * col[8*7];
- b2 = C5 * col[8*1] - C1 * col[8*3] + C7 * col[8*5] + C3 * col[8*7];
- b3 = C7 * col[8*1] - C5 * col[8*3] + C3 * col[8*5] - C1 * col[8*7];
-
- col[8*0] = (a0 + b0) >> COL_SHIFT;
- col[8*1] = (a1 + b1) >> COL_SHIFT;
- col[8*2] = (a2 + b2) >> COL_SHIFT;
- col[8*3] = (a3 + b3) >> COL_SHIFT;
- col[8*4] = (a3 - b3) >> COL_SHIFT;
- col[8*5] = (a2 - b2) >> COL_SHIFT;
- col[8*6] = (a1 - b1) >> COL_SHIFT;
- col[8*7] = (a0 - b0) >> COL_SHIFT;
+ int a0, a1, a2, a3, b0, b1, b2, b3;
+ const int C0 = 23170; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C1 = 22725; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C2 = 21407; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C3 = 19266; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C4 = 16383; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C5 = 12873; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C6 = 8867; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C7 = 4520; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+/*
+ if( !(col[8*1] | col[8*2] |col[8*3] |col[8*4] |col[8*5] |col[8*6] | col[8*7])) {
+ col[8*0] = col[8*1] = col[8*2] = col[8*3] = col[8*4] =
+ col[8*5] = col[8*6] = col[8*7] = col[8*0]<<3;
+ return;
+ }*/
+
+col[8*0] = input[8*0 + 0];
+col[8*1] = input[8*2 + 0];
+col[8*2] = input[8*0 + 1];
+col[8*3] = input[8*2 + 1];
+col[8*4] = input[8*4 + 0];
+col[8*5] = input[8*6 + 0];
+col[8*6] = input[8*4 + 1];
+col[8*7] = input[8*6 + 1];
+
+ a0 = C4*col[8*0] + C2*col[8*2] + C4*col[8*4] + C6*col[8*6] + (1<<(COL_SHIFT-1));
+ a1 = C4*col[8*0] + C6*col[8*2] - C4*col[8*4] - C2*col[8*6] + (1<<(COL_SHIFT-1));
+ a2 = C4*col[8*0] - C6*col[8*2] - C4*col[8*4] + C2*col[8*6] + (1<<(COL_SHIFT-1));
+ a3 = C4*col[8*0] - C2*col[8*2] + C4*col[8*4] - C6*col[8*6] + (1<<(COL_SHIFT-1));
+
+ b0 = C1*col[8*1] + C3*col[8*3] + C5*col[8*5] + C7*col[8*7];
+ b1 = C3*col[8*1] - C7*col[8*3] - C1*col[8*5] - C5*col[8*7];
+ b2 = C5*col[8*1] - C1*col[8*3] + C7*col[8*5] + C3*col[8*7];
+ b3 = C7*col[8*1] - C5*col[8*3] + C3*col[8*5] - C1*col[8*7];
+
+ col[8*0] = (a0 + b0) >> COL_SHIFT;
+ col[8*1] = (a1 + b1) >> COL_SHIFT;
+ col[8*2] = (a2 + b2) >> COL_SHIFT;
+ col[8*3] = (a3 + b3) >> COL_SHIFT;
+ col[8*4] = (a3 - b3) >> COL_SHIFT;
+ col[8*5] = (a2 - b2) >> COL_SHIFT;
+ col[8*6] = (a1 - b1) >> COL_SHIFT;
+ col[8*7] = (a0 - b0) >> COL_SHIFT;
}
-static void inline idctRow(int16_t * output, int16_t * input)
+static void inline idctRow (int16_t * output, int16_t * input)
{
- int16_t row[8];
-
- int a0, a1, a2, a3, b0, b1, b2, b3;
- const int C0 = 23170; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C1 = 22725; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C2 = 21407; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C3 = 19266; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C4 = 16383; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C5 = 12873; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C6 = 8867; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
- const int C7 = 4520; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-
- row[0] = input[0];
- row[2] = input[1];
- row[4] = input[4];
- row[6] = input[5];
- row[1] = input[8];
- row[3] = input[9];
- row[5] = input[12];
- row[7] = input[13];
-
- if(!(row[1] | row[2] | row[3] | row[4] | row[5] | row[6] | row[7]))
- {
- row[0] = row[1] = row[2] = row[3] = row[4] =
- row[5] = row[6] = row[7] = row[0] << 3;
+ int16_t row[8];
+
+ int a0, a1, a2, a3, b0, b1, b2, b3;
+ const int C0 = 23170; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C1 = 22725; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C2 = 21407; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C3 = 19266; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C4 = 16383; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C5 = 12873; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C6 = 8867; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+ const int C7 = 4520; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+
+row[0] = input[0];
+row[2] = input[1];
+row[4] = input[4];
+row[6] = input[5];
+row[1] = input[8];
+row[3] = input[9];
+row[5] = input[12];
+row[7] = input[13];
+
+ if( !(row[1] | row[2] |row[3] |row[4] |row[5] |row[6] | row[7]) ) {
+ row[0] = row[1] = row[2] = row[3] = row[4] =
+ row[5] = row[6] = row[7] = row[0]<<3;
+ output[0] = row[0];
+ output[2] = row[1];
+ output[4] = row[2];
+ output[6] = row[3];
+ output[8] = row[4];
+ output[10] = row[5];
+ output[12] = row[6];
+ output[14] = row[7];
+ return;
+ }
+
+ a0 = C4*row[0] + C2*row[2] + C4*row[4] + C6*row[6] + (1<<(ROW_SHIFT-1));
+ a1 = C4*row[0] + C6*row[2] - C4*row[4] - C2*row[6] + (1<<(ROW_SHIFT-1));
+ a2 = C4*row[0] - C6*row[2] - C4*row[4] + C2*row[6] + (1<<(ROW_SHIFT-1));
+ a3 = C4*row[0] - C2*row[2] + C4*row[4] - C6*row[6] + (1<<(ROW_SHIFT-1));
+
+ b0 = C1*row[1] + C3*row[3] + C5*row[5] + C7*row[7];
+ b1 = C3*row[1] - C7*row[3] - C1*row[5] - C5*row[7];
+ b2 = C5*row[1] - C1*row[3] + C7*row[5] + C3*row[7];
+ b3 = C7*row[1] - C5*row[3] + C3*row[5] - C1*row[7];
+
+ row[0] = (a0 + b0) >> ROW_SHIFT;
+ row[1] = (a1 + b1) >> ROW_SHIFT;
+ row[2] = (a2 + b2) >> ROW_SHIFT;
+ row[3] = (a3 + b3) >> ROW_SHIFT;
+ row[4] = (a3 - b3) >> ROW_SHIFT;
+ row[5] = (a2 - b2) >> ROW_SHIFT;
+ row[6] = (a1 - b1) >> ROW_SHIFT;
+ row[7] = (a0 - b0) >> ROW_SHIFT;
+
output[0] = row[0];
output[2] = row[1];
output[4] = row[2];
@@ -178,45 +206,15 @@ static void inline idctRow(int16_t * output, int16_t * input)
output[10] = row[5];
output[12] = row[6];
output[14] = row[7];
- return;
- }
-
- a0 = C4 * row[0] + C2 * row[2] + C4 * row[4] + C6 * row[6] + (1 << (ROW_SHIFT - 1));
- a1 = C4 * row[0] + C6 * row[2] - C4 * row[4] - C2 * row[6] + (1 << (ROW_SHIFT - 1));
- a2 = C4 * row[0] - C6 * row[2] - C4 * row[4] + C2 * row[6] + (1 << (ROW_SHIFT - 1));
- a3 = C4 * row[0] - C2 * row[2] + C4 * row[4] - C6 * row[6] + (1 << (ROW_SHIFT - 1));
-
- b0 = C1 * row[1] + C3 * row[3] + C5 * row[5] + C7 * row[7];
- b1 = C3 * row[1] - C7 * row[3] - C1 * row[5] - C5 * row[7];
- b2 = C5 * row[1] - C1 * row[3] + C7 * row[5] + C3 * row[7];
- b3 = C7 * row[1] - C5 * row[3] + C3 * row[5] - C1 * row[7];
-
- row[0] = (a0 + b0) >> ROW_SHIFT;
- row[1] = (a1 + b1) >> ROW_SHIFT;
- row[2] = (a2 + b2) >> ROW_SHIFT;
- row[3] = (a3 + b3) >> ROW_SHIFT;
- row[4] = (a3 - b3) >> ROW_SHIFT;
- row[5] = (a2 - b2) >> ROW_SHIFT;
- row[6] = (a1 - b1) >> ROW_SHIFT;
- row[7] = (a0 - b0) >> ROW_SHIFT;
-
- output[0] = row[0];
- output[2] = row[1];
- output[4] = row[2];
- output[6] = row[3];
- output[8] = row[4];
- output[10] = row[5];
- output[12] = row[6];
- output[14] = row[7];
}
#endif
static inline void idct(int16_t *block)
{
- DECLARE_ALIGNED(8, int64_t, align_tmp)[16];
- int16_t * const temp = (int16_t*)align_tmp;
+ DECLARE_ALIGNED(8, int64_t, align_tmp)[16];
+ int16_t * const temp= (int16_t*)align_tmp;
- __asm__ volatile(
+ __asm__ volatile(
#if 0 //Alternative, simpler variant
#define ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
@@ -286,7 +284,7 @@ static inline void idct(int16_t *block)
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm0, %%mm4 \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3 */\
"movq %%mm4, 16+" #dst " \n\t"\
-
+
#define COL_IDCT(src0, src4, src1, src5, dst, shift) \
"movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
"movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
@@ -360,7 +358,7 @@ static inline void idct(int16_t *block)
"movd %%mm6, 48+" #dst " \n\t"\
"movd %%mm4, 64+" #dst " \n\t"\
"movd %%mm5, 80+" #dst " \n\t"\
-
+
#define DC_COND_ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
@@ -452,21 +450,21 @@ static inline void idct(int16_t *block)
//IDCT( src0, src4, src1, src5, dst, rounder, shift)
- ROW_IDCT((%0), 8(%0), 16(%0), 24(%0), 0(%1), paddd 8(%2), 11)
- /*ROW_IDCT( 32(%0), 40(%0), 48(%0), 56(%0), 32(%1), paddd (%2), 11)
- ROW_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1), paddd (%2), 11)
- ROW_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1), paddd (%2), 11)*/
+ROW_IDCT( (%0), 8(%0), 16(%0), 24(%0), 0(%1),paddd 8(%2), 11)
+/*ROW_IDCT( 32(%0), 40(%0), 48(%0), 56(%0), 32(%1), paddd (%2), 11)
+ROW_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1), paddd (%2), 11)
+ROW_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1), paddd (%2), 11)*/
- DC_COND_ROW_IDCT(32(%0), 40(%0), 48(%0), 56(%0), 32(%1), paddd(%2), 11)
- DC_COND_ROW_IDCT(64(%0), 72(%0), 80(%0), 88(%0), 64(%1), paddd(%2), 11)
- DC_COND_ROW_IDCT(96(%0), 104(%0), 112(%0), 120(%0), 96(%1), paddd(%2), 11)
+DC_COND_ROW_IDCT( 32(%0), 40(%0), 48(%0), 56(%0), 32(%1),paddd (%2), 11)
+DC_COND_ROW_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11)
+DC_COND_ROW_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11)
//IDCT( src0, src4, src1, src5, dst, shift)
- COL_IDCT((%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
- COL_IDCT(8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
- COL_IDCT(16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
- COL_IDCT(24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
+COL_IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
+COL_IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
+COL_IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
+COL_IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
#else
@@ -633,7 +631,7 @@ static inline void idct(int16_t *block)
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm0, %%mm4 \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3 */\
"movq %%mm4, 16+" #dst " \n\t"\
-
+
#define ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
"movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
@@ -701,12 +699,12 @@ static inline void idct(int16_t *block)
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm0, %%mm4 \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3 */\
"movq %%mm4, 16+" #dst " \n\t"\
-
+
//IDCT( src0, src4, src1, src5, dst, rounder, shift)
- DC_COND_IDCT(0(%0), 8(%0), 16(%0), 24(%0), 0(%1), paddd 8(%2), 11)
- Z_COND_IDCT(32(%0), 40(%0), 48(%0), 56(%0), 32(%1), paddd(%2), 11, 4f)
- Z_COND_IDCT(64(%0), 72(%0), 80(%0), 88(%0), 64(%1), paddd(%2), 11, 2f)
- Z_COND_IDCT(96(%0), 104(%0), 112(%0), 120(%0), 96(%1), paddd(%2), 11, 1f)
+DC_COND_IDCT( 0(%0), 8(%0), 16(%0), 24(%0), 0(%1),paddd 8(%2), 11)
+Z_COND_IDCT( 32(%0), 40(%0), 48(%0), 56(%0), 32(%1),paddd (%2), 11, 4f)
+Z_COND_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11, 2f)
+Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 1f)
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, shift) \
@@ -785,16 +783,16 @@ static inline void idct(int16_t *block)
//IDCT( src0, src4, src1, src5, dst, shift)
- IDCT((%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
- IDCT(8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
- IDCT(16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
- IDCT(24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
+IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
+IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
+IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
+IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
"#" ASMALIGN(4) \
"4: \n\t"
- Z_COND_IDCT(64(%0), 72(%0), 80(%0), 88(%0), 64(%1), paddd(%2), 11, 6f)
- Z_COND_IDCT(96(%0), 104(%0), 112(%0), 120(%0), 96(%1), paddd(%2), 11, 5f)
+Z_COND_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11, 6f)
+Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 5f)
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, shift) \
@@ -860,15 +858,15 @@ static inline void idct(int16_t *block)
"movd %%mm5, 80+" #dst " \n\t"
//IDCT( src0, src4, src1, src5, dst, shift)
- IDCT((%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
- IDCT(8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
- IDCT(16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
- IDCT(24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
+IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
+IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
+IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
+IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
"#" ASMALIGN(4) \
"6: \n\t"
- Z_COND_IDCT(96(%0), 104(%0), 112(%0), 120(%0), 96(%1), paddd(%2), 11, 7f)
+Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 7f)
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, shift) \
@@ -926,15 +924,15 @@ static inline void idct(int16_t *block)
//IDCT( src0, src4, src1, src5, dst, shift)
- IDCT((%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
- IDCT(8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
- IDCT(16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
- IDCT(24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
+IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
+IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
+IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
+IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
"#" ASMALIGN(4) \
"2: \n\t"
- Z_COND_IDCT(96(%0), 104(%0), 112(%0), 120(%0), 96(%1), paddd(%2), 11, 3f)
+Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 3f)
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, shift) \
@@ -1003,10 +1001,10 @@ static inline void idct(int16_t *block)
"movd %%mm5, 80+" #dst " \n\t"
//IDCT( src0, src4, src1, src5, dst, shift)
- IDCT((%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
- IDCT(8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
- IDCT(16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
- IDCT(24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
+IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
+IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
+IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
+IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
"#" ASMALIGN(4) \
@@ -1067,10 +1065,10 @@ static inline void idct(int16_t *block)
//IDCT( src0, src4, src1, src5, dst, shift)
- IDCT((%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
- IDCT(8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
- IDCT(16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
- IDCT(24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
+IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
+IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
+IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
+IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
"#" ASMALIGN(4) \
@@ -1131,9 +1129,9 @@ static inline void idct(int16_t *block)
//IDCT( src0, src4, src1, src5, dst, shift)
- IDCT(0(%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
+IDCT( 0(%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
//IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
- IDCT(16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
+IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
//IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
@@ -1205,10 +1203,10 @@ static inline void idct(int16_t *block)
//IDCT( src0, src4, src1, src5, dst, shift)
- IDCT((%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
- IDCT(8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
- IDCT(16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
- IDCT(24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
+IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
+IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
+IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
+IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
@@ -1243,40 +1241,40 @@ static inline void idct(int16_t *block)
"movq %%mm0, 80+" #dst " \n\t"
//IDCT( src0, src4, src1, src5, dst, shift)
- IDCT(0(%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
+IDCT( 0(%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
//IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
- IDCT(16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
+IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
//IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
#endif
- /*
- Input
- 00 40 04 44 20 60 24 64
- 10 30 14 34 50 70 54 74
- 01 41 03 43 21 61 23 63
- 11 31 13 33 51 71 53 73
- 02 42 06 46 22 62 26 66
- 12 32 16 36 52 72 56 76
- 05 45 07 47 25 65 27 67
- 15 35 17 37 55 75 57 77
-
- Temp
- 00 04 10 14 20 24 30 34
- 40 44 50 54 60 64 70 74
- 01 03 11 13 21 23 31 33
- 41 43 51 53 61 63 71 73
- 02 06 12 16 22 26 32 36
- 42 46 52 56 62 66 72 76
- 05 07 15 17 25 27 35 37
- 45 47 55 57 65 67 75 77
- */
-
- "9: \n\t"
- :: "r"(block), "r"(temp), "r"(coeffs)
- : "%eax"
- );
+/*
+Input
+ 00 40 04 44 20 60 24 64
+ 10 30 14 34 50 70 54 74
+ 01 41 03 43 21 61 23 63
+ 11 31 13 33 51 71 53 73
+ 02 42 06 46 22 62 26 66
+ 12 32 16 36 52 72 56 76
+ 05 45 07 47 25 65 27 67
+ 15 35 17 37 55 75 57 77
+
+Temp
+ 00 04 10 14 20 24 30 34
+ 40 44 50 54 60 64 70 74
+ 01 03 11 13 21 23 31 33
+ 41 43 51 53 61 63 71 73
+ 02 06 12 16 22 26 32 36
+ 42 46 52 56 62 66 72 76
+ 05 07 15 17 25 27 35 37
+ 45 47 55 57 65 67 75 77
+*/
+
+"9: \n\t"
+ :: "r" (block), "r" (temp), "r" (coeffs)
+ : "%eax"
+ );
}
void ff_simple_idct_mmx(int16_t *block)
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libswscale/swscale_template.c b/src/filters/transform/MPCVideoDec/ffmpeg/libswscale/swscale_template.c
index 635c3ab79..ca8bcc475 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libswscale/swscale_template.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libswscale/swscale_template.c
@@ -20,7 +20,7 @@
* The C code (not assembly, MMX, ...) of this file can be used
* under the LGPL license.
*/
-
+
/*
* Modified to support multi-thread related features
* by Haruhiko Yamagata <h.yamagata@nifty.com> in 2006.
@@ -236,7 +236,7 @@
"paddw %%mm5, %%mm7 \n\t"\
"test %%"REG_S", %%"REG_S" \n\t"\
" jnz 2b \n\t"\
-
+
#define YSCALEYUV2PACKEDX_END\
:: "r" (&c->redDither), \
"m" (dummy), "m" (dummy), "m" (dummy),\
@@ -337,7 +337,7 @@
"paddw %%mm0, %%mm7 \n\t"\
"movq "U_TEMP"(%0), %%mm3 \n\t"\
"movq "V_TEMP"(%0), %%mm4 \n\t"\
-
+
#define YSCALEYUV2RGBX \
"psubw "U_OFFSET"(%0), %%mm3 \n\t" /* (U-128)8*/\
"psubw "V_OFFSET"(%0), %%mm4 \n\t" /* (V-128)8*/\
@@ -410,7 +410,7 @@
"psraw $7, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
"paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
"paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
-
+
#define YSCALEYUV2PACKED(index, c) REAL_YSCALEYUV2PACKED(index, c)
#define REAL_YSCALEYUV2RGB(index, c) \
@@ -491,7 +491,7 @@
"movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
"psraw $7, %%mm1 \n\t" \
"psraw $7, %%mm7 \n\t" \
-
+
#define YSCALEYUV2PACKED1(index, c) REAL_YSCALEYUV2PACKED1(index, c)
#define REAL_YSCALEYUV2RGB1(index, c) \
@@ -881,115 +881,108 @@
static inline void RENAME(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
- int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
- uint8_t *dest, uint8_t *uDest, uint8_t *vDest, long dstW0, long chrDstW0)
+ int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
+ uint8_t *dest, uint8_t *uDest, uint8_t *vDest, long dstW0, long chrDstW0)
{
- const stride_t dstW = dstW0;
- const stride_t chrDstW = chrDstW0;
+ const stride_t dstW = dstW0;
+ const stride_t chrDstW = chrDstW0;
#if HAVE_MMX
- if(c->params.subsampling & SWS_ACCURATE_RND)
- {
- if(uDest)
- {
- YSCALEYUV2YV12X_ACCURATE(0, CHR_MMX_FILTER_OFFSET, uDest, chrDstW)
- YSCALEYUV2YV12X_ACCURATE(4096, CHR_MMX_FILTER_OFFSET, vDest, chrDstW)
- }
+ if(c->params.subsampling & SWS_ACCURATE_RND){
+ if(uDest){
+ YSCALEYUV2YV12X_ACCURATE( 0, CHR_MMX_FILTER_OFFSET, uDest, chrDstW)
+ YSCALEYUV2YV12X_ACCURATE(4096, CHR_MMX_FILTER_OFFSET, vDest, chrDstW)
+ }
- YSCALEYUV2YV12X_ACCURATE(0, LUM_MMX_FILTER_OFFSET, dest, dstW)
- }
- else
- {
- if(uDest)
- {
- YSCALEYUV2YV12X(0, CHR_MMX_FILTER_OFFSET, uDest, chrDstW)
- YSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET, vDest, chrDstW)
- }
+ YSCALEYUV2YV12X_ACCURATE(0, LUM_MMX_FILTER_OFFSET, dest, dstW)
+ }else{
+ if(uDest){
+ YSCALEYUV2YV12X( 0, CHR_MMX_FILTER_OFFSET, uDest, chrDstW)
+ YSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET, vDest, chrDstW)
+ }
- YSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET, dest, dstW)
- }
+ YSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET, dest, dstW)
+ }
#else
#ifdef HAVE_ALTIVEC
- yuv2yuvX_altivec_real(lumFilter, lumSrc, lumFilterSize,
- chrFilter, chrSrc, chrFilterSize,
- dest, uDest, vDest, dstW, chrDstW);
+yuv2yuvX_altivec_real(lumFilter, lumSrc, lumFilterSize,
+ chrFilter, chrSrc, chrFilterSize,
+ dest, uDest, vDest, dstW, chrDstW);
#else //HAVE_ALTIVEC
- yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
- chrFilter, chrSrc, chrFilterSize,
- dest, uDest, vDest, dstW, chrDstW);
+yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
+ chrFilter, chrSrc, chrFilterSize,
+ dest, uDest, vDest, dstW, chrDstW);
#endif //!HAVE_ALTIVEC
#endif
}
static inline void RENAME(yuv2nv12X)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
- int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
- uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, int dstFormat)
+ int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
+ uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, int dstFormat)
{
- yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize,
- chrFilter, chrSrc, chrFilterSize,
- dest, uDest, dstW, chrDstW, dstFormat);
+yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize,
+ chrFilter, chrSrc, chrFilterSize,
+ dest, uDest, dstW, chrDstW, dstFormat);
}
static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,
- uint8_t *dest, uint8_t *uDest, uint8_t *vDest, long dstW0, long chrDstW0)
+ uint8_t *dest, uint8_t *uDest, uint8_t *vDest, long dstW0, long chrDstW0)
{
- const stride_t dstW = dstW0;
- const stride_t chrDstW = chrDstW0;
+ const stride_t dstW = dstW0;
+ const stride_t chrDstW = chrDstW0;
#if HAVE_MMX
- if(uDest != NULL)
- {
- asm volatile(
- YSCALEYUV2YV121
- :: "r"(chrSrc + chrDstW), "r"(uDest + chrDstW),
- "g"(-chrDstW)
- : "%"REG_a
- );
-
- asm volatile(
- YSCALEYUV2YV121
- :: "r"(chrSrc + 2048 + chrDstW), "r"(vDest + chrDstW),
- "g"(-chrDstW)
- : "%"REG_a
- );
- }
-
- asm volatile(
- YSCALEYUV2YV121
- :: "r"(lumSrc + dstW), "r"(dest + dstW),
- "g"(-dstW)
- : "%"REG_a
- );
+ if(uDest != NULL)
+ {
+ asm volatile(
+ YSCALEYUV2YV121
+ :: "r" (chrSrc + chrDstW), "r" (uDest + chrDstW),
+ "g" (-chrDstW)
+ : "%"REG_a
+ );
+
+ asm volatile(
+ YSCALEYUV2YV121
+ :: "r" (chrSrc + 2048 + chrDstW), "r" (vDest + chrDstW),
+ "g" (-chrDstW)
+ : "%"REG_a
+ );
+ }
+
+ asm volatile(
+ YSCALEYUV2YV121
+ :: "r" (lumSrc + dstW), "r" (dest + dstW),
+ "g" (-dstW)
+ : "%"REG_a
+ );
#else
- int i;
- for(i = 0; i < dstW; i++)
- {
- int val = lumSrc[i] >> 7;
-
- if(val & 256)
- {
- if(val < 0) val = 0;
- else val = 255;
- }
-
- dest[i] = val;
- }
-
- if(uDest != NULL)
- for(i = 0; i < chrDstW; i++)
- {
- int u = chrSrc[i] >> 7;
- int v = chrSrc[i + 2048] >> 7;
-
- if((u | v) & 256)
- {
- if(u < 0) u = 0;
- else if(u > 255) u = 255;
- if(v < 0) v = 0;
- else if(v > 255) v = 255;
- }
-
- uDest[i] = u;
- vDest[i] = v;
- }
+ int i;
+ for(i=0; i<dstW; i++)
+ {
+ int val= lumSrc[i]>>7;
+
+ if(val&256){
+ if(val<0) val=0;
+ else val=255;
+ }
+
+ dest[i]= val;
+ }
+
+ if(uDest != NULL)
+ for(i=0; i<chrDstW; i++)
+ {
+ int u=chrSrc[i]>>7;
+ int v=chrSrc[i + 2048]>>7;
+
+ if((u|v)&256){
+ if(u<0) u=0;
+ else if (u>255) u=255;
+ if(v<0) v=0;
+ else if (v>255) v=255;
+ }
+
+ uDest[i]= u;
+ vDest[i]= v;
+ }
#endif
}
@@ -998,1573 +991,1562 @@ static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,
* vertical scale YV12 to RGB
*/
static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
- int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
- uint8_t *dest, long dstW, long dstY)
+ int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
+ uint8_t *dest, long dstW, long dstY)
{
- long dummy = 0;
+ long dummy=0;
#if HAVE_MMX
- if(c->params.subsampling & SWS_ACCURATE_RND)
- {
- switch(c->dstFormat)
- {
- case IMGFMT_BGR32:
- YSCALEYUV2PACKEDX_ACCURATE
- YSCALEYUV2RGBX
- WRITEBGR32( % 4, % 5, % % REGa)
-
- YSCALEYUV2PACKEDX_END
- return;
- case IMGFMT_BGR24:
- YSCALEYUV2PACKEDX_ACCURATE
- YSCALEYUV2RGBX
- "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" //FIXME optimize
- "add %4, %%"REG_b" \n\t"
- WRITEBGR24( % % REGb, % 5, % % REGa)
-
-
- :: "r"(&c->redDither),
- "m"(dummy), "m"(dummy), "m"(dummy),
- "r"(dest), "m"(dstW)
- : "%"REG_a, "%"REG_b, "%"REG_d, "%"REG_S //FIXME ebx
- );
- return;
- case IMGFMT_BGR15:
- YSCALEYUV2PACKEDX_ACCURATE
- YSCALEYUV2RGBX
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+ if(c->params.subsampling & SWS_ACCURATE_RND){
+ switch(c->dstFormat){
+ case IMGFMT_BGR32:
+ YSCALEYUV2PACKEDX_ACCURATE
+ YSCALEYUV2RGBX
+ WRITEBGR32(%4, %5, %%REGa)
+
+ YSCALEYUV2PACKEDX_END
+ return;
+ case IMGFMT_BGR24:
+ YSCALEYUV2PACKEDX_ACCURATE
+ YSCALEYUV2RGBX
+ "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" //FIXME optimize
+ "add %4, %%"REG_b" \n\t"
+ WRITEBGR24(%%REGb, %5, %%REGa)
+
+
+ :: "r" (&c->redDither),
+ "m" (dummy), "m" (dummy), "m" (dummy),
+ "r" (dest), "m" (dstW)
+ : "%"REG_a, "%"REG_b, "%"REG_d, "%"REG_S //FIXME ebx
+ );
+ return;
+ case IMGFMT_BGR15:
+ YSCALEYUV2PACKEDX_ACCURATE
+ YSCALEYUV2RGBX
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
- "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
- "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+ "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
- WRITEBGR15( % 4, % 5, % % REGa)
- YSCALEYUV2PACKEDX_END
- return;
+ WRITEBGR15(%4, %5, %%REGa)
+ YSCALEYUV2PACKEDX_END
+ return;
case IMGFMT_BGR16:
- YSCALEYUV2PACKEDX_ACCURATE
- YSCALEYUV2RGBX
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+ YSCALEYUV2PACKEDX_ACCURATE
+ YSCALEYUV2RGBX
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
- "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
- "paddusb "MANGLE(g6Dither)", %%mm4\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+ "paddusb "MANGLE(g6Dither)", %%mm4\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
- WRITEBGR16( % 4, % 5, % % REGa)
- YSCALEYUV2PACKEDX_END
+ WRITEBGR16(%4, %5, %%REGa)
+ YSCALEYUV2PACKEDX_END
return;
- case IMGFMT_YUY2:
- YSCALEYUV2PACKEDX_ACCURATE
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-
- "psraw $3, %%mm3 \n\t"
- "psraw $3, %%mm4 \n\t"
- "psraw $3, %%mm1 \n\t"
- "psraw $3, %%mm7 \n\t"
- WRITEYUY2( % 4, % 5, % % REGa)
- YSCALEYUV2PACKEDX_END
- return;
- }
- }
- else
-{
- switch(c->dstFormat)
- {
- case IMGFMT_BGR32:
- YSCALEYUV2PACKEDX
- YSCALEYUV2RGBX
- WRITEBGR32( % 4, % 5, % % REGa)
- YSCALEYUV2PACKEDX_END
- return;
- case IMGFMT_BGR24:
- YSCALEYUV2PACKEDX
- YSCALEYUV2RGBX
- "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" //FIXME optimize
- "add %4, %%"REG_b" \n\t"
- WRITEBGR24( % % REGb, % 5, % % REGa)
-
- :: "r"(&c->redDither),
- "m"(dummy), "m"(dummy), "m"(dummy),
- "r"(dest), "m"(dstW)
- : "%"REG_a, "%"REG_b, "%"REG_d, "%"REG_S //FIXME ebx
- );
- return;
- case IMGFMT_BGR15:
- YSCALEYUV2PACKEDX
- YSCALEYUV2RGBX
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+ case IMGFMT_YUY2:
+ YSCALEYUV2PACKEDX_ACCURATE
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+
+ "psraw $3, %%mm3 \n\t"
+ "psraw $3, %%mm4 \n\t"
+ "psraw $3, %%mm1 \n\t"
+ "psraw $3, %%mm7 \n\t"
+ WRITEYUY2(%4, %5, %%REGa)
+ YSCALEYUV2PACKEDX_END
+ return;
+ }
+ }else{
+ switch(c->dstFormat)
+ {
+ case IMGFMT_BGR32:
+ YSCALEYUV2PACKEDX
+ YSCALEYUV2RGBX
+ WRITEBGR32(%4, %5, %%REGa)
+ YSCALEYUV2PACKEDX_END
+ return;
+ case IMGFMT_BGR24:
+ YSCALEYUV2PACKEDX
+ YSCALEYUV2RGBX
+ "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" //FIXME optimize
+ "add %4, %%"REG_b" \n\t"
+ WRITEBGR24(%%REGb, %5, %%REGa)
+
+ :: "r" (&c->redDither),
+ "m" (dummy), "m" (dummy), "m" (dummy),
+ "r" (dest), "m" (dstW)
+ : "%"REG_a, "%"REG_b, "%"REG_d, "%"REG_S //FIXME ebx
+ );
+ return;
+ case IMGFMT_BGR15:
+ YSCALEYUV2PACKEDX
+ YSCALEYUV2RGBX
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
- "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
- "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+ "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
- WRITEBGR15( % 4, % 5, % % REGa)
- YSCALEYUV2PACKEDX_END
- return;
- case IMGFMT_BGR16:
- YSCALEYUV2PACKEDX
- YSCALEYUV2RGBX
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+ WRITEBGR15(%4, %5, %%REGa)
+ YSCALEYUV2PACKEDX_END
+ return;
+ case IMGFMT_BGR16:
+ YSCALEYUV2PACKEDX
+ YSCALEYUV2RGBX
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
- "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
- "paddusb "MANGLE(g6Dither)", %%mm4\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+ "paddusb "MANGLE(g6Dither)", %%mm4\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
- WRITEBGR16( % 4, % 5, % % REGa)
- YSCALEYUV2PACKEDX_END
- return;
- case IMGFMT_YUY2:
- YSCALEYUV2PACKEDX
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-
- "psraw $3, %%mm3 \n\t"
- "psraw $3, %%mm4 \n\t"
- "psraw $3, %%mm1 \n\t"
- "psraw $3, %%mm7 \n\t"
- WRITEYUY2( % 4, % 5, % % REGa)
- YSCALEYUV2PACKEDX_END
- return;
- }
+ WRITEBGR16(%4, %5, %%REGa)
+ YSCALEYUV2PACKEDX_END
+ return;
+ case IMGFMT_YUY2:
+ YSCALEYUV2PACKEDX
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+
+ "psraw $3, %%mm3 \n\t"
+ "psraw $3, %%mm4 \n\t"
+ "psraw $3, %%mm1 \n\t"
+ "psraw $3, %%mm7 \n\t"
+ WRITEYUY2(%4, %5, %%REGa)
+ YSCALEYUV2PACKEDX_END
+ return;
+ }
}
#endif
#ifdef HAVE_ALTIVEC
- /* The following list of supported dstFormat values should
- match what's found in the body of altivec_yuv2packedX() */
- if(c->dstFormat == IMGFMT_ABGR || c->dstFormat == IMGFMT_BGRA ||
- c->dstFormat == IMGFMT_BGR24 || c->dstFormat == IMGFMT_RGB24 ||
- c->dstFormat == IMGFMT_RGBA || c->dstFormat == IMGFMT_ARGB)
- altivec_yuv2packedX(c, lumFilter, lumSrc, lumFilterSize,
- chrFilter, chrSrc, chrFilterSize,
- dest, dstW, dstY);
- else
+ /* The following list of supported dstFormat values should
+ match what's found in the body of altivec_yuv2packedX() */
+ if(c->dstFormat==IMGFMT_ABGR || c->dstFormat==IMGFMT_BGRA ||
+ c->dstFormat==IMGFMT_BGR24 || c->dstFormat==IMGFMT_RGB24 ||
+ c->dstFormat==IMGFMT_RGBA || c->dstFormat==IMGFMT_ARGB)
+ altivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize,
+ chrFilter, chrSrc, chrFilterSize,
+ dest, dstW, dstY);
+ else
#endif
- yuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize,
- chrFilter, chrSrc, chrFilterSize,
- dest, dstW, dstY);
+ yuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize,
+ chrFilter, chrSrc, chrFilterSize,
+ dest, dstW, dstY);
}
/**
* vertical bilinear scale YV12 to RGB
*/
static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,
- uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
+ uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
{
- int yalpha1 = yalpha ^ 4095;
- int uvalpha1 = uvalpha ^ 4095;
- int i;
+ int yalpha1=yalpha^4095;
+ int uvalpha1=uvalpha^4095;
+ int i;
#if 0 //isn't used
- if(flags & SWS_FULL_CHR_H_INT)
- {
- switch(dstFormat)
- {
+ if(flags&SWS_FULL_CHR_H_INT)
+ {
+ switch(dstFormat)
+ {
#if HAVE_MMX
- case IMGFMT_BGR32:
- asm volatile(
+ case IMGFMT_BGR32:
+ asm volatile(
- FULL_YSCALEYUV2RGB
- "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG
- "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0
+FULL_YSCALEYUV2RGB
+ "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG
+ "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0
- "movq %%mm3, %%mm1 \n\t"
- "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0
- "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0
+ "movq %%mm3, %%mm1 \n\t"
+ "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0
+ "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0
- MOVNTQ(%%mm3, (%4, %%REGa, 4))
- MOVNTQ(%%mm1, 8(%4, %%REGa, 4))
+ MOVNTQ(%%mm3, (%4, %%REGa, 4))
+ MOVNTQ(%%mm1, 8(%4, %%REGa, 4))
- "add $4, %%"REG_a" \n\t"
- "cmp %5, %%"REG_a" \n\t"
- " jb 1b \n\t"
+ "add $4, %%"REG_a" \n\t"
+ "cmp %5, %%"REG_a" \n\t"
+ " jb 1b \n\t"
- :: "r"(buf0), "r"(buf1), "r"(uvbuf0), "r"(uvbuf1), "r"(dest), "m"((long)dstW),
- "m"(yalpha1), "m"(uvalpha1)
- : "%"REG_a
- );
- break;
- case IMGFMT_BGR24:
- asm volatile(
+ :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" ((long)dstW),
+ "m" (yalpha1), "m" (uvalpha1)
+ : "%"REG_a
+ );
+ break;
+ case IMGFMT_BGR24:
+ asm volatile(
- FULL_YSCALEYUV2RGB
+FULL_YSCALEYUV2RGB
- // lsb ... msb
- "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG
- "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0
+ // lsb ... msb
+ "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG
+ "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0
- "movq %%mm3, %%mm1 \n\t"
- "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0
- "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0
+ "movq %%mm3, %%mm1 \n\t"
+ "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0
+ "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0
- "movq %%mm3, %%mm2 \n\t" // BGR0BGR0
- "psrlq $8, %%mm3 \n\t" // GR0BGR00
- "pand "MANGLE(bm00000111)", %%mm2\n\t" // BGR00000
- "pand "MANGLE(bm11111000)", %%mm3\n\t" // 000BGR00
- "por %%mm2, %%mm3 \n\t" // BGRBGR00
- "movq %%mm1, %%mm2 \n\t"
- "psllq $48, %%mm1 \n\t" // 000000BG
- "por %%mm1, %%mm3 \n\t" // BGRBGRBG
+ "movq %%mm3, %%mm2 \n\t" // BGR0BGR0
+ "psrlq $8, %%mm3 \n\t" // GR0BGR00
+ "pand "MANGLE(bm00000111)", %%mm2\n\t" // BGR00000
+ "pand "MANGLE(bm11111000)", %%mm3\n\t" // 000BGR00
+ "por %%mm2, %%mm3 \n\t" // BGRBGR00
+ "movq %%mm1, %%mm2 \n\t"
+ "psllq $48, %%mm1 \n\t" // 000000BG
+ "por %%mm1, %%mm3 \n\t" // BGRBGRBG
- "movq %%mm2, %%mm1 \n\t" // BGR0BGR0
- "psrld $16, %%mm2 \n\t" // R000R000
- "psrlq $24, %%mm1 \n\t" // 0BGR0000
- "por %%mm2, %%mm1 \n\t" // RBGRR000
+ "movq %%mm2, %%mm1 \n\t" // BGR0BGR0
+ "psrld $16, %%mm2 \n\t" // R000R000
+ "psrlq $24, %%mm1 \n\t" // 0BGR0000
+ "por %%mm2, %%mm1 \n\t" // RBGRR000
- "mov %4, %%"REG_b" \n\t"
- "add %%"REG_a", %%"REG_b" \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "add %%"REG_a", %%"REG_b" \n\t"
#if HAVE_MMX2
- //FIXME Alignment
- "movntq %%mm3, (%%"REG_b", %%"REG_a", 2)\n\t"
- "movntq %%mm1, 8(%%"REG_b", %%"REG_a", 2)\n\t"
+ //FIXME Alignment
+ "movntq %%mm3, (%%"REG_b", %%"REG_a", 2)\n\t"
+ "movntq %%mm1, 8(%%"REG_b", %%"REG_a", 2)\n\t"
#else
- "movd %%mm3, (%%"REG_b", %%"REG_a", 2) \n\t"
- "psrlq $32, %%mm3 \n\t"
- "movd %%mm3, 4(%%"REG_b", %%"REG_a", 2) \n\t"
- "movd %%mm1, 8(%%"REG_b", %%"REG_a", 2) \n\t"
+ "movd %%mm3, (%%"REG_b", %%"REG_a", 2) \n\t"
+ "psrlq $32, %%mm3 \n\t"
+ "movd %%mm3, 4(%%"REG_b", %%"REG_a", 2) \n\t"
+ "movd %%mm1, 8(%%"REG_b", %%"REG_a", 2) \n\t"
#endif
- "add $4, %%"REG_a" \n\t"
- "cmp %5, %%"REG_a" \n\t"
- " jb 1b \n\t"
-
- :: "r"(buf0), "r"(buf1), "r"(uvbuf0), "r"(uvbuf1), "m"(dest), "m"(dstW),
- "m"(yalpha1), "m"(uvalpha1)
- : "%"REG_a, "%"REG_b
- );
- break;
- case IMGFMT_BGR15:
- asm volatile(
-
- FULL_YSCALEYUV2RGB
+ "add $4, %%"REG_a" \n\t"
+ "cmp %5, %%"REG_a" \n\t"
+ " jb 1b \n\t"
+
+ :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW),
+ "m" (yalpha1), "m" (uvalpha1)
+ : "%"REG_a, "%"REG_b
+ );
+ break;
+ case IMGFMT_BGR15:
+ asm volatile(
+
+FULL_YSCALEYUV2RGB
#ifdef DITHER1XBPP
- "paddusb "MANGLE(g5Dither)", %%mm1\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm0\n\t"
- "paddusb "MANGLE(b5Dither)", %%mm3\n\t"
+ "paddusb "MANGLE(g5Dither)", %%mm1\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm0\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm3\n\t"
#endif
- "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G
- "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B
- "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R
-
- "psrlw $3, %%mm3 \n\t"
- "psllw $2, %%mm1 \n\t"
- "psllw $7, %%mm0 \n\t"
- "pand "MANGLE(g15Mask)", %%mm1 \n\t"
- "pand "MANGLE(r15Mask)", %%mm0 \n\t"
-
- "por %%mm3, %%mm1 \n\t"
- "por %%mm1, %%mm0 \n\t"
-
- MOVNTQ(%%mm0, (%4, %%REGa, 2))
-
- "add $4, %%"REG_a" \n\t"
- "cmp %5, %%"REG_a" \n\t"
- " jb 1b \n\t"
-
- :: "r"(buf0), "r"(buf1), "r"(uvbuf0), "r"(uvbuf1), "r"(dest), "m"(dstW),
- "m"(yalpha1), "m"(uvalpha1)
- : "%"REG_a
- );
- break;
- case IMGFMT_BGR16:
- asm volatile(
-
- FULL_YSCALEYUV2RGB
+ "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G
+ "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B
+ "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R
+
+ "psrlw $3, %%mm3 \n\t"
+ "psllw $2, %%mm1 \n\t"
+ "psllw $7, %%mm0 \n\t"
+ "pand "MANGLE(g15Mask)", %%mm1 \n\t"
+ "pand "MANGLE(r15Mask)", %%mm0 \n\t"
+
+ "por %%mm3, %%mm1 \n\t"
+ "por %%mm1, %%mm0 \n\t"
+
+ MOVNTQ(%%mm0, (%4, %%REGa, 2))
+
+ "add $4, %%"REG_a" \n\t"
+ "cmp %5, %%"REG_a" \n\t"
+ " jb 1b \n\t"
+
+ :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
+ "m" (yalpha1), "m" (uvalpha1)
+ : "%"REG_a
+ );
+ break;
+ case IMGFMT_BGR16:
+ asm volatile(
+
+FULL_YSCALEYUV2RGB
#ifdef DITHER1XBPP
- "paddusb "MANGLE(g6Dither)", %%mm1\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm0\n\t"
- "paddusb "MANGLE(b5Dither)", %%mm3\n\t"
+ "paddusb "MANGLE(g6Dither)", %%mm1\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm0\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm3\n\t"
#endif
- "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G
- "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B
- "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R
-
- "psrlw $3, %%mm3 \n\t"
- "psllw $3, %%mm1 \n\t"
- "psllw $8, %%mm0 \n\t"
- "pand "MANGLE(g16Mask)", %%mm1 \n\t"
- "pand "MANGLE(r16Mask)", %%mm0 \n\t"
-
- "por %%mm3, %%mm1 \n\t"
- "por %%mm1, %%mm0 \n\t"
-
- MOVNTQ(%%mm0, (%4, %%REGa, 2))
-
- "add $4, %%"REG_a" \n\t"
- "cmp %5, %%"REG_a" \n\t"
- " jb 1b \n\t"
-
- :: "r"(buf0), "r"(buf1), "r"(uvbuf0), "r"(uvbuf1), "r"(dest), "m"(dstW),
- "m"(yalpha1), "m"(uvalpha1)
- : "%"REG_a
- );
- break;
+ "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G
+ "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B
+ "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R
+
+ "psrlw $3, %%mm3 \n\t"
+ "psllw $3, %%mm1 \n\t"
+ "psllw $8, %%mm0 \n\t"
+ "pand "MANGLE(g16Mask)", %%mm1 \n\t"
+ "pand "MANGLE(r16Mask)", %%mm0 \n\t"
+
+ "por %%mm3, %%mm1 \n\t"
+ "por %%mm1, %%mm0 \n\t"
+
+ MOVNTQ(%%mm0, (%4, %%REGa, 2))
+
+ "add $4, %%"REG_a" \n\t"
+ "cmp %5, %%"REG_a" \n\t"
+ " jb 1b \n\t"
+
+ :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
+ "m" (yalpha1), "m" (uvalpha1)
+ : "%"REG_a
+ );
+ break;
#endif
- case IMGFMT_RGB32:
+ case IMGFMT_RGB32:
#if !HAVE_MMX
- case IMGFMT_BGR32:
+ case IMGFMT_BGR32:
#endif
- if(dstFormat == IMGFMT_BGR32)
- {
- int i;
+ if(dstFormat==IMGFMT_BGR32)
+ {
+ int i;
#ifdef WORDS_BIGENDIAN
- dest++;
+ dest++;
#endif
- for(i = 0; i < dstW; i++)
- {
- // vertical linear interpolation && yuv2rgb in a single step:
- int Y = yuvtab_2568[((buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19)];
- int U = ((uvbuf0[i] * uvalpha1 + uvbuf1[i] * uvalpha) >> 19);
- int V = ((uvbuf0[i+2048] * uvalpha1 + uvbuf1[i+2048] * uvalpha) >> 19);
- dest[0] = clip_table[((Y + yuvtab_40cf[U]) >> 13)];
- dest[1] = clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >> 13)];
- dest[2] = clip_table[((Y + yuvtab_3343[V]) >> 13)];
- dest += 4;
- }
- }
- else if(dstFormat == IMGFMT_BGR24)
- {
- int i;
- for(i = 0; i < dstW; i++)
- {
- // vertical linear interpolation && yuv2rgb in a single step:
- int Y = yuvtab_2568[((buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19)];
- int U = ((uvbuf0[i] * uvalpha1 + uvbuf1[i] * uvalpha) >> 19);
- int V = ((uvbuf0[i+2048] * uvalpha1 + uvbuf1[i+2048] * uvalpha) >> 19);
- dest[0] = clip_table[((Y + yuvtab_40cf[U]) >> 13)];
- dest[1] = clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >> 13)];
- dest[2] = clip_table[((Y + yuvtab_3343[V]) >> 13)];
- dest += 3;
- }
- }
- else if(dstFormat == IMGFMT_BGR16)
- {
- int i;
- for(i = 0; i < dstW; i++)
- {
- // vertical linear interpolation && yuv2rgb in a single step:
- int Y = yuvtab_2568[((buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19)];
- int U = ((uvbuf0[i] * uvalpha1 + uvbuf1[i] * uvalpha) >> 19);
- int V = ((uvbuf0[i+2048] * uvalpha1 + uvbuf1[i+2048] * uvalpha) >> 19);
-
- ((uint16_t*)dest)[i] =
- clip_table16b[(Y + yuvtab_40cf[U]) >> 13] |
- clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >> 13] |
- clip_table16r[(Y + yuvtab_3343[V]) >> 13];
- }
- }
- else if(dstFormat == IMGFMT_BGR15)
- {
- int i;
- for(i = 0; i < dstW; i++)
- {
- // vertical linear interpolation && yuv2rgb in a single step:
- int Y = yuvtab_2568[((buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19)];
- int U = ((uvbuf0[i] * uvalpha1 + uvbuf1[i] * uvalpha) >> 19);
- int V = ((uvbuf0[i+2048] * uvalpha1 + uvbuf1[i+2048] * uvalpha) >> 19);
-
- ((uint16_t*)dest)[i] =
- clip_table15b[(Y + yuvtab_40cf[U]) >> 13] |
- clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >> 13] |
- clip_table15r[(Y + yuvtab_3343[V]) >> 13];
- }
- }
- }//FULL_UV_IPOL
- else
- {
+ for(i=0;i<dstW;i++){
+ // vertical linear interpolation && yuv2rgb in a single step:
+ int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
+ int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
+ int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
+ dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
+ dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
+ dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
+ dest+= 4;
+ }
+ }
+ else if(dstFormat==IMGFMT_BGR24)
+ {
+ int i;
+ for(i=0;i<dstW;i++){
+ // vertical linear interpolation && yuv2rgb in a single step:
+ int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
+ int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
+ int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
+ dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
+ dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
+ dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
+ dest+= 3;
+ }
+ }
+ else if(dstFormat==IMGFMT_BGR16)
+ {
+ int i;
+ for(i=0;i<dstW;i++){
+ // vertical linear interpolation && yuv2rgb in a single step:
+ int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
+ int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
+ int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
+
+ ((uint16_t*)dest)[i] =
+ clip_table16b[(Y + yuvtab_40cf[U]) >>13] |
+ clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
+ clip_table16r[(Y + yuvtab_3343[V]) >>13];
+ }
+ }
+ else if(dstFormat==IMGFMT_BGR15)
+ {
+ int i;
+ for(i=0;i<dstW;i++){
+ // vertical linear interpolation && yuv2rgb in a single step:
+ int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
+ int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
+ int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
+
+ ((uint16_t*)dest)[i] =
+ clip_table15b[(Y + yuvtab_40cf[U]) >>13] |
+ clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
+ clip_table15r[(Y + yuvtab_3343[V]) >>13];
+ }
+ }
+ }//FULL_UV_IPOL
+ else
+ {
#endif // if 0
#if HAVE_MMX
- switch(c->dstFormat)
- {
+ switch(c->dstFormat)
+ {
//Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
- case IMGFMT_BGR32:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB(%%REGBP, %5)
- WRITEBGR32(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_BGR24:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB(%%REGBP, %5)
- WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_BGR15:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB(%%REGBP, %5)
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+ case IMGFMT_BGR32:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB(%%REGBP, %5)
+ WRITEBGR32(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_BGR24:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB(%%REGBP, %5)
+ WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_BGR15:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB(%%REGBP, %5)
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
- "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
- "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+ "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
- WRITEBGR15(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_BGR16:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB(%%REGBP, %5)
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+ WRITEBGR15(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_BGR16:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB(%%REGBP, %5)
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
- "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
- "paddusb "MANGLE(g6Dither)", %%mm4\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+ "paddusb "MANGLE(g6Dither)", %%mm4\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
- WRITEBGR16(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_YUY2:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2PACKED(%%REGBP, %5)
- WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- default:
- break;
- }
+ WRITEBGR16(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_YUY2:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2PACKED(%%REGBP, %5)
+ WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ default: break;
+ }
#endif //HAVE_MMX
- YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C)
- }
+YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C)
+}
- /**
- * YV12 to RGB without scaling or interpolating
- */
- static inline void RENAME(yuv2packed1)(SwsContext * c, uint16_t * buf0, uint16_t * uvbuf0, uint16_t * uvbuf1,
- uint8_t * dest, int dstW, int uvalpha, int dstFormat, int flags, int y)
- {
- const int yalpha1 = 0;
- int i;
+/**
+ * YV12 to RGB without scaling or interpolating
+ */
+static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *uvbuf0, uint16_t *uvbuf1,
+ uint8_t *dest, int dstW, int uvalpha, int dstFormat, int flags, int y)
+{
+ const int yalpha1=0;
+ int i;
- uint16_t *buf1 = buf0; //FIXME needed for the rgb1/bgr1
- const int yalpha = 4096; //FIXME ...
+ uint16_t *buf1= buf0; //FIXME needed for the rgb1/bgr1
+ const int yalpha= 4096; //FIXME ...
- if(flags & SWS_FULL_CHR_H_INT)
- {
- RENAME(yuv2packed2)(c, buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, y);
- return;
- }
+ if(flags&SWS_FULL_CHR_H_INT)
+ {
+ RENAME(yuv2packed2)(c, buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, y);
+ return;
+ }
#if HAVE_MMX
- if(uvalpha < 2048) // note this is not correct (shifts chrominance by 0.5 pixels) but its a bit faster
- {
- switch(dstFormat)
- {
- case IMGFMT_BGR32:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1(%%REGBP, %5)
- WRITEBGR32(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_BGR24:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1(%%REGBP, %5)
- WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_BGR15:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1(%%REGBP, %5)
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+ if( uvalpha < 2048 ) // note this is not correct (shifts chrominance by 0.5 pixels) but its a bit faster
+ {
+ switch(dstFormat)
+ {
+ case IMGFMT_BGR32:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB1(%%REGBP, %5)
+ WRITEBGR32(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_BGR24:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB1(%%REGBP, %5)
+ WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_BGR15:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB1(%%REGBP, %5)
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
- "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
- "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+ "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
- WRITEBGR15(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_BGR16:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1(%%REGBP, %5)
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+ WRITEBGR15(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_BGR16:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB1(%%REGBP, %5)
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
- "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
- "paddusb "MANGLE(g6Dither)", %%mm4\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+ "paddusb "MANGLE(g6Dither)", %%mm4\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
- WRITEBGR16(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_YUY2:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2PACKED1(%%REGBP, %5)
- WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- }
- }
- else
- {
- switch(dstFormat)
- {
- case IMGFMT_BGR32:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1b(%%REGBP, %5)
- WRITEBGR32(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_BGR24:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1b(%%REGBP, %5)
- WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_BGR15:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1b(%%REGBP, %5)
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+ WRITEBGR16(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_YUY2:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2PACKED1(%%REGBP, %5)
+ WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ }
+ }
+ else
+ {
+ switch(dstFormat)
+ {
+ case IMGFMT_BGR32:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB1b(%%REGBP, %5)
+ WRITEBGR32(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_BGR24:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB1b(%%REGBP, %5)
+ WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_BGR15:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB1b(%%REGBP, %5)
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
- "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
- "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+ "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
- WRITEBGR15(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_BGR16:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1b(%%REGBP, %5)
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+ WRITEBGR15(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_BGR16:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2RGB1b(%%REGBP, %5)
+ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
- "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
- "paddusb "MANGLE(g6Dither)", %%mm4\n\t"
- "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+ "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+ "paddusb "MANGLE(g6Dither)", %%mm4\n\t"
+ "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
- WRITEBGR16(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- case IMGFMT_YUY2:
- asm volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2PACKED1b(%%REGBP, %5)
- WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
-
- :: "c"(buf0), "d"(buf1), "S"(uvbuf0), "D"(uvbuf1), "m"(dest),
- "a"(&c->redDither)
- );
- return;
- }
- }
+ WRITEBGR16(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ case IMGFMT_YUY2:
+ asm volatile(
+ "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
+ "mov %4, %%"REG_b" \n\t"
+ "push %%"REG_BP" \n\t"
+ YSCALEYUV2PACKED1b(%%REGBP, %5)
+ WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
+ "pop %%"REG_BP" \n\t"
+ "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
+
+ :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+ "a" (&c->redDither)
+ );
+ return;
+ }
+ }
#endif
- if(uvalpha < 2048)
- {
- YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C)
- }
- else
- {
- YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C)
- }
- }
+ if( uvalpha < 2048 )
+ {
+ YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C)
+ }else{
+ YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C)
+ }
+}
//FIXME yuy2* can read upto 7 samples to much
- static inline void RENAME(yuy2ToY)(uint8_t * dst, uint8_t * src, long width)
- {
+static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, long width)
+{
#if HAVE_MMX
- asm volatile(
- "movq "MANGLE(bm01010101)", %%mm2\n\t"
- "mov %0, %%"REG_a" \n\t"
- "1: \n\t"
- "movq (%1, %%"REG_a",2), %%mm0 \n\t"
- "movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
- "pand %%mm2, %%mm0 \n\t"
- "pand %%mm2, %%mm1 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "movq %%mm0, (%2, %%"REG_a") \n\t"
- "add $8, %%"REG_a" \n\t"
- " js 1b \n\t"
- : : "g"((stride_t)-width), "r"(src+width*2), "r"(dst+width)
- : "%"REG_a
- );
+ asm volatile(
+ "movq "MANGLE(bm01010101)", %%mm2\n\t"
+ "mov %0, %%"REG_a" \n\t"
+ "1: \n\t"
+ "movq (%1, %%"REG_a",2), %%mm0 \n\t"
+ "movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
+ "pand %%mm2, %%mm0 \n\t"
+ "pand %%mm2, %%mm1 \n\t"
+ "packuswb %%mm1, %%mm0 \n\t"
+ "movq %%mm0, (%2, %%"REG_a") \n\t"
+ "add $8, %%"REG_a" \n\t"
+ " js 1b \n\t"
+ : : "g" ((stride_t)-width), "r" (src+width*2), "r" (dst+width)
+ : "%"REG_a
+ );
#else
- int i;
- for(i = 0; i < width; i++)
- dst[i] = src[2*i];
+ int i;
+ for(i=0; i<width; i++)
+ dst[i]= src[2*i];
#endif
- }
+}
- static inline void RENAME(yuy2ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, long width)
- {
+static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
+{
#if HAVE_MMX2 || HAVE_AMD3DNOW
- asm volatile(
- "movq "MANGLE(bm01010101)", %%mm4\n\t"
- "mov %0, %%"REG_a" \n\t"
- "1: \n\t"
- "movq (%1, %%"REG_a",4), %%mm0 \n\t"
- "movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
- "movq (%2, %%"REG_a",4), %%mm2 \n\t"
- "movq 8(%2, %%"REG_a",4), %%mm3 \n\t"
- PAVGB(%%mm2, %%mm0)
- PAVGB(%%mm3, %%mm1)
- "psrlw $8, %%mm0 \n\t"
- "psrlw $8, %%mm1 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "psrlw $8, %%mm0 \n\t"
- "pand %%mm4, %%mm1 \n\t"
- "packuswb %%mm0, %%mm0 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- "movd %%mm0, (%4, %%"REG_a") \n\t"
- "movd %%mm1, (%3, %%"REG_a") \n\t"
- "add $4, %%"REG_a" \n\t"
- " js 1b \n\t"
- : : "g"((stride_t)-width), "r"(src1+width*4), "r"(src2+width*4), "r"(dstU+width), "r"(dstV+width)
- : "%"REG_a
- );
+ asm volatile(
+ "movq "MANGLE(bm01010101)", %%mm4\n\t"
+ "mov %0, %%"REG_a" \n\t"
+ "1: \n\t"
+ "movq (%1, %%"REG_a",4), %%mm0 \n\t"
+ "movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
+ "movq (%2, %%"REG_a",4), %%mm2 \n\t"
+ "movq 8(%2, %%"REG_a",4), %%mm3 \n\t"
+ PAVGB(%%mm2, %%mm0)
+ PAVGB(%%mm3, %%mm1)
+ "psrlw $8, %%mm0 \n\t"
+ "psrlw $8, %%mm1 \n\t"
+ "packuswb %%mm1, %%mm0 \n\t"
+ "movq %%mm0, %%mm1 \n\t"
+ "psrlw $8, %%mm0 \n\t"
+ "pand %%mm4, %%mm1 \n\t"
+ "packuswb %%mm0, %%mm0 \n\t"
+ "packuswb %%mm1, %%mm1 \n\t"
+ "movd %%mm0, (%4, %%"REG_a") \n\t"
+ "movd %%mm1, (%3, %%"REG_a") \n\t"
+ "add $4, %%"REG_a" \n\t"
+ " js 1b \n\t"
+ : : "g" ((stride_t)-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width)
+ : "%"REG_a
+ );
#else
- int i;
- for(i = 0; i < width; i++)
- {
- dstU[i] = (src1[4*i + 1] + src2[4*i + 1]) >> 1;
- dstV[i] = (src1[4*i + 3] + src2[4*i + 3]) >> 1;
- }
+ int i;
+ for(i=0; i<width; i++)
+ {
+ dstU[i]= (src1[4*i + 1] + src2[4*i + 1])>>1;
+ dstV[i]= (src1[4*i + 3] + src2[4*i + 3])>>1;
+ }
#endif
- }
+}
//this is allmost identical to the previous, end exists only cuz yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses
- static inline void RENAME(uyvyToY)(uint8_t * dst, uint8_t * src, long width)
- {
+static inline void RENAME(uyvyToY)(uint8_t *dst, uint8_t *src, long width)
+{
#if HAVE_MMX
- asm volatile(
- "mov %0, %%"REG_a" \n\t"
- "1: \n\t"
- "movq (%1, %%"REG_a",2), %%mm0 \n\t"
- "movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
- "psrlw $8, %%mm0 \n\t"
- "psrlw $8, %%mm1 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "movq %%mm0, (%2, %%"REG_a") \n\t"
- "add $8, %%"REG_a" \n\t"
- " js 1b \n\t"
- : : "g"((stride_t)-width), "r"(src+width*2), "r"(dst+width)
- : "%"REG_a
- );
+ asm volatile(
+ "mov %0, %%"REG_a" \n\t"
+ "1: \n\t"
+ "movq (%1, %%"REG_a",2), %%mm0 \n\t"
+ "movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
+ "psrlw $8, %%mm0 \n\t"
+ "psrlw $8, %%mm1 \n\t"
+ "packuswb %%mm1, %%mm0 \n\t"
+ "movq %%mm0, (%2, %%"REG_a") \n\t"
+ "add $8, %%"REG_a" \n\t"
+ " js 1b \n\t"
+ : : "g" ((stride_t)-width), "r" (src+width*2), "r" (dst+width)
+ : "%"REG_a
+ );
#else
- int i;
- for(i = 0; i < width; i++)
- dst[i] = src[2*i+1];
+ int i;
+ for(i=0; i<width; i++)
+ dst[i]= src[2*i+1];
#endif
- }
+}
- static inline void RENAME(uyvyToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, long width)
- {
+static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
+{
#if HAVE_MMX2 || HAVE_AMD3DNOW
- asm volatile(
- "movq "MANGLE(bm01010101)", %%mm4\n\t"
- "mov %0, %%"REG_a" \n\t"
- "1: \n\t"
- "movq (%1, %%"REG_a",4), %%mm0 \n\t"
- "movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
- "movq (%2, %%"REG_a",4), %%mm2 \n\t"
- "movq 8(%2, %%"REG_a",4), %%mm3 \n\t"
- PAVGB(%%mm2, %%mm0)
- PAVGB(%%mm3, %%mm1)
- "pand %%mm4, %%mm0 \n\t"
- "pand %%mm4, %%mm1 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "psrlw $8, %%mm0 \n\t"
- "pand %%mm4, %%mm1 \n\t"
- "packuswb %%mm0, %%mm0 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- "movd %%mm0, (%4, %%"REG_a") \n\t"
- "movd %%mm1, (%3, %%"REG_a") \n\t"
- "add $4, %%"REG_a" \n\t"
- " js 1b \n\t"
- : : "g"((stride_t)-width), "r"(src1+width*4), "r"(src2+width*4), "r"(dstU+width), "r"(dstV+width)
- : "%"REG_a
- );
+ asm volatile(
+ "movq "MANGLE(bm01010101)", %%mm4\n\t"
+ "mov %0, %%"REG_a" \n\t"
+ "1: \n\t"
+ "movq (%1, %%"REG_a",4), %%mm0 \n\t"
+ "movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
+ "movq (%2, %%"REG_a",4), %%mm2 \n\t"
+ "movq 8(%2, %%"REG_a",4), %%mm3 \n\t"
+ PAVGB(%%mm2, %%mm0)
+ PAVGB(%%mm3, %%mm1)
+ "pand %%mm4, %%mm0 \n\t"
+ "pand %%mm4, %%mm1 \n\t"
+ "packuswb %%mm1, %%mm0 \n\t"
+ "movq %%mm0, %%mm1 \n\t"
+ "psrlw $8, %%mm0 \n\t"
+ "pand %%mm4, %%mm1 \n\t"
+ "packuswb %%mm0, %%mm0 \n\t"
+ "packuswb %%mm1, %%mm1 \n\t"
+ "movd %%mm0, (%4, %%"REG_a") \n\t"
+ "movd %%mm1, (%3, %%"REG_a") \n\t"
+ "add $4, %%"REG_a" \n\t"
+ " js 1b \n\t"
+ : : "g" ((stride_t)-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width)
+ : "%"REG_a
+ );
#else
- int i;
- for(i = 0; i < width; i++)
- {
- dstU[i] = (src1[4*i + 0] + src2[4*i + 0]) >> 1;
- dstV[i] = (src1[4*i + 2] + src2[4*i + 2]) >> 1;
- }
+ int i;
+ for(i=0; i<width; i++)
+ {
+ dstU[i]= (src1[4*i + 0] + src2[4*i + 0])>>1;
+ dstV[i]= (src1[4*i + 2] + src2[4*i + 2])>>1;
+ }
#endif
- }
-
- static inline void RENAME(bgr32ToY)(uint8_t * dst, uint8_t * src, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int b = ((uint32_t*)src)[i] & 0xFF;
- int g = (((uint32_t*)src)[i] >> 8) & 0xFF;
- int r = (((uint32_t*)src)[i] >> 16) & 0xFF;
+}
- dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
- }
- }
+static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int b= ((uint32_t*)src)[i]&0xFF;
+ int g= (((uint32_t*)src)[i]>>8)&0xFF;
+ int r= (((uint32_t*)src)[i]>>16)&0xFF;
+
+ dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT);
+ }
+}
- static inline void RENAME(bgr32ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- const int a = ((uint32_t*)src1)[2*i+0];
- const int e = ((uint32_t*)src1)[2*i+1];
- const int c = ((uint32_t*)src2)[2*i+0];
- const int d = ((uint32_t*)src2)[2*i+1];
- const int l = (a & 0xFF00FF) + (e & 0xFF00FF) + (c & 0xFF00FF) + (d & 0xFF00FF);
- const int h = (a & 0x00FF00) + (e & 0x00FF00) + (c & 0x00FF00) + (d & 0x00FF00);
- const int b = l & 0x3FF;
- const int g = h >> 8;
- const int r = l >> 16;
-
- dstU[i] = ((RU * r + GU * g + BU * b) >> (RGB2YUV_SHIFT + 2)) + 128;
- dstV[i] = ((RV * r + GV * g + BV * b) >> (RGB2YUV_SHIFT + 2)) + 128;
- }
- }
+static inline void RENAME(bgr32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ const int a= ((uint32_t*)src1)[2*i+0];
+ const int e= ((uint32_t*)src1)[2*i+1];
+ const int c= ((uint32_t*)src2)[2*i+0];
+ const int d= ((uint32_t*)src2)[2*i+1];
+ const int l= (a&0xFF00FF) + (e&0xFF00FF) + (c&0xFF00FF) + (d&0xFF00FF);
+ const int h= (a&0x00FF00) + (e&0x00FF00) + (c&0x00FF00) + (d&0x00FF00);
+ const int b= l&0x3FF;
+ const int g= h>>8;
+ const int r= l>>16;
+
+ dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
+ dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
+ }
+}
- static inline void RENAME(bgr24ToY)(uint8_t * dst, uint8_t * src, long width)
- {
+static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, long width)
+{
#if HAVE_MMX
- asm volatile(
- "mov %2, %%"REG_a" \n\t"
- "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t"
- "movq "MANGLE(w1111)", %%mm5 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
- "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t"
- ASMALIGN16
- "1: \n\t"
- PREFETCH" 64(%0, %%"REG_b") \n\t"
- "movd (%0, %%"REG_b"), %%mm0 \n\t"
- "movd 3(%0, %%"REG_b"), %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "movd 6(%0, %%"REG_b"), %%mm2 \n\t"
- "movd 9(%0, %%"REG_b"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "pmaddwd %%mm6, %%mm0 \n\t"
- "pmaddwd %%mm6, %%mm1 \n\t"
- "pmaddwd %%mm6, %%mm2 \n\t"
- "pmaddwd %%mm6, %%mm3 \n\t"
+ asm volatile(
+ "mov %2, %%"REG_a" \n\t"
+ "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t"
+ "movq "MANGLE(w1111)", %%mm5 \n\t"
+ "pxor %%mm7, %%mm7 \n\t"
+ "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t"
+ ASMALIGN16
+ "1: \n\t"
+ PREFETCH" 64(%0, %%"REG_b") \n\t"
+ "movd (%0, %%"REG_b"), %%mm0 \n\t"
+ "movd 3(%0, %%"REG_b"), %%mm1 \n\t"
+ "punpcklbw %%mm7, %%mm0 \n\t"
+ "punpcklbw %%mm7, %%mm1 \n\t"
+ "movd 6(%0, %%"REG_b"), %%mm2 \n\t"
+ "movd 9(%0, %%"REG_b"), %%mm3 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm3 \n\t"
+ "pmaddwd %%mm6, %%mm0 \n\t"
+ "pmaddwd %%mm6, %%mm1 \n\t"
+ "pmaddwd %%mm6, %%mm2 \n\t"
+ "pmaddwd %%mm6, %%mm3 \n\t"
#ifndef FAST_BGR2YV12
- "psrad $8, %%mm0 \n\t"
- "psrad $8, %%mm1 \n\t"
- "psrad $8, %%mm2 \n\t"
- "psrad $8, %%mm3 \n\t"
+ "psrad $8, %%mm0 \n\t"
+ "psrad $8, %%mm1 \n\t"
+ "psrad $8, %%mm2 \n\t"
+ "psrad $8, %%mm3 \n\t"
#endif
- "packssdw %%mm1, %%mm0 \n\t"
- "packssdw %%mm3, %%mm2 \n\t"
- "pmaddwd %%mm5, %%mm0 \n\t"
- "pmaddwd %%mm5, %%mm2 \n\t"
- "packssdw %%mm2, %%mm0 \n\t"
- "psraw $7, %%mm0 \n\t"
-
- "movd 12(%0, %%"REG_b"), %%mm4 \n\t"
- "movd 15(%0, %%"REG_b"), %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "movd 18(%0, %%"REG_b"), %%mm2 \n\t"
- "movd 21(%0, %%"REG_b"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "pmaddwd %%mm6, %%mm4 \n\t"
- "pmaddwd %%mm6, %%mm1 \n\t"
- "pmaddwd %%mm6, %%mm2 \n\t"
- "pmaddwd %%mm6, %%mm3 \n\t"
+ "packssdw %%mm1, %%mm0 \n\t"
+ "packssdw %%mm3, %%mm2 \n\t"
+ "pmaddwd %%mm5, %%mm0 \n\t"
+ "pmaddwd %%mm5, %%mm2 \n\t"
+ "packssdw %%mm2, %%mm0 \n\t"
+ "psraw $7, %%mm0 \n\t"
+
+ "movd 12(%0, %%"REG_b"), %%mm4 \n\t"
+ "movd 15(%0, %%"REG_b"), %%mm1 \n\t"
+ "punpcklbw %%mm7, %%mm4 \n\t"
+ "punpcklbw %%mm7, %%mm1 \n\t"
+ "movd 18(%0, %%"REG_b"), %%mm2 \n\t"
+ "movd 21(%0, %%"REG_b"), %%mm3 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm3 \n\t"
+ "pmaddwd %%mm6, %%mm4 \n\t"
+ "pmaddwd %%mm6, %%mm1 \n\t"
+ "pmaddwd %%mm6, %%mm2 \n\t"
+ "pmaddwd %%mm6, %%mm3 \n\t"
#ifndef FAST_BGR2YV12
- "psrad $8, %%mm4 \n\t"
- "psrad $8, %%mm1 \n\t"
- "psrad $8, %%mm2 \n\t"
- "psrad $8, %%mm3 \n\t"
+ "psrad $8, %%mm4 \n\t"
+ "psrad $8, %%mm1 \n\t"
+ "psrad $8, %%mm2 \n\t"
+ "psrad $8, %%mm3 \n\t"
#endif
- "packssdw %%mm1, %%mm4 \n\t"
- "packssdw %%mm3, %%mm2 \n\t"
- "pmaddwd %%mm5, %%mm4 \n\t"
- "pmaddwd %%mm5, %%mm2 \n\t"
- "add $24, %%"REG_b" \n\t"
- "packssdw %%mm2, %%mm4 \n\t"
- "psraw $7, %%mm4 \n\t"
-
- "packuswb %%mm4, %%mm0 \n\t"
- "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t"
-
- "movq %%mm0, (%1, %%"REG_a") \n\t"
- "add $8, %%"REG_a" \n\t"
- " js 1b \n\t"
- : : "r"(src+width*3), "r"(dst+width), "g"((stride_t)-width)
- : "%"REG_a, "%"REG_b
- );
+ "packssdw %%mm1, %%mm4 \n\t"
+ "packssdw %%mm3, %%mm2 \n\t"
+ "pmaddwd %%mm5, %%mm4 \n\t"
+ "pmaddwd %%mm5, %%mm2 \n\t"
+ "add $24, %%"REG_b" \n\t"
+ "packssdw %%mm2, %%mm4 \n\t"
+ "psraw $7, %%mm4 \n\t"
+
+ "packuswb %%mm4, %%mm0 \n\t"
+ "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t"
+
+ "movq %%mm0, (%1, %%"REG_a") \n\t"
+ "add $8, %%"REG_a" \n\t"
+ " js 1b \n\t"
+ : : "r" (src+width*3), "r" (dst+width), "g" ((stride_t)-width)
+ : "%"REG_a, "%"REG_b
+ );
#else
- int i;
- for(i = 0; i < width; i++)
- {
- int b = src[i*3+0];
- int g = src[i*3+1];
- int r = src[i*3+2];
-
- dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
- }
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int b= src[i*3+0];
+ int g= src[i*3+1];
+ int r= src[i*3+2];
+
+ dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT);
+ }
#endif
- }
+}
- static inline void RENAME(bgr24ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, long width)
- {
+static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
+{
#if HAVE_MMX
- asm volatile(
- "mov %4, %%"REG_a" \n\t"
- "movq "MANGLE(w1111)", %%mm5 \n\t"
- "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
- "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b" \n\t"
- "add %%"REG_b", %%"REG_b" \n\t"
- ASMALIGN16
- "1: \n\t"
- PREFETCH" 64(%0, %%"REG_b") \n\t"
- PREFETCH" 64(%1, %%"REG_b") \n\t"
+ asm volatile(
+ "mov %4, %%"REG_a" \n\t"
+ "movq "MANGLE(w1111)", %%mm5 \n\t"
+ "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t"
+ "pxor %%mm7, %%mm7 \n\t"
+ "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b" \n\t"
+ "add %%"REG_b", %%"REG_b" \n\t"
+ ASMALIGN16
+ "1: \n\t"
+ PREFETCH" 64(%0, %%"REG_b") \n\t"
+ PREFETCH" 64(%1, %%"REG_b") \n\t"
#if HAVE_MMX2 || HAVE_AMD3DNOW
- "movq (%0, %%"REG_b"), %%mm0 \n\t"
- "movq (%1, %%"REG_b"), %%mm1 \n\t"
- "movq 6(%0, %%"REG_b"), %%mm2 \n\t"
- "movq 6(%1, %%"REG_b"), %%mm3 \n\t"
- PAVGB(%%mm1, %%mm0)
- PAVGB(%%mm3, %%mm2)
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "psrlq $24, %%mm0 \n\t"
- "psrlq $24, %%mm2 \n\t"
- PAVGB(%%mm1, %%mm0)
- PAVGB(%%mm3, %%mm2)
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
+ "movq (%0, %%"REG_b"), %%mm0 \n\t"
+ "movq (%1, %%"REG_b"), %%mm1 \n\t"
+ "movq 6(%0, %%"REG_b"), %%mm2 \n\t"
+ "movq 6(%1, %%"REG_b"), %%mm3 \n\t"
+ PAVGB(%%mm1, %%mm0)
+ PAVGB(%%mm3, %%mm2)
+ "movq %%mm0, %%mm1 \n\t"
+ "movq %%mm2, %%mm3 \n\t"
+ "psrlq $24, %%mm0 \n\t"
+ "psrlq $24, %%mm2 \n\t"
+ PAVGB(%%mm1, %%mm0)
+ PAVGB(%%mm3, %%mm2)
+ "punpcklbw %%mm7, %%mm0 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
#else
- "movd (%0, %%"REG_b"), %%mm0 \n\t"
- "movd (%1, %%"REG_b"), %%mm1 \n\t"
- "movd 3(%0, %%"REG_b"), %%mm2 \n\t"
- "movd 3(%1, %%"REG_b"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "paddw %%mm1, %%mm0 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- "paddw %%mm2, %%mm0 \n\t"
- "movd 6(%0, %%"REG_b"), %%mm4 \n\t"
- "movd 6(%1, %%"REG_b"), %%mm1 \n\t"
- "movd 9(%0, %%"REG_b"), %%mm2 \n\t"
- "movd 9(%1, %%"REG_b"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "paddw %%mm1, %%mm4 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- "paddw %%mm4, %%mm2 \n\t"
- "psrlw $2, %%mm0 \n\t"
- "psrlw $2, %%mm2 \n\t"
+ "movd (%0, %%"REG_b"), %%mm0 \n\t"
+ "movd (%1, %%"REG_b"), %%mm1 \n\t"
+ "movd 3(%0, %%"REG_b"), %%mm2 \n\t"
+ "movd 3(%1, %%"REG_b"), %%mm3 \n\t"
+ "punpcklbw %%mm7, %%mm0 \n\t"
+ "punpcklbw %%mm7, %%mm1 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm3 \n\t"
+ "paddw %%mm1, %%mm0 \n\t"
+ "paddw %%mm3, %%mm2 \n\t"
+ "paddw %%mm2, %%mm0 \n\t"
+ "movd 6(%0, %%"REG_b"), %%mm4 \n\t"
+ "movd 6(%1, %%"REG_b"), %%mm1 \n\t"
+ "movd 9(%0, %%"REG_b"), %%mm2 \n\t"
+ "movd 9(%1, %%"REG_b"), %%mm3 \n\t"
+ "punpcklbw %%mm7, %%mm4 \n\t"
+ "punpcklbw %%mm7, %%mm1 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm3 \n\t"
+ "paddw %%mm1, %%mm4 \n\t"
+ "paddw %%mm3, %%mm2 \n\t"
+ "paddw %%mm4, %%mm2 \n\t"
+ "psrlw $2, %%mm0 \n\t"
+ "psrlw $2, %%mm2 \n\t"
#endif
- "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
- "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
+ "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
+ "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
- "pmaddwd %%mm0, %%mm1 \n\t"
- "pmaddwd %%mm2, %%mm3 \n\t"
- "pmaddwd %%mm6, %%mm0 \n\t"
- "pmaddwd %%mm6, %%mm2 \n\t"
+ "pmaddwd %%mm0, %%mm1 \n\t"
+ "pmaddwd %%mm2, %%mm3 \n\t"
+ "pmaddwd %%mm6, %%mm0 \n\t"
+ "pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
- "psrad $8, %%mm0 \n\t"
- "psrad $8, %%mm1 \n\t"
- "psrad $8, %%mm2 \n\t"
- "psrad $8, %%mm3 \n\t"
+ "psrad $8, %%mm0 \n\t"
+ "psrad $8, %%mm1 \n\t"
+ "psrad $8, %%mm2 \n\t"
+ "psrad $8, %%mm3 \n\t"
#endif
- "packssdw %%mm2, %%mm0 \n\t"
- "packssdw %%mm3, %%mm1 \n\t"
- "pmaddwd %%mm5, %%mm0 \n\t"
- "pmaddwd %%mm5, %%mm1 \n\t"
- "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0
- "psraw $7, %%mm0 \n\t"
+ "packssdw %%mm2, %%mm0 \n\t"
+ "packssdw %%mm3, %%mm1 \n\t"
+ "pmaddwd %%mm5, %%mm0 \n\t"
+ "pmaddwd %%mm5, %%mm1 \n\t"
+ "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0
+ "psraw $7, %%mm0 \n\t"
#if HAVE_MMX2 || HAVE_AMD3DNOW
- "movq 12(%0, %%"REG_b"), %%mm4 \n\t"
- "movq 12(%1, %%"REG_b"), %%mm1 \n\t"
- "movq 18(%0, %%"REG_b"), %%mm2 \n\t"
- "movq 18(%1, %%"REG_b"), %%mm3 \n\t"
- PAVGB(%%mm1, %%mm4)
- PAVGB(%%mm3, %%mm2)
- "movq %%mm4, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "psrlq $24, %%mm4 \n\t"
- "psrlq $24, %%mm2 \n\t"
- PAVGB(%%mm1, %%mm4)
- PAVGB(%%mm3, %%mm2)
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
+ "movq 12(%0, %%"REG_b"), %%mm4 \n\t"
+ "movq 12(%1, %%"REG_b"), %%mm1 \n\t"
+ "movq 18(%0, %%"REG_b"), %%mm2 \n\t"
+ "movq 18(%1, %%"REG_b"), %%mm3 \n\t"
+ PAVGB(%%mm1, %%mm4)
+ PAVGB(%%mm3, %%mm2)
+ "movq %%mm4, %%mm1 \n\t"
+ "movq %%mm2, %%mm3 \n\t"
+ "psrlq $24, %%mm4 \n\t"
+ "psrlq $24, %%mm2 \n\t"
+ PAVGB(%%mm1, %%mm4)
+ PAVGB(%%mm3, %%mm2)
+ "punpcklbw %%mm7, %%mm4 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
#else
- "movd 12(%0, %%"REG_b"), %%mm4 \n\t"
- "movd 12(%1, %%"REG_b"), %%mm1 \n\t"
- "movd 15(%0, %%"REG_b"), %%mm2 \n\t"
- "movd 15(%1, %%"REG_b"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "paddw %%mm1, %%mm4 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- "paddw %%mm2, %%mm4 \n\t"
- "movd 18(%0, %%"REG_b"), %%mm5 \n\t"
- "movd 18(%1, %%"REG_b"), %%mm1 \n\t"
- "movd 21(%0, %%"REG_b"), %%mm2 \n\t"
- "movd 21(%1, %%"REG_b"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm5 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "paddw %%mm1, %%mm5 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- "paddw %%mm5, %%mm2 \n\t"
- "movq "MANGLE(w1111)", %%mm5 \n\t"
- "psrlw $2, %%mm4 \n\t"
- "psrlw $2, %%mm2 \n\t"
+ "movd 12(%0, %%"REG_b"), %%mm4 \n\t"
+ "movd 12(%1, %%"REG_b"), %%mm1 \n\t"
+ "movd 15(%0, %%"REG_b"), %%mm2 \n\t"
+ "movd 15(%1, %%"REG_b"), %%mm3 \n\t"
+ "punpcklbw %%mm7, %%mm4 \n\t"
+ "punpcklbw %%mm7, %%mm1 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm3 \n\t"
+ "paddw %%mm1, %%mm4 \n\t"
+ "paddw %%mm3, %%mm2 \n\t"
+ "paddw %%mm2, %%mm4 \n\t"
+ "movd 18(%0, %%"REG_b"), %%mm5 \n\t"
+ "movd 18(%1, %%"REG_b"), %%mm1 \n\t"
+ "movd 21(%0, %%"REG_b"), %%mm2 \n\t"
+ "movd 21(%1, %%"REG_b"), %%mm3 \n\t"
+ "punpcklbw %%mm7, %%mm5 \n\t"
+ "punpcklbw %%mm7, %%mm1 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm3 \n\t"
+ "paddw %%mm1, %%mm5 \n\t"
+ "paddw %%mm3, %%mm2 \n\t"
+ "paddw %%mm5, %%mm2 \n\t"
+ "movq "MANGLE(w1111)", %%mm5 \n\t"
+ "psrlw $2, %%mm4 \n\t"
+ "psrlw $2, %%mm2 \n\t"
#endif
- "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
- "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
+ "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
+ "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
- "pmaddwd %%mm4, %%mm1 \n\t"
- "pmaddwd %%mm2, %%mm3 \n\t"
- "pmaddwd %%mm6, %%mm4 \n\t"
- "pmaddwd %%mm6, %%mm2 \n\t"
+ "pmaddwd %%mm4, %%mm1 \n\t"
+ "pmaddwd %%mm2, %%mm3 \n\t"
+ "pmaddwd %%mm6, %%mm4 \n\t"
+ "pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
- "psrad $8, %%mm4 \n\t"
- "psrad $8, %%mm1 \n\t"
- "psrad $8, %%mm2 \n\t"
- "psrad $8, %%mm3 \n\t"
+ "psrad $8, %%mm4 \n\t"
+ "psrad $8, %%mm1 \n\t"
+ "psrad $8, %%mm2 \n\t"
+ "psrad $8, %%mm3 \n\t"
#endif
- "packssdw %%mm2, %%mm4 \n\t"
- "packssdw %%mm3, %%mm1 \n\t"
- "pmaddwd %%mm5, %%mm4 \n\t"
- "pmaddwd %%mm5, %%mm1 \n\t"
- "add $24, %%"REG_b" \n\t"
- "packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2
- "psraw $7, %%mm4 \n\t"
-
- "movq %%mm0, %%mm1 \n\t"
- "punpckldq %%mm4, %%mm0 \n\t"
- "punpckhdq %%mm4, %%mm1 \n\t"
- "packsswb %%mm1, %%mm0 \n\t"
- "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t"
-
- "movd %%mm0, (%2, %%"REG_a") \n\t"
- "punpckhdq %%mm0, %%mm0 \n\t"
- "movd %%mm0, (%3, %%"REG_a") \n\t"
- "add $4, %%"REG_a" \n\t"
- " js 1b \n\t"
- : : "r"(src1+width*6), "r"(src2+width*6), "r"(dstU+width), "r"(dstV+width), "g"((stride_t)-width)
- : "%"REG_a, "%"REG_b
- );
+ "packssdw %%mm2, %%mm4 \n\t"
+ "packssdw %%mm3, %%mm1 \n\t"
+ "pmaddwd %%mm5, %%mm4 \n\t"
+ "pmaddwd %%mm5, %%mm1 \n\t"
+ "add $24, %%"REG_b" \n\t"
+ "packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2
+ "psraw $7, %%mm4 \n\t"
+
+ "movq %%mm0, %%mm1 \n\t"
+ "punpckldq %%mm4, %%mm0 \n\t"
+ "punpckhdq %%mm4, %%mm1 \n\t"
+ "packsswb %%mm1, %%mm0 \n\t"
+ "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t"
+
+ "movd %%mm0, (%2, %%"REG_a") \n\t"
+ "punpckhdq %%mm0, %%mm0 \n\t"
+ "movd %%mm0, (%3, %%"REG_a") \n\t"
+ "add $4, %%"REG_a" \n\t"
+ " js 1b \n\t"
+ : : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" ((stride_t)-width)
+ : "%"REG_a, "%"REG_b
+ );
#else
- int i;
- for(i = 0; i < width; i++)
- {
- int b = src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3];
- int g = src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4];
- int r = src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5];
-
- dstU[i] = ((RU * r + GU * g + BU * b) >> (RGB2YUV_SHIFT + 2)) + 128;
- dstV[i] = ((RV * r + GV * g + BV * b) >> (RGB2YUV_SHIFT + 2)) + 128;
- }
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3];
+ int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4];
+ int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5];
+
+ dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
+ dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
+ }
#endif
- }
-
- static inline void RENAME(bgr16ToY)(uint8_t * dst, uint8_t * src, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int d = ((uint16_t*)src)[i];
- int b = d & 0x1F;
- int g = (d >> 5) & 0x3F;
- int r = (d >> 11) & 0x1F;
-
- dst[i] = ((2 * RY * r + GY * g + 2 * BY * b) >> (RGB2YUV_SHIFT - 2)) + 16;
- }
- }
-
- static inline void RENAME(bgr16ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int d0 = ((uint32_t*)src1)[i];
- int d1 = ((uint32_t*)src2)[i];
-
- int dl = (d0 & 0x07E0F81F) + (d1 & 0x07E0F81F);
- int dh = ((d0 >> 5) & 0x07C0F83F) + ((d1 >> 5) & 0x07C0F83F);
-
- int dh2 = (dh >> 11) + (dh << 21);
- int d = dh2 + dl;
-
- int b = d & 0x7F;
- int r = (d >> 11) & 0x7F;
- int g = d >> 21;
- dstU[i] = ((2 * RU * r + GU * g + 2 * BU * b) >> (RGB2YUV_SHIFT + 2 - 2)) + 128;
- dstV[i] = ((2 * RV * r + GV * g + 2 * BV * b) >> (RGB2YUV_SHIFT + 2 - 2)) + 128;
- }
- }
-
- static inline void RENAME(bgr15ToY)(uint8_t * dst, uint8_t * src, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int d = ((uint16_t*)src)[i];
- int b = d & 0x1F;
- int g = (d >> 5) & 0x1F;
- int r = (d >> 10) & 0x1F;
-
- dst[i] = ((RY * r + GY * g + BY * b) >> (RGB2YUV_SHIFT - 3)) + 16;
- }
- }
-
- static inline void RENAME(bgr15ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int d0 = ((uint32_t*)src1)[i];
- int d1 = ((uint32_t*)src2)[i];
-
- int dl = (d0 & 0x03E07C1F) + (d1 & 0x03E07C1F);
- int dh = ((d0 >> 5) & 0x03E0F81F) + ((d1 >> 5) & 0x03E0F81F);
-
- int dh2 = (dh >> 11) + (dh << 21);
- int d = dh2 + dl;
-
- int b = d & 0x7F;
- int r = (d >> 10) & 0x7F;
- int g = d >> 21;
- dstU[i] = ((RU * r + GU * g + BU * b) >> (RGB2YUV_SHIFT + 2 - 3)) + 128;
- dstV[i] = ((RV * r + GV * g + BV * b) >> (RGB2YUV_SHIFT + 2 - 3)) + 128;
- }
- }
-
-
- static inline void RENAME(rgb32ToY)(uint8_t * dst, uint8_t * src, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int r = ((uint32_t*)src)[i] & 0xFF;
- int g = (((uint32_t*)src)[i] >> 8) & 0xFF;
- int b = (((uint32_t*)src)[i] >> 16) & 0xFF;
-
- dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
- }
- }
-
- static inline void RENAME(rgb32ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- const int a = ((uint32_t*)src1)[2*i+0];
- const int e = ((uint32_t*)src1)[2*i+1];
- const int c = ((uint32_t*)src2)[2*i+0];
- const int d = ((uint32_t*)src2)[2*i+1];
- const int l = (a & 0xFF00FF) + (e & 0xFF00FF) + (c & 0xFF00FF) + (d & 0xFF00FF);
- const int h = (a & 0x00FF00) + (e & 0x00FF00) + (c & 0x00FF00) + (d & 0x00FF00);
- const int r = l & 0x3FF;
- const int g = h >> 8;
- const int b = l >> 16;
-
- dstU[i] = ((RU * r + GU * g + BU * b) >> (RGB2YUV_SHIFT + 2)) + 128;
- dstV[i] = ((RV * r + GV * g + BV * b) >> (RGB2YUV_SHIFT + 2)) + 128;
- }
- }
-
- static inline void RENAME(rgb24ToY)(uint8_t * dst, uint8_t * src, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int r = src[i*3+0];
- int g = src[i*3+1];
- int b = src[i*3+2];
-
- dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
- }
- }
-
- static inline void RENAME(rgb24ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int r = src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3];
- int g = src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4];
- int b = src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5];
+}
- dstU[i] = ((RU * r + GU * g + BU * b) >> (RGB2YUV_SHIFT + 2)) + 128;
- dstV[i] = ((RV * r + GV * g + BV * b) >> (RGB2YUV_SHIFT + 2)) + 128;
- }
- }
+static inline void RENAME(bgr16ToY)(uint8_t *dst, uint8_t *src, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int d= ((uint16_t*)src)[i];
+ int b= d&0x1F;
+ int g= (d>>5)&0x3F;
+ int r= (d>>11)&0x1F;
+
+ dst[i]= ((2*RY*r + GY*g + 2*BY*b)>>(RGB2YUV_SHIFT-2)) + 16;
+ }
+}
- static inline void RENAME(rgb16ToY)(uint8_t * dst, uint8_t * src, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int d = ((uint16_t*)src)[i];
- int b = d & 0x1F;
- int g = (d >> 5) & 0x3F;
- int r = (d >> 11) & 0x1F;
+static inline void RENAME(bgr16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int d0= ((uint32_t*)src1)[i];
+ int d1= ((uint32_t*)src2)[i];
+
+ int dl= (d0&0x07E0F81F) + (d1&0x07E0F81F);
+ int dh= ((d0>>5)&0x07C0F83F) + ((d1>>5)&0x07C0F83F);
+
+ int dh2= (dh>>11) + (dh<<21);
+ int d= dh2 + dl;
+
+ int b= d&0x7F;
+ int r= (d>>11)&0x7F;
+ int g= d>>21;
+ dstU[i]= ((2*RU*r + GU*g + 2*BU*b)>>(RGB2YUV_SHIFT+2-2)) + 128;
+ dstV[i]= ((2*RV*r + GV*g + 2*BV*b)>>(RGB2YUV_SHIFT+2-2)) + 128;
+ }
+}
- dst[i] = ((2 * RY * r + GY * g + 2 * BY * b) >> (RGB2YUV_SHIFT - 2)) + 16;
- }
- }
+static inline void RENAME(bgr15ToY)(uint8_t *dst, uint8_t *src, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int d= ((uint16_t*)src)[i];
+ int b= d&0x1F;
+ int g= (d>>5)&0x1F;
+ int r= (d>>10)&0x1F;
+
+ dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;
+ }
+}
- static inline void RENAME(rgb16ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int d0 = ((uint32_t*)src1)[i];
- int d1 = ((uint32_t*)src2)[i];
+static inline void RENAME(bgr15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int d0= ((uint32_t*)src1)[i];
+ int d1= ((uint32_t*)src2)[i];
+
+ int dl= (d0&0x03E07C1F) + (d1&0x03E07C1F);
+ int dh= ((d0>>5)&0x03E0F81F) + ((d1>>5)&0x03E0F81F);
+
+ int dh2= (dh>>11) + (dh<<21);
+ int d= dh2 + dl;
+
+ int b= d&0x7F;
+ int r= (d>>10)&0x7F;
+ int g= d>>21;
+ dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2-3)) + 128;
+ dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2-3)) + 128;
+ }
+}
- int dl = (d0 & 0x07E0F81F) + (d1 & 0x07E0F81F);
- int dh = ((d0 >> 5) & 0x07C0F83F) + ((d1 >> 5) & 0x07C0F83F);
- int dh2 = (dh >> 11) + (dh << 21);
- int d = dh2 + dl;
+static inline void RENAME(rgb32ToY)(uint8_t *dst, uint8_t *src, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int r= ((uint32_t*)src)[i]&0xFF;
+ int g= (((uint32_t*)src)[i]>>8)&0xFF;
+ int b= (((uint32_t*)src)[i]>>16)&0xFF;
+
+ dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT);
+ }
+}
- int b = d & 0x7F;
- int r = (d >> 11) & 0x7F;
- int g = d >> 21;
- dstV[i] = ((2 * RU * r + GU * g + 2 * BU * b) >> (RGB2YUV_SHIFT + 2 - 2)) + 128;
- dstU[i] = ((2 * RV * r + GV * g + 2 * BV * b) >> (RGB2YUV_SHIFT + 2 - 2)) + 128;
- }
- }
+static inline void RENAME(rgb32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ const int a= ((uint32_t*)src1)[2*i+0];
+ const int e= ((uint32_t*)src1)[2*i+1];
+ const int c= ((uint32_t*)src2)[2*i+0];
+ const int d= ((uint32_t*)src2)[2*i+1];
+ const int l= (a&0xFF00FF) + (e&0xFF00FF) + (c&0xFF00FF) + (d&0xFF00FF);
+ const int h= (a&0x00FF00) + (e&0x00FF00) + (c&0x00FF00) + (d&0x00FF00);
+ const int r= l&0x3FF;
+ const int g= h>>8;
+ const int b= l>>16;
+
+ dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
+ dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
+ }
+}
- static inline void RENAME(rgb15ToY)(uint8_t * dst, uint8_t * src, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int d = ((uint16_t*)src)[i];
- int b = d & 0x1F;
- int g = (d >> 5) & 0x1F;
- int r = (d >> 10) & 0x1F;
+static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int r= src[i*3+0];
+ int g= src[i*3+1];
+ int b= src[i*3+2];
+
+ dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT);
+ }
+}
- dst[i] = ((RY * r + GY * g + BY * b) >> (RGB2YUV_SHIFT - 3)) + 16;
- }
- }
+static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int r= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3];
+ int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4];
+ int b= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5];
+
+ dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
+ dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
+ }
+}
- static inline void RENAME(rgb15ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- int d0 = ((uint32_t*)src1)[i];
- int d1 = ((uint32_t*)src2)[i];
+static inline void RENAME(rgb16ToY)(uint8_t *dst, uint8_t *src, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int d= ((uint16_t*)src)[i];
+ int b= d&0x1F;
+ int g= (d>>5)&0x3F;
+ int r= (d>>11)&0x1F;
+
+ dst[i]= ((2*RY*r + GY*g + 2*BY*b)>>(RGB2YUV_SHIFT-2)) + 16;
+ }
+}
- int dl = (d0 & 0x03E07C1F) + (d1 & 0x03E07C1F);
- int dh = ((d0 >> 5) & 0x03E0F81F) + ((d1 >> 5) & 0x03E0F81F);
+static inline void RENAME(rgb16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int d0= ((uint32_t*)src1)[i];
+ int d1= ((uint32_t*)src2)[i];
+
+ int dl= (d0&0x07E0F81F) + (d1&0x07E0F81F);
+ int dh= ((d0>>5)&0x07C0F83F) + ((d1>>5)&0x07C0F83F);
+
+ int dh2= (dh>>11) + (dh<<21);
+ int d= dh2 + dl;
+
+ int b= d&0x7F;
+ int r= (d>>11)&0x7F;
+ int g= d>>21;
+ dstV[i]= ((2*RU*r + GU*g + 2*BU*b)>>(RGB2YUV_SHIFT+2-2)) + 128;
+ dstU[i]= ((2*RV*r + GV*g + 2*BV*b)>>(RGB2YUV_SHIFT+2-2)) + 128;
+ }
+}
- int dh2 = (dh >> 11) + (dh << 21);
- int d = dh2 + dl;
+static inline void RENAME(rgb15ToY)(uint8_t *dst, uint8_t *src, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int d= ((uint16_t*)src)[i];
+ int b= d&0x1F;
+ int g= (d>>5)&0x1F;
+ int r= (d>>10)&0x1F;
+
+ dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;
+ }
+}
- int b = d & 0x7F;
- int r = (d >> 10) & 0x7F;
- int g = d >> 21;
- dstV[i] = ((RU * r + GU * g + BU * b) >> (RGB2YUV_SHIFT + 2 - 3)) + 128;
- dstU[i] = ((RV * r + GV * g + BV * b) >> (RGB2YUV_SHIFT + 2 - 3)) + 128;
- }
- }
+static inline void RENAME(rgb15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int d0= ((uint32_t*)src1)[i];
+ int d1= ((uint32_t*)src2)[i];
+
+ int dl= (d0&0x03E07C1F) + (d1&0x03E07C1F);
+ int dh= ((d0>>5)&0x03E0F81F) + ((d1>>5)&0x03E0F81F);
+
+ int dh2= (dh>>11) + (dh<<21);
+ int d= dh2 + dl;
+
+ int b= d&0x7F;
+ int r= (d>>10)&0x7F;
+ int g= d>>21;
+ dstV[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2-3)) + 128;
+ dstU[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2-3)) + 128;
+ }
+}
- static inline void RENAME(nv12ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- dstU[i] = src1[i<<1];
- dstV[i] = src1[(i<<1)+1];
- }
- }
+static inline void RENAME(nv12ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ dstU[i]= src1[i<<1];
+ dstV[i]= src1[(i<<1)+1];
+ }
+}
- static inline void RENAME(nv21ToUV)(uint8_t * dstU, uint8_t * dstV, uint8_t * src1, uint8_t * src2, int width)
- {
- int i;
- for(i = 0; i < width; i++)
- {
- dstV[i] = src1[i<<1];
- dstU[i] = src1[(i<<1)+1];
- }
- }
+static inline void RENAME(nv21ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ dstV[i]= src1[i<<1];
+ dstU[i]= src1[(i<<1)+1];
+ }
+}
// Bilinear / Bicubic scaling
- static inline void RENAME(hScale)(int16_t * dst, int dstW, uint8_t * src, int srcW, int xInc,
- int16_t * filter, int16_t * filterPos, long filterSize0)
- {
- const stride_t filterSize = filterSize0;
+static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,
+ int16_t *filter, int16_t *filterPos, long filterSize0)
+{
+ const stride_t filterSize = filterSize0;
#if HAVE_MMX
- assert(filterSize % 4 == 0 && filterSize > 0);
- if(filterSize == 4) // allways true for upscaling, sometimes for down too
- {
- stride_t counter = -2 * dstW;
- filter -= counter * 2;
- filterPos -= counter / 2;
- dst -= counter / 2;
- asm volatile(
- "pxor %%mm7, %%mm7 \n\t"
- "movq "MANGLE(w02)", %%mm6 \n\t"
- "push %%"REG_BP" \n\t" // we use 7 regs here ...
- "mov %%"REG_a", %%"REG_BP" \n\t"
- ASMALIGN16
- "1: \n\t"
- "movzwl (%2, %%"REG_BP"), %%eax \n\t"
- "movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
- "movq (%1, %%"REG_BP", 4), %%mm1\n\t"
- "movq 8(%1, %%"REG_BP", 4), %%mm3\n\t"
- "movd (%3, %%"REG_a"), %%mm0 \n\t"
- "movd (%3, %%"REG_b"), %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "pmaddwd %%mm1, %%mm0 \n\t"
- "pmaddwd %%mm2, %%mm3 \n\t"
- "psrad $8, %%mm0 \n\t"
- "psrad $8, %%mm3 \n\t"
- "packssdw %%mm3, %%mm0 \n\t"
- "pmaddwd %%mm6, %%mm0 \n\t"
- "packssdw %%mm0, %%mm0 \n\t"
- "movd %%mm0, (%4, %%"REG_BP") \n\t"
- "add $4, %%"REG_BP" \n\t"
- " jnc 1b \n\t"
-
- "pop %%"REG_BP" \n\t"
- : "+a"(counter)
- : "c"(filter), "d"(filterPos), "S"(src), "D"(dst)
- : "%"REG_b
- );
- }
- else if(filterSize == 8)
- {
- stride_t counter = -2 * dstW;
- filter -= counter * 4;
- filterPos -= counter / 2;
- dst -= counter / 2;
- asm volatile(
- "pxor %%mm7, %%mm7 \n\t"
- "movq "MANGLE(w02)", %%mm6 \n\t"
- "push %%"REG_BP" \n\t" // we use 7 regs here ...
- "mov %%"REG_a", %%"REG_BP" \n\t"
- ASMALIGN16
- "1: \n\t"
- "movzwl (%2, %%"REG_BP"), %%eax \n\t"
- "movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
- "movq (%1, %%"REG_BP", 8), %%mm1\n\t"
- "movq 16(%1, %%"REG_BP", 8), %%mm3\n\t"
- "movd (%3, %%"REG_a"), %%mm0 \n\t"
- "movd (%3, %%"REG_b"), %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "pmaddwd %%mm1, %%mm0 \n\t"
- "pmaddwd %%mm2, %%mm3 \n\t"
-
- "movq 8(%1, %%"REG_BP", 8), %%mm1\n\t"
- "movq 24(%1, %%"REG_BP", 8), %%mm5\n\t"
- "movd 4(%3, %%"REG_a"), %%mm4 \n\t"
- "movd 4(%3, %%"REG_b"), %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "pmaddwd %%mm1, %%mm4 \n\t"
- "pmaddwd %%mm2, %%mm5 \n\t"
- "paddd %%mm4, %%mm0 \n\t"
- "paddd %%mm5, %%mm3 \n\t"
-
- "psrad $8, %%mm0 \n\t"
- "psrad $8, %%mm3 \n\t"
- "packssdw %%mm3, %%mm0 \n\t"
- "pmaddwd %%mm6, %%mm0 \n\t"
- "packssdw %%mm0, %%mm0 \n\t"
- "movd %%mm0, (%4, %%"REG_BP") \n\t"
- "add $4, %%"REG_BP" \n\t"
- " jnc 1b \n\t"
-
- "pop %%"REG_BP" \n\t"
- : "+a"(counter)
- : "c"(filter), "d"(filterPos), "S"(src), "D"(dst)
- : "%"REG_b
- );
- }
- else
- {
- uint8_t *offset = src + filterSize;
- stride_t counter = -2 * dstW;
+ assert(filterSize % 4 == 0 && filterSize>0);
+ if(filterSize==4) // allways true for upscaling, sometimes for down too
+ {
+ stride_t counter= -2*dstW;
+ filter-= counter*2;
+ filterPos-= counter/2;
+ dst-= counter/2;
+ asm volatile(
+ "pxor %%mm7, %%mm7 \n\t"
+ "movq "MANGLE(w02)", %%mm6 \n\t"
+ "push %%"REG_BP" \n\t" // we use 7 regs here ...
+ "mov %%"REG_a", %%"REG_BP" \n\t"
+ ASMALIGN16
+ "1: \n\t"
+ "movzwl (%2, %%"REG_BP"), %%eax \n\t"
+ "movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
+ "movq (%1, %%"REG_BP", 4), %%mm1\n\t"
+ "movq 8(%1, %%"REG_BP", 4), %%mm3\n\t"
+ "movd (%3, %%"REG_a"), %%mm0 \n\t"
+ "movd (%3, %%"REG_b"), %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm0 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "pmaddwd %%mm1, %%mm0 \n\t"
+ "pmaddwd %%mm2, %%mm3 \n\t"
+ "psrad $8, %%mm0 \n\t"
+ "psrad $8, %%mm3 \n\t"
+ "packssdw %%mm3, %%mm0 \n\t"
+ "pmaddwd %%mm6, %%mm0 \n\t"
+ "packssdw %%mm0, %%mm0 \n\t"
+ "movd %%mm0, (%4, %%"REG_BP") \n\t"
+ "add $4, %%"REG_BP" \n\t"
+ " jnc 1b \n\t"
+
+ "pop %%"REG_BP" \n\t"
+ : "+a" (counter)
+ : "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
+ : "%"REG_b
+ );
+ }
+ else if(filterSize==8)
+ {
+ stride_t counter= -2*dstW;
+ filter-= counter*4;
+ filterPos-= counter/2;
+ dst-= counter/2;
+ asm volatile(
+ "pxor %%mm7, %%mm7 \n\t"
+ "movq "MANGLE(w02)", %%mm6 \n\t"
+ "push %%"REG_BP" \n\t" // we use 7 regs here ...
+ "mov %%"REG_a", %%"REG_BP" \n\t"
+ ASMALIGN16
+ "1: \n\t"
+ "movzwl (%2, %%"REG_BP"), %%eax \n\t"
+ "movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
+ "movq (%1, %%"REG_BP", 8), %%mm1\n\t"
+ "movq 16(%1, %%"REG_BP", 8), %%mm3\n\t"
+ "movd (%3, %%"REG_a"), %%mm0 \n\t"
+ "movd (%3, %%"REG_b"), %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm0 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "pmaddwd %%mm1, %%mm0 \n\t"
+ "pmaddwd %%mm2, %%mm3 \n\t"
+
+ "movq 8(%1, %%"REG_BP", 8), %%mm1\n\t"
+ "movq 24(%1, %%"REG_BP", 8), %%mm5\n\t"
+ "movd 4(%3, %%"REG_a"), %%mm4 \n\t"
+ "movd 4(%3, %%"REG_b"), %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm4 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "pmaddwd %%mm1, %%mm4 \n\t"
+ "pmaddwd %%mm2, %%mm5 \n\t"
+ "paddd %%mm4, %%mm0 \n\t"
+ "paddd %%mm5, %%mm3 \n\t"
+
+ "psrad $8, %%mm0 \n\t"
+ "psrad $8, %%mm3 \n\t"
+ "packssdw %%mm3, %%mm0 \n\t"
+ "pmaddwd %%mm6, %%mm0 \n\t"
+ "packssdw %%mm0, %%mm0 \n\t"
+ "movd %%mm0, (%4, %%"REG_BP") \n\t"
+ "add $4, %%"REG_BP" \n\t"
+ " jnc 1b \n\t"
+
+ "pop %%"REG_BP" \n\t"
+ : "+a" (counter)
+ : "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
+ : "%"REG_b
+ );
+ }
+ else
+ {
+ uint8_t *offset = src+filterSize;
+ stride_t counter= -2*dstW;
// filter-= counter*filterSize/2;
- filterPos -= counter / 2;
- dst -= counter / 2;
- asm volatile(
- "pxor %%mm7, %%mm7 \n\t"
- "movq "MANGLE(w02)", %%mm6 \n\t"
- ASMALIGN16
- "1: \n\t"
- "mov %2, %%"REG_c" \n\t"
- "movzwl (%%"REG_c", %0), %%eax \n\t"
- "movzwl 2(%%"REG_c", %0), %%ebx \n\t"
- "mov %5, %%"REG_c" \n\t"
- "pxor %%mm4, %%mm4 \n\t"
- "pxor %%mm5, %%mm5 \n\t"
- "2: \n\t"
- "movq (%1), %%mm1 \n\t"
- "movq (%1, %6), %%mm3 \n\t"
- "movd (%%"REG_c", %%"REG_a"), %%mm0\n\t"
- "movd (%%"REG_c", %%"REG_b"), %%mm2\n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "pmaddwd %%mm1, %%mm0 \n\t"
- "pmaddwd %%mm2, %%mm3 \n\t"
- "paddd %%mm3, %%mm5 \n\t"
- "paddd %%mm0, %%mm4 \n\t"
- "add $8, %1 \n\t"
- "add $4, %%"REG_c" \n\t"
- "cmp %4, %%"REG_c" \n\t"
- " jb 2b \n\t"
- "add %6, %1 \n\t"
- "psrad $8, %%mm4 \n\t"
- "psrad $8, %%mm5 \n\t"
- "packssdw %%mm5, %%mm4 \n\t"
- "pmaddwd %%mm6, %%mm4 \n\t"
- "packssdw %%mm4, %%mm4 \n\t"
- "mov %3, %%"REG_a" \n\t"
- "movd %%mm4, (%%"REG_a", %0) \n\t"
- "add $4, %0 \n\t"
- " jnc 1b \n\t"
-
- : "+r"(counter), "+r"(filter)
- : "m"(filterPos), "m"(dst), "m"(offset),
- "m"(src), "r"(filterSize*2)
- : "%"REG_b, "%"REG_a, "%"REG_c
- );
- }
+ filterPos-= counter/2;
+ dst-= counter/2;
+ asm volatile(
+ "pxor %%mm7, %%mm7 \n\t"
+ "movq "MANGLE(w02)", %%mm6 \n\t"
+ ASMALIGN16
+ "1: \n\t"
+ "mov %2, %%"REG_c" \n\t"
+ "movzwl (%%"REG_c", %0), %%eax \n\t"
+ "movzwl 2(%%"REG_c", %0), %%ebx \n\t"
+ "mov %5, %%"REG_c" \n\t"
+ "pxor %%mm4, %%mm4 \n\t"
+ "pxor %%mm5, %%mm5 \n\t"
+ "2: \n\t"
+ "movq (%1), %%mm1 \n\t"
+ "movq (%1, %6), %%mm3 \n\t"
+ "movd (%%"REG_c", %%"REG_a"), %%mm0\n\t"
+ "movd (%%"REG_c", %%"REG_b"), %%mm2\n\t"
+ "punpcklbw %%mm7, %%mm0 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "pmaddwd %%mm1, %%mm0 \n\t"
+ "pmaddwd %%mm2, %%mm3 \n\t"
+ "paddd %%mm3, %%mm5 \n\t"
+ "paddd %%mm0, %%mm4 \n\t"
+ "add $8, %1 \n\t"
+ "add $4, %%"REG_c" \n\t"
+ "cmp %4, %%"REG_c" \n\t"
+ " jb 2b \n\t"
+ "add %6, %1 \n\t"
+ "psrad $8, %%mm4 \n\t"
+ "psrad $8, %%mm5 \n\t"
+ "packssdw %%mm5, %%mm4 \n\t"
+ "pmaddwd %%mm6, %%mm4 \n\t"
+ "packssdw %%mm4, %%mm4 \n\t"
+ "mov %3, %%"REG_a" \n\t"
+ "movd %%mm4, (%%"REG_a", %0) \n\t"
+ "add $4, %0 \n\t"
+ " jnc 1b \n\t"
+
+ : "+r" (counter), "+r" (filter)
+ : "m" (filterPos), "m" (dst), "m"(offset),
+ "m" (src), "r" (filterSize*2)
+ : "%"REG_b, "%"REG_a, "%"REG_c
+ );
+ }
#else
#ifdef HAVE_ALTIVEC
- hScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize);
+ hScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize);
#else
- int i;
- for(i = 0; i < dstW; i++)
- {
- int j;
- int srcPos = filterPos[i];
- int val = 0;
+ int i;
+ for(i=0; i<dstW; i++)
+ {
+ int j;
+ int srcPos= filterPos[i];
+ int val=0;
// printf("filterPos: %d\n", filterPos[i]);
- for(j = 0; j < filterSize; j++)
- {
+ for(j=0; j<filterSize; j++)
+ {
// printf("filter: %d, src: %d\n", filter[i], src[srcPos + j]);
- val += ((int)src[srcPos + j]) * filter[filterSize*i + j];
- }
+ val += ((int)src[srcPos + j])*filter[filterSize*i + j];
+ }
// filter += hFilterSize;
- dst[i] = FFMIN(FFMAX(0, val >> 7), (1 << 15) - 1); // the cubic equation does overflow ...
+ dst[i] = FFMIN(FFMAX(0, val>>7), (1<<15)-1); // the cubic equation does overflow ...
// dst[i] = val>>7;
- }
+ }
#endif
#endif
- }
- // *** horizontal scale Y line to temp buffer
- static inline void RENAME(hyscale)(uint16_t * dst, long dstWidth, uint8_t * src, int srcW, int xInc,
- int flags, int canMMX2BeUsed, int16_t * hLumFilter,
- int16_t * hLumFilterPos, int hLumFilterSize, void * funnyYCode,
- int srcFormat, uint8_t * formatConvBuffer, int16_t * mmx2Filter,
- int32_t * mmx2FilterPos)
- {
- if(srcFormat == IMGFMT_YUY2 || srcFormat == IMGFMT_YVYU)
- {
- RENAME(yuy2ToY)(formatConvBuffer, src, srcW);
- src = formatConvBuffer;
- }
- else if(srcFormat == IMGFMT_UYVY || srcFormat == IMGFMT_VYUY)
- {
- RENAME(uyvyToY)(formatConvBuffer, src, srcW);
- src = formatConvBuffer;
- }
- else if(srcFormat == IMGFMT_BGR32)
- {
- RENAME(bgr32ToY)(formatConvBuffer, src, srcW);
- src = formatConvBuffer;
- }
- else if(srcFormat == IMGFMT_BGR24)
- {
- RENAME(bgr24ToY)(formatConvBuffer, src, srcW);
- src = formatConvBuffer;
- }
- else if(srcFormat == IMGFMT_BGR16)
- {
- RENAME(bgr16ToY)(formatConvBuffer, src, srcW);
- src = formatConvBuffer;
- }
- else if(srcFormat == IMGFMT_BGR15)
- {
- RENAME(bgr15ToY)(formatConvBuffer, src, srcW);
- src = formatConvBuffer;
- }
- else if(srcFormat == IMGFMT_RGB32)
- {
- RENAME(rgb32ToY)(formatConvBuffer, src, srcW);
- src = formatConvBuffer;
- }
- else if(srcFormat == IMGFMT_RGB24)
- {
- RENAME(rgb24ToY)(formatConvBuffer, src, srcW);
- src = formatConvBuffer;
- }
- else if(srcFormat == IMGFMT_RGB16)
- {
- RENAME(rgb16ToY)(formatConvBuffer, src, srcW);
- src = formatConvBuffer;
- }
- else if(srcFormat == IMGFMT_RGB15)
- {
- RENAME(rgb15ToY)(formatConvBuffer, src, srcW);
- src = formatConvBuffer;
- }
+}
+ // *** horizontal scale Y line to temp buffer
+static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, int srcW, int xInc,
+ int flags, int canMMX2BeUsed, int16_t *hLumFilter,
+ int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode,
+ int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
+ int32_t *mmx2FilterPos)
+{
+ if(srcFormat==IMGFMT_YUY2 || srcFormat==IMGFMT_YVYU)
+ {
+ RENAME(yuy2ToY)(formatConvBuffer, src, srcW);
+ src= formatConvBuffer;
+ }
+ else if(srcFormat==IMGFMT_UYVY || srcFormat==IMGFMT_VYUY)
+ {
+ RENAME(uyvyToY)(formatConvBuffer, src, srcW);
+ src= formatConvBuffer;
+ }
+ else if(srcFormat==IMGFMT_BGR32)
+ {
+ RENAME(bgr32ToY)(formatConvBuffer, src, srcW);
+ src= formatConvBuffer;
+ }
+ else if(srcFormat==IMGFMT_BGR24)
+ {
+ RENAME(bgr24ToY)(formatConvBuffer, src, srcW);
+ src= formatConvBuffer;
+ }
+ else if(srcFormat==IMGFMT_BGR16)
+ {
+ RENAME(bgr16ToY)(formatConvBuffer, src, srcW);
+ src= formatConvBuffer;
+ }
+ else if(srcFormat==IMGFMT_BGR15)
+ {
+ RENAME(bgr15ToY)(formatConvBuffer, src, srcW);
+ src= formatConvBuffer;
+ }
+ else if(srcFormat==IMGFMT_RGB32)
+ {
+ RENAME(rgb32ToY)(formatConvBuffer, src, srcW);
+ src= formatConvBuffer;
+ }
+ else if(srcFormat==IMGFMT_RGB24)
+ {
+ RENAME(rgb24ToY)(formatConvBuffer, src, srcW);
+ src= formatConvBuffer;
+ }
+ else if(srcFormat==IMGFMT_RGB16)
+ {
+ RENAME(rgb16ToY)(formatConvBuffer, src, srcW);
+ src= formatConvBuffer;
+ }
+ else if(srcFormat==IMGFMT_RGB15)
+ {
+ RENAME(rgb15ToY)(formatConvBuffer, src, srcW);
+ src= formatConvBuffer;
+ }
#if HAVE_MMX
- // use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
- if(!(flags & SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
+ // use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
+ if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
- if(!(flags & SWS_FAST_BILINEAR))
+ if(!(flags&SWS_FAST_BILINEAR))
#endif
- {
- RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
- }
- else // Fast Bilinear upscale / crap downscale
- {
+ {
+ RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
+ }
+ else // Fast Bilinear upscale / crap downscale
+ {
#if ARCH_X86_32 || ARCH_X86_64
#if HAVE_MMX2
- int i;
- if(canMMX2BeUsed)
- {
- asm volatile(
- "pxor %%mm7, %%mm7 \n\t"
- "mov %0, %%"REG_c" \n\t"
- "mov %1, %%"REG_D" \n\t"
- "mov %2, %%"REG_d" \n\t"
- "mov %3, %%"REG_b" \n\t"
- "xor %%"REG_a", %%"REG_a" \n\t" // i
- PREFETCH" (%%"REG_c") \n\t"
- PREFETCH" 32(%%"REG_c") \n\t"
- PREFETCH" 64(%%"REG_c") \n\t"
+ int i;
+ if(canMMX2BeUsed)
+ {
+ asm volatile(
+ "pxor %%mm7, %%mm7 \n\t"
+ "mov %0, %%"REG_c" \n\t"
+ "mov %1, %%"REG_D" \n\t"
+ "mov %2, %%"REG_d" \n\t"
+ "mov %3, %%"REG_b" \n\t"
+ "xor %%"REG_a", %%"REG_a" \n\t" // i
+ PREFETCH" (%%"REG_c") \n\t"
+ PREFETCH" 32(%%"REG_c") \n\t"
+ PREFETCH" 64(%%"REG_c") \n\t"
#if ARCH_X86_64
@@ -2575,7 +2557,7 @@ static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
-
+
#else
#define FUNNY_Y_CODE \
@@ -2584,209 +2566,209 @@ static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *
"addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
-
+
#endif
- FUNNY_Y_CODE
- FUNNY_Y_CODE
- FUNNY_Y_CODE
- FUNNY_Y_CODE
- FUNNY_Y_CODE
- FUNNY_Y_CODE
- FUNNY_Y_CODE
- FUNNY_Y_CODE
-
- :: "m"(src), "m"(dst), "m"(mmx2Filter), "m"(mmx2FilterPos),
- "m"(funnyYCode)
- : "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
- );
- for(i = dstWidth - 1; (i * xInc) >> 16 >= srcW - 1; i--) dst[i] = src[srcW-1] * 128;
- }
- else
- {
+FUNNY_Y_CODE
+FUNNY_Y_CODE
+FUNNY_Y_CODE
+FUNNY_Y_CODE
+FUNNY_Y_CODE
+FUNNY_Y_CODE
+FUNNY_Y_CODE
+FUNNY_Y_CODE
+
+ :: "m" (src), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
+ "m" (funnyYCode)
+ : "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
+ );
+ for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128;
+ }
+ else
+ {
#endif
- long xInc_shr16 = xInc >> 16;
- uint16_t xInc_mask = xInc & 0xffff;
- //NO MMX just normal asm ...
- asm volatile(
- "xor %%"REG_a", %%"REG_a" \n\t" // i
- "xor %%"REG_b", %%"REG_b" \n\t" // xx
- "xorl %%ecx, %%ecx \n\t" // 2*xalpha
- ASMALIGN16
- "1: \n\t"
- "movzbl (%0, %%"REG_b"), %%edi \n\t" //src[xx]
- "movzbl 1(%0, %%"REG_b"), %%esi \n\t" //src[xx+1]
- "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
- "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
- "shll $16, %%edi \n\t"
- "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
- "mov %1, %%"REG_D" \n\t"
- "shrl $9, %%esi \n\t"
- "movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
- "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
- "adc %3, %%"REG_b" \n\t" //xx+= xInc>>8 + carry
-
- "movzbl (%0, %%"REG_b"), %%edi \n\t" //src[xx]
- "movzbl 1(%0, %%"REG_b"), %%esi \n\t" //src[xx+1]
- "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
- "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
- "shll $16, %%edi \n\t"
- "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
- "mov %1, %%"REG_D" \n\t"
- "shrl $9, %%esi \n\t"
- "movw %%si, 2(%%"REG_D", %%"REG_a", 2)\n\t"
- "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
- "adc %3, %%"REG_b" \n\t" //xx+= xInc>>8 + carry
-
-
- "add $2, %%"REG_a" \n\t"
- "cmp %2, %%"REG_a" \n\t"
- " jb 1b \n\t"
-
-
- :: "r"(src), "m"(dst), "m"(dstWidth), "m"(xInc_shr16), "m"(xInc_mask)
- : "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
- );
+ long xInc_shr16 = xInc >> 16;
+ uint16_t xInc_mask = xInc & 0xffff;
+ //NO MMX just normal asm ...
+ asm volatile(
+ "xor %%"REG_a", %%"REG_a" \n\t" // i
+ "xor %%"REG_b", %%"REG_b" \n\t" // xx
+ "xorl %%ecx, %%ecx \n\t" // 2*xalpha
+ ASMALIGN16
+ "1: \n\t"
+ "movzbl (%0, %%"REG_b"), %%edi \n\t" //src[xx]
+ "movzbl 1(%0, %%"REG_b"), %%esi \n\t" //src[xx+1]
+ "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
+ "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
+ "shll $16, %%edi \n\t"
+ "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
+ "mov %1, %%"REG_D" \n\t"
+ "shrl $9, %%esi \n\t"
+ "movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
+ "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
+ "adc %3, %%"REG_b" \n\t" //xx+= xInc>>8 + carry
+
+ "movzbl (%0, %%"REG_b"), %%edi \n\t" //src[xx]
+ "movzbl 1(%0, %%"REG_b"), %%esi \n\t" //src[xx+1]
+ "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
+ "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
+ "shll $16, %%edi \n\t"
+ "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
+ "mov %1, %%"REG_D" \n\t"
+ "shrl $9, %%esi \n\t"
+ "movw %%si, 2(%%"REG_D", %%"REG_a", 2)\n\t"
+ "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
+ "adc %3, %%"REG_b" \n\t" //xx+= xInc>>8 + carry
+
+
+ "add $2, %%"REG_a" \n\t"
+ "cmp %2, %%"REG_a" \n\t"
+ " jb 1b \n\t"
+
+
+ :: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask)
+ : "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
+ );
#if HAVE_MMX2
- } //if MMX2 can't be used
+ } //if MMX2 can't be used
#endif
#else
- int i;
- unsigned int xpos = 0;
- for(i = 0; i < dstWidth; i++)
- {
- register unsigned int xx = xpos >> 16;
- register unsigned int xalpha = (xpos & 0xFFFF) >> 9;
- dst[i] = (src[xx] << 7) + (src[xx+1] - src[xx]) * xalpha;
- xpos += xInc;
- }
+ int i;
+ unsigned int xpos=0;
+ for(i=0;i<dstWidth;i++)
+ {
+ register unsigned int xx=xpos>>16;
+ register unsigned int xalpha=(xpos&0xFFFF)>>9;
+ dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
+ xpos+=xInc;
+ }
#endif
- }
- }
+ }
+}
- inline static void RENAME(hcscale)(uint16_t * dst, long dstWidth, uint8_t * src1, uint8_t * src2,
- int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t * hChrFilter,
- int16_t * hChrFilterPos, int hChrFilterSize, void * funnyUVCode,
- int srcFormat, uint8_t * formatConvBuffer, int16_t * mmx2Filter,
- int32_t * mmx2FilterPos)
- {
- if(srcFormat == IMGFMT_YUY2)
- {
- RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_UYVY)
- {
- RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_YVYU)
- {
- RENAME(yuy2ToUV)(formatConvBuffer + 2048, formatConvBuffer, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_VYUY)
- {
- RENAME(uyvyToUV)(formatConvBuffer + 2048, formatConvBuffer, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_BGR32)
- {
- RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_BGR24)
- {
- RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_BGR16)
- {
- RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_BGR15)
- {
- RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_RGB32)
- {
- RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_RGB24)
- {
- RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_RGB16)
- {
- RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_RGB15)
- {
- RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_NV12)
- {
- RENAME(nv12ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(srcFormat == IMGFMT_NV21)
- {
- RENAME(nv21ToUV)(formatConvBuffer, formatConvBuffer + 2048, src1, src2, srcW);
- src1 = formatConvBuffer;
- src2 = formatConvBuffer + 2048;
- }
- else if(isGray(srcFormat))
- {
- return;
- }
+inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,
+ int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
+ int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
+ int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
+ int32_t *mmx2FilterPos)
+{
+ if(srcFormat==IMGFMT_YUY2)
+ {
+ RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_UYVY)
+ {
+ RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_YVYU)
+ {
+ RENAME(yuy2ToUV)(formatConvBuffer+2048, formatConvBuffer, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_VYUY)
+ {
+ RENAME(uyvyToUV)(formatConvBuffer+2048, formatConvBuffer, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_BGR32)
+ {
+ RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_BGR24)
+ {
+ RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_BGR16)
+ {
+ RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_BGR15)
+ {
+ RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_RGB32)
+ {
+ RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_RGB24)
+ {
+ RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_RGB16)
+ {
+ RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_RGB15)
+ {
+ RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_NV12)
+ {
+ RENAME(nv12ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(srcFormat==IMGFMT_NV21)
+ {
+ RENAME(nv21ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
+ else if(isGray(srcFormat))
+ {
+ return;
+ }
#if HAVE_MMX
- // use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
- if(!(flags & SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
+ // use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
+ if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
- if(!(flags & SWS_FAST_BILINEAR))
+ if(!(flags&SWS_FAST_BILINEAR))
#endif
- {
- RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
- if(src2) // NV12 does not have this.
- RENAME(hScale)(dst + 2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
- }
- else // Fast Bilinear upscale / crap downscale
- {
+ {
+ RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
+ if (src2) // NV12 does not have this.
+ RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
+ }
+ else // Fast Bilinear upscale / crap downscale
+ {
#if ARCH_X86_32 || ARCH_X86_64
#if HAVE_MMX2
- int i;
- if(canMMX2BeUsed)
- {
- asm volatile(
- "pxor %%mm7, %%mm7 \n\t"
- "mov %0, %%"REG_c" \n\t"
- "mov %1, %%"REG_D" \n\t"
- "mov %2, %%"REG_d" \n\t"
- "mov %3, %%"REG_b" \n\t"
- "xor %%"REG_a", %%"REG_a" \n\t" // i
- PREFETCH" (%%"REG_c") \n\t"
- PREFETCH" 32(%%"REG_c") \n\t"
- PREFETCH" 64(%%"REG_c") \n\t"
+ int i;
+ if(canMMX2BeUsed)
+ {
+ asm volatile(
+ "pxor %%mm7, %%mm7 \n\t"
+ "mov %0, %%"REG_c" \n\t"
+ "mov %1, %%"REG_D" \n\t"
+ "mov %2, %%"REG_d" \n\t"
+ "mov %3, %%"REG_b" \n\t"
+ "xor %%"REG_a", %%"REG_a" \n\t" // i
+ PREFETCH" (%%"REG_c") \n\t"
+ PREFETCH" 32(%%"REG_c") \n\t"
+ PREFETCH" 64(%%"REG_c") \n\t"
#if ARCH_X86_64
@@ -2797,7 +2779,7 @@ static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
-
+
#else
#define FUNNY_UV_CODE \
@@ -2806,517 +2788,503 @@ static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *
"addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
-
+
#endif
- FUNNY_UV_CODE
- FUNNY_UV_CODE
- FUNNY_UV_CODE
- FUNNY_UV_CODE
- "xor %%"REG_a", %%"REG_a" \n\t" // i
- "mov %5, %%"REG_c" \n\t" // src
- "mov %1, %%"REG_D" \n\t" // buf1
- "add $4096, %%"REG_D" \n\t"
- PREFETCH" (%%"REG_c") \n\t"
- PREFETCH" 32(%%"REG_c") \n\t"
- PREFETCH" 64(%%"REG_c") \n\t"
-
- FUNNY_UV_CODE
- FUNNY_UV_CODE
- FUNNY_UV_CODE
- FUNNY_UV_CODE
-
- :: "m"(src1), "m"(dst), "m"(mmx2Filter), "m"(mmx2FilterPos),
- "m"(funnyUVCode), "m"(src2)
- : "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
- );
- for(i = dstWidth - 1; (i * xInc) >> 16 >= srcW - 1; i--)
- {
+FUNNY_UV_CODE
+FUNNY_UV_CODE
+FUNNY_UV_CODE
+FUNNY_UV_CODE
+ "xor %%"REG_a", %%"REG_a" \n\t" // i
+ "mov %5, %%"REG_c" \n\t" // src
+ "mov %1, %%"REG_D" \n\t" // buf1
+ "add $4096, %%"REG_D" \n\t"
+ PREFETCH" (%%"REG_c") \n\t"
+ PREFETCH" 32(%%"REG_c") \n\t"
+ PREFETCH" 64(%%"REG_c") \n\t"
+
+FUNNY_UV_CODE
+FUNNY_UV_CODE
+FUNNY_UV_CODE
+FUNNY_UV_CODE
+
+ :: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
+ "m" (funnyUVCode), "m" (src2)
+ : "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
+ );
+ for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
+ {
// printf("%d %d %d\n", dstWidth, i, srcW);
- dst[i] = src1[srcW-1] * 128;
- dst[i+2048] = src2[srcW-1] * 128;
- }
- }
- else
- {
+ dst[i] = src1[srcW-1]*128;
+ dst[i+2048] = src2[srcW-1]*128;
+ }
+ }
+ else
+ {
#endif
- long xInc_shr16 = (long)(xInc >> 16);
- uint16_t xInc_mask = xInc & 0xffff;
- asm volatile(
- "xor %%"REG_a", %%"REG_a" \n\t" // i
- "xor %%"REG_b", %%"REG_b" \n\t" // xx
- "xorl %%ecx, %%ecx \n\t" // 2*xalpha
- ASMALIGN16
- "1: \n\t"
- "mov %0, %%"REG_S" \n\t"
- "movzbl (%%"REG_S", %%"REG_b"), %%edi \n\t" //src[xx]
- "movzbl 1(%%"REG_S", %%"REG_b"), %%esi \n\t" //src[xx+1]
- "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
- "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
- "shll $16, %%edi \n\t"
- "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
- "mov %1, %%"REG_D" \n\t"
- "shrl $9, %%esi \n\t"
- "movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
-
- "movzbl (%5, %%"REG_b"), %%edi \n\t" //src[xx]
- "movzbl 1(%5, %%"REG_b"), %%esi \n\t" //src[xx+1]
- "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
- "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
- "shll $16, %%edi \n\t"
- "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
- "mov %1, %%"REG_D" \n\t"
- "shrl $9, %%esi \n\t"
- "movw %%si, 4096(%%"REG_D", %%"REG_a", 2)\n\t"
-
- "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
- "adc %3, %%"REG_b" \n\t" //xx+= xInc>>8 + carry
- "add $1, %%"REG_a" \n\t"
- "cmp %2, %%"REG_a" \n\t"
- " jb 1b \n\t"
-
- /* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here,
- which is needed to support GCC 4.0. */
+ long xInc_shr16 = (long) (xInc >> 16);
+ uint16_t xInc_mask = xInc & 0xffff;
+ asm volatile(
+ "xor %%"REG_a", %%"REG_a" \n\t" // i
+ "xor %%"REG_b", %%"REG_b" \n\t" // xx
+ "xorl %%ecx, %%ecx \n\t" // 2*xalpha
+ ASMALIGN16
+ "1: \n\t"
+ "mov %0, %%"REG_S" \n\t"
+ "movzbl (%%"REG_S", %%"REG_b"), %%edi \n\t" //src[xx]
+ "movzbl 1(%%"REG_S", %%"REG_b"), %%esi \n\t" //src[xx+1]
+ "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
+ "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
+ "shll $16, %%edi \n\t"
+ "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
+ "mov %1, %%"REG_D" \n\t"
+ "shrl $9, %%esi \n\t"
+ "movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
+
+ "movzbl (%5, %%"REG_b"), %%edi \n\t" //src[xx]
+ "movzbl 1(%5, %%"REG_b"), %%esi \n\t" //src[xx+1]
+ "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
+ "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
+ "shll $16, %%edi \n\t"
+ "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
+ "mov %1, %%"REG_D" \n\t"
+ "shrl $9, %%esi \n\t"
+ "movw %%si, 4096(%%"REG_D", %%"REG_a", 2)\n\t"
+
+ "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
+ "adc %3, %%"REG_b" \n\t" //xx+= xInc>>8 + carry
+ "add $1, %%"REG_a" \n\t"
+ "cmp %2, %%"REG_a" \n\t"
+ " jb 1b \n\t"
+
+/* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here,
+ which is needed to support GCC 4.0. */
#if ARCH_X86_64 && ((__GNUC__ > 3) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4))
- :: "m"(src1), "m"(dst), "g"((stride_t)dstWidth), "m"(xInc_shr16), "m"(xInc_mask),
+ :: "m" (src1), "m" (dst), "g" ((stride_t)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
- :: "m"(src1), "m"(dst), "m"((long)dstWidth), "m"(xInc_shr16), "m"(xInc_mask),
+ :: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
- "r"(src2)
- : "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
- );
+ "r" (src2)
+ : "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
+ );
#if HAVE_MMX2
- } //if MMX2 can't be used
+ } //if MMX2 can't be used
#endif
#else
- int i;
- unsigned int xpos = 0;
- for(i = 0; i < dstWidth; i++)
- {
- register unsigned int xx = xpos >> 16;
- register unsigned int xalpha = (xpos & 0xFFFF) >> 9;
- dst[i] = (src1[xx] * (xalpha ^ 127) + src1[xx+1] * xalpha);
- dst[i+2048] = (src2[xx] * (xalpha ^ 127) + src2[xx+1] * xalpha);
- /* slower
- dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
- dst[i+2048]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
- */
- xpos += xInc;
- }
+ int i;
+ unsigned int xpos=0;
+ for(i=0;i<dstWidth;i++)
+ {
+ register unsigned int xx=xpos>>16;
+ register unsigned int xalpha=(xpos&0xFFFF)>>9;
+ dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
+ dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
+/* slower
+ dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
+ dst[i+2048]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
+*/
+ xpos+=xInc;
+ }
#endif
- }
- }
+ }
+}
- static int RENAME(swScaleI)(SwsContext * c, uint8_t * src[], stride_t srcStride[], int srcSliceY,
- int srcSliceH, uint8_t * dst[], stride_t dstStride[], int dstYstart, int dstYend)
- {
-
- /* load a few things into local vars to make the code more readable? and faster */
- const int srcW = c->srcW;
- const int dstW = c->dstW;
- const int dstH = c->dstH;
- const int chrDstW = c->chrDstW;
- const int chrSrcW = c->chrSrcW;
- const int lumXInc = c->lumXInc;
- const int chrXInc = c->chrXInc;
- const int dstFormat = c->dstFormat;
- const int srcFormat = c->srcFormat;
- const SwsParams params = c->params;
- const int canMMX2BeUsed = c->canMMX2BeUsed;
- int16_t *vLumFilterPos = c->vLumFilterPos;
- int16_t *vChrFilterPos = c->vChrFilterPos;
- int16_t *hLumFilterPos = c->hLumFilterPos;
- int16_t *hChrFilterPos = c->hChrFilterPos;
- int16_t *vLumFilter = c->vLumFilter;
- int16_t *vChrFilter = c->vChrFilter;
- int16_t *hLumFilter = c->hLumFilter;
- int16_t *hChrFilter = c->hChrFilter;
- int32_t *lumMmxFilter = c->lumMmxFilter;
- int32_t *chrMmxFilter = c->chrMmxFilter;
- const int vLumFilterSize = c->vLumFilterSize;
- const int vChrFilterSize = c->vChrFilterSize;
- const int hLumFilterSize = c->hLumFilterSize;
- const int hChrFilterSize = c->hChrFilterSize;
- int16_t **lumPixBuf = c->lumPixBuf;
- int16_t **chrPixBuf = c->chrPixBuf;
- const int vLumBufSize = c->vLumBufSize;
- const int vChrBufSize = c->vChrBufSize;
- uint8_t *funnyYCode = c->funnyYCode;
- uint8_t *funnyUVCode = c->funnyUVCode;
- uint8_t *formatConvBuffer = c->formatConvBuffer;
- const int chrSrcSliceY = srcSliceY >> c->chrSrcVSubSample;
- const int chrSrcSliceH = -((-srcSliceH) >> c->chrSrcVSubSample);
- int lastDstY;
-
- /* vars which will change and which we need to store back in the context */
- int dstY = dstYstart;
- int lumBufIndex = c->lumBufIndex;
- int chrBufIndex = c->chrBufIndex;
- int lastInLumBuf = c->lastInLumBuf;
- int lastInChrBuf = c->lastInChrBuf;
-
- if(isPacked(c->srcFormat))
- {
- src[0] =
- src[1] =
- src[2] = src[0];
- srcStride[0] =
- srcStride[1] =
- srcStride[2] = srcStride[0];
- }
- srcStride[1] <<= c->vChrDrop;
- srcStride[2] <<= c->vChrDrop;
+static int RENAME(swScaleI)(SwsContext *c, uint8_t* src[], stride_t srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], stride_t dstStride[], int dstYstart, int dstYend){
+
+ /* load a few things into local vars to make the code more readable? and faster */
+ const int srcW= c->srcW;
+ const int dstW= c->dstW;
+ const int dstH= c->dstH;
+ const int chrDstW= c->chrDstW;
+ const int chrSrcW= c->chrSrcW;
+ const int lumXInc= c->lumXInc;
+ const int chrXInc= c->chrXInc;
+ const int dstFormat= c->dstFormat;
+ const int srcFormat= c->srcFormat;
+ const SwsParams params= c->params;
+ const int canMMX2BeUsed= c->canMMX2BeUsed;
+ int16_t *vLumFilterPos= c->vLumFilterPos;
+ int16_t *vChrFilterPos= c->vChrFilterPos;
+ int16_t *hLumFilterPos= c->hLumFilterPos;
+ int16_t *hChrFilterPos= c->hChrFilterPos;
+ int16_t *vLumFilter= c->vLumFilter;
+ int16_t *vChrFilter= c->vChrFilter;
+ int16_t *hLumFilter= c->hLumFilter;
+ int16_t *hChrFilter= c->hChrFilter;
+ int32_t *lumMmxFilter= c->lumMmxFilter;
+ int32_t *chrMmxFilter= c->chrMmxFilter;
+ const int vLumFilterSize= c->vLumFilterSize;
+ const int vChrFilterSize= c->vChrFilterSize;
+ const int hLumFilterSize= c->hLumFilterSize;
+ const int hChrFilterSize= c->hChrFilterSize;
+ int16_t **lumPixBuf= c->lumPixBuf;
+ int16_t **chrPixBuf= c->chrPixBuf;
+ const int vLumBufSize= c->vLumBufSize;
+ const int vChrBufSize= c->vChrBufSize;
+ uint8_t *funnyYCode= c->funnyYCode;
+ uint8_t *funnyUVCode= c->funnyUVCode;
+ uint8_t *formatConvBuffer= c->formatConvBuffer;
+ const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
+ const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
+ int lastDstY;
+
+ /* vars which will change and which we need to store back in the context */
+ int dstY= dstYstart;
+ int lumBufIndex= c->lumBufIndex;
+ int chrBufIndex= c->chrBufIndex;
+ int lastInLumBuf= c->lastInLumBuf;
+ int lastInChrBuf= c->lastInChrBuf;
+
+ if(isPacked(c->srcFormat)){
+ src[0]=
+ src[1]=
+ src[2]= src[0];
+ srcStride[0]=
+ srcStride[1]=
+ srcStride[2]= srcStride[0];
+ }
+ srcStride[1]<<= c->vChrDrop;
+ srcStride[2]<<= c->vChrDrop;
// printf("swscale %X %X %X -> %X %X %X\n", (int)src[0], (int)src[1], (int)src[2],
// (int)dst[0], (int)dst[1], (int)dst[2]);
#if 0 //self test FIXME move to a vfilter or something
- {
- static volatile int i = 0;
- i++;
- if(srcFormat == IMGFMT_YV12 && i == 1 && srcSliceH >= c->srcH)
- selfTest(src, srcStride, c->srcW, c->srcH);
- i--;
- }
+{
+static volatile int i=0;
+i++;
+if(srcFormat==IMGFMT_YV12 && i==1 && srcSliceH>= c->srcH)
+ selfTest(src, srcStride, c->srcW, c->srcH);
+i--;
+}
#endif
//printf("sws Strides:%d %d %d -> %d %d %d\n", srcStride[0],srcStride[1],srcStride[2],
//dstStride[0],dstStride[1],dstStride[2]);
- if(dstStride[0] % 8 != 0 || dstStride[1] % 8 != 0 || dstStride[2] % 8 != 0)
- {
- static int firstTime = 1; //FIXME move this into the context perhaps
- if(params.debug & SWS_PRINT_INFO && firstTime)
- {
- MSG_WARN("SwScaler: Warning: dstStride is not aligned!\n"
- "SwScaler: ->cannot do aligned memory acesses anymore\n");
- firstTime = 0;
- }
- }
-
- /* Note the user might start scaling the picture in the middle so this will not get executed
- this is not really intended but works currently, so ppl might do it */
- if(srcSliceY == 0)
- {
- lumBufIndex = 0;
- chrBufIndex = 0;
- // dstY=0; moved to RENAME(swScale)
- lastInLumBuf = -1;
- lastInChrBuf = -1;
- }
- lastDstY = dstY;
-
- if(vLumFilterPos[dstYend] < srcSliceY || vLumFilterPos[dstYstart] > srcSliceY + srcSliceH)
- {
- goto ret0;
- }
-
- for(; dstY < dstYend; dstY++)
- {
- unsigned char *dest = dst[0] + dstStride[0] * dstY;
- const int chrDstY = dstY >> c->chrDstVSubSample;
- unsigned char *uDest = dst[1] + dstStride[1] * chrDstY;
- unsigned char *vDest = dst[2] + dstStride[2] * chrDstY;
-
- const int firstLumSrcY = vLumFilterPos[dstY]; //First line needed as input
- const int firstChrSrcY = vChrFilterPos[chrDstY]; //First line needed as input
- const int lastLumSrcY = firstLumSrcY + vLumFilterSize - 1; // Last line needed as input
- const int lastChrSrcY = firstChrSrcY + vChrFilterSize - 1; // Last line needed as input
+ if(dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0)
+ {
+ static int firstTime=1; //FIXME move this into the context perhaps
+ if(params.debug & SWS_PRINT_INFO && firstTime)
+ {
+ MSG_WARN("SwScaler: Warning: dstStride is not aligned!\n"
+ "SwScaler: ->cannot do aligned memory acesses anymore\n");
+ firstTime=0;
+ }
+ }
+
+ /* Note the user might start scaling the picture in the middle so this will not get executed
+ this is not really intended but works currently, so ppl might do it */
+ if(srcSliceY ==0){
+ lumBufIndex=0;
+ chrBufIndex=0;
+ // dstY=0; moved to RENAME(swScale)
+ lastInLumBuf= -1;
+ lastInChrBuf= -1;
+ }
+ lastDstY= dstY;
+
+ if(vLumFilterPos[dstYend]<srcSliceY || vLumFilterPos[dstYstart]>srcSliceY+srcSliceH){
+ goto ret0;
+ }
+
+ for(;dstY < dstYend; dstY++){
+ unsigned char *dest =dst[0]+dstStride[0]*dstY;
+ const int chrDstY= dstY>>c->chrDstVSubSample;
+ unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;
+ unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;
+
+ const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
+ const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
+ const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input
+ const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input
//printf("dstY:%d dstH:%d firstLumSrcY:%d lastInLumBuf:%d vLumBufSize: %d vChrBufSize: %d slice: %d %d vLumFilterSize: %d firstChrSrcY: %d vChrFilterSize: %d c->chrSrcVSubSample: %d\n",
// dstY, dstH, firstLumSrcY, lastInLumBuf, vLumBufSize, vChrBufSize, srcSliceY, srcSliceH, vLumFilterSize, firstChrSrcY, vChrFilterSize, c->chrSrcVSubSample);
- //handle holes (FAST_BILINEAR & weird filters)
- if(firstLumSrcY > lastInLumBuf) lastInLumBuf = firstLumSrcY - 1;
- if(firstChrSrcY > lastInChrBuf) lastInChrBuf = firstChrSrcY - 1;
+ //handle holes (FAST_BILINEAR & weird filters)
+ if(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
+ if(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
//printf("%d %d %d\n", firstChrSrcY, lastInChrBuf, vChrBufSize);
- ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1)
- ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1)
-
- // Do we have enough lines in this slice to output the dstY line
- if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH) >> c->chrSrcVSubSample))
- {
- //Do horizontal scaling
- while(lastInLumBuf < lastLumSrcY)
- {
- uint8_t *s = src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0];
- lumBufIndex++;
+ ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1)
+ ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1)
+
+ // Do we have enough lines in this slice to output the dstY line
+ if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample))
+ {
+ //Do horizontal scaling
+ while(lastInLumBuf < lastLumSrcY)
+ {
+ uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
+ lumBufIndex++;
// printf("%d %d %d %d\n", lumBufIndex, vLumBufSize, lastInLumBuf, lastLumSrcY);
- ASSERT(lumBufIndex < 2 * vLumBufSize)
- ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
- ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
+ ASSERT(lumBufIndex < 2*vLumBufSize)
+ ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
+ ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
// printf("%d %d\n", lumBufIndex, vLumBufSize);
- RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
- params.methodLuma.method, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
- funnyYCode, c->srcFormat, formatConvBuffer,
- c->lumMmx2Filter, c->lumMmx2FilterPos);
- lastInLumBuf++;
- }
- while(lastInChrBuf < lastChrSrcY)
- {
- uint8_t *src1 = src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1];
- uint8_t *src2 = src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2];
- chrBufIndex++;
- ASSERT(chrBufIndex < 2 * vChrBufSize)
- ASSERT(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH))
- ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
- //FIXME replace parameters through context struct (some at least)
-
- if(!(isGray(srcFormat) || isGray(dstFormat)))
- RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
- params.methodChroma.method, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
- funnyUVCode, c->srcFormat, formatConvBuffer,
- c->chrMmx2Filter, c->chrMmx2FilterPos);
- lastInChrBuf++;
- }
- //wrap buf index around to stay inside the ring buffer
- if(lumBufIndex >= vLumBufSize) lumBufIndex -= vLumBufSize;
- if(chrBufIndex >= vChrBufSize) chrBufIndex -= vChrBufSize;
- }
- else // not enough lines left in this slice -> load the rest in the buffer
- {
- /* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n",
- firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY,
- lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize,
- vChrBufSize, vLumBufSize);*/
-
- //Do horizontal scaling
- while(lastInLumBuf + 1 < srcSliceY + srcSliceH)
- {
- uint8_t *s = src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0];
- lumBufIndex++;
- ASSERT(lumBufIndex < 2 * vLumBufSize)
- ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
- ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
- RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
- params.methodLuma.method, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
- funnyYCode, c->srcFormat, formatConvBuffer,
- c->lumMmx2Filter, c->lumMmx2FilterPos);
- lastInLumBuf++;
- }
- while(lastInChrBuf + 1 < (chrSrcSliceY + chrSrcSliceH))
- {
- uint8_t *src1 = src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1];
- uint8_t *src2 = src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2];
- chrBufIndex++;
- ASSERT(chrBufIndex < 2 * vChrBufSize)
- ASSERT(lastInChrBuf + 1 - chrSrcSliceY < chrSrcSliceH)
- ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
-
- if(!(isGray(srcFormat) || isGray(dstFormat)))
- RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
- params.methodChroma.method, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
- funnyUVCode, c->srcFormat, formatConvBuffer,
- c->chrMmx2Filter, c->chrMmx2FilterPos);
- lastInChrBuf++;
- }
- //wrap buf index around to stay inside the ring buffer
- if(lumBufIndex >= vLumBufSize) lumBufIndex -= vLumBufSize;
- if(chrBufIndex >= vChrBufSize) chrBufIndex -= vChrBufSize;
- break; //we can't output a dstY line so let's try with the next slice
- }
+ RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
+ params.methodLuma.method, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
+ funnyYCode, c->srcFormat, formatConvBuffer,
+ c->lumMmx2Filter, c->lumMmx2FilterPos);
+ lastInLumBuf++;
+ }
+ while(lastInChrBuf < lastChrSrcY)
+ {
+ uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
+ uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
+ chrBufIndex++;
+ ASSERT(chrBufIndex < 2*vChrBufSize)
+ ASSERT(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH))
+ ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
+ //FIXME replace parameters through context struct (some at least)
+
+ if(!(isGray(srcFormat) || isGray(dstFormat)))
+ RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
+ params.methodChroma.method, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
+ funnyUVCode, c->srcFormat, formatConvBuffer,
+ c->chrMmx2Filter, c->chrMmx2FilterPos);
+ lastInChrBuf++;
+ }
+ //wrap buf index around to stay inside the ring buffer
+ if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;
+ if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;
+ }
+ else // not enough lines left in this slice -> load the rest in the buffer
+ {
+/* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n",
+ firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY,
+ lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize,
+ vChrBufSize, vLumBufSize);*/
+
+ //Do horizontal scaling
+ while(lastInLumBuf+1 < srcSliceY + srcSliceH)
+ {
+ uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
+ lumBufIndex++;
+ ASSERT(lumBufIndex < 2*vLumBufSize)
+ ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
+ ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
+ RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
+ params.methodLuma.method, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
+ funnyYCode, c->srcFormat, formatConvBuffer,
+ c->lumMmx2Filter, c->lumMmx2FilterPos);
+ lastInLumBuf++;
+ }
+ while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH))
+ {
+ uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
+ uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
+ chrBufIndex++;
+ ASSERT(chrBufIndex < 2*vChrBufSize)
+ ASSERT(lastInChrBuf + 1 - chrSrcSliceY < chrSrcSliceH)
+ ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
+
+ if(!(isGray(srcFormat) || isGray(dstFormat)))
+ RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
+ params.methodChroma.method, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
+ funnyUVCode, c->srcFormat, formatConvBuffer,
+ c->chrMmx2Filter, c->chrMmx2FilterPos);
+ lastInChrBuf++;
+ }
+ //wrap buf index around to stay inside the ring buffer
+ if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;
+ if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;
+ break; //we can't output a dstY line so let's try with the next slice
+ }
#if HAVE_MMX
- b5Dither = dither8[dstY&1];
- g6Dither = dither4[dstY&1];
- g5Dither = dither8[dstY&1];
- r5Dither = dither8[(dstY+1)&1];
+ b5Dither= dither8[dstY&1];
+ g6Dither= dither4[dstY&1];
+ g5Dither= dither8[dstY&1];
+ r5Dither= dither8[(dstY+1)&1];
#endif
- if(dstY < dstH - 2)
- {
- int16_t **lumSrcPtr = lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
- int16_t **chrSrcPtr = chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
+ if(dstY < dstH-2)
+ {
+ int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
+ int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
#if HAVE_MMX
- int i;
- if(params.subsampling & SWS_ACCURATE_RND)
- {
- int s = APCK_SIZE / 8;
- for(i = 0; i < vLumFilterSize; i += 2)
- {
- *(void**)&lumMmxFilter[s*i+0 ] = lumSrcPtr[i ];
- *(void**)&lumMmxFilter[s*i+APCK_PTR2/4 ] = lumSrcPtr[i+(vLumFilterSize>1)];
- lumMmxFilter[s*i+APCK_COEF/4 ] =
- lumMmxFilter[s*i+APCK_COEF/4+1] = vLumFilter[dstY*vLumFilterSize + i ]
- + (vLumFilterSize > 1 ? vLumFilter[dstY*vLumFilterSize + i + 1] << 16 : 0);
- }
- for(i = 0; i < vChrFilterSize; i += 2)
- {
- *(void**)&chrMmxFilter[s*i+0 ] = chrSrcPtr[i ];
- *(void**)&chrMmxFilter[s*i+APCK_PTR2/4 ] = chrSrcPtr[i+(vChrFilterSize>1)];
- chrMmxFilter[s*i+APCK_COEF/4 ] =
- chrMmxFilter[s*i+APCK_COEF/4+1] = vChrFilter[chrDstY*vChrFilterSize + i ]
- + (vChrFilterSize > 1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1] << 16 : 0);
- }
- }
- else
- {
- for(i = 0; i < vLumFilterSize; i++)
- {
- lumMmxFilter[4*i+0] = (int32_t)lumSrcPtr[i];
- lumMmxFilter[4*i+2] =
- lumMmxFilter[4*i+3] =
- ((uint16_t)vLumFilter[dstY*vLumFilterSize + i]) * 0x10001;
- }
- for(i = 0; i < vChrFilterSize; i++)
- {
- chrMmxFilter[4*i+0] = (int32_t)chrSrcPtr[i];
- chrMmxFilter[4*i+2] =
- chrMmxFilter[4*i+3] =
- ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i]) * 0x10001;
- }
- }
-#endif
- if(dstFormat == IMGFMT_NV12 || dstFormat == IMGFMT_NV21)
- {
- const int chrSkipMask = (1 << c->chrDstVSubSample) - 1;
- if(dstY & chrSkipMask) uDest = NULL; //FIXME split functions in lumi / chromi
- RENAME(yuv2nv12X)(c,
- vLumFilter + dstY * vLumFilterSize , lumSrcPtr, vLumFilterSize,
- vChrFilter + chrDstY * vChrFilterSize, chrSrcPtr, vChrFilterSize,
- dest, /*uDest*/dstY & chrSkipMask ? NULL : dst[1] + dstStride[1]*chrDstY, dstW, chrDstW, dstFormat);
- }
- else if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like
- {
- const int chrSkipMask = (1 << c->chrDstVSubSample) - 1;
- if((dstY & chrSkipMask) || isGray(dstFormat)) uDest = vDest = NULL; //FIXME split functions in lumi / chromi
- if(vLumFilterSize == 1 && vChrFilterSize == 1) // Unscaled YV12
- {
- int16_t *lumBuf = lumPixBuf[0];
- int16_t *chrBuf = chrPixBuf[0];
- RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW, chrDstW);
- }
- else //General YV12
- {
- RENAME(yuv2yuvX)(c,
- vLumFilter + dstY * vLumFilterSize , lumSrcPtr, vLumFilterSize,
- vChrFilter + chrDstY * vChrFilterSize, chrSrcPtr, vChrFilterSize,
- dest, uDest, vDest, dstW, chrDstW);
- }
- }
- else
- {
- ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize * 2);
- ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize * 2);
- if(vLumFilterSize == 1 && vChrFilterSize == 2) //Unscaled RGB
- {
- int chrAlpha = vChrFilter[2*dstY+1];
- RENAME(yuv2packed1)(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr + 1),
- dest, dstW, chrAlpha, dstFormat, params.v_chr_drop, dstY);
- }
- else if(vLumFilterSize == 2 && vChrFilterSize == 2) //BiLinear Upscale RGB
- {
- int lumAlpha = vLumFilter[2*dstY+1];
- int chrAlpha = vChrFilter[2*dstY+1];
- lumMmxFilter[2] =
- lumMmxFilter[3] = vLumFilter[2*dstY ] * 0x10001;
- chrMmxFilter[2] =
- chrMmxFilter[3] = vChrFilter[2*chrDstY] * 0x10001;
- RENAME(yuv2packed2)(c, *lumSrcPtr, *(lumSrcPtr + 1), *chrSrcPtr, *(chrSrcPtr + 1),
- dest, dstW, lumAlpha, chrAlpha, dstY);
- }
- else //General RGB
- {
- RENAME(yuv2packedX)(c,
- vLumFilter + dstY * vLumFilterSize, lumSrcPtr, vLumFilterSize,
- vChrFilter + dstY * vChrFilterSize, chrSrcPtr, vChrFilterSize,
- dest, dstW, dstY);
- }
+ int i;
+ if(params.subsampling & SWS_ACCURATE_RND){
+ int s= APCK_SIZE / 8;
+ for(i=0; i<vLumFilterSize; i+=2){
+ *(void**)&lumMmxFilter[s*i+0 ]= lumSrcPtr[i ];
+ *(void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
+ lumMmxFilter[s*i+APCK_COEF/4 ]=
+ lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
+ + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
}
- }
- else // hmm looks like we can't use MMX here without overwriting this array's tail
- {
- int16_t **lumSrcPtr = lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
- int16_t **chrSrcPtr = chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
- if(dstFormat == IMGFMT_NV12 || dstFormat == IMGFMT_NV21)
- {
- const int chrSkipMask = (1 << c->chrDstVSubSample) - 1;
- if(dstY & chrSkipMask) uDest = NULL; //FIXME split functions in lumi / chromi
- yuv2nv12XinC(
- vLumFilter + dstY * vLumFilterSize , lumSrcPtr, vLumFilterSize,
- vChrFilter + chrDstY * vChrFilterSize, chrSrcPtr, vChrFilterSize,
- dest, /*uDest*/dstY & chrSkipMask ? NULL : dst[1] + dstStride[1]*chrDstY, dstW, chrDstW, dstFormat);
+ for(i=0; i<vChrFilterSize; i+=2){
+ *(void**)&chrMmxFilter[s*i+0 ]= chrSrcPtr[i ];
+ *(void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrSrcPtr[i+(vChrFilterSize>1)];
+ chrMmxFilter[s*i+APCK_COEF/4 ]=
+ chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
+ + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
}
- else if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12
+ }else{
+ for(i=0; i<vLumFilterSize; i++)
{
- const int chrSkipMask = (1 << c->chrDstVSubSample) - 1;
- if((dstY & chrSkipMask) || isGray(dstFormat)) uDest = vDest = NULL; //FIXME split functions in lumi / chromi
- yuv2yuvXinC(
- vLumFilter + dstY * vLumFilterSize , lumSrcPtr, vLumFilterSize,
- vChrFilter + chrDstY * vChrFilterSize, chrSrcPtr, vChrFilterSize,
- dest, uDest, vDest, dstW, chrDstW);
+ lumMmxFilter[4*i+0]= (int32_t)lumSrcPtr[i];
+ lumMmxFilter[4*i+2]=
+ lumMmxFilter[4*i+3]=
+ ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
}
- else
+ for(i=0; i<vChrFilterSize; i++)
{
- ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize * 2);
- ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize * 2);
- yuv2packedXinC(c,
- vLumFilter + dstY * vLumFilterSize, lumSrcPtr, vLumFilterSize,
- vChrFilter + dstY * vChrFilterSize, chrSrcPtr, vChrFilterSize,
- dest, dstW, dstY);
+ chrMmxFilter[4*i+0]= (int32_t)chrSrcPtr[i];
+ chrMmxFilter[4*i+2]=
+ chrMmxFilter[4*i+3]=
+ ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
}
- }
}
+#endif
+ if(dstFormat == IMGFMT_NV12 || dstFormat == IMGFMT_NV21){
+ const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
+ if(dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
+ RENAME(yuv2nv12X)(c,
+ vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
+ vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
+ dest, /*uDest*/dstY&chrSkipMask?NULL:dst[1]+dstStride[1]*chrDstY, dstW, chrDstW, dstFormat);
+ }
+ else if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like
+ {
+ const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
+ if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
+ if(vLumFilterSize == 1 && vChrFilterSize == 1) // Unscaled YV12
+ {
+ int16_t *lumBuf = lumPixBuf[0];
+ int16_t *chrBuf= chrPixBuf[0];
+ RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW, chrDstW);
+ }
+ else //General YV12
+ {
+ RENAME(yuv2yuvX)(c,
+ vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
+ vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
+ dest, uDest, vDest, dstW, chrDstW);
+ }
+ }
+ else
+ {
+ ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
+ ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
+ if(vLumFilterSize == 1 && vChrFilterSize == 2) //Unscaled RGB
+ {
+ int chrAlpha= vChrFilter[2*dstY+1];
+ RENAME(yuv2packed1)(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1),
+ dest, dstW, chrAlpha, dstFormat, params.v_chr_drop, dstY);
+ }
+ else if(vLumFilterSize == 2 && vChrFilterSize == 2) //BiLinear Upscale RGB
+ {
+ int lumAlpha= vLumFilter[2*dstY+1];
+ int chrAlpha= vChrFilter[2*dstY+1];
+ lumMmxFilter[2]=
+ lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001;
+ chrMmxFilter[2]=
+ chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001;
+ RENAME(yuv2packed2)(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1),
+ dest, dstW, lumAlpha, chrAlpha, dstY);
+ }
+ else //General RGB
+ {
+ RENAME(yuv2packedX)(c,
+ vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
+ vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
+ dest, dstW, dstY);
+ }
+ }
+ }
+ else // hmm looks like we can't use MMX here without overwriting this array's tail
+ {
+ int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
+ int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
+ if(dstFormat == IMGFMT_NV12 || dstFormat == IMGFMT_NV21){
+ const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
+ if(dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
+ yuv2nv12XinC(
+ vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
+ vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
+ dest, /*uDest*/dstY&chrSkipMask?NULL:dst[1]+dstStride[1]*chrDstY, dstW, chrDstW, dstFormat);
+ }
+ else if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12
+ {
+ const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
+ if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
+ yuv2yuvXinC(
+ vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
+ vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
+ dest, uDest, vDest, dstW, chrDstW);
+ }
+ else
+ {
+ ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
+ ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
+ yuv2packedXinC(c,
+ vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
+ vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
+ dest, dstW, dstY);
+ }
+ }
+ }
#if HAVE_MMX
- __asm __volatile(SFENCE:::"memory");
- __asm __volatile(EMMS:::"memory");
+ __asm __volatile(SFENCE:::"memory");
+ __asm __volatile(EMMS:::"memory");
#endif
ret0:
- /* store changed local vars back in the context */
- c->dstY = dstY;
- c->lumBufIndex = lumBufIndex;
- c->chrBufIndex = chrBufIndex;
- c->lastInLumBuf = lastInLumBuf;
- c->lastInChrBuf = lastInChrBuf;
- return dstY - lastDstY;
- }
-
- int RENAME(sws_thread_work)(SwsContext * c) // Thread func
- {
- SwsThreadParam *stp = &c->stp;
- return RENAME(swScaleI)(c, stp->src, stp->srcStride, stp->srcSliceY,
- stp->srcSliceH, stp->dst, stp->dstStride, stp->dstYstart, stp->dstYend);
- }
-
- static int RENAME(swScale)(SwsContext * c, uint8_t * src[], stride_t srcStride[], int srcSliceY,
- int srcSliceH, uint8_t * dst[], stride_t dstStride[])
- {
- int dstLines;
- int i;
- int lastDstY;
- int processedLines = 0;
+ /* store changed local vars back in the context */
+ c->dstY= dstY;
+ c->lumBufIndex= lumBufIndex;
+ c->chrBufIndex= chrBufIndex;
+ c->lastInLumBuf= lastInLumBuf;
+ c->lastInChrBuf= lastInChrBuf;
+ return dstY - lastDstY;
+}
- if(srcSliceY == 0) c->dstY = 0;
+int RENAME(sws_thread_work)(SwsContext *c) // Thread func
+{
+ SwsThreadParam *stp= &c->stp;
+ return RENAME(swScaleI)(c, stp->src, stp->srcStride, stp->srcSliceY,
+ stp->srcSliceH, stp->dst, stp->dstStride, stp->dstYstart, stp->dstYend);
+}
- if(c->thread_count == 1)
- {
- return RENAME(swScaleI)(c, src, srcStride, srcSliceY,
- srcSliceH, dst, dstStride, c->dstY, c->dstH);
- }
- else
- {
- lastDstY = c->dstY;
- c[0].stp.dstYstart = c->dstY;
- dstLines = (c->dstH - c->dstY) / c->thread_count;
- c[0].stp.dstYend = c->dstY + dstLines;
- for(i = 0; i < c->thread_count; i++)
- {
- c[i].stp.c = &c[i];
- c[i].stp.src = src;
- c[i].stp.srcStride = srcStride;
- c[i].stp.srcSliceY = srcSliceY;
- c[i].stp.srcSliceH = srcSliceH;
- c[i].stp.dst = dst;
- c[i].stp.dstStride = dstStride;
- c[i].stp.dstYstart = c[0].stp.dstYstart + dstLines * i; // +2*i; //(+2*i makes green or black line in the middle of screen; test item to see multihreading)
- c[i].stp.dstYend = c[0].stp.dstYend + dstLines * i;
- }
- c[c->thread_count-1].stp.dstYend = c->dstH;
- c->execute(c, RENAME(sws_thread_work), c->ret, c->thread_count);
- for(i = 0; i < c->thread_count; i++)
- {
- processedLines += c->ret[i];
- }
- c->dstY = lastDstY + processedLines;
- return processedLines;
- }
- }
+static int RENAME(swScale)(SwsContext *c, uint8_t* src[], stride_t srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], stride_t dstStride[])
+{
+ int dstLines;
+ int i;
+ int lastDstY;
+ int processedLines=0;
+
+ if(srcSliceY==0) c->dstY= 0;
+
+ if (c->thread_count==1)
+ {
+ return RENAME(swScaleI)(c,src,srcStride,srcSliceY,
+ srcSliceH,dst,dstStride,c->dstY,c->dstH);
+ }
+ else
+ {
+ lastDstY= c->dstY;
+ c[0].stp.dstYstart= c->dstY;
+ dstLines= (c->dstH-c->dstY)/c->thread_count;
+ c[0].stp.dstYend= c->dstY + dstLines;
+ for (i=0; i<c->thread_count; i++){
+ c[i].stp.c= &c[i];
+ c[i].stp.src= src;
+ c[i].stp.srcStride= srcStride;
+ c[i].stp.srcSliceY= srcSliceY;
+ c[i].stp.srcSliceH= srcSliceH;
+ c[i].stp.dst= dst;
+ c[i].stp.dstStride= dstStride;
+ c[i].stp.dstYstart= c[0].stp.dstYstart+dstLines*i;// +2*i; //(+2*i makes green or black line in the middle of screen; test item to see multihreading)
+ c[i].stp.dstYend = c[0].stp.dstYend+ dstLines*i;
+ }
+ c[c->thread_count-1].stp.dstYend= c->dstH;
+ c->execute(c, RENAME(sws_thread_work), c->ret, c->thread_count);
+ for (i=0; i<c->thread_count; i++){
+ processedLines +=c->ret[i];
+ }
+ c->dstY= lastDstY+processedLines;
+ return processedLines;
+ }
+}
diff --git a/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/ia32/nasm.h b/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/ia32/nasm.h
index feca50b48..b7cb2d257 100644
--- a/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/ia32/nasm.h
+++ b/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/ia32/nasm.h
@@ -1,96 +1,75 @@
-;
-libFLAC - Free Lossless Audio Codec library
-;
-Copyright(C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Josh Coalson
-;
-;
-Redistribution and use in source and binary forms, with or without
-;
-modification, are permitted provided that the following conditions
-;
-are met:
-;
-;
-- Redistributions of source code must retain the above copyright
-;
-notice, this list of conditions and the following disclaimer.
-;
-;
-- Redistributions in binary form must reproduce the above copyright
-;
-notice, this list of conditions and the following disclaimer in the
-;
-documentation and / or other materials provided with the distribution.
-;
-;
-- Neither the name of the Xiph.org Foundation nor the names of its
-;
-contributors may be used to endorse or promote products derived from
-;
-this software without specific prior written permission.
-;
-;
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-;
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-;
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-;
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
-;
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- ;
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
- ; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- ; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-;
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING
- ; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-;
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+; libFLAC - Free Lossless Audio Codec library
+; Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions
+; are met:
+;
+; - Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+;
+; - Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+;
+; - Neither the name of the Xiph.org Foundation nor the names of its
+; contributors may be used to endorse or promote products derived from
+; this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-bits 32
+ bits 32
-% ifdef OBJ_FORMAT_win32
-% define FLAC__PUBLIC_NEEDS_UNDERSCORE
-% idefine code_section section .text align = 16
- % idefine data_section section .data align = 32
- % idefine bss_section section .bss align = 32
- % elifdef OBJ_FORMAT_aout
- % define FLAC__PUBLIC_NEEDS_UNDERSCORE
- % idefine code_section section .text
- % idefine data_section section .data
- % idefine bss_section section .bss
- % elifdef OBJ_FORMAT_aoutb
- % define FLAC__PUBLIC_NEEDS_UNDERSCORE
- % idefine code_section section .text
- % idefine data_section section .data
- % idefine bss_section section .bss
- % elifdef OBJ_FORMAT_elf
- % idefine code_section section .text align = 16
- % idefine data_section section .data align = 32
- % idefine bss_section section .bss align = 32
- % else
- % error unsupported object format!
- % endif
+%ifdef OBJ_FORMAT_win32
+ %define FLAC__PUBLIC_NEEDS_UNDERSCORE
+ %idefine code_section section .text align=16
+ %idefine data_section section .data align=32
+ %idefine bss_section section .bss align=32
+%elifdef OBJ_FORMAT_aout
+ %define FLAC__PUBLIC_NEEDS_UNDERSCORE
+ %idefine code_section section .text
+ %idefine data_section section .data
+ %idefine bss_section section .bss
+%elifdef OBJ_FORMAT_aoutb
+ %define FLAC__PUBLIC_NEEDS_UNDERSCORE
+ %idefine code_section section .text
+ %idefine data_section section .data
+ %idefine bss_section section .bss
+%elifdef OBJ_FORMAT_elf
+ %idefine code_section section .text align=16
+ %idefine data_section section .data align=32
+ %idefine bss_section section .bss align=32
+%else
+ %error unsupported object format!
+%endif
- % imacro cglobal 1
- % ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
- global _ % 1
- % else
- global % 1
- % endif
- % endmacro
+%imacro cglobal 1
+ %ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
+ global _%1
+ %else
+ global %1
+ %endif
+%endmacro
- % imacro cextern 1
- % ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
- extern _ % 1
- % else
- extern % 1
- % endif
- % endmacro
+%imacro cextern 1
+ %ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
+ extern _%1
+ %else
+ extern %1
+ %endif
+%endmacro
- % imacro cident 1
- _ % 1:
- % 1:
- % endmacro
+%imacro cident 1
+_%1:
+%1:
+%endmacro