Compare commits
13 commits
64ecf78dbb
...
1d5dc51fdf
Author | SHA1 | Date | |
---|---|---|---|
1d5dc51fdf | |||
d4748ac579 | |||
b57716fa6b | |||
3fc1b2df26 | |||
8b11c08e69 | |||
dce15d8047 | |||
|
f40b82faba | ||
|
03869b9959 | ||
|
df550439a1 | ||
|
6a8d8fbee6 | ||
|
86a4a1a994 | ||
|
08501adfd1 | ||
|
ebe6250b20 |
236 changed files with 59184 additions and 60744 deletions
46
.gitea/workflows/build-and-test.yml
Normal file
46
.gitea/workflows/build-and-test.yml
Normal file
|
@ -0,0 +1,46 @@
|
|||
name: Test openperf
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
checkout_repos:
|
||||
runs-on: nix
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
arch: ["native"] # Define architectures here
|
||||
test_name: ["stream"] # Define test names here
|
||||
|
||||
steps:
|
||||
- name: Checkout Main Repo (openperf)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: openperf/openperf
|
||||
path: openperf
|
||||
|
||||
- name: Checkout Abstract Machine Repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: openperf/abstract-machine
|
||||
path: abstract-machine
|
||||
|
||||
- name: Checkout Nemu Repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: openperf/nemu
|
||||
path: nemu
|
||||
|
||||
- name: Build and Run with Matrix
|
||||
working-directory: openperf
|
||||
env:
|
||||
AM_HOME: "${{ github.workspace }}/abstract-machine"
|
||||
NEMU_HOME: "${{ github.workspace }}/nemu"
|
||||
run: |
|
||||
nix develop .#native --impure --command make ARCH=${{ matrix.arch }} ALL=${{ matrix.test_name }} run
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -17,4 +17,4 @@ _*
|
|||
build/
|
||||
!.gitignore
|
||||
.vscode
|
||||
!mersenne-riscv32e.bin
|
||||
abstract-machine/
|
||||
|
|
68
Makefile
68
Makefile
|
@ -1,7 +1,7 @@
|
|||
|
||||
BENCH_LIBS := bench openlibm soft-fp
|
||||
|
||||
$(BENCH_LIBS): %: latest
|
||||
$(BENCH_LIBS): %:
|
||||
$(MAKE) -s -C ./src/common/$* archive
|
||||
|
||||
COLOR_RED = \033[1;31m
|
||||
|
@ -11,38 +11,78 @@ COLOR_NONE = \033[0m
|
|||
RESULT = .result
|
||||
$(shell > $(RESULT))
|
||||
|
||||
ALL = cpuemu mcf x264 tcc stream linpack gemm whetstone
|
||||
KEEP_LOG_FAILED ?= true
|
||||
KEEP_LOG_SUCCEED ?= false
|
||||
TIME := $(shell date --iso=seconds)
|
||||
|
||||
ALL = mcf x264 tcc stream linpack gemm whetstone
|
||||
|
||||
all: $(BENCH_LIBS) $(ALL)
|
||||
@echo "test list [$(words $(ALL)) item(s)]:" $(ALL)
|
||||
@echo "OpenPerf [$(words $(ALL)) item(s)]:" $(ALL)
|
||||
@if [ -z "$(mainargs)" ]; then \
|
||||
echo "Empty mainargs, use \"ref\" by default"; \
|
||||
echo "====== Running OpenPerf [input *ref*] ======"; \
|
||||
else \
|
||||
echo "====== Running OpenPerf [input *$${mainargs}*] ======"; \
|
||||
fi
|
||||
|
||||
$(ALL): %: $(BENCH_LIBS) latest
|
||||
$(ALL): %: $(BENCH_LIBS)
|
||||
@{\
|
||||
TMP=$*.tmp;\
|
||||
make -C ./src/$* ARCH=$(ARCH) run 2>&1 | tee -a $$TMP;\
|
||||
if [ $${PIPESTATUS[0]} -eq 0 ]; then \
|
||||
$(MAKE) -C ./src/$* ARCH=$(ARCH) run 2>&1 | tee -a $$TMP;\
|
||||
if [ $${PIPESTATUS[0]} -eq 0 ]; then \
|
||||
printf "[%14s] $(COLOR_GREEN)PASS$(COLOR_NONE) " $* >> $(RESULT); \
|
||||
cat $$TMP | grep -E -i -e "time: ([0-9]*\.)?[0-9]* ms" >> $(RESULT); \
|
||||
rm $$TMP;\
|
||||
cat $$TMP | grep -E -i -e "OpenPerf time: ([0-9]*\.)?[0-9]*" >> $(RESULT); \
|
||||
if $(KEEP_LOG_SUCCEED); then \
|
||||
mkdir -p "logs/$(TIME)/"; \
|
||||
mv $$TMP "logs/$(TIME)/"; \
|
||||
else \
|
||||
rm $$TMP; \
|
||||
fi \
|
||||
else \
|
||||
printf "[%14s] $(COLOR_RED)***FAIL***$(COLOR_NONE)\n" $* >> $(RESULT); \
|
||||
rm $$TMP; \
|
||||
if $(KEEP_LOG_FAILED); then \
|
||||
mkdir -p "logs/$(TIME)/"; \
|
||||
mv $$TMP "logs/$(TIME)/"; \
|
||||
else \
|
||||
rm $$TMP; \
|
||||
fi \
|
||||
fi \
|
||||
}
|
||||
|
||||
run: $(BENCH_LIBS) all
|
||||
@cat $(RESULT)
|
||||
@cat $(RESULT) | grep -E -o "time: ([0-9]*\.[0-9]*) ms" | awk '{sum += $$2} END {print sum " ms"}'
|
||||
@echo "============================================="
|
||||
@if grep -q -i -e "fail" "$(RESULT)"; then \
|
||||
echo "OpenPerf FAIL"; \
|
||||
else \
|
||||
echo "OpenPerf PASS"; \
|
||||
fi
|
||||
@awk '\
|
||||
{ \
|
||||
h = min = s = ms = us = 0;\
|
||||
if (match($$0, /([0-9]+) h/, arr)) h = arr[1]; \
|
||||
if (match($$0, /([0-9]+) min/, arr)) min = arr[1]; \
|
||||
if (match($$0, /([0-9]+) s/, arr)) s = arr[1]; \
|
||||
if (match($$0, /([0-9]+)\.([0-9]*) ms/, arr)) {ms = arr[1]; us = arr[2]} \
|
||||
total_ms += h * 3600000 + min * 60000 + s * 1000 + ms; \
|
||||
} \
|
||||
END { \
|
||||
printf "Total time: %d h %d min %d s %d.%d ms\n", \
|
||||
int(total_ms / 3600000), \
|
||||
int((total_ms % 3600000) / 60000), \
|
||||
int((total_ms % 60000) / 1000), \
|
||||
total_ms % 1000, \
|
||||
us; \
|
||||
} \
|
||||
' $(RESULT)
|
||||
@rm $(RESULT)
|
||||
|
||||
|
||||
CLEAN_ALL = $(dir $(shell find . -mindepth 2 -name Makefile))
|
||||
clean-all: $(CLEAN_ALL)
|
||||
|
||||
$(CLEAN_ALL):
|
||||
-@$(MAKE) -s -C $@ clean
|
||||
|
||||
.PHONY: $(BENCH_LIBS) $(CLEAN_ALL) $(ALL) all run clean-all latest
|
||||
|
||||
latest:
|
||||
.PHONY: $(BENCH_LIBS) $(CLEAN_ALL) $(ALL) all run clean-all
|
||||
|
||||
|
|
|
@ -1,13 +1,42 @@
|
|||
#include <am.h>
|
||||
#include <klib.h>
|
||||
#include <bench_debug.h>
|
||||
#include <klib-macros.h>
|
||||
#include <klib.h>
|
||||
|
||||
uint64_t uptime()
|
||||
{
|
||||
return (io_read(AM_TIMER_UPTIME).us);
|
||||
}
|
||||
uint64_t uptime() { return (io_read(AM_TIMER_UPTIME).us); }
|
||||
|
||||
char *format_time(uint64_t us) {
|
||||
|
||||
static char buf[128];
|
||||
uint64_t ms = us / 1000;
|
||||
uint64_t s = ms / 1000;
|
||||
uint64_t min = s / 60;
|
||||
uint64_t h = min / 60;
|
||||
|
||||
us %= 1000;
|
||||
ms %= 1000;
|
||||
s %= 60;
|
||||
min %= 60;
|
||||
|
||||
int len = 0;
|
||||
if (h > 0) {
|
||||
len = bench_sprintf(buf, "%ld h %ld min %ld s %ld.000 ms", h, min, s, ms);
|
||||
} else if (min > 0) {
|
||||
len = bench_sprintf(buf, "%ld min %ld s, %ld.000 ms", min, s, ms);
|
||||
} else if (s > 0) {
|
||||
len = bench_sprintf(buf, "%ld s, %ld.000 ms", s, ms);
|
||||
} else {
|
||||
len = bench_sprintf(buf, "%ld.000 ms", ms);
|
||||
}
|
||||
char *p = &buf[len - 4];
|
||||
while (us > 0) {
|
||||
*(p--) = '0' + us % 10;
|
||||
us /= 10;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
/* char *format_time(uint64_t us) {
|
||||
static char buf[32];
|
||||
uint64_t ms = us / 1000;
|
||||
us -= ms * 1000;
|
||||
|
@ -19,14 +48,14 @@ char *format_time(uint64_t us) {
|
|||
us /= 10;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
} */
|
||||
|
||||
// FNV hash
|
||||
uint32_t checksum(void *start, void *end) {
|
||||
const uint32_t x = 16777619;
|
||||
uint32_t h1 = 2166136261u;
|
||||
for (uint8_t *p = (uint8_t*)start; p + 4 < (uint8_t*)end; p += 4) {
|
||||
for (int i = 0; i < 4; i ++) {
|
||||
for (uint8_t *p = (uint8_t *)start; p + 4 < (uint8_t *)end; p += 4) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
h1 = (h1 ^ p[i]) * x;
|
||||
}
|
||||
}
|
||||
|
|
438
src/common/bench/bench_debug.c
Normal file
438
src/common/bench/bench_debug.c
Normal file
|
@ -0,0 +1,438 @@
|
|||
#include <am.h>
|
||||
#include <klib-macros.h>
|
||||
#include <klib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define ZEROPAD 1
|
||||
#define SIGN 2
|
||||
#define PLUS 4
|
||||
#define SPACE 8
|
||||
#define LEFT 16
|
||||
#define SPECIAL 32
|
||||
#define LARGE 64
|
||||
|
||||
#define is_digit(c) ((c) >= '0' && (c) <= '9')
|
||||
|
||||
#define SZ_NUM_BUF 32
|
||||
static char sprint_fe[SZ_NUM_BUF + 1];
|
||||
#define PRINT_BUF_SIZE 512
|
||||
|
||||
static const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
static const char *upper_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
static size_t strnlen(const char *s, size_t count) {
|
||||
const char *sc;
|
||||
for (sc = s; *sc != '\0' && count--; ++sc)
|
||||
;
|
||||
return sc - s;
|
||||
}
|
||||
|
||||
static int skip_atoi(const char **s) {
|
||||
int i = 0;
|
||||
while (is_digit(**s))
|
||||
i = i * 10 + *((*s)++) - '0';
|
||||
return i;
|
||||
}
|
||||
|
||||
static char *number(char *str, long num, int base, int size, int precision,
|
||||
int type) {
|
||||
char c, sign, tmp[66];
|
||||
const char *dig = digits;
|
||||
int i;
|
||||
if (type & LARGE)
|
||||
dig = upper_digits;
|
||||
if (type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
if (base < 2 || base > 36)
|
||||
return 0;
|
||||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if (num < 0) {
|
||||
sign = '-';
|
||||
num = -num;
|
||||
size--;
|
||||
} else if (type & PLUS) {
|
||||
sign = '+';
|
||||
size--;
|
||||
} else if (type & SPACE) {
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
if (type & SPECIAL) {
|
||||
if (base == 16)
|
||||
size -= 2;
|
||||
else if (base == 8)
|
||||
size--;
|
||||
}
|
||||
i = 0;
|
||||
if (num == 0)
|
||||
tmp[i++] = '0';
|
||||
else {
|
||||
while (num != 0) {
|
||||
tmp[i++] = dig[((unsigned long)num) % (unsigned)base];
|
||||
num = ((unsigned long)num) / (unsigned)base;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > precision)
|
||||
precision = i;
|
||||
size -= precision;
|
||||
if (!(type & (ZEROPAD | LEFT)))
|
||||
while (size-- > 0)
|
||||
*str++ = ' ';
|
||||
if (sign)
|
||||
*str++ = sign;
|
||||
if (type & SPECIAL) {
|
||||
if (base == 8)
|
||||
*str++ = '0'; // 0
|
||||
else if (base == 16) {
|
||||
*str++ = '0';
|
||||
*str++ = digits[33]; // 0x
|
||||
}
|
||||
}
|
||||
if (!(type & LEFT))
|
||||
while (size-- > 0)
|
||||
*str++ = c;
|
||||
while (i < precision--)
|
||||
*str++ = '0';
|
||||
while (i-- > 0)
|
||||
*str++ = tmp[i];
|
||||
while (size-- > 0)
|
||||
*str++ = ' ';
|
||||
return str;
|
||||
}
|
||||
static int ilog10(double n) {
|
||||
int rv = 0;
|
||||
|
||||
while (n >= 10) {
|
||||
if (n >= 100000) {
|
||||
n /= 100000;
|
||||
rv += 5;
|
||||
} else {
|
||||
n /= 10;
|
||||
rv++;
|
||||
}
|
||||
}
|
||||
while (n < 1) {
|
||||
if (n < 0.00001) {
|
||||
n *= 100000;
|
||||
rv -= 5;
|
||||
} else {
|
||||
n *= 10;
|
||||
rv--;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
static double i10x(int n) {
|
||||
double rv = 1;
|
||||
|
||||
while (n > 0) {
|
||||
if (n >= 5) {
|
||||
rv *= 100000;
|
||||
n -= 5;
|
||||
} else {
|
||||
rv *= 10;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
while (n < 0) { /* Right shift */
|
||||
if (n <= -5) {
|
||||
rv /= 100000;
|
||||
n += 5;
|
||||
} else {
|
||||
rv /= 10;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void ftoa(char *buf, double val, int prec, char fmt) {
|
||||
int d;
|
||||
int e = 0, m = 0;
|
||||
char sign = 0;
|
||||
double w;
|
||||
const char *er = 0;
|
||||
const char ds = '.';
|
||||
unsigned int *pu = (unsigned int *)&val;
|
||||
|
||||
if (((pu[1] & 0x7ff00000) == 0x7ff00000) &&
|
||||
(((pu[1] & 0xfffff) != 0) || (pu[0] != 0))) {
|
||||
er = "NaN";
|
||||
} else {
|
||||
if (prec < 0)
|
||||
prec = 6;
|
||||
if (val < 0) {
|
||||
val = 0 - val;
|
||||
sign = '-';
|
||||
} else {
|
||||
sign = '+';
|
||||
}
|
||||
if (((pu[1] & 0x7fffffff) == 0x7ff00000) && (pu[0] == 0)) {
|
||||
er = "INF";
|
||||
} else {
|
||||
if (fmt == 'f') {
|
||||
val += i10x(0 - prec) / 2;
|
||||
m = ilog10(val);
|
||||
if (m < 0)
|
||||
m = 0;
|
||||
if (m + prec + 3 >= SZ_NUM_BUF)
|
||||
er = "OV";
|
||||
} else {
|
||||
if (val != 0) {
|
||||
val += i10x(ilog10(val) - prec) / 2;
|
||||
e = ilog10(val);
|
||||
|
||||
if (e > 99 || prec + 7 >= SZ_NUM_BUF) {
|
||||
er = "OV";
|
||||
} else {
|
||||
if (e < -99)
|
||||
e = -99;
|
||||
val /= i10x(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!er) {
|
||||
if (sign == '-')
|
||||
*buf++ = sign;
|
||||
|
||||
do {
|
||||
if (m == -1)
|
||||
*buf++ = ds;
|
||||
w = i10x(m);
|
||||
d = (int)(val / w);
|
||||
val -= d * w;
|
||||
|
||||
*buf++ = (char)('0' + d);
|
||||
|
||||
} while (--m >= -prec);
|
||||
|
||||
if (fmt != 'f') {
|
||||
*buf++ = (char)fmt;
|
||||
if (e < 0) {
|
||||
e = 0 - e;
|
||||
*buf++ = '-';
|
||||
} else {
|
||||
*buf++ = '+';
|
||||
}
|
||||
*buf++ = (char)('0' + e / 10);
|
||||
*buf++ = (char)('0' + e % 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (er) {
|
||||
if (sign)
|
||||
*buf++ = sign;
|
||||
do {
|
||||
*buf++ = *er++;
|
||||
} while (*er);
|
||||
}
|
||||
*buf = 0;
|
||||
}
|
||||
int bench_vsprintf(char *buf, const char *fmt, va_list args) {
|
||||
int len = 0;
|
||||
unsigned long long num = 0;
|
||||
int i = 0, j = 0, base = 0;
|
||||
char *str;
|
||||
const char *s;
|
||||
int flags; /* flags to number() */
|
||||
int field_width; /* width of output field */
|
||||
int precision; /* min. # of digits for integers; max number of chars for from
|
||||
string */
|
||||
int qualifier; /* 'h', 'l', or 'L' for integer fields */
|
||||
/* 'z' support added 23/7/1999 S.H. */
|
||||
/* 'z' changed to 'Z' --davidm 1/25/99 */
|
||||
|
||||
for (str = buf; *fmt; ++fmt) {
|
||||
if (*fmt != '%') {
|
||||
*str++ = *fmt;
|
||||
continue;
|
||||
}
|
||||
/* flags */
|
||||
flags = 0;
|
||||
repeat:
|
||||
++fmt;
|
||||
switch (*fmt) {
|
||||
case '-':
|
||||
flags |= LEFT;
|
||||
goto repeat;
|
||||
case '+':
|
||||
flags |= PLUS;
|
||||
goto repeat;
|
||||
case ' ':
|
||||
flags |= SPACE;
|
||||
goto repeat;
|
||||
case '#':
|
||||
flags |= SPECIAL;
|
||||
goto repeat;
|
||||
case '0':
|
||||
flags |= ZEROPAD;
|
||||
goto repeat;
|
||||
}
|
||||
|
||||
field_width = -1;
|
||||
if ('0' <= *fmt && *fmt <= '9')
|
||||
field_width = skip_atoi(&fmt);
|
||||
else if (*fmt == '*') {
|
||||
++fmt; /*skip '*' */
|
||||
/* it's the next argument */
|
||||
field_width = va_arg(args, int);
|
||||
if (field_width < 0) {
|
||||
field_width = -field_width;
|
||||
flags |= LEFT;
|
||||
}
|
||||
}
|
||||
precision = -1;
|
||||
if (*fmt == '.') {
|
||||
++fmt;
|
||||
if ('0' <= *fmt && *fmt <= '9')
|
||||
precision = skip_atoi(&fmt);
|
||||
else if (*fmt == '*') {
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
precision = va_arg(args, int);
|
||||
}
|
||||
if (precision < 0)
|
||||
precision = 0;
|
||||
}
|
||||
qualifier = -1;
|
||||
if (*fmt == 'l' && *(fmt + 1) == 'l') {
|
||||
qualifier = 'q';
|
||||
fmt += 2;
|
||||
} else if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'Z') {
|
||||
qualifier = *fmt;
|
||||
++fmt;
|
||||
}
|
||||
/* default base */
|
||||
base = 10;
|
||||
switch (*fmt) {
|
||||
case 'c':
|
||||
if (!(flags & LEFT))
|
||||
while (--field_width > 0)
|
||||
*str++ = ' ';
|
||||
*str++ = (unsigned char)va_arg(args, int);
|
||||
while (--field_width > 0)
|
||||
*str++ = ' ';
|
||||
continue;
|
||||
case 's':
|
||||
s = va_arg(args, char *);
|
||||
if (!s)
|
||||
s = "";
|
||||
len = strnlen(s, precision);
|
||||
if (!(flags & LEFT))
|
||||
while (len < field_width--)
|
||||
*str++ = ' ';
|
||||
for (i = 0; i < len; ++i)
|
||||
*str++ = *s++;
|
||||
while (len < field_width--)
|
||||
*str++ = ' ';
|
||||
continue;
|
||||
case 'p':
|
||||
if (field_width == -1) {
|
||||
field_width = 2 * sizeof(void *);
|
||||
flags |= ZEROPAD;
|
||||
}
|
||||
str = number(str, (unsigned long)va_arg(args, void *), 16, field_width,
|
||||
precision, flags);
|
||||
continue;
|
||||
case 'n':
|
||||
if (qualifier == 'l') {
|
||||
long *ip = va_arg(args, long *);
|
||||
*ip = (str - buf);
|
||||
} else if (qualifier == 'Z') {
|
||||
size_t *ip = va_arg(args, size_t *);
|
||||
*ip = (str - buf);
|
||||
} else {
|
||||
int *ip = va_arg(args, int *);
|
||||
*ip = (str - buf);
|
||||
}
|
||||
continue;
|
||||
case 'f': /* Floating point (decimal) */
|
||||
case 'e': /* Floating point (e) */
|
||||
case 'E': /* Floating point (E) */
|
||||
ftoa(sprint_fe, va_arg(args, double), precision, *fmt); /* 浮点转字符串*/
|
||||
if (!(flags & LEFT)) {
|
||||
for (j = strnlen(sprint_fe, SZ_NUM_BUF); j < field_width; j++)
|
||||
*str++ = ' ';
|
||||
}
|
||||
i = 0;
|
||||
while (sprint_fe[i])
|
||||
*str++ = sprint_fe[i++]; /* 主体 */
|
||||
while (j++ < field_width)
|
||||
*str++ = ' ';
|
||||
|
||||
continue;
|
||||
case '%':
|
||||
*str++ = '%';
|
||||
continue;
|
||||
case 'o':
|
||||
base = 8;
|
||||
break;
|
||||
case 'X':
|
||||
flags |= LARGE;
|
||||
case 'x':
|
||||
base = 16;
|
||||
break;
|
||||
case 'd':
|
||||
case 'i':
|
||||
flags |= SIGN;
|
||||
case 'u':
|
||||
break;
|
||||
default:
|
||||
*str++ = '%';
|
||||
if (*fmt)
|
||||
*str++ = *fmt;
|
||||
else
|
||||
--fmt;
|
||||
continue;
|
||||
}
|
||||
if (qualifier == 'l') {
|
||||
num = va_arg(args, unsigned long);
|
||||
if (flags & SIGN)
|
||||
num = (signed long)num;
|
||||
} else if (qualifier == 'q') {
|
||||
num = va_arg(args, unsigned long long);
|
||||
if (flags & SIGN)
|
||||
num = (signed long long)num;
|
||||
} else if (qualifier == 'Z') {
|
||||
num = va_arg(args, size_t);
|
||||
} else if (qualifier == 'h') {
|
||||
num = (unsigned short)va_arg(args, int);
|
||||
if (flags & SIGN)
|
||||
num = (signed short)num;
|
||||
} else {
|
||||
num = va_arg(args, unsigned int);
|
||||
if (flags & SIGN)
|
||||
num = (signed int)num;
|
||||
}
|
||||
str = number(str, num, base, field_width, precision, flags);
|
||||
}
|
||||
*str = '\0';
|
||||
return str - buf;
|
||||
}
|
||||
|
||||
int bench_sprintf(char *s, const char *fmt, ...) {
|
||||
va_list arg;
|
||||
va_start(arg, fmt);
|
||||
int length = bench_vsprintf(s, fmt, arg);
|
||||
va_end(arg);
|
||||
return length;
|
||||
}
|
||||
|
||||
int bench_printf(const char *fmt, ...) {
|
||||
char s[PRINT_BUF_SIZE];
|
||||
va_list arg;
|
||||
va_start(arg, fmt);
|
||||
int length = bench_vsprintf(s, fmt, arg);
|
||||
va_end(arg);
|
||||
for (int i = 0; s[i] != '\0'; i++) {
|
||||
putch(s[i]);
|
||||
}
|
||||
return length;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#include <am.h>
|
||||
#include <bench_malloc.h>
|
||||
#include <klib.h>
|
||||
#include <am.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static intptr_t program_break = 0;
|
||||
|
@ -21,139 +21,136 @@ static void *sbrk(intptr_t increment) {
|
|||
// }
|
||||
|
||||
static inline size_t word_align(size_t size) {
|
||||
return ( size + (sizeof(size_t) - 1)) & ~(sizeof(size_t) - 1);
|
||||
return (size + (sizeof(size_t) - 1)) & ~(sizeof(size_t) - 1);
|
||||
}
|
||||
|
||||
struct chunk {
|
||||
struct chunk *next, *prev;
|
||||
size_t size;
|
||||
size_t free;
|
||||
void *data;
|
||||
struct chunk *next, *prev;
|
||||
size_t size;
|
||||
size_t free;
|
||||
void *data;
|
||||
};
|
||||
|
||||
typedef struct chunk *Chunk;
|
||||
|
||||
static void *malloc_base() {
|
||||
static Chunk b = NULL;
|
||||
if (!b) {
|
||||
b = sbrk(word_align(sizeof(struct chunk)));
|
||||
if (b == (void*) -1) {
|
||||
// _exit(127);
|
||||
assert(0);
|
||||
}
|
||||
b->next = NULL;
|
||||
b->prev = NULL;
|
||||
b->size = 0;
|
||||
b->free = 0;
|
||||
b->data = NULL;
|
||||
static Chunk b = NULL;
|
||||
if (!b) {
|
||||
b = sbrk(word_align(sizeof(struct chunk)));
|
||||
if (b == (void *)-1) {
|
||||
// _exit(127);
|
||||
assert(0);
|
||||
}
|
||||
return b;
|
||||
b->next = NULL;
|
||||
b->prev = NULL;
|
||||
b->size = 0;
|
||||
b->free = 0;
|
||||
b->data = NULL;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
//We need this function because we use variable `heap`
|
||||
//and it is initialized in run time.
|
||||
void bench_malloc_init() {
|
||||
program_break = (intptr_t)heap.start;
|
||||
}
|
||||
// We need this function because the variable `heap` is used
|
||||
// and initialized at runtime.
|
||||
void bench_malloc_init() { program_break = (intptr_t)heap.start; }
|
||||
|
||||
static Chunk malloc_chunk_find(size_t s, Chunk *heap) {
|
||||
Chunk c = malloc_base();
|
||||
for (; c && (!c->free || c->size < s); *heap = c, c = c->next);
|
||||
return c;
|
||||
Chunk c = malloc_base();
|
||||
for (; c && (!c->free || c->size < s); *heap = c, c = c->next)
|
||||
;
|
||||
return c;
|
||||
}
|
||||
|
||||
static void malloc_merge_next(Chunk c) {
|
||||
c->size = c->size + c->next->size + sizeof(struct chunk);
|
||||
c->next = c->next->next;
|
||||
if (c->next) {
|
||||
c->next->prev = c;
|
||||
}
|
||||
c->size = c->size + c->next->size + sizeof(struct chunk);
|
||||
c->next = c->next->next;
|
||||
if (c->next) {
|
||||
c->next->prev = c;
|
||||
}
|
||||
}
|
||||
|
||||
static void malloc_split_next(Chunk c, size_t size) {
|
||||
Chunk newc = (Chunk)((char*) c + size);
|
||||
newc->prev = c;
|
||||
newc->next = c->next;
|
||||
newc->size = c->size - size;
|
||||
newc->free = 1;
|
||||
newc->data = newc + 1;
|
||||
if (c->next) {
|
||||
c->next->prev = newc;
|
||||
}
|
||||
c->next = newc;
|
||||
c->size = size - sizeof(struct chunk);
|
||||
Chunk newc = (Chunk)((char *)c + size);
|
||||
newc->prev = c;
|
||||
newc->next = c->next;
|
||||
newc->size = c->size - size;
|
||||
newc->free = 1;
|
||||
newc->data = newc + 1;
|
||||
if (c->next) {
|
||||
c->next->prev = newc;
|
||||
}
|
||||
c->next = newc;
|
||||
c->size = size - sizeof(struct chunk);
|
||||
}
|
||||
|
||||
void *bench_malloc(size_t size) {
|
||||
if (!size) return NULL;
|
||||
size_t length = word_align(size + sizeof(struct chunk));
|
||||
Chunk prev = NULL;
|
||||
Chunk c = malloc_chunk_find(size, &prev);
|
||||
if (!c) {
|
||||
Chunk newc = sbrk(length);
|
||||
if (newc == (void*) -1) {
|
||||
return NULL;
|
||||
}
|
||||
newc->next = NULL;
|
||||
newc->prev = prev;
|
||||
newc->size = length - sizeof(struct chunk);
|
||||
newc->data = newc + 1;
|
||||
prev->next = newc;
|
||||
c = newc;
|
||||
} else if (length + sizeof(size_t) < c->size) {
|
||||
malloc_split_next(c, length);
|
||||
if (!size)
|
||||
return NULL;
|
||||
size_t length = word_align(size + sizeof(struct chunk));
|
||||
Chunk prev = NULL;
|
||||
Chunk c = malloc_chunk_find(size, &prev);
|
||||
if (!c) {
|
||||
Chunk newc = sbrk(length);
|
||||
if (newc == (void *)-1) {
|
||||
return NULL;
|
||||
}
|
||||
c->free = 0;
|
||||
return c->data;
|
||||
newc->next = NULL;
|
||||
newc->prev = prev;
|
||||
newc->size = length - sizeof(struct chunk);
|
||||
newc->data = newc + 1;
|
||||
prev->next = newc;
|
||||
c = newc;
|
||||
} else if (length + sizeof(size_t) < c->size) {
|
||||
malloc_split_next(c, length);
|
||||
}
|
||||
c->free = 0;
|
||||
return c->data;
|
||||
}
|
||||
|
||||
void bench_free(void *ptr) {
|
||||
if (!ptr || ptr < malloc_base() || ptr > sbrk(0)) return;
|
||||
Chunk c = (Chunk) ptr - 1;
|
||||
if (c->data != ptr) return;
|
||||
c->free = 1;
|
||||
if (!ptr || ptr < malloc_base() || ptr > sbrk(0))
|
||||
return;
|
||||
Chunk c = (Chunk)ptr - 1;
|
||||
if (c->data != ptr)
|
||||
return;
|
||||
c->free = 1;
|
||||
|
||||
if (c->next && c->next->free) {
|
||||
malloc_merge_next(c);
|
||||
}
|
||||
if (c->prev->free) {
|
||||
malloc_merge_next(c = c->prev);
|
||||
}
|
||||
if (!c->next) {
|
||||
c->prev->next = NULL;
|
||||
sbrk(- c->size - sizeof(struct chunk));
|
||||
}
|
||||
if (c->next && c->next->free) {
|
||||
malloc_merge_next(c);
|
||||
}
|
||||
if (c->prev->free) {
|
||||
malloc_merge_next(c = c->prev);
|
||||
}
|
||||
if (!c->next) {
|
||||
c->prev->next = NULL;
|
||||
sbrk(-c->size - sizeof(struct chunk));
|
||||
}
|
||||
}
|
||||
|
||||
void *bench_calloc(size_t nmemb, size_t size) {
|
||||
size_t length = nmemb * size;
|
||||
void *ptr = bench_malloc(length);
|
||||
if (ptr) {
|
||||
char *dst = ptr;
|
||||
for (size_t i = 0; i < length; *dst = 0, ++dst, ++i);
|
||||
}
|
||||
return ptr;
|
||||
size_t length = nmemb * size;
|
||||
void *ptr = bench_malloc(length);
|
||||
if (ptr) {
|
||||
char *dst = ptr;
|
||||
for (size_t i = 0; i < length; *dst = 0, ++dst, ++i)
|
||||
;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *bench_realloc(void *ptr, size_t size) {
|
||||
void *newptr = bench_malloc(size);
|
||||
if (newptr && ptr && ptr >= malloc_base() && ptr <= sbrk(0)) {
|
||||
Chunk c = (Chunk) ptr - 1;
|
||||
if (c->data == ptr) {
|
||||
size_t length = c->size > size ? size : c->size;
|
||||
char *dst = newptr, *src = ptr;
|
||||
for (size_t i = 0; i < length; *dst = *src, ++src, ++dst, ++i);
|
||||
bench_free(ptr);
|
||||
}
|
||||
void *newptr = bench_malloc(size);
|
||||
if (newptr && ptr && ptr >= malloc_base() && ptr <= sbrk(0)) {
|
||||
Chunk c = (Chunk)ptr - 1;
|
||||
if (c->data == ptr) {
|
||||
size_t length = c->size > size ? size : c->size;
|
||||
char *dst = newptr, *src = ptr;
|
||||
for (size_t i = 0; i < length; *dst = *src, ++src, ++dst, ++i)
|
||||
;
|
||||
bench_free(ptr);
|
||||
}
|
||||
return newptr;
|
||||
}
|
||||
return newptr;
|
||||
}
|
||||
|
||||
void bench_all_free() {
|
||||
program_break = (intptr_t)heap.start;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void bench_all_free() { program_break = (intptr_t)heap.start; }
|
||||
|
|
|
@ -1,456 +1,418 @@
|
|||
#include <klib.h>
|
||||
#include <bench_malloc.h>
|
||||
#include <klib.h>
|
||||
|
||||
|
||||
#define __tolower(c) ((('A' <= (c))&&((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c))
|
||||
int strcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
if(s1 == NULL || s2 == NULL)
|
||||
#define __tolower(c) ((('A' <= (c)) && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c))
|
||||
int strcasecmp(const char *s1, const char *s2) {
|
||||
if (s1 == NULL || s2 == NULL)
|
||||
return 0;
|
||||
|
||||
while((*s1 != '\0') && (__tolower(*s1) == __tolower(*s2)))
|
||||
{
|
||||
s1++; s2++;
|
||||
while ((*s1 != '\0') && (__tolower(*s1) == __tolower(*s2))) {
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return (*s1 - *s2);
|
||||
}
|
||||
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if(s1 == NULL || s2 == NULL)
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n) {
|
||||
if (s1 == NULL || s2 == NULL)
|
||||
return 0;
|
||||
|
||||
while((*s1 != '\0') && (__tolower(*s1) == __tolower(*s2)) && (n > 1))
|
||||
{
|
||||
s1++; s2++;
|
||||
while ((*s1 != '\0') && (__tolower(*s1) == __tolower(*s2)) && (n > 1)) {
|
||||
s1++;
|
||||
s2++;
|
||||
n--;
|
||||
}
|
||||
return (*s1 - *s2);
|
||||
}
|
||||
|
||||
char* strdup(const char* str)
|
||||
{
|
||||
if(str == NULL)
|
||||
char *strdup(const char *str) {
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
|
||||
char* strat = (char*)str;
|
||||
char *strat = (char *)str;
|
||||
int len = 0;
|
||||
while (*str++ != '\0')
|
||||
len++;
|
||||
char* ret = (char*)bench_malloc(len + 1);
|
||||
char *ret = (char *)bench_malloc(len + 1);
|
||||
|
||||
while ((*ret++ = *strat++) != '\0')
|
||||
{}
|
||||
while ((*ret++ = *strat++) != '\0') {
|
||||
}
|
||||
|
||||
return ret - (len + 1);
|
||||
}
|
||||
|
||||
size_t strspn(const char *str, const char *group)
|
||||
{
|
||||
const char *p = NULL;
|
||||
const char *a = NULL;
|
||||
size_t count = 0;
|
||||
size_t strspn(const char *str, const char *group) {
|
||||
const char *p = NULL;
|
||||
const char *a = NULL;
|
||||
size_t count = 0;
|
||||
|
||||
for (p = str; *p != '\0'; ++p)
|
||||
{
|
||||
for (a = group; *a != '\0'; ++a)
|
||||
{
|
||||
if (*p == *a)
|
||||
{
|
||||
++count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (p = str; *p != '\0'; ++p) {
|
||||
for (a = group; *a != '\0'; ++a) {
|
||||
if (*p == *a) {
|
||||
++count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (*a == '\0')
|
||||
{
|
||||
return count;
|
||||
}
|
||||
}
|
||||
if (*a == '\0') {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t strcspn ( const char * str1, const char * str2 ) {
|
||||
size_t strcspn(const char *str1, const char *str2) {
|
||||
char *p1 = (char *)str1;
|
||||
char *p2;
|
||||
while (*p1 != '\0') {
|
||||
p2 = (char *)str2;
|
||||
while (*p2 != '\0') {
|
||||
if (*p2 == *p1) return p1-str1;
|
||||
++p2;
|
||||
if (*p2 == *p1)
|
||||
return p1 - str1;
|
||||
++p2;
|
||||
}
|
||||
++p1;
|
||||
}
|
||||
return p1 - str1;
|
||||
return p1 - str1;
|
||||
}
|
||||
|
||||
unsigned long strtoul(const char *pstart, char **pend, int base)
|
||||
{
|
||||
const char *s = pstart;
|
||||
unsigned long result = 0;
|
||||
char c;
|
||||
unsigned long strtoul(const char *pstart, char **pend, int base) {
|
||||
const char *s = pstart;
|
||||
unsigned long result = 0;
|
||||
char c;
|
||||
|
||||
assert (base > 2 && base < 36);
|
||||
assert(base > 2 && base < 36);
|
||||
|
||||
do {
|
||||
c = *s++;
|
||||
} while (c == ' ');
|
||||
if (c == '-' || c == '+'){
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X') &&
|
||||
((s[1] >= '0' && s[1] <= '9') ||
|
||||
(s[1] >= 'A' && s[1] <= 'F') ||
|
||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
do {
|
||||
c = *s++;
|
||||
} while (c == ' ');
|
||||
if (c == '-' || c == '+') {
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X') &&
|
||||
((s[1] >= '0' && s[1] <= '9') || (s[1] >= 'A' && s[1] <= 'F') ||
|
||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0) {
|
||||
base = c == '0' ? 8 : 10;
|
||||
base = c == '0' ? 8 : 10;
|
||||
}
|
||||
for ( ; *s; c = *s++) {
|
||||
for (; *s; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
c -= '0';
|
||||
} else if (c >= 'A' && c <= 'Z') {
|
||||
c -= 'A' - 10;
|
||||
c -= 'A' - 10;
|
||||
} else if (c >= 'a' && c <= 'z') {
|
||||
c -= 'a' - 10;
|
||||
c -= 'a' - 10;
|
||||
} else {
|
||||
break;
|
||||
break;
|
||||
}
|
||||
result *= base;
|
||||
result += c;
|
||||
}
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
result *= base;
|
||||
result += c;
|
||||
}
|
||||
return result;
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned long long strtoull(const char *pstart, char **pend, int base)
|
||||
{
|
||||
const char *s = pstart;
|
||||
unsigned long long result = 0;
|
||||
char c;
|
||||
unsigned long long strtoull(const char *pstart, char **pend, int base) {
|
||||
const char *s = pstart;
|
||||
unsigned long long result = 0;
|
||||
char c;
|
||||
|
||||
assert (base > 2 && base < 36);
|
||||
assert(base > 2 && base < 36);
|
||||
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+'){
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X') &&
|
||||
((s[1] >= '0' && s[1] <= '9') ||
|
||||
(s[1] >= 'A' && s[1] <= 'F') ||
|
||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+') {
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X') &&
|
||||
((s[1] >= '0' && s[1] <= '9') || (s[1] >= 'A' && s[1] <= 'F') ||
|
||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0) {
|
||||
base = c == '0' ? 8 : 10;
|
||||
base = c == '0' ? 8 : 10;
|
||||
}
|
||||
for ( ; *s; c = *s++) {
|
||||
for (; *s; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
c -= '0';
|
||||
} else if (c >= 'A' && c <= 'Z') {
|
||||
c -= 'A' - 10;
|
||||
c -= 'A' - 10;
|
||||
} else if (c >= 'a' && c <= 'z') {
|
||||
c -= 'a' - 10;
|
||||
c -= 'a' - 10;
|
||||
} else {
|
||||
break;
|
||||
break;
|
||||
}
|
||||
result *= base;
|
||||
result += c;
|
||||
}
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
result *= base;
|
||||
result += c;
|
||||
}
|
||||
return result;
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
long strtol(const char *pstart, char **pend, int base)
|
||||
{
|
||||
const char *s = pstart;
|
||||
long result = 0;
|
||||
char c;
|
||||
long strtol(const char *pstart, char **pend, int base) {
|
||||
const char *s = pstart;
|
||||
long result = 0;
|
||||
char c;
|
||||
long sign = 1;
|
||||
|
||||
assert (base > 2 && base < 36);
|
||||
assert(base > 2 && base < 36);
|
||||
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+'){
|
||||
sign = (c == '-') ? -1: 1;
|
||||
c = *s++;
|
||||
}
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+') {
|
||||
sign = (c == '-') ? -1 : 1;
|
||||
c = *s++;
|
||||
}
|
||||
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X') &&
|
||||
((s[1] >= '0' && s[1] <= '9') ||
|
||||
(s[1] >= 'A' && s[1] <= 'F') ||
|
||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X') &&
|
||||
((s[1] >= '0' && s[1] <= '9') || (s[1] >= 'A' && s[1] <= 'F') ||
|
||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0) {
|
||||
base = c == '0' ? 8 : 10;
|
||||
base = c == '0' ? 8 : 10;
|
||||
}
|
||||
for ( ; *s; c = *s++) {
|
||||
for (; *s; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
c -= '0';
|
||||
} else if (c >= 'A' && c <= 'Z') {
|
||||
c -= 'A' - 10;
|
||||
c -= 'A' - 10;
|
||||
} else if (c >= 'a' && c <= 'z') {
|
||||
c -= 'a' - 10;
|
||||
c -= 'a' - 10;
|
||||
} else {
|
||||
break;
|
||||
break;
|
||||
}
|
||||
result *= base;
|
||||
result += c;
|
||||
}
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
result *= base;
|
||||
result += c;
|
||||
}
|
||||
return sign * result;
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
}
|
||||
return sign * result;
|
||||
}
|
||||
|
||||
long long strtoll(const char *pstart, char **pend, int base)
|
||||
{
|
||||
const char *s = pstart;
|
||||
long long result = 0;
|
||||
char c;
|
||||
long long strtoll(const char *pstart, char **pend, int base) {
|
||||
const char *s = pstart;
|
||||
long long result = 0;
|
||||
char c;
|
||||
long long sign = 1;
|
||||
|
||||
assert (base > 2 && base < 36);
|
||||
assert(base > 2 && base < 36);
|
||||
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+'){
|
||||
sign = (c == '-') ? -1: 1;
|
||||
c = *s++;
|
||||
}
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+') {
|
||||
sign = (c == '-') ? -1 : 1;
|
||||
c = *s++;
|
||||
}
|
||||
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X') &&
|
||||
((s[1] >= '0' && s[1] <= '9') ||
|
||||
(s[1] >= 'A' && s[1] <= 'F') ||
|
||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X') &&
|
||||
((s[1] >= '0' && s[1] <= '9') || (s[1] >= 'A' && s[1] <= 'F') ||
|
||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0) {
|
||||
base = c == '0' ? 8 : 10;
|
||||
base = c == '0' ? 8 : 10;
|
||||
}
|
||||
for ( ; *s; c = *s++) {
|
||||
for (; *s; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
c -= '0';
|
||||
} else if (c >= 'A' && c <= 'Z') {
|
||||
c -= 'A' - 10;
|
||||
c -= 'A' - 10;
|
||||
} else if (c >= 'a' && c <= 'z') {
|
||||
c -= 'a' - 10;
|
||||
c -= 'a' - 10;
|
||||
} else {
|
||||
break;
|
||||
break;
|
||||
}
|
||||
result *= base;
|
||||
result += c;
|
||||
}
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
result *= base;
|
||||
result += c;
|
||||
}
|
||||
return sign * result;
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
}
|
||||
return sign * result;
|
||||
}
|
||||
|
||||
double strtod(const char *pstart, char **pend)
|
||||
{
|
||||
const char *s = pstart;
|
||||
double result = 0;
|
||||
char c;
|
||||
double strtod(const char *pstart, char **pend) {
|
||||
const char *s = pstart;
|
||||
double result = 0;
|
||||
char c;
|
||||
double sign = 1.0;
|
||||
double frac = 0.1;
|
||||
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+'){
|
||||
sign = (c == '-') ? -1.0 : 1.0;
|
||||
c = *s++;
|
||||
}
|
||||
|
||||
for ( ; ; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result *= 10;
|
||||
result += c;
|
||||
}
|
||||
if(c == '.') {
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+') {
|
||||
sign = (c == '-') ? -1.0 : 1.0;
|
||||
c = *s++;
|
||||
for ( ; ; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result += c * frac;
|
||||
frac *= 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
for (;; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result *= 10;
|
||||
result += c;
|
||||
}
|
||||
return (sign * result);
|
||||
if (c == '.') {
|
||||
c = *s++;
|
||||
for (;; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result += c * frac;
|
||||
frac *= 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
}
|
||||
return (sign * result);
|
||||
}
|
||||
|
||||
long double strtold(const char *pstart, char **pend)
|
||||
{
|
||||
const char *s = pstart;
|
||||
long double result = 0;
|
||||
char c;
|
||||
long double strtold(const char *pstart, char **pend) {
|
||||
const char *s = pstart;
|
||||
long double result = 0;
|
||||
char c;
|
||||
long double sign = 1.0;
|
||||
long double frac = 0.1;
|
||||
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+'){
|
||||
sign = (c == '-') ? -1.0 : 1.0;
|
||||
c = *s++;
|
||||
}
|
||||
|
||||
for ( ; ; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result *= 10;
|
||||
result += c;
|
||||
}
|
||||
if(c == '.') {
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+') {
|
||||
sign = (c == '-') ? -1.0 : 1.0;
|
||||
c = *s++;
|
||||
for ( ; ; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result += c * frac;
|
||||
frac *= 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
for (;; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result *= 10;
|
||||
result += c;
|
||||
}
|
||||
return (sign * result);
|
||||
if (c == '.') {
|
||||
c = *s++;
|
||||
for (;; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result += c * frac;
|
||||
frac *= 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
}
|
||||
return (sign * result);
|
||||
}
|
||||
|
||||
float strtof(const char *pstart, char **pend)
|
||||
{
|
||||
const char *s = pstart;
|
||||
float result = 0;
|
||||
char c;
|
||||
float strtof(const char *pstart, char **pend) {
|
||||
const char *s = pstart;
|
||||
float result = 0;
|
||||
char c;
|
||||
float sign = 1.0;
|
||||
float frac = 0.1;
|
||||
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+'){
|
||||
sign = (c == '-') ? -1.0 : 1.0;
|
||||
c = *s++;
|
||||
}
|
||||
|
||||
for ( ; ; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result *= 10;
|
||||
result += c;
|
||||
}
|
||||
if(c == '.') {
|
||||
do {
|
||||
c = *s++;
|
||||
} while ((c == ' '));
|
||||
if (c == '-' || c == '+') {
|
||||
sign = (c == '-') ? -1.0 : 1.0;
|
||||
c = *s++;
|
||||
for ( ; ; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result += c * frac;
|
||||
frac *= 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
for (;; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result *= 10;
|
||||
result += c;
|
||||
}
|
||||
return (sign * result);
|
||||
if (c == '.') {
|
||||
c = *s++;
|
||||
for (;; c = *s++) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
c -= '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
result += c * frac;
|
||||
frac *= 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pend != NULL) {
|
||||
*pend = (char *)(s - 1);
|
||||
}
|
||||
return (sign * result);
|
||||
}
|
||||
|
||||
char *strchr(const char *s, const char ch)
|
||||
{
|
||||
char *strchr(const char *s, const char ch) {
|
||||
if (NULL == s)
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
|
||||
const char *pSrc = s;
|
||||
while ('\0' != *pSrc)
|
||||
{
|
||||
if (*pSrc == ch)
|
||||
{
|
||||
while ('\0' != *pSrc) {
|
||||
if (*pSrc == ch) {
|
||||
return (char *)pSrc;
|
||||
}
|
||||
}
|
||||
pSrc++;
|
||||
}
|
||||
if(ch == 0)
|
||||
{
|
||||
}
|
||||
if (ch == 0) {
|
||||
return (char *)pSrc;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *strrchr(const char *s, const char ch)
|
||||
{
|
||||
if(s == NULL)
|
||||
{
|
||||
return NULL;
|
||||
char *strrchr(const char *s, const char ch) {
|
||||
if (s == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *p_char = NULL;
|
||||
while(*s != '\0')
|
||||
{
|
||||
if(*s == ch)
|
||||
{
|
||||
p_char = (char *)s;
|
||||
while (*s != '\0') {
|
||||
if (*s == ch) {
|
||||
p_char = (char *)s;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
if(ch == 0)
|
||||
{
|
||||
if (ch == 0) {
|
||||
p_char = (char *)s;
|
||||
}
|
||||
return p_char;
|
||||
}
|
||||
|
||||
char* strstr(const char* dest, const char* src)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *strstr(const char *dest, const char *src) { assert(0); }
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef __BENCH_COMMON
|
||||
#define __BENCH_COMMON
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
uint64_t uptime();
|
||||
char *format_time(uint64_t us);
|
||||
|
@ -14,6 +14,6 @@ typedef struct {
|
|||
uint64_t ref_time;
|
||||
uint32_t checksum;
|
||||
size_t repeat_time;
|
||||
} Setting;
|
||||
} Setting;
|
||||
|
||||
#endif
|
||||
|
|
35
src/common/bench/include/bench_debug.h
Normal file
35
src/common/bench/include/bench_debug.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef __BENCH_DEBUG_H
|
||||
#define __BENCH_DEBUG_H
|
||||
#include <stdarg.h>
|
||||
|
||||
#define ANSI_ERROR "\33[1;31m"
|
||||
#define ANSI_WARN "\33[1;93m"
|
||||
#define ANSI_INFO "\33[1;34m"
|
||||
#define ANSI_DEBUG "\33[1;32m"
|
||||
#define ANSI_TRACE "\33[1;90m"
|
||||
#define ANSI_NONE "\33[0m"
|
||||
|
||||
#ifndef LOG_LEVEL
|
||||
#define LOG_LEVEL 2
|
||||
#endif
|
||||
|
||||
#define LOG_LEVEL_ERROR 0
|
||||
#define LOG_LEVEL_WARN 1
|
||||
#define LOG_LEVEL_INFO 2
|
||||
#define LOG_LEVEL_DEBUG 3
|
||||
#define LOG_LEVEL_TRACE 4
|
||||
|
||||
#define ANSI_FMT(str, fmt) fmt str ANSI_NONE "\n"
|
||||
|
||||
#define BENCH_LOG(level, str, ...) \
|
||||
do { \
|
||||
if (LOG_LEVEL >= LOG_LEVEL_##level) { \
|
||||
bench_printf(ANSI_FMT(str, ANSI_##level), ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int bench_vsprintf(char *buf, const char *fmt, va_list args);
|
||||
int bench_sprintf(char *s, const char *fmt, ...);
|
||||
int bench_printf(const char *fmt, ...);
|
||||
|
||||
#endif
|
|
@ -5,11 +5,10 @@
|
|||
#include <stdint.h>
|
||||
|
||||
void bench_malloc_init();
|
||||
void *bench_malloc (size_t size);
|
||||
void *bench_calloc (size_t number, size_t size);
|
||||
void *bench_realloc (void *p, size_t size);
|
||||
void bench_free (void *ptr);
|
||||
void bench_all_free (void);
|
||||
void *bench_malloc(size_t size);
|
||||
void *bench_calloc(size_t number, size_t size);
|
||||
void *bench_realloc(void *p, size_t size);
|
||||
void bench_free(void *ptr);
|
||||
void bench_all_free(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
int strcasecmp (const char *s1, const char *s2);
|
||||
int strncasecmp (const char *s1, const char *s2, size_t n);
|
||||
char* strdup (const char* str);
|
||||
size_t strspn (const char *str, const char *group);
|
||||
size_t strcspn ( const char * str1, const char * str2 );
|
||||
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
char *strdup(const char *str);
|
||||
size_t strspn(const char *str, const char *group);
|
||||
size_t strcspn(const char *str1, const char *str2);
|
||||
|
||||
unsigned long strtoul(const char *pstart, char **pend, int base);
|
||||
unsigned long long strtoull(const char *pstart, char **pend, int base);
|
||||
|
@ -18,9 +17,7 @@ double strtod(const char *pstart, char **pend);
|
|||
long double strtold(const char *pstart, char **pend);
|
||||
float strtof(const char *pstart, char **pend);
|
||||
char *strchr(const char *s, const char ch);
|
||||
char* strstr(const char* dest, const char* src);
|
||||
char *strstr(const char *dest, const char *src);
|
||||
char *strrchr(const char *s, const char ch);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -7,34 +7,30 @@
|
|||
* Annex B Byte Stream format
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "annexb.h"
|
||||
#include "memalloc.h"
|
||||
#include "fast_memory.h"
|
||||
#include "global.h"
|
||||
#include "memalloc.h"
|
||||
|
||||
static const int IOBUFFERSIZE = 512*1024; //65536;
|
||||
static const int IOBUFFERSIZE = 512 * 1024; // 65536;
|
||||
|
||||
void malloc_annex_b(VideoParameters *p_Vid)
|
||||
{
|
||||
if ( (p_Vid->annex_b = (ANNEXB_t *) calloc(1, sizeof(ANNEXB_t))) == NULL)
|
||||
{
|
||||
void malloc_annex_b(VideoParameters *p_Vid) {
|
||||
if ((p_Vid->annex_b = (ANNEXB_t *)calloc(1, sizeof(ANNEXB_t))) == NULL) {
|
||||
snprintf(errortext, ET_SIZE, "Memory allocation for Annex_B file failed");
|
||||
error(errortext,100);
|
||||
error(errortext, 100);
|
||||
}
|
||||
if ((p_Vid->annex_b->Buf = (byte*) malloc(p_Vid->nalu->max_size)) == NULL)
|
||||
{
|
||||
if ((p_Vid->annex_b->Buf = (byte *)malloc(p_Vid->nalu->max_size)) == NULL) {
|
||||
error("GetAnnexbNALU: Buf", 101);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_annex_b(ANNEXB_t *annex_b)
|
||||
{
|
||||
void init_annex_b(ANNEXB_t *annex_b) {
|
||||
annex_b->BitStreamFile = -1;
|
||||
annex_b->iobuffer = NULL;
|
||||
annex_b->iobufferread = NULL;
|
||||
|
@ -44,12 +40,11 @@ void init_annex_b(ANNEXB_t *annex_b)
|
|||
annex_b->nextstartcodebytes = 0;
|
||||
}
|
||||
|
||||
void free_annex_b(VideoParameters *p_Vid)
|
||||
{
|
||||
void free_annex_b(VideoParameters *p_Vid) {
|
||||
free(p_Vid->annex_b->Buf);
|
||||
p_Vid->annex_b->Buf = NULL;
|
||||
free(p_Vid->annex_b);
|
||||
p_Vid->annex_b = NULL;
|
||||
p_Vid->annex_b = NULL;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -58,11 +53,10 @@ void free_annex_b(VideoParameters *p_Vid)
|
|||
* fill IO buffer
|
||||
************************************************************************
|
||||
*/
|
||||
static inline int getChunk(ANNEXB_t *annex_b)
|
||||
{
|
||||
unsigned int readbytes = read (annex_b->BitStreamFile, annex_b->iobuffer, annex_b->iIOBufferSize);
|
||||
if (0==readbytes)
|
||||
{
|
||||
static inline int getChunk(ANNEXB_t *annex_b) {
|
||||
unsigned int readbytes =
|
||||
read(annex_b->BitStreamFile, annex_b->iobuffer, annex_b->iIOBufferSize);
|
||||
if (0 == readbytes) {
|
||||
annex_b->is_eof = TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
@ -78,10 +72,8 @@ static inline int getChunk(ANNEXB_t *annex_b)
|
|||
* returns a byte from IO buffer
|
||||
************************************************************************
|
||||
*/
|
||||
static inline byte getfbyte(ANNEXB_t *annex_b)
|
||||
{
|
||||
if (0 == annex_b->bytesinbuffer)
|
||||
{
|
||||
static inline byte getfbyte(ANNEXB_t *annex_b) {
|
||||
if (0 == annex_b->bytesinbuffer) {
|
||||
if (0 == getChunk(annex_b))
|
||||
return 0;
|
||||
}
|
||||
|
@ -105,25 +97,21 @@ static inline byte getfbyte(ANNEXB_t *annex_b)
|
|||
* indicates number of 0x00 bytes in start-code.
|
||||
************************************************************************
|
||||
*/
|
||||
static inline int FindStartCode (unsigned char *Buf, int zeros_in_startcode)
|
||||
{
|
||||
static inline int FindStartCode(unsigned char *Buf, int zeros_in_startcode) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < zeros_in_startcode; i++)
|
||||
{
|
||||
if(*(Buf++) != 0)
|
||||
{
|
||||
for (i = 0; i < zeros_in_startcode; i++) {
|
||||
if (*(Buf++) != 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(*Buf != 1)
|
||||
if (*Buf != 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -143,8 +131,7 @@ static inline int FindStartCode (unsigned char *Buf, int zeros_in_startcode)
|
|||
************************************************************************
|
||||
*/
|
||||
|
||||
int GetAnnexbNALU (VideoParameters *p_Vid, NALU_t *nalu)
|
||||
{
|
||||
int GetAnnexbNALU(VideoParameters *p_Vid, NALU_t *nalu) {
|
||||
ANNEXB_t *annex_b = p_Vid->annex_b;
|
||||
int i;
|
||||
int info2 = 0, info3 = 0, pos = 0;
|
||||
|
@ -152,150 +139,139 @@ int GetAnnexbNALU (VideoParameters *p_Vid, NALU_t *nalu)
|
|||
int LeadingZero8BitsCount = 0;
|
||||
byte *pBuf = annex_b->Buf;
|
||||
|
||||
if (annex_b->nextstartcodebytes != 0)
|
||||
{
|
||||
for (i=0; i<annex_b->nextstartcodebytes-1; i++)
|
||||
{
|
||||
if (annex_b->nextstartcodebytes != 0) {
|
||||
for (i = 0; i < annex_b->nextstartcodebytes - 1; i++) {
|
||||
(*pBuf++) = 0;
|
||||
pos++;
|
||||
}
|
||||
(*pBuf++) = 1;
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(!annex_b->is_eof)
|
||||
{
|
||||
} else {
|
||||
while (!annex_b->is_eof) {
|
||||
pos++;
|
||||
if ((*(pBuf++)= getfbyte(annex_b))!= 0)
|
||||
if ((*(pBuf++) = getfbyte(annex_b)) != 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(annex_b->is_eof == TRUE)
|
||||
{
|
||||
if(pos==0)
|
||||
{
|
||||
if (annex_b->is_eof == TRUE) {
|
||||
if (pos == 0) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "GetAnnexbNALU can't read start code\n");
|
||||
} else {
|
||||
printf("GetAnnexbNALU can't read start code\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(*(pBuf - 1) != 1 || pos < 3)
|
||||
{
|
||||
printf ("GetAnnexbNALU: no Start Code at the beginning of the NALU, return -1\n");
|
||||
if (*(pBuf - 1) != 1 || pos < 3) {
|
||||
printf("GetAnnexbNALU: no Start Code at the beginning of the NALU, return "
|
||||
"-1\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pos == 3)
|
||||
{
|
||||
if (pos == 3) {
|
||||
nalu->startcodeprefix_len = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
LeadingZero8BitsCount = pos - 4;
|
||||
nalu->startcodeprefix_len = 4;
|
||||
}
|
||||
|
||||
//the 1st byte stream NAL unit can has leading_zero_8bits, but subsequent ones are not
|
||||
//allowed to contain it since these zeros(if any) are considered trailing_zero_8bits
|
||||
//of the previous byte stream NAL unit.
|
||||
if(!annex_b->IsFirstByteStreamNALU && LeadingZero8BitsCount > 0)
|
||||
{
|
||||
printf ("GetAnnexbNALU: The leading_zero_8bits syntax can only be present in the first byte stream NAL unit, return -1\n");
|
||||
// the 1st byte stream NAL unit can has leading_zero_8bits, but subsequent
|
||||
// ones are not allowed to contain it since these zeros(if any) are considered
|
||||
// trailing_zero_8bits of the previous byte stream NAL unit.
|
||||
if (!annex_b->IsFirstByteStreamNALU && LeadingZero8BitsCount > 0) {
|
||||
printf("GetAnnexbNALU: The leading_zero_8bits syntax can only be present "
|
||||
"in the first byte stream NAL unit, return -1\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
LeadingZero8BitsCount = pos;
|
||||
annex_b->IsFirstByteStreamNALU = 0;
|
||||
|
||||
while (!StartCodeFound)
|
||||
{
|
||||
if (annex_b->is_eof == TRUE)
|
||||
{
|
||||
while (!StartCodeFound) {
|
||||
if (annex_b->is_eof == TRUE) {
|
||||
pBuf -= 2;
|
||||
while(*(pBuf--)==0)
|
||||
while (*(pBuf--) == 0)
|
||||
pos--;
|
||||
|
||||
nalu->len = (pos - 1) - LeadingZero8BitsCount;
|
||||
memcpy (nalu->buf, annex_b->Buf + LeadingZero8BitsCount, nalu->len);
|
||||
nalu->forbidden_bit = (*(nalu->buf) >> 7) & 1;
|
||||
nalu->nal_reference_idc = (NalRefIdc) ((*(nalu->buf) >> 5) & 3);
|
||||
nalu->nal_unit_type = (NaluType) ((*(nalu->buf)) & 0x1f);
|
||||
memcpy(nalu->buf, annex_b->Buf + LeadingZero8BitsCount, nalu->len);
|
||||
nalu->forbidden_bit = (*(nalu->buf) >> 7) & 1;
|
||||
nalu->nal_reference_idc = (NalRefIdc)((*(nalu->buf) >> 5) & 3);
|
||||
nalu->nal_unit_type = (NaluType)((*(nalu->buf)) & 0x1f);
|
||||
annex_b->nextstartcodebytes = 0;
|
||||
|
||||
// printf ("GetAnnexbNALU, eof case: pos %d nalu->len %d, nalu->reference_idc %d, nal_unit_type %d \n", pos, nalu->len, nalu->nal_reference_idc, nalu->nal_unit_type);
|
||||
// printf ("GetAnnexbNALU, eof case: pos %d nalu->len %d,
|
||||
// nalu->reference_idc %d, nal_unit_type %d \n", pos, nalu->len,
|
||||
// nalu->nal_reference_idc, nalu->nal_unit_type);
|
||||
|
||||
#if TRACE
|
||||
fprintf (p_Dec->p_trace, "\n\nLast NALU in File\n\n");
|
||||
fprintf (p_Dec->p_trace, "Annex B NALU w/ %s startcode, len %d, forbidden_bit %d, nal_reference_idc %d, nal_unit_type %d\n\n",
|
||||
nalu->startcodeprefix_len == 4?"long":"short", nalu->len, nalu->forbidden_bit, nalu->nal_reference_idc, nalu->nal_unit_type);
|
||||
fflush (p_Dec->p_trace);
|
||||
fprintf(p_Dec->p_trace, "\n\nLast NALU in File\n\n");
|
||||
fprintf(p_Dec->p_trace,
|
||||
"Annex B NALU w/ %s startcode, len %d, forbidden_bit %d, "
|
||||
"nal_reference_idc %d, nal_unit_type %d\n\n",
|
||||
nalu->startcodeprefix_len == 4 ? "long" : "short", nalu->len,
|
||||
nalu->forbidden_bit, nalu->nal_reference_idc,
|
||||
nalu->nal_unit_type);
|
||||
fflush(p_Dec->p_trace);
|
||||
#endif
|
||||
return (pos - 1);
|
||||
}
|
||||
|
||||
pos++;
|
||||
*(pBuf ++) = getfbyte(annex_b);
|
||||
*(pBuf++) = getfbyte(annex_b);
|
||||
info3 = FindStartCode(pBuf - 4, 3);
|
||||
if(info3 != 1)
|
||||
{
|
||||
if (info3 != 1) {
|
||||
info2 = FindStartCode(pBuf - 3, 2);
|
||||
StartCodeFound = info2 & 0x01;
|
||||
}
|
||||
else
|
||||
} else
|
||||
StartCodeFound = 1;
|
||||
}
|
||||
|
||||
// Here, we have found another start code (and read length of startcode bytes more than we should
|
||||
// have. Hence, go back in the file
|
||||
if(info3 == 1) //if the detected start code is 00 00 01, trailing_zero_8bits is sure not to be present
|
||||
// Here, we have found another start code (and read length of startcode bytes
|
||||
// more than we should have. Hence, go back in the file
|
||||
if (info3 == 1) // if the detected start code is 00 00 01, trailing_zero_8bits
|
||||
// is sure not to be present
|
||||
{
|
||||
pBuf -= 5;
|
||||
while(*(pBuf--) == 0)
|
||||
while (*(pBuf--) == 0)
|
||||
pos--;
|
||||
annex_b->nextstartcodebytes = 4;
|
||||
}
|
||||
else if (info2 == 1)
|
||||
} else if (info2 == 1)
|
||||
annex_b->nextstartcodebytes = 3;
|
||||
else
|
||||
{
|
||||
else {
|
||||
printf(" Panic: Error in next start code search \n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pos -= annex_b->nextstartcodebytes;
|
||||
|
||||
// Here the leading zeros(if any), Start code, the complete NALU, trailing zeros(if any)
|
||||
// and the next start code is in the Buf.
|
||||
// The size of Buf is pos - rewind, pos are the number of bytes excluding the next
|
||||
// start code, and (pos) - LeadingZero8BitsCount
|
||||
// is the size of the NALU.
|
||||
// Here the leading zeros(if any), Start code, the complete NALU, trailing
|
||||
// zeros(if any) and the next start code is in the Buf. The size of Buf is pos
|
||||
// - rewind, pos are the number of bytes excluding the next start code, and
|
||||
// (pos) - LeadingZero8BitsCount is the size of the NALU.
|
||||
|
||||
nalu->len = pos - LeadingZero8BitsCount;
|
||||
fast_memcpy (nalu->buf, annex_b->Buf + LeadingZero8BitsCount, nalu->len);
|
||||
nalu->forbidden_bit = (*(nalu->buf) >> 7) & 1;
|
||||
nalu->nal_reference_idc = (NalRefIdc) ((*(nalu->buf) >> 5) & 3);
|
||||
nalu->nal_unit_type = (NaluType) ((*(nalu->buf)) & 0x1f);
|
||||
fast_memcpy(nalu->buf, annex_b->Buf + LeadingZero8BitsCount, nalu->len);
|
||||
nalu->forbidden_bit = (*(nalu->buf) >> 7) & 1;
|
||||
nalu->nal_reference_idc = (NalRefIdc)((*(nalu->buf) >> 5) & 3);
|
||||
nalu->nal_unit_type = (NaluType)((*(nalu->buf)) & 0x1f);
|
||||
nalu->lost_packets = 0;
|
||||
|
||||
|
||||
//printf ("GetAnnexbNALU, regular case: pos %d nalu->len %d, nalu->reference_idc %d, nal_unit_type %d \n", pos, nalu->len, nalu->nal_reference_idc, nalu->nal_unit_type);
|
||||
// printf ("GetAnnexbNALU, regular case: pos %d nalu->len %d,
|
||||
// nalu->reference_idc %d, nal_unit_type %d \n", pos, nalu->len,
|
||||
// nalu->nal_reference_idc, nalu->nal_unit_type);
|
||||
#if TRACE
|
||||
fprintf (p_Dec->p_trace, "\n\nAnnex B NALU w/ %s startcode, len %d, forbidden_bit %d, nal_reference_idc %d, nal_unit_type %d\n\n",
|
||||
nalu->startcodeprefix_len == 4?"long":"short", nalu->len, nalu->forbidden_bit, nalu->nal_reference_idc, nalu->nal_unit_type);
|
||||
fflush (p_Dec->p_trace);
|
||||
fprintf(p_Dec->p_trace,
|
||||
"\n\nAnnex B NALU w/ %s startcode, len %d, forbidden_bit %d, "
|
||||
"nal_reference_idc %d, nal_unit_type %d\n\n",
|
||||
nalu->startcodeprefix_len == 4 ? "long" : "short", nalu->len,
|
||||
nalu->forbidden_bit, nalu->nal_reference_idc, nalu->nal_unit_type);
|
||||
fflush(p_Dec->p_trace);
|
||||
#endif
|
||||
|
||||
return (pos);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -304,51 +280,43 @@ int GetAnnexbNALU (VideoParameters *p_Vid, NALU_t *nalu)
|
|||
* none
|
||||
************************************************************************
|
||||
*/
|
||||
void OpenAnnexBFile (VideoParameters *p_Vid, char *fn)
|
||||
{
|
||||
void OpenAnnexBFile(VideoParameters *p_Vid, char *fn) {
|
||||
ANNEXB_t *annex_b = p_Vid->annex_b;
|
||||
if (NULL != annex_b->iobuffer)
|
||||
{
|
||||
error ("OpenAnnexBFile: tried to open Annex B file twice",500);
|
||||
if (NULL != annex_b->iobuffer) {
|
||||
error("OpenAnnexBFile: tried to open Annex B file twice", 500);
|
||||
}
|
||||
if ((annex_b->BitStreamFile = open(fn, OPENFLAGS_READ)) == -1)
|
||||
{
|
||||
snprintf (errortext, ET_SIZE, "Cannot open Annex B ByteStream file '%s'", fn);
|
||||
error(errortext,500);
|
||||
if ((annex_b->BitStreamFile = open(fn, OPENFLAGS_READ)) == -1) {
|
||||
snprintf(errortext, ET_SIZE, "Cannot open Annex B ByteStream file '%s'",
|
||||
fn);
|
||||
error(errortext, 500);
|
||||
}
|
||||
|
||||
annex_b->iIOBufferSize = IOBUFFERSIZE * sizeof (byte);
|
||||
annex_b->iobuffer = malloc (annex_b->iIOBufferSize);
|
||||
if (NULL == annex_b->iobuffer)
|
||||
{
|
||||
error ("OpenAnnexBFile: cannot allocate IO buffer",500);
|
||||
annex_b->iIOBufferSize = IOBUFFERSIZE * sizeof(byte);
|
||||
annex_b->iobuffer = malloc(annex_b->iIOBufferSize);
|
||||
if (NULL == annex_b->iobuffer) {
|
||||
error("OpenAnnexBFile: cannot allocate IO buffer", 500);
|
||||
}
|
||||
annex_b->is_eof = FALSE;
|
||||
getChunk(annex_b);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
* Closes the bit stream file
|
||||
************************************************************************
|
||||
*/
|
||||
void CloseAnnexBFile(VideoParameters *p_Vid)
|
||||
{
|
||||
void CloseAnnexBFile(VideoParameters *p_Vid) {
|
||||
ANNEXB_t *annex_b = p_Vid->annex_b;
|
||||
if (annex_b->BitStreamFile != -1)
|
||||
{
|
||||
if (annex_b->BitStreamFile != -1) {
|
||||
close(annex_b->BitStreamFile);
|
||||
annex_b->BitStreamFile = - 1;
|
||||
annex_b->BitStreamFile = -1;
|
||||
}
|
||||
free (annex_b->iobuffer);
|
||||
free(annex_b->iobuffer);
|
||||
annex_b->iobuffer = NULL;
|
||||
}
|
||||
|
||||
|
||||
void ResetAnnexB(ANNEXB_t *annex_b)
|
||||
{
|
||||
void ResetAnnexB(ANNEXB_t *annex_b) {
|
||||
annex_b->is_eof = FALSE;
|
||||
annex_b->bytesinbuffer = 0;
|
||||
annex_b->iobufferread = annex_b->iobuffer;
|
||||
|
|
|
@ -5,27 +5,27 @@
|
|||
* \brief
|
||||
* Binary arithmetic decoder routines.
|
||||
*
|
||||
* This modified implementation of the M Coder is based on JVT-U084
|
||||
* This modified implementation of the M Coder is based on JVT-U084
|
||||
* with the choice of M_BITS = 16.
|
||||
*
|
||||
* \date
|
||||
* 21. Oct 2000
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Detlev Marpe <marpe@hhi.de>
|
||||
* - Gabi Blaettermann
|
||||
* - Gunnar Marten
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
||||
#include "biaridecod.h"
|
||||
#include "global.h"
|
||||
#include "memalloc.h"
|
||||
#include "biaridecod.h"
|
||||
|
||||
|
||||
#define B_BITS 10 // Number of bits to represent the whole coding interval
|
||||
#define HALF 0x01FE //(1 << (B_BITS-1)) - 2
|
||||
#define QUARTER 0x0100 //(1 << (B_BITS-2))
|
||||
#define B_BITS 10 // Number of bits to represent the whole coding interval
|
||||
#define HALF 0x01FE //(1 << (B_BITS-1)) - 2
|
||||
#define QUARTER 0x0100 //(1 << (B_BITS-2))
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
|
@ -35,30 +35,25 @@
|
|||
* allocates memory
|
||||
************************************************************************
|
||||
*/
|
||||
DecodingEnvironmentPtr arideco_create_decoding_environment()
|
||||
{
|
||||
DecodingEnvironmentPtr arideco_create_decoding_environment() {
|
||||
DecodingEnvironmentPtr dep;
|
||||
|
||||
if ((dep = calloc(1,sizeof(DecodingEnvironment))) == NULL)
|
||||
if ((dep = calloc(1, sizeof(DecodingEnvironment))) == NULL)
|
||||
no_mem_exit("arideco_create_decoding_environment: dep");
|
||||
return dep;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
* Frees memory of the DecodingEnvironment struct
|
||||
***********************************************************************
|
||||
*/
|
||||
void arideco_delete_decoding_environment(DecodingEnvironmentPtr dep)
|
||||
{
|
||||
if (dep == NULL)
|
||||
{
|
||||
void arideco_delete_decoding_environment(DecodingEnvironmentPtr dep) {
|
||||
if (dep == NULL) {
|
||||
snprintf(errortext, ET_SIZE, "Error freeing dep (NULL pointer)");
|
||||
error (errortext, 200);
|
||||
}
|
||||
else
|
||||
error(errortext, 200);
|
||||
} else
|
||||
free(dep);
|
||||
}
|
||||
|
||||
|
@ -68,10 +63,9 @@ void arideco_delete_decoding_environment(DecodingEnvironmentPtr dep)
|
|||
* finalize arithetic decoding():
|
||||
************************************************************************
|
||||
*/
|
||||
void arideco_done_decoding(DecodingEnvironmentPtr dep)
|
||||
{
|
||||
void arideco_done_decoding(DecodingEnvironmentPtr dep) {
|
||||
(*dep->Dcodestrm_len)++;
|
||||
#if(TRACE==2)
|
||||
#if (TRACE == 2)
|
||||
fprintf(p_trace, "done_decoding: %d\n", *dep->Dcodestrm_len);
|
||||
#endif
|
||||
}
|
||||
|
@ -82,9 +76,8 @@ void arideco_done_decoding(DecodingEnvironmentPtr dep)
|
|||
* read one byte from the bitstream
|
||||
************************************************************************
|
||||
*/
|
||||
unsigned int getbyte(DecodingEnvironmentPtr dep)
|
||||
{
|
||||
#if(TRACE==2)
|
||||
unsigned int getbyte(DecodingEnvironmentPtr dep) {
|
||||
#if (TRACE == 2)
|
||||
fprintf(p_trace, "get_byte: %d\n", (*dep->Dcodestrm_len));
|
||||
#endif
|
||||
return dep->Dcodestrm[(*dep->Dcodestrm_len)++];
|
||||
|
@ -96,15 +89,14 @@ unsigned int getbyte(DecodingEnvironmentPtr dep)
|
|||
* read two bytes from the bitstream
|
||||
************************************************************************
|
||||
*/
|
||||
unsigned int getword(DecodingEnvironmentPtr dep)
|
||||
{
|
||||
unsigned int getword(DecodingEnvironmentPtr dep) {
|
||||
int d = *dep->Dcodestrm_len;
|
||||
#if(TRACE==2)
|
||||
#if (TRACE == 2)
|
||||
fprintf(p_trace, "get_byte: %d\n", d);
|
||||
fprintf(p_trace, "get_byte: %d\n", d + 1);
|
||||
#endif
|
||||
*dep->Dcodestrm_len += 2;
|
||||
return ((dep->Dcodestrm[d]<<8) | dep->Dcodestrm[d+1]);
|
||||
return ((dep->Dcodestrm[d] << 8) | dep->Dcodestrm[d + 1]);
|
||||
}
|
||||
/*!
|
||||
************************************************************************
|
||||
|
@ -112,43 +104,43 @@ unsigned int getword(DecodingEnvironmentPtr dep)
|
|||
* Initializes the DecodingEnvironment for the arithmetic coder
|
||||
************************************************************************
|
||||
*/
|
||||
void arideco_start_decoding(DecodingEnvironmentPtr dep, unsigned char *code_buffer,
|
||||
int firstbyte, int *code_len)
|
||||
{
|
||||
void arideco_start_decoding(DecodingEnvironmentPtr dep,
|
||||
unsigned char *code_buffer, int firstbyte,
|
||||
int *code_len) {
|
||||
|
||||
dep->Dcodestrm = code_buffer;
|
||||
dep->Dcodestrm_len = code_len;
|
||||
dep->Dcodestrm = code_buffer;
|
||||
dep->Dcodestrm_len = code_len;
|
||||
*dep->Dcodestrm_len = firstbyte;
|
||||
|
||||
dep->Dvalue = getbyte(dep);
|
||||
dep->Dvalue = (dep->Dvalue << 16) | getword(dep); // lookahead of 2 bytes: always make sure that bitstream buffer
|
||||
// contains 2 more bytes than actual bitstream
|
||||
dep->Dvalue =
|
||||
(dep->Dvalue << 16) |
|
||||
getword(dep); // lookahead of 2 bytes: always make sure that bitstream
|
||||
// buffer contains 2 more bytes than actual bitstream
|
||||
dep->DbitsLeft = 15;
|
||||
dep->Drange = HALF;
|
||||
|
||||
#if (2==TRACE)
|
||||
fprintf(p_trace, "value: %d firstbyte: %d code_len: %d\n", dep->Dvalue >> dep->DbitsLeft, firstbyte, *code_len);
|
||||
#if (2 == TRACE)
|
||||
fprintf(p_trace, "value: %d firstbyte: %d code_len: %d\n",
|
||||
dep->Dvalue >> dep->DbitsLeft, firstbyte, *code_len);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
* arideco_bits_read
|
||||
************************************************************************
|
||||
*/
|
||||
int arideco_bits_read(DecodingEnvironmentPtr dep)
|
||||
{
|
||||
int arideco_bits_read(DecodingEnvironmentPtr dep) {
|
||||
int tmp = ((*dep->Dcodestrm_len) << 3) - dep->DbitsLeft;
|
||||
|
||||
#if (2==TRACE)
|
||||
#if (2 == TRACE)
|
||||
fprintf(p_trace, "tmp: %d\n", tmp);
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -157,53 +149,48 @@ int arideco_bits_read(DecodingEnvironmentPtr dep)
|
|||
* the decoded symbol
|
||||
************************************************************************
|
||||
*/
|
||||
unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi_ct )
|
||||
{
|
||||
unsigned int bit = bi_ct->MPS;
|
||||
unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep,
|
||||
BiContextTypePtr bi_ct) {
|
||||
unsigned int bit = bi_ct->MPS;
|
||||
unsigned int *value = &dep->Dvalue;
|
||||
unsigned int *range = &dep->Drange;
|
||||
uint16 *state = &bi_ct->state;
|
||||
unsigned int rLPS = rLPS_table_64x4[*state][(*range>>6) & 0x03];
|
||||
unsigned int *range = &dep->Drange;
|
||||
uint16 *state = &bi_ct->state;
|
||||
unsigned int rLPS = rLPS_table_64x4[*state][(*range >> 6) & 0x03];
|
||||
int *DbitsLeft = &dep->DbitsLeft;
|
||||
|
||||
*range -= rLPS;
|
||||
|
||||
if(*value < (*range << *DbitsLeft)) //MPS
|
||||
if (*value < (*range << *DbitsLeft)) // MPS
|
||||
{
|
||||
*state = AC_next_state_MPS_64[*state]; // next state
|
||||
*state = AC_next_state_MPS_64[*state]; // next state
|
||||
|
||||
if( *range >= QUARTER )
|
||||
{
|
||||
if (*range >= QUARTER) {
|
||||
return (bit);
|
||||
}
|
||||
else
|
||||
} else
|
||||
*range <<= 1;
|
||||
|
||||
(*DbitsLeft)--;
|
||||
}
|
||||
else // LPS
|
||||
} else // LPS
|
||||
{
|
||||
int renorm = renorm_table_32[(rLPS>>3) & 0x1F];
|
||||
int renorm = renorm_table_32[(rLPS >> 3) & 0x1F];
|
||||
*value -= (*range << dep->DbitsLeft);
|
||||
|
||||
*range = (rLPS << renorm);
|
||||
(*DbitsLeft) -= renorm;
|
||||
|
||||
bit ^= 0x01;
|
||||
if (!(*state)) // switch meaning of MPS if necessary
|
||||
bi_ct->MPS ^= 0x01;
|
||||
if (!(*state)) // switch meaning of MPS if necessary
|
||||
bi_ct->MPS ^= 0x01;
|
||||
|
||||
*state = AC_next_state_LPS_64[*state]; // next state
|
||||
*state = AC_next_state_LPS_64[*state]; // next state
|
||||
}
|
||||
|
||||
if( *DbitsLeft > 0 )
|
||||
{
|
||||
if (*DbitsLeft > 0) {
|
||||
return (bit);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
*value <<= 16;
|
||||
*value |= getword(dep); // lookahead of 2 bytes: always make sure that bitstream buffer
|
||||
*value |= getword(
|
||||
dep); // lookahead of 2 bytes: always make sure that bitstream buffer
|
||||
// contains 2 more bytes than actual bitstream
|
||||
(*DbitsLeft) += 16;
|
||||
|
||||
|
@ -211,7 +198,6 @@ unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -220,26 +206,23 @@ unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi
|
|||
* the decoded symbol
|
||||
************************************************************************
|
||||
*/
|
||||
unsigned int biari_decode_symbol_eq_prob(DecodingEnvironmentPtr dep)
|
||||
{
|
||||
int tmp_value;
|
||||
unsigned int *value = &dep->Dvalue;
|
||||
int *DbitsLeft = &dep->DbitsLeft;
|
||||
unsigned int biari_decode_symbol_eq_prob(DecodingEnvironmentPtr dep) {
|
||||
int tmp_value;
|
||||
unsigned int *value = &dep->Dvalue;
|
||||
int *DbitsLeft = &dep->DbitsLeft;
|
||||
|
||||
if(--(*DbitsLeft) == 0)
|
||||
{
|
||||
*value = (*value << 16) | getword( dep ); // lookahead of 2 bytes: always make sure that bitstream buffer
|
||||
// contains 2 more bytes than actual bitstream
|
||||
if (--(*DbitsLeft) == 0) {
|
||||
*value =
|
||||
(*value << 16) |
|
||||
getword(dep); // lookahead of 2 bytes: always make sure that bitstream
|
||||
// buffer contains 2 more bytes than actual bitstream
|
||||
*DbitsLeft = 16;
|
||||
}
|
||||
tmp_value = *value - (dep->Drange << *DbitsLeft);
|
||||
tmp_value = *value - (dep->Drange << *DbitsLeft);
|
||||
|
||||
if (tmp_value < 0)
|
||||
{
|
||||
if (tmp_value < 0) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
*value = tmp_value;
|
||||
return 1;
|
||||
}
|
||||
|
@ -253,35 +236,30 @@ unsigned int biari_decode_symbol_eq_prob(DecodingEnvironmentPtr dep)
|
|||
* the decoded symbol
|
||||
************************************************************************
|
||||
*/
|
||||
unsigned int biari_decode_final(DecodingEnvironmentPtr dep)
|
||||
{
|
||||
unsigned int range = dep->Drange - 2;
|
||||
int value = dep->Dvalue;
|
||||
unsigned int biari_decode_final(DecodingEnvironmentPtr dep) {
|
||||
unsigned int range = dep->Drange - 2;
|
||||
int value = dep->Dvalue;
|
||||
value -= (range << dep->DbitsLeft);
|
||||
|
||||
if (value < 0)
|
||||
{
|
||||
if( range >= QUARTER )
|
||||
{
|
||||
if (value < 0) {
|
||||
if (range >= QUARTER) {
|
||||
dep->Drange = range;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dep->Drange = (range << 1);
|
||||
if( --(dep->DbitsLeft) > 0 )
|
||||
if (--(dep->DbitsLeft) > 0)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
dep->Dvalue = (dep->Dvalue << 16) | getword( dep ); // lookahead of 2 bytes: always make sure that bitstream buffer
|
||||
// contains 2 more bytes than actual bitstream
|
||||
else {
|
||||
dep->Dvalue =
|
||||
(dep->Dvalue << 16) |
|
||||
getword(
|
||||
dep); // lookahead of 2 bytes: always make sure that bitstream
|
||||
// buffer contains 2 more bytes than actual bitstream
|
||||
dep->DbitsLeft = 16;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -292,21 +270,16 @@ unsigned int biari_decode_final(DecodingEnvironmentPtr dep)
|
|||
* Initializes a given context with some pre-defined probability state
|
||||
************************************************************************
|
||||
*/
|
||||
void biari_init_context (int qp, BiContextTypePtr ctx, const signed char* ini)
|
||||
{
|
||||
int pstate = ((ini[0]* qp )>>4) + ini[1];
|
||||
void biari_init_context(int qp, BiContextTypePtr ctx, const signed char *ini) {
|
||||
int pstate = ((ini[0] * qp) >> 4) + ini[1];
|
||||
|
||||
if ( pstate >= 64 )
|
||||
{
|
||||
if (pstate >= 64) {
|
||||
pstate = imin(126, pstate);
|
||||
ctx->state = (uint16) (pstate - 64);
|
||||
ctx->MPS = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx->state = (uint16)(pstate - 64);
|
||||
ctx->MPS = 1;
|
||||
} else {
|
||||
pstate = imax(1, pstate);
|
||||
ctx->state = (uint16) (63 - pstate);
|
||||
ctx->MPS = 0;
|
||||
ctx->state = (uint16)(63 - pstate);
|
||||
ctx->MPS = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* Block Prediction related functions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
*************************************************************************************
|
||||
|
@ -14,49 +15,48 @@
|
|||
|
||||
#include "contributors.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "block.h"
|
||||
#include "global.h"
|
||||
|
||||
#include "macroblock.h"
|
||||
#include "mc_prediction.h"
|
||||
#include "image.h"
|
||||
#include "macroblock.h"
|
||||
#include "mb_access.h"
|
||||
#include "mc_prediction.h"
|
||||
|
||||
void compute_residue (imgpel **curImg, imgpel **mpr, int **mb_rres, int mb_x, int opix_x, int width, int height)
|
||||
{
|
||||
void compute_residue(imgpel **curImg, imgpel **mpr, int **mb_rres, int mb_x,
|
||||
int opix_x, int width, int height) {
|
||||
imgpel *imgOrg, *imgPred;
|
||||
int *m7;
|
||||
int *m7;
|
||||
int i, j;
|
||||
|
||||
for (j = 0; j < height; j++)
|
||||
{
|
||||
imgOrg = &curImg[j][opix_x];
|
||||
for (j = 0; j < height; j++) {
|
||||
imgOrg = &curImg[j][opix_x];
|
||||
imgPred = &mpr[j][mb_x];
|
||||
m7 = &mb_rres[j][mb_x];
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
m7 = &mb_rres[j][mb_x];
|
||||
for (i = 0; i < width; i++) {
|
||||
*m7++ = *imgOrg++ - *imgPred++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sample_reconstruct (imgpel **curImg, imgpel **mpr, int **mb_rres, int mb_x, int opix_x, int width, int height, int max_imgpel_value, int dq_bits)
|
||||
{
|
||||
void sample_reconstruct(imgpel **curImg, imgpel **mpr, int **mb_rres, int mb_x,
|
||||
int opix_x, int width, int height, int max_imgpel_value,
|
||||
int dq_bits) {
|
||||
imgpel *imgOrg, *imgPred;
|
||||
int *m7;
|
||||
int *m7;
|
||||
int i, j;
|
||||
|
||||
for (j = 0; j < height; j++)
|
||||
{
|
||||
for (j = 0; j < height; j++) {
|
||||
imgOrg = &curImg[j][opix_x];
|
||||
imgPred = &mpr[j][mb_x];
|
||||
m7 = &mb_rres[j][mb_x];
|
||||
for (i=0;i<width;i++)
|
||||
*imgOrg++ = (imgpel) iClip1( max_imgpel_value, rshift_rnd_sf(*m7++, dq_bits) + *imgPred++);
|
||||
m7 = &mb_rres[j][mb_x];
|
||||
for (i = 0; i < width; i++)
|
||||
*imgOrg++ = (imgpel)iClip1(max_imgpel_value,
|
||||
rshift_rnd_sf(*m7++, dq_bits) + *imgPred++);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -6,39 +6,36 @@
|
|||
* \brief
|
||||
* Configuration handling.
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation
|
||||
*details)
|
||||
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||
* \note
|
||||
* In the future this module should hide the Parameters and offer only
|
||||
* Functions for their access. Modules which make frequent use of some parameters
|
||||
* (e.g. picture size in macroblocks) are free to buffer them on local variables.
|
||||
* This will not only avoid global variable and make the code more readable, but also
|
||||
* speed it up. It will also greatly facilitate future enhancements such as the
|
||||
* handling of different picture sizes in the same sequence. \n
|
||||
* \n
|
||||
* For now, everything is just copied to the inp_par structure (gulp)
|
||||
* Functions for their access. Modules which make frequent use of some
|
||||
*parameters (e.g. picture size in macroblocks) are free to buffer them on local
|
||||
*variables. This will not only avoid global variable and make the code more
|
||||
*readable, but also speed it up. It will also greatly facilitate future
|
||||
*enhancements such as the handling of different picture sizes in the same
|
||||
*sequence. \n \n For now, everything is just copied to
|
||||
*the inp_par structure (gulp)
|
||||
*
|
||||
**************************************************************************************
|
||||
* \par Configuration File Format
|
||||
**************************************************************************************
|
||||
* Format is line oriented, maximum of one parameter per line \n
|
||||
* \n
|
||||
* Lines have the following format: \n
|
||||
* \<ParameterName\> = \<ParameterValue\> # Comments \\n \n
|
||||
* Whitespace is space and \\t
|
||||
* \par
|
||||
* \<ParameterName\> are the predefined names for Parameters and are case sensitive.
|
||||
* See configfile.h for the definition of those names and their mapping to
|
||||
* cfgparams->values.
|
||||
* \par
|
||||
* Format is line oriented, maximum of one parameter per line \n \n Lines have
|
||||
*the following format: \n
|
||||
* \<ParameterName\> = \<ParameterValue\> # Comments \\n \n Whitespace is space
|
||||
*and \\t \par
|
||||
* \<ParameterName\> are the predefined names for Parameters and are case
|
||||
*sensitive. See configfile.h for the definition of those names and their
|
||||
*mapping to cfgparams->values. \par
|
||||
* \<ParameterValue\> are either integers [0..9]* or strings.
|
||||
* Integers must fit into the wordlengths, signed values are generally assumed.
|
||||
* Strings containing no whitespace characters can be used directly. Strings containing
|
||||
* whitespace characters are to be inclosed in double quotes ("string with whitespace")
|
||||
* The double quote character is forbidden (may want to implement something smarter here).
|
||||
* \par
|
||||
* Any Parameters whose ParameterName is undefined lead to the termination of the program
|
||||
* with an error message.
|
||||
* Integers must fit into the wordlengths, signed values are generally
|
||||
*assumed. Strings containing no whitespace characters can be used directly.
|
||||
*Strings containing whitespace characters are to be inclosed in double quotes
|
||||
*("string with whitespace") The double quote character is forbidden (may want
|
||||
*to implement something smarter here). \par Any Parameters whose ParameterName
|
||||
*is undefined lead to the termination of the program with an error message.
|
||||
*
|
||||
* \par Known bug/Shortcoming:
|
||||
* zero-length strings (i.e. to signal an non-existing file
|
||||
|
@ -46,29 +43,29 @@
|
|||
*
|
||||
* \par Rules for using command files
|
||||
* \n
|
||||
* All Parameters are initially taken from DEFAULTCONFIGFILENAME, defined in configfile.h.
|
||||
* If an -f \<config\> parameter is present in the command line then this file is used to
|
||||
* update the defaults of DEFAULTCONFIGFILENAME. There can be more than one -f parameters
|
||||
* present. If -p <ParameterName = ParameterValue> parameters are present then these
|
||||
* override the default and the additional config file's settings, and are themselves
|
||||
* overridden by future -p parameters. There must be whitespace between -f and -p commands
|
||||
* and their respective parameters
|
||||
* All Parameters are initially taken from DEFAULTCONFIGFILENAME, defined in
|
||||
*configfile.h. If an -f \<config\> parameter is present in the command line
|
||||
*then this file is used to update the defaults of DEFAULTCONFIGFILENAME. There
|
||||
*can be more than one -f parameters present. If -p <ParameterName =
|
||||
*ParameterValue> parameters are present then these override the default and the
|
||||
*additional config file's settings, and are themselves overridden by future -p
|
||||
*parameters. There must be whitespace between -f and -p commands and their
|
||||
*respective parameters
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "configfile.h"
|
||||
#include "global.h"
|
||||
#include "memalloc.h"
|
||||
|
||||
static int ParameterNameToMapIndex (Mapping *Map, char *s);
|
||||
static int ParameterNameToMapIndex(Mapping *Map, char *s);
|
||||
|
||||
|
||||
#define MAX_ITEMS_TO_PARSE 10000
|
||||
#define MAX_ITEMS_TO_PARSE 10000
|
||||
#ifdef SPEC
|
||||
#ifdef SPEC_WINDOWS
|
||||
#define STRCMP(x,y) _stricmp(x,y)
|
||||
#define STRCMP(x, y) _stricmp(x, y)
|
||||
#else
|
||||
#define STRCMP strcmp
|
||||
#endif
|
||||
|
@ -88,69 +85,66 @@ static int ParameterNameToMapIndex (Mapping *Map, char *s);
|
|||
* NULL in case of error. Error message will be set in errortext
|
||||
***********************************************************************
|
||||
*/
|
||||
char *GetConfigFileContent (char *Filename)
|
||||
{
|
||||
char *GetConfigFileContent(char *Filename) {
|
||||
long FileSize;
|
||||
FILE *f;
|
||||
char *buf;
|
||||
|
||||
if (NULL == (f = fopen (Filename, "r")))
|
||||
{
|
||||
snprintf (errortext, ET_SIZE, "Cannot open configuration file %s.", Filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (0 != fseek (f, 0, SEEK_END))
|
||||
{
|
||||
snprintf (errortext, ET_SIZE, "Cannot fseek in configuration file %s.", Filename);
|
||||
if (NULL == (f = fopen(Filename, "r"))) {
|
||||
snprintf(errortext, ET_SIZE, "Cannot open configuration file %s.",
|
||||
Filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FileSize = ftell (f);
|
||||
if (FileSize < 0 || FileSize > 100000)
|
||||
{
|
||||
snprintf (errortext, ET_SIZE, "Unreasonable Filesize %ld reported by ftell for configuration file %s.", FileSize, Filename);
|
||||
return NULL;
|
||||
}
|
||||
if (0 != fseek (f, 0, SEEK_SET))
|
||||
{
|
||||
snprintf (errortext, ET_SIZE, "Cannot fseek in configuration file %s.", Filename);
|
||||
if (0 != fseek(f, 0, SEEK_END)) {
|
||||
snprintf(errortext, ET_SIZE, "Cannot fseek in configuration file %s.",
|
||||
Filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((buf = malloc (FileSize + 1))==NULL) no_mem_exit("GetConfigFileContent: buf");
|
||||
FileSize = ftell(f);
|
||||
if (FileSize < 0 || FileSize > 100000) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
"Unreasonable Filesize %ld reported by ftell for configuration "
|
||||
"file %s.",
|
||||
FileSize, Filename);
|
||||
return NULL;
|
||||
}
|
||||
if (0 != fseek(f, 0, SEEK_SET)) {
|
||||
snprintf(errortext, ET_SIZE, "Cannot fseek in configuration file %s.",
|
||||
Filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Note that ftell() gives us the file size as the file system sees it. The actual file size,
|
||||
// as reported by fread() below will be often smaller due to CR/LF to CR conversion and/or
|
||||
// control characters after the dos EOF marker in the file.
|
||||
if ((buf = malloc(FileSize + 1)) == NULL)
|
||||
no_mem_exit("GetConfigFileContent: buf");
|
||||
|
||||
FileSize = (long) fread (buf, 1, FileSize, f);
|
||||
// Note that ftell() gives us the file size as the file system sees it. The
|
||||
// actual file size, as reported by fread() below will be often smaller due to
|
||||
// CR/LF to CR conversion and/or control characters after the dos EOF marker
|
||||
// in the file.
|
||||
|
||||
FileSize = (long)fread(buf, 1, FileSize, f);
|
||||
buf[FileSize] = '\0';
|
||||
|
||||
|
||||
fclose (f);
|
||||
fclose(f);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
* Parses the character array buf and writes global variable input, which is defined in
|
||||
* configfile.h. This hack will continue to be necessary to facilitate the addition of
|
||||
* new parameters through the Map[] mechanism (Need compiler-generated addresses in map[]).
|
||||
* \param p_Inp
|
||||
* InputParameters of configuration
|
||||
* \param Map
|
||||
* Mapping structure to specify the name and value mapping relation
|
||||
* \param buf
|
||||
* buffer to be parsed
|
||||
* \param bufsize
|
||||
* buffer size of buffer
|
||||
* Parses the character array buf and writes global variable input, which is
|
||||
*defined in configfile.h. This hack will continue to be necessary to
|
||||
*facilitate the addition of new parameters through the Map[] mechanism (Need
|
||||
*compiler-generated addresses in map[]). \param p_Inp InputParameters of
|
||||
*configuration \param Map Mapping structure to specify the name and value
|
||||
*mapping relation \param buf buffer to be parsed \param bufsize buffer size of
|
||||
*buffer
|
||||
***********************************************************************
|
||||
*/
|
||||
void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
||||
{
|
||||
void ParseContent(InputParameters *p_Inp, Mapping *Map, char *buf,
|
||||
int bufsize) {
|
||||
char *items[MAX_ITEMS_TO_PARSE] = {NULL};
|
||||
int MapIdx;
|
||||
int item = 0;
|
||||
|
@ -161,19 +155,20 @@ void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
|||
double DoubleContent;
|
||||
int i;
|
||||
|
||||
// Stage one: Generate an argc/argv-type list in items[], without comments and whitespace.
|
||||
// This is context insensitive and could be done most easily with lex(1).
|
||||
// Stage one: Generate an argc/argv-type list in items[], without comments and
|
||||
// whitespace. This is context insensitive and could be done most easily with
|
||||
// lex(1).
|
||||
|
||||
while (p < bufend)
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
while (p < bufend) {
|
||||
switch (*p) {
|
||||
case 13:
|
||||
++p;
|
||||
break;
|
||||
case '#': // Found comment
|
||||
*p = '\0'; // Replace '#' with '\0' in case of comment immediately following integer or string
|
||||
while (*p != '\n' && p < bufend) // Skip till EOL or EOF, whichever comes first
|
||||
case '#': // Found comment
|
||||
*p = '\0'; // Replace '#' with '\0' in case of comment immediately
|
||||
// following integer or string
|
||||
while (*p != '\n' &&
|
||||
p < bufend) // Skip till EOL or EOF, whichever comes first
|
||||
++p;
|
||||
InString = 0;
|
||||
InItem = 0;
|
||||
|
@ -181,34 +176,30 @@ void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
|||
case '\n':
|
||||
InItem = 0;
|
||||
InString = 0;
|
||||
*p++='\0';
|
||||
*p++ = '\0';
|
||||
break;
|
||||
case ' ':
|
||||
case '\t': // Skip whitespace, leave state unchanged
|
||||
case '\t': // Skip whitespace, leave state unchanged
|
||||
if (InString)
|
||||
p++;
|
||||
else
|
||||
{ // Terminate non-strings once whitespace is found
|
||||
else { // Terminate non-strings once whitespace is found
|
||||
*p++ = '\0';
|
||||
InItem = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case '"': // Begin/End of String
|
||||
case '"': // Begin/End of String
|
||||
*p++ = '\0';
|
||||
if (!InString)
|
||||
{
|
||||
if (!InString) {
|
||||
items[item++] = p;
|
||||
InItem = ~InItem;
|
||||
}
|
||||
else
|
||||
} else
|
||||
InItem = 0;
|
||||
InString = ~InString; // Toggle
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!InItem)
|
||||
{
|
||||
if (!InItem) {
|
||||
items[item++] = p;
|
||||
InItem = ~InItem;
|
||||
}
|
||||
|
@ -218,53 +209,57 @@ void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
|||
|
||||
item--;
|
||||
|
||||
for (i=0; i<item; i+= 3)
|
||||
{
|
||||
if (0 > (MapIdx = ParameterNameToMapIndex (Map, items[i])))
|
||||
{
|
||||
//snprintf (errortext, ET_SIZE, " Parsing error in config file: Parameter Name '%s' not recognized.", items[i]);
|
||||
//error (errortext, 300);
|
||||
printf ("\n\tParsing error in config file: Parameter Name '%s' not recognized.", items[i]);
|
||||
i -= 2 ;
|
||||
for (i = 0; i < item; i += 3) {
|
||||
if (0 > (MapIdx = ParameterNameToMapIndex(Map, items[i]))) {
|
||||
// snprintf (errortext, ET_SIZE, " Parsing error in config file: Parameter
|
||||
// Name '%s' not recognized.", items[i]); error (errortext, 300);
|
||||
printf("\n\tParsing error in config file: Parameter Name '%s' not "
|
||||
"recognized.",
|
||||
items[i]);
|
||||
i -= 2;
|
||||
continue;
|
||||
}
|
||||
if (STRCMP ("=", items[i+1]))
|
||||
{
|
||||
snprintf (errortext, ET_SIZE, " Parsing error in config file: '=' expected as the second token in each line.");
|
||||
error (errortext, 300);
|
||||
if (STRCMP("=", items[i + 1])) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
" Parsing error in config file: '=' expected as the second "
|
||||
"token in each line.");
|
||||
error(errortext, 300);
|
||||
}
|
||||
|
||||
// Now interpret the Value, context sensitive...
|
||||
|
||||
switch (Map[MapIdx].Type)
|
||||
{
|
||||
case 0: // Numerical
|
||||
if (1 != sscanf (items[i+2], "%d", &IntContent))
|
||||
{
|
||||
snprintf (errortext, ET_SIZE, " Parsing error: Expected numerical value for Parameter of %s, found '%s'.", items[i], items[i+2]);
|
||||
error (errortext, 300);
|
||||
switch (Map[MapIdx].Type) {
|
||||
case 0: // Numerical
|
||||
if (1 != sscanf(items[i + 2], "%d", &IntContent)) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
" Parsing error: Expected numerical value for Parameter of "
|
||||
"%s, found '%s'.",
|
||||
items[i], items[i + 2]);
|
||||
error(errortext, 300);
|
||||
}
|
||||
* (int *) (Map[MapIdx].Place) = IntContent;
|
||||
printf (".");
|
||||
*(int *)(Map[MapIdx].Place) = IntContent;
|
||||
printf(".");
|
||||
break;
|
||||
case 1:
|
||||
if (items[i + 2] == NULL)
|
||||
memset((char *) Map[MapIdx].Place, 0, Map[MapIdx].char_size);
|
||||
memset((char *)Map[MapIdx].Place, 0, Map[MapIdx].char_size);
|
||||
else
|
||||
strncpy ((char *) Map[MapIdx].Place, items [i+2], Map[MapIdx].char_size);
|
||||
printf (".");
|
||||
strncpy((char *)Map[MapIdx].Place, items[i + 2], Map[MapIdx].char_size);
|
||||
printf(".");
|
||||
break;
|
||||
case 2: // Numerical double
|
||||
if (1 != sscanf (items[i+2], "%lf", &DoubleContent))
|
||||
{
|
||||
snprintf (errortext, ET_SIZE, " Parsing error: Expected numerical value for Parameter of %s, found '%s'.", items[i], items[i+2]);
|
||||
error (errortext, 300);
|
||||
case 2: // Numerical double
|
||||
if (1 != sscanf(items[i + 2], "%lf", &DoubleContent)) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
" Parsing error: Expected numerical value for Parameter of "
|
||||
"%s, found '%s'.",
|
||||
items[i], items[i + 2]);
|
||||
error(errortext, 300);
|
||||
}
|
||||
* (double *) (Map[MapIdx].Place) = DoubleContent;
|
||||
printf (".");
|
||||
*(double *)(Map[MapIdx].Place) = DoubleContent;
|
||||
printf(".");
|
||||
break;
|
||||
default:
|
||||
error ("Unknown value type in the map definition of configfile.h",-1);
|
||||
error("Unknown value type in the map definition of configfile.h", -1);
|
||||
}
|
||||
}
|
||||
*p_Inp = cfgparams;
|
||||
|
@ -283,12 +278,11 @@ void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
|||
* -1 for error
|
||||
***********************************************************************
|
||||
*/
|
||||
static int ParameterNameToMapIndex (Mapping *Map, char *s)
|
||||
{
|
||||
static int ParameterNameToMapIndex(Mapping *Map, char *s) {
|
||||
int i = 0;
|
||||
|
||||
while (Map[i].TokenName != NULL)
|
||||
if (0==STRCMP (Map[i].TokenName, s))
|
||||
if (0 == STRCMP(Map[i].TokenName, s))
|
||||
return i;
|
||||
else
|
||||
i++;
|
||||
|
@ -303,17 +297,15 @@ static int ParameterNameToMapIndex (Mapping *Map, char *s)
|
|||
* -1 for error
|
||||
***********************************************************************
|
||||
*/
|
||||
int InitParams(Mapping *Map)
|
||||
{
|
||||
int InitParams(Mapping *Map) {
|
||||
int i = 0;
|
||||
|
||||
while (Map[i].TokenName != NULL)
|
||||
{
|
||||
while (Map[i].TokenName != NULL) {
|
||||
if (Map[i].Type == 0)
|
||||
* (int *) (Map[i].Place) = (int) Map[i].Default;
|
||||
*(int *)(Map[i].Place) = (int)Map[i].Default;
|
||||
else if (Map[i].Type == 2)
|
||||
* (double *) (Map[i].Place) = Map[i].Default;
|
||||
i++;
|
||||
*(double *)(Map[i].Place) = Map[i].Default;
|
||||
i++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -326,64 +318,65 @@ int InitParams(Mapping *Map)
|
|||
* -1 for error
|
||||
***********************************************************************
|
||||
*/
|
||||
int TestParams(Mapping *Map, int bitdepth_qp_scale[3])
|
||||
{
|
||||
int TestParams(Mapping *Map, int bitdepth_qp_scale[3]) {
|
||||
int i = 0;
|
||||
|
||||
while (Map[i].TokenName != NULL)
|
||||
{
|
||||
if (Map[i].param_limits == 1)
|
||||
{
|
||||
if (Map[i].Type == 0)
|
||||
{
|
||||
if ( * (int *) (Map[i].Place) < (int) Map[i].min_limit || * (int *) (Map[i].Place) > (int) Map[i].max_limit )
|
||||
{
|
||||
snprintf(errortext, ET_SIZE, "Error in input parameter %s. Check configuration file. Value should be in [%d, %d] range.", Map[i].TokenName, (int) Map[i].min_limit,(int)Map[i].max_limit );
|
||||
error (errortext, 400);
|
||||
while (Map[i].TokenName != NULL) {
|
||||
if (Map[i].param_limits == 1) {
|
||||
if (Map[i].Type == 0) {
|
||||
if (*(int *)(Map[i].Place) < (int)Map[i].min_limit ||
|
||||
*(int *)(Map[i].Place) > (int)Map[i].max_limit) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
"Error in input parameter %s. Check configuration file. "
|
||||
"Value should be in [%d, %d] range.",
|
||||
Map[i].TokenName, (int)Map[i].min_limit,
|
||||
(int)Map[i].max_limit);
|
||||
error(errortext, 400);
|
||||
}
|
||||
|
||||
}
|
||||
else if (Map[i].Type == 2)
|
||||
{
|
||||
if ( * (double *) (Map[i].Place) < Map[i].min_limit || * (double *) (Map[i].Place) > Map[i].max_limit )
|
||||
{
|
||||
snprintf(errortext, ET_SIZE, "Error in input parameter %s. Check configuration file. Value should be in [%.2f, %.2f] range.", Map[i].TokenName,Map[i].min_limit ,Map[i].max_limit );
|
||||
error (errortext, 400);
|
||||
} else if (Map[i].Type == 2) {
|
||||
if (*(double *)(Map[i].Place) < Map[i].min_limit ||
|
||||
*(double *)(Map[i].Place) > Map[i].max_limit) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
"Error in input parameter %s. Check configuration file. "
|
||||
"Value should be in [%.2f, %.2f] range.",
|
||||
Map[i].TokenName, Map[i].min_limit, Map[i].max_limit);
|
||||
error(errortext, 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Map[i].param_limits == 2)
|
||||
} else if (Map[i].param_limits == 2) {
|
||||
if (Map[i].Type == 0) {
|
||||
if (*(int *)(Map[i].Place) < (int)Map[i].min_limit) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
"Error in input parameter %s. Check configuration file. "
|
||||
"Value should not be smaller than %d.",
|
||||
Map[i].TokenName, (int)Map[i].min_limit);
|
||||
error(errortext, 400);
|
||||
}
|
||||
} else if (Map[i].Type == 2) {
|
||||
if (*(double *)(Map[i].Place) < Map[i].min_limit) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
"Error in input parameter %s. Check configuration file. "
|
||||
"Value should not be smaller than %2.f.",
|
||||
Map[i].TokenName, Map[i].min_limit);
|
||||
error(errortext, 400);
|
||||
}
|
||||
}
|
||||
} else if (Map[i].param_limits == 3) // Only used for QPs
|
||||
{
|
||||
if (Map[i].Type == 0)
|
||||
{
|
||||
if ( * (int *) (Map[i].Place) < (int) Map[i].min_limit )
|
||||
{
|
||||
snprintf(errortext, ET_SIZE, "Error in input parameter %s. Check configuration file. Value should not be smaller than %d.", Map[i].TokenName, (int) Map[i].min_limit);
|
||||
error (errortext, 400);
|
||||
}
|
||||
}
|
||||
else if (Map[i].Type == 2)
|
||||
{
|
||||
if ( * (double *) (Map[i].Place) < Map[i].min_limit )
|
||||
{
|
||||
snprintf(errortext, ET_SIZE, "Error in input parameter %s. Check configuration file. Value should not be smaller than %2.f.", Map[i].TokenName,Map[i].min_limit);
|
||||
error (errortext, 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Map[i].param_limits == 3) // Only used for QPs
|
||||
{
|
||||
|
||||
if (Map[i].Type == 0)
|
||||
{
|
||||
int cur_qp = * (int *) (Map[i].Place);
|
||||
int min_qp = (int) (Map[i].min_limit - (bitdepth_qp_scale? bitdepth_qp_scale[0]: 0));
|
||||
int max_qp = (int) Map[i].max_limit;
|
||||
|
||||
if (( cur_qp < min_qp ) || ( cur_qp > max_qp ))
|
||||
{
|
||||
snprintf(errortext, ET_SIZE, "Error in input parameter %s. Check configuration file. Value should be in [%d, %d] range.", Map[i].TokenName, min_qp, max_qp );
|
||||
error (errortext, 400);
|
||||
|
||||
if (Map[i].Type == 0) {
|
||||
int cur_qp = *(int *)(Map[i].Place);
|
||||
int min_qp = (int)(Map[i].min_limit -
|
||||
(bitdepth_qp_scale ? bitdepth_qp_scale[0] : 0));
|
||||
int max_qp = (int)Map[i].max_limit;
|
||||
|
||||
if ((cur_qp < min_qp) || (cur_qp > max_qp)) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
"Error in input parameter %s. Check configuration file. "
|
||||
"Value should be in [%d, %d] range.",
|
||||
Map[i].TokenName, min_qp, max_qp);
|
||||
error(errortext, 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -393,8 +386,6 @@ int TestParams(Mapping *Map, int bitdepth_qp_scale[3])
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
|
@ -403,24 +394,25 @@ int TestParams(Mapping *Map, int bitdepth_qp_scale[3])
|
|||
* -1 for error
|
||||
***********************************************************************
|
||||
*/
|
||||
int DisplayParams(Mapping *Map, char *message)
|
||||
{
|
||||
int DisplayParams(Mapping *Map, char *message) {
|
||||
int i = 0;
|
||||
|
||||
printf("******************************************************\n");
|
||||
printf("* %s *\n", message);
|
||||
printf("******************************************************\n");
|
||||
while (Map[i].TokenName != NULL)
|
||||
{
|
||||
while (Map[i].TokenName != NULL) {
|
||||
if (Map[i].Type == 0)
|
||||
printf("Parameter %s = %d\n",Map[i].TokenName,* (int *) (Map[i].Place));
|
||||
printf("Parameter %s = %d\n", Map[i].TokenName, *(int *)(Map[i].Place));
|
||||
else if (Map[i].Type == 1)
|
||||
printf("Parameter %s = ""%s""\n",Map[i].TokenName,(char *) (Map[i].Place));
|
||||
printf("Parameter %s = "
|
||||
"%s"
|
||||
"\n",
|
||||
Map[i].TokenName, (char *)(Map[i].Place));
|
||||
else if (Map[i].Type == 2)
|
||||
printf("Parameter %s = %.2f\n",Map[i].TokenName,* (double *) (Map[i].Place));
|
||||
i++;
|
||||
printf("Parameter %s = %.2f\n", Map[i].TokenName,
|
||||
*(double *)(Map[i].Place));
|
||||
i++;
|
||||
}
|
||||
printf("******************************************************\n");
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,39 +6,36 @@
|
|||
* \brief
|
||||
* Configuration handling.
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation
|
||||
*details)
|
||||
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||
* \note
|
||||
* In the future this module should hide the Parameters and offer only
|
||||
* Functions for their access. Modules which make frequent use of some parameters
|
||||
* (e.g. picture size in macroblocks) are free to buffer them on local variables.
|
||||
* This will not only avoid global variable and make the code more readable, but also
|
||||
* speed it up. It will also greatly facilitate future enhancements such as the
|
||||
* handling of different picture sizes in the same sequence. \n
|
||||
* \n
|
||||
* For now, everything is just copied to the inp_par structure (gulp)
|
||||
* Functions for their access. Modules which make frequent use of some
|
||||
*parameters (e.g. picture size in macroblocks) are free to buffer them on local
|
||||
*variables. This will not only avoid global variable and make the code more
|
||||
*readable, but also speed it up. It will also greatly facilitate future
|
||||
*enhancements such as the handling of different picture sizes in the same
|
||||
*sequence. \n \n For now, everything is just copied to
|
||||
*the inp_par structure (gulp)
|
||||
*
|
||||
**************************************************************************************
|
||||
* \par Configuration File Format
|
||||
**************************************************************************************
|
||||
* Format is line oriented, maximum of one parameter per line \n
|
||||
* \n
|
||||
* Lines have the following format: \n
|
||||
* \<ParameterName\> = \<ParameterValue\> # Comments \\n \n
|
||||
* Whitespace is space and \\t
|
||||
* \par
|
||||
* \<ParameterName\> are the predefined names for Parameters and are case sensitive.
|
||||
* See configfile.h for the definition of those names and their mapping to
|
||||
* cfgparams->values.
|
||||
* \par
|
||||
* Format is line oriented, maximum of one parameter per line \n \n Lines have
|
||||
*the following format: \n
|
||||
* \<ParameterName\> = \<ParameterValue\> # Comments \\n \n Whitespace is space
|
||||
*and \\t \par
|
||||
* \<ParameterName\> are the predefined names for Parameters and are case
|
||||
*sensitive. See configfile.h for the definition of those names and their
|
||||
*mapping to cfgparams->values. \par
|
||||
* \<ParameterValue\> are either integers [0..9]* or strings.
|
||||
* Integers must fit into the wordlengths, signed values are generally assumed.
|
||||
* Strings containing no whitespace characters can be used directly. Strings containing
|
||||
* whitespace characters are to be inclosed in double quotes ("string with whitespace")
|
||||
* The double quote character is forbidden (may want to implement something smarter here).
|
||||
* \par
|
||||
* Any Parameters whose ParameterName is undefined lead to the termination of the program
|
||||
* with an error message.
|
||||
* Integers must fit into the wordlengths, signed values are generally
|
||||
*assumed. Strings containing no whitespace characters can be used directly.
|
||||
*Strings containing whitespace characters are to be inclosed in double quotes
|
||||
*("string with whitespace") The double quote character is forbidden (may want
|
||||
*to implement something smarter here). \par Any Parameters whose ParameterName
|
||||
*is undefined lead to the termination of the program with an error message.
|
||||
*
|
||||
* \par Known bug/Shortcoming:
|
||||
* zero-length strings (i.e. to signal an non-existing file
|
||||
|
@ -46,13 +43,14 @@
|
|||
*
|
||||
* \par Rules for using command files
|
||||
* \n
|
||||
* All Parameters are initially taken from DEFAULTCONFIGFILENAME, defined in configfile.h.
|
||||
* If an -f \<config\> parameter is present in the command line then this file is used to
|
||||
* update the defaults of DEFAULTCONFIGFILENAME. There can be more than one -f parameters
|
||||
* present. If -p <ParameterName = ParameterValue> parameters are present then these
|
||||
* override the default and the additional config file's settings, and are themselves
|
||||
* overridden by future -p parameters. There must be whitespace between -f and -p commands
|
||||
* and their respective parameters
|
||||
* All Parameters are initially taken from DEFAULTCONFIGFILENAME, defined in
|
||||
*configfile.h. If an -f \<config\> parameter is present in the command line
|
||||
*then this file is used to update the defaults of DEFAULTCONFIGFILENAME. There
|
||||
*can be more than one -f parameters present. If -p <ParameterName =
|
||||
*ParameterValue> parameters are present then these override the default and the
|
||||
*additional config file's settings, and are themselves overridden by future -p
|
||||
*parameters. There must be whitespace between -f and -p commands and their
|
||||
*respective parameters
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
|
@ -60,13 +58,13 @@
|
|||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "memalloc.h"
|
||||
#include "config_common.h"
|
||||
#include "configfile.h"
|
||||
#define MAX_ITEMS_TO_PARSE 10000
|
||||
#include "global.h"
|
||||
#include "memalloc.h"
|
||||
#define MAX_ITEMS_TO_PARSE 10000
|
||||
|
||||
static void PatchInp (InputParameters *p_Inp);
|
||||
static void PatchInp(InputParameters *p_Inp);
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
|
@ -74,43 +72,46 @@ static void PatchInp (InputParameters *p_Inp);
|
|||
* print help message and exit
|
||||
***********************************************************************
|
||||
*/
|
||||
void JMDecHelpExit (void)
|
||||
{
|
||||
fprintf( stderr, "\n ldecod [-h] [-d defdec.cfg] {[-f curenc1.cfg]...[-f curencN.cfg]}"
|
||||
" {[-p EncParam1=EncValue1]..[-p EncParamM=EncValueM]}\n\n"
|
||||
"## Parameters\n\n"
|
||||
void JMDecHelpExit(void) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"\n ldecod [-h] [-d defdec.cfg] {[-f curenc1.cfg]...[-f curencN.cfg]}"
|
||||
" {[-p EncParam1=EncValue1]..[-p EncParamM=EncValueM]}\n\n"
|
||||
"## Parameters\n\n"
|
||||
|
||||
"## Options\n"
|
||||
" -h : prints function usage\n"
|
||||
" -d : use <defdec.cfg> as default file for parameter initializations.\n"
|
||||
" If not used then file defaults to encoder.cfg in local directory.\n"
|
||||
" -f : read <curencM.cfg> for reseting selected encoder parameters.\n"
|
||||
" Multiple files could be used that set different parameters\n"
|
||||
" -p : Set parameter <DecParamM> to <DecValueM>.\n"
|
||||
" See default decoder.cfg file for description of all parameters.\n\n"
|
||||
"## Options\n"
|
||||
" -h : prints function usage\n"
|
||||
" -d : use <defdec.cfg> as default file for parameter "
|
||||
"initializations.\n"
|
||||
" If not used then file defaults to encoder.cfg in local "
|
||||
"directory.\n"
|
||||
" -f : read <curencM.cfg> for reseting selected encoder parameters.\n"
|
||||
" Multiple files could be used that set different parameters\n"
|
||||
" -p : Set parameter <DecParamM> to <DecValueM>.\n"
|
||||
" See default decoder.cfg file for description of all "
|
||||
"parameters.\n\n"
|
||||
|
||||
"## Examples of usage:\n"
|
||||
" ldecod\n"
|
||||
" ldecod -h\n"
|
||||
" ldecod -d default.cfg\n"
|
||||
" ldecod -f curenc1.cfg\n"
|
||||
" ldecod -f curenc1.cfg -p InputFile=\"e:\\data\\container_qcif_30.264\" -p OutputFile=\"dec.yuv\" -p RefFile=\"Rec.yuv\"\n");
|
||||
"## Examples of usage:\n"
|
||||
" ldecod\n"
|
||||
" ldecod -h\n"
|
||||
" ldecod -d default.cfg\n"
|
||||
" ldecod -f curenc1.cfg\n"
|
||||
" ldecod -f curenc1.cfg -p "
|
||||
"InputFile=\"e:\\data\\container_qcif_30.264\" -p OutputFile=\"dec.yuv\" "
|
||||
"-p RefFile=\"Rec.yuv\"\n");
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
* exit with error message if reading from config file failed
|
||||
************************************************************************
|
||||
*/
|
||||
static inline void conf_read_check (int val, int expected)
|
||||
{
|
||||
if (val != expected)
|
||||
{
|
||||
error ("init_conf: error reading from config file", 500);
|
||||
static inline void conf_read_check(int val, int expected) {
|
||||
if (val != expected) {
|
||||
error("init_conf: error reading from config file", 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,16 +129,13 @@ static inline void conf_read_check (int val, int expected)
|
|||
* command line parameters
|
||||
***********************************************************************
|
||||
*/
|
||||
void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
||||
{
|
||||
void ParseCommand(InputParameters *p_Inp, int ac, char *av[]) {
|
||||
char *content = NULL;
|
||||
int CLcount, ContentLen, NumberParams;
|
||||
char *filename=DEFAULTCONFIGFILENAME;
|
||||
char *filename = DEFAULTCONFIGFILENAME;
|
||||
|
||||
if (ac==2)
|
||||
{
|
||||
if (0 == strncmp (av[1], "-v", 2))
|
||||
{
|
||||
if (ac == 2) {
|
||||
if (0 == strncmp(av[1], "-v", 2)) {
|
||||
#if !defined(SPEC)
|
||||
printf("JM " JM ": compiled " __DATE__ " " __TIME__ "\n");
|
||||
#else
|
||||
|
@ -146,103 +144,99 @@ void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
if (0 == strncmp (av[1], "-h", 2))
|
||||
{
|
||||
if (0 == strncmp(av[1], "-h", 2)) {
|
||||
JMDecHelpExit();
|
||||
}
|
||||
}
|
||||
|
||||
memset (&cfgparams, 0, sizeof (InputParameters));
|
||||
//Set default parameters.
|
||||
printf ("Setting Default Parameters...\n");
|
||||
memset(&cfgparams, 0, sizeof(InputParameters));
|
||||
// Set default parameters.
|
||||
printf("Setting Default Parameters...\n");
|
||||
InitParams(Map);
|
||||
|
||||
// Process default config file
|
||||
CLcount = 1;
|
||||
|
||||
if (ac>=3)
|
||||
{
|
||||
if (0 == strncmp (av[1], "-d", 2))
|
||||
{
|
||||
if(0 == strncmp (av[2], "null", 4))
|
||||
filename=NULL;
|
||||
if (ac >= 3) {
|
||||
if (0 == strncmp(av[1], "-d", 2)) {
|
||||
if (0 == strncmp(av[2], "null", 4))
|
||||
filename = NULL;
|
||||
else
|
||||
filename=av[2];
|
||||
filename = av[2];
|
||||
CLcount = 3;
|
||||
}
|
||||
if (0 == strncmp (av[1], "-h", 2))
|
||||
{
|
||||
if (0 == strncmp(av[1], "-h", 2)) {
|
||||
JMDecHelpExit();
|
||||
}
|
||||
}
|
||||
if(filename)
|
||||
{
|
||||
printf ("Parsing Configfile %s\n", filename);
|
||||
content = GetConfigFileContent (filename);
|
||||
if (NULL != content)
|
||||
{
|
||||
//error (errortext, 300);
|
||||
ParseContent (p_Inp, Map, content, (int) strlen(content));
|
||||
printf ("\n");
|
||||
free (content);
|
||||
if (filename) {
|
||||
printf("Parsing Configfile %s\n", filename);
|
||||
content = GetConfigFileContent(filename);
|
||||
if (NULL != content) {
|
||||
// error (errortext, 300);
|
||||
ParseContent(p_Inp, Map, content, (int)strlen(content));
|
||||
printf("\n");
|
||||
free(content);
|
||||
}
|
||||
}
|
||||
// Parse the command line
|
||||
|
||||
while (CLcount < ac)
|
||||
{
|
||||
if (0 == strncmp (av[CLcount], "-h", 2))
|
||||
{
|
||||
while (CLcount < ac) {
|
||||
if (0 == strncmp(av[CLcount], "-h", 2)) {
|
||||
JMDecHelpExit();
|
||||
}
|
||||
|
||||
if (0 == strncmp (av[CLcount], "-f", 2) || 0 == strncmp (av[CLcount], "-F", 2)) // A file parameter?
|
||||
if (0 == strncmp(av[CLcount], "-f", 2) ||
|
||||
0 == strncmp(av[CLcount], "-F", 2)) // A file parameter?
|
||||
{
|
||||
content = GetConfigFileContent (av[CLcount+1]);
|
||||
if (NULL==content)
|
||||
error (errortext, 300);
|
||||
printf ("Parsing Configfile %s", av[CLcount+1]);
|
||||
ParseContent (p_Inp, Map, content, (int) strlen (content));
|
||||
printf ("\n");
|
||||
free (content);
|
||||
content = GetConfigFileContent(av[CLcount + 1]);
|
||||
if (NULL == content)
|
||||
error(errortext, 300);
|
||||
printf("Parsing Configfile %s", av[CLcount + 1]);
|
||||
ParseContent(p_Inp, Map, content, (int)strlen(content));
|
||||
printf("\n");
|
||||
free(content);
|
||||
CLcount += 2;
|
||||
}
|
||||
else if (0 == strncmp (av[CLcount], "-i", 2) || 0 == strncmp (av[CLcount], "-I", 2)) // A file parameter?
|
||||
} else if (0 == strncmp(av[CLcount], "-i", 2) ||
|
||||
0 == strncmp(av[CLcount], "-I", 2)) // A file parameter?
|
||||
{
|
||||
strncpy(p_Inp->infile, av[CLcount+1], FILE_NAME_SIZE);
|
||||
strncpy(p_Inp->infile, av[CLcount + 1], FILE_NAME_SIZE);
|
||||
CLcount += 2;
|
||||
}
|
||||
else if (0 == strncmp (av[CLcount], "-r", 2) || 0 == strncmp (av[CLcount], "-R", 2)) // A file parameter?
|
||||
} else if (0 == strncmp(av[CLcount], "-r", 2) ||
|
||||
0 == strncmp(av[CLcount], "-R", 2)) // A file parameter?
|
||||
{
|
||||
strncpy(p_Inp->reffile, av[CLcount+1], FILE_NAME_SIZE);
|
||||
strncpy(p_Inp->reffile, av[CLcount + 1], FILE_NAME_SIZE);
|
||||
CLcount += 2;
|
||||
}
|
||||
else if (0 == strncmp (av[CLcount], "-o", 2) || 0 == strncmp (av[CLcount], "-O", 2)) // A file parameter?
|
||||
} else if (0 == strncmp(av[CLcount], "-o", 2) ||
|
||||
0 == strncmp(av[CLcount], "-O", 2)) // A file parameter?
|
||||
{
|
||||
strncpy(p_Inp->outfile, av[CLcount+1], FILE_NAME_SIZE);
|
||||
strncpy(p_Inp->outfile, av[CLcount + 1], FILE_NAME_SIZE);
|
||||
CLcount += 2;
|
||||
}
|
||||
else if (0 == strncmp (av[CLcount], "-s", 2) || 0 == strncmp (av[CLcount], "-S", 2)) // A file parameter?
|
||||
} else if (0 == strncmp(av[CLcount], "-s", 2) ||
|
||||
0 == strncmp(av[CLcount], "-S", 2)) // A file parameter?
|
||||
{
|
||||
p_Inp->silent = 1;
|
||||
CLcount += 1;
|
||||
}
|
||||
else if (0 == strncmp (av[CLcount], "-n", 2) || 0 == strncmp (av[CLcount], "-N", 2)) // A file parameter?
|
||||
} else if (0 == strncmp(av[CLcount], "-n", 2) ||
|
||||
0 == strncmp(av[CLcount], "-N", 2)) // A file parameter?
|
||||
{
|
||||
conf_read_check (sscanf(av[CLcount+1],"%d", &p_Inp->iDecFrmNum), 1);
|
||||
conf_read_check(sscanf(av[CLcount + 1], "%d", &p_Inp->iDecFrmNum), 1);
|
||||
CLcount += 2;
|
||||
}
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
else if (0 == strncmp (av[CLcount], "-mpr", 4) || 0 == strncmp (av[CLcount], "-MPR", 4)) // A file parameter?
|
||||
else if (0 == strncmp(av[CLcount], "-mpr", 4) ||
|
||||
0 == strncmp(av[CLcount], "-MPR", 4)) // A file parameter?
|
||||
{
|
||||
conf_read_check (sscanf(av[CLcount+1],"%d", &p_Inp->DecodeAllLayers), 1);
|
||||
conf_read_check(sscanf(av[CLcount + 1], "%d", &p_Inp->DecodeAllLayers),
|
||||
1);
|
||||
CLcount += 2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (0 == strncmp (av[CLcount], "-p", 2) || 0 == strncmp (av[CLcount], "-P", 2)) // A config change?
|
||||
else if (0 == strncmp(av[CLcount], "-p", 2) ||
|
||||
0 == strncmp(av[CLcount], "-P", 2)) // A config change?
|
||||
{
|
||||
// Collect all data until next parameter (starting with -<x> (x is any character)),
|
||||
// put it into content, and parse content.
|
||||
// Collect all data until next parameter (starting with -<x> (x is any
|
||||
// character)), put it into content, and parse content.
|
||||
|
||||
++CLcount;
|
||||
ContentLen = 0;
|
||||
|
@ -250,46 +244,49 @@ void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
|||
|
||||
// determine the necessary size for content
|
||||
while (NumberParams < ac && av[NumberParams][0] != '-')
|
||||
ContentLen += (int) strlen (av[NumberParams++]); // Space for all the strings
|
||||
ContentLen += 1000; // Additional 1000 bytes for spaces and \0s
|
||||
ContentLen +=
|
||||
(int)strlen(av[NumberParams++]); // Space for all the strings
|
||||
ContentLen += 1000; // Additional 1000 bytes for spaces and \0s
|
||||
|
||||
|
||||
if ((content = malloc (ContentLen))==NULL) no_mem_exit("Configure: content");;
|
||||
if ((content = malloc(ContentLen)) == NULL)
|
||||
no_mem_exit("Configure: content");
|
||||
;
|
||||
content[0] = '\0';
|
||||
|
||||
// concatenate all parameters identified before
|
||||
|
||||
while (CLcount < NumberParams)
|
||||
{
|
||||
while (CLcount < NumberParams) {
|
||||
char *source = &av[CLcount][0];
|
||||
char *destin = &content[(int) strlen (content)];
|
||||
char *destin = &content[(int)strlen(content)];
|
||||
|
||||
while (*source != '\0')
|
||||
{
|
||||
if (*source == '=') // The Parser expects whitespace before and after '='
|
||||
while (*source != '\0') {
|
||||
if (*source ==
|
||||
'=') // The Parser expects whitespace before and after '='
|
||||
{
|
||||
*destin++=' '; *destin++='='; *destin++=' '; // Hence make sure we add it
|
||||
}
|
||||
else
|
||||
*destin++=*source;
|
||||
*destin++ = ' ';
|
||||
*destin++ = '=';
|
||||
*destin++ = ' '; // Hence make sure we add it
|
||||
} else
|
||||
*destin++ = *source;
|
||||
source++;
|
||||
}
|
||||
*destin = '\0';
|
||||
CLcount++;
|
||||
}
|
||||
printf ("Parsing command line string '%s'", content);
|
||||
ParseContent (p_Inp, Map, content, (int) strlen(content));
|
||||
free (content);
|
||||
printf ("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf (errortext, ET_SIZE, "Error in command line, ac %d, around string '%s', missing -f or -p parameters?", CLcount, av[CLcount]);
|
||||
error (errortext, 300);
|
||||
printf("Parsing command line string '%s'", content);
|
||||
ParseContent(p_Inp, Map, content, (int)strlen(content));
|
||||
free(content);
|
||||
printf("\n");
|
||||
} else {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
"Error in command line, ac %d, around string '%s', missing -f "
|
||||
"or -p parameters?",
|
||||
CLcount, av[CLcount]);
|
||||
error(errortext, 300);
|
||||
}
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
printf("\n");
|
||||
|
||||
PatchInp(p_Inp);
|
||||
cfgparams = *p_Inp;
|
||||
p_Inp->enable_32_pulldown = 0;
|
||||
|
@ -297,19 +294,15 @@ void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
|||
DisplayParams(Map, "Decoder Parameters");
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
* Checks the input parameters for consistency.
|
||||
***********************************************************************
|
||||
*/
|
||||
static void PatchInp (InputParameters *p_Inp)
|
||||
{
|
||||
//int i;
|
||||
//int storedBplus1;
|
||||
static void PatchInp(InputParameters *p_Inp) {
|
||||
// int i;
|
||||
// int storedBplus1;
|
||||
|
||||
TestParams(Map, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
* CABAC context initializations
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Detlev Marpe <marpe@hhi.de>
|
||||
* - Heiko Schwarz <hschwarz@hhi.de>
|
||||
**************************************************************************************
|
||||
|
@ -15,108 +16,127 @@
|
|||
|
||||
#define CONTEXT_INI_C
|
||||
|
||||
#include "defines.h"
|
||||
#include "global.h"
|
||||
#include "biaridecod.h"
|
||||
#include "ctx_tables.h"
|
||||
#include "defines.h"
|
||||
#include "global.h"
|
||||
|
||||
#define IBIARI_CTX_INIT2(ii, jj, ctx, tab, num, qp) \
|
||||
{ \
|
||||
for (i = 0; i < ii; ++i) \
|
||||
for (j = 0; j < jj; ++j) { \
|
||||
biari_init_context(qp, &(ctx[i][j]), tab##_I[num][i][j]); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define IBIARI_CTX_INIT2(ii,jj,ctx,tab,num, qp) \
|
||||
{ \
|
||||
for (i=0; i<ii; ++i) \
|
||||
for (j=0; j<jj; ++j) \
|
||||
{ \
|
||||
biari_init_context (qp, &(ctx[i][j]), tab ## _I[num][i][j]); \
|
||||
} \
|
||||
}
|
||||
#define PBIARI_CTX_INIT2(ii, jj, ctx, tab, num, qp) \
|
||||
{ \
|
||||
for (i = 0; i < ii; ++i) \
|
||||
for (j = 0; j < jj; ++j) { \
|
||||
biari_init_context(qp, &(ctx[i][j]), tab##_P[num][i][j]); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define PBIARI_CTX_INIT2(ii,jj,ctx,tab,num, qp) \
|
||||
{ \
|
||||
for (i=0; i<ii; ++i) \
|
||||
for (j=0; j<jj; ++j) \
|
||||
{ \
|
||||
biari_init_context (qp, &(ctx[i][j]), tab ## _P[num][i][j]); \
|
||||
} \
|
||||
}
|
||||
#define IBIARI_CTX_INIT1(jj, ctx, tab, num, qp) \
|
||||
{ \
|
||||
for (j = 0; j < jj; ++j) { \
|
||||
biari_init_context(qp, &(ctx[j]), tab##_I[num][0][j]); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define PBIARI_CTX_INIT1(jj, ctx, tab, num, qp) \
|
||||
{{for (j = 0; j < jj; \
|
||||
++j){biari_init_context(qp, &(ctx[j]), tab##_P[num][0][j]); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define IBIARI_CTX_INIT1(jj,ctx,tab,num, qp) \
|
||||
{ \
|
||||
for (j=0; j<jj; ++j) \
|
||||
{ \
|
||||
biari_init_context (qp, &(ctx[j]), tab ## _I[num][0][j]); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define PBIARI_CTX_INIT1(jj,ctx,tab,num, qp) \
|
||||
{ \
|
||||
{ \
|
||||
for (j=0; j<jj; ++j) \
|
||||
{ \
|
||||
biari_init_context (qp, &(ctx[j]), tab ## _P[num][0][j]); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
void init_contexts (Slice *currSlice)
|
||||
{
|
||||
MotionInfoContexts* mc = currSlice->mot_ctx;
|
||||
TextureInfoContexts* tc = currSlice->tex_ctx;
|
||||
void init_contexts(Slice *currSlice) {
|
||||
MotionInfoContexts *mc = currSlice->mot_ctx;
|
||||
TextureInfoContexts *tc = currSlice->tex_ctx;
|
||||
int i, j;
|
||||
int qp = imax(0, currSlice->qp); //p_Vid->qp);
|
||||
int qp = imax(0, currSlice->qp); // p_Vid->qp);
|
||||
int model_number = currSlice->model_number;
|
||||
|
||||
//printf("%d -", p_Vid->currentSlice->model_number);
|
||||
// printf("%d -", p_Vid->currentSlice->model_number);
|
||||
|
||||
//--- motion coding contexts ---
|
||||
if ((currSlice->slice_type == I_SLICE)||(currSlice->slice_type == SI_SLICE))
|
||||
{
|
||||
IBIARI_CTX_INIT2 (3, NUM_MB_TYPE_CTX, mc->mb_type_contexts, INIT_MB_TYPE, model_number, qp);
|
||||
IBIARI_CTX_INIT2 (2, NUM_B8_TYPE_CTX, mc->b8_type_contexts, INIT_B8_TYPE, model_number, qp);
|
||||
IBIARI_CTX_INIT2 (2, NUM_MV_RES_CTX, mc->mv_res_contexts, INIT_MV_RES, model_number, qp);
|
||||
IBIARI_CTX_INIT2 (2, NUM_REF_NO_CTX, mc->ref_no_contexts, INIT_REF_NO, model_number, qp);
|
||||
IBIARI_CTX_INIT1 ( NUM_DELTA_QP_CTX, mc->delta_qp_contexts, INIT_DELTA_QP, model_number, qp);
|
||||
IBIARI_CTX_INIT1 ( NUM_MB_AFF_CTX, mc->mb_aff_contexts, INIT_MB_AFF, model_number, qp);
|
||||
if ((currSlice->slice_type == I_SLICE) ||
|
||||
(currSlice->slice_type == SI_SLICE)) {
|
||||
IBIARI_CTX_INIT2(3, NUM_MB_TYPE_CTX, mc->mb_type_contexts, INIT_MB_TYPE,
|
||||
model_number, qp);
|
||||
IBIARI_CTX_INIT2(2, NUM_B8_TYPE_CTX, mc->b8_type_contexts, INIT_B8_TYPE,
|
||||
model_number, qp);
|
||||
IBIARI_CTX_INIT2(2, NUM_MV_RES_CTX, mc->mv_res_contexts, INIT_MV_RES,
|
||||
model_number, qp);
|
||||
IBIARI_CTX_INIT2(2, NUM_REF_NO_CTX, mc->ref_no_contexts, INIT_REF_NO,
|
||||
model_number, qp);
|
||||
IBIARI_CTX_INIT1(NUM_DELTA_QP_CTX, mc->delta_qp_contexts, INIT_DELTA_QP,
|
||||
model_number, qp);
|
||||
IBIARI_CTX_INIT1(NUM_MB_AFF_CTX, mc->mb_aff_contexts, INIT_MB_AFF,
|
||||
model_number, qp);
|
||||
|
||||
//--- texture coding contexts ---
|
||||
IBIARI_CTX_INIT1 ( NUM_TRANSFORM_SIZE_CTX, tc->transform_size_contexts, INIT_TRANSFORM_SIZE, model_number, qp);
|
||||
IBIARI_CTX_INIT1 ( NUM_IPR_CTX, tc->ipr_contexts, INIT_IPR, model_number, qp);
|
||||
IBIARI_CTX_INIT1 ( NUM_CIPR_CTX, tc->cipr_contexts, INIT_CIPR, model_number, qp);
|
||||
IBIARI_CTX_INIT2 (3, NUM_CBP_CTX, tc->cbp_contexts, INIT_CBP, model_number, qp);
|
||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_BCBP_CTX, tc->bcbp_contexts, INIT_BCBP, model_number, qp);
|
||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[0], INIT_MAP, model_number, qp);
|
||||
IBIARI_CTX_INIT1(NUM_TRANSFORM_SIZE_CTX, tc->transform_size_contexts,
|
||||
INIT_TRANSFORM_SIZE, model_number, qp);
|
||||
IBIARI_CTX_INIT1(NUM_IPR_CTX, tc->ipr_contexts, INIT_IPR, model_number, qp);
|
||||
IBIARI_CTX_INIT1(NUM_CIPR_CTX, tc->cipr_contexts, INIT_CIPR, model_number,
|
||||
qp);
|
||||
IBIARI_CTX_INIT2(3, NUM_CBP_CTX, tc->cbp_contexts, INIT_CBP, model_number,
|
||||
qp);
|
||||
IBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_BCBP_CTX, tc->bcbp_contexts,
|
||||
INIT_BCBP, model_number, qp);
|
||||
IBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[0],
|
||||
INIT_MAP, model_number, qp);
|
||||
#if ENABLE_FIELD_CTX
|
||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[1], INIT_FLD_MAP, model_number, qp);
|
||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[1], INIT_FLD_LAST, model_number, qp);
|
||||
IBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[1],
|
||||
INIT_FLD_MAP, model_number, qp);
|
||||
IBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[1],
|
||||
INIT_FLD_LAST, model_number, qp);
|
||||
#endif
|
||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[0], INIT_LAST, model_number, qp);
|
||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ONE_CTX, tc->one_contexts, INIT_ONE, model_number, qp);
|
||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ABS_CTX, tc->abs_contexts, INIT_ABS, model_number, qp);
|
||||
}
|
||||
else
|
||||
{
|
||||
PBIARI_CTX_INIT2 (3, NUM_MB_TYPE_CTX, mc->mb_type_contexts, INIT_MB_TYPE, model_number, qp);
|
||||
PBIARI_CTX_INIT2 (2, NUM_B8_TYPE_CTX, mc->b8_type_contexts, INIT_B8_TYPE, model_number, qp);
|
||||
PBIARI_CTX_INIT2 (2, NUM_MV_RES_CTX, mc->mv_res_contexts, INIT_MV_RES, model_number, qp);
|
||||
PBIARI_CTX_INIT2 (2, NUM_REF_NO_CTX, mc->ref_no_contexts, INIT_REF_NO, model_number, qp);
|
||||
PBIARI_CTX_INIT1 ( NUM_DELTA_QP_CTX, mc->delta_qp_contexts, INIT_DELTA_QP, model_number, qp);
|
||||
PBIARI_CTX_INIT1 ( NUM_MB_AFF_CTX, mc->mb_aff_contexts, INIT_MB_AFF, model_number, qp);
|
||||
IBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[0],
|
||||
INIT_LAST, model_number, qp);
|
||||
IBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_ONE_CTX, tc->one_contexts, INIT_ONE,
|
||||
model_number, qp);
|
||||
IBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_ABS_CTX, tc->abs_contexts, INIT_ABS,
|
||||
model_number, qp);
|
||||
} else {
|
||||
PBIARI_CTX_INIT2(3, NUM_MB_TYPE_CTX, mc->mb_type_contexts, INIT_MB_TYPE,
|
||||
model_number, qp);
|
||||
PBIARI_CTX_INIT2(2, NUM_B8_TYPE_CTX, mc->b8_type_contexts, INIT_B8_TYPE,
|
||||
model_number, qp);
|
||||
PBIARI_CTX_INIT2(2, NUM_MV_RES_CTX, mc->mv_res_contexts, INIT_MV_RES,
|
||||
model_number, qp);
|
||||
PBIARI_CTX_INIT2(2, NUM_REF_NO_CTX, mc->ref_no_contexts, INIT_REF_NO,
|
||||
model_number, qp);
|
||||
PBIARI_CTX_INIT1(NUM_DELTA_QP_CTX, mc->delta_qp_contexts, INIT_DELTA_QP,
|
||||
model_number, qp);
|
||||
PBIARI_CTX_INIT1(NUM_MB_AFF_CTX, mc->mb_aff_contexts, INIT_MB_AFF,
|
||||
model_number, qp);
|
||||
|
||||
//--- texture coding contexts ---
|
||||
PBIARI_CTX_INIT1 ( NUM_TRANSFORM_SIZE_CTX, tc->transform_size_contexts, INIT_TRANSFORM_SIZE, model_number, qp);
|
||||
PBIARI_CTX_INIT1 ( NUM_IPR_CTX, tc->ipr_contexts, INIT_IPR, model_number, qp);
|
||||
PBIARI_CTX_INIT1 ( NUM_CIPR_CTX, tc->cipr_contexts, INIT_CIPR, model_number, qp);
|
||||
PBIARI_CTX_INIT2 (3, NUM_CBP_CTX, tc->cbp_contexts, INIT_CBP, model_number, qp);
|
||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_BCBP_CTX, tc->bcbp_contexts, INIT_BCBP, model_number, qp);
|
||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[0], INIT_MAP, model_number, qp);
|
||||
PBIARI_CTX_INIT1(NUM_TRANSFORM_SIZE_CTX, tc->transform_size_contexts,
|
||||
INIT_TRANSFORM_SIZE, model_number, qp);
|
||||
PBIARI_CTX_INIT1(NUM_IPR_CTX, tc->ipr_contexts, INIT_IPR, model_number, qp);
|
||||
PBIARI_CTX_INIT1(NUM_CIPR_CTX, tc->cipr_contexts, INIT_CIPR, model_number,
|
||||
qp);
|
||||
PBIARI_CTX_INIT2(3, NUM_CBP_CTX, tc->cbp_contexts, INIT_CBP, model_number,
|
||||
qp);
|
||||
PBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_BCBP_CTX, tc->bcbp_contexts,
|
||||
INIT_BCBP, model_number, qp);
|
||||
PBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[0],
|
||||
INIT_MAP, model_number, qp);
|
||||
#if ENABLE_FIELD_CTX
|
||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[1], INIT_FLD_MAP, model_number, qp);
|
||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[1], INIT_FLD_LAST, model_number, qp);
|
||||
PBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[1],
|
||||
INIT_FLD_MAP, model_number, qp);
|
||||
PBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[1],
|
||||
INIT_FLD_LAST, model_number, qp);
|
||||
#endif
|
||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[0], INIT_LAST, model_number, qp);
|
||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ONE_CTX, tc->one_contexts, INIT_ONE, model_number, qp);
|
||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ABS_CTX, tc->abs_contexts, INIT_ABS, model_number, qp);
|
||||
PBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[0],
|
||||
INIT_LAST, model_number, qp);
|
||||
PBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_ONE_CTX, tc->one_contexts, INIT_ONE,
|
||||
model_number, qp);
|
||||
PBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_ABS_CTX, tc->abs_contexts, INIT_ABS,
|
||||
model_number, qp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
* \file
|
||||
* decoder_test.c
|
||||
* \brief
|
||||
* H.264/AVC decoder test
|
||||
* H.264/AVC decoder test
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Yuwen He <yhe@dolby.com>
|
||||
***********************************************************************
|
||||
*/
|
||||
|
@ -15,44 +16,44 @@
|
|||
|
||||
#include <sys/stat.h>
|
||||
|
||||
//#include "global.h"
|
||||
#include "h264decoder.h"
|
||||
// #include "global.h"
|
||||
#include "configfile.h"
|
||||
#include "h264decoder.h"
|
||||
|
||||
#define DECOUTPUT_TEST 0
|
||||
#define DECOUTPUT_TEST 0
|
||||
|
||||
#define PRINT_OUTPUT_POC 0
|
||||
#define BITSTREAM_FILENAME "test.264"
|
||||
#define DECRECON_FILENAME "test_dec.yuv"
|
||||
#define ENCRECON_FILENAME "test_rec.yuv"
|
||||
#define DECOUTPUT_VIEW0_FILENAME "H264_Decoder_Output_View0.yuv"
|
||||
#define DECOUTPUT_VIEW1_FILENAME "H264_Decoder_Output_View1.yuv"
|
||||
#define PRINT_OUTPUT_POC 0
|
||||
#define BITSTREAM_FILENAME "test.264"
|
||||
#define DECRECON_FILENAME "test_dec.yuv"
|
||||
#define ENCRECON_FILENAME "test_rec.yuv"
|
||||
#define DECOUTPUT_VIEW0_FILENAME "H264_Decoder_Output_View0.yuv"
|
||||
#define DECOUTPUT_VIEW1_FILENAME "H264_Decoder_Output_View1.yuv"
|
||||
|
||||
|
||||
static void Configure(InputParameters *p_Inp, int ac, char *av[])
|
||||
{
|
||||
//char *config_filename=NULL;
|
||||
//char errortext[ET_SIZE];
|
||||
static void Configure(InputParameters *p_Inp, int ac, char *av[]) {
|
||||
// char *config_filename=NULL;
|
||||
// char errortext[ET_SIZE];
|
||||
memset(p_Inp, 0, sizeof(InputParameters));
|
||||
strcpy(p_Inp->infile, BITSTREAM_FILENAME); //! set default bitstream name
|
||||
strcpy(p_Inp->outfile, DECRECON_FILENAME); //! set default output file name
|
||||
strcpy(p_Inp->reffile, ENCRECON_FILENAME); //! set default reference file name
|
||||
|
||||
|
||||
p_Inp->FileFormat = PAR_OF_ANNEXB;
|
||||
p_Inp->ref_offset=0;
|
||||
p_Inp->poc_scale=2;
|
||||
p_Inp->ref_offset = 0;
|
||||
p_Inp->poc_scale = 2;
|
||||
p_Inp->silent = FALSE;
|
||||
p_Inp->intra_profile_deblocking = 0;
|
||||
|
||||
#ifdef _LEAKYBUCKET_
|
||||
p_Inp->R_decoder=500000; //! Decoder rate
|
||||
p_Inp->B_decoder=104000; //! Decoder buffer size
|
||||
p_Inp->F_decoder=73000; //! Decoder initial delay
|
||||
strcpy(p_Inp->LeakyBucketParamFile,"leakybucketparam.cfg"); // file where Leaky Bucket parameters (computed by encoder) are stored
|
||||
p_Inp->R_decoder = 500000; //! Decoder rate
|
||||
p_Inp->B_decoder = 104000; //! Decoder buffer size
|
||||
p_Inp->F_decoder = 73000; //! Decoder initial delay
|
||||
strcpy(p_Inp->LeakyBucketParamFile,
|
||||
"leakybucketparam.cfg"); // file where Leaky Bucket parameters
|
||||
// (computed by encoder) are stored
|
||||
#endif
|
||||
p_Inp->iDecFrmNum = 0;
|
||||
|
||||
p_Inp->write_uv=1;
|
||||
p_Inp->write_uv = 1;
|
||||
// picture error concealment
|
||||
p_Inp->conceal_mode = 0;
|
||||
p_Inp->ref_poc_gap = 2;
|
||||
|
@ -60,116 +61,123 @@ static void Configure(InputParameters *p_Inp, int ac, char *av[])
|
|||
|
||||
ParseCommand(p_Inp, ac, av);
|
||||
|
||||
fprintf(stdout,"----------------------------- JM %s %s -----------------------------\n", VERSION, EXT_VERSION);
|
||||
//fprintf(stdout," Decoder config file : %s \n",config_filename);
|
||||
if(!p_Inp->bDisplayDecParams)
|
||||
{
|
||||
fprintf(stdout,"--------------------------------------------------------------------------\n");
|
||||
fprintf(stdout," Input H.264 bitstream : %s \n",p_Inp->infile);
|
||||
fprintf(stdout," Output decoded YUV : %s \n",p_Inp->outfile);
|
||||
//fprintf(stdout," Output status file : %s \n",LOGFILE);
|
||||
fprintf(stdout," Input reference file : %s \n",p_Inp->reffile);
|
||||
fprintf(
|
||||
stdout,
|
||||
"----------------------------- JM %s %s -----------------------------\n",
|
||||
VERSION, EXT_VERSION);
|
||||
// fprintf(stdout," Decoder config file : %s
|
||||
// \n",config_filename);
|
||||
if (!p_Inp->bDisplayDecParams) {
|
||||
fprintf(stdout, "----------------------------------------------------------"
|
||||
"----------------\n");
|
||||
fprintf(stdout, " Input H.264 bitstream : %s \n",
|
||||
p_Inp->infile);
|
||||
fprintf(stdout, " Output decoded YUV : %s \n",
|
||||
p_Inp->outfile);
|
||||
// fprintf(stdout," Output status file : %s
|
||||
// \n",LOGFILE);
|
||||
fprintf(stdout, " Input reference file : %s \n",
|
||||
p_Inp->reffile);
|
||||
|
||||
fprintf(stdout,"--------------------------------------------------------------------------\n");
|
||||
#ifdef _LEAKYBUCKET_
|
||||
fprintf(stdout," Rate_decoder : %8ld \n",p_Inp->R_decoder);
|
||||
fprintf(stdout," B_decoder : %8ld \n",p_Inp->B_decoder);
|
||||
fprintf(stdout," F_decoder : %8ld \n",p_Inp->F_decoder);
|
||||
fprintf(stdout," LeakyBucketParamFile: %s \n",p_Inp->LeakyBucketParamFile); // Leaky Bucket Param file
|
||||
fprintf(stdout, "----------------------------------------------------------"
|
||||
"----------------\n");
|
||||
#ifdef _LEAKYBUCKET_
|
||||
fprintf(stdout, " Rate_decoder : %8ld \n", p_Inp->R_decoder);
|
||||
fprintf(stdout, " B_decoder : %8ld \n", p_Inp->B_decoder);
|
||||
fprintf(stdout, " F_decoder : %8ld \n", p_Inp->F_decoder);
|
||||
fprintf(stdout, " LeakyBucketParamFile: %s \n",
|
||||
p_Inp->LeakyBucketParamFile); // Leaky Bucket Param file
|
||||
calc_buffer(p_Inp);
|
||||
fprintf(stdout,"--------------------------------------------------------------------------\n");
|
||||
#endif
|
||||
fprintf(stdout, "----------------------------------------------------------"
|
||||
"----------------\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!p_Inp->silent)
|
||||
{
|
||||
fprintf(stdout,"POC must = frame# or field# for SNRs to be correct\n");
|
||||
fprintf(stdout,"--------------------------------------------------------------------------\n");
|
||||
fprintf(stdout," Frame POC Pic# QP SnrY SnrU SnrV Y:U:V Time(ms)\n");
|
||||
fprintf(stdout,"--------------------------------------------------------------------------\n");
|
||||
if (!p_Inp->silent) {
|
||||
fprintf(stdout, "POC must = frame# or field# for SNRs to be correct\n");
|
||||
fprintf(stdout, "----------------------------------------------------------"
|
||||
"----------------\n");
|
||||
fprintf(stdout, " Frame POC Pic# QP SnrY SnrU SnrV "
|
||||
" Y:U:V Time(ms)\n");
|
||||
fprintf(stdout, "----------------------------------------------------------"
|
||||
"----------------\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************
|
||||
if bOutputAllFrames is 1, then output all valid frames to file onetime;
|
||||
if bOutputAllFrames is 1, then output all valid frames to file onetime;
|
||||
else output the first valid frame and move the buffer to the end of list;
|
||||
*********************************************************/
|
||||
static int WriteOneFrame(DecodedPicList *pDecPic, int hFileOutput0, int hFileOutput1, int bOutputAllFrames)
|
||||
{
|
||||
int iOutputFrame=0;
|
||||
static int WriteOneFrame(DecodedPicList *pDecPic, int hFileOutput0,
|
||||
int hFileOutput1, int bOutputAllFrames) {
|
||||
int iOutputFrame = 0;
|
||||
DecodedPicList *pPic = pDecPic;
|
||||
|
||||
if(pPic && (((pPic->iYUVStorageFormat==2) && pPic->bValid==3) || ((pPic->iYUVStorageFormat!=2) && pPic->bValid==1)) )
|
||||
{
|
||||
if (pPic && (((pPic->iYUVStorageFormat == 2) && pPic->bValid == 3) ||
|
||||
((pPic->iYUVStorageFormat != 2) && pPic->bValid == 1))) {
|
||||
int i, iWidth, iHeight, iStride, iWidthUV, iHeightUV, iStrideUV;
|
||||
byte *pbBuf;
|
||||
byte *pbBuf;
|
||||
int hFileOutput;
|
||||
|
||||
iWidth = pPic->iWidth*((pPic->iBitDepth+7)>>3);
|
||||
iWidth = pPic->iWidth * ((pPic->iBitDepth + 7) >> 3);
|
||||
iHeight = pPic->iHeight;
|
||||
iStride = pPic->iYBufStride;
|
||||
if(pPic->iYUVFormat != YUV444)
|
||||
iWidthUV = pPic->iWidth>>1;
|
||||
if (pPic->iYUVFormat != YUV444)
|
||||
iWidthUV = pPic->iWidth >> 1;
|
||||
else
|
||||
iWidthUV = pPic->iWidth;
|
||||
if(pPic->iYUVFormat == YUV420)
|
||||
iHeightUV = pPic->iHeight>>1;
|
||||
if (pPic->iYUVFormat == YUV420)
|
||||
iHeightUV = pPic->iHeight >> 1;
|
||||
else
|
||||
iHeightUV = pPic->iHeight;
|
||||
iWidthUV *= ((pPic->iBitDepth+7)>>3);
|
||||
iWidthUV *= ((pPic->iBitDepth + 7) >> 3);
|
||||
iStrideUV = pPic->iUVBufStride;
|
||||
|
||||
do
|
||||
{
|
||||
if(pPic->iYUVStorageFormat==2)
|
||||
hFileOutput = (pPic->iViewId&0xffff)? hFileOutput1 : hFileOutput0;
|
||||
|
||||
do {
|
||||
if (pPic->iYUVStorageFormat == 2)
|
||||
hFileOutput = (pPic->iViewId & 0xffff) ? hFileOutput1 : hFileOutput0;
|
||||
else
|
||||
hFileOutput = hFileOutput0;
|
||||
if(hFileOutput >=0)
|
||||
{
|
||||
//Y;
|
||||
if (hFileOutput >= 0) {
|
||||
// Y;
|
||||
pbBuf = pPic->pY;
|
||||
for(i=0; i<iHeight; i++)
|
||||
write(hFileOutput, pbBuf+i*iStride, iWidth);
|
||||
for (i = 0; i < iHeight; i++)
|
||||
write(hFileOutput, pbBuf + i * iStride, iWidth);
|
||||
|
||||
if(pPic->iYUVFormat != YUV400)
|
||||
{
|
||||
//U;
|
||||
pbBuf = pPic->pU;
|
||||
for(i=0; i<iHeightUV; i++)
|
||||
write(hFileOutput, pbBuf+i*iStrideUV, iWidthUV);
|
||||
//V;
|
||||
pbBuf = pPic->pV;
|
||||
for(i=0; i<iHeightUV; i++)
|
||||
write(hFileOutput, pbBuf+i*iStrideUV, iWidthUV);
|
||||
if (pPic->iYUVFormat != YUV400) {
|
||||
// U;
|
||||
pbBuf = pPic->pU;
|
||||
for (i = 0; i < iHeightUV; i++)
|
||||
write(hFileOutput, pbBuf + i * iStrideUV, iWidthUV);
|
||||
// V;
|
||||
pbBuf = pPic->pV;
|
||||
for (i = 0; i < iHeightUV; i++)
|
||||
write(hFileOutput, pbBuf + i * iStrideUV, iWidthUV);
|
||||
}
|
||||
|
||||
iOutputFrame++;
|
||||
}
|
||||
|
||||
if((pPic->iYUVStorageFormat==2))
|
||||
{
|
||||
hFileOutput = ((pPic->iViewId>>16)&0xffff)? hFileOutput1 : hFileOutput0;
|
||||
if(hFileOutput>=0)
|
||||
{
|
||||
int iPicSize =iHeight*iStride;
|
||||
//Y;
|
||||
pbBuf = pPic->pY+iPicSize;
|
||||
for(i=0; i<iHeight; i++)
|
||||
write(hFileOutput, pbBuf+i*iStride, iWidth);
|
||||
if ((pPic->iYUVStorageFormat == 2)) {
|
||||
hFileOutput =
|
||||
((pPic->iViewId >> 16) & 0xffff) ? hFileOutput1 : hFileOutput0;
|
||||
if (hFileOutput >= 0) {
|
||||
int iPicSize = iHeight * iStride;
|
||||
// Y;
|
||||
pbBuf = pPic->pY + iPicSize;
|
||||
for (i = 0; i < iHeight; i++)
|
||||
write(hFileOutput, pbBuf + i * iStride, iWidth);
|
||||
|
||||
if(pPic->iYUVFormat != YUV400)
|
||||
{
|
||||
iPicSize = iHeightUV*iStrideUV;
|
||||
//U;
|
||||
pbBuf = pPic->pU+iPicSize;
|
||||
for(i=0; i<iHeightUV; i++)
|
||||
write(hFileOutput, pbBuf+i*iStrideUV, iWidthUV);
|
||||
//V;
|
||||
pbBuf = pPic->pV+iPicSize;
|
||||
for(i=0; i<iHeightUV; i++)
|
||||
write(hFileOutput, pbBuf+i*iStrideUV, iWidthUV);
|
||||
if (pPic->iYUVFormat != YUV400) {
|
||||
iPicSize = iHeightUV * iStrideUV;
|
||||
// U;
|
||||
pbBuf = pPic->pU + iPicSize;
|
||||
for (i = 0; i < iHeightUV; i++)
|
||||
write(hFileOutput, pbBuf + i * iStrideUV, iWidthUV);
|
||||
// V;
|
||||
pbBuf = pPic->pV + iPicSize;
|
||||
for (i = 0; i < iHeightUV; i++)
|
||||
write(hFileOutput, pbBuf + i * iStrideUV, iWidthUV);
|
||||
}
|
||||
|
||||
iOutputFrame++;
|
||||
|
@ -181,7 +189,7 @@ static int WriteOneFrame(DecodedPicList *pDecPic, int hFileOutput0, int hFileOut
|
|||
#endif
|
||||
pPic->bValid = 0;
|
||||
pPic = pPic->pNext;
|
||||
}while(pPic != NULL && pPic->bValid && bOutputAllFrames);
|
||||
} while (pPic != NULL && pPic->bValid && bOutputAllFrames);
|
||||
}
|
||||
#if PRINT_OUTPUT_POC
|
||||
else
|
||||
|
@ -197,65 +205,62 @@ static int WriteOneFrame(DecodedPicList *pDecPic, int hFileOutput0, int hFileOut
|
|||
* main function for JM decoder
|
||||
***********************************************************************
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char **argv) {
|
||||
int iRet;
|
||||
DecodedPicList *pDecPicList;
|
||||
int hFileDecOutput0=-1, hFileDecOutput1=-1;
|
||||
int iFramesOutput=0, iFramesDecoded=0;
|
||||
int hFileDecOutput0 = -1, hFileDecOutput1 = -1;
|
||||
int iFramesOutput = 0, iFramesDecoded = 0;
|
||||
InputParameters InputParams;
|
||||
|
||||
#if DECOUTPUT_TEST
|
||||
hFileDecOutput0 = open(DECOUTPUT_VIEW0_FILENAME, OPENFLAGS_WRITE, OPEN_PERMISSIONS);
|
||||
hFileDecOutput0 =
|
||||
open(DECOUTPUT_VIEW0_FILENAME, OPENFLAGS_WRITE, OPEN_PERMISSIONS);
|
||||
fprintf(stdout, "Decoder output view0: %s\n", DECOUTPUT_VIEW0_FILENAME);
|
||||
hFileDecOutput1 = open(DECOUTPUT_VIEW1_FILENAME, OPENFLAGS_WRITE, OPEN_PERMISSIONS);
|
||||
hFileDecOutput1 =
|
||||
open(DECOUTPUT_VIEW1_FILENAME, OPENFLAGS_WRITE, OPEN_PERMISSIONS);
|
||||
fprintf(stdout, "Decoder output view1: %s\n", DECOUTPUT_VIEW1_FILENAME);
|
||||
#endif
|
||||
|
||||
//get input parameters;
|
||||
// get input parameters;
|
||||
Configure(&InputParams, argc, argv);
|
||||
//open decoder;
|
||||
// open decoder;
|
||||
iRet = OpenDecoder(&InputParams);
|
||||
if(iRet != DEC_OPEN_NOERR)
|
||||
{
|
||||
if (iRet != DEC_OPEN_NOERR) {
|
||||
fprintf(stderr, "Open encoder failed: 0x%x!\n", iRet);
|
||||
return -1; //failed;
|
||||
return -1; // failed;
|
||||
}
|
||||
|
||||
//decoding;
|
||||
do
|
||||
{
|
||||
// decoding;
|
||||
do {
|
||||
iRet = DecodeOneFrame(&pDecPicList);
|
||||
if(iRet==DEC_EOS || iRet==DEC_SUCCEED)
|
||||
{
|
||||
//process the decoded picture, output or display;
|
||||
iFramesOutput += WriteOneFrame(pDecPicList, hFileDecOutput0, hFileDecOutput1, 0);
|
||||
if (iRet == DEC_EOS || iRet == DEC_SUCCEED) {
|
||||
// process the decoded picture, output or display;
|
||||
iFramesOutput +=
|
||||
WriteOneFrame(pDecPicList, hFileDecOutput0, hFileDecOutput1, 0);
|
||||
iFramesDecoded++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//error handling;
|
||||
} else {
|
||||
// error handling;
|
||||
fprintf(stderr, "Error in decoding process: 0x%x\n", iRet);
|
||||
}
|
||||
}while((iRet == DEC_SUCCEED) && ((p_Dec->p_Inp->iDecFrmNum==0) || (iFramesDecoded<p_Dec->p_Inp->iDecFrmNum)));
|
||||
} while ((iRet == DEC_SUCCEED) &&
|
||||
((p_Dec->p_Inp->iDecFrmNum == 0) ||
|
||||
(iFramesDecoded < p_Dec->p_Inp->iDecFrmNum)));
|
||||
|
||||
iRet = FinitDecoder(&pDecPicList);
|
||||
iFramesOutput += WriteOneFrame(pDecPicList, hFileDecOutput0, hFileDecOutput1 , 1);
|
||||
iFramesOutput +=
|
||||
WriteOneFrame(pDecPicList, hFileDecOutput0, hFileDecOutput1, 1);
|
||||
iRet = CloseDecoder();
|
||||
|
||||
//quit;
|
||||
if(hFileDecOutput0>=0)
|
||||
{
|
||||
// quit;
|
||||
if (hFileDecOutput0 >= 0) {
|
||||
close(hFileDecOutput0);
|
||||
}
|
||||
if(hFileDecOutput1>=0)
|
||||
{
|
||||
if (hFileDecOutput1 >= 0) {
|
||||
close(hFileDecOutput1);
|
||||
}
|
||||
|
||||
//printf("%d frames are decoded.\n", iFramesDecoded);
|
||||
//printf("%d frames are decoded, %d frames output.\n", iFramesDecoded, iFramesOutput);
|
||||
// printf("%d frames are decoded.\n", iFramesDecoded);
|
||||
// printf("%d frames are decoded, %d frames output.\n", iFramesDecoded,
|
||||
// iFramesOutput);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
* \file erc_api.c
|
||||
*
|
||||
* \brief
|
||||
* External (still inside video decoder) interface for error concealment module
|
||||
* External (still inside video decoder) interface for error concealment
|
||||
*module
|
||||
*
|
||||
* \author
|
||||
* - Ari Hourunranta <ari.hourunranta@nokia.com>
|
||||
|
@ -14,11 +15,10 @@
|
|||
*************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "global.h"
|
||||
#include "memalloc.h"
|
||||
#include "erc_api.h"
|
||||
#include "fast_memory.h"
|
||||
#include "global.h"
|
||||
#include "memalloc.h"
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
|
@ -26,11 +26,12 @@
|
|||
* Initinize the error concealment module
|
||||
************************************************************************
|
||||
*/
|
||||
void ercInit(VideoParameters *p_Vid, int pic_sizex, int pic_sizey, int flag)
|
||||
{
|
||||
void ercInit(VideoParameters *p_Vid, int pic_sizex, int pic_sizey, int flag) {
|
||||
ercClose(p_Vid, p_Vid->erc_errorVar);
|
||||
p_Vid->erc_object_list = (objectBuffer_t *) calloc((pic_sizex * pic_sizey) >> 6, sizeof(objectBuffer_t));
|
||||
if (p_Vid->erc_object_list == NULL) no_mem_exit("ercInit: erc_object_list");
|
||||
p_Vid->erc_object_list = (objectBuffer_t *)calloc(
|
||||
(pic_sizex * pic_sizey) >> 6, sizeof(objectBuffer_t));
|
||||
if (p_Vid->erc_object_list == NULL)
|
||||
no_mem_exit("ercInit: erc_object_list");
|
||||
|
||||
// the error concealment instance is allocated
|
||||
p_Vid->erc_errorVar = ercOpen();
|
||||
|
@ -47,12 +48,12 @@ void ercInit(VideoParameters *p_Vid, int pic_sizex, int pic_sizey, int flag)
|
|||
* The allocated ercVariables_t is returned.
|
||||
************************************************************************
|
||||
*/
|
||||
ercVariables_t *ercOpen( void )
|
||||
{
|
||||
ercVariables_t *ercOpen(void) {
|
||||
ercVariables_t *errorVar = NULL;
|
||||
|
||||
errorVar = (ercVariables_t *)malloc( sizeof(ercVariables_t));
|
||||
if ( errorVar == NULL ) no_mem_exit("ercOpen: errorVar");
|
||||
errorVar = (ercVariables_t *)malloc(sizeof(ercVariables_t));
|
||||
if (errorVar == NULL)
|
||||
no_mem_exit("ercOpen: errorVar");
|
||||
|
||||
errorVar->nOfMBs = 0;
|
||||
errorVar->segments = NULL;
|
||||
|
@ -82,49 +83,55 @@ ercVariables_t *ercOpen( void )
|
|||
* Width of the frame in pixels.
|
||||
************************************************************************
|
||||
*/
|
||||
void ercReset( ercVariables_t *errorVar, int nOfMBs, int numOfSegments, int picSizeX )
|
||||
{
|
||||
void ercReset(ercVariables_t *errorVar, int nOfMBs, int numOfSegments,
|
||||
int picSizeX) {
|
||||
signed char *tmp = NULL;
|
||||
int i = 0;
|
||||
|
||||
if ( errorVar && errorVar->concealment )
|
||||
{
|
||||
if (errorVar && errorVar->concealment) {
|
||||
ercSegment_t *segments = NULL;
|
||||
// If frame size has been changed
|
||||
if ( nOfMBs != errorVar->nOfMBs && errorVar->yCondition != NULL )
|
||||
{
|
||||
free( errorVar->yCondition );
|
||||
if (nOfMBs != errorVar->nOfMBs && errorVar->yCondition != NULL) {
|
||||
free(errorVar->yCondition);
|
||||
errorVar->yCondition = NULL;
|
||||
free( errorVar->prevFrameYCondition );
|
||||
free(errorVar->prevFrameYCondition);
|
||||
errorVar->prevFrameYCondition = NULL;
|
||||
free( errorVar->uCondition );
|
||||
free(errorVar->uCondition);
|
||||
errorVar->uCondition = NULL;
|
||||
free( errorVar->vCondition );
|
||||
free(errorVar->vCondition);
|
||||
errorVar->vCondition = NULL;
|
||||
free( errorVar->segments );
|
||||
free(errorVar->segments);
|
||||
errorVar->segments = NULL;
|
||||
}
|
||||
|
||||
// If the structures are uninitialized (first frame, or frame size is changed)
|
||||
if ( errorVar->yCondition == NULL )
|
||||
{
|
||||
errorVar->segments = (ercSegment_t *)malloc( numOfSegments*sizeof(ercSegment_t) );
|
||||
if ( errorVar->segments == NULL ) no_mem_exit("ercReset: errorVar->segments");
|
||||
fast_memset( errorVar->segments, 0, numOfSegments*sizeof(ercSegment_t));
|
||||
// If the structures are uninitialized (first frame, or frame size is
|
||||
// changed)
|
||||
if (errorVar->yCondition == NULL) {
|
||||
errorVar->segments =
|
||||
(ercSegment_t *)malloc(numOfSegments * sizeof(ercSegment_t));
|
||||
if (errorVar->segments == NULL)
|
||||
no_mem_exit("ercReset: errorVar->segments");
|
||||
fast_memset(errorVar->segments, 0, numOfSegments * sizeof(ercSegment_t));
|
||||
errorVar->nOfSegments = numOfSegments;
|
||||
|
||||
errorVar->yCondition = (signed char *)malloc( 4*nOfMBs*sizeof(signed char) );
|
||||
if ( errorVar->yCondition == NULL ) no_mem_exit("ercReset: errorVar->yCondition");
|
||||
errorVar->prevFrameYCondition = (signed char *)malloc( 4*nOfMBs*sizeof(signed char) );
|
||||
if ( errorVar->prevFrameYCondition == NULL ) no_mem_exit("ercReset: errorVar->prevFrameYCondition");
|
||||
errorVar->uCondition = (signed char *)malloc( nOfMBs*sizeof(signed char) );
|
||||
if ( errorVar->uCondition == NULL ) no_mem_exit("ercReset: errorVar->uCondition");
|
||||
errorVar->vCondition = (signed char *)malloc( nOfMBs*sizeof(signed char) );
|
||||
if ( errorVar->vCondition == NULL ) no_mem_exit("ercReset: errorVar->vCondition");
|
||||
errorVar->yCondition =
|
||||
(signed char *)malloc(4 * nOfMBs * sizeof(signed char));
|
||||
if (errorVar->yCondition == NULL)
|
||||
no_mem_exit("ercReset: errorVar->yCondition");
|
||||
errorVar->prevFrameYCondition =
|
||||
(signed char *)malloc(4 * nOfMBs * sizeof(signed char));
|
||||
if (errorVar->prevFrameYCondition == NULL)
|
||||
no_mem_exit("ercReset: errorVar->prevFrameYCondition");
|
||||
errorVar->uCondition =
|
||||
(signed char *)malloc(nOfMBs * sizeof(signed char));
|
||||
if (errorVar->uCondition == NULL)
|
||||
no_mem_exit("ercReset: errorVar->uCondition");
|
||||
errorVar->vCondition =
|
||||
(signed char *)malloc(nOfMBs * sizeof(signed char));
|
||||
if (errorVar->vCondition == NULL)
|
||||
no_mem_exit("ercReset: errorVar->vCondition");
|
||||
errorVar->nOfMBs = nOfMBs;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Store the yCondition struct of the previous frame
|
||||
tmp = errorVar->prevFrameYCondition;
|
||||
errorVar->prevFrameYCondition = errorVar->yCondition;
|
||||
|
@ -132,26 +139,30 @@ void ercReset( ercVariables_t *errorVar, int nOfMBs, int numOfSegments, int picS
|
|||
}
|
||||
|
||||
// Reset tables and parameters
|
||||
fast_memset( errorVar->yCondition, 0, 4*nOfMBs*sizeof(*errorVar->yCondition));
|
||||
fast_memset( errorVar->uCondition, 0, nOfMBs*sizeof(*errorVar->uCondition));
|
||||
fast_memset( errorVar->vCondition, 0, nOfMBs*sizeof(*errorVar->vCondition));
|
||||
fast_memset(errorVar->yCondition, 0,
|
||||
4 * nOfMBs * sizeof(*errorVar->yCondition));
|
||||
fast_memset(errorVar->uCondition, 0,
|
||||
nOfMBs * sizeof(*errorVar->uCondition));
|
||||
fast_memset(errorVar->vCondition, 0,
|
||||
nOfMBs * sizeof(*errorVar->vCondition));
|
||||
|
||||
if (errorVar->nOfSegments != numOfSegments)
|
||||
{
|
||||
free( errorVar->segments );
|
||||
if (errorVar->nOfSegments != numOfSegments) {
|
||||
free(errorVar->segments);
|
||||
errorVar->segments = NULL;
|
||||
errorVar->segments = (ercSegment_t *)malloc( numOfSegments*sizeof(ercSegment_t) );
|
||||
if ( errorVar->segments == NULL ) no_mem_exit("ercReset: errorVar->segments");
|
||||
errorVar->segments =
|
||||
(ercSegment_t *)malloc(numOfSegments * sizeof(ercSegment_t));
|
||||
if (errorVar->segments == NULL)
|
||||
no_mem_exit("ercReset: errorVar->segments");
|
||||
errorVar->nOfSegments = numOfSegments;
|
||||
}
|
||||
|
||||
//memset( errorVar->segments, 0, errorVar->nOfSegments * sizeof(ercSegment_t));
|
||||
// memset( errorVar->segments, 0, errorVar->nOfSegments *
|
||||
// sizeof(ercSegment_t));
|
||||
|
||||
segments = errorVar->segments;
|
||||
for ( i = 0; i < errorVar->nOfSegments; i++ )
|
||||
{
|
||||
for (i = 0; i < errorVar->nOfSegments; i++) {
|
||||
segments->startMBPos = 0;
|
||||
segments->endMBPos = (short) (nOfMBs - 1);
|
||||
segments->endMBPos = (short)(nOfMBs - 1);
|
||||
(segments++)->fCorrupted = 1; //! mark segments as corrupted
|
||||
}
|
||||
|
||||
|
@ -171,71 +182,57 @@ void ercReset( ercVariables_t *errorVar, int nOfMBs, int numOfSegments, int picS
|
|||
* Variables for error concealment
|
||||
************************************************************************
|
||||
*/
|
||||
void ercClose(VideoParameters *p_Vid, ercVariables_t *errorVar )
|
||||
{
|
||||
if ( errorVar != NULL )
|
||||
{
|
||||
if (errorVar->yCondition != NULL)
|
||||
{
|
||||
free( errorVar->segments );
|
||||
free( errorVar->yCondition );
|
||||
free( errorVar->uCondition );
|
||||
free( errorVar->vCondition );
|
||||
free( errorVar->prevFrameYCondition );
|
||||
void ercClose(VideoParameters *p_Vid, ercVariables_t *errorVar) {
|
||||
if (errorVar != NULL) {
|
||||
if (errorVar->yCondition != NULL) {
|
||||
free(errorVar->segments);
|
||||
free(errorVar->yCondition);
|
||||
free(errorVar->uCondition);
|
||||
free(errorVar->vCondition);
|
||||
free(errorVar->prevFrameYCondition);
|
||||
}
|
||||
free( errorVar );
|
||||
free(errorVar);
|
||||
errorVar = NULL;
|
||||
}
|
||||
|
||||
if (p_Vid->erc_object_list)
|
||||
{
|
||||
if (p_Vid->erc_object_list) {
|
||||
free(p_Vid->erc_object_list);
|
||||
p_Vid->erc_object_list=NULL;
|
||||
p_Vid->erc_object_list = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
* Sets error concealment ON/OFF. Can be invoked only between frames, not during a frame
|
||||
* \param errorVar
|
||||
* Variables for error concealment
|
||||
* \param value
|
||||
* Sets error concealment ON/OFF. Can be invoked only between frames, not
|
||||
*during a frame \param errorVar Variables for error concealment \param value
|
||||
* New value
|
||||
************************************************************************
|
||||
*/
|
||||
void ercSetErrorConcealment( ercVariables_t *errorVar, int value )
|
||||
{
|
||||
if ( errorVar != NULL )
|
||||
void ercSetErrorConcealment(ercVariables_t *errorVar, int value) {
|
||||
if (errorVar != NULL)
|
||||
errorVar->concealment = value;
|
||||
}
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
* Creates a new segment in the segment-list, and marks the start MB and bit position.
|
||||
* If the end of the previous segment was not explicitly marked by "ercStopSegment",
|
||||
* also marks the end of the previous segment.
|
||||
* If needed, it reallocates the segment-list for a larger storage place.
|
||||
* \param currMBNum
|
||||
* The MB number where the new slice/segment starts
|
||||
* \param segment
|
||||
* Segment/Slice No. counted by the caller
|
||||
* \param bitPos
|
||||
* Bitstream pointer: number of bits read from the buffer.
|
||||
* \param errorVar
|
||||
* Variables for error detector
|
||||
* Creates a new segment in the segment-list, and marks the start MB and
|
||||
*bit position. If the end of the previous segment was not explicitly marked by
|
||||
*"ercStopSegment", also marks the end of the previous segment. If needed, it
|
||||
*reallocates the segment-list for a larger storage place. \param currMBNum The
|
||||
*MB number where the new slice/segment starts \param segment Segment/Slice No.
|
||||
*counted by the caller \param bitPos Bitstream pointer: number of bits read
|
||||
*from the buffer. \param errorVar Variables for error detector
|
||||
************************************************************************
|
||||
*/
|
||||
void ercStartSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar )
|
||||
{
|
||||
if ( errorVar && errorVar->concealment )
|
||||
{
|
||||
void ercStartSegment(int currMBNum, int segment, unsigned int bitPos,
|
||||
ercVariables_t *errorVar) {
|
||||
if (errorVar && errorVar->concealment) {
|
||||
errorVar->currSegmentCorrupted = 0;
|
||||
|
||||
errorVar->segments[ segment ].fCorrupted = 0;
|
||||
errorVar->segments[ segment ].startMBPos = (short) currMBNum;
|
||||
|
||||
errorVar->segments[segment].fCorrupted = 0;
|
||||
errorVar->segments[segment].startMBPos = (short)currMBNum;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,11 +251,10 @@ void ercStartSegment( int currMBNum, int segment, unsigned int bitPos, ercVariab
|
|||
* Variables for error detector
|
||||
************************************************************************
|
||||
*/
|
||||
void ercStopSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar )
|
||||
{
|
||||
if ( errorVar && errorVar->concealment )
|
||||
{
|
||||
errorVar->segments[ segment ].endMBPos = (short) currMBNum;
|
||||
void ercStopSegment(int currMBNum, int segment, unsigned int bitPos,
|
||||
ercVariables_t *errorVar) {
|
||||
if (errorVar && errorVar->concealment) {
|
||||
errorVar->segments[segment].endMBPos = (short)currMBNum;
|
||||
errorVar->currSegment++;
|
||||
}
|
||||
}
|
||||
|
@ -274,26 +270,23 @@ void ercStopSegment( int currMBNum, int segment, unsigned int bitPos, ercVariabl
|
|||
* Variables for error detector
|
||||
************************************************************************
|
||||
*/
|
||||
void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar )
|
||||
{
|
||||
void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar) {
|
||||
int j = 0;
|
||||
int current_segment;
|
||||
|
||||
current_segment = errorVar->currSegment-1;
|
||||
if ( errorVar && errorVar->concealment )
|
||||
{
|
||||
if (errorVar->currSegmentCorrupted == 0)
|
||||
{
|
||||
current_segment = errorVar->currSegment - 1;
|
||||
if (errorVar && errorVar->concealment) {
|
||||
if (errorVar->currSegmentCorrupted == 0) {
|
||||
errorVar->nOfCorruptedSegments++;
|
||||
errorVar->currSegmentCorrupted = 1;
|
||||
}
|
||||
|
||||
for ( j = errorVar->segments[current_segment].startMBPos; j <= errorVar->segments[current_segment].endMBPos; j++ )
|
||||
{
|
||||
errorVar->yCondition[MBNum2YBlock (j, 0, picSizeX)] = ERC_BLOCK_CORRUPTED;
|
||||
errorVar->yCondition[MBNum2YBlock (j, 1, picSizeX)] = ERC_BLOCK_CORRUPTED;
|
||||
errorVar->yCondition[MBNum2YBlock (j, 2, picSizeX)] = ERC_BLOCK_CORRUPTED;
|
||||
errorVar->yCondition[MBNum2YBlock (j, 3, picSizeX)] = ERC_BLOCK_CORRUPTED;
|
||||
for (j = errorVar->segments[current_segment].startMBPos;
|
||||
j <= errorVar->segments[current_segment].endMBPos; j++) {
|
||||
errorVar->yCondition[MBNum2YBlock(j, 0, picSizeX)] = ERC_BLOCK_CORRUPTED;
|
||||
errorVar->yCondition[MBNum2YBlock(j, 1, picSizeX)] = ERC_BLOCK_CORRUPTED;
|
||||
errorVar->yCondition[MBNum2YBlock(j, 2, picSizeX)] = ERC_BLOCK_CORRUPTED;
|
||||
errorVar->yCondition[MBNum2YBlock(j, 3, picSizeX)] = ERC_BLOCK_CORRUPTED;
|
||||
errorVar->uCondition[j] = ERC_BLOCK_CORRUPTED;
|
||||
errorVar->vCondition[j] = ERC_BLOCK_CORRUPTED;
|
||||
}
|
||||
|
@ -312,21 +305,19 @@ void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar )
|
|||
* Variables for error detector
|
||||
************************************************************************
|
||||
*/
|
||||
void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar )
|
||||
{
|
||||
void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar) {
|
||||
int j = 0;
|
||||
int current_segment;
|
||||
|
||||
current_segment = errorVar->currSegment-1;
|
||||
if ( errorVar && errorVar->concealment )
|
||||
{
|
||||
current_segment = errorVar->currSegment - 1;
|
||||
if (errorVar && errorVar->concealment) {
|
||||
// mark all the Blocks belonging to the segment as OK */
|
||||
for ( j = errorVar->segments[current_segment].startMBPos; j <= errorVar->segments[current_segment].endMBPos; j++ )
|
||||
{
|
||||
errorVar->yCondition[MBNum2YBlock (j, 0, picSizeX)] = ERC_BLOCK_OK;
|
||||
errorVar->yCondition[MBNum2YBlock (j, 1, picSizeX)] = ERC_BLOCK_OK;
|
||||
errorVar->yCondition[MBNum2YBlock (j, 2, picSizeX)] = ERC_BLOCK_OK;
|
||||
errorVar->yCondition[MBNum2YBlock (j, 3, picSizeX)] = ERC_BLOCK_OK;
|
||||
for (j = errorVar->segments[current_segment].startMBPos;
|
||||
j <= errorVar->segments[current_segment].endMBPos; j++) {
|
||||
errorVar->yCondition[MBNum2YBlock(j, 0, picSizeX)] = ERC_BLOCK_OK;
|
||||
errorVar->yCondition[MBNum2YBlock(j, 1, picSizeX)] = ERC_BLOCK_OK;
|
||||
errorVar->yCondition[MBNum2YBlock(j, 2, picSizeX)] = ERC_BLOCK_OK;
|
||||
errorVar->yCondition[MBNum2YBlock(j, 3, picSizeX)] = ERC_BLOCK_OK;
|
||||
errorVar->uCondition[j] = ERC_BLOCK_OK;
|
||||
errorVar->vCondition[j] = ERC_BLOCK_OK;
|
||||
}
|
||||
|
@ -337,9 +328,8 @@ void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar )
|
|||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
* Marks the Blocks of the given component (YUV) of the current MB as concealed.
|
||||
* \param currMBNum
|
||||
* Selects the segment where this MB number is in.
|
||||
* Marks the Blocks of the given component (YUV) of the current MB as
|
||||
*concealed. \param currMBNum Selects the segment where this MB number is in.
|
||||
* \param comp
|
||||
* Component to mark (0:Y, 1:U, 2:V, <0:All)
|
||||
* \param picSizeX
|
||||
|
@ -348,25 +338,26 @@ void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar )
|
|||
* Variables for error detector
|
||||
************************************************************************
|
||||
*/
|
||||
void ercMarkCurrMBConcealed( int currMBNum, int comp, int picSizeX, ercVariables_t *errorVar )
|
||||
{
|
||||
void ercMarkCurrMBConcealed(int currMBNum, int comp, int picSizeX,
|
||||
ercVariables_t *errorVar) {
|
||||
int setAll = 0;
|
||||
|
||||
if ( errorVar && errorVar->concealment )
|
||||
{
|
||||
if (comp < 0)
|
||||
{
|
||||
if (errorVar && errorVar->concealment) {
|
||||
if (comp < 0) {
|
||||
setAll = 1;
|
||||
comp = 0;
|
||||
}
|
||||
|
||||
switch (comp)
|
||||
{
|
||||
switch (comp) {
|
||||
case 0:
|
||||
errorVar->yCondition[MBNum2YBlock (currMBNum, 0, picSizeX)] = ERC_BLOCK_CONCEALED;
|
||||
errorVar->yCondition[MBNum2YBlock (currMBNum, 1, picSizeX)] = ERC_BLOCK_CONCEALED;
|
||||
errorVar->yCondition[MBNum2YBlock (currMBNum, 2, picSizeX)] = ERC_BLOCK_CONCEALED;
|
||||
errorVar->yCondition[MBNum2YBlock (currMBNum, 3, picSizeX)] = ERC_BLOCK_CONCEALED;
|
||||
errorVar->yCondition[MBNum2YBlock(currMBNum, 0, picSizeX)] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
errorVar->yCondition[MBNum2YBlock(currMBNum, 1, picSizeX)] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
errorVar->yCondition[MBNum2YBlock(currMBNum, 2, picSizeX)] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
errorVar->yCondition[MBNum2YBlock(currMBNum, 3, picSizeX)] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
if (!setAll)
|
||||
break;
|
||||
case 1:
|
||||
|
|
|
@ -15,11 +15,15 @@
|
|||
*************************************************************************************
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "erc_do.h"
|
||||
#include "global.h"
|
||||
|
||||
static void concealBlocks ( VideoParameters *p_Vid, int lastColumn, int lastRow, int comp, frame *recfr, int picSizeX, signed char *condition );
|
||||
static void pixMeanInterpolateBlock( VideoParameters *p_Vid, imgpel *src[], imgpel *block, int blockSize, int frameWidth );
|
||||
static void concealBlocks(VideoParameters *p_Vid, int lastColumn, int lastRow,
|
||||
int comp, frame *recfr, int picSizeX,
|
||||
signed char *condition);
|
||||
static void pixMeanInterpolateBlock(VideoParameters *p_Vid, imgpel *src[],
|
||||
imgpel *block, int blockSize,
|
||||
int frameWidth);
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
|
@ -27,9 +31,8 @@ static void pixMeanInterpolateBlock( VideoParameters *p_Vid, imgpel *src[], imgp
|
|||
* The main function for Intra frame concealment.
|
||||
* Calls "concealBlocks" for each color component (Y,U,V) separately
|
||||
* \return
|
||||
* 0, if the concealment was not successful and simple concealment should be used
|
||||
* 1, otherwise (even if none of the blocks were concealed)
|
||||
* \param p_Vid
|
||||
* 0, if the concealment was not successful and simple concealment should
|
||||
*be used 1, otherwise (even if none of the blocks were concealed) \param p_Vid
|
||||
* video encoding parameters for current picture
|
||||
* \param recfr
|
||||
* Reconstructed frame buffer
|
||||
|
@ -41,32 +44,32 @@ static void pixMeanInterpolateBlock( VideoParameters *p_Vid, imgpel *src[], imgp
|
|||
* Variables for error concealment
|
||||
************************************************************************
|
||||
*/
|
||||
int ercConcealIntraFrame( VideoParameters *p_Vid, frame *recfr, int picSizeX, int picSizeY, ercVariables_t *errorVar )
|
||||
{
|
||||
int ercConcealIntraFrame(VideoParameters *p_Vid, frame *recfr, int picSizeX,
|
||||
int picSizeY, ercVariables_t *errorVar) {
|
||||
int lastColumn = 0, lastRow = 0;
|
||||
|
||||
// if concealment is on
|
||||
if ( errorVar && errorVar->concealment )
|
||||
{
|
||||
if (errorVar && errorVar->concealment) {
|
||||
// if there are segments to be concealed
|
||||
if ( errorVar->nOfCorruptedSegments )
|
||||
{
|
||||
if (errorVar->nOfCorruptedSegments) {
|
||||
// Y
|
||||
lastRow = (int) (picSizeY>>3);
|
||||
lastColumn = (int) (picSizeX>>3);
|
||||
concealBlocks( p_Vid, lastColumn, lastRow, 0, recfr, picSizeX, errorVar->yCondition );
|
||||
lastRow = (int)(picSizeY >> 3);
|
||||
lastColumn = (int)(picSizeX >> 3);
|
||||
concealBlocks(p_Vid, lastColumn, lastRow, 0, recfr, picSizeX,
|
||||
errorVar->yCondition);
|
||||
|
||||
// U (dimensions halved compared to Y)
|
||||
lastRow = (int) (picSizeY>>4);
|
||||
lastColumn = (int) (picSizeX>>4);
|
||||
concealBlocks( p_Vid, lastColumn, lastRow, 1, recfr, picSizeX, errorVar->uCondition );
|
||||
lastRow = (int)(picSizeY >> 4);
|
||||
lastColumn = (int)(picSizeX >> 4);
|
||||
concealBlocks(p_Vid, lastColumn, lastRow, 1, recfr, picSizeX,
|
||||
errorVar->uCondition);
|
||||
|
||||
// V ( dimensions equal to U )
|
||||
concealBlocks( p_Vid, lastColumn, lastRow, 2, recfr, picSizeX, errorVar->vCondition );
|
||||
concealBlocks(p_Vid, lastColumn, lastRow, 2, recfr, picSizeX,
|
||||
errorVar->vCondition);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -84,38 +87,42 @@ int ercConcealIntraFrame( VideoParameters *p_Vid, frame *recfr, int picSizeX, in
|
|||
* \param column
|
||||
* x coordinate in blocks
|
||||
* \param predBlocks[]
|
||||
* list of neighboring source blocks (numbering 0 to 7, 1 means: use the neighbor)
|
||||
* \param frameWidth
|
||||
* width of frame in pixels
|
||||
* \param mbWidthInBlocks
|
||||
* 2 for Y, 1 for U/V components
|
||||
* list of neighboring source blocks (numbering 0 to 7, 1 means: use the
|
||||
*neighbor) \param frameWidth width of frame in pixels \param mbWidthInBlocks 2
|
||||
*for Y, 1 for U/V components
|
||||
************************************************************************
|
||||
*/
|
||||
void ercPixConcealIMB(VideoParameters *p_Vid, imgpel *currFrame, int row, int column, int predBlocks[], int frameWidth, int mbWidthInBlocks)
|
||||
{
|
||||
imgpel *src[8]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
|
||||
imgpel *currBlock = NULL;
|
||||
void ercPixConcealIMB(VideoParameters *p_Vid, imgpel *currFrame, int row,
|
||||
int column, int predBlocks[], int frameWidth,
|
||||
int mbWidthInBlocks) {
|
||||
imgpel *src[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
imgpel *currBlock = NULL;
|
||||
|
||||
// collect the reliable neighboring blocks
|
||||
if (predBlocks[0])
|
||||
src[0] = currFrame + (row-mbWidthInBlocks)*frameWidth*8 + (column+mbWidthInBlocks)*8;
|
||||
if (predBlocks[1])
|
||||
src[1] = currFrame + (row-mbWidthInBlocks)*frameWidth*8 + (column-mbWidthInBlocks)*8;
|
||||
if (predBlocks[2])
|
||||
src[2] = currFrame + (row+mbWidthInBlocks)*frameWidth*8 + (column-mbWidthInBlocks)*8;
|
||||
if (predBlocks[3])
|
||||
src[3] = currFrame + (row+mbWidthInBlocks)*frameWidth*8 + (column+mbWidthInBlocks)*8;
|
||||
if (predBlocks[4])
|
||||
src[4] = currFrame + (row-mbWidthInBlocks)*frameWidth*8 + column*8;
|
||||
if (predBlocks[5])
|
||||
src[5] = currFrame + row*frameWidth*8 + (column-mbWidthInBlocks)*8;
|
||||
if (predBlocks[6])
|
||||
src[6] = currFrame + (row+mbWidthInBlocks)*frameWidth*8 + column*8;
|
||||
if (predBlocks[7])
|
||||
src[7] = currFrame + row*frameWidth*8 + (column+mbWidthInBlocks)*8;
|
||||
// collect the reliable neighboring blocks
|
||||
if (predBlocks[0])
|
||||
src[0] = currFrame + (row - mbWidthInBlocks) * frameWidth * 8 +
|
||||
(column + mbWidthInBlocks) * 8;
|
||||
if (predBlocks[1])
|
||||
src[1] = currFrame + (row - mbWidthInBlocks) * frameWidth * 8 +
|
||||
(column - mbWidthInBlocks) * 8;
|
||||
if (predBlocks[2])
|
||||
src[2] = currFrame + (row + mbWidthInBlocks) * frameWidth * 8 +
|
||||
(column - mbWidthInBlocks) * 8;
|
||||
if (predBlocks[3])
|
||||
src[3] = currFrame + (row + mbWidthInBlocks) * frameWidth * 8 +
|
||||
(column + mbWidthInBlocks) * 8;
|
||||
if (predBlocks[4])
|
||||
src[4] = currFrame + (row - mbWidthInBlocks) * frameWidth * 8 + column * 8;
|
||||
if (predBlocks[5])
|
||||
src[5] = currFrame + row * frameWidth * 8 + (column - mbWidthInBlocks) * 8;
|
||||
if (predBlocks[6])
|
||||
src[6] = currFrame + (row + mbWidthInBlocks) * frameWidth * 8 + column * 8;
|
||||
if (predBlocks[7])
|
||||
src[7] = currFrame + row * frameWidth * 8 + (column + mbWidthInBlocks) * 8;
|
||||
|
||||
currBlock = currFrame + row*frameWidth*8 + column*8;
|
||||
pixMeanInterpolateBlock( p_Vid, src, currBlock, mbWidthInBlocks*8, frameWidth );
|
||||
currBlock = currFrame + row * frameWidth * 8 + column * 8;
|
||||
pixMeanInterpolateBlock(p_Vid, src, currBlock, mbWidthInBlocks * 8,
|
||||
frameWidth);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -151,79 +158,80 @@ void ercPixConcealIMB(VideoParameters *p_Vid, imgpel *currFrame, int row, int co
|
|||
* No corner neighbors are considered
|
||||
************************************************************************
|
||||
*/
|
||||
int ercCollect8PredBlocks( int predBlocks[], int currRow, int currColumn, signed char *condition,
|
||||
int maxRow, int maxColumn, int step, byte fNoCornerNeigh )
|
||||
{
|
||||
int srcCounter = 0;
|
||||
int ercCollect8PredBlocks(int predBlocks[], int currRow, int currColumn,
|
||||
signed char *condition, int maxRow, int maxColumn,
|
||||
int step, byte fNoCornerNeigh) {
|
||||
int srcCounter = 0;
|
||||
int srcCountMin = (fNoCornerNeigh ? 2 : 4);
|
||||
int threshold = ERC_BLOCK_OK;
|
||||
int threshold = ERC_BLOCK_OK;
|
||||
|
||||
memset( predBlocks, 0, 8*sizeof(int) );
|
||||
memset(predBlocks, 0, 8 * sizeof(int));
|
||||
|
||||
// collect the reliable neighboring blocks
|
||||
do
|
||||
{
|
||||
do {
|
||||
srcCounter = 0;
|
||||
// top
|
||||
if (currRow > 0 && condition[ (currRow-1)*maxColumn + currColumn ] >= threshold )
|
||||
{ //ERC_BLOCK_OK (3) or ERC_BLOCK_CONCEALED (2)
|
||||
predBlocks[4] = condition[ (currRow-1)*maxColumn + currColumn ];
|
||||
if (currRow > 0 &&
|
||||
condition[(currRow - 1) * maxColumn + currColumn] >=
|
||||
threshold) { // ERC_BLOCK_OK (3) or ERC_BLOCK_CONCEALED (2)
|
||||
predBlocks[4] = condition[(currRow - 1) * maxColumn + currColumn];
|
||||
srcCounter++;
|
||||
}
|
||||
// bottom
|
||||
if ( currRow < (maxRow-step) && condition[ (currRow+step)*maxColumn + currColumn ] >= threshold )
|
||||
{
|
||||
predBlocks[6] = condition[ (currRow+step)*maxColumn + currColumn ];
|
||||
if (currRow < (maxRow - step) &&
|
||||
condition[(currRow + step) * maxColumn + currColumn] >= threshold) {
|
||||
predBlocks[6] = condition[(currRow + step) * maxColumn + currColumn];
|
||||
srcCounter++;
|
||||
}
|
||||
|
||||
if ( currColumn > 0 )
|
||||
{
|
||||
if (currColumn > 0) {
|
||||
// left
|
||||
if ( condition[ currRow*maxColumn + currColumn - 1 ] >= threshold )
|
||||
{
|
||||
predBlocks[5] = condition[ currRow*maxColumn + currColumn - 1 ];
|
||||
if (condition[currRow * maxColumn + currColumn - 1] >= threshold) {
|
||||
predBlocks[5] = condition[currRow * maxColumn + currColumn - 1];
|
||||
srcCounter++;
|
||||
}
|
||||
|
||||
if ( !fNoCornerNeigh )
|
||||
{
|
||||
if (!fNoCornerNeigh) {
|
||||
// top-left
|
||||
if ( currRow > 0 && condition[ (currRow-1)*maxColumn + currColumn - 1 ] >= threshold )
|
||||
{
|
||||
predBlocks[1] = condition[ (currRow-1)*maxColumn + currColumn - 1 ];
|
||||
if (currRow > 0 &&
|
||||
condition[(currRow - 1) * maxColumn + currColumn - 1] >=
|
||||
threshold) {
|
||||
predBlocks[1] = condition[(currRow - 1) * maxColumn + currColumn - 1];
|
||||
srcCounter++;
|
||||
}
|
||||
// bottom-left
|
||||
if ( currRow < (maxRow-step) && condition[ (currRow+step)*maxColumn + currColumn - 1 ] >= threshold )
|
||||
{
|
||||
predBlocks[2] = condition[ (currRow+step)*maxColumn + currColumn - 1 ];
|
||||
if (currRow < (maxRow - step) &&
|
||||
condition[(currRow + step) * maxColumn + currColumn - 1] >=
|
||||
threshold) {
|
||||
predBlocks[2] =
|
||||
condition[(currRow + step) * maxColumn + currColumn - 1];
|
||||
srcCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( currColumn < (maxColumn-step) )
|
||||
{
|
||||
if (currColumn < (maxColumn - step)) {
|
||||
// right
|
||||
if ( condition[ currRow*maxColumn+currColumn + step ] >= threshold )
|
||||
{
|
||||
predBlocks[7] = condition[ currRow*maxColumn+currColumn + step ];
|
||||
if (condition[currRow * maxColumn + currColumn + step] >= threshold) {
|
||||
predBlocks[7] = condition[currRow * maxColumn + currColumn + step];
|
||||
srcCounter++;
|
||||
}
|
||||
|
||||
if ( !fNoCornerNeigh )
|
||||
{
|
||||
if (!fNoCornerNeigh) {
|
||||
// top-right
|
||||
if ( currRow > 0 && condition[ (currRow-1)*maxColumn + currColumn + step ] >= threshold )
|
||||
{
|
||||
predBlocks[0] = condition[ (currRow-1)*maxColumn + currColumn + step ];
|
||||
if (currRow > 0 &&
|
||||
condition[(currRow - 1) * maxColumn + currColumn + step] >=
|
||||
threshold) {
|
||||
predBlocks[0] =
|
||||
condition[(currRow - 1) * maxColumn + currColumn + step];
|
||||
srcCounter++;
|
||||
}
|
||||
// bottom-right
|
||||
if ( currRow < (maxRow-step) && condition[ (currRow+step)*maxColumn + currColumn + step ] >= threshold )
|
||||
{
|
||||
predBlocks[3] = condition[ (currRow+step)*maxColumn + currColumn + step ];
|
||||
if (currRow < (maxRow - step) &&
|
||||
condition[(currRow + step) * maxColumn + currColumn + step] >=
|
||||
threshold) {
|
||||
predBlocks[3] =
|
||||
condition[(currRow + step) * maxColumn + currColumn + step];
|
||||
srcCounter++;
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +240,7 @@ int ercCollect8PredBlocks( int predBlocks[], int currRow, int currColumn, signed
|
|||
threshold--;
|
||||
if (threshold < ERC_BLOCK_CONCEALED)
|
||||
break;
|
||||
} while ( srcCounter < srcCountMin);
|
||||
} while (srcCounter < srcCountMin);
|
||||
|
||||
return srcCounter;
|
||||
}
|
||||
|
@ -260,20 +268,19 @@ int ercCollect8PredBlocks( int predBlocks[], int currRow, int currColumn, signed
|
|||
* in vertical/horizontal direction. (Y:2 U,V:1)
|
||||
************************************************************************
|
||||
*/
|
||||
int ercCollectColumnBlocks( int predBlocks[], int currRow, int currColumn, signed char *condition, int maxRow, int maxColumn, int step )
|
||||
{
|
||||
int ercCollectColumnBlocks(int predBlocks[], int currRow, int currColumn,
|
||||
signed char *condition, int maxRow, int maxColumn,
|
||||
int step) {
|
||||
int srcCounter = 0, threshold = ERC_BLOCK_CORRUPTED;
|
||||
|
||||
memset( predBlocks, 0, 8*sizeof(int) );
|
||||
memset(predBlocks, 0, 8 * sizeof(int));
|
||||
|
||||
// in this case, row > 0 and row < 17
|
||||
if ( condition[ (currRow-1)*maxColumn + currColumn ] > threshold )
|
||||
{
|
||||
if (condition[(currRow - 1) * maxColumn + currColumn] > threshold) {
|
||||
predBlocks[4] = 1;
|
||||
srcCounter++;
|
||||
}
|
||||
if ( condition[ (currRow+step)*maxColumn + currColumn ] > threshold )
|
||||
{
|
||||
if (condition[(currRow + step) * maxColumn + currColumn] > threshold) {
|
||||
predBlocks[6] = 1;
|
||||
srcCounter++;
|
||||
}
|
||||
|
@ -289,189 +296,177 @@ int ercCollectColumnBlocks( int predBlocks[], int currRow, int currColumn, signe
|
|||
* Finds the corrupted blocks and calls pixel interpolation functions
|
||||
* to correct them, one block at a time.
|
||||
* Scanning is done vertically and each corrupted column is corrected
|
||||
* bi-directionally, i.e., first block, last block, first block+1, last block -1 ...
|
||||
* \param p_Vid
|
||||
* video encoding parameters for current picture
|
||||
* \param lastColumn
|
||||
* Number of block columns in the frame
|
||||
* \param lastRow
|
||||
* Number of block rows in the frame
|
||||
* \param comp
|
||||
* color component
|
||||
* \param recfr
|
||||
* Reconstructed frame buffer
|
||||
* \param picSizeX
|
||||
* Width of the frame in pixels
|
||||
* \param condition
|
||||
* The block condition (ok, lost) table
|
||||
* bi-directionally, i.e., first block, last block, first block+1, last
|
||||
*block -1 ... \param p_Vid video encoding parameters for current picture \param
|
||||
*lastColumn Number of block columns in the frame \param lastRow Number of block
|
||||
*rows in the frame \param comp color component \param recfr Reconstructed frame
|
||||
*buffer \param picSizeX Width of the frame in pixels \param condition The block
|
||||
*condition (ok, lost) table
|
||||
************************************************************************
|
||||
*/
|
||||
static void concealBlocks( VideoParameters *p_Vid, int lastColumn, int lastRow, int comp, frame *recfr, int picSizeX, signed char *condition )
|
||||
{
|
||||
int row, column, srcCounter = 0, thr = ERC_BLOCK_CORRUPTED,
|
||||
lastCorruptedRow = -1, firstCorruptedRow = -1, currRow = 0,
|
||||
areaHeight = 0, i = 0, smoothColumn = 0;
|
||||
static void concealBlocks(VideoParameters *p_Vid, int lastColumn, int lastRow,
|
||||
int comp, frame *recfr, int picSizeX,
|
||||
signed char *condition) {
|
||||
int row, column, srcCounter = 0, thr = ERC_BLOCK_CORRUPTED,
|
||||
lastCorruptedRow = -1, firstCorruptedRow = -1, currRow = 0,
|
||||
areaHeight = 0, i = 0, smoothColumn = 0;
|
||||
int predBlocks[8], step = 1;
|
||||
|
||||
// in the Y component do the concealment MB-wise (not block-wise):
|
||||
// this is useful if only whole MBs can be damaged or lost
|
||||
if ( comp == 0 )
|
||||
if (comp == 0)
|
||||
step = 2;
|
||||
else
|
||||
step = 1;
|
||||
|
||||
for ( column = 0; column < lastColumn; column += step )
|
||||
{
|
||||
for ( row = 0; row < lastRow; row += step )
|
||||
{
|
||||
if ( condition[row*lastColumn+column] <= thr )
|
||||
{
|
||||
for (column = 0; column < lastColumn; column += step) {
|
||||
for (row = 0; row < lastRow; row += step) {
|
||||
if (condition[row * lastColumn + column] <= thr) {
|
||||
firstCorruptedRow = row;
|
||||
// find the last row which has corrupted blocks (in same continuous area)
|
||||
for ( lastCorruptedRow = row+step; lastCorruptedRow < lastRow; lastCorruptedRow += step )
|
||||
{
|
||||
// find the last row which has corrupted blocks (in same continuous
|
||||
// area)
|
||||
for (lastCorruptedRow = row + step; lastCorruptedRow < lastRow;
|
||||
lastCorruptedRow += step) {
|
||||
// check blocks in the current column
|
||||
if ( condition[ lastCorruptedRow*lastColumn + column ] > thr )
|
||||
{
|
||||
if (condition[lastCorruptedRow * lastColumn + column] > thr) {
|
||||
// current one is already OK, so the last was the previous one
|
||||
lastCorruptedRow -= step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( lastCorruptedRow >= lastRow )
|
||||
{
|
||||
if (lastCorruptedRow >= lastRow) {
|
||||
// correct only from above
|
||||
lastCorruptedRow = lastRow-step;
|
||||
for ( currRow = firstCorruptedRow; currRow < lastRow; currRow += step )
|
||||
{
|
||||
srcCounter = ercCollect8PredBlocks( predBlocks, currRow, column, condition, lastRow, lastColumn, step, 1 );
|
||||
lastCorruptedRow = lastRow - step;
|
||||
for (currRow = firstCorruptedRow; currRow < lastRow;
|
||||
currRow += step) {
|
||||
srcCounter =
|
||||
ercCollect8PredBlocks(predBlocks, currRow, column, condition,
|
||||
lastRow, lastColumn, step, 1);
|
||||
|
||||
switch( comp )
|
||||
{
|
||||
case 0 :
|
||||
ercPixConcealIMB( p_Vid, recfr->yptr, currRow, column, predBlocks, picSizeX, 2 );
|
||||
switch (comp) {
|
||||
case 0:
|
||||
ercPixConcealIMB(p_Vid, recfr->yptr, currRow, column, predBlocks,
|
||||
picSizeX, 2);
|
||||
break;
|
||||
case 1 :
|
||||
ercPixConcealIMB( p_Vid, recfr->uptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
||||
case 1:
|
||||
ercPixConcealIMB(p_Vid, recfr->uptr, currRow, column, predBlocks,
|
||||
(picSizeX >> 1), 1);
|
||||
break;
|
||||
case 2 :
|
||||
ercPixConcealIMB( p_Vid, recfr->vptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
||||
case 2:
|
||||
ercPixConcealIMB(p_Vid, recfr->vptr, currRow, column, predBlocks,
|
||||
(picSizeX >> 1), 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( comp == 0 )
|
||||
{
|
||||
condition[ currRow*lastColumn+column] = ERC_BLOCK_CONCEALED;
|
||||
condition[ currRow*lastColumn+column + 1] = ERC_BLOCK_CONCEALED;
|
||||
condition[ currRow*lastColumn+column + lastColumn] = ERC_BLOCK_CONCEALED;
|
||||
condition[ currRow*lastColumn+column + lastColumn + 1] = ERC_BLOCK_CONCEALED;
|
||||
if (comp == 0) {
|
||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||
condition[currRow * lastColumn + column + 1] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
condition[currRow * lastColumn + column + lastColumn] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
condition[currRow * lastColumn + column + lastColumn + 1] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
} else {
|
||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||
}
|
||||
else
|
||||
{
|
||||
condition[ currRow*lastColumn+column] = ERC_BLOCK_CONCEALED;
|
||||
}
|
||||
|
||||
}
|
||||
row = lastRow;
|
||||
}
|
||||
else if ( firstCorruptedRow == 0 )
|
||||
{
|
||||
} else if (firstCorruptedRow == 0) {
|
||||
// correct only from below
|
||||
for ( currRow = lastCorruptedRow; currRow >= 0; currRow -= step )
|
||||
{
|
||||
srcCounter = ercCollect8PredBlocks( predBlocks, currRow, column, condition, lastRow, lastColumn, step, 1 );
|
||||
for (currRow = lastCorruptedRow; currRow >= 0; currRow -= step) {
|
||||
srcCounter =
|
||||
ercCollect8PredBlocks(predBlocks, currRow, column, condition,
|
||||
lastRow, lastColumn, step, 1);
|
||||
|
||||
switch( comp )
|
||||
{
|
||||
case 0 :
|
||||
ercPixConcealIMB( p_Vid, recfr->yptr, currRow, column, predBlocks, picSizeX, 2 );
|
||||
switch (comp) {
|
||||
case 0:
|
||||
ercPixConcealIMB(p_Vid, recfr->yptr, currRow, column, predBlocks,
|
||||
picSizeX, 2);
|
||||
break;
|
||||
case 1 :
|
||||
ercPixConcealIMB( p_Vid, recfr->uptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
||||
case 1:
|
||||
ercPixConcealIMB(p_Vid, recfr->uptr, currRow, column, predBlocks,
|
||||
(picSizeX >> 1), 1);
|
||||
break;
|
||||
case 2 :
|
||||
ercPixConcealIMB( p_Vid, recfr->vptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
||||
case 2:
|
||||
ercPixConcealIMB(p_Vid, recfr->vptr, currRow, column, predBlocks,
|
||||
(picSizeX >> 1), 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( comp == 0 )
|
||||
{
|
||||
condition[ currRow*lastColumn+column] = ERC_BLOCK_CONCEALED;
|
||||
condition[ currRow*lastColumn+column + 1] = ERC_BLOCK_CONCEALED;
|
||||
condition[ currRow*lastColumn+column + lastColumn] = ERC_BLOCK_CONCEALED;
|
||||
condition[ currRow*lastColumn+column + lastColumn + 1] = ERC_BLOCK_CONCEALED;
|
||||
if (comp == 0) {
|
||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||
condition[currRow * lastColumn + column + 1] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
condition[currRow * lastColumn + column + lastColumn] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
condition[currRow * lastColumn + column + lastColumn + 1] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
} else {
|
||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||
}
|
||||
else
|
||||
{
|
||||
condition[ currRow*lastColumn+column] = ERC_BLOCK_CONCEALED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
row = lastCorruptedRow+step;
|
||||
}
|
||||
else
|
||||
{
|
||||
row = lastCorruptedRow + step;
|
||||
} else {
|
||||
// correct bi-directionally
|
||||
|
||||
row = lastCorruptedRow+step;
|
||||
areaHeight = lastCorruptedRow-firstCorruptedRow+step;
|
||||
row = lastCorruptedRow + step;
|
||||
areaHeight = lastCorruptedRow - firstCorruptedRow + step;
|
||||
|
||||
// Conceal the corrupted area switching between the up and the bottom rows
|
||||
for ( i = 0; i < areaHeight; i += step )
|
||||
{
|
||||
if ( i % 2 )
|
||||
{
|
||||
// Conceal the corrupted area switching between the up and the bottom
|
||||
// rows
|
||||
for (i = 0; i < areaHeight; i += step) {
|
||||
if (i % 2) {
|
||||
currRow = lastCorruptedRow;
|
||||
lastCorruptedRow -= step;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
currRow = firstCorruptedRow;
|
||||
firstCorruptedRow += step;
|
||||
}
|
||||
|
||||
if (smoothColumn > 0)
|
||||
{
|
||||
srcCounter = ercCollectColumnBlocks( predBlocks, currRow, column, condition, lastRow, lastColumn, step );
|
||||
}
|
||||
else
|
||||
{
|
||||
srcCounter = ercCollect8PredBlocks( predBlocks, currRow, column, condition, lastRow, lastColumn, step, 1 );
|
||||
if (smoothColumn > 0) {
|
||||
srcCounter =
|
||||
ercCollectColumnBlocks(predBlocks, currRow, column, condition,
|
||||
lastRow, lastColumn, step);
|
||||
} else {
|
||||
srcCounter =
|
||||
ercCollect8PredBlocks(predBlocks, currRow, column, condition,
|
||||
lastRow, lastColumn, step, 1);
|
||||
}
|
||||
|
||||
switch( comp )
|
||||
{
|
||||
case 0 :
|
||||
ercPixConcealIMB( p_Vid, recfr->yptr, currRow, column, predBlocks, picSizeX, 2 );
|
||||
switch (comp) {
|
||||
case 0:
|
||||
ercPixConcealIMB(p_Vid, recfr->yptr, currRow, column, predBlocks,
|
||||
picSizeX, 2);
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
ercPixConcealIMB( p_Vid, recfr->uptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
||||
case 1:
|
||||
ercPixConcealIMB(p_Vid, recfr->uptr, currRow, column, predBlocks,
|
||||
(picSizeX >> 1), 1);
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
ercPixConcealIMB( p_Vid, recfr->vptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
||||
case 2:
|
||||
ercPixConcealIMB(p_Vid, recfr->vptr, currRow, column, predBlocks,
|
||||
(picSizeX >> 1), 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( comp == 0 )
|
||||
{
|
||||
condition[ currRow*lastColumn+column] = ERC_BLOCK_CONCEALED;
|
||||
condition[ currRow*lastColumn+column + 1] = ERC_BLOCK_CONCEALED;
|
||||
condition[ currRow*lastColumn+column + lastColumn] = ERC_BLOCK_CONCEALED;
|
||||
condition[ currRow*lastColumn+column + lastColumn + 1] = ERC_BLOCK_CONCEALED;
|
||||
}
|
||||
else
|
||||
{
|
||||
condition[ currRow*lastColumn+column ] = ERC_BLOCK_CONCEALED;
|
||||
if (comp == 0) {
|
||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||
condition[currRow * lastColumn + column + 1] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
condition[currRow * lastColumn + column + lastColumn] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
condition[currRow * lastColumn + column + lastColumn + 1] =
|
||||
ERC_BLOCK_CONCEALED;
|
||||
} else {
|
||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastCorruptedRow = -1;
|
||||
firstCorruptedRow = -1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -494,50 +489,47 @@ static void concealBlocks( VideoParameters *p_Vid, int lastColumn, int lastRow,
|
|||
* Width of the frame in pixels
|
||||
************************************************************************
|
||||
*/
|
||||
static void pixMeanInterpolateBlock( VideoParameters *p_Vid, imgpel *src[], imgpel *block, int blockSize, int frameWidth )
|
||||
{
|
||||
static void pixMeanInterpolateBlock(VideoParameters *p_Vid, imgpel *src[],
|
||||
imgpel *block, int blockSize,
|
||||
int frameWidth) {
|
||||
int row, column, k, tmp, srcCounter = 0, weight = 0, bmax = blockSize - 1;
|
||||
|
||||
k = 0;
|
||||
for ( row = 0; row < blockSize; row++ )
|
||||
{
|
||||
for ( column = 0; column < blockSize; column++ )
|
||||
{
|
||||
for (row = 0; row < blockSize; row++) {
|
||||
for (column = 0; column < blockSize; column++) {
|
||||
tmp = 0;
|
||||
srcCounter = 0;
|
||||
// above
|
||||
if ( src[4] != NULL )
|
||||
{
|
||||
weight = blockSize-row;
|
||||
tmp += weight * (*(src[4]+bmax*frameWidth+column));
|
||||
if (src[4] != NULL) {
|
||||
weight = blockSize - row;
|
||||
tmp += weight * (*(src[4] + bmax * frameWidth + column));
|
||||
srcCounter += weight;
|
||||
}
|
||||
// left
|
||||
if ( src[5] != NULL )
|
||||
{
|
||||
weight = blockSize-column;
|
||||
tmp += weight * (*(src[5]+row*frameWidth+bmax));
|
||||
if (src[5] != NULL) {
|
||||
weight = blockSize - column;
|
||||
tmp += weight * (*(src[5] + row * frameWidth + bmax));
|
||||
srcCounter += weight;
|
||||
}
|
||||
// below
|
||||
if ( src[6] != NULL )
|
||||
{
|
||||
weight = row+1;
|
||||
tmp += weight * (*(src[6]+column));
|
||||
if (src[6] != NULL) {
|
||||
weight = row + 1;
|
||||
tmp += weight * (*(src[6] + column));
|
||||
srcCounter += weight;
|
||||
}
|
||||
// right
|
||||
if ( src[7] != NULL )
|
||||
{
|
||||
weight = column+1;
|
||||
tmp += weight * (*(src[7]+row*frameWidth));
|
||||
if (src[7] != NULL) {
|
||||
weight = column + 1;
|
||||
tmp += weight * (*(src[7] + row * frameWidth));
|
||||
srcCounter += weight;
|
||||
}
|
||||
|
||||
if ( srcCounter > 0 )
|
||||
block[ k + column ] = (imgpel)(tmp/srcCounter);
|
||||
if (srcCounter > 0)
|
||||
block[k + column] = (imgpel)(tmp / srcCounter);
|
||||
else
|
||||
block[ k + column ] = (imgpel) (blockSize == 8 ? p_Vid->dc_pred_value_comp[1] : p_Vid->dc_pred_value_comp[0]);
|
||||
block[k + column] =
|
||||
(imgpel)(blockSize == 8 ? p_Vid->dc_pred_value_comp[1]
|
||||
: p_Vid->dc_pred_value_comp[0]);
|
||||
}
|
||||
k += frameWidth;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,24 +16,22 @@
|
|||
* This simple error concealment implemented in this decoder uses
|
||||
* the existing dependencies of syntax elements.
|
||||
* In case that an element is detected as false this elements and all
|
||||
* dependend elements are marked as elements to conceal in the p_Vid->ec_flag[]
|
||||
* array. If the decoder requests a new element by the function
|
||||
* readSyntaxElement_xxxx() this array is checked first if an error concealment has
|
||||
* to be applied on this element.
|
||||
* In case that an error occured a concealed element is given to the
|
||||
* decoding function in macroblock().
|
||||
* dependend elements are marked as elements to conceal in the
|
||||
*p_Vid->ec_flag[] array. If the decoder requests a new element by the function
|
||||
* readSyntaxElement_xxxx() this array is checked first if an error
|
||||
*concealment has to be applied on this element. In case that an error occured a
|
||||
*concealed element is given to the decoding function in macroblock().
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Sebastian Purreiter <sebastian.purreiter@mch.siemens.de>
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
#include "contributors.h"
|
||||
#include "global.h"
|
||||
#include "elements.h"
|
||||
|
||||
|
||||
#include "global.h"
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
|
@ -49,75 +47,71 @@
|
|||
* EX_SYNC sync on next header
|
||||
***********************************************************************
|
||||
*/
|
||||
int set_ec_flag(VideoParameters *p_Vid, int se)
|
||||
{
|
||||
int set_ec_flag(VideoParameters *p_Vid, int se) {
|
||||
|
||||
/*
|
||||
if (p_Vid->ec_flag[se] == NO_EC)
|
||||
printf("Error concealment on element %s\n",SEtypes[se]);
|
||||
*/
|
||||
switch (se)
|
||||
{
|
||||
case SE_HEADER :
|
||||
switch (se) {
|
||||
case SE_HEADER:
|
||||
p_Vid->ec_flag[SE_HEADER] = EC_REQ;
|
||||
case SE_PTYPE :
|
||||
case SE_PTYPE:
|
||||
p_Vid->ec_flag[SE_PTYPE] = EC_REQ;
|
||||
case SE_MBTYPE :
|
||||
case SE_MBTYPE:
|
||||
p_Vid->ec_flag[SE_MBTYPE] = EC_REQ;
|
||||
|
||||
case SE_REFFRAME :
|
||||
case SE_REFFRAME:
|
||||
p_Vid->ec_flag[SE_REFFRAME] = EC_REQ;
|
||||
p_Vid->ec_flag[SE_MVD] = EC_REQ; // set all motion vectors to zero length
|
||||
se = SE_CBP_INTER; // conceal also Inter texture elements
|
||||
se = SE_CBP_INTER; // conceal also Inter texture elements
|
||||
break;
|
||||
|
||||
case SE_INTRAPREDMODE :
|
||||
case SE_INTRAPREDMODE:
|
||||
p_Vid->ec_flag[SE_INTRAPREDMODE] = EC_REQ;
|
||||
se = SE_CBP_INTRA; // conceal also Intra texture elements
|
||||
se = SE_CBP_INTRA; // conceal also Intra texture elements
|
||||
break;
|
||||
case SE_MVD :
|
||||
case SE_MVD:
|
||||
p_Vid->ec_flag[SE_MVD] = EC_REQ;
|
||||
se = SE_CBP_INTER; // conceal also Inter texture elements
|
||||
se = SE_CBP_INTER; // conceal also Inter texture elements
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (se)
|
||||
{
|
||||
case SE_CBP_INTRA :
|
||||
switch (se) {
|
||||
case SE_CBP_INTRA:
|
||||
p_Vid->ec_flag[SE_CBP_INTRA] = EC_REQ;
|
||||
case SE_LUM_DC_INTRA :
|
||||
case SE_LUM_DC_INTRA:
|
||||
p_Vid->ec_flag[SE_LUM_DC_INTRA] = EC_REQ;
|
||||
case SE_CHR_DC_INTRA :
|
||||
case SE_CHR_DC_INTRA:
|
||||
p_Vid->ec_flag[SE_CHR_DC_INTRA] = EC_REQ;
|
||||
case SE_LUM_AC_INTRA :
|
||||
case SE_LUM_AC_INTRA:
|
||||
p_Vid->ec_flag[SE_LUM_AC_INTRA] = EC_REQ;
|
||||
case SE_CHR_AC_INTRA :
|
||||
case SE_CHR_AC_INTRA:
|
||||
p_Vid->ec_flag[SE_CHR_AC_INTRA] = EC_REQ;
|
||||
break;
|
||||
|
||||
case SE_CBP_INTER :
|
||||
case SE_CBP_INTER:
|
||||
p_Vid->ec_flag[SE_CBP_INTER] = EC_REQ;
|
||||
case SE_LUM_DC_INTER :
|
||||
case SE_LUM_DC_INTER:
|
||||
p_Vid->ec_flag[SE_LUM_DC_INTER] = EC_REQ;
|
||||
case SE_CHR_DC_INTER :
|
||||
case SE_CHR_DC_INTER:
|
||||
p_Vid->ec_flag[SE_CHR_DC_INTER] = EC_REQ;
|
||||
case SE_LUM_AC_INTER :
|
||||
case SE_LUM_AC_INTER:
|
||||
p_Vid->ec_flag[SE_LUM_AC_INTER] = EC_REQ;
|
||||
case SE_CHR_AC_INTER :
|
||||
case SE_CHR_AC_INTER:
|
||||
p_Vid->ec_flag[SE_CHR_AC_INTER] = EC_REQ;
|
||||
break;
|
||||
case SE_DELTA_QUANT_INTER :
|
||||
case SE_DELTA_QUANT_INTER:
|
||||
p_Vid->ec_flag[SE_DELTA_QUANT_INTER] = EC_REQ;
|
||||
break;
|
||||
case SE_DELTA_QUANT_INTRA :
|
||||
case SE_DELTA_QUANT_INTRA:
|
||||
p_Vid->ec_flag[SE_DELTA_QUANT_INTRA] = EC_REQ;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return EC_REQ;
|
||||
}
|
||||
|
@ -129,14 +123,12 @@ int set_ec_flag(VideoParameters *p_Vid, int se)
|
|||
*
|
||||
***********************************************************************
|
||||
*/
|
||||
void reset_ec_flags(VideoParameters *p_Vid)
|
||||
{
|
||||
void reset_ec_flags(VideoParameters *p_Vid) {
|
||||
int i;
|
||||
for (i=0; i<SE_MAX_ELEMENTS; i++)
|
||||
for (i = 0; i < SE_MAX_ELEMENTS; i++)
|
||||
p_Vid->ec_flag[i] = NO_EC;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
|
@ -148,59 +140,57 @@ void reset_ec_flags(VideoParameters *p_Vid)
|
|||
* EC_REQ if element requires error concealment
|
||||
***********************************************************************
|
||||
*/
|
||||
int get_concealed_element(VideoParameters *p_Vid, SyntaxElement *sym)
|
||||
{
|
||||
int get_concealed_element(VideoParameters *p_Vid, SyntaxElement *sym) {
|
||||
if (p_Vid->ec_flag[sym->type] == NO_EC)
|
||||
return NO_EC;
|
||||
/*
|
||||
#if TRACE
|
||||
printf("TRACE: get concealed element for %s!!!\n", SEtypes[sym->type]);
|
||||
#endif
|
||||
*/
|
||||
switch (sym->type)
|
||||
{
|
||||
case SE_HEADER :
|
||||
/*
|
||||
#if TRACE
|
||||
printf("TRACE: get concealed element for %s!!!\n", SEtypes[sym->type]);
|
||||
#endif
|
||||
*/
|
||||
switch (sym->type) {
|
||||
case SE_HEADER:
|
||||
sym->len = 31;
|
||||
sym->inf = 0; // Picture Header
|
||||
break;
|
||||
|
||||
case SE_PTYPE : // inter_img_1
|
||||
case SE_MBTYPE : // set COPY_MB
|
||||
case SE_REFFRAME :
|
||||
case SE_PTYPE: // inter_img_1
|
||||
case SE_MBTYPE: // set COPY_MB
|
||||
case SE_REFFRAME:
|
||||
sym->len = 1;
|
||||
sym->inf = 0;
|
||||
break;
|
||||
|
||||
case SE_INTRAPREDMODE :
|
||||
case SE_MVD :
|
||||
case SE_INTRAPREDMODE:
|
||||
case SE_MVD:
|
||||
sym->len = 1;
|
||||
sym->inf = 0; // set vector to zero length
|
||||
sym->inf = 0; // set vector to zero length
|
||||
break;
|
||||
|
||||
case SE_CBP_INTRA :
|
||||
case SE_CBP_INTRA:
|
||||
sym->len = 5;
|
||||
sym->inf = 0; // codenumber 3 <=> no CBP information for INTRA images
|
||||
break;
|
||||
|
||||
case SE_LUM_DC_INTRA :
|
||||
case SE_CHR_DC_INTRA :
|
||||
case SE_LUM_AC_INTRA :
|
||||
case SE_CHR_AC_INTRA :
|
||||
case SE_LUM_DC_INTRA:
|
||||
case SE_CHR_DC_INTRA:
|
||||
case SE_LUM_AC_INTRA:
|
||||
case SE_CHR_AC_INTRA:
|
||||
sym->len = 1;
|
||||
sym->inf = 0; // return EOB
|
||||
sym->inf = 0; // return EOB
|
||||
break;
|
||||
|
||||
case SE_CBP_INTER :
|
||||
case SE_CBP_INTER:
|
||||
sym->len = 1;
|
||||
sym->inf = 0; // codenumber 1 <=> no CBP information for INTER images
|
||||
break;
|
||||
|
||||
case SE_LUM_DC_INTER :
|
||||
case SE_CHR_DC_INTER :
|
||||
case SE_LUM_AC_INTER :
|
||||
case SE_CHR_AC_INTER :
|
||||
case SE_LUM_DC_INTER:
|
||||
case SE_CHR_DC_INTER:
|
||||
case SE_LUM_AC_INTER:
|
||||
case SE_CHR_AC_INTER:
|
||||
sym->len = 1;
|
||||
sym->inf = 0; // return EOB
|
||||
sym->inf = 0; // return EOB
|
||||
break;
|
||||
|
||||
case SE_DELTA_QUANT_INTER:
|
||||
|
@ -217,4 +207,3 @@ int get_concealed_element(VideoParameters *p_Vid, SyntaxElement *sym)
|
|||
|
||||
return EC_REQ;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* \brief
|
||||
* Trace file handling and standard error handling function.
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Karsten Suehring <suehring@hhi.de>
|
||||
***************************************************************************************
|
||||
*/
|
||||
|
@ -15,7 +16,6 @@
|
|||
#include "global.h"
|
||||
#include "mbuffer.h"
|
||||
|
||||
|
||||
#if TRACE
|
||||
|
||||
/*!
|
||||
|
@ -24,10 +24,7 @@
|
|||
* decrement trace p_Dec->bitcounter (used for special case in mb aff)
|
||||
************************************************************************
|
||||
*/
|
||||
void dectracebitcnt(int count)
|
||||
{
|
||||
p_Dec->bitcounter -= count;
|
||||
}
|
||||
void dectracebitcnt(int count) { p_Dec->bitcounter -= count; }
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
|
@ -37,57 +34,54 @@ void dectracebitcnt(int count)
|
|||
************************************************************************
|
||||
*/
|
||||
void tracebits(
|
||||
const signed char *trace_str, //!< tracing information, signed char array describing the symbol
|
||||
int len, //!< length of syntax element in bits
|
||||
int info, //!< infoword of syntax element
|
||||
int value1)
|
||||
{
|
||||
const signed char *trace_str, //!< tracing information, signed char array
|
||||
//!< describing the symbol
|
||||
int len, //!< length of syntax element in bits
|
||||
int info, //!< infoword of syntax element
|
||||
int value1) {
|
||||
int i, chars;
|
||||
// int outint = 1;
|
||||
|
||||
if(len>=64)
|
||||
{
|
||||
snprintf(errortext, ET_SIZE, "Length argument to put too long for trace to work");
|
||||
error (errortext, 600);
|
||||
if (len >= 64) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
"Length argument to put too long for trace to work");
|
||||
error(errortext, 600);
|
||||
}
|
||||
|
||||
putc('@', p_Dec->p_trace);
|
||||
chars = fprintf(p_Dec->p_trace, "%i", p_Dec->bitcounter);
|
||||
while(chars++ < 5)
|
||||
putc(' ',p_Dec->p_trace);
|
||||
while (chars++ < 5)
|
||||
putc(' ', p_Dec->p_trace);
|
||||
|
||||
chars += fprintf(p_Dec->p_trace, " %s", trace_str);
|
||||
while(chars++ < 55)
|
||||
putc(' ',p_Dec->p_trace);
|
||||
while (chars++ < 55)
|
||||
putc(' ', p_Dec->p_trace);
|
||||
|
||||
// Align bitpattern
|
||||
if(len<15)
|
||||
{
|
||||
for(i=0 ; i<15-len ; i++)
|
||||
if (len < 15) {
|
||||
for (i = 0; i < 15 - len; i++)
|
||||
fputc(' ', p_Dec->p_trace);
|
||||
}
|
||||
|
||||
// Print bitpattern
|
||||
for(i=0 ; i<len/2 ; i++)
|
||||
{
|
||||
for (i = 0; i < len / 2; i++) {
|
||||
fputc('0', p_Dec->p_trace);
|
||||
}
|
||||
// put 1
|
||||
fprintf(p_Dec->p_trace, "1");
|
||||
|
||||
// Print bitpattern
|
||||
for(i=0 ; i<len/2 ; i++)
|
||||
{
|
||||
if (0x01 & ( info >> ((len/2-i)-1)))
|
||||
fputc('1', p_Dec->p_trace);
|
||||
else
|
||||
fputc('0', p_Dec->p_trace);
|
||||
for (i = 0; i < len / 2; i++) {
|
||||
if (0x01 & (info >> ((len / 2 - i) - 1)))
|
||||
fputc('1', p_Dec->p_trace);
|
||||
else
|
||||
fputc('0', p_Dec->p_trace);
|
||||
}
|
||||
|
||||
fprintf(p_Dec->p_trace, " (%3d) \n", value1);
|
||||
p_Dec->bitcounter += len;
|
||||
|
||||
fflush (p_Dec->p_trace);
|
||||
fflush(p_Dec->p_trace);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -97,52 +91,48 @@ void tracebits(
|
|||
************************************************************************
|
||||
*/
|
||||
void tracebits2(
|
||||
const signed char *trace_str, //!< tracing information, signed char array describing the symbol
|
||||
int len, //!< length of syntax element in bits
|
||||
int info)
|
||||
{
|
||||
const signed char *trace_str, //!< tracing information, signed char array
|
||||
//!< describing the symbol
|
||||
int len, //!< length of syntax element in bits
|
||||
int info) {
|
||||
|
||||
int i, chars;
|
||||
// int outint = 1;
|
||||
|
||||
if(len>=64)
|
||||
{
|
||||
snprintf(errortext, ET_SIZE, "Length argument to put too long for trace to work");
|
||||
error (errortext, 600);
|
||||
if (len >= 64) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
"Length argument to put too long for trace to work");
|
||||
error(errortext, 600);
|
||||
}
|
||||
|
||||
putc('@', p_Dec->p_trace);
|
||||
chars = fprintf(p_Dec->p_trace, "%i", p_Dec->bitcounter);
|
||||
|
||||
while(chars++ < 5)
|
||||
putc(' ',p_Dec->p_trace);
|
||||
while (chars++ < 5)
|
||||
putc(' ', p_Dec->p_trace);
|
||||
|
||||
chars += fprintf(p_Dec->p_trace, " %s", trace_str);
|
||||
|
||||
while(chars++ < 55)
|
||||
putc(' ',p_Dec->p_trace);
|
||||
while (chars++ < 55)
|
||||
putc(' ', p_Dec->p_trace);
|
||||
|
||||
// Align bitpattern
|
||||
if(len < 15)
|
||||
{
|
||||
for(i = 0; i < 15 - len; i++)
|
||||
if (len < 15) {
|
||||
for (i = 0; i < 15 - len; i++)
|
||||
fputc(' ', p_Dec->p_trace);
|
||||
}
|
||||
|
||||
p_Dec->bitcounter += len;
|
||||
while (len >= 32)
|
||||
{
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
while (len >= 32) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
fputc('0', p_Dec->p_trace);
|
||||
}
|
||||
len -= 8;
|
||||
}
|
||||
|
||||
// Print bitpattern
|
||||
for(i=0 ; i<len ; i++)
|
||||
{
|
||||
if (0x01 & ( info >> (len-i-1)))
|
||||
for (i = 0; i < len; i++) {
|
||||
if (0x01 & (info >> (len - i - 1)))
|
||||
fputc('1', p_Dec->p_trace);
|
||||
else
|
||||
fputc('0', p_Dec->p_trace);
|
||||
|
@ -150,7 +140,6 @@ void tracebits2(
|
|||
|
||||
fprintf(p_Dec->p_trace, " (%3d) \n", info);
|
||||
|
||||
fflush (p_Dec->p_trace);
|
||||
fflush(p_Dec->p_trace);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -8,29 +8,39 @@
|
|||
* Support for Flexible Macroblock Ordering (FMO)
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Stephan Wenger stewe@cs.tu-berlin.de
|
||||
* - Karsten Suehring suehring@hhi.de
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "elements.h"
|
||||
#include "defines.h"
|
||||
#include "header.h"
|
||||
#include "fmo.h"
|
||||
#include "defines.h"
|
||||
#include "elements.h"
|
||||
#include "fast_memory.h"
|
||||
#include "global.h"
|
||||
#include "header.h"
|
||||
|
||||
//#define PRINT_FMO_MAPS
|
||||
|
||||
static void FmoGenerateType0MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits );
|
||||
static void FmoGenerateType1MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits );
|
||||
static void FmoGenerateType2MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits );
|
||||
static void FmoGenerateType3MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice );
|
||||
static void FmoGenerateType4MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice );
|
||||
static void FmoGenerateType5MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice );
|
||||
static void FmoGenerateType6MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits );
|
||||
// #define PRINT_FMO_MAPS
|
||||
|
||||
static void FmoGenerateType0MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits);
|
||||
static void FmoGenerateType1MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits);
|
||||
static void FmoGenerateType2MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits);
|
||||
static void FmoGenerateType3MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits,
|
||||
Slice *currSlice);
|
||||
static void FmoGenerateType4MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits,
|
||||
Slice *currSlice);
|
||||
static void FmoGenerateType5MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits,
|
||||
Slice *currSlice);
|
||||
static void FmoGenerateType6MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits);
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
|
@ -43,69 +53,72 @@ static void FmoGenerateType6MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
static int FmoGenerateMapUnitToSliceGroupMap (VideoParameters *p_Vid, Slice *currSlice)
|
||||
{
|
||||
seq_parameter_set_rbsp_t* sps = p_Vid->active_sps;
|
||||
pic_parameter_set_rbsp_t* pps = p_Vid->active_pps;
|
||||
static int FmoGenerateMapUnitToSliceGroupMap(VideoParameters *p_Vid,
|
||||
Slice *currSlice) {
|
||||
seq_parameter_set_rbsp_t *sps = p_Vid->active_sps;
|
||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||
|
||||
unsigned int NumSliceGroupMapUnits;
|
||||
|
||||
NumSliceGroupMapUnits = (sps->pic_height_in_map_units_minus1+1)* (sps->pic_width_in_mbs_minus1+1);
|
||||
NumSliceGroupMapUnits = (sps->pic_height_in_map_units_minus1 + 1) *
|
||||
(sps->pic_width_in_mbs_minus1 + 1);
|
||||
|
||||
if (pps->slice_group_map_type == 6)
|
||||
{
|
||||
if ((pps->pic_size_in_map_units_minus1 + 1) != NumSliceGroupMapUnits)
|
||||
{
|
||||
error ("wrong pps->pic_size_in_map_units_minus1 for used SPS and FMO type 6", 500);
|
||||
if (pps->slice_group_map_type == 6) {
|
||||
if ((pps->pic_size_in_map_units_minus1 + 1) != NumSliceGroupMapUnits) {
|
||||
error(
|
||||
"wrong pps->pic_size_in_map_units_minus1 for used SPS and FMO type 6",
|
||||
500);
|
||||
}
|
||||
}
|
||||
|
||||
// allocate memory for p_Vid->MapUnitToSliceGroupMap
|
||||
if (p_Vid->MapUnitToSliceGroupMap)
|
||||
free (p_Vid->MapUnitToSliceGroupMap);
|
||||
if ((p_Vid->MapUnitToSliceGroupMap = malloc ((NumSliceGroupMapUnits) * sizeof (int))) == NULL)
|
||||
{
|
||||
printf ("cannot allocated %d bytes for p_Vid->MapUnitToSliceGroupMap, exit\n", (int) ( (pps->pic_size_in_map_units_minus1+1) * sizeof (int)));
|
||||
exit (-1);
|
||||
free(p_Vid->MapUnitToSliceGroupMap);
|
||||
if ((p_Vid->MapUnitToSliceGroupMap =
|
||||
malloc((NumSliceGroupMapUnits) * sizeof(int))) == NULL) {
|
||||
printf(
|
||||
"cannot allocated %d bytes for p_Vid->MapUnitToSliceGroupMap, exit\n",
|
||||
(int)((pps->pic_size_in_map_units_minus1 + 1) * sizeof(int)));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (pps->num_slice_groups_minus1 == 0) // only one slice group
|
||||
if (pps->num_slice_groups_minus1 == 0) // only one slice group
|
||||
{
|
||||
fast_memset (p_Vid->MapUnitToSliceGroupMap, 0, NumSliceGroupMapUnits * sizeof (int));
|
||||
fast_memset(p_Vid->MapUnitToSliceGroupMap, 0,
|
||||
NumSliceGroupMapUnits * sizeof(int));
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (pps->slice_group_map_type)
|
||||
{
|
||||
switch (pps->slice_group_map_type) {
|
||||
case 0:
|
||||
FmoGenerateType0MapUnitMap (p_Vid, NumSliceGroupMapUnits);
|
||||
FmoGenerateType0MapUnitMap(p_Vid, NumSliceGroupMapUnits);
|
||||
break;
|
||||
case 1:
|
||||
FmoGenerateType1MapUnitMap (p_Vid, NumSliceGroupMapUnits);
|
||||
FmoGenerateType1MapUnitMap(p_Vid, NumSliceGroupMapUnits);
|
||||
break;
|
||||
case 2:
|
||||
FmoGenerateType2MapUnitMap (p_Vid, NumSliceGroupMapUnits);
|
||||
FmoGenerateType2MapUnitMap(p_Vid, NumSliceGroupMapUnits);
|
||||
break;
|
||||
case 3:
|
||||
FmoGenerateType3MapUnitMap (p_Vid, NumSliceGroupMapUnits, currSlice);
|
||||
FmoGenerateType3MapUnitMap(p_Vid, NumSliceGroupMapUnits, currSlice);
|
||||
break;
|
||||
case 4:
|
||||
FmoGenerateType4MapUnitMap (p_Vid, NumSliceGroupMapUnits, currSlice);
|
||||
FmoGenerateType4MapUnitMap(p_Vid, NumSliceGroupMapUnits, currSlice);
|
||||
break;
|
||||
case 5:
|
||||
FmoGenerateType5MapUnitMap (p_Vid, NumSliceGroupMapUnits, currSlice);
|
||||
FmoGenerateType5MapUnitMap(p_Vid, NumSliceGroupMapUnits, currSlice);
|
||||
break;
|
||||
case 6:
|
||||
FmoGenerateType6MapUnitMap (p_Vid, NumSliceGroupMapUnits);
|
||||
FmoGenerateType6MapUnitMap(p_Vid, NumSliceGroupMapUnits);
|
||||
break;
|
||||
default:
|
||||
printf ("Illegal slice_group_map_type %d , exit \n", (int) pps->slice_group_map_type);
|
||||
exit (-1);
|
||||
printf("Illegal slice_group_map_type %d , exit \n",
|
||||
(int)pps->slice_group_map_type);
|
||||
exit(-1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -116,66 +129,58 @@ static int FmoGenerateMapUnitToSliceGroupMap (VideoParameters *p_Vid, Slice *cur
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
static int FmoGenerateMbToSliceGroupMap (VideoParameters *p_Vid, Slice *pSlice)
|
||||
{
|
||||
seq_parameter_set_rbsp_t* sps = p_Vid->active_sps;
|
||||
static int FmoGenerateMbToSliceGroupMap(VideoParameters *p_Vid, Slice *pSlice) {
|
||||
seq_parameter_set_rbsp_t *sps = p_Vid->active_sps;
|
||||
|
||||
unsigned i;
|
||||
|
||||
// allocate memory for p_Vid->MbToSliceGroupMap
|
||||
if (p_Vid->MbToSliceGroupMap)
|
||||
free (p_Vid->MbToSliceGroupMap);
|
||||
free(p_Vid->MbToSliceGroupMap);
|
||||
|
||||
if ((p_Vid->MbToSliceGroupMap = malloc ((p_Vid->PicSizeInMbs) * sizeof (int))) == NULL)
|
||||
{
|
||||
printf ("cannot allocate %d bytes for p_Vid->MbToSliceGroupMap, exit\n", (int) ((p_Vid->PicSizeInMbs) * sizeof (int)));
|
||||
exit (-1);
|
||||
if ((p_Vid->MbToSliceGroupMap =
|
||||
malloc((p_Vid->PicSizeInMbs) * sizeof(int))) == NULL) {
|
||||
printf("cannot allocate %d bytes for p_Vid->MbToSliceGroupMap, exit\n",
|
||||
(int)((p_Vid->PicSizeInMbs) * sizeof(int)));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
if ((sps->frame_mbs_only_flag)|| pSlice->field_pic_flag)
|
||||
{
|
||||
if ((sps->frame_mbs_only_flag) || pSlice->field_pic_flag) {
|
||||
int *MbToSliceGroupMap = p_Vid->MbToSliceGroupMap;
|
||||
int *MapUnitToSliceGroupMap = p_Vid->MapUnitToSliceGroupMap;
|
||||
for (i=0; i<p_Vid->PicSizeInMbs; i++)
|
||||
{
|
||||
for (i = 0; i < p_Vid->PicSizeInMbs; i++) {
|
||||
*MbToSliceGroupMap++ = *MapUnitToSliceGroupMap++;
|
||||
}
|
||||
} else if (sps->mb_adaptive_frame_field_flag && (!pSlice->field_pic_flag)) {
|
||||
for (i = 0; i < p_Vid->PicSizeInMbs; i++) {
|
||||
p_Vid->MbToSliceGroupMap[i] = p_Vid->MapUnitToSliceGroupMap[i / 2];
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < p_Vid->PicSizeInMbs; i++) {
|
||||
p_Vid->MbToSliceGroupMap[i] =
|
||||
p_Vid->MapUnitToSliceGroupMap[(i / (2 * p_Vid->PicWidthInMbs)) *
|
||||
p_Vid->PicWidthInMbs +
|
||||
(i % p_Vid->PicWidthInMbs)];
|
||||
}
|
||||
}
|
||||
else
|
||||
if (sps->mb_adaptive_frame_field_flag && (!pSlice->field_pic_flag))
|
||||
{
|
||||
for (i=0; i<p_Vid->PicSizeInMbs; i++)
|
||||
{
|
||||
p_Vid->MbToSliceGroupMap[i] = p_Vid->MapUnitToSliceGroupMap[i/2];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i<p_Vid->PicSizeInMbs; i++)
|
||||
{
|
||||
p_Vid->MbToSliceGroupMap[i] = p_Vid->MapUnitToSliceGroupMap[(i/(2*p_Vid->PicWidthInMbs))*p_Vid->PicWidthInMbs+(i%p_Vid->PicWidthInMbs)];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
* FMO initialization: Generates p_Vid->MapUnitToSliceGroupMap and p_Vid->MbToSliceGroupMap.
|
||||
* FMO initialization: Generates p_Vid->MapUnitToSliceGroupMap and
|
||||
*p_Vid->MbToSliceGroupMap.
|
||||
*
|
||||
* \param p_Vid
|
||||
* video encoding parameters for current picture
|
||||
************************************************************************
|
||||
*/
|
||||
int fmo_init(VideoParameters *p_Vid, Slice *pSlice)
|
||||
{
|
||||
pic_parameter_set_rbsp_t* pps = p_Vid->active_pps;
|
||||
int fmo_init(VideoParameters *p_Vid, Slice *pSlice) {
|
||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||
|
||||
#ifdef PRINT_FMO_MAPS
|
||||
unsigned i,j;
|
||||
unsigned i, j;
|
||||
#endif
|
||||
|
||||
FmoGenerateMapUnitToSliceGroupMap(p_Vid, pSlice);
|
||||
|
@ -187,22 +192,19 @@ int fmo_init(VideoParameters *p_Vid, Slice *pSlice)
|
|||
printf("\n");
|
||||
printf("FMO Map (Units):\n");
|
||||
|
||||
for (j=0; j<p_Vid->PicHeightInMapUnits; j++)
|
||||
{
|
||||
for (i=0; i<p_Vid->PicWidthInMbs; i++)
|
||||
{
|
||||
printf("%c",48+p_Vid->MapUnitToSliceGroupMap[i+j*p_Vid->PicWidthInMbs]);
|
||||
for (j = 0; j < p_Vid->PicHeightInMapUnits; j++) {
|
||||
for (i = 0; i < p_Vid->PicWidthInMbs; i++) {
|
||||
printf("%c",
|
||||
48 + p_Vid->MapUnitToSliceGroupMap[i + j * p_Vid->PicWidthInMbs]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
printf("FMO Map (Mb):\n");
|
||||
|
||||
for (j=0; j<p_Vid->PicHeightInMbs; j++)
|
||||
{
|
||||
for (i=0; i<p_Vid->PicWidthInMbs; i++)
|
||||
{
|
||||
printf("%c",48 + p_Vid->MbToSliceGroupMap[i + j * p_Vid->PicWidthInMbs]);
|
||||
for (j = 0; j < p_Vid->PicHeightInMbs; j++) {
|
||||
for (i = 0; i < p_Vid->PicWidthInMbs; i++) {
|
||||
printf("%c", 48 + p_Vid->MbToSliceGroupMap[i + j * p_Vid->PicWidthInMbs]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
@ -213,29 +215,24 @@ int fmo_init(VideoParameters *p_Vid, Slice *pSlice)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
* Free memory allocated by FMO functions
|
||||
************************************************************************
|
||||
*/
|
||||
int FmoFinit(VideoParameters *p_Vid)
|
||||
{
|
||||
if (p_Vid->MbToSliceGroupMap)
|
||||
{
|
||||
free (p_Vid->MbToSliceGroupMap);
|
||||
int FmoFinit(VideoParameters *p_Vid) {
|
||||
if (p_Vid->MbToSliceGroupMap) {
|
||||
free(p_Vid->MbToSliceGroupMap);
|
||||
p_Vid->MbToSliceGroupMap = NULL;
|
||||
}
|
||||
if (p_Vid->MapUnitToSliceGroupMap)
|
||||
{
|
||||
free (p_Vid->MapUnitToSliceGroupMap);
|
||||
if (p_Vid->MapUnitToSliceGroupMap) {
|
||||
free(p_Vid->MapUnitToSliceGroupMap);
|
||||
p_Vid->MapUnitToSliceGroupMap = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -245,12 +242,10 @@ int FmoFinit(VideoParameters *p_Vid)
|
|||
* VideoParameters
|
||||
************************************************************************
|
||||
*/
|
||||
int FmoGetNumberOfSliceGroup(VideoParameters *p_Vid)
|
||||
{
|
||||
int FmoGetNumberOfSliceGroup(VideoParameters *p_Vid) {
|
||||
return p_Vid->NumberOfSliceGroups;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -263,12 +258,10 @@ int FmoGetNumberOfSliceGroup(VideoParameters *p_Vid)
|
|||
* None
|
||||
************************************************************************
|
||||
*/
|
||||
int FmoGetLastMBOfPicture(VideoParameters *p_Vid)
|
||||
{
|
||||
return FmoGetLastMBInSliceGroup (p_Vid, FmoGetNumberOfSliceGroup(p_Vid)-1);
|
||||
int FmoGetLastMBOfPicture(VideoParameters *p_Vid) {
|
||||
return FmoGetLastMBInSliceGroup(p_Vid, FmoGetNumberOfSliceGroup(p_Vid) - 1);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -279,18 +272,15 @@ int FmoGetLastMBOfPicture(VideoParameters *p_Vid)
|
|||
************************************************************************
|
||||
*/
|
||||
|
||||
int FmoGetLastMBInSliceGroup (VideoParameters *p_Vid, int SliceGroup)
|
||||
{
|
||||
int FmoGetLastMBInSliceGroup(VideoParameters *p_Vid, int SliceGroup) {
|
||||
int i;
|
||||
|
||||
for (i=p_Vid->PicSizeInMbs-1; i>=0; i--)
|
||||
if (FmoGetSliceGroupId (p_Vid, i) == SliceGroup)
|
||||
for (i = p_Vid->PicSizeInMbs - 1; i >= 0; i--)
|
||||
if (FmoGetSliceGroupId(p_Vid, i) == SliceGroup)
|
||||
return i;
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -302,14 +292,12 @@ int FmoGetLastMBInSliceGroup (VideoParameters *p_Vid, int SliceGroup)
|
|||
* Macroblock number (in scan order)
|
||||
************************************************************************
|
||||
*/
|
||||
int FmoGetSliceGroupId (VideoParameters *p_Vid, int mb)
|
||||
{
|
||||
assert (mb < (int) p_Vid->PicSizeInMbs);
|
||||
assert (p_Vid->MbToSliceGroupMap != NULL);
|
||||
int FmoGetSliceGroupId(VideoParameters *p_Vid, int mb) {
|
||||
assert(mb < (int)p_Vid->PicSizeInMbs);
|
||||
assert(p_Vid->MbToSliceGroupMap != NULL);
|
||||
return p_Vid->MbToSliceGroupMap[mb];
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -322,20 +310,19 @@ int FmoGetSliceGroupId (VideoParameters *p_Vid, int mb)
|
|||
* number of the current macroblock
|
||||
************************************************************************
|
||||
*/
|
||||
int FmoGetNextMBNr (VideoParameters *p_Vid, int CurrentMbNr)
|
||||
{
|
||||
int SliceGroup = FmoGetSliceGroupId (p_Vid, CurrentMbNr);
|
||||
int FmoGetNextMBNr(VideoParameters *p_Vid, int CurrentMbNr) {
|
||||
int SliceGroup = FmoGetSliceGroupId(p_Vid, CurrentMbNr);
|
||||
|
||||
while (++CurrentMbNr<(int)p_Vid->PicSizeInMbs && p_Vid->MbToSliceGroupMap [CurrentMbNr] != SliceGroup)
|
||||
while (++CurrentMbNr < (int)p_Vid->PicSizeInMbs &&
|
||||
p_Vid->MbToSliceGroupMap[CurrentMbNr] != SliceGroup)
|
||||
;
|
||||
|
||||
if (CurrentMbNr >= (int)p_Vid->PicSizeInMbs)
|
||||
return -1; // No further MB in this slice (could be end of picture)
|
||||
return -1; // No further MB in this slice (could be end of picture)
|
||||
else
|
||||
return CurrentMbNr;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -343,25 +330,23 @@ int FmoGetNextMBNr (VideoParameters *p_Vid, int CurrentMbNr)
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
static void FmoGenerateType0MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits )
|
||||
{
|
||||
pic_parameter_set_rbsp_t* pps = p_Vid->active_pps;
|
||||
static void FmoGenerateType0MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits) {
|
||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||
unsigned iGroup, j;
|
||||
unsigned i = 0;
|
||||
do
|
||||
{
|
||||
for( iGroup = 0;
|
||||
do {
|
||||
for (iGroup = 0;
|
||||
(iGroup <= pps->num_slice_groups_minus1) && (i < PicSizeInMapUnits);
|
||||
i += pps->run_length_minus1[iGroup++] + 1 )
|
||||
{
|
||||
for( j = 0; j <= pps->run_length_minus1[ iGroup ] && i + j < PicSizeInMapUnits; j++ )
|
||||
p_Vid->MapUnitToSliceGroupMap[i+j] = iGroup;
|
||||
i += pps->run_length_minus1[iGroup++] + 1) {
|
||||
for (j = 0;
|
||||
j <= pps->run_length_minus1[iGroup] && i + j < PicSizeInMapUnits;
|
||||
j++)
|
||||
p_Vid->MapUnitToSliceGroupMap[i + j] = iGroup;
|
||||
}
|
||||
}
|
||||
while( i < PicSizeInMapUnits );
|
||||
} while (i < PicSizeInMapUnits);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -369,47 +354,48 @@ static void FmoGenerateType0MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
static void FmoGenerateType1MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits )
|
||||
{
|
||||
pic_parameter_set_rbsp_t* pps = p_Vid->active_pps;
|
||||
static void FmoGenerateType1MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits) {
|
||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||
unsigned i;
|
||||
for( i = 0; i < PicSizeInMapUnits; i++ )
|
||||
{
|
||||
p_Vid->MapUnitToSliceGroupMap[i] = ((i%p_Vid->PicWidthInMbs)+(((i/p_Vid->PicWidthInMbs)*(pps->num_slice_groups_minus1+1))/2))
|
||||
%(pps->num_slice_groups_minus1+1);
|
||||
for (i = 0; i < PicSizeInMapUnits; i++) {
|
||||
p_Vid->MapUnitToSliceGroupMap[i] =
|
||||
((i % p_Vid->PicWidthInMbs) +
|
||||
(((i / p_Vid->PicWidthInMbs) * (pps->num_slice_groups_minus1 + 1)) /
|
||||
2)) %
|
||||
(pps->num_slice_groups_minus1 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
* Generate foreground with left-over slice group map type MapUnit map (type 2)
|
||||
* Generate foreground with left-over slice group map type MapUnit map (type
|
||||
*2)
|
||||
*
|
||||
************************************************************************
|
||||
*/
|
||||
static void FmoGenerateType2MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits )
|
||||
{
|
||||
pic_parameter_set_rbsp_t* pps = p_Vid->active_pps;
|
||||
static void FmoGenerateType2MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits) {
|
||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||
int iGroup;
|
||||
unsigned i, x, y;
|
||||
unsigned yTopLeft, xTopLeft, yBottomRight, xBottomRight;
|
||||
|
||||
for( i = 0; i < PicSizeInMapUnits; i++ )
|
||||
p_Vid->MapUnitToSliceGroupMap[ i ] = pps->num_slice_groups_minus1;
|
||||
for (i = 0; i < PicSizeInMapUnits; i++)
|
||||
p_Vid->MapUnitToSliceGroupMap[i] = pps->num_slice_groups_minus1;
|
||||
|
||||
for( iGroup = pps->num_slice_groups_minus1 - 1 ; iGroup >= 0; iGroup-- )
|
||||
{
|
||||
yTopLeft = pps->top_left[ iGroup ] / p_Vid->PicWidthInMbs;
|
||||
xTopLeft = pps->top_left[ iGroup ] % p_Vid->PicWidthInMbs;
|
||||
yBottomRight = pps->bottom_right[ iGroup ] / p_Vid->PicWidthInMbs;
|
||||
xBottomRight = pps->bottom_right[ iGroup ] % p_Vid->PicWidthInMbs;
|
||||
for( y = yTopLeft; y <= yBottomRight; y++ )
|
||||
for( x = xTopLeft; x <= xBottomRight; x++ )
|
||||
p_Vid->MapUnitToSliceGroupMap[ y * p_Vid->PicWidthInMbs + x ] = iGroup;
|
||||
}
|
||||
for (iGroup = pps->num_slice_groups_minus1 - 1; iGroup >= 0; iGroup--) {
|
||||
yTopLeft = pps->top_left[iGroup] / p_Vid->PicWidthInMbs;
|
||||
xTopLeft = pps->top_left[iGroup] % p_Vid->PicWidthInMbs;
|
||||
yBottomRight = pps->bottom_right[iGroup] / p_Vid->PicWidthInMbs;
|
||||
xBottomRight = pps->bottom_right[iGroup] % p_Vid->PicWidthInMbs;
|
||||
for (y = yTopLeft; y <= yBottomRight; y++)
|
||||
for (x = xTopLeft; x <= xBottomRight; x++)
|
||||
p_Vid->MapUnitToSliceGroupMap[y * p_Vid->PicWidthInMbs + x] = iGroup;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -417,74 +403,66 @@ static void FmoGenerateType2MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
static void FmoGenerateType3MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice )
|
||||
{
|
||||
pic_parameter_set_rbsp_t* pps = p_Vid->active_pps;
|
||||
static void FmoGenerateType3MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits,
|
||||
Slice *currSlice) {
|
||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||
unsigned i, k;
|
||||
int leftBound, topBound, rightBound, bottomBound;
|
||||
int x, y, xDir, yDir;
|
||||
int mapUnitVacant;
|
||||
|
||||
unsigned mapUnitsInSliceGroup0 = imin((pps->slice_group_change_rate_minus1 + 1) * currSlice->slice_group_change_cycle, PicSizeInMapUnits);
|
||||
unsigned mapUnitsInSliceGroup0 =
|
||||
imin((pps->slice_group_change_rate_minus1 + 1) *
|
||||
currSlice->slice_group_change_cycle,
|
||||
PicSizeInMapUnits);
|
||||
|
||||
for( i = 0; i < PicSizeInMapUnits; i++ )
|
||||
p_Vid->MapUnitToSliceGroupMap[ i ] = 2;
|
||||
for (i = 0; i < PicSizeInMapUnits; i++)
|
||||
p_Vid->MapUnitToSliceGroupMap[i] = 2;
|
||||
|
||||
x = ( p_Vid->PicWidthInMbs - pps->slice_group_change_direction_flag ) / 2;
|
||||
y = ( p_Vid->PicHeightInMapUnits - pps->slice_group_change_direction_flag ) / 2;
|
||||
x = (p_Vid->PicWidthInMbs - pps->slice_group_change_direction_flag) / 2;
|
||||
y = (p_Vid->PicHeightInMapUnits - pps->slice_group_change_direction_flag) / 2;
|
||||
|
||||
leftBound = x;
|
||||
topBound = y;
|
||||
rightBound = x;
|
||||
leftBound = x;
|
||||
topBound = y;
|
||||
rightBound = x;
|
||||
bottomBound = y;
|
||||
|
||||
xDir = pps->slice_group_change_direction_flag - 1;
|
||||
yDir = pps->slice_group_change_direction_flag;
|
||||
xDir = pps->slice_group_change_direction_flag - 1;
|
||||
yDir = pps->slice_group_change_direction_flag;
|
||||
|
||||
for( k = 0; k < PicSizeInMapUnits; k += mapUnitVacant )
|
||||
{
|
||||
mapUnitVacant = ( p_Vid->MapUnitToSliceGroupMap[ y * p_Vid->PicWidthInMbs + x ] == 2 );
|
||||
if( mapUnitVacant )
|
||||
p_Vid->MapUnitToSliceGroupMap[ y * p_Vid->PicWidthInMbs + x ] = ( k >= mapUnitsInSliceGroup0 );
|
||||
for (k = 0; k < PicSizeInMapUnits; k += mapUnitVacant) {
|
||||
mapUnitVacant =
|
||||
(p_Vid->MapUnitToSliceGroupMap[y * p_Vid->PicWidthInMbs + x] == 2);
|
||||
if (mapUnitVacant)
|
||||
p_Vid->MapUnitToSliceGroupMap[y * p_Vid->PicWidthInMbs + x] =
|
||||
(k >= mapUnitsInSliceGroup0);
|
||||
|
||||
if( xDir == -1 && x == leftBound )
|
||||
{
|
||||
leftBound = imax( leftBound - 1, 0 );
|
||||
if (xDir == -1 && x == leftBound) {
|
||||
leftBound = imax(leftBound - 1, 0);
|
||||
x = leftBound;
|
||||
xDir = 0;
|
||||
yDir = 2 * pps->slice_group_change_direction_flag - 1;
|
||||
} else if (xDir == 1 && x == rightBound) {
|
||||
rightBound = imin(rightBound + 1, (int)p_Vid->PicWidthInMbs - 1);
|
||||
x = rightBound;
|
||||
xDir = 0;
|
||||
yDir = 1 - 2 * pps->slice_group_change_direction_flag;
|
||||
} else if (yDir == -1 && y == topBound) {
|
||||
topBound = imax(topBound - 1, 0);
|
||||
y = topBound;
|
||||
xDir = 1 - 2 * pps->slice_group_change_direction_flag;
|
||||
yDir = 0;
|
||||
} else if (yDir == 1 && y == bottomBound) {
|
||||
bottomBound = imin(bottomBound + 1, (int)p_Vid->PicHeightInMapUnits - 1);
|
||||
y = bottomBound;
|
||||
xDir = 2 * pps->slice_group_change_direction_flag - 1;
|
||||
yDir = 0;
|
||||
} else {
|
||||
x = x + xDir;
|
||||
y = y + yDir;
|
||||
}
|
||||
else
|
||||
if( xDir == 1 && x == rightBound )
|
||||
{
|
||||
rightBound = imin( rightBound + 1, (int)p_Vid->PicWidthInMbs - 1 );
|
||||
x = rightBound;
|
||||
xDir = 0;
|
||||
yDir = 1 - 2 * pps->slice_group_change_direction_flag;
|
||||
}
|
||||
else
|
||||
if( yDir == -1 && y == topBound )
|
||||
{
|
||||
topBound = imax( topBound - 1, 0 );
|
||||
y = topBound;
|
||||
xDir = 1 - 2 * pps->slice_group_change_direction_flag;
|
||||
yDir = 0;
|
||||
}
|
||||
else
|
||||
if( yDir == 1 && y == bottomBound )
|
||||
{
|
||||
bottomBound = imin( bottomBound + 1, (int)p_Vid->PicHeightInMapUnits - 1 );
|
||||
y = bottomBound;
|
||||
xDir = 2 * pps->slice_group_change_direction_flag - 1;
|
||||
yDir = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = x + xDir;
|
||||
y = y + yDir;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -494,21 +472,28 @@ static void FmoGenerateType3MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
static void FmoGenerateType4MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice )
|
||||
{
|
||||
pic_parameter_set_rbsp_t* pps = p_Vid->active_pps;
|
||||
static void FmoGenerateType4MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits,
|
||||
Slice *currSlice) {
|
||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||
|
||||
unsigned mapUnitsInSliceGroup0 = imin((pps->slice_group_change_rate_minus1 + 1) * currSlice->slice_group_change_cycle, PicSizeInMapUnits);
|
||||
unsigned sizeOfUpperLeftGroup = pps->slice_group_change_direction_flag ? ( PicSizeInMapUnits - mapUnitsInSliceGroup0 ) : mapUnitsInSliceGroup0;
|
||||
unsigned mapUnitsInSliceGroup0 =
|
||||
imin((pps->slice_group_change_rate_minus1 + 1) *
|
||||
currSlice->slice_group_change_cycle,
|
||||
PicSizeInMapUnits);
|
||||
unsigned sizeOfUpperLeftGroup =
|
||||
pps->slice_group_change_direction_flag
|
||||
? (PicSizeInMapUnits - mapUnitsInSliceGroup0)
|
||||
: mapUnitsInSliceGroup0;
|
||||
|
||||
unsigned i;
|
||||
|
||||
for( i = 0; i < PicSizeInMapUnits; i++ )
|
||||
if( i < sizeOfUpperLeftGroup )
|
||||
p_Vid->MapUnitToSliceGroupMap[ i ] = pps->slice_group_change_direction_flag;
|
||||
for (i = 0; i < PicSizeInMapUnits; i++)
|
||||
if (i < sizeOfUpperLeftGroup)
|
||||
p_Vid->MapUnitToSliceGroupMap[i] = pps->slice_group_change_direction_flag;
|
||||
else
|
||||
p_Vid->MapUnitToSliceGroupMap[ i ] = 1 - pps->slice_group_change_direction_flag;
|
||||
|
||||
p_Vid->MapUnitToSliceGroupMap[i] =
|
||||
1 - pps->slice_group_change_direction_flag;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -518,22 +503,30 @@ static void FmoGenerateType4MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
static void FmoGenerateType5MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice )
|
||||
{
|
||||
pic_parameter_set_rbsp_t* pps = p_Vid->active_pps;
|
||||
static void FmoGenerateType5MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits,
|
||||
Slice *currSlice) {
|
||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||
|
||||
unsigned mapUnitsInSliceGroup0 = imin((pps->slice_group_change_rate_minus1 + 1) * currSlice->slice_group_change_cycle, PicSizeInMapUnits);
|
||||
unsigned sizeOfUpperLeftGroup = pps->slice_group_change_direction_flag ? ( PicSizeInMapUnits - mapUnitsInSliceGroup0 ) : mapUnitsInSliceGroup0;
|
||||
unsigned mapUnitsInSliceGroup0 =
|
||||
imin((pps->slice_group_change_rate_minus1 + 1) *
|
||||
currSlice->slice_group_change_cycle,
|
||||
PicSizeInMapUnits);
|
||||
unsigned sizeOfUpperLeftGroup =
|
||||
pps->slice_group_change_direction_flag
|
||||
? (PicSizeInMapUnits - mapUnitsInSliceGroup0)
|
||||
: mapUnitsInSliceGroup0;
|
||||
|
||||
unsigned i,j, k = 0;
|
||||
|
||||
for( j = 0; j < p_Vid->PicWidthInMbs; j++ )
|
||||
for( i = 0; i < p_Vid->PicHeightInMapUnits; i++ )
|
||||
if( k++ < sizeOfUpperLeftGroup )
|
||||
p_Vid->MapUnitToSliceGroupMap[ i * p_Vid->PicWidthInMbs + j ] = pps->slice_group_change_direction_flag;
|
||||
else
|
||||
p_Vid->MapUnitToSliceGroupMap[ i * p_Vid->PicWidthInMbs + j ] = 1 - pps->slice_group_change_direction_flag;
|
||||
unsigned i, j, k = 0;
|
||||
|
||||
for (j = 0; j < p_Vid->PicWidthInMbs; j++)
|
||||
for (i = 0; i < p_Vid->PicHeightInMapUnits; i++)
|
||||
if (k++ < sizeOfUpperLeftGroup)
|
||||
p_Vid->MapUnitToSliceGroupMap[i * p_Vid->PicWidthInMbs + j] =
|
||||
pps->slice_group_change_direction_flag;
|
||||
else
|
||||
p_Vid->MapUnitToSliceGroupMap[i * p_Vid->PicWidthInMbs + j] =
|
||||
1 - pps->slice_group_change_direction_flag;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -543,13 +536,11 @@ static void FmoGenerateType5MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
static void FmoGenerateType6MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits )
|
||||
{
|
||||
pic_parameter_set_rbsp_t* pps = p_Vid->active_pps;
|
||||
static void FmoGenerateType6MapUnitMap(VideoParameters *p_Vid,
|
||||
unsigned PicSizeInMapUnits) {
|
||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||
unsigned i;
|
||||
for (i=0; i<PicSizeInMapUnits; i++)
|
||||
{
|
||||
for (i = 0; i < PicSizeInMapUnits; i++) {
|
||||
p_Vid->MapUnitToSliceGroupMap[i] = pps->slice_group_id[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -7,13 +7,14 @@
|
|||
* image I/O related functions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*************************************************************************************
|
||||
*/
|
||||
#include "img_io.h"
|
||||
#include "contributors.h"
|
||||
#include "global.h"
|
||||
#include "img_io.h"
|
||||
#include "report.h"
|
||||
#ifdef SPEC
|
||||
#define STRCMP strcmp
|
||||
|
@ -22,19 +23,10 @@
|
|||
#endif
|
||||
|
||||
static const VIDEO_SIZE VideoRes[] = {
|
||||
{ "qcif" , 176, 144},
|
||||
{ "qqvga" , 160, 128},
|
||||
{ "qvga" , 320, 240},
|
||||
{ "sif" , 352, 240},
|
||||
{ "cif" , 352, 288},
|
||||
{ "vga" , 640, 480},
|
||||
{ "sd1" , 720, 480},
|
||||
{ "sd2" , 704, 576},
|
||||
{ "sd3" , 720, 576},
|
||||
{ "720p" , 1280, 720},
|
||||
{ "1080p" , 1920, 1080},
|
||||
{ NULL, 0, 0}
|
||||
};
|
||||
{"qcif", 176, 144}, {"qqvga", 160, 128}, {"qvga", 320, 240},
|
||||
{"sif", 352, 240}, {"cif", 352, 288}, {"vga", 640, 480},
|
||||
{"sd1", 720, 480}, {"sd2", 704, 576}, {"sd3", 720, 576},
|
||||
{"720p", 1280, 720}, {"1080p", 1920, 1080}, {NULL, 0, 0}};
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
|
@ -43,8 +35,8 @@ static const VIDEO_SIZE VideoRes[] = {
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, double *fps)
|
||||
{
|
||||
int ParseSizeFromString(VideoDataFile *input_file, int *x_size, int *y_size,
|
||||
double *fps) {
|
||||
char *p1, *p2, *tail;
|
||||
char *fn = input_file->fname;
|
||||
char c;
|
||||
|
@ -52,27 +44,26 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
|||
|
||||
*x_size = *y_size = -1;
|
||||
p1 = p2 = fn;
|
||||
while (p1 != NULL && p2 != NULL)
|
||||
{
|
||||
while (p1 != NULL && p2 != NULL) {
|
||||
// Search for first '_'
|
||||
p1 = strstr( p1, "_");
|
||||
p1 = strstr(p1, "_");
|
||||
if (p1 == NULL)
|
||||
break;
|
||||
|
||||
// Search for end character of x_size (first 'x' after last '_')
|
||||
p2 = strstr( p1, "x");
|
||||
p2 = strstr(p1, "x");
|
||||
|
||||
// If no 'x' is found, exit
|
||||
if (p2 == NULL)
|
||||
if (p2 == NULL)
|
||||
break;
|
||||
|
||||
// Try conversion of number
|
||||
*p2 = 0;
|
||||
*x_size = strtol( p1 + 1, &tail, 10);
|
||||
*x_size = strtol(p1 + 1, &tail, 10);
|
||||
|
||||
// If there are characters left in the string, or the string is null, discard conversion
|
||||
if (*tail != '\0' || *(p1 + 1) == '\0')
|
||||
{
|
||||
// If there are characters left in the string, or the string is null,
|
||||
// discard conversion
|
||||
if (*tail != '\0' || *(p1 + 1) == '\0') {
|
||||
*p2 = 'x';
|
||||
p1 = tail;
|
||||
continue;
|
||||
|
@ -82,10 +73,9 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
|||
*p2 = 'x';
|
||||
|
||||
// Search for end character of y_size (first '_' or '.' after last 'x')
|
||||
p1 = strpbrk( p2 + 1, "_.");
|
||||
p1 = strpbrk(p2 + 1, "_.");
|
||||
// If no '_' or '.' is found, try again from current position
|
||||
if (p1 == NULL)
|
||||
{
|
||||
if (p1 == NULL) {
|
||||
p1 = p2 + 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -93,11 +83,11 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
|||
// Try conversion of number
|
||||
c = *p1;
|
||||
*p1 = 0;
|
||||
*y_size = strtol( p2 + 1, &tail, 10);
|
||||
*y_size = strtol(p2 + 1, &tail, 10);
|
||||
|
||||
// If there are characters left in the string, or the string is null, discard conversion
|
||||
if (*tail != '\0' || *(p2 + 1) == '\0')
|
||||
{
|
||||
// If there are characters left in the string, or the string is null,
|
||||
// discard conversion
|
||||
if (*tail != '\0' || *(p2 + 1) == '\0') {
|
||||
*p1 = c;
|
||||
p1 = tail;
|
||||
continue;
|
||||
|
@ -107,20 +97,20 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
|||
*p1 = c;
|
||||
|
||||
// Search for end character of y_size (first 'i' or 'p' after last '_')
|
||||
p2 = strstr( p1 + 1, "ip");
|
||||
p2 = strstr(p1 + 1, "ip");
|
||||
|
||||
// If no 'i' or 'p' is found, exit
|
||||
if (p2 == NULL)
|
||||
if (p2 == NULL)
|
||||
break;
|
||||
|
||||
// Try conversion of number
|
||||
c = *p2;
|
||||
*p2 = 0;
|
||||
*fps = strtod( p1 + 1, &tail);
|
||||
*fps = strtod(p1 + 1, &tail);
|
||||
|
||||
// If there are characters left in the string, or the string is null, discard conversion
|
||||
if (*tail != '\0' || *(p1 + 1) == '\0')
|
||||
{
|
||||
// If there are characters left in the string, or the string is null,
|
||||
// discard conversion
|
||||
if (*tail != '\0' || *(p1 + 1) == '\0') {
|
||||
*p2 = c;
|
||||
p1 = tail;
|
||||
continue;
|
||||
|
@ -132,21 +122,18 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
|||
}
|
||||
|
||||
// Now lets test some common video file formats
|
||||
if (p1 == NULL || p2 == NULL)
|
||||
{
|
||||
for (i = 0; VideoRes[i].name != NULL; i++)
|
||||
{
|
||||
if (STRCMP (fn, VideoRes[i].name))
|
||||
{
|
||||
if (p1 == NULL || p2 == NULL) {
|
||||
for (i = 0; VideoRes[i].name != NULL; i++) {
|
||||
if (STRCMP(fn, VideoRes[i].name)) {
|
||||
*x_size = VideoRes[i].x_size;
|
||||
*y_size = VideoRes[i].y_size;
|
||||
*y_size = VideoRes[i].y_size;
|
||||
// Should add frame rate support as well
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (*x_size == -1 || *y_size == -1) ? 0 : 1;
|
||||
return (*x_size == -1 || *y_size == -1) ? 0 : 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -156,45 +143,43 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
void ParseFrameNoFormatFromString (VideoDataFile *input_file)
|
||||
{
|
||||
char *p1, *p2, *tail;
|
||||
char *fn = input_file->fname;
|
||||
char *fhead = input_file->fhead;
|
||||
char *ftail = input_file->ftail;
|
||||
int *zero_pad = &input_file->zero_pad;
|
||||
int *num_digits = &input_file->num_digits;
|
||||
void ParseFrameNoFormatFromString(VideoDataFile *input_file) {
|
||||
char *p1, *p2, *tail;
|
||||
char *fn = input_file->fname;
|
||||
char *fhead = input_file->fhead;
|
||||
char *ftail = input_file->ftail;
|
||||
int *zero_pad = &input_file->zero_pad;
|
||||
int *num_digits = &input_file->num_digits;
|
||||
|
||||
*zero_pad = 0;
|
||||
*num_digits = -1;
|
||||
p1 = p2 = fn;
|
||||
while (p1 != NULL && p2 != NULL)
|
||||
{
|
||||
while (p1 != NULL && p2 != NULL) {
|
||||
// Search for first '_'
|
||||
p1 = strstr( p1, "%");
|
||||
p1 = strstr(p1, "%");
|
||||
if (p1 == NULL)
|
||||
break;
|
||||
|
||||
strncpy(fhead, fn, p1 - fn);
|
||||
|
||||
// Search for end character of x_size (first 'x' after last '_')
|
||||
p2 = strstr( p1, "d");
|
||||
p2 = strstr(p1, "d");
|
||||
|
||||
// If no 'x' is found, exit
|
||||
if (p2 == NULL)
|
||||
if (p2 == NULL)
|
||||
break;
|
||||
|
||||
|
||||
// Try conversion of number
|
||||
*p2 = 0;
|
||||
|
||||
if (*(p1 + 1) == '0')
|
||||
*zero_pad = 1;
|
||||
|
||||
*num_digits = strtol( p1 + 1, &tail, 10);
|
||||
*num_digits = strtol(p1 + 1, &tail, 10);
|
||||
|
||||
// If there are characters left in the string, or the string is null, discard conversion
|
||||
if (*tail != '\0' || *(p1 + 1) == '\0')
|
||||
{
|
||||
// If there are characters left in the string, or the string is null,
|
||||
// discard conversion
|
||||
if (*tail != '\0' || *(p1 + 1) == '\0') {
|
||||
*p2 = 'd';
|
||||
p1 = tail;
|
||||
continue;
|
||||
|
@ -204,15 +189,13 @@ void ParseFrameNoFormatFromString (VideoDataFile *input_file)
|
|||
*p2 = 'd';
|
||||
|
||||
tail++;
|
||||
strncpy(ftail, tail, (int) strlen(tail));
|
||||
strncpy(ftail, tail, (int)strlen(tail));
|
||||
break;
|
||||
}
|
||||
|
||||
if (input_file->vdtype == VIDEO_TIFF)
|
||||
{
|
||||
if (input_file->vdtype == VIDEO_TIFF) {
|
||||
input_file->is_concatenated = 0;
|
||||
}
|
||||
else
|
||||
} else
|
||||
input_file->is_concatenated = (*num_digits == -1) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
@ -222,31 +205,29 @@ void ParseFrameNoFormatFromString (VideoDataFile *input_file)
|
|||
* Open file containing a single frame
|
||||
************************************************************************
|
||||
*/
|
||||
void OpenFrameFile( VideoDataFile *input_file, int FrameNumberInFile)
|
||||
{
|
||||
char infile [FILE_NAME_SIZE], in_number[16];
|
||||
void OpenFrameFile(VideoDataFile *input_file, int FrameNumberInFile) {
|
||||
char infile[FILE_NAME_SIZE], in_number[16];
|
||||
int length = 0;
|
||||
in_number[length]='\0';
|
||||
length = (int) strlen(input_file->fhead);
|
||||
in_number[length] = '\0';
|
||||
length = (int)strlen(input_file->fhead);
|
||||
strncpy(infile, input_file->fhead, length);
|
||||
infile[length]='\0';
|
||||
if (input_file->zero_pad)
|
||||
infile[length] = '\0';
|
||||
if (input_file->zero_pad)
|
||||
snprintf(in_number, 16, "%0*d", input_file->num_digits, FrameNumberInFile);
|
||||
else
|
||||
snprintf(in_number, 16, "%*d", input_file->num_digits, FrameNumberInFile);
|
||||
|
||||
strncat(infile, in_number, sizeof(in_number));
|
||||
length += sizeof(in_number);
|
||||
infile[length]='\0';
|
||||
infile[length] = '\0';
|
||||
strncat(infile, input_file->ftail, strlen(input_file->ftail));
|
||||
length += (int) strlen(input_file->ftail);
|
||||
infile[length]='\0';
|
||||
length += (int)strlen(input_file->ftail);
|
||||
infile[length] = '\0';
|
||||
|
||||
if ((input_file->f_num = open(infile, OPENFLAGS_READ)) == -1)
|
||||
{
|
||||
printf ("OpenFrameFile: cannot open file %s\n", infile);
|
||||
if ((input_file->f_num = open(infile, OPENFLAGS_READ)) == -1) {
|
||||
printf("OpenFrameFile: cannot open file %s\n", infile);
|
||||
report_stats_on_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -255,20 +236,18 @@ void OpenFrameFile( VideoDataFile *input_file, int FrameNumberInFile)
|
|||
* Open file(s) containing the entire frame sequence
|
||||
************************************************************************
|
||||
*/
|
||||
void OpenFiles( VideoDataFile *input_file)
|
||||
{
|
||||
if (input_file->is_concatenated == 1)
|
||||
{
|
||||
if ((int) strlen(input_file->fname) == 0)
|
||||
{
|
||||
snprintf(errortext, ET_SIZE, "No input sequence name was provided. Please check settings.");
|
||||
error (errortext, 500);
|
||||
void OpenFiles(VideoDataFile *input_file) {
|
||||
if (input_file->is_concatenated == 1) {
|
||||
if ((int)strlen(input_file->fname) == 0) {
|
||||
snprintf(errortext, ET_SIZE,
|
||||
"No input sequence name was provided. Please check settings.");
|
||||
error(errortext, 500);
|
||||
}
|
||||
|
||||
if ((input_file->f_num = open(input_file->fname, OPENFLAGS_READ)) == -1)
|
||||
{
|
||||
snprintf(errortext, ET_SIZE, "Input file %s does not exist",input_file->fname);
|
||||
error (errortext, 500);
|
||||
if ((input_file->f_num = open(input_file->fname, OPENFLAGS_READ)) == -1) {
|
||||
snprintf(errortext, ET_SIZE, "Input file %s does not exist",
|
||||
input_file->fname);
|
||||
error(errortext, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -279,8 +258,7 @@ void OpenFiles( VideoDataFile *input_file)
|
|||
* Close input file
|
||||
************************************************************************
|
||||
*/
|
||||
void CloseFiles(VideoDataFile *input_file)
|
||||
{
|
||||
void CloseFiles(VideoDataFile *input_file) {
|
||||
if (input_file->f_num != -1)
|
||||
close(input_file->f_num);
|
||||
input_file->f_num = -1;
|
||||
|
@ -291,38 +269,28 @@ void CloseFiles(VideoDataFile *input_file)
|
|||
* ParseVideoType
|
||||
*
|
||||
* ==========================================================================
|
||||
*/
|
||||
VideoFileType ParseVideoType (VideoDataFile *input_file)
|
||||
{
|
||||
*/
|
||||
VideoFileType ParseVideoType(VideoDataFile *input_file) {
|
||||
char *format;
|
||||
|
||||
format = input_file->fname + (int) strlen(input_file->fname) - 3;
|
||||
format = input_file->fname + (int)strlen(input_file->fname) - 3;
|
||||
|
||||
if (STRCMP (format, "yuv") == 0)
|
||||
{
|
||||
if (STRCMP(format, "yuv") == 0) {
|
||||
input_file->vdtype = VIDEO_YUV;
|
||||
input_file->format.yuv_format = YUV420;
|
||||
input_file->avi = NULL;
|
||||
}
|
||||
else if (STRCMP (format, "rgb") == 0)
|
||||
{
|
||||
} else if (STRCMP(format, "rgb") == 0) {
|
||||
input_file->vdtype = VIDEO_RGB;
|
||||
input_file->format.yuv_format = YUV444;
|
||||
input_file->avi = NULL;
|
||||
}
|
||||
else if (STRCMP (format, "tif") == 0)
|
||||
{
|
||||
} else if (STRCMP(format, "tif") == 0) {
|
||||
input_file->vdtype = VIDEO_TIFF;
|
||||
input_file->avi = NULL;
|
||||
}
|
||||
else if (STRCMP (format, "avi") == 0)
|
||||
{
|
||||
} else if (STRCMP(format, "avi") == 0) {
|
||||
input_file->vdtype = VIDEO_AVI;
|
||||
}
|
||||
else
|
||||
{
|
||||
//snprintf(errortext, ET_SIZE, "ERROR: video file format not supported");
|
||||
//error (errortext, 500);
|
||||
} else {
|
||||
// snprintf(errortext, ET_SIZE, "ERROR: video file format not supported");
|
||||
// error (errortext, 500);
|
||||
input_file->vdtype = VIDEO_YUV;
|
||||
input_file->format.yuv_format = YUV420;
|
||||
input_file->avi = NULL;
|
||||
|
|
|
@ -6,42 +6,40 @@
|
|||
* Input data Image Processing functions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Michael Tourapis <alexis.tourapis@dolby.com>
|
||||
*
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
||||
#include "contributors.h"
|
||||
#include "global.h"
|
||||
#include "img_process.h"
|
||||
#include "contributors.h"
|
||||
#include "fast_memory.h"
|
||||
#include "global.h"
|
||||
#include "io_image.h"
|
||||
#include "memalloc.h"
|
||||
#include "fast_memory.h"
|
||||
|
||||
static inline void ResetImage(ImageData *imgOut) {
|
||||
fast_memset(imgOut->frm_data[0][0], 0,
|
||||
imgOut->format.height[0] * imgOut->format.width[0] *
|
||||
sizeof(imgpel));
|
||||
|
||||
static inline void ResetImage(ImageData *imgOut)
|
||||
{
|
||||
fast_memset(imgOut->frm_data[0][0], 0, imgOut->format.height[0] * imgOut->format.width[0] * sizeof (imgpel));
|
||||
|
||||
if (imgOut->format.yuv_format != YUV400)
|
||||
{
|
||||
if (sizeof(imgpel) == sizeof(signed char))
|
||||
{
|
||||
fast_memset(imgOut->frm_data[1][0], 128, imgOut->format.height[1] * imgOut->format.width[1] * sizeof (imgpel));
|
||||
fast_memset(imgOut->frm_data[2][0], 128, imgOut->format.height[1] * imgOut->format.width[1] * sizeof (imgpel));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (imgOut->format.yuv_format != YUV400) {
|
||||
if (sizeof(imgpel) == sizeof(signed char)) {
|
||||
fast_memset(imgOut->frm_data[1][0], 128,
|
||||
imgOut->format.height[1] * imgOut->format.width[1] *
|
||||
sizeof(imgpel));
|
||||
fast_memset(imgOut->frm_data[2][0], 128,
|
||||
imgOut->format.height[1] * imgOut->format.width[1] *
|
||||
sizeof(imgpel));
|
||||
} else {
|
||||
int i, j, k;
|
||||
imgpel med_value;
|
||||
for (k = 1; k <=2; k++)
|
||||
{
|
||||
med_value = (imgpel) (imgOut->format.max_value[k] + 1) >> 1;
|
||||
for (j = 0; j < imgOut->format.height[1]; j++)
|
||||
{
|
||||
for (i = 0; i < imgOut->format.width[1]; i++)
|
||||
{
|
||||
for (k = 1; k <= 2; k++) {
|
||||
med_value = (imgpel)(imgOut->format.max_value[k] + 1) >> 1;
|
||||
for (j = 0; j < imgOut->format.height[1]; j++) {
|
||||
for (i = 0; i < imgOut->format.width[1]; i++) {
|
||||
imgOut->frm_data[k][j][i] = med_value;
|
||||
}
|
||||
}
|
||||
|
@ -50,124 +48,129 @@ static inline void ResetImage(ImageData *imgOut)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void CPImage(ImageData *imgOut, ImageData *imgIn) {
|
||||
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0],
|
||||
imgIn->format.height[0] * imgIn->format.width[0] * sizeof(imgpel));
|
||||
|
||||
static inline void CPImage(ImageData *imgOut, ImageData *imgIn)
|
||||
{
|
||||
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0], imgIn->format.height[0] * imgIn->format.width[0] * sizeof (imgpel));
|
||||
|
||||
if (imgIn->format.yuv_format != YUV400)
|
||||
{
|
||||
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[1][0], imgIn->format.height[1] * imgIn->format.width[1] * sizeof (imgpel));
|
||||
memcpy(imgOut->frm_data[2][0], imgIn->frm_data[2][0], imgIn->format.height[1] * imgIn->format.width[1] * sizeof (imgpel));
|
||||
if (imgIn->format.yuv_format != YUV400) {
|
||||
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[1][0],
|
||||
imgIn->format.height[1] * imgIn->format.width[1] * sizeof(imgpel));
|
||||
memcpy(imgOut->frm_data[2][0], imgIn->frm_data[2][0],
|
||||
imgIn->format.height[1] * imgIn->format.width[1] * sizeof(imgpel));
|
||||
}
|
||||
}
|
||||
|
||||
// to be modified
|
||||
static inline void FilterImage(ImageData *imgOut, ImageData *imgIn)
|
||||
{
|
||||
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0], imgIn->format.height[0] * imgIn->format.width[0] * sizeof (imgpel));
|
||||
static inline void FilterImage(ImageData *imgOut, ImageData *imgIn) {
|
||||
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0],
|
||||
imgIn->format.height[0] * imgIn->format.width[0] * sizeof(imgpel));
|
||||
|
||||
if (imgIn->format.yuv_format != YUV400)
|
||||
{
|
||||
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[1][0], imgIn->format.height[1] * imgIn->format.width[1] * sizeof (imgpel));
|
||||
memcpy(imgOut->frm_data[2][0], imgIn->frm_data[2][0], imgIn->format.height[1] * imgIn->format.width[1] * sizeof (imgpel));
|
||||
if (imgIn->format.yuv_format != YUV400) {
|
||||
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[1][0],
|
||||
imgIn->format.height[1] * imgIn->format.width[1] * sizeof(imgpel));
|
||||
memcpy(imgOut->frm_data[2][0], imgIn->frm_data[2][0],
|
||||
imgIn->format.height[1] * imgIn->format.width[1] * sizeof(imgpel));
|
||||
}
|
||||
}
|
||||
|
||||
// Line interleaving for 3:2 pulldown
|
||||
static inline void BlendImageLines(ImageData *imgIn0, ImageData *imgIn1)
|
||||
{
|
||||
static inline void BlendImageLines(ImageData *imgIn0, ImageData *imgIn1) {
|
||||
int j;
|
||||
for (j = 1; j < imgIn1->format.height[0]; j += 2)
|
||||
memcpy(imgIn0->frm_data[0][j], imgIn1->frm_data[0][j], imgIn1->format.width[0] * sizeof (imgpel));
|
||||
memcpy(imgIn0->frm_data[0][j], imgIn1->frm_data[0][j],
|
||||
imgIn1->format.width[0] * sizeof(imgpel));
|
||||
|
||||
if (imgIn1->format.yuv_format != YUV400)
|
||||
{
|
||||
for (j = 1; j < imgIn1->format.height[1]; j += 2)
|
||||
{
|
||||
memcpy(imgIn0->frm_data[1][j], imgIn1->frm_data[1][j], imgIn1->format.width[1] * sizeof (imgpel));
|
||||
if (imgIn1->format.yuv_format != YUV400) {
|
||||
for (j = 1; j < imgIn1->format.height[1]; j += 2) {
|
||||
memcpy(imgIn0->frm_data[1][j], imgIn1->frm_data[1][j],
|
||||
imgIn1->format.width[1] * sizeof(imgpel));
|
||||
}
|
||||
for (j = 1; j < imgIn1->format.height[2]; j += 2)
|
||||
{
|
||||
memcpy(imgIn0->frm_data[2][j], imgIn1->frm_data[2][j], imgIn1->format.width[2] * sizeof (imgpel));
|
||||
for (j = 1; j < imgIn1->format.height[2]; j += 2) {
|
||||
memcpy(imgIn0->frm_data[2][j], imgIn1->frm_data[2][j],
|
||||
imgIn1->format.width[2] * sizeof(imgpel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// to be modified
|
||||
static inline void FilterImageSep(ImageData *imgOut, ImageData *imgIn)
|
||||
{
|
||||
static inline void FilterImageSep(ImageData *imgOut, ImageData *imgIn) {
|
||||
int i, j;
|
||||
static const int SepFilter[6] = {1, -5, 20, 20, -5, 1};
|
||||
int max_width = imgOut->format.width[0] - 1;
|
||||
int max_width = imgOut->format.width[0] - 1;
|
||||
int max_height = imgOut->format.height[0] - 1;
|
||||
|
||||
int **temp_data = new_mem2Dint(imgIn->format.height[0], imgIn->format.width[0]); // temp memory for filtering. Could be allocated once to speed up code
|
||||
int **temp_data = new_mem2Dint(
|
||||
imgIn->format.height[0],
|
||||
imgIn->format.width[0]); // temp memory for filtering. Could be allocated
|
||||
// once to speed up code
|
||||
|
||||
// implementation was not optimized. only just implemented as proof of concept
|
||||
// horizontal filtering
|
||||
for (j = 0; j < imgOut->format.height[0]; j++)
|
||||
{
|
||||
for (i = 0; i < imgOut->format.width[0]; i++)
|
||||
{
|
||||
temp_data[j][i] =
|
||||
SepFilter[0] * imgIn->frm_data[0][j][iClip3(0, max_width, i - 2)] +
|
||||
SepFilter[1] * imgIn->frm_data[0][j][iClip3(0, max_width, i - 1)] +
|
||||
SepFilter[2] * imgIn->frm_data[0][j][iClip3(0, max_width, i )] +
|
||||
SepFilter[3] * imgIn->frm_data[0][j][iClip3(0, max_width, i + 1)] +
|
||||
SepFilter[4] * imgIn->frm_data[0][j][iClip3(0, max_width, i + 2)] +
|
||||
SepFilter[5] * imgIn->frm_data[0][j][iClip3(0, max_width, i + 3)];
|
||||
for (j = 0; j < imgOut->format.height[0]; j++) {
|
||||
for (i = 0; i < imgOut->format.width[0]; i++) {
|
||||
temp_data[j][i] =
|
||||
SepFilter[0] * imgIn->frm_data[0][j][iClip3(0, max_width, i - 2)] +
|
||||
SepFilter[1] * imgIn->frm_data[0][j][iClip3(0, max_width, i - 1)] +
|
||||
SepFilter[2] * imgIn->frm_data[0][j][iClip3(0, max_width, i)] +
|
||||
SepFilter[3] * imgIn->frm_data[0][j][iClip3(0, max_width, i + 1)] +
|
||||
SepFilter[4] * imgIn->frm_data[0][j][iClip3(0, max_width, i + 2)] +
|
||||
SepFilter[5] * imgIn->frm_data[0][j][iClip3(0, max_width, i + 3)];
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < imgOut->format.height[0]; j++)
|
||||
{
|
||||
for (i = 0; i < imgOut->format.width[0]; i++)
|
||||
{
|
||||
imgOut->frm_data[0][j][i] = (imgpel) iClip3(0, imgOut->format.max_value[0], rshift_rnd_sign(
|
||||
SepFilter[0] * temp_data[iClip3(0, max_height, j - 2)][i] +
|
||||
SepFilter[1] * temp_data[iClip3(0, max_height, j - 1)][i] +
|
||||
SepFilter[2] * temp_data[iClip3(0, max_height, j )][i] +
|
||||
SepFilter[3] * temp_data[iClip3(0, max_height, j + 1)][i] +
|
||||
SepFilter[4] * temp_data[iClip3(0, max_height, j + 2)][i] +
|
||||
SepFilter[5] * temp_data[iClip3(0, max_height, j + 3)][i], 10));
|
||||
for (j = 0; j < imgOut->format.height[0]; j++) {
|
||||
for (i = 0; i < imgOut->format.width[0]; i++) {
|
||||
imgOut->frm_data[0][j][i] = (imgpel)iClip3(
|
||||
0, imgOut->format.max_value[0],
|
||||
rshift_rnd_sign(
|
||||
SepFilter[0] * temp_data[iClip3(0, max_height, j - 2)][i] +
|
||||
SepFilter[1] * temp_data[iClip3(0, max_height, j - 1)][i] +
|
||||
SepFilter[2] * temp_data[iClip3(0, max_height, j)][i] +
|
||||
SepFilter[3] * temp_data[iClip3(0, max_height, j + 1)][i] +
|
||||
SepFilter[4] * temp_data[iClip3(0, max_height, j + 2)][i] +
|
||||
SepFilter[5] * temp_data[iClip3(0, max_height, j + 3)][i],
|
||||
10));
|
||||
}
|
||||
}
|
||||
|
||||
if (imgOut->format.yuv_format != YUV400)
|
||||
{
|
||||
if (imgOut->format.yuv_format != YUV400) {
|
||||
int k;
|
||||
max_width = imgOut->format.width[1] - 1;
|
||||
max_width = imgOut->format.width[1] - 1;
|
||||
max_height = imgOut->format.height[1] - 1;
|
||||
|
||||
for (k = 1; k <=2; k++)
|
||||
{
|
||||
for (k = 1; k <= 2; k++) {
|
||||
// horizontal filtering
|
||||
for (j = 0; j < imgOut->format.height[1]; j++)
|
||||
{
|
||||
for (i = 0; i < imgOut->format.width[1]; i++)
|
||||
{
|
||||
temp_data[j][i] =
|
||||
SepFilter[0] * imgIn->frm_data[k][j][iClip3(0, max_width, i - 2)] +
|
||||
SepFilter[1] * imgIn->frm_data[k][j][iClip3(0, max_width, i - 1)] +
|
||||
SepFilter[2] * imgIn->frm_data[k][j][iClip3(0, max_width, i )] +
|
||||
SepFilter[3] * imgIn->frm_data[k][j][iClip3(0, max_width, i + 1)] +
|
||||
SepFilter[4] * imgIn->frm_data[k][j][iClip3(0, max_width, i + 2)] +
|
||||
SepFilter[5] * imgIn->frm_data[k][j][iClip3(0, max_width, i + 3)];
|
||||
for (j = 0; j < imgOut->format.height[1]; j++) {
|
||||
for (i = 0; i < imgOut->format.width[1]; i++) {
|
||||
temp_data[j][i] =
|
||||
SepFilter[0] *
|
||||
imgIn->frm_data[k][j][iClip3(0, max_width, i - 2)] +
|
||||
SepFilter[1] *
|
||||
imgIn->frm_data[k][j][iClip3(0, max_width, i - 1)] +
|
||||
SepFilter[2] * imgIn->frm_data[k][j][iClip3(0, max_width, i)] +
|
||||
SepFilter[3] *
|
||||
imgIn->frm_data[k][j][iClip3(0, max_width, i + 1)] +
|
||||
SepFilter[4] *
|
||||
imgIn->frm_data[k][j][iClip3(0, max_width, i + 2)] +
|
||||
SepFilter[5] * imgIn->frm_data[k][j][iClip3(0, max_width, i + 3)];
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < imgOut->format.height[1]; j++)
|
||||
{
|
||||
for (i = 0; i < imgOut->format.width[1]; i++)
|
||||
{
|
||||
imgOut->frm_data[k][j][i] = (imgpel) iClip3(0, imgOut->format.max_value[k], rshift_rnd_sign(
|
||||
SepFilter[0] * temp_data[iClip3(0, max_height, j - 2)][i] +
|
||||
SepFilter[1] * temp_data[iClip3(0, max_height, j - 1)][i] +
|
||||
SepFilter[2] * temp_data[iClip3(0, max_height, j )][i] +
|
||||
SepFilter[3] * temp_data[iClip3(0, max_height, j + 1)][i] +
|
||||
SepFilter[4] * temp_data[iClip3(0, max_height, j + 2)][i] +
|
||||
SepFilter[5] * temp_data[iClip3(0, max_height, j + 3)][i], 10));
|
||||
for (j = 0; j < imgOut->format.height[1]; j++) {
|
||||
for (i = 0; i < imgOut->format.width[1]; i++) {
|
||||
imgOut->frm_data[k][j][i] = (imgpel)iClip3(
|
||||
0, imgOut->format.max_value[k],
|
||||
rshift_rnd_sign(
|
||||
SepFilter[0] * temp_data[iClip3(0, max_height, j - 2)][i] +
|
||||
SepFilter[1] *
|
||||
temp_data[iClip3(0, max_height, j - 1)][i] +
|
||||
SepFilter[2] * temp_data[iClip3(0, max_height, j)][i] +
|
||||
SepFilter[3] *
|
||||
temp_data[iClip3(0, max_height, j + 1)][i] +
|
||||
SepFilter[4] *
|
||||
temp_data[iClip3(0, max_height, j + 2)][i] +
|
||||
SepFilter[5] * temp_data[iClip3(0, max_height, j + 3)][i],
|
||||
10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,70 +179,66 @@ static inline void FilterImageSep(ImageData *imgOut, ImageData *imgIn)
|
|||
free_mem2Dint(temp_data);
|
||||
}
|
||||
|
||||
|
||||
// to be modified
|
||||
static inline void MuxImages(ImageData *imgOut, ImageData *imgIn0, ImageData *imgIn1, ImageData *Map)
|
||||
{
|
||||
static inline void MuxImages(ImageData *imgOut, ImageData *imgIn0,
|
||||
ImageData *imgIn1, ImageData *Map) {
|
||||
int i, j;
|
||||
for (j = 0; j < imgOut->format.height[0]; j++)
|
||||
{
|
||||
for (i = 0; i < imgOut->format.width[0]; i++)
|
||||
{
|
||||
imgOut->frm_data[0][j][i] = (imgpel) rshift_rnd_sf(imgIn0->frm_data[0][j][i] * (Map->format.max_value[0] - Map->frm_data[0][j][i]) + imgIn1->frm_data[0][j][i] * Map->frm_data[0][j][i], Map->format.bit_depth[0]);
|
||||
for (j = 0; j < imgOut->format.height[0]; j++) {
|
||||
for (i = 0; i < imgOut->format.width[0]; i++) {
|
||||
imgOut->frm_data[0][j][i] = (imgpel)rshift_rnd_sf(
|
||||
imgIn0->frm_data[0][j][i] *
|
||||
(Map->format.max_value[0] - Map->frm_data[0][j][i]) +
|
||||
imgIn1->frm_data[0][j][i] * Map->frm_data[0][j][i],
|
||||
Map->format.bit_depth[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (imgOut->format.yuv_format != YUV400)
|
||||
{
|
||||
|
||||
if (imgOut->format.yuv_format != YUV400) {
|
||||
int k;
|
||||
for (k = 1; k <=2; k++)
|
||||
{
|
||||
for (j = 0; j < imgOut->format.height[1]; j++)
|
||||
{
|
||||
for (i = 0; i < imgOut->format.width[1]; i++)
|
||||
{
|
||||
imgOut->frm_data[k][j][i] = (imgpel) rshift_rnd_sf(imgIn0->frm_data[k][j][i] * (Map->format.max_value[k] - Map->frm_data[k][j][i]) + imgIn1->frm_data[k][j][i] * Map->frm_data[k][j][i], Map->format.bit_depth[k]);
|
||||
for (k = 1; k <= 2; k++) {
|
||||
for (j = 0; j < imgOut->format.height[1]; j++) {
|
||||
for (i = 0; i < imgOut->format.width[1]; i++) {
|
||||
imgOut->frm_data[k][j][i] = (imgpel)rshift_rnd_sf(
|
||||
imgIn0->frm_data[k][j][i] *
|
||||
(Map->format.max_value[k] - Map->frm_data[k][j][i]) +
|
||||
imgIn1->frm_data[k][j][i] * Map->frm_data[k][j][i],
|
||||
Map->format.bit_depth[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void YV12toYUV(ImageData *imgOut, ImageData *imgIn)
|
||||
{
|
||||
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0], imgIn->format.height[0] * imgIn->format.width[0] * sizeof (imgpel));
|
||||
static inline void YV12toYUV(ImageData *imgOut, ImageData *imgIn) {
|
||||
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0],
|
||||
imgIn->format.height[0] * imgIn->format.width[0] * sizeof(imgpel));
|
||||
|
||||
if (imgIn->format.yuv_format != YUV400)
|
||||
{
|
||||
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[2][0], imgIn->format.height[1] * imgIn->format.width[1] * sizeof (imgpel));
|
||||
memcpy(imgOut->frm_data[2][0], imgIn->frm_data[1][0], imgIn->format.height[1] * imgIn->format.width[1] * sizeof (imgpel));
|
||||
if (imgIn->format.yuv_format != YUV400) {
|
||||
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[2][0],
|
||||
imgIn->format.height[1] * imgIn->format.width[1] * sizeof(imgpel));
|
||||
memcpy(imgOut->frm_data[2][0], imgIn->frm_data[1][0],
|
||||
imgIn->format.height[1] * imgIn->format.width[1] * sizeof(imgpel));
|
||||
}
|
||||
}
|
||||
|
||||
int init_process_image( VideoParameters *p_Vid, InputParameters *p_Inp)
|
||||
{
|
||||
int init_process_image(VideoParameters *p_Vid, InputParameters *p_Inp) {
|
||||
int memory_size = 0;
|
||||
switch( p_Inp->ProcessInput )
|
||||
{
|
||||
switch (p_Inp->ProcessInput) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return memory_size;
|
||||
}
|
||||
|
||||
void clear_process_image( VideoParameters *p_Vid, InputParameters *p_Inp)
|
||||
{
|
||||
switch( p_Inp->ProcessInput )
|
||||
{
|
||||
void clear_process_image(VideoParameters *p_Vid, InputParameters *p_Inp) {
|
||||
switch (p_Inp->ProcessInput) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void process_image( VideoParameters *p_Vid, InputParameters *p_Inp )
|
||||
{
|
||||
switch( p_Inp->ProcessInput )
|
||||
{
|
||||
void process_image(VideoParameters *p_Vid, InputParameters *p_Inp) {
|
||||
switch (p_Inp->ProcessInput) {
|
||||
default:
|
||||
case 0:
|
||||
CPImage(&p_Vid->imgData, &p_Vid->imgData0);
|
||||
|
@ -248,33 +247,31 @@ void process_image( VideoParameters *p_Vid, InputParameters *p_Inp )
|
|||
break;
|
||||
case 1:
|
||||
FilterImage(&p_Vid->imgData, &p_Vid->imgData0);
|
||||
if (p_Inp->enable_32_pulldown)
|
||||
{
|
||||
if (p_Inp->enable_32_pulldown) {
|
||||
FilterImage(&p_Vid->imgData32, &p_Vid->imgData4);
|
||||
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
YV12toYUV(&p_Vid->imgData, &p_Vid->imgData0);
|
||||
if (p_Inp->enable_32_pulldown)
|
||||
{
|
||||
if (p_Inp->enable_32_pulldown) {
|
||||
YV12toYUV(&p_Vid->imgData32, &p_Vid->imgData4);
|
||||
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
MuxImages(&p_Vid->imgData, &p_Vid->imgData0, &p_Vid->imgData1, &p_Vid->imgData2);
|
||||
if (p_Inp->enable_32_pulldown)
|
||||
{
|
||||
MuxImages(&p_Vid->imgData32, &p_Vid->imgData4, &p_Vid->imgData5, &p_Vid->imgData6);
|
||||
MuxImages(&p_Vid->imgData, &p_Vid->imgData0, &p_Vid->imgData1,
|
||||
&p_Vid->imgData2);
|
||||
if (p_Inp->enable_32_pulldown) {
|
||||
MuxImages(&p_Vid->imgData32, &p_Vid->imgData4, &p_Vid->imgData5,
|
||||
&p_Vid->imgData6);
|
||||
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
||||
}
|
||||
|
||||
break;
|
||||
case 4:
|
||||
FilterImageSep(&p_Vid->imgData, &p_Vid->imgData0);
|
||||
if (p_Inp->enable_32_pulldown)
|
||||
{
|
||||
if (p_Inp->enable_32_pulldown) {
|
||||
FilterImageSep(&p_Vid->imgData, &p_Vid->imgData4);
|
||||
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
||||
}
|
||||
|
@ -282,6 +279,3 @@ void process_image( VideoParameters *p_Vid, InputParameters *p_Inp )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
|
||||
#include "nalucommon.h"
|
||||
|
||||
typedef struct annex_b_struct
|
||||
{
|
||||
int BitStreamFile; //!< the bit stream file
|
||||
typedef struct annex_b_struct {
|
||||
int BitStreamFile; //!< the bit stream file
|
||||
byte *iobuffer;
|
||||
byte *iobufferread;
|
||||
int bytesinbuffer;
|
||||
|
@ -25,15 +24,14 @@ typedef struct annex_b_struct
|
|||
|
||||
int IsFirstByteStreamNALU;
|
||||
int nextstartcodebytes;
|
||||
byte *Buf;
|
||||
byte *Buf;
|
||||
} ANNEXB_t;
|
||||
|
||||
extern int GetAnnexbNALU (VideoParameters *p_Vid, NALU_t *nalu);
|
||||
extern void OpenAnnexBFile (VideoParameters *p_Vid, char *fn);
|
||||
extern int GetAnnexbNALU(VideoParameters *p_Vid, NALU_t *nalu);
|
||||
extern void OpenAnnexBFile(VideoParameters *p_Vid, char *fn);
|
||||
extern void CloseAnnexBFile(VideoParameters *p_Vid);
|
||||
extern void malloc_annex_b (VideoParameters *p_Vid);
|
||||
extern void free_annex_b (VideoParameters *p_Vid);
|
||||
extern void init_annex_b (ANNEXB_t *annex_b);
|
||||
extern void ResetAnnexB (ANNEXB_t *annex_b);
|
||||
extern void malloc_annex_b(VideoParameters *p_Vid);
|
||||
extern void free_annex_b(VideoParameters *p_Vid);
|
||||
extern void init_annex_b(ANNEXB_t *annex_b);
|
||||
extern void ResetAnnexB(ANNEXB_t *annex_b);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -20,116 +20,63 @@
|
|||
#ifndef _BIARIDECOD_H_
|
||||
#define _BIARIDECOD_H_
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* D e f i n i t i o n s
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
/* Range table for LPS */
|
||||
static const byte rLPS_table_64x4[64][4]=
|
||||
{
|
||||
{ 128, 176, 208, 240},
|
||||
{ 128, 167, 197, 227},
|
||||
{ 128, 158, 187, 216},
|
||||
{ 123, 150, 178, 205},
|
||||
{ 116, 142, 169, 195},
|
||||
{ 111, 135, 160, 185},
|
||||
{ 105, 128, 152, 175},
|
||||
{ 100, 122, 144, 166},
|
||||
{ 95, 116, 137, 158},
|
||||
{ 90, 110, 130, 150},
|
||||
{ 85, 104, 123, 142},
|
||||
{ 81, 99, 117, 135},
|
||||
{ 77, 94, 111, 128},
|
||||
{ 73, 89, 105, 122},
|
||||
{ 69, 85, 100, 116},
|
||||
{ 66, 80, 95, 110},
|
||||
{ 62, 76, 90, 104},
|
||||
{ 59, 72, 86, 99},
|
||||
{ 56, 69, 81, 94},
|
||||
{ 53, 65, 77, 89},
|
||||
{ 51, 62, 73, 85},
|
||||
{ 48, 59, 69, 80},
|
||||
{ 46, 56, 66, 76},
|
||||
{ 43, 53, 63, 72},
|
||||
{ 41, 50, 59, 69},
|
||||
{ 39, 48, 56, 65},
|
||||
{ 37, 45, 54, 62},
|
||||
{ 35, 43, 51, 59},
|
||||
{ 33, 41, 48, 56},
|
||||
{ 32, 39, 46, 53},
|
||||
{ 30, 37, 43, 50},
|
||||
{ 29, 35, 41, 48},
|
||||
{ 27, 33, 39, 45},
|
||||
{ 26, 31, 37, 43},
|
||||
{ 24, 30, 35, 41},
|
||||
{ 23, 28, 33, 39},
|
||||
{ 22, 27, 32, 37},
|
||||
{ 21, 26, 30, 35},
|
||||
{ 20, 24, 29, 33},
|
||||
{ 19, 23, 27, 31},
|
||||
{ 18, 22, 26, 30},
|
||||
{ 17, 21, 25, 28},
|
||||
{ 16, 20, 23, 27},
|
||||
{ 15, 19, 22, 25},
|
||||
{ 14, 18, 21, 24},
|
||||
{ 14, 17, 20, 23},
|
||||
{ 13, 16, 19, 22},
|
||||
{ 12, 15, 18, 21},
|
||||
{ 12, 14, 17, 20},
|
||||
{ 11, 14, 16, 19},
|
||||
{ 11, 13, 15, 18},
|
||||
{ 10, 12, 15, 17},
|
||||
{ 10, 12, 14, 16},
|
||||
{ 9, 11, 13, 15},
|
||||
{ 9, 11, 12, 14},
|
||||
{ 8, 10, 12, 14},
|
||||
{ 8, 9, 11, 13},
|
||||
{ 7, 9, 11, 12},
|
||||
{ 7, 9, 10, 12},
|
||||
{ 7, 8, 10, 11},
|
||||
{ 6, 8, 9, 11},
|
||||
{ 6, 7, 9, 10},
|
||||
{ 6, 7, 8, 9},
|
||||
{ 2, 2, 2, 2}
|
||||
};
|
||||
static const byte rLPS_table_64x4[64][4] = {
|
||||
{128, 176, 208, 240}, {128, 167, 197, 227}, {128, 158, 187, 216},
|
||||
{123, 150, 178, 205}, {116, 142, 169, 195}, {111, 135, 160, 185},
|
||||
{105, 128, 152, 175}, {100, 122, 144, 166}, {95, 116, 137, 158},
|
||||
{90, 110, 130, 150}, {85, 104, 123, 142}, {81, 99, 117, 135},
|
||||
{77, 94, 111, 128}, {73, 89, 105, 122}, {69, 85, 100, 116},
|
||||
{66, 80, 95, 110}, {62, 76, 90, 104}, {59, 72, 86, 99},
|
||||
{56, 69, 81, 94}, {53, 65, 77, 89}, {51, 62, 73, 85},
|
||||
{48, 59, 69, 80}, {46, 56, 66, 76}, {43, 53, 63, 72},
|
||||
{41, 50, 59, 69}, {39, 48, 56, 65}, {37, 45, 54, 62},
|
||||
{35, 43, 51, 59}, {33, 41, 48, 56}, {32, 39, 46, 53},
|
||||
{30, 37, 43, 50}, {29, 35, 41, 48}, {27, 33, 39, 45},
|
||||
{26, 31, 37, 43}, {24, 30, 35, 41}, {23, 28, 33, 39},
|
||||
{22, 27, 32, 37}, {21, 26, 30, 35}, {20, 24, 29, 33},
|
||||
{19, 23, 27, 31}, {18, 22, 26, 30}, {17, 21, 25, 28},
|
||||
{16, 20, 23, 27}, {15, 19, 22, 25}, {14, 18, 21, 24},
|
||||
{14, 17, 20, 23}, {13, 16, 19, 22}, {12, 15, 18, 21},
|
||||
{12, 14, 17, 20}, {11, 14, 16, 19}, {11, 13, 15, 18},
|
||||
{10, 12, 15, 17}, {10, 12, 14, 16}, {9, 11, 13, 15},
|
||||
{9, 11, 12, 14}, {8, 10, 12, 14}, {8, 9, 11, 13},
|
||||
{7, 9, 11, 12}, {7, 9, 10, 12}, {7, 8, 10, 11},
|
||||
{6, 8, 9, 11}, {6, 7, 9, 10}, {6, 7, 8, 9},
|
||||
{2, 2, 2, 2}};
|
||||
|
||||
static const byte AC_next_state_MPS_64[64] = {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
|
||||
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
|
||||
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 62, 63};
|
||||
|
||||
static const byte AC_next_state_MPS_64[64] =
|
||||
{
|
||||
1,2,3,4,5,6,7,8,9,10,
|
||||
11,12,13,14,15,16,17,18,19,20,
|
||||
21,22,23,24,25,26,27,28,29,30,
|
||||
31,32,33,34,35,36,37,38,39,40,
|
||||
41,42,43,44,45,46,47,48,49,50,
|
||||
51,52,53,54,55,56,57,58,59,60,
|
||||
61,62,62,63
|
||||
};
|
||||
static const byte AC_next_state_LPS_64[64] = {
|
||||
0, 0, 1, 2, 2, 4, 4, 5, 6, 7, 8, 9, 9, 11, 11, 12,
|
||||
13, 13, 15, 15, 16, 16, 18, 18, 19, 19, 21, 21, 22, 22, 23, 24,
|
||||
24, 25, 26, 26, 27, 27, 28, 29, 29, 30, 30, 30, 31, 32, 32, 33,
|
||||
33, 33, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 63};
|
||||
|
||||
static const byte renorm_table_32[32] = {6, 5, 4, 4, 3, 3, 3, 3, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
|
||||
static const byte AC_next_state_LPS_64[64] =
|
||||
{
|
||||
0, 0, 1, 2, 2, 4, 4, 5, 6, 7,
|
||||
8, 9, 9,11,11,12,13,13,15,15,
|
||||
16,16,18,18,19,19,21,21,22,22,
|
||||
23,24,24,25,26,26,27,27,28,29,
|
||||
29,30,30,30,31,32,32,33,33,33,
|
||||
34,34,35,35,35,36,36,36,37,37,
|
||||
37,38,38,63
|
||||
};
|
||||
|
||||
static const byte renorm_table_32[32]={6,5,4,4,3,3,3,3,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
|
||||
|
||||
|
||||
extern void arideco_start_decoding(DecodingEnvironmentPtr eep, unsigned char *code_buffer, int firstbyte, int *code_len);
|
||||
extern int arideco_bits_read(DecodingEnvironmentPtr dep);
|
||||
extern void arideco_start_decoding(DecodingEnvironmentPtr eep,
|
||||
unsigned char *code_buffer, int firstbyte,
|
||||
int *code_len);
|
||||
extern int arideco_bits_read(DecodingEnvironmentPtr dep);
|
||||
extern void arideco_done_decoding(DecodingEnvironmentPtr dep);
|
||||
extern void biari_init_context (int qp, BiContextTypePtr ctx, const signed char* ini);
|
||||
extern unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi_ct );
|
||||
extern void biari_init_context(int qp, BiContextTypePtr ctx,
|
||||
const signed char *ini);
|
||||
extern unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep,
|
||||
BiContextTypePtr bi_ct);
|
||||
extern unsigned int biari_decode_symbol_eq_prob(DecodingEnvironmentPtr dep);
|
||||
extern unsigned int biari_decode_final(DecodingEnvironmentPtr dep);
|
||||
extern unsigned int getbyte(DecodingEnvironmentPtr dep);
|
||||
extern unsigned int getword(DecodingEnvironmentPtr dep);
|
||||
#endif // BIARIDECOD_H_
|
||||
|
||||
#endif // BIARIDECOD_H_
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* block prediction header
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* address and affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
|
@ -19,7 +19,9 @@
|
|||
#define _BLK_PREDICTION_H_
|
||||
#include "mbuffer.h"
|
||||
|
||||
extern void compute_residue (imgpel **curImg, imgpel **mb_pred, int **mb_rres, int mb_x, int opix_x, int width, int height);
|
||||
extern void sample_reconstruct (imgpel **curImg, imgpel **mb_pred, int **mb_rres, int mb_x, int opix_x, int width, int height, int max_imgpel_value, int dq_bits);
|
||||
extern void compute_residue(imgpel **curImg, imgpel **mb_pred, int **mb_rres,
|
||||
int mb_x, int opix_x, int width, int height);
|
||||
extern void sample_reconstruct(imgpel **curImg, imgpel **mb_pred, int **mb_rres,
|
||||
int mb_x, int opix_x, int width, int height,
|
||||
int max_imgpel_value, int dq_bits);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -21,111 +21,101 @@
|
|||
#include "global.h"
|
||||
#include "transform8x8.h"
|
||||
|
||||
static const byte QP_SCALE_CR[52]=
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,
|
||||
12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
|
||||
28,29,29,30,31,32,32,33,34,34,35,35,36,36,37,37,
|
||||
37,38,38,38,39,39,39,39
|
||||
static const byte QP_SCALE_CR[52] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 29, 30, 31, 32, 32, 33,
|
||||
34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 39
|
||||
|
||||
};
|
||||
|
||||
//! look up tables for FRExt_chroma support
|
||||
static const unsigned char subblk_offset_x[3][8][4] =
|
||||
{
|
||||
{
|
||||
{0, 4, 0, 4},
|
||||
{0, 4, 0, 4},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
},
|
||||
{
|
||||
{0, 4, 0, 4},
|
||||
{0, 4, 0, 4},
|
||||
{0, 4, 0, 4},
|
||||
{0, 4, 0, 4},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
},
|
||||
{
|
||||
{0, 4, 0, 4},
|
||||
{8,12, 8,12},
|
||||
{0, 4, 0, 4},
|
||||
{8,12, 8,12},
|
||||
{0, 4, 0, 4},
|
||||
{8,12, 8,12},
|
||||
{0, 4, 0, 4},
|
||||
{8,12, 8,12}
|
||||
}
|
||||
};
|
||||
static const unsigned char subblk_offset_x[3][8][4] = {{
|
||||
{0, 4, 0, 4},
|
||||
{0, 4, 0, 4},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
},
|
||||
{
|
||||
{0, 4, 0, 4},
|
||||
{0, 4, 0, 4},
|
||||
{0, 4, 0, 4},
|
||||
{0, 4, 0, 4},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
},
|
||||
{{0, 4, 0, 4},
|
||||
{8, 12, 8, 12},
|
||||
{0, 4, 0, 4},
|
||||
{8, 12, 8, 12},
|
||||
{0, 4, 0, 4},
|
||||
{8, 12, 8, 12},
|
||||
{0, 4, 0, 4},
|
||||
{8, 12, 8, 12}}};
|
||||
|
||||
static const unsigned char subblk_offset_y[3][8][4] = {{{0, 0, 4, 4},
|
||||
{0, 0, 4, 4},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0}},
|
||||
{{0, 0, 4, 4},
|
||||
{8, 8, 12, 12},
|
||||
{0, 0, 4, 4},
|
||||
{8, 8, 12, 12},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0}},
|
||||
{{0, 0, 4, 4},
|
||||
{0, 0, 4, 4},
|
||||
{8, 8, 12, 12},
|
||||
{8, 8, 12, 12},
|
||||
{0, 0, 4, 4},
|
||||
{0, 0, 4, 4},
|
||||
{8, 8, 12, 12},
|
||||
{8, 8, 12, 12}}};
|
||||
|
||||
static const unsigned char subblk_offset_y[3][8][4] =
|
||||
{
|
||||
{
|
||||
{0, 0, 4, 4},
|
||||
{0, 0, 4, 4},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
},
|
||||
{
|
||||
{0, 0, 4, 4},
|
||||
{8, 8,12,12},
|
||||
{0, 0, 4, 4},
|
||||
{8, 8,12,12},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
},
|
||||
{
|
||||
{0, 0, 4, 4},
|
||||
{0, 0, 4, 4},
|
||||
{8, 8,12,12},
|
||||
{8, 8,12,12},
|
||||
{0, 0, 4, 4},
|
||||
{0, 0, 4, 4},
|
||||
{8, 8,12,12},
|
||||
{8, 8,12,12}
|
||||
}
|
||||
};
|
||||
|
||||
static const byte decode_block_scan[16] = {0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15};
|
||||
static const byte decode_block_scan[16] = {0, 1, 4, 5, 2, 3, 6, 7,
|
||||
8, 9, 12, 13, 10, 11, 14, 15};
|
||||
|
||||
extern void iMBtrans4x4(Macroblock *currMB, ColorPlane pl, int smb);
|
||||
extern void iMBtrans8x8(Macroblock *currMB, ColorPlane pl);
|
||||
|
||||
extern void itrans_sp_cr(Macroblock *currMB, int uv);
|
||||
|
||||
extern void intrapred_chroma (Macroblock *currMB);
|
||||
extern void intrapred_chroma(Macroblock *currMB);
|
||||
extern void intrapred_chroma_mbaff(Macroblock *currMB);
|
||||
|
||||
extern void Inv_Residual_trans_4x4(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||
extern void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,int joff);
|
||||
extern void Inv_Residual_trans_16x16 (Macroblock *currMB, ColorPlane pl);
|
||||
extern void Inv_Residual_trans_4x4(Macroblock *currMB, ColorPlane pl, int ioff,
|
||||
int joff);
|
||||
extern void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,
|
||||
int joff);
|
||||
extern void Inv_Residual_trans_16x16(Macroblock *currMB, ColorPlane pl);
|
||||
extern void Inv_Residual_trans_Chroma(Macroblock *currMB, int uv);
|
||||
|
||||
extern void itrans4x4 (Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||
extern void itrans4x4(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||
extern void itrans4x4_ls(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||
extern void itrans_sp (Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||
extern int intrapred (Macroblock *currMB, ColorPlane pl, int ioff,int joff,int i4,int j4);
|
||||
extern void itrans_2 (Macroblock *currMB, ColorPlane pl);
|
||||
extern void iTransform (Macroblock *currMB, ColorPlane pl, int smb);
|
||||
extern void itrans_sp(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||
extern int intrapred(Macroblock *currMB, ColorPlane pl, int ioff, int joff,
|
||||
int i4, int j4);
|
||||
extern void itrans_2(Macroblock *currMB, ColorPlane pl);
|
||||
extern void iTransform(Macroblock *currMB, ColorPlane pl, int smb);
|
||||
|
||||
extern void copy_image_data (imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2, int width, int height);
|
||||
extern void copy_image_data_16x16 (imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2);
|
||||
extern void copy_image_data_8x8 (imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2);
|
||||
extern void copy_image_data_4x4 (imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2);
|
||||
extern void copy_image_data(imgpel **imgBuf1, imgpel **imgBuf2, int off1,
|
||||
int off2, int width, int height);
|
||||
extern void copy_image_data_16x16(imgpel **imgBuf1, imgpel **imgBuf2, int off1,
|
||||
int off2);
|
||||
extern void copy_image_data_8x8(imgpel **imgBuf1, imgpel **imgBuf2, int off1,
|
||||
int off2);
|
||||
extern void copy_image_data_4x4(imgpel **imgBuf1, imgpel **imgBuf2, int off1,
|
||||
int off2);
|
||||
extern int CheckVertMV(Macroblock *currMB, int vec1_y, int block_size_y);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -21,42 +21,61 @@
|
|||
|
||||
#include "global.h"
|
||||
|
||||
extern MotionInfoContexts* create_contexts_MotionInfo(void);
|
||||
extern TextureInfoContexts* create_contexts_TextureInfo(void);
|
||||
extern MotionInfoContexts *create_contexts_MotionInfo(void);
|
||||
extern TextureInfoContexts *create_contexts_TextureInfo(void);
|
||||
extern void delete_contexts_MotionInfo(MotionInfoContexts *enco_ctx);
|
||||
extern void delete_contexts_TextureInfo(TextureInfoContexts *enco_ctx);
|
||||
|
||||
extern void cabac_new_slice(Slice *currSlice);
|
||||
|
||||
extern void readMB_typeInfo_CABAC_i_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readMB_typeInfo_CABAC_p_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readMB_typeInfo_CABAC_b_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readB8_typeInfo_CABAC_p_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readB8_typeInfo_CABAC_b_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readIntraPredMode_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readRefFrame_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void read_MVD_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void read_CBP_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readRunLevel_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void read_dQuant_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readCIPredMode_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void read_skip_flag_CABAC_p_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void read_skip_flag_CABAC_b_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readFieldModeInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readMB_transform_size_flag_CABAC(Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
||||
extern void readMB_typeInfo_CABAC_i_slice(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void readMB_typeInfo_CABAC_p_slice(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void readMB_typeInfo_CABAC_b_slice(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void readB8_typeInfo_CABAC_p_slice(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void readB8_typeInfo_CABAC_b_slice(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void readIntraPredMode_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void readRefFrame_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void read_MVD_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void read_CBP_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void readRunLevel_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void read_dQuant_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void readCIPredMode_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void read_skip_flag_CABAC_p_slice(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void read_skip_flag_CABAC_b_slice(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void readFieldModeInfo_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
extern void readMB_transform_size_flag_CABAC(Macroblock *currMB,
|
||||
SyntaxElement *se,
|
||||
DecodingEnvironmentPtr dep_dp);
|
||||
|
||||
extern void readIPCM_CABAC(Slice *currSlice, struct datapartition *dP);
|
||||
|
||||
extern int cabac_startcode_follows(Slice *currSlice, int eos_bit);
|
||||
extern int cabac_startcode_follows(Slice *currSlice, int eos_bit);
|
||||
|
||||
extern int readSyntaxElement_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *this_dataPart);
|
||||
extern int readSyntaxElement_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||
DataPartition *this_dataPart);
|
||||
|
||||
extern int check_next_mb_and_get_field_mode_CABAC_p_slice( Slice *currSlice, SyntaxElement *se, DataPartition *act_dp);
|
||||
extern int check_next_mb_and_get_field_mode_CABAC_b_slice( Slice *currSlice, SyntaxElement *se, DataPartition *act_dp);
|
||||
extern int check_next_mb_and_get_field_mode_CABAC_p_slice(
|
||||
Slice *currSlice, SyntaxElement *se, DataPartition *act_dp);
|
||||
extern int check_next_mb_and_get_field_mode_CABAC_b_slice(
|
||||
Slice *currSlice, SyntaxElement *se, DataPartition *act_dp);
|
||||
|
||||
extern void CheckAvailabilityOfNeighborsCABAC(Macroblock *currMB);
|
||||
|
||||
extern void set_read_and_store_CBP(Macroblock **currMB, int chroma_format_idc);
|
||||
|
||||
#endif // _CABAC_H_
|
||||
|
||||
#endif // _CABAC_H_
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
* Common Config parsing functions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
************************************************************************
|
||||
|
@ -17,19 +18,22 @@
|
|||
|
||||
//! Maps parameter name to its address, type etc.
|
||||
typedef struct {
|
||||
char *TokenName; //!< name
|
||||
void *Place; //!< address
|
||||
int Type; //!< type: 0-int, 1-char[], 2-double
|
||||
double Default; //!< default value
|
||||
int param_limits; //!< 0: no limits, 1: both min and max, 2: only min (i.e. no negatives), 3: special case for QPs since min needs bitdepth_qp_scale
|
||||
char *TokenName; //!< name
|
||||
void *Place; //!< address
|
||||
int Type; //!< type: 0-int, 1-char[], 2-double
|
||||
double Default; //!< default value
|
||||
int param_limits; //!< 0: no limits, 1: both min and max, 2: only min (i.e. no
|
||||
//!< negatives), 3: special case for QPs since min needs
|
||||
//!< bitdepth_qp_scale
|
||||
double min_limit;
|
||||
double max_limit;
|
||||
int char_size; //!< Dimension of type char[]
|
||||
int char_size; //!< Dimension of type char[]
|
||||
} Mapping;
|
||||
|
||||
extern char *GetConfigFileContent (char *Filename);
|
||||
extern int InitParams (Mapping *Map);
|
||||
extern int TestParams (Mapping *Map, int bitdepth_qp_scale[3]);
|
||||
extern int DisplayParams (Mapping *Map, char *message);
|
||||
extern void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize);
|
||||
extern char *GetConfigFileContent(char *Filename);
|
||||
extern int InitParams(Mapping *Map);
|
||||
extern int TestParams(Mapping *Map, int bitdepth_qp_scale[3]);
|
||||
extern int DisplayParams(Mapping *Map, char *message);
|
||||
extern void ParseContent(InputParameters *p_Inp, Mapping *Map, char *buf,
|
||||
int bufsize);
|
||||
#endif
|
||||
|
|
|
@ -14,51 +14,86 @@
|
|||
#define DEFAULTCONFIGFILENAME "decoder.cfg"
|
||||
|
||||
#include "config_common.h"
|
||||
//#define PROFILE_IDC 88
|
||||
//#define LEVEL_IDC 21
|
||||
|
||||
// #define PROFILE_IDC 88
|
||||
// #define LEVEL_IDC 21
|
||||
|
||||
InputParameters cfgparams;
|
||||
|
||||
#ifdef INCLUDED_BY_CONFIGFILE_C
|
||||
// Mapping_Map Syntax:
|
||||
// {NAMEinConfigFile, &cfgparams.VariableName, Type, InitialValue, LimitType, MinLimit, MaxLimit, CharSize}
|
||||
// Types : {0:int, 1:text, 2: double}
|
||||
// LimitType: {0:none, 1:both, 2:minimum, 3: QP based}
|
||||
// We could separate this based on types to make it more flexible and allow also defaults for text types.
|
||||
// {NAMEinConfigFile, &cfgparams.VariableName, Type, InitialValue, LimitType,
|
||||
// MinLimit, MaxLimit, CharSize} Types : {0:int, 1:text, 2: double} LimitType:
|
||||
// {0:none, 1:both, 2:minimum, 3: QP based} We could separate this based on
|
||||
// types to make it more flexible and allow also defaults for text types.
|
||||
Mapping Map[] = {
|
||||
{"InputFile", &cfgparams.infile, 1, 0.0, 0, 0.0, 0.0, FILE_NAME_SIZE, },
|
||||
{"OutputFile", &cfgparams.outfile, 1, 0.0, 0, 0.0, 0.0, FILE_NAME_SIZE, },
|
||||
{"RefFile", &cfgparams.reffile, 1, 0.0, 0, 0.0, 0.0, FILE_NAME_SIZE, },
|
||||
{"WriteUV", &cfgparams.write_uv, 0, 0.0, 1, 0.0, 1.0, 0 },
|
||||
{"FileFormat", &cfgparams.FileFormat, 0, 0.0, 1, 0.0, 1.0, 0 },
|
||||
{"RefOffset", &cfgparams.ref_offset, 0, 0.0, 1, 0.0, 256.0, 0 },
|
||||
{"POCScale", &cfgparams.poc_scale, 0, 2.0, 1, 1.0, 10.0, 0 },
|
||||
{
|
||||
"InputFile",
|
||||
&cfgparams.infile,
|
||||
1,
|
||||
0.0,
|
||||
0,
|
||||
0.0,
|
||||
0.0,
|
||||
FILE_NAME_SIZE,
|
||||
},
|
||||
{
|
||||
"OutputFile",
|
||||
&cfgparams.outfile,
|
||||
1,
|
||||
0.0,
|
||||
0,
|
||||
0.0,
|
||||
0.0,
|
||||
FILE_NAME_SIZE,
|
||||
},
|
||||
{
|
||||
"RefFile",
|
||||
&cfgparams.reffile,
|
||||
1,
|
||||
0.0,
|
||||
0,
|
||||
0.0,
|
||||
0.0,
|
||||
FILE_NAME_SIZE,
|
||||
},
|
||||
{"WriteUV", &cfgparams.write_uv, 0, 0.0, 1, 0.0, 1.0, 0},
|
||||
{"FileFormat", &cfgparams.FileFormat, 0, 0.0, 1, 0.0, 1.0, 0},
|
||||
{"RefOffset", &cfgparams.ref_offset, 0, 0.0, 1, 0.0, 256.0, 0},
|
||||
{"POCScale", &cfgparams.poc_scale, 0, 2.0, 1, 1.0, 10.0, 0},
|
||||
#ifdef _LEAKYBUCKET_
|
||||
{"R_decoder", &cfgparams.R_decoder, 0, 0.0, 2, 0.0, 0.0, 0 },
|
||||
{"B_decoder", &cfgparams.B_decoder, 0, 0.0, 2, 0.0, 0.0, 0 },
|
||||
{"F_decoder", &cfgparams.F_decoder, 0, 0.0, 2, 0.0, 0.0, 0 },
|
||||
{"LeakyBucketParamFile", &cfgparams.LeakyBucketParamFile, 1, 0.0, 0, 0.0, 0.0, FILE_NAME_SIZE, },
|
||||
{"R_decoder", &cfgparams.R_decoder, 0, 0.0, 2, 0.0, 0.0, 0},
|
||||
{"B_decoder", &cfgparams.B_decoder, 0, 0.0, 2, 0.0, 0.0, 0},
|
||||
{"F_decoder", &cfgparams.F_decoder, 0, 0.0, 2, 0.0, 0.0, 0},
|
||||
{
|
||||
"LeakyBucketParamFile",
|
||||
&cfgparams.LeakyBucketParamFile,
|
||||
1,
|
||||
0.0,
|
||||
0,
|
||||
0.0,
|
||||
0.0,
|
||||
FILE_NAME_SIZE,
|
||||
},
|
||||
#endif
|
||||
{"DisplayDecParams", &cfgparams.bDisplayDecParams, 0, 1.0, 1, 0.0, 1.0, 0 },
|
||||
{"ConcealMode", &cfgparams.conceal_mode, 0, 0.0, 1, 0.0, 2.0, 0 },
|
||||
{"RefPOCGap", &cfgparams.ref_poc_gap, 0, 2.0, 1, 0.0, 4.0, 0 },
|
||||
{"POCGap", &cfgparams.poc_gap, 0, 2.0, 1, 0.0, 4.0, 0 },
|
||||
{"Silent", &cfgparams.silent, 0, 0.0, 1, 0.0, 1.0, 0 },
|
||||
{"IntraProfileDeblocking", &cfgparams.intra_profile_deblocking, 0, 1.0, 1, 0.0, 1.0, 0 },
|
||||
{"DecFrmNum", &cfgparams.iDecFrmNum, 0, 0.0, 2, 0.0, 0.0, 0 },
|
||||
{"DisplayDecParams", &cfgparams.bDisplayDecParams, 0, 1.0, 1, 0.0, 1.0, 0},
|
||||
{"ConcealMode", &cfgparams.conceal_mode, 0, 0.0, 1, 0.0, 2.0, 0},
|
||||
{"RefPOCGap", &cfgparams.ref_poc_gap, 0, 2.0, 1, 0.0, 4.0, 0},
|
||||
{"POCGap", &cfgparams.poc_gap, 0, 2.0, 1, 0.0, 4.0, 0},
|
||||
{"Silent", &cfgparams.silent, 0, 0.0, 1, 0.0, 1.0, 0},
|
||||
{"IntraProfileDeblocking", &cfgparams.intra_profile_deblocking, 0, 1.0, 1,
|
||||
0.0, 1.0, 0},
|
||||
{"DecFrmNum", &cfgparams.iDecFrmNum, 0, 0.0, 2, 0.0, 0.0, 0},
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
{"DecodeAllLayers", &cfgparams.DecodeAllLayers, 0, 0.0, 1, 0.0, 1.0, 0 },
|
||||
{"DecodeAllLayers", &cfgparams.DecodeAllLayers, 0, 0.0, 1, 0.0, 1.0, 0},
|
||||
#endif
|
||||
{NULL, NULL, -1, 0.0, 0, 0.0, 0.0, 0 },
|
||||
{NULL, NULL, -1, 0.0, 0, 0.0, 0.0, 0},
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDED_BY_CONFIGFILE_C
|
||||
extern Mapping Map[];
|
||||
#endif
|
||||
extern void JMDecHelpExit ();
|
||||
extern void JMDecHelpExit();
|
||||
extern void ParseCommand(InputParameters *p_Inp, int ac, char *av[]);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -7,17 +7,16 @@
|
|||
* CABAC context initializations
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Detlev Marpe <marpe@hhi.de>
|
||||
* - Heiko Schwarz <hschwarz@hhi.de>
|
||||
**************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _CONTEXT_INI_
|
||||
#define _CONTEXT_INI_
|
||||
|
||||
extern void init_contexts (Slice *currslice);
|
||||
extern void init_contexts(Slice *currslice);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
Nokia Inc., USA
|
||||
Nokia Corporation, Finland
|
||||
Siemens AG, Germany
|
||||
Fraunhofer-Institute for Telecommunications Heinrich-Hertz-Institut (HHI), Germany
|
||||
University of Hannover, Institut of Communication Theory and Signal Processing, Germany
|
||||
TICSP, Tampere University of Technology, Finland
|
||||
Munich University of Technology, Institute for Communications Engineering, Germany
|
||||
Fraunhofer-Institute for Telecommunications Heinrich-Hertz-Institut (HHI),
|
||||
Germany University of Hannover, Institut of Communication Theory and Signal
|
||||
Processing, Germany TICSP, Tampere University of Technology, Finland Munich
|
||||
University of Technology, Institute for Communications Engineering, Germany
|
||||
Videolocus, Canada
|
||||
Motorola Inc., USA
|
||||
Microsoft Corp., USA
|
||||
|
@ -30,12 +30,9 @@
|
|||
\par Full Contact Information
|
||||
\verbatim
|
||||
|
||||
Lowell Winger <lwinger@videolocus.com><lwinger@uwaterloo.ca>
|
||||
Guy Côté <gcote@videolocus.com>
|
||||
Michael Gallant <mgallant@videolocus.com>
|
||||
VideoLocus Inc.
|
||||
97 Randall Dr.
|
||||
Waterloo, ON, Canada N2V1C5
|
||||
Lowell Winger <lwinger@videolocus.com><lwinger@uwaterloo.ca> Guy Côté
|
||||
<gcote@videolocus.com> Michael Gallant <mgallant@videolocus.com> VideoLocus
|
||||
Inc. 97 Randall Dr. Waterloo, ON, Canada N2V1C5
|
||||
|
||||
Inge Lille-Langøy <inge.lille-langoy@telenor.com>
|
||||
Telenor Satellite Services
|
||||
|
@ -152,10 +149,8 @@
|
|||
San Diego, CA 92121 USA
|
||||
|
||||
Feng Wu <fengwu@microsoft.com>
|
||||
Xiaoyan Sun <sunxiaoyan@msrchina.research.microsoft.com>
|
||||
Microsoft Research Asia
|
||||
3/F, Beijing Sigma Center
|
||||
No.49, Zhichun Road, Hai Dian District,
|
||||
Xiaoyan Sun <sunxiaoyan@msrchina.research.microsoft.com> Microsoft
|
||||
Research Asia 3/F, Beijing Sigma Center No.49, Zhichun Road, Hai Dian District,
|
||||
Beijing China 100080
|
||||
|
||||
Yoshihiro Kikuchi <yoshihiro.kikuchi@toshiba.co.jp>
|
||||
|
@ -211,22 +206,20 @@
|
|||
2 Independence Way
|
||||
Princeton, NJ 08540
|
||||
|
||||
Shun-ichi Sekiguchi <Sekiguchi.Shunichi@eb.MitsubishiElectric.co.jp>
|
||||
Information Technology R&D Center,
|
||||
Shun-ichi Sekiguchi <Sekiguchi.Shunichi@eb.MitsubishiElectric.co.jp>
|
||||
Information Technology R&D Center,
|
||||
Mitsubishi Electric Corporation
|
||||
5-1-1, Ofuna, Kamakura, Japan
|
||||
|
||||
Yung-Lyul Lee <yllee@sejong.ac.kr>
|
||||
Ki-Hun Han <khhan@dms.sejong.ac.kr>
|
||||
Department of Computer Engineering,
|
||||
Department of Computer Engineering,
|
||||
Sejong University
|
||||
98 Kunja-Dong, Kwangjin-Gu, Seoul 143-747, Korea
|
||||
|
||||
Jianhua Wu <jianhua.wu@sg.panasonic.com>
|
||||
Panasonic Singapore Laboratories Pte Ltd
|
||||
Blk 1022 Tai Seng Ave #06-3530 Tai Seng Ind Est
|
||||
Singapore 534415
|
||||
Jianhua Wu <jianhua.wu@sg.panasonic.com> Panasonic
|
||||
Singapore Laboratories Pte Ltd Blk 1022 Tai Seng Ave #06-3530 Tai Seng Ind Est
|
||||
Singapore 534415
|
||||
|
||||
\endverbatim
|
||||
*/
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,259 +7,272 @@
|
|||
* Header file containing some useful global definitions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Detlev Marpe
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
*
|
||||
* \date
|
||||
* 21. March 2001
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DEFINES_H_
|
||||
#define _DEFINES_H_
|
||||
#ifdef TRACE
|
||||
#undef TRACE
|
||||
#endif
|
||||
#if defined _DEBUG
|
||||
# define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
|
||||
#define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
|
||||
#else
|
||||
# define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
|
||||
#define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
|
||||
#endif
|
||||
|
||||
#define JM "17 (FRExt)"
|
||||
#define VERSION "17.1"
|
||||
#define EXT_VERSION "(FRExt)"
|
||||
#define JM "17 (FRExt)"
|
||||
#define VERSION "17.1"
|
||||
#define EXT_VERSION "(FRExt)"
|
||||
|
||||
#define DUMP_DPB 0 //!< Dump DPB info for debug purposes
|
||||
#define PRINTREFLIST 0 //!< Print ref list info for debug purposes
|
||||
#define PAIR_FIELDS_IN_OUTPUT 0 //!< Pair field pictures for output purposes
|
||||
#define IMGTYPE 1 //!< Define imgpel size type. 0 implies byte (cannot handle >8 bit depths) and 1 implies unsigned short
|
||||
#define ENABLE_FIELD_CTX 1 //!< Enables Field mode related context types for CABAC
|
||||
#define ENABLE_HIGH444_CTX 1 //!< Enables High 444 profile context types for CABAC.
|
||||
#define ZEROSNR 0 //!< PSNR computation method
|
||||
#define ENABLE_OUTPUT_TONEMAPPING 1 //!< enable tone map the output if tone mapping SEI present
|
||||
#define JCOST_CALC_SCALEUP 1 //!< 1: J = (D<<LAMBDA_ACCURACY_BITS)+Lambda*R; 0: J = D + ((Lambda*R+Rounding)>>LAMBDA_ACCURACY_BITS)
|
||||
#define DISABLE_ERC 1 //!< Disable any error concealment processes
|
||||
#define JM_PARALLEL_DEBLOCK 0 //!< Enables Parallel Deblocking
|
||||
#define DUMP_DPB 0 //!< Dump DPB info for debug purposes
|
||||
#define PRINTREFLIST 0 //!< Print ref list info for debug purposes
|
||||
#define PAIR_FIELDS_IN_OUTPUT 0 //!< Pair field pictures for output purposes
|
||||
#define IMGTYPE \
|
||||
1 //!< Define imgpel size type. 0 implies byte (cannot handle >8 bit depths)
|
||||
//!< and 1 implies unsigned short
|
||||
#define ENABLE_FIELD_CTX \
|
||||
1 //!< Enables Field mode related context types for CABAC
|
||||
#define ENABLE_HIGH444_CTX \
|
||||
1 //!< Enables High 444 profile context types for CABAC.
|
||||
#define ZEROSNR 0 //!< PSNR computation method
|
||||
#define ENABLE_OUTPUT_TONEMAPPING \
|
||||
1 //!< enable tone map the output if tone mapping SEI present
|
||||
#define JCOST_CALC_SCALEUP \
|
||||
1 //!< 1: J = (D<<LAMBDA_ACCURACY_BITS)+Lambda*R; 0: J = D +
|
||||
//!< ((Lambda*R+Rounding)>>LAMBDA_ACCURACY_BITS)
|
||||
#define DISABLE_ERC 1 //!< Disable any error concealment processes
|
||||
#define JM_PARALLEL_DEBLOCK 0 //!< Enables Parallel Deblocking
|
||||
|
||||
#define MVC_EXTENSION_ENABLE 1 //!< enable support for the Multiview High Profile
|
||||
#define MVC_EXTENSION_ENABLE \
|
||||
1 //!< enable support for the Multiview High Profile
|
||||
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
#define MVC_INIT_VIEW_ID -1
|
||||
#define MAX_VIEW_NUM 1024
|
||||
#define BASE_VIEW_IDX 0
|
||||
#define FREEPTR(ptr) { if(ptr) {free(ptr); (ptr)=NULL;} }
|
||||
#define MVC_INIT_VIEW_ID -1
|
||||
#define MAX_VIEW_NUM 1024
|
||||
#define BASE_VIEW_IDX 0
|
||||
#define FREEPTR(ptr) \
|
||||
{ \
|
||||
if (ptr) { \
|
||||
free(ptr); \
|
||||
(ptr) = NULL; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
#define SSE_MEMORY_ALIGNMENT 16
|
||||
#define SSE_MEMORY_ALIGNMENT 16
|
||||
|
||||
//#define MAX_NUM_SLICES 150
|
||||
#define MAX_NUM_SLICES 50
|
||||
#define MAX_REFERENCE_PICTURES 32 //!< H.264 allows 32 fields
|
||||
#define MAX_CODED_FRAME_SIZE 8000000 //!< bytes for one frame
|
||||
#define MAX_NUM_DECSLICES 16
|
||||
#define MAX_DEC_THREADS 16 //16 core deocoding;
|
||||
#define MCBUF_LUMA_PAD_X 32
|
||||
#define MCBUF_LUMA_PAD_Y 12
|
||||
#define MCBUF_CHROMA_PAD_X 16
|
||||
#define MCBUF_CHROMA_PAD_Y 8
|
||||
// #define MAX_NUM_SLICES 150
|
||||
#define MAX_NUM_SLICES 50
|
||||
#define MAX_REFERENCE_PICTURES 32 //!< H.264 allows 32 fields
|
||||
#define MAX_CODED_FRAME_SIZE 8000000 //!< bytes for one frame
|
||||
#define MAX_NUM_DECSLICES 16
|
||||
#define MAX_DEC_THREADS 16 // 16 core deocoding;
|
||||
#define MCBUF_LUMA_PAD_X 32
|
||||
#define MCBUF_LUMA_PAD_Y 12
|
||||
#define MCBUF_CHROMA_PAD_X 16
|
||||
#define MCBUF_CHROMA_PAD_Y 8
|
||||
|
||||
//AVC Profile IDC definitions
|
||||
// AVC Profile IDC definitions
|
||||
typedef enum {
|
||||
FREXT_CAVLC444 = 44, //!< YUV 4:4:4/14 "CAVLC 4:4:4"
|
||||
BASELINE = 66, //!< YUV 4:2:0/8 "Baseline"
|
||||
MAIN = 77, //!< YUV 4:2:0/8 "Main"
|
||||
EXTENDED = 88, //!< YUV 4:2:0/8 "Extended"
|
||||
FREXT_HP = 100, //!< YUV 4:2:0/8 "High"
|
||||
FREXT_Hi10P = 110, //!< YUV 4:2:0/10 "High 10"
|
||||
FREXT_Hi422 = 122, //!< YUV 4:2:2/10 "High 4:2:2"
|
||||
FREXT_Hi444 = 244, //!< YUV 4:4:4/14 "High 4:4:4"
|
||||
MVC_HIGH = 118, //!< YUV 4:2:0/8 "Multiview High"
|
||||
STEREO_HIGH = 128 //!< YUV 4:2:0/8 "Stereo High"
|
||||
FREXT_CAVLC444 = 44, //!< YUV 4:4:4/14 "CAVLC 4:4:4"
|
||||
BASELINE = 66, //!< YUV 4:2:0/8 "Baseline"
|
||||
MAIN = 77, //!< YUV 4:2:0/8 "Main"
|
||||
EXTENDED = 88, //!< YUV 4:2:0/8 "Extended"
|
||||
FREXT_HP = 100, //!< YUV 4:2:0/8 "High"
|
||||
FREXT_Hi10P = 110, //!< YUV 4:2:0/10 "High 10"
|
||||
FREXT_Hi422 = 122, //!< YUV 4:2:2/10 "High 4:2:2"
|
||||
FREXT_Hi444 = 244, //!< YUV 4:4:4/14 "High 4:4:4"
|
||||
MVC_HIGH = 118, //!< YUV 4:2:0/8 "Multiview High"
|
||||
STEREO_HIGH = 128 //!< YUV 4:2:0/8 "Stereo High"
|
||||
} ProfileIDC;
|
||||
|
||||
#define FILE_NAME_SIZE 255
|
||||
#define FILE_NAME_SIZE 255
|
||||
#define INPUT_TEXT_SIZE 1024
|
||||
|
||||
#if (ENABLE_HIGH444_CTX == 1)
|
||||
# define NUM_BLOCK_TYPES 22
|
||||
#define NUM_BLOCK_TYPES 22
|
||||
#else
|
||||
# define NUM_BLOCK_TYPES 10
|
||||
#define NUM_BLOCK_TYPES 10
|
||||
#endif
|
||||
|
||||
// #define _LEAKYBUCKET_
|
||||
|
||||
//#define _LEAKYBUCKET_
|
||||
|
||||
#define BLOCK_SHIFT 2
|
||||
#define BLOCK_SIZE 4
|
||||
#define BLOCK_SIZE_8x8 8
|
||||
#define SMB_BLOCK_SIZE 8
|
||||
#define BLOCK_PIXELS 16
|
||||
#define MB_BLOCK_SIZE 16
|
||||
#define MB_PIXELS 256 // MB_BLOCK_SIZE * MB_BLOCK_SIZE
|
||||
#define MB_PIXELS_SHIFT 8 // log2(MB_BLOCK_SIZE * MB_BLOCK_SIZE)
|
||||
#define MB_BLOCK_SHIFT 4
|
||||
#define BLOCK_MULTIPLE 4 // (MB_BLOCK_SIZE/BLOCK_SIZE)
|
||||
#define MB_BLOCK_PARTITIONS 16 // (BLOCK_MULTIPLE * BLOCK_MULTIPLE)
|
||||
#define BLOCK_CONTEXT 64 // (4 * MB_BLOCK_PARTITIONS)
|
||||
#define BLOCK_SHIFT 2
|
||||
#define BLOCK_SIZE 4
|
||||
#define BLOCK_SIZE_8x8 8
|
||||
#define SMB_BLOCK_SIZE 8
|
||||
#define BLOCK_PIXELS 16
|
||||
#define MB_BLOCK_SIZE 16
|
||||
#define MB_PIXELS 256 // MB_BLOCK_SIZE * MB_BLOCK_SIZE
|
||||
#define MB_PIXELS_SHIFT 8 // log2(MB_BLOCK_SIZE * MB_BLOCK_SIZE)
|
||||
#define MB_BLOCK_SHIFT 4
|
||||
#define BLOCK_MULTIPLE 4 // (MB_BLOCK_SIZE/BLOCK_SIZE)
|
||||
#define MB_BLOCK_PARTITIONS 16 // (BLOCK_MULTIPLE * BLOCK_MULTIPLE)
|
||||
#define BLOCK_CONTEXT 64 // (4 * MB_BLOCK_PARTITIONS)
|
||||
|
||||
// These variables relate to the subpel accuracy supported by the software (1/4)
|
||||
#define BLOCK_SIZE_SP 16 // BLOCK_SIZE << 2
|
||||
#define BLOCK_SIZE_8x8_SP 32 // BLOCK_SIZE8x8 << 2
|
||||
#define BLOCK_SIZE_SP 16 // BLOCK_SIZE << 2
|
||||
#define BLOCK_SIZE_8x8_SP 32 // BLOCK_SIZE8x8 << 2
|
||||
|
||||
// Available MB modes
|
||||
typedef enum {
|
||||
PSKIP = 0,
|
||||
BSKIP_DIRECT = 0,
|
||||
P16x16 = 1,
|
||||
P16x8 = 2,
|
||||
P8x16 = 3,
|
||||
SMB8x8 = 4,
|
||||
SMB8x4 = 5,
|
||||
SMB4x8 = 6,
|
||||
SMB4x4 = 7,
|
||||
P8x8 = 8,
|
||||
I4MB = 9,
|
||||
I16MB = 10,
|
||||
IBLOCK = 11,
|
||||
SI4MB = 12,
|
||||
I8MB = 13,
|
||||
IPCM = 14,
|
||||
MAXMODE = 15
|
||||
PSKIP = 0,
|
||||
BSKIP_DIRECT = 0,
|
||||
P16x16 = 1,
|
||||
P16x8 = 2,
|
||||
P8x16 = 3,
|
||||
SMB8x8 = 4,
|
||||
SMB8x4 = 5,
|
||||
SMB4x8 = 6,
|
||||
SMB4x4 = 7,
|
||||
P8x8 = 8,
|
||||
I4MB = 9,
|
||||
I16MB = 10,
|
||||
IBLOCK = 11,
|
||||
SI4MB = 12,
|
||||
I8MB = 13,
|
||||
IPCM = 14,
|
||||
MAXMODE = 15
|
||||
} MBModeTypes;
|
||||
|
||||
// number of intra prediction modes
|
||||
#define NO_INTRA_PMODE 9
|
||||
#define NO_INTRA_PMODE 9
|
||||
|
||||
// Direct Mode types
|
||||
typedef enum {
|
||||
DIR_TEMPORAL = 0, //!< Temporal Direct Mode
|
||||
DIR_SPATIAL = 1 //!< Spatial Direct Mode
|
||||
DIR_SPATIAL = 1 //!< Spatial Direct Mode
|
||||
} DirectModes;
|
||||
|
||||
// CAVLC block types
|
||||
typedef enum {
|
||||
LUMA = 0,
|
||||
LUMA_INTRA16x16DC = 1,
|
||||
LUMA_INTRA16x16AC = 2,
|
||||
CB = 3,
|
||||
CB_INTRA16x16DC = 4,
|
||||
CB_INTRA16x16AC = 5,
|
||||
CR = 8,
|
||||
CR_INTRA16x16DC = 9,
|
||||
CR_INTRA16x16AC = 10
|
||||
LUMA = 0,
|
||||
LUMA_INTRA16x16DC = 1,
|
||||
LUMA_INTRA16x16AC = 2,
|
||||
CB = 3,
|
||||
CB_INTRA16x16DC = 4,
|
||||
CB_INTRA16x16AC = 5,
|
||||
CR = 8,
|
||||
CR_INTRA16x16DC = 9,
|
||||
CR_INTRA16x16AC = 10
|
||||
} CAVLCBlockTypes;
|
||||
|
||||
// CABAC block types
|
||||
typedef enum {
|
||||
LUMA_16DC = 0,
|
||||
LUMA_16AC = 1,
|
||||
LUMA_8x8 = 2,
|
||||
LUMA_8x4 = 3,
|
||||
LUMA_4x8 = 4,
|
||||
LUMA_4x4 = 5,
|
||||
CHROMA_DC = 6,
|
||||
CHROMA_AC = 7,
|
||||
CHROMA_DC_2x4 = 8,
|
||||
CHROMA_DC_4x4 = 9,
|
||||
CB_16DC = 10,
|
||||
CB_16AC = 11,
|
||||
CB_8x8 = 12,
|
||||
CB_8x4 = 13,
|
||||
CB_4x8 = 14,
|
||||
CB_4x4 = 15,
|
||||
CR_16DC = 16,
|
||||
CR_16AC = 17,
|
||||
CR_8x8 = 18,
|
||||
CR_8x4 = 19,
|
||||
CR_4x8 = 20,
|
||||
CR_4x4 = 21
|
||||
LUMA_16DC = 0,
|
||||
LUMA_16AC = 1,
|
||||
LUMA_8x8 = 2,
|
||||
LUMA_8x4 = 3,
|
||||
LUMA_4x8 = 4,
|
||||
LUMA_4x4 = 5,
|
||||
CHROMA_DC = 6,
|
||||
CHROMA_AC = 7,
|
||||
CHROMA_DC_2x4 = 8,
|
||||
CHROMA_DC_4x4 = 9,
|
||||
CB_16DC = 10,
|
||||
CB_16AC = 11,
|
||||
CB_8x8 = 12,
|
||||
CB_8x4 = 13,
|
||||
CB_4x8 = 14,
|
||||
CB_4x4 = 15,
|
||||
CR_16DC = 16,
|
||||
CR_16AC = 17,
|
||||
CR_8x8 = 18,
|
||||
CR_8x4 = 19,
|
||||
CR_4x8 = 20,
|
||||
CR_4x4 = 21
|
||||
} CABACBlockTypes;
|
||||
|
||||
// Macro defines
|
||||
#define Q_BITS 15
|
||||
#define DQ_BITS 6
|
||||
#define Q_BITS_8 16
|
||||
#define DQ_BITS_8 6
|
||||
#define Q_BITS 15
|
||||
#define DQ_BITS 6
|
||||
#define Q_BITS_8 16
|
||||
#define DQ_BITS_8 6
|
||||
|
||||
#define IS_I16MB(MB) ((MB)->mb_type == I16MB || (MB)->mb_type == IPCM)
|
||||
#define IS_DIRECT(MB) ((MB)->mb_type == 0 && (currSlice->slice_type == B_SLICE))
|
||||
|
||||
#define IS_I16MB(MB) ((MB)->mb_type==I16MB || (MB)->mb_type==IPCM)
|
||||
#define IS_DIRECT(MB) ((MB)->mb_type==0 && (currSlice->slice_type == B_SLICE ))
|
||||
|
||||
#define TOTRUN_NUM 15
|
||||
#define RUNBEFORE_NUM 7
|
||||
#define RUNBEFORE_NUM_M1 6
|
||||
#define TOTRUN_NUM 15
|
||||
#define RUNBEFORE_NUM 7
|
||||
#define RUNBEFORE_NUM_M1 6
|
||||
|
||||
// Quantization parameter range
|
||||
#define MIN_QP 0
|
||||
#define MAX_QP 51
|
||||
// 4x4 intra prediction modes
|
||||
#define MIN_QP 0
|
||||
#define MAX_QP 51
|
||||
// 4x4 intra prediction modes
|
||||
typedef enum {
|
||||
VERT_PRED = 0,
|
||||
HOR_PRED = 1,
|
||||
DC_PRED = 2,
|
||||
DIAG_DOWN_LEFT_PRED = 3,
|
||||
VERT_PRED = 0,
|
||||
HOR_PRED = 1,
|
||||
DC_PRED = 2,
|
||||
DIAG_DOWN_LEFT_PRED = 3,
|
||||
DIAG_DOWN_RIGHT_PRED = 4,
|
||||
VERT_RIGHT_PRED = 5,
|
||||
HOR_DOWN_PRED = 6,
|
||||
VERT_LEFT_PRED = 7,
|
||||
HOR_UP_PRED = 8
|
||||
VERT_RIGHT_PRED = 5,
|
||||
HOR_DOWN_PRED = 6,
|
||||
VERT_LEFT_PRED = 7,
|
||||
HOR_UP_PRED = 8
|
||||
} I4x4PredModes;
|
||||
|
||||
// 16x16 intra prediction modes
|
||||
typedef enum {
|
||||
VERT_PRED_16 = 0,
|
||||
HOR_PRED_16 = 1,
|
||||
DC_PRED_16 = 2,
|
||||
PLANE_16 = 3
|
||||
VERT_PRED_16 = 0,
|
||||
HOR_PRED_16 = 1,
|
||||
DC_PRED_16 = 2,
|
||||
PLANE_16 = 3
|
||||
} I16x16PredModes;
|
||||
|
||||
// 8x8 chroma intra prediction modes
|
||||
typedef enum {
|
||||
DC_PRED_8 = 0,
|
||||
HOR_PRED_8 = 1,
|
||||
VERT_PRED_8 = 2,
|
||||
PLANE_8 = 3
|
||||
DC_PRED_8 = 0,
|
||||
HOR_PRED_8 = 1,
|
||||
VERT_PRED_8 = 2,
|
||||
PLANE_8 = 3
|
||||
} I8x8PredModes;
|
||||
|
||||
enum {
|
||||
EOS = 1, //!< End Of Sequence
|
||||
SOP = 2, //!< Start Of Picture
|
||||
SOS = 3, //!< Start Of Slice
|
||||
EOS = 1, //!< End Of Sequence
|
||||
SOP = 2, //!< Start Of Picture
|
||||
SOS = 3, //!< Start Of Slice
|
||||
SOS_CONT = 4
|
||||
};
|
||||
|
||||
// MV Prediction types
|
||||
typedef enum {
|
||||
MVPRED_MEDIAN = 0,
|
||||
MVPRED_L = 1,
|
||||
MVPRED_U = 2,
|
||||
MVPRED_UR = 3
|
||||
MVPRED_MEDIAN = 0,
|
||||
MVPRED_L = 1,
|
||||
MVPRED_U = 2,
|
||||
MVPRED_UR = 3
|
||||
} MVPredTypes;
|
||||
|
||||
enum {
|
||||
DECODING_OK = 0,
|
||||
SEARCH_SYNC = 1,
|
||||
PICTURE_DECODED = 2
|
||||
};
|
||||
enum { DECODING_OK = 0, SEARCH_SYNC = 1, PICTURE_DECODED = 2 };
|
||||
|
||||
#define LAMBDA_ACCURACY_BITS 16
|
||||
#define INVALIDINDEX (-135792468)
|
||||
#define LAMBDA_ACCURACY_BITS 16
|
||||
#define INVALIDINDEX (-135792468)
|
||||
|
||||
#define RC_MAX_TEMPORAL_LEVELS 5
|
||||
#define RC_MAX_TEMPORAL_LEVELS 5
|
||||
|
||||
//Start code and Emulation Prevention need this to be defined in identical manner at encoder and decoder
|
||||
#define ZEROBYTES_SHORTSTARTCODE 2 //indicates the number of zero bytes in the short start-code prefix
|
||||
// Start code and Emulation Prevention need this to be defined in identical
|
||||
// manner at encoder and decoder
|
||||
#define ZEROBYTES_SHORTSTARTCODE \
|
||||
2 // indicates the number of zero bytes in the short start-code prefix
|
||||
|
||||
#define MAX_PLANE 3
|
||||
#define IS_FREXT_PROFILE(profile_idc) ( profile_idc>=FREXT_HP || profile_idc == FREXT_CAVLC444 )
|
||||
#define HI_INTRA_ONLY_PROFILE (((p_Vid->active_sps->profile_idc>=FREXT_Hi10P)&&(p_Vid->active_sps->constrained_set3_flag))||(p_Vid->active_sps->profile_idc==FREXT_CAVLC444))
|
||||
#define MAX_PLANE 3
|
||||
#define IS_FREXT_PROFILE(profile_idc) \
|
||||
(profile_idc >= FREXT_HP || profile_idc == FREXT_CAVLC444)
|
||||
#define HI_INTRA_ONLY_PROFILE \
|
||||
(((p_Vid->active_sps->profile_idc >= FREXT_Hi10P) && \
|
||||
(p_Vid->active_sps->constrained_set3_flag)) || \
|
||||
(p_Vid->active_sps->profile_idc == FREXT_CAVLC444))
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*!
|
||||
**************************************************************************
|
||||
* \file distortion.h
|
||||
* \brief
|
||||
* \brief
|
||||
* Distortion data header file
|
||||
* \date 2.23.2009,
|
||||
*
|
||||
* \author
|
||||
* \author
|
||||
* Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
**************************************************************************
|
||||
|
@ -15,17 +15,15 @@
|
|||
#define _DISTORTION_H_
|
||||
|
||||
// Distortion data structure. Could be extended in the future to support
|
||||
// other data
|
||||
typedef struct distortion_data
|
||||
{
|
||||
int i4x4rd[4][4]; //! i4x4 rd cost
|
||||
distblk i4x4 [4][4]; //! i4x4 cost
|
||||
distblk i8x8 [2][2]; //! i8x8 cost
|
||||
int i8x8rd[2][2]; //! i8x8 rd cost
|
||||
int i16x16;
|
||||
int i16x16rd;
|
||||
double rd_cost;
|
||||
// other data
|
||||
typedef struct distortion_data {
|
||||
int i4x4rd[4][4]; //! i4x4 rd cost
|
||||
distblk i4x4[4][4]; //! i4x4 cost
|
||||
distblk i8x8[2][2]; //! i8x8 cost
|
||||
int i8x8rd[2][2]; //! i8x8 rd cost
|
||||
int i16x16;
|
||||
int i16x16rd;
|
||||
double rd_cost;
|
||||
} DistortionData;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -39,40 +39,40 @@
|
|||
* TYPE_CBP | SE_CBP_INTRA, SE_CBP_INTER
|
||||
* SE_DELTA_QUANT_INTER
|
||||
* SE_DELTA_QUANT_INTRA
|
||||
* TYPE_COEFF_Y | SE_LUM_DC_INTRA, SE_LUM_AC_INTRA, SE_LUM_DC_INTER, SE_LUM_AC_INTER
|
||||
* TYPE_2x2DC | SE_CHR_DC_INTRA, SE_CHR_DC_INTER
|
||||
* TYPE_COEFF_Y | SE_LUM_DC_INTRA, SE_LUM_AC_INTRA, SE_LUM_DC_INTER,
|
||||
* SE_LUM_AC_INTER TYPE_2x2DC | SE_CHR_DC_INTRA, SE_CHR_DC_INTER
|
||||
* TYPE_COEFF_C | SE_CHR_AC_INTRA, SE_CHR_AC_INTER
|
||||
* TYPE_EOS | SE_EOS
|
||||
*/
|
||||
*/
|
||||
|
||||
#define SE_HEADER 0
|
||||
#define SE_PTYPE 1
|
||||
#define SE_MBTYPE 2
|
||||
#define SE_REFFRAME 3
|
||||
#define SE_INTRAPREDMODE 4
|
||||
#define SE_MVD 5
|
||||
#define SE_CBP_INTRA 6
|
||||
#define SE_LUM_DC_INTRA 7
|
||||
#define SE_CHR_DC_INTRA 8
|
||||
#define SE_LUM_AC_INTRA 9
|
||||
#define SE_CHR_AC_INTRA 10
|
||||
#define SE_CBP_INTER 11
|
||||
#define SE_LUM_DC_INTER 12
|
||||
#define SE_CHR_DC_INTER 13
|
||||
#define SE_LUM_AC_INTER 14
|
||||
#define SE_CHR_AC_INTER 15
|
||||
#define SE_DELTA_QUANT_INTER 16
|
||||
#define SE_DELTA_QUANT_INTRA 17
|
||||
#define SE_BFRAME 18
|
||||
#define SE_EOS 19
|
||||
#define SE_MAX_ELEMENTS 20
|
||||
#define SE_HEADER 0
|
||||
#define SE_PTYPE 1
|
||||
#define SE_MBTYPE 2
|
||||
#define SE_REFFRAME 3
|
||||
#define SE_INTRAPREDMODE 4
|
||||
#define SE_MVD 5
|
||||
#define SE_CBP_INTRA 6
|
||||
#define SE_LUM_DC_INTRA 7
|
||||
#define SE_CHR_DC_INTRA 8
|
||||
#define SE_LUM_AC_INTRA 9
|
||||
#define SE_CHR_AC_INTRA 10
|
||||
#define SE_CBP_INTER 11
|
||||
#define SE_LUM_DC_INTER 12
|
||||
#define SE_CHR_DC_INTER 13
|
||||
#define SE_LUM_AC_INTER 14
|
||||
#define SE_CHR_AC_INTER 15
|
||||
#define SE_DELTA_QUANT_INTER 16
|
||||
#define SE_DELTA_QUANT_INTRA 17
|
||||
#define SE_BFRAME 18
|
||||
#define SE_EOS 19
|
||||
#define SE_MAX_ELEMENTS 20
|
||||
|
||||
#define NO_EC 0 //!< no error concealment necessary
|
||||
#define EC_REQ 1 //!< error concealment required
|
||||
#define EC_SYNC 2 //!< search and sync on next header element
|
||||
|
||||
#define NO_EC 0 //!< no error concealment necessary
|
||||
#define EC_REQ 1 //!< error concealment required
|
||||
#define EC_SYNC 2 //!< search and sync on next header element
|
||||
|
||||
#define MAXPARTITIONMODES 2 //!< maximum possible partition modes as defined in assignSE2partition[][]
|
||||
#define MAXPARTITIONMODES \
|
||||
2 //!< maximum possible partition modes as defined in assignSE2partition[][]
|
||||
|
||||
/*!
|
||||
* \brief lookup-table to assign different elements to partition
|
||||
|
@ -99,14 +99,14 @@
|
|||
* outlined in document Q15-J-23.
|
||||
*/
|
||||
|
||||
|
||||
static const byte assignSE2partition[][SE_MAX_ELEMENTS] =
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // element number (do not uncomment)
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, //!< all elements in one partition no data partitioning
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 0 } //!< three partitions per slice
|
||||
static const byte assignSE2partition[][SE_MAX_ELEMENTS] = {
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // element
|
||||
// number (do not uncomment)
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0}, //!< all elements in one partition no data
|
||||
//!< partitioning
|
||||
{0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
|
||||
1, 0, 2, 2, 2, 2, 0, 0, 0, 0} //!< three partitions per slice
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* statistics reports for the encoding process.
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Tourapis <alexismt@ieee.org>
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
*
|
||||
|
@ -17,52 +18,55 @@
|
|||
#define _ENC_STATISTICS_H_
|
||||
#include "global.h"
|
||||
|
||||
struct stat_parameters
|
||||
{
|
||||
float bitrate; //!< average bit rate for the sequence except first frame
|
||||
int64 bit_ctr; //!< counter for bit usage
|
||||
int64 bit_ctr_n; //!< bit usage for the current frame
|
||||
int64 bit_ctr_emulationprevention; //!< stored bits needed to prevent start code emulation
|
||||
int bit_slice; //!< number of bits in current slice
|
||||
int stored_bit_slice; //!< keep number of bits in current slice (to restore status in case of MB re-encoding)
|
||||
int b8_mode_0_use [NUM_SLICE_TYPES][2];
|
||||
int64 mode_use_transform[NUM_SLICE_TYPES][MAXMODE][2];
|
||||
int64 intra_chroma_mode[4];
|
||||
struct stat_parameters {
|
||||
float bitrate; //!< average bit rate for the sequence except first frame
|
||||
int64 bit_ctr; //!< counter for bit usage
|
||||
int64 bit_ctr_n; //!< bit usage for the current frame
|
||||
int64 bit_ctr_emulationprevention; //!< stored bits needed to prevent start
|
||||
//!< code emulation
|
||||
int bit_slice; //!< number of bits in current slice
|
||||
int stored_bit_slice; //!< keep number of bits in current slice (to restore
|
||||
//!< status in case of MB re-encoding)
|
||||
int b8_mode_0_use[NUM_SLICE_TYPES][2];
|
||||
int64 mode_use_transform[NUM_SLICE_TYPES][MAXMODE][2];
|
||||
int64 intra_chroma_mode[4];
|
||||
|
||||
// B pictures
|
||||
int NumberBFrames;
|
||||
int NumberBFrames;
|
||||
|
||||
int frame_counter;
|
||||
int64 quant [NUM_SLICE_TYPES];
|
||||
int64 num_macroblocks [NUM_SLICE_TYPES];
|
||||
int frame_ctr [NUM_SLICE_TYPES];
|
||||
int64 bit_counter [NUM_SLICE_TYPES];
|
||||
float bitrate_st [NUM_SLICE_TYPES];
|
||||
int64 mode_use [NUM_SLICE_TYPES][MAXMODE]; //!< Macroblock mode usage for Intra frames
|
||||
int64 bit_use_mode [NUM_SLICE_TYPES][MAXMODE]; //!< statistics of bit usage
|
||||
int64 bit_use_mb_type [NUM_SLICE_TYPES];
|
||||
int64 bit_use_header [NUM_SLICE_TYPES];
|
||||
int64 tmp_bit_use_cbp [NUM_SLICE_TYPES];
|
||||
int64 bit_use_coeffC [NUM_SLICE_TYPES];
|
||||
int64 bit_use_coeff [3][NUM_SLICE_TYPES];
|
||||
int64 bit_use_delta_quant [NUM_SLICE_TYPES];
|
||||
int64 bit_use_stuffingBits[NUM_SLICE_TYPES];
|
||||
int frame_counter;
|
||||
int64 quant[NUM_SLICE_TYPES];
|
||||
int64 num_macroblocks[NUM_SLICE_TYPES];
|
||||
int frame_ctr[NUM_SLICE_TYPES];
|
||||
int64 bit_counter[NUM_SLICE_TYPES];
|
||||
float bitrate_st[NUM_SLICE_TYPES];
|
||||
int64 mode_use[NUM_SLICE_TYPES]
|
||||
[MAXMODE]; //!< Macroblock mode usage for Intra frames
|
||||
int64 bit_use_mode[NUM_SLICE_TYPES][MAXMODE]; //!< statistics of bit usage
|
||||
int64 bit_use_mb_type[NUM_SLICE_TYPES];
|
||||
int64 bit_use_header[NUM_SLICE_TYPES];
|
||||
int64 tmp_bit_use_cbp[NUM_SLICE_TYPES];
|
||||
int64 bit_use_coeffC[NUM_SLICE_TYPES];
|
||||
int64 bit_use_coeff[3][NUM_SLICE_TYPES];
|
||||
int64 bit_use_delta_quant[NUM_SLICE_TYPES];
|
||||
int64 bit_use_stuffingBits[NUM_SLICE_TYPES];
|
||||
|
||||
int bit_ctr_parametersets;
|
||||
int bit_ctr_parametersets_n;
|
||||
int64 bit_ctr_filler_data;
|
||||
int64 bit_ctr_filler_data_n;
|
||||
int bit_ctr_parametersets;
|
||||
int bit_ctr_parametersets_n;
|
||||
int64 bit_ctr_filler_data;
|
||||
int64 bit_ctr_filler_data_n;
|
||||
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
float bitrate_v[2]; //!< average bit rate for the sequence except first frame
|
||||
int64 bit_ctr_v[2]; //!< counter for bit usage
|
||||
int64 bit_ctr_n_v[2]; //!< bit usage for the current frame
|
||||
int64 bit_ctr_emulationprevention_v[2]; //!< stored bits needed to prevent start code emulation
|
||||
int64 bit_counter_v[2][NUM_SLICE_TYPES];
|
||||
int bit_ctr_parametersets_v[2];
|
||||
int bit_ctr_parametersets_n_v[2];
|
||||
int64 bit_ctr_filler_data_v[2];
|
||||
int64 bit_ctr_filler_data_n_v[2];
|
||||
float bitrate_v[2]; //!< average bit rate for the sequence except first frame
|
||||
int64 bit_ctr_v[2]; //!< counter for bit usage
|
||||
int64 bit_ctr_n_v[2]; //!< bit usage for the current frame
|
||||
int64 bit_ctr_emulationprevention_v[2]; //!< stored bits needed to prevent
|
||||
//!< start code emulation
|
||||
int64 bit_counter_v[2][NUM_SLICE_TYPES];
|
||||
int bit_ctr_parametersets_v[2];
|
||||
int bit_ctr_parametersets_n_v[2];
|
||||
int64 bit_ctr_filler_data_v[2];
|
||||
int64 bit_ctr_filler_data_n_v[2];
|
||||
#endif
|
||||
};
|
||||
typedef struct stat_parameters StatParameters;
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
* \file erc_api.h
|
||||
*
|
||||
* \brief
|
||||
* External (still inside video decoder) interface for error concealment module
|
||||
* External (still inside video decoder) interface for error concealment
|
||||
*module
|
||||
*
|
||||
* \author
|
||||
* - Ari Hourunranta <ari.hourunranta@nokia.com>
|
||||
|
@ -17,116 +18,117 @@
|
|||
* ************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _ERC_API_H_
|
||||
#define _ERC_API_H_
|
||||
|
||||
#include "erc_globals.h"
|
||||
|
||||
/*
|
||||
* Defines
|
||||
*/
|
||||
* Defines
|
||||
*/
|
||||
|
||||
/* If the average motion vector of the correctly received macroblocks is less than the
|
||||
threshold, concealByCopy is used, otherwise concealByTrial is used. */
|
||||
/* If the average motion vector of the correctly received macroblocks is less
|
||||
than the threshold, concealByCopy is used, otherwise concealByTrial is used. */
|
||||
#define MVPERMB_THR 8
|
||||
|
||||
/* used to determine the size of the allocated memory for a temporal Region (MB) */
|
||||
#define DEF_REGION_SIZE 384 /* 8*8*6 */
|
||||
|
||||
#define ERC_BLOCK_OK 3
|
||||
#define ERC_BLOCK_CONCEALED 2
|
||||
#define ERC_BLOCK_CORRUPTED 1
|
||||
#define ERC_BLOCK_EMPTY 0
|
||||
/* used to determine the size of the allocated memory for a temporal Region (MB)
|
||||
*/
|
||||
#define DEF_REGION_SIZE 384 /* 8*8*6 */
|
||||
|
||||
#define ERC_BLOCK_OK 3
|
||||
#define ERC_BLOCK_CONCEALED 2
|
||||
#define ERC_BLOCK_CORRUPTED 1
|
||||
#define ERC_BLOCK_EMPTY 0
|
||||
|
||||
/*
|
||||
* Functions to convert MBNum representation to blockNum
|
||||
*/
|
||||
* Functions to convert MBNum representation to blockNum
|
||||
*/
|
||||
|
||||
#define xPosYBlock(currYBlockNum,picSizeX) \
|
||||
((currYBlockNum)%((picSizeX)>>3))
|
||||
#define xPosYBlock(currYBlockNum, picSizeX) \
|
||||
((currYBlockNum) % ((picSizeX) >> 3))
|
||||
|
||||
#define yPosYBlock(currYBlockNum,picSizeX) \
|
||||
((currYBlockNum)/((picSizeX)>>3))
|
||||
#define yPosYBlock(currYBlockNum, picSizeX) \
|
||||
((currYBlockNum) / ((picSizeX) >> 3))
|
||||
|
||||
#define xPosMB(currMBNum,picSizeX) \
|
||||
((currMBNum)%((picSizeX)>>4))
|
||||
#define xPosMB(currMBNum, picSizeX) ((currMBNum) % ((picSizeX) >> 4))
|
||||
|
||||
#define yPosMB(currMBNum,picSizeX) \
|
||||
((currMBNum)/((picSizeX)>>4))
|
||||
#define yPosMB(currMBNum, picSizeX) ((currMBNum) / ((picSizeX) >> 4))
|
||||
|
||||
#define MBxy2YBlock(currXPos,currYPos,comp,picSizeX) \
|
||||
((((currYPos)<<1)+((comp)>>1))*((picSizeX)>>3)+((currXPos)<<1)+((comp)&1))
|
||||
|
||||
#define MBNum2YBlock(currMBNum,comp,picSizeX) \
|
||||
MBxy2YBlock(xPosMB((currMBNum),(picSizeX)),yPosMB((currMBNum),(picSizeX)),(comp),(picSizeX))
|
||||
#define MBxy2YBlock(currXPos, currYPos, comp, picSizeX) \
|
||||
((((currYPos) << 1) + ((comp) >> 1)) * ((picSizeX) >> 3) + \
|
||||
((currXPos) << 1) + ((comp) & 1))
|
||||
|
||||
#define MBNum2YBlock(currMBNum, comp, picSizeX) \
|
||||
MBxy2YBlock(xPosMB((currMBNum), (picSizeX)), \
|
||||
yPosMB((currMBNum), (picSizeX)), (comp), (picSizeX))
|
||||
|
||||
/*
|
||||
* typedefs
|
||||
*/
|
||||
* typedefs
|
||||
*/
|
||||
|
||||
/* segment data structure */
|
||||
typedef struct ercSegment_s
|
||||
{
|
||||
short startMBPos;
|
||||
short endMBPos;
|
||||
signed char fCorrupted;
|
||||
typedef struct ercSegment_s {
|
||||
short startMBPos;
|
||||
short endMBPos;
|
||||
signed char fCorrupted;
|
||||
} ercSegment_t;
|
||||
|
||||
/* Error detector & concealment instance data structure */
|
||||
typedef struct ercVariables_s
|
||||
{
|
||||
typedef struct ercVariables_s {
|
||||
/* Number of macroblocks (size or size/4 of the arrays) */
|
||||
int nOfMBs;
|
||||
int nOfMBs;
|
||||
/* Number of segments (slices) in frame */
|
||||
int nOfSegments;
|
||||
int nOfSegments;
|
||||
|
||||
/* Array for conditions of Y blocks */
|
||||
signed char *yCondition;
|
||||
signed char *yCondition;
|
||||
/* Array for conditions of U blocks */
|
||||
signed char *uCondition;
|
||||
signed char *uCondition;
|
||||
/* Array for conditions of V blocks */
|
||||
signed char *vCondition;
|
||||
signed char *vCondition;
|
||||
|
||||
/* Array for Slice level information */
|
||||
ercSegment_t *segments;
|
||||
int currSegment;
|
||||
int currSegment;
|
||||
|
||||
/* Conditions of the MBs of the previous frame */
|
||||
signed char *prevFrameYCondition;
|
||||
signed char *prevFrameYCondition;
|
||||
|
||||
/* Flag telling if the current segment was found to be corrupted */
|
||||
int currSegmentCorrupted;
|
||||
int currSegmentCorrupted;
|
||||
/* Counter for corrupted segments per picture */
|
||||
int nOfCorruptedSegments;
|
||||
int nOfCorruptedSegments;
|
||||
|
||||
/* State variables for error detector and concealer */
|
||||
int concealment;
|
||||
int concealment;
|
||||
|
||||
} ercVariables_t;
|
||||
|
||||
/*
|
||||
* External function interface
|
||||
*/
|
||||
* External function interface
|
||||
*/
|
||||
|
||||
void ercInit (VideoParameters *p_Vid, int pic_sizex, int pic_sizey, int flag);
|
||||
ercVariables_t *ercOpen( void );
|
||||
void ercReset( ercVariables_t *errorVar, int nOfMBs, int numOfSegments, int picSizeX );
|
||||
void ercClose( VideoParameters *p_Vid, ercVariables_t *errorVar );
|
||||
void ercSetErrorConcealment( ercVariables_t *errorVar, int value );
|
||||
void ercInit(VideoParameters *p_Vid, int pic_sizex, int pic_sizey, int flag);
|
||||
ercVariables_t *ercOpen(void);
|
||||
void ercReset(ercVariables_t *errorVar, int nOfMBs, int numOfSegments,
|
||||
int picSizeX);
|
||||
void ercClose(VideoParameters *p_Vid, ercVariables_t *errorVar);
|
||||
void ercSetErrorConcealment(ercVariables_t *errorVar, int value);
|
||||
|
||||
void ercStartSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar );
|
||||
void ercStopSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar );
|
||||
void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar );
|
||||
void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar );
|
||||
void ercMarkCurrMBConcealed( int currMBNum, int comp, int picSizeX, ercVariables_t *errorVar );
|
||||
|
||||
int ercConcealIntraFrame( VideoParameters *p_Vid, frame *recfr, int picSizeX, int picSizeY, ercVariables_t *errorVar );
|
||||
int ercConcealInterFrame( frame *recfr, objectBuffer_t *object_list,
|
||||
int picSizeX, int picSizeY, ercVariables_t *errorVar, int chroma_format_idc );
|
||||
void ercStartSegment(int currMBNum, int segment, unsigned int bitPos,
|
||||
ercVariables_t *errorVar);
|
||||
void ercStopSegment(int currMBNum, int segment, unsigned int bitPos,
|
||||
ercVariables_t *errorVar);
|
||||
void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar);
|
||||
void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar);
|
||||
void ercMarkCurrMBConcealed(int currMBNum, int comp, int picSizeX,
|
||||
ercVariables_t *errorVar);
|
||||
|
||||
int ercConcealIntraFrame(VideoParameters *p_Vid, frame *recfr, int picSizeX,
|
||||
int picSizeY, ercVariables_t *errorVar);
|
||||
int ercConcealInterFrame(frame *recfr, objectBuffer_t *object_list,
|
||||
int picSizeX, int picSizeY, ercVariables_t *errorVar,
|
||||
int chroma_format_idc);
|
||||
|
||||
/* Thomson APIs for concealing entire frame loss */
|
||||
|
||||
|
@ -134,25 +136,26 @@ int ercConcealInterFrame( frame *recfr, objectBuffer_t *object_list,
|
|||
#include "output.h"
|
||||
|
||||
struct concealment_node {
|
||||
StorablePicture* picture;
|
||||
int missingpocs;
|
||||
struct concealment_node *next;
|
||||
StorablePicture *picture;
|
||||
int missingpocs;
|
||||
struct concealment_node *next;
|
||||
};
|
||||
|
||||
extern struct concealment_node * init_node(StorablePicture* , int );
|
||||
extern void print_node( struct concealment_node * );
|
||||
extern void print_list( struct concealment_node * );
|
||||
extern void init_lists_for_non_reference_loss(DecodedPictureBuffer *p_Dpb, int , PictureStructure );
|
||||
extern struct concealment_node *init_node(StorablePicture *, int);
|
||||
extern void print_node(struct concealment_node *);
|
||||
extern void print_list(struct concealment_node *);
|
||||
extern void init_lists_for_non_reference_loss(DecodedPictureBuffer *p_Dpb, int,
|
||||
PictureStructure);
|
||||
|
||||
extern void conceal_non_ref_pics(DecodedPictureBuffer *p_Dpb, int diff);
|
||||
extern void conceal_lost_frames (DecodedPictureBuffer *p_Dpb, Slice *pSlice);
|
||||
extern void conceal_lost_frames(DecodedPictureBuffer *p_Dpb, Slice *pSlice);
|
||||
|
||||
extern void sliding_window_poc_management(DecodedPictureBuffer *p_Dpb, StorablePicture *p);
|
||||
extern void write_lost_non_ref_pic (DecodedPictureBuffer *p_Dpb, int poc, int p_out);
|
||||
extern void write_lost_ref_after_idr (DecodedPictureBuffer *p_Dpb, int pos);
|
||||
extern void sliding_window_poc_management(DecodedPictureBuffer *p_Dpb,
|
||||
StorablePicture *p);
|
||||
extern void write_lost_non_ref_pic(DecodedPictureBuffer *p_Dpb, int poc,
|
||||
int p_out);
|
||||
extern void write_lost_ref_after_idr(DecodedPictureBuffer *p_Dpb, int pos);
|
||||
|
||||
extern int comp(const void *, const void *);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -16,29 +16,35 @@
|
|||
#ifndef _ERC_DO_H_
|
||||
#define _ERC_DO_H_
|
||||
|
||||
|
||||
#include "erc_api.h"
|
||||
|
||||
void ercPixConcealIMB (VideoParameters *p_Vid, imgpel *currFrame, int row, int column, int predBlocks[], int frameWidth, int mbWidthInBlocks);
|
||||
void ercPixConcealIMB(VideoParameters *p_Vid, imgpel *currFrame, int row,
|
||||
int column, int predBlocks[], int frameWidth,
|
||||
int mbWidthInBlocks);
|
||||
|
||||
int ercCollect8PredBlocks( int predBlocks[], int currRow, int currColumn, signed char *condition,
|
||||
int maxRow, int maxColumn, int step, byte fNoCornerNeigh );
|
||||
int ercCollectColumnBlocks( int predBlocks[], int currRow, int currColumn, signed char *condition, int maxRow, int maxColumn, int step );
|
||||
int ercCollect8PredBlocks(int predBlocks[], int currRow, int currColumn,
|
||||
signed char *condition, int maxRow, int maxColumn,
|
||||
int step, byte fNoCornerNeigh);
|
||||
int ercCollectColumnBlocks(int predBlocks[], int currRow, int currColumn,
|
||||
signed char *condition, int maxRow, int maxColumn,
|
||||
int step);
|
||||
|
||||
#define isSplitted(object_list,currMBNum) \
|
||||
((object_list+((currMBNum)<<2))->regionMode >= REGMODE_SPLITTED)
|
||||
#define isSplitted(object_list, currMBNum) \
|
||||
((object_list + ((currMBNum) << 2))->regionMode >= REGMODE_SPLITTED)
|
||||
|
||||
/* this can be used as isBlock(...,INTRA) or isBlock(...,INTER_COPY) */
|
||||
#define isBlock(object_list,currMBNum,comp,regMode) \
|
||||
(isSplitted(object_list,currMBNum) ? \
|
||||
((object_list+((currMBNum)<<2)+(comp))->regionMode == REGMODE_##regMode##_8x8) : \
|
||||
((object_list+((currMBNum)<<2))->regionMode == REGMODE_##regMode))
|
||||
#define isBlock(object_list, currMBNum, comp, regMode) \
|
||||
(isSplitted(object_list, currMBNum) \
|
||||
? ((object_list + ((currMBNum) << 2) + (comp))->regionMode == \
|
||||
REGMODE_##regMode##_8x8) \
|
||||
: ((object_list + ((currMBNum) << 2))->regionMode == \
|
||||
REGMODE_##regMode))
|
||||
|
||||
/* this can be used as getParam(...,mv) or getParam(...,xMin) or getParam(...,yMin) */
|
||||
#define getParam(object_list,currMBNum,comp,param) \
|
||||
(isSplitted(object_list,currMBNum) ? \
|
||||
((object_list+((currMBNum)<<2)+(comp))->param) : \
|
||||
((object_list+((currMBNum)<<2))->param))
|
||||
/* this can be used as getParam(...,mv) or getParam(...,xMin) or
|
||||
* getParam(...,yMin) */
|
||||
#define getParam(object_list, currMBNum, comp, param) \
|
||||
(isSplitted(object_list, currMBNum) \
|
||||
? ((object_list + ((currMBNum) << 2) + (comp))->param) \
|
||||
: ((object_list + ((currMBNum) << 2))->param))
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -20,33 +20,34 @@
|
|||
/* "block" means an 8x8 pixel area */
|
||||
|
||||
/* Region modes */
|
||||
#define REGMODE_INTER_COPY 0 //!< Copy region
|
||||
#define REGMODE_INTER_PRED 1 //!< Inter region with motion vectors
|
||||
#define REGMODE_INTRA 2 //!< Intra region
|
||||
#define REGMODE_SPLITTED 3 //!< Any region mode higher than this indicates that the region
|
||||
//!< is splitted which means 8x8 block
|
||||
#define REGMODE_INTER_COPY_8x8 4
|
||||
#define REGMODE_INTER_PRED_8x8 5
|
||||
#define REGMODE_INTRA_8x8 6
|
||||
#define REGMODE_INTER_COPY 0 //!< Copy region
|
||||
#define REGMODE_INTER_PRED 1 //!< Inter region with motion vectors
|
||||
#define REGMODE_INTRA 2 //!< Intra region
|
||||
#define REGMODE_SPLITTED \
|
||||
3 //!< Any region mode higher than this indicates that the region
|
||||
//!< is splitted which means 8x8 block
|
||||
#define REGMODE_INTER_COPY_8x8 4
|
||||
#define REGMODE_INTER_PRED_8x8 5
|
||||
#define REGMODE_INTRA_8x8 6
|
||||
|
||||
//! YUV pixel domain image arrays for a video frame
|
||||
typedef struct frame_s
|
||||
{
|
||||
typedef struct frame_s {
|
||||
VideoParameters *p_Vid;
|
||||
imgpel *yptr;
|
||||
imgpel *uptr;
|
||||
imgpel *vptr;
|
||||
} frame;
|
||||
|
||||
//! region structure stores information about a region that is needed for concealment
|
||||
typedef struct object_buffer
|
||||
{
|
||||
byte regionMode; //!< region mode as above
|
||||
int xMin; //!< X coordinate of the pixel position of the top-left corner of the region
|
||||
int yMin; //!< Y coordinate of the pixel position of the top-left corner of the region
|
||||
int mv[3]; //!< motion vectors in 1/4 pixel units: mvx = mv[0], mvy = mv[1],
|
||||
//!< and ref_frame = mv[2]
|
||||
//! region structure stores information about a region that is needed for
|
||||
//! concealment
|
||||
typedef struct object_buffer {
|
||||
byte regionMode; //!< region mode as above
|
||||
int xMin; //!< X coordinate of the pixel position of the top-left corner of
|
||||
//!< the region
|
||||
int yMin; //!< Y coordinate of the pixel position of the top-left corner of
|
||||
//!< the region
|
||||
int mv[3]; //!< motion vectors in 1/4 pixel units: mvx = mv[0], mvy = mv[1],
|
||||
//!< and ref_frame = mv[2]
|
||||
} objectBuffer_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
#ifndef _ERRORCONCEALMENT_H_
|
||||
#define _ERRORCONCEALMENT_H_
|
||||
|
||||
extern int get_concealed_element(VideoParameters *p_Vid, SyntaxElement *sym);
|
||||
extern int set_ec_flag (VideoParameters *p_Vid, int se);
|
||||
extern void reset_ec_flags (VideoParameters *p_Vid);
|
||||
extern int get_concealed_element(VideoParameters *p_Vid, SyntaxElement *sym);
|
||||
extern int set_ec_flag(VideoParameters *p_Vid, int se);
|
||||
extern void reset_ec_flags(VideoParameters *p_Vid);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* Memory handling operations
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Chris Vogt
|
||||
*
|
||||
**************************************************************************
|
||||
|
@ -17,16 +18,12 @@
|
|||
|
||||
#include "typedefs.h"
|
||||
|
||||
|
||||
static inline void fast_memset(void *dst,int value,int width)
|
||||
{
|
||||
memset(dst,value,width);
|
||||
static inline void fast_memset(void *dst, int value, int width) {
|
||||
memset(dst, value, width);
|
||||
}
|
||||
|
||||
static inline void fast_memcpy(void *dst,void *src,int width)
|
||||
{
|
||||
memcpy(dst,src,width);
|
||||
static inline void fast_memcpy(void *dst, void *src, int width) {
|
||||
memcpy(dst, src, width);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,14 +17,13 @@
|
|||
#ifndef _FMO_H_
|
||||
#define _FMO_H_
|
||||
|
||||
|
||||
extern int fmo_init (VideoParameters *p_Vid, Slice *pSlice);
|
||||
extern int FmoFinit (VideoParameters *p_Vid);
|
||||
extern int fmo_init(VideoParameters *p_Vid, Slice *pSlice);
|
||||
extern int FmoFinit(VideoParameters *p_Vid);
|
||||
|
||||
extern int FmoGetNumberOfSliceGroup(VideoParameters *p_Vid);
|
||||
extern int FmoGetLastMBOfPicture (VideoParameters *p_Vid);
|
||||
extern int FmoGetLastMBOfPicture(VideoParameters *p_Vid);
|
||||
extern int FmoGetLastMBInSliceGroup(VideoParameters *p_Vid, int SliceGroup);
|
||||
extern int FmoGetSliceGroupId (VideoParameters *p_Vid, int mb);
|
||||
extern int FmoGetNextMBNr (VideoParameters *p_Vid, int CurrentMbNr);
|
||||
extern int FmoGetSliceGroupId(VideoParameters *p_Vid, int mb);
|
||||
extern int FmoGetNextMBNr(VideoParameters *p_Vid, int CurrentMbNr);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,43 +12,37 @@
|
|||
#ifndef _FRAME_H_
|
||||
#define _FRAME_H_
|
||||
|
||||
typedef enum {
|
||||
CM_UNKNOWN = -1,
|
||||
CM_YUV = 0,
|
||||
CM_RGB = 1,
|
||||
CM_XYZ = 2
|
||||
} ColorModel;
|
||||
typedef enum { CM_UNKNOWN = -1, CM_YUV = 0, CM_RGB = 1, CM_XYZ = 2 } ColorModel;
|
||||
|
||||
typedef enum {
|
||||
CF_UNKNOWN = -1, //!< Unknown color format
|
||||
YUV400 = 0, //!< Monochrome
|
||||
YUV420 = 1, //!< 4:2:0
|
||||
YUV422 = 2, //!< 4:2:2
|
||||
YUV444 = 3 //!< 4:4:4
|
||||
CF_UNKNOWN = -1, //!< Unknown color format
|
||||
YUV400 = 0, //!< Monochrome
|
||||
YUV420 = 1, //!< 4:2:0
|
||||
YUV422 = 2, //!< 4:2:2
|
||||
YUV444 = 3 //!< 4:4:4
|
||||
} ColorFormat;
|
||||
|
||||
typedef struct frame_format
|
||||
{
|
||||
ColorFormat yuv_format; //!< YUV format (0=4:0:0, 1=4:2:0, 2=4:2:2, 3=4:4:4)
|
||||
ColorModel color_model; //!< 4:4:4 format (0: YUV, 1: RGB, 2: XYZ)
|
||||
double frame_rate; //!< frame rate
|
||||
int width[3]; //!< component frame width
|
||||
int height[3]; //!< component frame height
|
||||
int auto_crop_right; //!< luma component auto crop right
|
||||
int auto_crop_bottom; //!< luma component auto crop bottom
|
||||
int auto_crop_right_cr; //!< chroma component auto crop right
|
||||
int auto_crop_bottom_cr; //!< chroma component auto crop bottom
|
||||
int width_crop; //!< width after cropping consideration
|
||||
int height_crop; //!< height after cropping consideration
|
||||
int mb_width; //!< luma component frame width
|
||||
int mb_height; //!< luma component frame height
|
||||
int size_cmp[3]; //!< component sizes (width * height)
|
||||
int size; //!< total image size (sum of size_cmp)
|
||||
int bit_depth[3]; //!< component bit depth
|
||||
int max_value[3]; //!< component max value
|
||||
int max_value_sq[3]; //!< component max value squared
|
||||
int pic_unit_size_on_disk; //!< picture sample unit size on storage medium
|
||||
int pic_unit_size_shift3; //!< pic_unit_size_on_disk >> 3
|
||||
typedef struct frame_format {
|
||||
ColorFormat yuv_format; //!< YUV format (0=4:0:0, 1=4:2:0, 2=4:2:2, 3=4:4:4)
|
||||
ColorModel color_model; //!< 4:4:4 format (0: YUV, 1: RGB, 2: XYZ)
|
||||
double frame_rate; //!< frame rate
|
||||
int width[3]; //!< component frame width
|
||||
int height[3]; //!< component frame height
|
||||
int auto_crop_right; //!< luma component auto crop right
|
||||
int auto_crop_bottom; //!< luma component auto crop bottom
|
||||
int auto_crop_right_cr; //!< chroma component auto crop right
|
||||
int auto_crop_bottom_cr; //!< chroma component auto crop bottom
|
||||
int width_crop; //!< width after cropping consideration
|
||||
int height_crop; //!< height after cropping consideration
|
||||
int mb_width; //!< luma component frame width
|
||||
int mb_height; //!< luma component frame height
|
||||
int size_cmp[3]; //!< component sizes (width * height)
|
||||
int size; //!< total image size (sum of size_cmp)
|
||||
int bit_depth[3]; //!< component bit depth
|
||||
int max_value[3]; //!< component max value
|
||||
int max_value_sq[3]; //!< component max value squared
|
||||
int pic_unit_size_on_disk; //!< picture sample unit size on storage medium
|
||||
int pic_unit_size_shift3; //!< pic_unit_size_on_disk >> 3
|
||||
} FrameFormat;
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,7 @@
|
|||
* \author
|
||||
* Copyright (C) 2009 Dolby
|
||||
* Yuwen He (yhe@dolby.com)
|
||||
*
|
||||
*
|
||||
************************************************************************
|
||||
*/
|
||||
#ifndef _H264DECODER_H_
|
||||
|
@ -16,26 +16,24 @@
|
|||
|
||||
#include "global.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
DEC_GEN_NOERR = 0,
|
||||
DEC_OPEN_NOERR = 0,
|
||||
DEC_CLOSE_NOERR = 0,
|
||||
DEC_CLOSE_NOERR = 0,
|
||||
DEC_SUCCEED = 0,
|
||||
DEC_EOS =1,
|
||||
DEC_EOS = 1,
|
||||
DEC_NEED_DATA = 2,
|
||||
DEC_INVALID_PARAM = 3,
|
||||
DEC_ERRMASK = 0x8000
|
||||
// DEC_ERRMASK = 0x80000000
|
||||
}DecErrCode;
|
||||
// DEC_ERRMASK = 0x80000000
|
||||
} DecErrCode;
|
||||
|
||||
typedef struct dec_set_t
|
||||
{
|
||||
typedef struct dec_set_t {
|
||||
int iPostprocLevel; // valid interval are [0..100]
|
||||
int bDBEnable;
|
||||
int bAllLayers;
|
||||
int time_incr;
|
||||
int bDecCompAdapt;
|
||||
int bDecCompAdapt;
|
||||
} DecSet_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
#define _HEADER_H_
|
||||
|
||||
extern int FirstPartOfSliceHeader(Slice *currSlice);
|
||||
extern int RestOfSliceHeader (Slice *currSlice);
|
||||
extern int RestOfSliceHeader(Slice *currSlice);
|
||||
|
||||
extern void dec_ref_pic_marking(VideoParameters *p_Vid, Bitstream *currStream, Slice *pSlice);
|
||||
extern void dec_ref_pic_marking(VideoParameters *p_Vid, Bitstream *currStream,
|
||||
Slice *pSlice);
|
||||
|
||||
extern void decode_poc(VideoParameters *p_Vid, Slice *pSlice);
|
||||
extern int dumppoc (VideoParameters *p_Vid);
|
||||
extern int dumppoc(VideoParameters *p_Vid);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
* define some inline functions that are used within the encoder.
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
* - Alexis Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
|
@ -19,308 +20,296 @@
|
|||
|
||||
#if !defined(SPEC)
|
||||
// For SPEC CPU always use static inline
|
||||
# if !(defined(WIN32) || defined(WIN64)) && (__STDC_VERSION__ < 199901L)
|
||||
#define static
|
||||
#define inline
|
||||
#if !(defined(WIN32) || defined(WIN64)) && (__STDC_VERSION__ < 199901L)
|
||||
#define static
|
||||
#define inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
static inline short smin(short a, short b)
|
||||
{
|
||||
return (short) (((a) < (b)) ? (a) : (b));
|
||||
static inline short smin(short a, short b) {
|
||||
return (short)(((a) < (b)) ? (a) : (b));
|
||||
}
|
||||
|
||||
static inline short smax(short a, short b)
|
||||
{
|
||||
return (short) (((a) > (b)) ? (a) : (b));
|
||||
static inline short smax(short a, short b) {
|
||||
return (short)(((a) > (b)) ? (a) : (b));
|
||||
}
|
||||
|
||||
static inline int imin(int a, int b)
|
||||
{
|
||||
return ((a) < (b)) ? (a) : (b);
|
||||
}
|
||||
static inline int imin(int a, int b) { return ((a) < (b)) ? (a) : (b); }
|
||||
|
||||
static inline int imax(int a, int b)
|
||||
{
|
||||
return ((a) > (b)) ? (a) : (b);
|
||||
}
|
||||
static inline int imax(int a, int b) { return ((a) > (b)) ? (a) : (b); }
|
||||
|
||||
static inline int imedian(int a,int b,int c)
|
||||
{
|
||||
static inline int imedian(int a, int b, int c) {
|
||||
if (a > b) // a > b
|
||||
{
|
||||
if (b > c)
|
||||
return(b); // a > b > c
|
||||
else if (a > c)
|
||||
return(c); // a > c > b
|
||||
else
|
||||
return(a); // c > a > b
|
||||
}
|
||||
else // b > a
|
||||
{
|
||||
if (a > c)
|
||||
return(a); // b > a > c
|
||||
else if (b > c)
|
||||
return(c); // b > c > a
|
||||
{
|
||||
if (b > c)
|
||||
return (b); // a > b > c
|
||||
else if (a > c)
|
||||
return (c); // a > c > b
|
||||
else
|
||||
return(b); // c > b > a
|
||||
return (a); // c > a > b
|
||||
} else // b > a
|
||||
{
|
||||
if (a > c)
|
||||
return (a); // b > a > c
|
||||
else if (b > c)
|
||||
return (c); // b > c > a
|
||||
else
|
||||
return (b); // c > b > a
|
||||
}
|
||||
}
|
||||
|
||||
static inline int imedian_old(int a, int b, int c)
|
||||
{
|
||||
return (a + b + c - imin(a, imin(b, c)) - imax(a, imax(b ,c)));
|
||||
static inline int imedian_old(int a, int b, int c) {
|
||||
return (a + b + c - imin(a, imin(b, c)) - imax(a, imax(b, c)));
|
||||
}
|
||||
|
||||
static inline double dmin(double a, double b)
|
||||
{
|
||||
static inline double dmin(double a, double b) {
|
||||
return ((a) < (b)) ? (a) : (b);
|
||||
}
|
||||
|
||||
static inline double dmax(double a, double b)
|
||||
{
|
||||
static inline double dmax(double a, double b) {
|
||||
return ((a) > (b)) ? (a) : (b);
|
||||
}
|
||||
|
||||
static inline int64 i64min(int64 a, int64 b)
|
||||
{
|
||||
static inline int64 i64min(int64 a, int64 b) { return ((a) < (b)) ? (a) : (b); }
|
||||
|
||||
static inline int64 i64max(int64 a, int64 b) { return ((a) > (b)) ? (a) : (b); }
|
||||
|
||||
static inline distblk distblkmin(distblk a, distblk b) {
|
||||
return ((a) < (b)) ? (a) : (b);
|
||||
}
|
||||
|
||||
static inline int64 i64max(int64 a, int64 b)
|
||||
{
|
||||
static inline distblk distblkmax(distblk a, distblk b) {
|
||||
return ((a) > (b)) ? (a) : (b);
|
||||
}
|
||||
|
||||
static inline distblk distblkmin(distblk a, distblk b)
|
||||
{
|
||||
return ((a) < (b)) ? (a) : (b);
|
||||
}
|
||||
|
||||
static inline distblk distblkmax(distblk a, distblk b)
|
||||
{
|
||||
return ((a) > (b)) ? (a) : (b);
|
||||
}
|
||||
|
||||
static inline short sabs(short x)
|
||||
{
|
||||
static inline short sabs(short x) {
|
||||
static const short SHORT_BITS = (sizeof(short) * CHAR_BIT) - 1;
|
||||
short y = (short) (x >> SHORT_BITS);
|
||||
return (short) ((x ^ y) - y);
|
||||
short y = (short)(x >> SHORT_BITS);
|
||||
return (short)((x ^ y) - y);
|
||||
}
|
||||
|
||||
static inline int iabs(int x)
|
||||
{
|
||||
static inline int iabs(int x) {
|
||||
static const int INT_BITS = (sizeof(int) * CHAR_BIT) - 1;
|
||||
int y = x >> INT_BITS;
|
||||
return (x ^ y) - y;
|
||||
}
|
||||
|
||||
static inline double dabs(double x)
|
||||
{
|
||||
return ((x) < 0) ? -(x) : (x);
|
||||
}
|
||||
static inline double dabs(double x) { return ((x) < 0) ? -(x) : (x); }
|
||||
|
||||
static inline int64 i64abs(int64 x)
|
||||
{
|
||||
static inline int64 i64abs(int64 x) {
|
||||
static const int64 INT64_BITS = (sizeof(int64) * CHAR_BIT) - 1;
|
||||
int64 y = x >> INT64_BITS;
|
||||
return (x ^ y) - y;
|
||||
}
|
||||
|
||||
static inline double dabs2(double x)
|
||||
{
|
||||
return (x) * (x);
|
||||
}
|
||||
static inline double dabs2(double x) { return (x) * (x); }
|
||||
|
||||
static inline int iabs2(int x)
|
||||
{
|
||||
return (x) * (x);
|
||||
}
|
||||
static inline int iabs2(int x) { return (x) * (x); }
|
||||
|
||||
static inline int64 i64abs2(int64 x)
|
||||
{
|
||||
return (x) * (x);
|
||||
}
|
||||
static inline int64 i64abs2(int64 x) { return (x) * (x); }
|
||||
|
||||
static inline int isign(int x)
|
||||
{
|
||||
return ( (x > 0) - (x < 0));
|
||||
}
|
||||
static inline int isign(int x) { return ((x > 0) - (x < 0)); }
|
||||
|
||||
static inline int isignab(int a, int b)
|
||||
{
|
||||
static inline int isignab(int a, int b) {
|
||||
return ((b) < 0) ? -iabs(a) : iabs(a);
|
||||
}
|
||||
|
||||
static inline int rshift_rnd(int x, int a)
|
||||
{
|
||||
return (a > 0) ? ((x + (1 << (a-1) )) >> a) : (x << (-a));
|
||||
static inline int rshift_rnd(int x, int a) {
|
||||
return (a > 0) ? ((x + (1 << (a - 1))) >> a) : (x << (-a));
|
||||
}
|
||||
|
||||
static inline int rshift_rnd_sign(int x, int a)
|
||||
{
|
||||
return (x > 0) ? ( ( x + (1 << (a-1)) ) >> a ) : (-( ( iabs(x) + (1 << (a-1)) ) >> a ));
|
||||
static inline int rshift_rnd_sign(int x, int a) {
|
||||
return (x > 0) ? ((x + (1 << (a - 1))) >> a)
|
||||
: (-((iabs(x) + (1 << (a - 1))) >> a));
|
||||
}
|
||||
|
||||
static inline unsigned int rshift_rnd_us(unsigned int x, unsigned int a)
|
||||
{
|
||||
return (a > 0) ? ((x + (1 << (a-1))) >> a) : x;
|
||||
static inline unsigned int rshift_rnd_us(unsigned int x, unsigned int a) {
|
||||
return (a > 0) ? ((x + (1 << (a - 1))) >> a) : x;
|
||||
}
|
||||
|
||||
static inline int rshift_rnd_sf(int x, int a)
|
||||
{
|
||||
return ((x + (1 << (a-1) )) >> a);
|
||||
static inline int rshift_rnd_sf(int x, int a) {
|
||||
return ((x + (1 << (a - 1))) >> a);
|
||||
}
|
||||
|
||||
static inline int shift_off_sf(int x, int o, int a)
|
||||
{
|
||||
return ((x + o) >> a);
|
||||
static inline int shift_off_sf(int x, int o, int a) { return ((x + o) >> a); }
|
||||
|
||||
static inline unsigned int rshift_rnd_us_sf(unsigned int x, unsigned int a) {
|
||||
return ((x + (1 << (a - 1))) >> a);
|
||||
}
|
||||
|
||||
static inline unsigned int rshift_rnd_us_sf(unsigned int x, unsigned int a)
|
||||
{
|
||||
return ((x + (1 << (a-1))) >> a);
|
||||
}
|
||||
|
||||
static inline int iClip1(int high, int x)
|
||||
{
|
||||
static inline int iClip1(int high, int x) {
|
||||
x = imax(x, 0);
|
||||
x = imin(x, high);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline int iClip3(int low, int high, int x)
|
||||
{
|
||||
static inline int iClip3(int low, int high, int x) {
|
||||
x = imax(x, low);
|
||||
x = imin(x, high);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline short sClip3(short low, short high, short x)
|
||||
{
|
||||
static inline short sClip3(short low, short high, short x) {
|
||||
x = smax(x, low);
|
||||
x = smin(x, high);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline double dClip3(double low, double high, double x)
|
||||
{
|
||||
static inline double dClip3(double low, double high, double x) {
|
||||
x = dmax(x, low);
|
||||
x = dmin(x, high);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
static inline distblk weighted_cost(int factor, int bits)
|
||||
{
|
||||
static inline distblk weighted_cost(int factor, int bits) {
|
||||
#if JCOST_CALC_SCALEUP
|
||||
return (((distblk)(factor))*((distblk)(bits)));
|
||||
return (((distblk)(factor)) * ((distblk)(bits)));
|
||||
#else
|
||||
#if (USE_RND_COST)
|
||||
return (rshift_rnd_sf((lambda) * (bits), LAMBDA_ACCURACY_BITS));
|
||||
#else
|
||||
return (((factor)*(bits))>>LAMBDA_ACCURACY_BITS);
|
||||
return (((factor) * (bits)) >> LAMBDA_ACCURACY_BITS);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int RSD(int x)
|
||||
{
|
||||
return ((x&2)?(x|1):(x&(~1)));
|
||||
}
|
||||
static inline int RSD(int x) { return ((x & 2) ? (x | 1) : (x & (~1))); }
|
||||
|
||||
static inline int power2(int x)
|
||||
{
|
||||
return 1 << (x);
|
||||
}
|
||||
static inline int power2(int x) { return 1 << (x); }
|
||||
|
||||
static const uint64 po2[64] = {0x1,
|
||||
0x2,
|
||||
0x4,
|
||||
0x8,
|
||||
0x10,
|
||||
0x20,
|
||||
0x40,
|
||||
0x80,
|
||||
0x100,
|
||||
0x200,
|
||||
0x400,
|
||||
0x800,
|
||||
0x1000,
|
||||
0x2000,
|
||||
0x4000,
|
||||
0x8000,
|
||||
0x10000,
|
||||
0x20000,
|
||||
0x40000,
|
||||
0x80000,
|
||||
0x100000,
|
||||
0x200000,
|
||||
0x400000,
|
||||
0x800000,
|
||||
0x1000000,
|
||||
0x2000000,
|
||||
0x4000000,
|
||||
0x8000000,
|
||||
0x10000000,
|
||||
0x20000000,
|
||||
0x40000000,
|
||||
0x80000000,
|
||||
0x100000000,
|
||||
0x200000000,
|
||||
0x400000000,
|
||||
0x800000000,
|
||||
0x1000000000,
|
||||
0x2000000000,
|
||||
0x4000000000,
|
||||
0x8000000000,
|
||||
0x10000000000,
|
||||
0x20000000000,
|
||||
0x40000000000,
|
||||
0x80000000000,
|
||||
0x100000000000,
|
||||
0x200000000000,
|
||||
0x400000000000,
|
||||
0x800000000000,
|
||||
0x1000000000000,
|
||||
0x2000000000000,
|
||||
0x4000000000000,
|
||||
0x8000000000000,
|
||||
0x10000000000000,
|
||||
0x20000000000000,
|
||||
0x40000000000000,
|
||||
0x80000000000000,
|
||||
0x100000000000000,
|
||||
0x200000000000000,
|
||||
0x400000000000000,
|
||||
0x800000000000000,
|
||||
0x1000000000000000,
|
||||
0x2000000000000000,
|
||||
0x4000000000000000,
|
||||
0x8000000000000000};
|
||||
|
||||
static const uint64 po2[64] = {0x1,0x2,0x4,0x8,0x10,0x20,0x40,0x80,0x100,0x200,0x400,0x800,0x1000,0x2000,0x4000,0x8000,
|
||||
0x10000,0x20000,0x40000,0x80000,0x100000,0x200000,0x400000,0x800000,0x1000000,0x2000000,0x4000000,0x8000000,
|
||||
0x10000000,0x20000000,0x40000000,0x80000000,0x100000000,0x200000000,0x400000000,0x800000000,
|
||||
0x1000000000,0x2000000000,0x4000000000,0x8000000000,0x10000000000,0x20000000000,0x40000000000,0x80000000000,
|
||||
0x100000000000,0x200000000000,0x400000000000,0x800000000000,
|
||||
0x1000000000000,0x2000000000000,0x4000000000000,0x8000000000000,
|
||||
0x10000000000000,0x20000000000000,0x40000000000000,0x80000000000000,
|
||||
0x100000000000000,0x200000000000000,0x400000000000000,0x800000000000000,
|
||||
0x1000000000000000,0x2000000000000000,0x4000000000000000,0x8000000000000000};
|
||||
static inline int64 i64_power2(int x) { return ((x > 63) ? 0 : po2[x]); }
|
||||
|
||||
static inline int64 i64_power2(int x)
|
||||
{
|
||||
return((x > 63) ? 0 : po2[x]);
|
||||
}
|
||||
|
||||
static inline int float2int (float x)
|
||||
{
|
||||
static inline int float2int(float x) {
|
||||
return (int)((x < 0) ? (x - 0.5f) : (x + 0.5f));
|
||||
}
|
||||
|
||||
static inline int get_bit(int64 x,int n)
|
||||
{
|
||||
return (int)(((x >> n) & 1));
|
||||
}
|
||||
static inline int get_bit(int64 x, int n) { return (int)(((x >> n) & 1)); }
|
||||
|
||||
#if ZEROSNR
|
||||
static inline float psnr(int max_sample_sq, int samples, float sse_distortion )
|
||||
{
|
||||
return (float) (10.0 * log10(max_sample_sq * (double) ((double) samples / (sse_distortion < 1.0 ? 1.0 : sse_distortion))));
|
||||
static inline float psnr(int max_sample_sq, int samples, float sse_distortion) {
|
||||
return (
|
||||
float)(10.0 *
|
||||
log10(max_sample_sq *
|
||||
(double)((double)samples /
|
||||
(sse_distortion < 1.0 ? 1.0 : sse_distortion))));
|
||||
}
|
||||
#else
|
||||
static inline float psnr(int max_sample_sq, int samples, float sse_distortion )
|
||||
{
|
||||
return (float) (sse_distortion == 0.0 ? 0.0 : (10.0 * log10(max_sample_sq * (double) ((double) samples / sse_distortion))));
|
||||
static inline float psnr(int max_sample_sq, int samples, float sse_distortion) {
|
||||
return (
|
||||
float)(sse_distortion == 0.0
|
||||
? 0.0
|
||||
: (10.0 * log10(max_sample_sq *
|
||||
(double)((double)samples / sse_distortion))));
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int CheckCost_Shift(int64 mcost, int64 min_mcost)
|
||||
{
|
||||
if((mcost<<LAMBDA_ACCURACY_BITS) >= min_mcost)
|
||||
static inline int CheckCost_Shift(int64 mcost, int64 min_mcost) {
|
||||
if ((mcost << LAMBDA_ACCURACY_BITS) >= min_mcost)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int CheckCost(int64 mcost, int64 min_mcost)
|
||||
{
|
||||
static inline int CheckCost(int64 mcost, int64 min_mcost) {
|
||||
return ((mcost) >= (min_mcost));
|
||||
}
|
||||
|
||||
static inline void down_scale(distblk *pblkdistCost)
|
||||
{
|
||||
static inline void down_scale(distblk *pblkdistCost) {
|
||||
#if JCOST_CALC_SCALEUP
|
||||
#if (IMGTYPE < 2)
|
||||
*pblkdistCost = (*pblkdistCost)>>LAMBDA_ACCURACY_BITS;
|
||||
*pblkdistCost = (*pblkdistCost) >> LAMBDA_ACCURACY_BITS;
|
||||
#else
|
||||
*pblkdistCost = (*pblkdistCost)/(1<<LAMBDA_ACCURACY_BITS);
|
||||
*pblkdistCost = (*pblkdistCost) / (1 << LAMBDA_ACCURACY_BITS);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void up_scale(distblk *pblkdistCost)
|
||||
{
|
||||
static inline void up_scale(distblk *pblkdistCost) {
|
||||
#if JCOST_CALC_SCALEUP
|
||||
#if (IMGTYPE < 2)
|
||||
*pblkdistCost = (*pblkdistCost)<<LAMBDA_ACCURACY_BITS;
|
||||
*pblkdistCost = (*pblkdistCost) << LAMBDA_ACCURACY_BITS;
|
||||
#else
|
||||
*pblkdistCost = (*pblkdistCost)*(1<<LAMBDA_ACCURACY_BITS);
|
||||
*pblkdistCost = (*pblkdistCost) * (1 << LAMBDA_ACCURACY_BITS);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline distblk dist_scale(distblk blkdistCost)
|
||||
{
|
||||
static inline distblk dist_scale(distblk blkdistCost) {
|
||||
#if JCOST_CALC_SCALEUP
|
||||
#if (IMGTYPE < 2)
|
||||
return ((blkdistCost)<<LAMBDA_ACCURACY_BITS);
|
||||
return ((blkdistCost) << LAMBDA_ACCURACY_BITS);
|
||||
#else
|
||||
return ((blkdistCost) *((distblk) (1<<LAMBDA_ACCURACY_BITS));
|
||||
#endif
|
||||
|
@ -329,23 +318,21 @@ static inline distblk dist_scale(distblk blkdistCost)
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline int dist_down(distblk blkdistCost)
|
||||
{
|
||||
static inline int dist_down(distblk blkdistCost) {
|
||||
#if JCOST_CALC_SCALEUP
|
||||
#if (IMGTYPE < 2)
|
||||
return ((int)((blkdistCost)>>LAMBDA_ACCURACY_BITS));
|
||||
return ((int)((blkdistCost) >> LAMBDA_ACCURACY_BITS));
|
||||
#else
|
||||
return ((int)(blkdistCost/((distblk) (1<<LAMBDA_ACCURACY_BITS))));
|
||||
return ((int)(blkdistCost / ((distblk)(1 << LAMBDA_ACCURACY_BITS))));
|
||||
#endif
|
||||
#else
|
||||
return ((int)blkdistCost);
|
||||
#endif
|
||||
}
|
||||
|
||||
# if !(defined(WIN32) || defined(WIN64)) && (__STDC_VERSION__ < 199901L)
|
||||
#undef static
|
||||
#undef inline
|
||||
#if !(defined(WIN32) || defined(WIN64)) && (__STDC_VERSION__ < 199901L)
|
||||
#undef static
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -15,29 +15,31 @@
|
|||
#include "mbuffer.h"
|
||||
|
||||
extern void calculate_frame_no(VideoParameters *p_Vid, StorablePicture *p);
|
||||
extern void find_snr (VideoParameters *p_Vid, StorablePicture *p, int *p_ref);
|
||||
extern int picture_order ( Slice *pSlice );
|
||||
extern void find_snr(VideoParameters *p_Vid, StorablePicture *p, int *p_ref);
|
||||
extern int picture_order(Slice *pSlice);
|
||||
|
||||
extern void decode_one_slice (Slice *currSlice);
|
||||
extern int read_new_slice (Slice *currSlice);
|
||||
extern void exit_picture (VideoParameters *p_Vid, StorablePicture **dec_picture);
|
||||
extern int decode_one_frame (DecoderParams *pDecoder);
|
||||
extern void decode_one_slice(Slice *currSlice);
|
||||
extern int read_new_slice(Slice *currSlice);
|
||||
extern void exit_picture(VideoParameters *p_Vid, StorablePicture **dec_picture);
|
||||
extern int decode_one_frame(DecoderParams *pDecoder);
|
||||
|
||||
extern int is_new_picture(StorablePicture *dec_picture, Slice *currSlice, OldSliceParams *p_old_slice);
|
||||
extern int is_new_picture(StorablePicture *dec_picture, Slice *currSlice,
|
||||
OldSliceParams *p_old_slice);
|
||||
extern void init_old_slice(OldSliceParams *p_old_slice);
|
||||
// For 4:4:4 independent mode
|
||||
extern void copy_dec_picture_JV (VideoParameters *p_Vid, StorablePicture *dst, StorablePicture *src );
|
||||
extern void copy_dec_picture_JV(VideoParameters *p_Vid, StorablePicture *dst,
|
||||
StorablePicture *src);
|
||||
|
||||
extern void frame_postprocessing(VideoParameters *p_Vid);
|
||||
extern void field_postprocessing(VideoParameters *p_Vid);
|
||||
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
extern int GetVOIdx(VideoParameters *p_Vid, int iViewId);
|
||||
extern int get_maxViewIdx(VideoParameters *p_Vid, int view_id, int anchor_pic_flag, int listidx);
|
||||
extern int get_maxViewIdx(VideoParameters *p_Vid, int view_id,
|
||||
int anchor_pic_flag, int listidx);
|
||||
#endif
|
||||
|
||||
extern void init_slice(VideoParameters *p_Vid, Slice *currSlice);
|
||||
extern void decode_slice(Slice *currSlice, int current_header);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* image I/O related functions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
@ -15,16 +16,16 @@
|
|||
#ifndef _IMG_IO_H_
|
||||
#define _IMG_IO_H_
|
||||
|
||||
#include "io_video.h"
|
||||
#include "io_raw.h"
|
||||
#include "io_tiff.h"
|
||||
#include "io_video.h"
|
||||
|
||||
extern int ParseSizeFromString (VideoDataFile *input_file, int *xlen, int *ylen, double *fps);
|
||||
extern void ParseFrameNoFormatFromString (VideoDataFile *input_file);
|
||||
extern void OpenFrameFile (VideoDataFile *input_file, int FrameNumberInFile);
|
||||
extern void OpenFiles (VideoDataFile *input_file);
|
||||
extern void CloseFiles (VideoDataFile *input_file);
|
||||
extern VideoFileType ParseVideoType (VideoDataFile *input_file);
|
||||
extern int ParseSizeFromString(VideoDataFile *input_file, int *xlen, int *ylen,
|
||||
double *fps);
|
||||
extern void ParseFrameNoFormatFromString(VideoDataFile *input_file);
|
||||
extern void OpenFrameFile(VideoDataFile *input_file, int FrameNumberInFile);
|
||||
extern void OpenFiles(VideoDataFile *input_file);
|
||||
extern void CloseFiles(VideoDataFile *input_file);
|
||||
extern VideoFileType ParseVideoType(VideoDataFile *input_file);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*!
|
||||
************************************************************************
|
||||
************************************************************************
|
||||
* \file img_process.h
|
||||
*
|
||||
* \brief
|
||||
* Input data Image Processing functions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Michael Tourapis <alexis.tourapis@dolby.com>
|
||||
*
|
||||
************************************************************************
|
||||
|
@ -15,11 +16,8 @@
|
|||
#ifndef _IMG_PROCESS_H_
|
||||
#define _IMG_PROCESS_H_
|
||||
|
||||
|
||||
extern int init_process_image ( VideoParameters *p_Vid, InputParameters *p_Inp );
|
||||
extern void clear_process_image( VideoParameters *p_Vid, InputParameters *p_Inp);
|
||||
extern void process_image ( VideoParameters *p_Vid, InputParameters *p_Inp );
|
||||
|
||||
|
||||
extern int init_process_image(VideoParameters *p_Vid, InputParameters *p_Inp);
|
||||
extern void clear_process_image(VideoParameters *p_Vid, InputParameters *p_Inp);
|
||||
extern void process_image(VideoParameters *p_Vid, InputParameters *p_Inp);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*!
|
||||
************************************************************************
|
||||
************************************************************************
|
||||
* \file img_process_types.h
|
||||
*
|
||||
* \brief
|
||||
* Input data Image Processing Types
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Michael Tourapis <alexis.tourapis@dolby.com>
|
||||
* - Athanasios Leontaris <aleon@dolby.com>
|
||||
*
|
||||
|
@ -16,9 +17,9 @@
|
|||
#ifndef _IMG_PROCESS_TYPES_H_
|
||||
#define _IMG_PROCESS_TYPES_H_
|
||||
|
||||
#define DEMUX_META_DEBUG 0
|
||||
#define MAX_NUM_PARTITIONS 32
|
||||
#define NUM_VIEWS 2
|
||||
#define NUM_COMPONENTS 3
|
||||
#define DEMUX_META_DEBUG 0
|
||||
#define MAX_NUM_PARTITIONS 32
|
||||
#define NUM_VIEWS 2
|
||||
#define NUM_COMPONENTS 3
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,12 +14,18 @@
|
|||
#define _INPUT_H_
|
||||
|
||||
extern int testEndian(void);
|
||||
extern void initInput(VideoParameters *p_Vid, FrameFormat *source, FrameFormat *output);
|
||||
extern void AllocateFrameMemory (VideoParameters *p_Vid, InputParameters *p_Inp, FrameFormat *source);
|
||||
extern void DeleteFrameMemory (VideoParameters *p_Vid);
|
||||
extern void initInput(VideoParameters *p_Vid, FrameFormat *source,
|
||||
FrameFormat *output);
|
||||
extern void AllocateFrameMemory(VideoParameters *p_Vid, InputParameters *p_Inp,
|
||||
FrameFormat *source);
|
||||
extern void DeleteFrameMemory(VideoParameters *p_Vid);
|
||||
|
||||
extern int read_one_frame (VideoParameters *p_Vid, VideoDataFile *input_file, int FrameNoInFile, int HeaderSize, FrameFormat *source, FrameFormat *output, imgpel **pImage[3]);
|
||||
extern void pad_borders ( FrameFormat output, int img_size_x, int img_size_y, int img_size_x_cr, int img_size_y_cr, imgpel **pImage[3]);
|
||||
extern int read_one_frame(VideoParameters *p_Vid, VideoDataFile *input_file,
|
||||
int FrameNoInFile, int HeaderSize,
|
||||
FrameFormat *source, FrameFormat *output,
|
||||
imgpel **pImage[3]);
|
||||
extern void pad_borders(FrameFormat output, int img_size_x, int img_size_y,
|
||||
int img_size_x_cr, int img_size_y_cr,
|
||||
imgpel **pImage[3]);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* definitions for intra 16x16 prediction
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* address and affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
|
@ -22,4 +22,3 @@
|
|||
extern int intrapred16x16(Macroblock *currMB, ColorPlane pl, int b8);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* definitions for intra 4x4 prediction
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* address and affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
|
@ -19,7 +19,7 @@
|
|||
#include "global.h"
|
||||
#include "mbuffer.h"
|
||||
|
||||
extern int intrapred(Macroblock *currMB, ColorPlane pl, int ioff, int joff, int img_block_x, int img_block_y);
|
||||
extern int intrapred(Macroblock *currMB, ColorPlane pl, int ioff, int joff,
|
||||
int img_block_x, int img_block_y);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* definitions for intra 8x8 prediction
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* address and affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
|
@ -22,4 +22,3 @@
|
|||
extern int intrapred8x8(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* \file io_image.h
|
||||
*
|
||||
* \brief
|
||||
* Image I/O
|
||||
* Image I/O
|
||||
*
|
||||
* \author
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
|
@ -17,20 +17,19 @@
|
|||
#include "defines.h"
|
||||
#include "frame.h"
|
||||
|
||||
typedef struct image_data
|
||||
{
|
||||
FrameFormat format; //!< image format
|
||||
typedef struct image_data {
|
||||
FrameFormat format; //!< image format
|
||||
// Standard data
|
||||
imgpel **frm_data[MAX_PLANE]; //!< Frame Data
|
||||
imgpel **top_data[MAX_PLANE]; //!< pointers to top field data
|
||||
imgpel **bot_data[MAX_PLANE]; //!< pointers to bottom field data
|
||||
|
||||
imgpel **frm_data[MAX_PLANE]; //!< Frame Data
|
||||
imgpel **top_data[MAX_PLANE]; //!< pointers to top field data
|
||||
imgpel **bot_data[MAX_PLANE]; //!< pointers to bottom field data
|
||||
|
||||
//! Optional data (could also add uint8 data in case imgpel is of type uint16)
|
||||
//! These can be useful for enabling input/conversion of content of different types
|
||||
//! while keeping optimal processing size.
|
||||
uint16 **frm_uint16[MAX_PLANE]; //!< optional frame Data for uint16
|
||||
uint16 **top_uint16[MAX_PLANE]; //!< optional pointers to top field data
|
||||
uint16 **bot_uint16[MAX_PLANE]; //!< optional pointers to bottom field data
|
||||
//! These can be useful for enabling input/conversion of content of different
|
||||
//! types while keeping optimal processing size.
|
||||
uint16 **frm_uint16[MAX_PLANE]; //!< optional frame Data for uint16
|
||||
uint16 **top_uint16[MAX_PLANE]; //!< optional pointers to top field data
|
||||
uint16 **bot_uint16[MAX_PLANE]; //!< optional pointers to bottom field data
|
||||
|
||||
int frm_stride[MAX_PLANE];
|
||||
int top_stride[MAX_PLANE];
|
||||
|
@ -38,4 +37,3 @@ typedef struct image_data
|
|||
} ImageData;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -15,8 +15,12 @@
|
|||
#ifndef _IO_RAW_H_
|
||||
#define _IO_RAW_H_
|
||||
|
||||
extern int ReadFrameConcatenated (InputParameters *p_Inp, VideoDataFile *input_file, int FrameNoInFile, int HeaderSize, FrameFormat *source, unsigned char *buf);
|
||||
extern int ReadFrameSeparate (InputParameters *p_Inp, VideoDataFile *input_file, int FrameNoInFile, int HeaderSize, FrameFormat *source, unsigned char *buf);
|
||||
extern int ReadFrameConcatenated(InputParameters *p_Inp,
|
||||
VideoDataFile *input_file, int FrameNoInFile,
|
||||
int HeaderSize, FrameFormat *source,
|
||||
unsigned char *buf);
|
||||
extern int ReadFrameSeparate(InputParameters *p_Inp, VideoDataFile *input_file,
|
||||
int FrameNoInFile, int HeaderSize,
|
||||
FrameFormat *source, unsigned char *buf);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
// See TIFF 6.0 Specification
|
||||
// http://partners.adobe.com/public/developer/tiff/index.html
|
||||
|
||||
|
||||
extern int ReadTIFFImage (InputParameters *p_Inp, VideoDataFile *input_file, int FrameNoInFile, FrameFormat *source, unsigned char *buf);
|
||||
extern int ReadTIFFImage(InputParameters *p_Inp, VideoDataFile *input_file,
|
||||
int FrameNoInFile, FrameFormat *source,
|
||||
unsigned char *buf);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* \file io_video.h
|
||||
*
|
||||
* \brief
|
||||
* Video I/O
|
||||
* Video I/O
|
||||
*
|
||||
* \author
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
|
@ -17,47 +17,47 @@
|
|||
#include "frame.h"
|
||||
|
||||
typedef struct video_size {
|
||||
char* name;
|
||||
char *name;
|
||||
int x_size;
|
||||
int y_size;
|
||||
} VIDEO_SIZE;
|
||||
|
||||
typedef enum {
|
||||
VIDEO_UNKNOWN = -1,
|
||||
VIDEO_YUV = 0,
|
||||
VIDEO_RGB = 1,
|
||||
VIDEO_XYZ = 2,
|
||||
VIDEO_TIFF = 3,
|
||||
VIDEO_AVI = 4
|
||||
VIDEO_YUV = 0,
|
||||
VIDEO_RGB = 1,
|
||||
VIDEO_XYZ = 2,
|
||||
VIDEO_TIFF = 3,
|
||||
VIDEO_AVI = 4
|
||||
} VideoFileType;
|
||||
|
||||
typedef struct video_data_file
|
||||
{
|
||||
//char* fname; //!< video file name
|
||||
char fname[FILE_NAME_SIZE]; //!< video file name
|
||||
char fhead[FILE_NAME_SIZE]; //!< header of video file
|
||||
char ftail[FILE_NAME_SIZE]; //!< tail of video file
|
||||
int f_num; //!< video file number
|
||||
VideoFileType vdtype; //!< File format
|
||||
FrameFormat format; //!< video format information
|
||||
int is_concatenated; //!< Single or multifile input?
|
||||
int is_interleaved; //!< Support for interleaved and non-interleaved input sources
|
||||
int zero_pad; //!< Used when separate image files are used as input. Enables zero padding for file numbering
|
||||
int num_digits; //!< Number of digits for file numbering
|
||||
int start_frame; //!< start frame
|
||||
int end_frame; //!< end frame
|
||||
int nframes; //!< number of frames
|
||||
int crop_x_size; //!< crop information (x component)
|
||||
int crop_y_size; //!< crop information (y component)
|
||||
int crop_x_offset; //!< crop offset (x component);
|
||||
int crop_y_offset; //!< crop offset (y component);
|
||||
typedef struct video_data_file {
|
||||
// char* fname; //!< video file name
|
||||
char fname[FILE_NAME_SIZE]; //!< video file name
|
||||
char fhead[FILE_NAME_SIZE]; //!< header of video file
|
||||
char ftail[FILE_NAME_SIZE]; //!< tail of video file
|
||||
int f_num; //!< video file number
|
||||
VideoFileType vdtype; //!< File format
|
||||
FrameFormat format; //!< video format information
|
||||
int is_concatenated; //!< Single or multifile input?
|
||||
int is_interleaved; //!< Support for interleaved and non-interleaved input
|
||||
//!< sources
|
||||
int zero_pad; //!< Used when separate image files are used as input. Enables
|
||||
//!< zero padding for file numbering
|
||||
int num_digits; //!< Number of digits for file numbering
|
||||
int start_frame; //!< start frame
|
||||
int end_frame; //!< end frame
|
||||
int nframes; //!< number of frames
|
||||
int crop_x_size; //!< crop information (x component)
|
||||
int crop_y_size; //!< crop information (y component)
|
||||
int crop_x_offset; //!< crop offset (x component);
|
||||
int crop_y_offset; //!< crop offset (y component);
|
||||
|
||||
// AVI related information to be added here
|
||||
int* avi;
|
||||
//avi_t* avi;
|
||||
//int header;
|
||||
//char compressor[8];
|
||||
int *avi;
|
||||
// avi_t* avi;
|
||||
// int header;
|
||||
// char compressor[8];
|
||||
} VideoDataFile;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*!
|
||||
**************************************************************************
|
||||
* \file lagrangian.h
|
||||
* \brief
|
||||
* \brief
|
||||
* Distortion data header file
|
||||
* \date 2.23.2009,
|
||||
*
|
||||
* \author
|
||||
* \author
|
||||
* Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
**************************************************************************
|
||||
|
@ -14,12 +14,10 @@
|
|||
#ifndef _LAGRANGIAN_H_
|
||||
#define _LAGRANGIAN_H_
|
||||
|
||||
typedef struct lambda_params
|
||||
{
|
||||
double md; //!< Mode decision Lambda
|
||||
double me[3]; //!< Motion Estimation Lambda
|
||||
int mf[3]; //!< Integer formatted Motion Estimation Lambda
|
||||
typedef struct lambda_params {
|
||||
double md; //!< Mode decision Lambda
|
||||
double me[3]; //!< Motion Estimation Lambda
|
||||
int mf[3]; //!< Integer formatted Motion Estimation Lambda
|
||||
} LambdaParams;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
* Header for Leaky Buffer parameters
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Shankar Regunathan <shanre@microsoft.com>
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
@ -23,4 +24,3 @@ void calc_buffer(InputParameters *p_Inp);
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
* \brief
|
||||
* Headerfile for loopfilter processing
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
|
||||
**************************************************************************
|
||||
*/
|
||||
|
@ -20,49 +21,61 @@
|
|||
|
||||
#include "global.h"
|
||||
|
||||
|
||||
#define GROUP_SIZE 1
|
||||
#define GROUP_SIZE 1
|
||||
|
||||
/*********************************************************************************************************/
|
||||
|
||||
// NOTE: In principle, the alpha and beta tables are calculated with the formulas below
|
||||
// NOTE: In principle, the alpha and beta tables are calculated with the
|
||||
// formulas below
|
||||
// Alpha( qp ) = 0.8 * (2^(qp/6) - 1)
|
||||
// Beta ( qp ) = 0.5 * qp - 7
|
||||
|
||||
// The tables actually used have been "hand optimized" though (by Anthony Joch). So, the
|
||||
// table values might be a little different to formula-generated values. Also, the first
|
||||
// few values of both tables is set to zero to force the filter off at low qp’s
|
||||
// The tables actually used have been "hand optimized" though (by Anthony Joch).
|
||||
// So, the table values might be a little different to formula-generated values.
|
||||
// Also, the first few values of both tables is set to zero to force the filter
|
||||
// off at low qp’s
|
||||
|
||||
static const byte ALPHA_TABLE[52] = {0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,4,4,5,6, 7,8,9,10,12,13,15,17, 20,22,25,28,32,36,40,45, 50,56,63,71,80,90,101,113, 127,144,162,182,203,226,255,255} ;
|
||||
static const byte BETA_TABLE[52] = {0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,2,2,2,3, 3,3,3, 4, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10, 11,11,12,12,13,13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18} ;
|
||||
static const byte CLIP_TAB[52][5] =
|
||||
{
|
||||
{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0, 0},{ 0, 0, 0, 1, 1},{ 0, 0, 0, 1, 1},{ 0, 0, 0, 1, 1},{ 0, 0, 0, 1, 1},{ 0, 0, 1, 1, 1},{ 0, 0, 1, 1, 1},{ 0, 1, 1, 1, 1},
|
||||
{ 0, 1, 1, 1, 1},{ 0, 1, 1, 1, 1},{ 0, 1, 1, 1, 1},{ 0, 1, 1, 2, 2},{ 0, 1, 1, 2, 2},{ 0, 1, 1, 2, 2},{ 0, 1, 1, 2, 2},{ 0, 1, 2, 3, 3},
|
||||
{ 0, 1, 2, 3, 3},{ 0, 2, 2, 3, 3},{ 0, 2, 2, 4, 4},{ 0, 2, 3, 4, 4},{ 0, 2, 3, 4, 4},{ 0, 3, 3, 5, 5},{ 0, 3, 4, 6, 6},{ 0, 3, 4, 6, 6},
|
||||
{ 0, 4, 5, 7, 7},{ 0, 4, 5, 8, 8},{ 0, 4, 6, 9, 9},{ 0, 5, 7,10,10},{ 0, 6, 8,11,11},{ 0, 6, 8,13,13},{ 0, 7,10,14,14},{ 0, 8,11,16,16},
|
||||
{ 0, 9,12,18,18},{ 0,10,13,20,20},{ 0,11,15,23,23},{ 0,13,17,25,25}
|
||||
} ;
|
||||
static const byte ALPHA_TABLE[52] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 4, 4, 5, 6, 7, 8, 9, 10, 12, 13,
|
||||
15, 17, 20, 22, 25, 28, 32, 36, 40, 45, 50, 56, 63,
|
||||
71, 80, 90, 101, 113, 127, 144, 162, 182, 203, 226, 255, 255};
|
||||
static const byte BETA_TABLE[52] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,
|
||||
2, 3, 3, 3, 3, 4, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
|
||||
11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18};
|
||||
static const byte CLIP_TAB[52][5] = {
|
||||
{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 1, 1},
|
||||
{0, 0, 0, 1, 1}, {0, 0, 0, 1, 1}, {0, 0, 0, 1, 1},
|
||||
{0, 0, 1, 1, 1}, {0, 0, 1, 1, 1}, {0, 1, 1, 1, 1},
|
||||
{0, 1, 1, 1, 1}, {0, 1, 1, 1, 1}, {0, 1, 1, 1, 1},
|
||||
{0, 1, 1, 2, 2}, {0, 1, 1, 2, 2}, {0, 1, 1, 2, 2},
|
||||
{0, 1, 1, 2, 2}, {0, 1, 2, 3, 3}, {0, 1, 2, 3, 3},
|
||||
{0, 2, 2, 3, 3}, {0, 2, 2, 4, 4}, {0, 2, 3, 4, 4},
|
||||
{0, 2, 3, 4, 4}, {0, 3, 3, 5, 5}, {0, 3, 4, 6, 6},
|
||||
{0, 3, 4, 6, 6}, {0, 4, 5, 7, 7}, {0, 4, 5, 8, 8},
|
||||
{0, 4, 6, 9, 9}, {0, 5, 7, 10, 10}, {0, 6, 8, 11, 11},
|
||||
{0, 6, 8, 13, 13}, {0, 7, 10, 14, 14}, {0, 8, 11, 16, 16},
|
||||
{0, 9, 12, 18, 18}, {0, 10, 13, 20, 20}, {0, 11, 15, 23, 23},
|
||||
{0, 13, 17, 25, 25}};
|
||||
|
||||
static const signed char chroma_edge[2][4][4] = //[dir][edge][yuv_format]
|
||||
{ { {-4, 0, 0, 0},
|
||||
{-4,-4,-4, 4},
|
||||
{-4, 4, 4, 8},
|
||||
{-4,-4,-4, 12}},
|
||||
{{{-4, 0, 0, 0}, {-4, -4, -4, 4}, {-4, 4, 4, 8}, {-4, -4, -4, 12}},
|
||||
|
||||
{ {-4, 0, 0, 0},
|
||||
{-4,-4, 4, 4},
|
||||
{-4, 4, 8, 8},
|
||||
{-4,-4, 12, 12}}};
|
||||
{{-4, 0, 0, 0}, {-4, -4, 4, 4}, {-4, 4, 8, 8}, {-4, -4, 12, 12}}};
|
||||
|
||||
static const int pelnum_cr[2][4] = {{0,8,16,16}, {0,8, 8,16}}; //[dir:0=vert, 1=hor.][yuv_format]
|
||||
static const int pelnum_cr[2][4] = {
|
||||
{0, 8, 16, 16}, {0, 8, 8, 16}}; //[dir:0=vert, 1=hor.][yuv_format]
|
||||
|
||||
|
||||
static inline int compare_mvs(const MotionVector *mv0, const MotionVector *mv1, int mvlimit)
|
||||
{
|
||||
return ((iabs( mv0->mv_x - mv1->mv_x) >= 4) | (iabs( mv0->mv_y - mv1->mv_y) >= mvlimit));
|
||||
static inline int compare_mvs(const MotionVector *mv0, const MotionVector *mv1,
|
||||
int mvlimit) {
|
||||
return ((iabs(mv0->mv_x - mv1->mv_x) >= 4) |
|
||||
(iabs(mv0->mv_y - mv1->mv_y) >= mvlimit));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
#include "global.h"
|
||||
#include "mbuffer.h"
|
||||
|
||||
extern void DeblockPicture(VideoParameters *p_Vid, StorablePicture *p) ;
|
||||
extern void DeblockPicturePartially(VideoParameters *p_Vid, StorablePicture *p, int iStart, int iEnd) ;
|
||||
void init_Deblock(VideoParameters *p_Vid, int mb_aff_frame_flag);
|
||||
extern void DeblockPicture(VideoParameters *p_Vid, StorablePicture *p);
|
||||
extern void DeblockPicturePartially(VideoParameters *p_Vid, StorablePicture *p,
|
||||
int iStart, int iEnd);
|
||||
void init_Deblock(VideoParameters *p_Vid, int mb_aff_frame_flag);
|
||||
#endif //_LOOPFILTER_H_
|
||||
|
|
|
@ -14,139 +14,116 @@
|
|||
#ifndef _MACROBLOCK_H_
|
||||
#define _MACROBLOCK_H_
|
||||
|
||||
#include "block.h"
|
||||
#include "global.h"
|
||||
#include "mbuffer.h"
|
||||
#include "block.h"
|
||||
|
||||
//! single scan pattern
|
||||
static const byte SNGL_SCAN[16][2] =
|
||||
{
|
||||
{0,0},{1,0},{0,1},{0,2},
|
||||
{1,1},{2,0},{3,0},{2,1},
|
||||
{1,2},{0,3},{1,3},{2,2},
|
||||
{3,1},{3,2},{2,3},{3,3}
|
||||
};
|
||||
static const byte SNGL_SCAN[16][2] = {
|
||||
{0, 0}, {1, 0}, {0, 1}, {0, 2}, {1, 1}, {2, 0}, {3, 0}, {2, 1},
|
||||
{1, 2}, {0, 3}, {1, 3}, {2, 2}, {3, 1}, {3, 2}, {2, 3}, {3, 3}};
|
||||
|
||||
//! field scan pattern
|
||||
static const byte FIELD_SCAN[16][2] =
|
||||
{
|
||||
{0,0},{0,1},{1,0},{0,2},
|
||||
{0,3},{1,1},{1,2},{1,3},
|
||||
{2,0},{2,1},{2,2},{2,3},
|
||||
{3,0},{3,1},{3,2},{3,3}
|
||||
};
|
||||
static const byte FIELD_SCAN[16][2] = {
|
||||
{0, 0}, {0, 1}, {1, 0}, {0, 2}, {0, 3}, {1, 1}, {1, 2}, {1, 3},
|
||||
{2, 0}, {2, 1}, {2, 2}, {2, 3}, {3, 0}, {3, 1}, {3, 2}, {3, 3}};
|
||||
|
||||
//! used to control block sizes : Not used/16x16/16x8/8x16/8x8/8x4/4x8/4x4
|
||||
static const int BLOCK_STEP[8][2]=
|
||||
{
|
||||
{0,0},{4,4},{4,2},{2,4},{2,2},{2,1},{1,2},{1,1}
|
||||
};
|
||||
static const int BLOCK_STEP[8][2] = {{0, 0}, {4, 4}, {4, 2}, {2, 4},
|
||||
{2, 2}, {2, 1}, {1, 2}, {1, 1}};
|
||||
|
||||
//! single scan pattern
|
||||
static const byte SNGL_SCAN8x8[64][2] = {
|
||||
{0,0}, {1,0}, {0,1}, {0,2}, {1,1}, {2,0}, {3,0}, {2,1}, {1,2}, {0,3}, {0,4}, {1,3}, {2,2}, {3,1}, {4,0}, {5,0},
|
||||
{4,1}, {3,2}, {2,3}, {1,4}, {0,5}, {0,6}, {1,5}, {2,4}, {3,3}, {4,2}, {5,1}, {6,0}, {7,0}, {6,1}, {5,2}, {4,3},
|
||||
{3,4}, {2,5}, {1,6}, {0,7}, {1,7}, {2,6}, {3,5}, {4,4}, {5,3}, {6,2}, {7,1}, {7,2}, {6,3}, {5,4}, {4,5}, {3,6},
|
||||
{2,7}, {3,7}, {4,6}, {5,5}, {6,4}, {7,3}, {7,4}, {6,5}, {5,6}, {4,7}, {5,7}, {6,6}, {7,5}, {7,6}, {6,7}, {7,7}
|
||||
};
|
||||
|
||||
{0, 0}, {1, 0}, {0, 1}, {0, 2}, {1, 1}, {2, 0}, {3, 0}, {2, 1},
|
||||
{1, 2}, {0, 3}, {0, 4}, {1, 3}, {2, 2}, {3, 1}, {4, 0}, {5, 0},
|
||||
{4, 1}, {3, 2}, {2, 3}, {1, 4}, {0, 5}, {0, 6}, {1, 5}, {2, 4},
|
||||
{3, 3}, {4, 2}, {5, 1}, {6, 0}, {7, 0}, {6, 1}, {5, 2}, {4, 3},
|
||||
{3, 4}, {2, 5}, {1, 6}, {0, 7}, {1, 7}, {2, 6}, {3, 5}, {4, 4},
|
||||
{5, 3}, {6, 2}, {7, 1}, {7, 2}, {6, 3}, {5, 4}, {4, 5}, {3, 6},
|
||||
{2, 7}, {3, 7}, {4, 6}, {5, 5}, {6, 4}, {7, 3}, {7, 4}, {6, 5},
|
||||
{5, 6}, {4, 7}, {5, 7}, {6, 6}, {7, 5}, {7, 6}, {6, 7}, {7, 7}};
|
||||
|
||||
//! field scan pattern
|
||||
static const byte FIELD_SCAN8x8[64][2] = { // 8x8
|
||||
{0,0}, {0,1}, {0,2}, {1,0}, {1,1}, {0,3}, {0,4}, {1,2}, {2,0}, {1,3}, {0,5}, {0,6}, {0,7}, {1,4}, {2,1}, {3,0},
|
||||
{2,2}, {1,5}, {1,6}, {1,7}, {2,3}, {3,1}, {4,0}, {3,2}, {2,4}, {2,5}, {2,6}, {2,7}, {3,3}, {4,1}, {5,0}, {4,2},
|
||||
{3,4}, {3,5}, {3,6}, {3,7}, {4,3}, {5,1}, {6,0}, {5,2}, {4,4}, {4,5}, {4,6}, {4,7}, {5,3}, {6,1}, {6,2}, {5,4},
|
||||
{5,5}, {5,6}, {5,7}, {6,3}, {7,0}, {7,1}, {6,4}, {6,5}, {6,6}, {6,7}, {7,2}, {7,3}, {7,4}, {7,5}, {7,6}, {7,7}
|
||||
};
|
||||
static const byte FIELD_SCAN8x8[64][2] = { // 8x8
|
||||
{0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, {0, 4}, {1, 2},
|
||||
{2, 0}, {1, 3}, {0, 5}, {0, 6}, {0, 7}, {1, 4}, {2, 1}, {3, 0},
|
||||
{2, 2}, {1, 5}, {1, 6}, {1, 7}, {2, 3}, {3, 1}, {4, 0}, {3, 2},
|
||||
{2, 4}, {2, 5}, {2, 6}, {2, 7}, {3, 3}, {4, 1}, {5, 0}, {4, 2},
|
||||
{3, 4}, {3, 5}, {3, 6}, {3, 7}, {4, 3}, {5, 1}, {6, 0}, {5, 2},
|
||||
{4, 4}, {4, 5}, {4, 6}, {4, 7}, {5, 3}, {6, 1}, {6, 2}, {5, 4},
|
||||
{5, 5}, {5, 6}, {5, 7}, {6, 3}, {7, 0}, {7, 1}, {6, 4}, {6, 5},
|
||||
{6, 6}, {6, 7}, {7, 2}, {7, 3}, {7, 4}, {7, 5}, {7, 6}, {7, 7}};
|
||||
|
||||
//! single scan pattern
|
||||
static const byte SCAN_YUV422[8][2] =
|
||||
{
|
||||
{0,0},{0,1},
|
||||
{1,0},{0,2},
|
||||
{0,3},{1,1},
|
||||
{1,2},{1,3}
|
||||
};
|
||||
static const byte SCAN_YUV422[8][2] = {{0, 0}, {0, 1}, {1, 0}, {0, 2},
|
||||
{0, 3}, {1, 1}, {1, 2}, {1, 3}};
|
||||
|
||||
static const unsigned char cbp_blk_chroma[8][4] =
|
||||
{ {16, 17, 18, 19},
|
||||
{20, 21, 22, 23},
|
||||
{24, 25, 26, 27},
|
||||
{28, 29, 30, 31},
|
||||
{32, 33, 34, 35},
|
||||
{36, 37, 38, 39},
|
||||
{40, 41, 42, 43},
|
||||
{44, 45, 46, 47}
|
||||
};
|
||||
static const unsigned char cbp_blk_chroma[8][4] = {
|
||||
{16, 17, 18, 19}, {20, 21, 22, 23}, {24, 25, 26, 27}, {28, 29, 30, 31},
|
||||
{32, 33, 34, 35}, {36, 37, 38, 39}, {40, 41, 42, 43}, {44, 45, 46, 47}};
|
||||
|
||||
static const unsigned char cofuv_blk_x[3][8][4] =
|
||||
{ { {0, 1, 0, 1},
|
||||
{0, 1, 0, 1},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0} },
|
||||
static const unsigned char cofuv_blk_x[3][8][4] = {{{0, 1, 0, 1},
|
||||
{0, 1, 0, 1},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0}},
|
||||
|
||||
{ {0, 1, 0, 1},
|
||||
{0, 1, 0, 1},
|
||||
{0, 1, 0, 1},
|
||||
{0, 1, 0, 1},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0} },
|
||||
{{0, 1, 0, 1},
|
||||
{0, 1, 0, 1},
|
||||
{0, 1, 0, 1},
|
||||
{0, 1, 0, 1},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0}},
|
||||
|
||||
{ {0, 1, 0, 1},
|
||||
{2, 3, 2, 3},
|
||||
{0, 1, 0, 1},
|
||||
{2, 3, 2, 3},
|
||||
{0, 1, 0, 1},
|
||||
{2, 3, 2, 3},
|
||||
{0, 1, 0, 1},
|
||||
{2, 3, 2, 3} }
|
||||
};
|
||||
{{0, 1, 0, 1},
|
||||
{2, 3, 2, 3},
|
||||
{0, 1, 0, 1},
|
||||
{2, 3, 2, 3},
|
||||
{0, 1, 0, 1},
|
||||
{2, 3, 2, 3},
|
||||
{0, 1, 0, 1},
|
||||
{2, 3, 2, 3}}};
|
||||
|
||||
static const unsigned char cofuv_blk_y[3][8][4] =
|
||||
{
|
||||
{ { 0, 0, 1, 1},
|
||||
{ 0, 0, 1, 1},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0} },
|
||||
static const unsigned char cofuv_blk_y[3][8][4] = {{{0, 0, 1, 1},
|
||||
{0, 0, 1, 1},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0}},
|
||||
|
||||
{ { 0, 0, 1, 1},
|
||||
{ 2, 2, 3, 3},
|
||||
{ 0, 0, 1, 1},
|
||||
{ 2, 2, 3, 3},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0} },
|
||||
|
||||
{ { 0, 0, 1, 1},
|
||||
{ 0, 0, 1, 1},
|
||||
{ 2, 2, 3, 3},
|
||||
{ 2, 2, 3, 3},
|
||||
{ 0, 0, 1, 1},
|
||||
{ 0, 0, 1, 1},
|
||||
{ 2, 2, 3, 3},
|
||||
{ 2, 2, 3, 3}}
|
||||
};
|
||||
{{0, 0, 1, 1},
|
||||
{2, 2, 3, 3},
|
||||
{0, 0, 1, 1},
|
||||
{2, 2, 3, 3},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0}},
|
||||
|
||||
{{0, 0, 1, 1},
|
||||
{0, 0, 1, 1},
|
||||
{2, 2, 3, 3},
|
||||
{2, 2, 3, 3},
|
||||
{0, 0, 1, 1},
|
||||
{0, 0, 1, 1},
|
||||
{2, 2, 3, 3},
|
||||
{2, 2, 3, 3}}};
|
||||
|
||||
extern void setup_slice_methods(Slice *currSlice);
|
||||
extern void get_neighbors(Macroblock *currMB, PixelPos *block, int mb_x, int mb_y, int blockshape_x);
|
||||
|
||||
extern void start_macroblock (Slice *currSlice, Macroblock **currMB);
|
||||
extern int decode_one_macroblock(Macroblock *currMB, StorablePicture *dec_picture);
|
||||
extern Boolean exit_macroblock (Slice *currSlice, int eos_bit);
|
||||
extern void update_qp (Macroblock *currMB, int qp);
|
||||
extern void get_neighbors(Macroblock *currMB, PixelPos *block, int mb_x,
|
||||
int mb_y, int blockshape_x);
|
||||
|
||||
extern void start_macroblock(Slice *currSlice, Macroblock **currMB);
|
||||
extern int decode_one_macroblock(Macroblock *currMB,
|
||||
StorablePicture *dec_picture);
|
||||
extern Boolean exit_macroblock(Slice *currSlice, int eos_bit);
|
||||
extern void update_qp(Macroblock *currMB, int qp);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
* Functions for macroblock neighborhoods
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
||||
|
@ -18,14 +19,18 @@
|
|||
|
||||
extern void CheckAvailabilityOfNeighbors(Macroblock *currMB);
|
||||
|
||||
extern void getAffNeighbour (Macroblock *currMB, int xN, int yN, int mb_size[2], PixelPos *pix);
|
||||
extern void getNonAffNeighbour (Macroblock *currMB, int xN, int yN, int mb_size[2], PixelPos *pix);
|
||||
extern void get4x4Neighbour (Macroblock *currMB, int xN, int yN, int mb_size[2], PixelPos *pix);
|
||||
extern void get4x4NeighbourBase (Macroblock *currMB, int block_x, int block_y, int mb_size[2], PixelPos *pix);
|
||||
extern Boolean mb_is_available (int mbAddr, Macroblock *currMB);
|
||||
extern void get_mb_pos (VideoParameters *p_Vid, int mb_addr, int mb_size[2], short *x, short *y);
|
||||
extern void get_mb_block_pos_normal (int mb_addr, short *x, short *y);
|
||||
extern void get_mb_block_pos_mbaff (int mb_addr, short *x, short *y);
|
||||
|
||||
extern void getAffNeighbour(Macroblock *currMB, int xN, int yN, int mb_size[2],
|
||||
PixelPos *pix);
|
||||
extern void getNonAffNeighbour(Macroblock *currMB, int xN, int yN,
|
||||
int mb_size[2], PixelPos *pix);
|
||||
extern void get4x4Neighbour(Macroblock *currMB, int xN, int yN, int mb_size[2],
|
||||
PixelPos *pix);
|
||||
extern void get4x4NeighbourBase(Macroblock *currMB, int block_x, int block_y,
|
||||
int mb_size[2], PixelPos *pix);
|
||||
extern Boolean mb_is_available(int mbAddr, Macroblock *currMB);
|
||||
extern void get_mb_pos(VideoParameters *p_Vid, int mb_addr, int mb_size[2],
|
||||
short *x, short *y);
|
||||
extern void get_mb_block_pos_normal(int mb_addr, short *x, short *y);
|
||||
extern void get_mb_block_pos_mbaff(int mb_addr, short *x, short *y);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,29 +7,48 @@
|
|||
* Functions for macroblock prediction
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _MB_PREDICTION_H_
|
||||
#define _MB_PREDICTION_H_
|
||||
|
||||
extern int mb_pred_intra4x4 (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
||||
extern int mb_pred_intra16x16 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
||||
extern int mb_pred_intra8x8 (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
||||
extern int mb_pred_intra4x4(Macroblock *currMB, ColorPlane curr_plane,
|
||||
imgpel **currImg, StorablePicture *dec_picture);
|
||||
extern int mb_pred_intra16x16(Macroblock *currMB, ColorPlane curr_plane,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_intra8x8(Macroblock *currMB, ColorPlane curr_plane,
|
||||
imgpel **currImg, StorablePicture *dec_picture);
|
||||
|
||||
extern int mb_pred_skip (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
||||
extern int mb_pred_sp_skip (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
||||
extern int mb_pred_p_inter8x8 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
||||
extern int mb_pred_p_inter16x16 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
||||
extern int mb_pred_p_inter16x8 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
||||
extern int mb_pred_p_inter8x16 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
||||
extern int mb_pred_b_d4x4spatial (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
||||
extern int mb_pred_b_d8x8spatial (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
||||
extern int mb_pred_b_d4x4temporal(Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
||||
extern int mb_pred_b_d8x8temporal(Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
||||
extern int mb_pred_b_inter8x8 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
||||
extern int mb_pred_ipcm (Macroblock *currMB);
|
||||
extern int mb_pred_skip(Macroblock *currMB, ColorPlane curr_plane,
|
||||
imgpel **currImg, StorablePicture *dec_picture);
|
||||
extern int mb_pred_sp_skip(Macroblock *currMB, ColorPlane curr_plane,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_p_inter8x8(Macroblock *currMB, ColorPlane curr_plane,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_p_inter16x16(Macroblock *currMB, ColorPlane curr_plane,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_p_inter16x8(Macroblock *currMB, ColorPlane curr_plane,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_p_inter8x16(Macroblock *currMB, ColorPlane curr_plane,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_b_d4x4spatial(Macroblock *currMB, ColorPlane curr_plane,
|
||||
imgpel **currImg,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_b_d8x8spatial(Macroblock *currMB, ColorPlane curr_plane,
|
||||
imgpel **currImg,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_b_d4x4temporal(Macroblock *currMB, ColorPlane curr_plane,
|
||||
imgpel **currImg,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_b_d8x8temporal(Macroblock *currMB, ColorPlane curr_plane,
|
||||
imgpel **currImg,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_b_inter8x8(Macroblock *currMB, ColorPlane curr_plane,
|
||||
StorablePicture *dec_picture);
|
||||
extern int mb_pred_ipcm(Macroblock *currMB);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
* Frame buffer functions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
affiliation details)
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
|
||||
|
||||
* - Jill Boyce <jill.boyce@thomson.net>
|
||||
* - Saurav K Bandyopadhyay <saurav@ieee.org>
|
||||
* - Zhenyu Wu <Zhenyu.Wu@thomson.net
|
||||
|
@ -26,109 +27,111 @@
|
|||
|
||||
#define MAX_LIST_SIZE 33
|
||||
//! definition of pic motion parameters
|
||||
typedef struct pic_motion_params_old
|
||||
{
|
||||
byte * mb_field; //!< field macroblock indicator
|
||||
typedef struct pic_motion_params_old {
|
||||
byte *mb_field; //!< field macroblock indicator
|
||||
|
||||
} PicMotionParamsOld;
|
||||
|
||||
//! definition of pic motion parameters
|
||||
typedef struct pic_motion_params
|
||||
{
|
||||
struct storable_picture *ref_pic[2]; //!< referrence picture pointer
|
||||
MotionVector mv[2]; //!< motion vector
|
||||
signed char ref_idx[2]; //!< reference picture [list][subblock_y][subblock_x]
|
||||
//byte mb_field; //!< field macroblock indicator
|
||||
//byte field_frame; //!< indicates if co_located is field or frame. Will be removed at some point
|
||||
typedef struct pic_motion_params {
|
||||
struct storable_picture *ref_pic[2]; //!< referrence picture pointer
|
||||
MotionVector mv[2]; //!< motion vector
|
||||
signed char ref_idx[2]; //!< reference picture [list][subblock_y][subblock_x]
|
||||
// byte mb_field; //!< field macroblock indicator
|
||||
// byte field_frame; //!< indicates if co_located is field
|
||||
// or frame. Will be removed at some point
|
||||
} PicMotionParams;
|
||||
|
||||
//! definition a picture (field or frame)
|
||||
typedef struct storable_picture
|
||||
{
|
||||
typedef struct storable_picture {
|
||||
PictureStructure structure;
|
||||
|
||||
int poc;
|
||||
int top_poc;
|
||||
int bottom_poc;
|
||||
int frame_poc;
|
||||
unsigned int frame_num;
|
||||
unsigned int recovery_frame;
|
||||
int poc;
|
||||
int top_poc;
|
||||
int bottom_poc;
|
||||
int frame_poc;
|
||||
unsigned int frame_num;
|
||||
unsigned int recovery_frame;
|
||||
|
||||
int pic_num;
|
||||
int long_term_pic_num;
|
||||
int long_term_frame_idx;
|
||||
int pic_num;
|
||||
int long_term_pic_num;
|
||||
int long_term_frame_idx;
|
||||
|
||||
byte is_long_term;
|
||||
int used_for_reference;
|
||||
int is_output;
|
||||
int non_existing;
|
||||
int separate_colour_plane_flag;
|
||||
byte is_long_term;
|
||||
int used_for_reference;
|
||||
int is_output;
|
||||
int non_existing;
|
||||
int separate_colour_plane_flag;
|
||||
|
||||
short max_slice_id;
|
||||
short max_slice_id;
|
||||
|
||||
int size_x, size_y, size_x_cr, size_y_cr;
|
||||
int size_x_m1, size_y_m1, size_x_cr_m1, size_y_cr_m1;
|
||||
int coded_frame;
|
||||
int mb_aff_frame_flag;
|
||||
unsigned PicWidthInMbs;
|
||||
unsigned PicSizeInMbs;
|
||||
int iLumaPadY, iLumaPadX;
|
||||
int iChromaPadY, iChromaPadX;
|
||||
int size_x, size_y, size_x_cr, size_y_cr;
|
||||
int size_x_m1, size_y_m1, size_x_cr_m1, size_y_cr_m1;
|
||||
int coded_frame;
|
||||
int mb_aff_frame_flag;
|
||||
unsigned PicWidthInMbs;
|
||||
unsigned PicSizeInMbs;
|
||||
int iLumaPadY, iLumaPadX;
|
||||
int iChromaPadY, iChromaPadX;
|
||||
|
||||
imgpel **imgY; //!< Y picture component
|
||||
imgpel ***imgUV; //!< U and V picture components
|
||||
imgpel ***img_comp; //!< Y,U, and V components
|
||||
|
||||
imgpel ** imgY; //!< Y picture component
|
||||
imgpel *** imgUV; //!< U and V picture components
|
||||
imgpel *** img_comp; //!< Y,U, and V components
|
||||
struct pic_motion_params **mv_info; //!< Motion info
|
||||
struct pic_motion_params **JVmv_info[MAX_PLANE]; //!< Motion info
|
||||
|
||||
struct pic_motion_params_old motion; //!< Motion info
|
||||
struct pic_motion_params_old
|
||||
JVmotion[MAX_PLANE]; //!< Motion info for 4:4:4 independent mode decoding
|
||||
|
||||
struct pic_motion_params **mv_info; //!< Motion info
|
||||
struct pic_motion_params **JVmv_info[MAX_PLANE]; //!< Motion info
|
||||
short **slice_id; //!< reference picture [mb_x][mb_y]
|
||||
|
||||
struct pic_motion_params_old motion; //!< Motion info
|
||||
struct pic_motion_params_old JVmotion[MAX_PLANE]; //!< Motion info for 4:4:4 independent mode decoding
|
||||
struct storable_picture
|
||||
*top_field; // for mb aff, if frame for referencing the top field
|
||||
struct storable_picture
|
||||
*bottom_field; // for mb aff, if frame for referencing the bottom field
|
||||
struct storable_picture
|
||||
*frame; // for mb aff, if field for referencing the combined frame
|
||||
|
||||
short ** slice_id; //!< reference picture [mb_x][mb_y]
|
||||
int slice_type;
|
||||
int idr_flag;
|
||||
int no_output_of_prior_pics_flag;
|
||||
int long_term_reference_flag;
|
||||
int adaptive_ref_pic_buffering_flag;
|
||||
|
||||
struct storable_picture *top_field; // for mb aff, if frame for referencing the top field
|
||||
struct storable_picture *bottom_field; // for mb aff, if frame for referencing the bottom field
|
||||
struct storable_picture *frame; // for mb aff, if field for referencing the combined frame
|
||||
|
||||
int slice_type;
|
||||
int idr_flag;
|
||||
int no_output_of_prior_pics_flag;
|
||||
int long_term_reference_flag;
|
||||
int adaptive_ref_pic_buffering_flag;
|
||||
|
||||
int chroma_format_idc;
|
||||
int frame_mbs_only_flag;
|
||||
int frame_cropping_flag;
|
||||
int frame_cropping_rect_left_offset;
|
||||
int frame_cropping_rect_right_offset;
|
||||
int frame_cropping_rect_top_offset;
|
||||
int frame_cropping_rect_bottom_offset;
|
||||
int qp;
|
||||
int chroma_qp_offset[2];
|
||||
int slice_qp_delta;
|
||||
DecRefPicMarking_t *dec_ref_pic_marking_buffer; //!< stores the memory management control operations
|
||||
int chroma_format_idc;
|
||||
int frame_mbs_only_flag;
|
||||
int frame_cropping_flag;
|
||||
int frame_cropping_rect_left_offset;
|
||||
int frame_cropping_rect_right_offset;
|
||||
int frame_cropping_rect_top_offset;
|
||||
int frame_cropping_rect_bottom_offset;
|
||||
int qp;
|
||||
int chroma_qp_offset[2];
|
||||
int slice_qp_delta;
|
||||
DecRefPicMarking_t
|
||||
*dec_ref_pic_marking_buffer; //!< stores the memory management control
|
||||
//!< operations
|
||||
|
||||
// picture error concealment
|
||||
int concealed_pic; //indicates if this is a concealed picture
|
||||
|
||||
int concealed_pic; // indicates if this is a concealed picture
|
||||
|
||||
// variables for tone mapping
|
||||
int seiHasTone_mapping;
|
||||
int tone_mapping_model_id;
|
||||
int tonemapped_bit_depth;
|
||||
imgpel* tone_mapping_lut; //!< tone mapping look up table
|
||||
int seiHasTone_mapping;
|
||||
int tone_mapping_model_id;
|
||||
int tonemapped_bit_depth;
|
||||
imgpel *tone_mapping_lut; //!< tone mapping look up table
|
||||
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
int view_id;
|
||||
int inter_view_flag;
|
||||
int anchor_pic_flag;
|
||||
int view_id;
|
||||
int inter_view_flag;
|
||||
int anchor_pic_flag;
|
||||
#endif
|
||||
int iLumaStride;
|
||||
int iChromaStride;
|
||||
int iLumaExpandedHeight;
|
||||
int iChromaExpandedHeight;
|
||||
int iLumaStride;
|
||||
int iChromaStride;
|
||||
int iLumaExpandedHeight;
|
||||
int iChromaExpandedHeight;
|
||||
imgpel **cur_imgY; // for more efficient get_block_luma
|
||||
int no_ref;
|
||||
int iCodingType;
|
||||
|
@ -140,31 +143,33 @@ typedef struct storable_picture
|
|||
typedef StorablePicture *StorablePicturePtr;
|
||||
|
||||
//! definition a picture (field or frame)
|
||||
typedef struct colocated_params
|
||||
{
|
||||
int mb_adaptive_frame_field_flag;
|
||||
int size_x, size_y;
|
||||
byte is_long_term;
|
||||
typedef struct colocated_params {
|
||||
int mb_adaptive_frame_field_flag;
|
||||
int size_x, size_y;
|
||||
byte is_long_term;
|
||||
|
||||
} ColocatedParams;
|
||||
|
||||
//! Frame Stores for Decoded Picture Buffer
|
||||
typedef struct frame_store
|
||||
{
|
||||
int is_used; //!< 0=empty; 1=top; 2=bottom; 3=both fields (or frame)
|
||||
int is_reference; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
|
||||
int is_long_term; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
|
||||
int is_orig_reference; //!< original marking by nal_ref_idc: 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
|
||||
typedef struct frame_store {
|
||||
int is_used; //!< 0=empty; 1=top; 2=bottom; 3=both fields (or frame)
|
||||
int is_reference; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both
|
||||
//!< fields (or frame) used
|
||||
int is_long_term; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both
|
||||
//!< fields (or frame) used
|
||||
int is_orig_reference; //!< original marking by nal_ref_idc: 0=not used for
|
||||
//!< ref; 1=top used; 2=bottom used; 3=both fields (or
|
||||
//!< frame) used
|
||||
|
||||
int is_non_existent;
|
||||
int is_non_existent;
|
||||
|
||||
unsigned frame_num;
|
||||
unsigned recovery_frame;
|
||||
unsigned frame_num;
|
||||
unsigned recovery_frame;
|
||||
|
||||
int frame_num_wrap;
|
||||
int long_term_frame_idx;
|
||||
int is_output;
|
||||
int poc;
|
||||
int frame_num_wrap;
|
||||
int long_term_frame_idx;
|
||||
int is_output;
|
||||
int poc;
|
||||
|
||||
// picture error concealment
|
||||
int concealment_reference;
|
||||
|
@ -174,92 +179,95 @@ typedef struct frame_store
|
|||
StorablePicture *bottom_field;
|
||||
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
int view_id;
|
||||
int inter_view_flag[2];
|
||||
int anchor_pic_flag[2];
|
||||
int view_id;
|
||||
int inter_view_flag[2];
|
||||
int anchor_pic_flag[2];
|
||||
#endif
|
||||
|
||||
|
||||
} FrameStore;
|
||||
|
||||
|
||||
//! Decoded Picture Buffer
|
||||
typedef struct decoded_picture_buffer
|
||||
{
|
||||
typedef struct decoded_picture_buffer {
|
||||
VideoParameters *p_Vid;
|
||||
InputParameters *p_Inp;
|
||||
FrameStore **fs;
|
||||
FrameStore **fs_ref;
|
||||
FrameStore **fs_ltref;
|
||||
unsigned size;
|
||||
unsigned used_size;
|
||||
unsigned ref_frames_in_buffer;
|
||||
unsigned ltref_frames_in_buffer;
|
||||
int last_output_poc;
|
||||
FrameStore **fs;
|
||||
FrameStore **fs_ref;
|
||||
FrameStore **fs_ltref;
|
||||
unsigned size;
|
||||
unsigned used_size;
|
||||
unsigned ref_frames_in_buffer;
|
||||
unsigned ltref_frames_in_buffer;
|
||||
int last_output_poc;
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
int last_output_view_id;
|
||||
int max_long_term_pic_idx[MAX_VIEW_NUM];
|
||||
int last_output_view_id;
|
||||
int max_long_term_pic_idx[MAX_VIEW_NUM];
|
||||
#else
|
||||
int max_long_term_pic_idx;
|
||||
int max_long_term_pic_idx;
|
||||
#endif
|
||||
|
||||
int init_done;
|
||||
int num_ref_frames;
|
||||
int init_done;
|
||||
int num_ref_frames;
|
||||
|
||||
FrameStore *last_picture;
|
||||
FrameStore *last_picture;
|
||||
} DecodedPictureBuffer;
|
||||
|
||||
extern void init_dpb(VideoParameters *p_Vid, DecodedPictureBuffer *p_Dpb);
|
||||
extern void re_init_dpb(VideoParameters *p_Vid, DecodedPictureBuffer *p_Dpb);
|
||||
extern void free_dpb(DecodedPictureBuffer *p_Dpb);
|
||||
extern FrameStore* alloc_frame_store(void);
|
||||
extern void free_frame_store (FrameStore* f);
|
||||
extern StorablePicture* alloc_storable_picture(VideoParameters *p_Vid, PictureStructure type, int size_x, int size_y, int size_x_cr, int size_y_cr);
|
||||
extern void free_storable_picture (StorablePicture* p);
|
||||
extern void store_picture_in_dpb(DecodedPictureBuffer *p_Dpb, StorablePicture* p);
|
||||
extern StorablePicture* get_short_term_pic (DecodedPictureBuffer *p_Dpb, int picNum);
|
||||
extern StorablePicture* get_long_term_pic (DecodedPictureBuffer *p_Dpb, int LongtermPicNum);
|
||||
extern void init_dpb(VideoParameters *p_Vid, DecodedPictureBuffer *p_Dpb);
|
||||
extern void re_init_dpb(VideoParameters *p_Vid, DecodedPictureBuffer *p_Dpb);
|
||||
extern void free_dpb(DecodedPictureBuffer *p_Dpb);
|
||||
extern FrameStore *alloc_frame_store(void);
|
||||
extern void free_frame_store(FrameStore *f);
|
||||
extern StorablePicture *alloc_storable_picture(VideoParameters *p_Vid,
|
||||
PictureStructure type,
|
||||
int size_x, int size_y,
|
||||
int size_x_cr, int size_y_cr);
|
||||
extern void free_storable_picture(StorablePicture *p);
|
||||
extern void store_picture_in_dpb(DecodedPictureBuffer *p_Dpb,
|
||||
StorablePicture *p);
|
||||
extern StorablePicture *get_short_term_pic(DecodedPictureBuffer *p_Dpb,
|
||||
int picNum);
|
||||
extern StorablePicture *get_long_term_pic(DecodedPictureBuffer *p_Dpb,
|
||||
int LongtermPicNum);
|
||||
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
extern void flush_dpb(DecodedPictureBuffer *p_Dpb, int curr_view_id);
|
||||
extern int GetMaxDecFrameBuffering(VideoParameters *p_Vid);
|
||||
extern void append_interview_list(DecodedPictureBuffer *p_Dpb,
|
||||
PictureStructure currPicStructure,
|
||||
int list_idx,
|
||||
FrameStore **list,
|
||||
int *listXsize,
|
||||
int currPOC,
|
||||
int curr_view_id,
|
||||
int anchor_pic_flag);
|
||||
extern void update_ref_list(DecodedPictureBuffer *p_Dpb, int curr_view_id);
|
||||
extern void update_ltref_list(DecodedPictureBuffer *p_Dpb, int curr_view_id);
|
||||
extern void flush_dpb(DecodedPictureBuffer *p_Dpb, int curr_view_id);
|
||||
extern int GetMaxDecFrameBuffering(VideoParameters *p_Vid);
|
||||
extern void append_interview_list(DecodedPictureBuffer *p_Dpb,
|
||||
PictureStructure currPicStructure,
|
||||
int list_idx, FrameStore **list,
|
||||
int *listXsize, int currPOC, int curr_view_id,
|
||||
int anchor_pic_flag);
|
||||
extern void update_ref_list(DecodedPictureBuffer *p_Dpb, int curr_view_id);
|
||||
extern void update_ltref_list(DecodedPictureBuffer *p_Dpb, int curr_view_id);
|
||||
#else
|
||||
extern void flush_dpb(DecodedPictureBuffer *p_Dpb);
|
||||
extern void flush_dpb(DecodedPictureBuffer *p_Dpb);
|
||||
#endif
|
||||
extern void init_lists(Slice *currSlice);
|
||||
extern void init_lists_p_slice(Slice *currSlice);
|
||||
extern void init_lists_b_slice(Slice *currSlice);
|
||||
extern void init_lists_i_slice(Slice *currSlice);
|
||||
extern void update_pic_num (Slice *currSlice);
|
||||
extern void init_lists(Slice *currSlice);
|
||||
extern void init_lists_p_slice(Slice *currSlice);
|
||||
extern void init_lists_b_slice(Slice *currSlice);
|
||||
extern void init_lists_i_slice(Slice *currSlice);
|
||||
extern void update_pic_num(Slice *currSlice);
|
||||
|
||||
extern void dpb_split_field (VideoParameters *p_Vid, FrameStore *fs);
|
||||
extern void dpb_combine_field(VideoParameters *p_Vid, FrameStore *fs);
|
||||
extern void dpb_combine_field_yuv(VideoParameters *p_Vid, FrameStore *fs);
|
||||
extern void dpb_split_field(VideoParameters *p_Vid, FrameStore *fs);
|
||||
extern void dpb_combine_field(VideoParameters *p_Vid, FrameStore *fs);
|
||||
extern void dpb_combine_field_yuv(VideoParameters *p_Vid, FrameStore *fs);
|
||||
|
||||
extern void reorder_ref_pic_list(Slice *currSlice, int cur_list);
|
||||
extern void reorder_ref_pic_list(Slice *currSlice, int cur_list);
|
||||
|
||||
extern void init_mbaff_lists(VideoParameters *p_Vid, Slice *currSlice);
|
||||
extern void alloc_ref_pic_list_reordering_buffer(Slice *currSlice);
|
||||
extern void free_ref_pic_list_reordering_buffer(Slice *currSlice);
|
||||
extern void init_mbaff_lists(VideoParameters *p_Vid, Slice *currSlice);
|
||||
extern void alloc_ref_pic_list_reordering_buffer(Slice *currSlice);
|
||||
extern void free_ref_pic_list_reordering_buffer(Slice *currSlice);
|
||||
|
||||
extern void fill_frame_num_gap(VideoParameters *p_Vid, Slice *pSlice);
|
||||
extern void fill_frame_num_gap(VideoParameters *p_Vid, Slice *pSlice);
|
||||
|
||||
extern void compute_colocated (Slice *currSlice, StorablePicture **listX[6]);
|
||||
extern void compute_colocated(Slice *currSlice, StorablePicture **listX[6]);
|
||||
|
||||
extern void gen_pic_list_from_frame_list(PictureStructure currStructure,
|
||||
FrameStore **fs_list, int list_idx,
|
||||
StorablePicture **list,
|
||||
signed char *list_size, int long_term);
|
||||
|
||||
extern void gen_pic_list_from_frame_list(PictureStructure currStructure, FrameStore **fs_list, int list_idx, StorablePicture **list, signed char *list_size, int long_term);
|
||||
|
||||
|
||||
extern void pad_dec_picture(VideoParameters *p_Vid, StorablePicture *dec_picture);
|
||||
extern void pad_buf(imgpel *pImgBuf, int iWidth, int iHeight, int iStride, int iPadX, int iPadY);
|
||||
extern void pad_dec_picture(VideoParameters *p_Vid,
|
||||
StorablePicture *dec_picture);
|
||||
extern void pad_buf(imgpel *pImgBuf, int iWidth, int iHeight, int iStride,
|
||||
int iPadX, int iPadY);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
* MVC Frame buffer functions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Athanasios Leontaris <aleon@dolby.com>
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
|
@ -21,18 +22,24 @@
|
|||
#include "global.h"
|
||||
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
extern void reorder_lists_mvc (Slice * currSlice, int currPOC);
|
||||
extern void init_lists_mvc (Slice *currSlice);
|
||||
extern void reorder_lists_mvc(Slice *currSlice, int currPOC);
|
||||
extern void init_lists_mvc(Slice *currSlice);
|
||||
extern void init_lists_p_slice_mvc(Slice *currSlice);
|
||||
extern void init_lists_b_slice_mvc(Slice *currSlice);
|
||||
extern void init_lists_i_slice_mvc(Slice *currSlice);
|
||||
|
||||
extern void reorder_ref_pic_list_mvc(Slice *currSlice, int cur_list, int **anchor_ref, int **non_anchor_ref,
|
||||
int view_id, int anchor_pic_flag, int currPOC, int listidx);
|
||||
extern void reorder_ref_pic_list_mvc(Slice *currSlice, int cur_list,
|
||||
int **anchor_ref, int **non_anchor_ref,
|
||||
int view_id, int anchor_pic_flag,
|
||||
int currPOC, int listidx);
|
||||
|
||||
extern void reorder_short_term(Slice *currSlice, int cur_list, int num_ref_idx_lX_active_minus1, int picNumLX, int *refIdxLX, int currViewID);
|
||||
extern void reorder_long_term(Slice *currSlice, StorablePicture **RefPicListX, int num_ref_idx_lX_active_minus1, int LongTermPicNum, int *refIdxLX, int currViewID);
|
||||
extern void reorder_short_term(Slice *currSlice, int cur_list,
|
||||
int num_ref_idx_lX_active_minus1, int picNumLX,
|
||||
int *refIdxLX, int currViewID);
|
||||
extern void reorder_long_term(Slice *currSlice, StorablePicture **RefPicListX,
|
||||
int num_ref_idx_lX_active_minus1,
|
||||
int LongTermPicNum, int *refIdxLX,
|
||||
int currViewID);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* definitions for motion compensated prediction
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* address and affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
|
@ -20,14 +20,22 @@
|
|||
#include "global.h"
|
||||
#include "mbuffer.h"
|
||||
|
||||
extern int allocate_pred_mem(Slice *currSlice);
|
||||
extern void free_pred_mem (Slice *currSlice);
|
||||
extern int allocate_pred_mem(Slice *currSlice);
|
||||
extern void free_pred_mem(Slice *currSlice);
|
||||
|
||||
extern void get_block_luma(StorablePicture *curr_ref, int x_pos, int y_pos, int hor_block_size, int ver_block_size, imgpel **block,
|
||||
int shift_x,int maxold_x,int maxold_y,int **tmp_res,int max_imgpel_value,imgpel no_ref_value,Macroblock *currMB);
|
||||
extern void get_block_luma(StorablePicture *curr_ref, int x_pos, int y_pos,
|
||||
int hor_block_size, int ver_block_size,
|
||||
imgpel **block, int shift_x, int maxold_x,
|
||||
int maxold_y, int **tmp_res, int max_imgpel_value,
|
||||
imgpel no_ref_value, Macroblock *currMB);
|
||||
|
||||
extern void intra_cr_decoding (Macroblock *currMB, int yuv);
|
||||
extern void prepare_direct_params(Macroblock *currMB, StorablePicture *dec_picture, MotionVector *pmvl0, MotionVector *pmvl1,signed char *l0_rFrame, signed char *l1_rFrame);
|
||||
extern void perform_mc (Macroblock *currMB, ColorPlane pl, StorablePicture *dec_picture, int pred_dir, int i, int j, int block_size_x, int block_size_y);
|
||||
extern void intra_cr_decoding(Macroblock *currMB, int yuv);
|
||||
extern void prepare_direct_params(Macroblock *currMB,
|
||||
StorablePicture *dec_picture,
|
||||
MotionVector *pmvl0, MotionVector *pmvl1,
|
||||
signed char *l0_rFrame,
|
||||
signed char *l1_rFrame);
|
||||
extern void perform_mc(Macroblock *currMB, ColorPlane pl,
|
||||
StorablePicture *dec_picture, int pred_dir, int i, int j,
|
||||
int block_size_x, int block_size_y);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
* Memory allocation and free helper funtions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
************************************************************************
|
||||
*/
|
||||
|
@ -17,164 +18,206 @@
|
|||
#ifndef _MEMALLOC_H_
|
||||
#define _MEMALLOC_H_
|
||||
|
||||
#include "global.h"
|
||||
#include "mbuffer.h"
|
||||
#include "distortion.h"
|
||||
#include "global.h"
|
||||
#include "lagrangian.h"
|
||||
#include "mbuffer.h"
|
||||
#include "quant_params.h"
|
||||
|
||||
extern int get_mem2Ddist(DistortionData ***array2D, int dim0, int dim1);
|
||||
extern int get_mem2Ddist(DistortionData ***array2D, int dim0, int dim1);
|
||||
|
||||
extern int get_mem2Dlm (LambdaParams ***array2D, int dim0, int dim1);
|
||||
extern int get_mem2Dolm (LambdaParams ***array2D, int dim0, int dim1, int offset);
|
||||
extern int get_mem2Dlm(LambdaParams ***array2D, int dim0, int dim1);
|
||||
extern int get_mem2Dolm(LambdaParams ***array2D, int dim0, int dim1,
|
||||
int offset);
|
||||
|
||||
extern int get_mem2Dmp (PicMotionParams ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3Dmp (PicMotionParams ****array3D, int dim0, int dim1, int dim2);
|
||||
extern int get_mem2Dmp(PicMotionParams ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3Dmp(PicMotionParams ****array3D, int dim0, int dim1,
|
||||
int dim2);
|
||||
|
||||
extern int get_mem2Dquant(LevelQuantParams ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3Dquant(LevelQuantParams ****array3D, int dim0, int dim1, int dim2);
|
||||
extern int get_mem4Dquant(LevelQuantParams *****array4D, int dim0, int dim1, int dim2, int dim3);
|
||||
extern int get_mem5Dquant(LevelQuantParams ******array5D, int dim0, int dim1, int dim2, int dim3, int dim4);
|
||||
extern int get_mem2Dquant(LevelQuantParams ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3Dquant(LevelQuantParams ****array3D, int dim0, int dim1,
|
||||
int dim2);
|
||||
extern int get_mem4Dquant(LevelQuantParams *****array4D, int dim0, int dim1,
|
||||
int dim2, int dim3);
|
||||
extern int get_mem5Dquant(LevelQuantParams ******array5D, int dim0, int dim1,
|
||||
int dim2, int dim3, int dim4);
|
||||
|
||||
extern int get_mem2Dmv (MotionVector ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3Dmv (MotionVector ****array3D, int dim0, int dim1, int dim2);
|
||||
extern int get_mem4Dmv (MotionVector *****array4D, int dim0, int dim1, int dim2, int dim3);
|
||||
extern int get_mem5Dmv (MotionVector ******array5D, int dim0, int dim1, int dim2, int dim3, int dim4);
|
||||
extern int get_mem6Dmv (MotionVector *******array6D, int dim0, int dim1, int dim2, int dim3, int dim4, int dim5);
|
||||
extern int get_mem7Dmv (MotionVector ********array7D, int dim0, int dim1, int dim2, int dim3, int dim4, int dim5, int dim6);
|
||||
extern int get_mem2Dmv(MotionVector ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3Dmv(MotionVector ****array3D, int dim0, int dim1, int dim2);
|
||||
extern int get_mem4Dmv(MotionVector *****array4D, int dim0, int dim1, int dim2,
|
||||
int dim3);
|
||||
extern int get_mem5Dmv(MotionVector ******array5D, int dim0, int dim1, int dim2,
|
||||
int dim3, int dim4);
|
||||
extern int get_mem6Dmv(MotionVector *******array6D, int dim0, int dim1,
|
||||
int dim2, int dim3, int dim4, int dim5);
|
||||
extern int get_mem7Dmv(MotionVector ********array7D, int dim0, int dim1,
|
||||
int dim2, int dim3, int dim4, int dim5, int dim6);
|
||||
|
||||
extern byte** new_mem2D(int dim0, int dim1);
|
||||
extern int get_mem2D(byte ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3D(byte ****array3D, int dim0, int dim1, int dim2);
|
||||
extern int get_mem4D(byte *****array4D, int dim0, int dim1, int dim2, int dim3);
|
||||
extern byte **new_mem2D(int dim0, int dim1);
|
||||
extern int get_mem2D(byte ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3D(byte ****array3D, int dim0, int dim1, int dim2);
|
||||
extern int get_mem4D(byte *****array4D, int dim0, int dim1, int dim2, int dim3);
|
||||
|
||||
extern int** new_mem2Dint(int dim0, int dim1);
|
||||
extern int get_mem2Dint(int ***array2D, int rows, int columns);
|
||||
extern int get_mem2DintWithPad(int ***array2D, int dim0, int dim1, int iPadY, int iPadX);
|
||||
extern int get_mem2Dint64(int64 ***array2D, int rows, int columns);
|
||||
extern int get_mem3Dint(int ****array3D, int frames, int rows, int columns);
|
||||
extern int get_mem3Dint64(int64 ****array3D, int frames, int rows, int columns);
|
||||
extern int get_mem4Dint(int *****array4D, int idx, int frames, int rows, int columns );
|
||||
extern int get_mem4Dint64(int64 *****array4D, int idx, int frames, int rows, int columns );
|
||||
extern int get_mem5Dint(int ******array5D, int refs, int blocktype, int rows, int columns, int component);
|
||||
extern int **new_mem2Dint(int dim0, int dim1);
|
||||
extern int get_mem2Dint(int ***array2D, int rows, int columns);
|
||||
extern int get_mem2DintWithPad(int ***array2D, int dim0, int dim1, int iPadY,
|
||||
int iPadX);
|
||||
extern int get_mem2Dint64(int64 ***array2D, int rows, int columns);
|
||||
extern int get_mem3Dint(int ****array3D, int frames, int rows, int columns);
|
||||
extern int get_mem3Dint64(int64 ****array3D, int frames, int rows, int columns);
|
||||
extern int get_mem4Dint(int *****array4D, int idx, int frames, int rows,
|
||||
int columns);
|
||||
extern int get_mem4Dint64(int64 *****array4D, int idx, int frames, int rows,
|
||||
int columns);
|
||||
extern int get_mem5Dint(int ******array5D, int refs, int blocktype, int rows,
|
||||
int columns, int component);
|
||||
|
||||
extern uint16** new_mem2Duint16(int dim0, int dim1);
|
||||
extern uint16 **new_mem2Duint16(int dim0, int dim1);
|
||||
extern int get_mem2Duint16(uint16 ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3Duint16(uint16 ****array3D,int dim0, int dim1, int dim2);
|
||||
extern int get_mem3Duint16(uint16 ****array3D, int dim0, int dim1, int dim2);
|
||||
|
||||
extern int get_mem2Ddistblk(distblk ***array2D, int rows, int columns);
|
||||
extern int get_mem3Ddistblk(distblk ****array3D, int frames, int rows, int columns);
|
||||
extern int get_mem4Ddistblk(distblk *****array4D, int idx, int frames, int rows, int columns );
|
||||
extern int get_mem2Ddistblk(distblk ***array2D, int rows, int columns);
|
||||
extern int get_mem3Ddistblk(distblk ****array3D, int frames, int rows,
|
||||
int columns);
|
||||
extern int get_mem4Ddistblk(distblk *****array4D, int idx, int frames, int rows,
|
||||
int columns);
|
||||
|
||||
extern int get_mem2Dshort(short ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3Dshort(short ****array3D, int dim0, int dim1, int dim2);
|
||||
extern int get_mem4Dshort(short *****array4D, int dim0, int dim1, int dim2, int dim3);
|
||||
extern int get_mem5Dshort(short ******array5D, int dim0, int dim1, int dim2, int dim3, int dim4);
|
||||
extern int get_mem6Dshort(short *******array6D, int dim0, int dim1, int dim2, int dim3, int dim4, int dim5);
|
||||
extern int get_mem7Dshort(short ********array7D, int dim0, int dim1, int dim2, int dim3, int dim4, int dim5, int dim6);
|
||||
extern int get_mem2Dshort(short ***array2D, int dim0, int dim1);
|
||||
extern int get_mem3Dshort(short ****array3D, int dim0, int dim1, int dim2);
|
||||
extern int get_mem4Dshort(short *****array4D, int dim0, int dim1, int dim2,
|
||||
int dim3);
|
||||
extern int get_mem5Dshort(short ******array5D, int dim0, int dim1, int dim2,
|
||||
int dim3, int dim4);
|
||||
extern int get_mem6Dshort(short *******array6D, int dim0, int dim1, int dim2,
|
||||
int dim3, int dim4, int dim5);
|
||||
extern int get_mem7Dshort(short ********array7D, int dim0, int dim1, int dim2,
|
||||
int dim3, int dim4, int dim5, int dim6);
|
||||
|
||||
extern int get_mem1Dpel(imgpel **array2D, int rows);
|
||||
extern int get_mem2Dpel(imgpel ***array2D, int rows, int columns);
|
||||
extern int get_mem2DpelWithPad(imgpel ***array2D, int dim0, int dim1, int iPadY, int iPadX);
|
||||
extern int get_mem1Dpel(imgpel **array2D, int rows);
|
||||
extern int get_mem2Dpel(imgpel ***array2D, int rows, int columns);
|
||||
extern int get_mem2DpelWithPad(imgpel ***array2D, int dim0, int dim1, int iPadY,
|
||||
int iPadX);
|
||||
|
||||
extern int get_mem3Dpel(imgpel ****array3D, int frames, int rows, int columns);
|
||||
extern int get_mem3DpelWithPad(imgpel ****array3D, int dim0, int dim1, int dim2, int iPadY, int iPadX);
|
||||
extern int get_mem3DpelWithPadSeparately(imgpel ****array3D, int dim0, int dim1, int dim2, int iPadY, int iPadX);
|
||||
extern int get_mem4Dpel(imgpel *****array4D, int sub_x, int sub_y, int rows, int columns);
|
||||
extern int get_mem4DpelWithPad(imgpel *****array4D, int sub_x, int sub_y, int rows, int columns, int iPadY, int iPadX);
|
||||
extern int get_mem4DpelWithPadSeparately(imgpel *****array4D, int dim0, int dim1, int dim2, int dim3, int iPadY, int iPadX);
|
||||
extern int get_mem5Dpel(imgpel ******array5D, int dims, int sub_x, int sub_y, int rows, int columns);
|
||||
extern int get_mem5DpelWithPad(imgpel ******array5D, int dims, int sub_x, int sub_y, int rows, int columns, int iPadY, int iPadX);
|
||||
extern int get_mem5DpelWithPadSeparately(imgpel ******array5D, int dim0, int dim1, int dim2, int dim3, int dim4, int iPadY, int iPadX);
|
||||
extern int get_mem2Ddouble (double ***array2D, int rows, int columns);
|
||||
extern int get_mem3Dpel(imgpel ****array3D, int frames, int rows, int columns);
|
||||
extern int get_mem3DpelWithPad(imgpel ****array3D, int dim0, int dim1, int dim2,
|
||||
int iPadY, int iPadX);
|
||||
extern int get_mem3DpelWithPadSeparately(imgpel ****array3D, int dim0, int dim1,
|
||||
int dim2, int iPadY, int iPadX);
|
||||
extern int get_mem4Dpel(imgpel *****array4D, int sub_x, int sub_y, int rows,
|
||||
int columns);
|
||||
extern int get_mem4DpelWithPad(imgpel *****array4D, int sub_x, int sub_y,
|
||||
int rows, int columns, int iPadY, int iPadX);
|
||||
extern int get_mem4DpelWithPadSeparately(imgpel *****array4D, int dim0,
|
||||
int dim1, int dim2, int dim3,
|
||||
int iPadY, int iPadX);
|
||||
extern int get_mem5Dpel(imgpel ******array5D, int dims, int sub_x, int sub_y,
|
||||
int rows, int columns);
|
||||
extern int get_mem5DpelWithPad(imgpel ******array5D, int dims, int sub_x,
|
||||
int sub_y, int rows, int columns, int iPadY,
|
||||
int iPadX);
|
||||
extern int get_mem5DpelWithPadSeparately(imgpel ******array5D, int dim0,
|
||||
int dim1, int dim2, int dim3, int dim4,
|
||||
int iPadY, int iPadX);
|
||||
extern int get_mem2Ddouble(double ***array2D, int rows, int columns);
|
||||
|
||||
extern int get_mem1Dodouble(double **array1D, int dim0, int offset);
|
||||
extern int get_mem2Dodouble(double ***array2D, int rows, int columns, int offset);
|
||||
extern int get_mem3Dodouble(double ****array2D, int rows, int columns, int pels, int offset);
|
||||
extern int get_mem1Dodouble(double **array1D, int dim0, int offset);
|
||||
extern int get_mem2Dodouble(double ***array2D, int rows, int columns,
|
||||
int offset);
|
||||
extern int get_mem3Dodouble(double ****array2D, int rows, int columns, int pels,
|
||||
int offset);
|
||||
|
||||
extern int get_mem2Doint (int ***array2D, int rows, int columns, int offset);
|
||||
extern int get_mem3Doint (int ****array3D, int rows, int columns, int pels, int offset);
|
||||
extern int get_mem2Doint(int ***array2D, int rows, int columns, int offset);
|
||||
extern int get_mem3Doint(int ****array3D, int rows, int columns, int pels,
|
||||
int offset);
|
||||
|
||||
extern int get_offset_mem2Dshort(short ***array2D, int rows, int columns, int offset_y, int offset_x);
|
||||
extern int get_offset_mem2Dshort(short ***array2D, int rows, int columns,
|
||||
int offset_y, int offset_x);
|
||||
|
||||
extern void free_offset_mem2Dshort(short **array2D, int columns, int offset_x, int offset_y);
|
||||
extern void free_offset_mem2Dshort(short **array2D, int columns, int offset_x,
|
||||
int offset_y);
|
||||
|
||||
extern void free_mem2Ddist (DistortionData **array2D);
|
||||
extern void free_mem2Ddist(DistortionData **array2D);
|
||||
|
||||
extern void free_mem2Dlm (LambdaParams **array2D);
|
||||
extern void free_mem2Dolm (LambdaParams **array2D, int offset);
|
||||
extern void free_mem2Dlm(LambdaParams **array2D);
|
||||
extern void free_mem2Dolm(LambdaParams **array2D, int offset);
|
||||
|
||||
extern void free_mem2Dmp (PicMotionParams **array2D);
|
||||
extern void free_mem3Dmp (PicMotionParams ***array2D);
|
||||
extern void free_mem2Dmp(PicMotionParams **array2D);
|
||||
extern void free_mem3Dmp(PicMotionParams ***array2D);
|
||||
|
||||
extern void free_mem2Dquant(LevelQuantParams **array2D);
|
||||
extern void free_mem3Dquant(LevelQuantParams ***array2D);
|
||||
extern void free_mem4Dquant(LevelQuantParams ****array2D);
|
||||
extern void free_mem2Dquant(LevelQuantParams **array2D);
|
||||
extern void free_mem3Dquant(LevelQuantParams ***array2D);
|
||||
extern void free_mem4Dquant(LevelQuantParams ****array2D);
|
||||
extern void free_mem5Dquant(LevelQuantParams *****array2D);
|
||||
|
||||
extern void free_mem2Dmv (MotionVector **array2D);
|
||||
extern void free_mem3Dmv (MotionVector ***array2D);
|
||||
extern void free_mem4Dmv (MotionVector ****array2D);
|
||||
extern void free_mem5Dmv (MotionVector *****array2D);
|
||||
extern void free_mem6Dmv (MotionVector ******array2D);
|
||||
extern void free_mem7Dmv (MotionVector *******array7D);
|
||||
extern void free_mem2Dmv(MotionVector **array2D);
|
||||
extern void free_mem3Dmv(MotionVector ***array2D);
|
||||
extern void free_mem4Dmv(MotionVector ****array2D);
|
||||
extern void free_mem5Dmv(MotionVector *****array2D);
|
||||
extern void free_mem6Dmv(MotionVector ******array2D);
|
||||
extern void free_mem7Dmv(MotionVector *******array7D);
|
||||
|
||||
extern int get_mem2D_spp(StorablePicturePtr ***array3D, int dim0, int dim1);
|
||||
extern int get_mem3D_spp(StorablePicturePtr ****array3D, int dim0, int dim1, int dim2);
|
||||
extern int get_mem2D_spp(StorablePicturePtr ***array3D, int dim0, int dim1);
|
||||
extern int get_mem3D_spp(StorablePicturePtr ****array3D, int dim0, int dim1,
|
||||
int dim2);
|
||||
|
||||
extern void free_mem2D_spp (StorablePicturePtr **array2D);
|
||||
extern void free_mem3D_spp (StorablePicturePtr ***array2D);
|
||||
extern void free_mem2D_spp(StorablePicturePtr **array2D);
|
||||
extern void free_mem3D_spp(StorablePicturePtr ***array2D);
|
||||
|
||||
extern void free_mem2D (byte **array2D);
|
||||
extern void free_mem3D (byte ***array3D);
|
||||
extern void free_mem4D (byte ****array4D);
|
||||
extern void free_mem2D(byte **array2D);
|
||||
extern void free_mem3D(byte ***array3D);
|
||||
extern void free_mem4D(byte ****array4D);
|
||||
|
||||
extern void free_mem2Dint (int **array2D);
|
||||
extern void free_mem2Dint(int **array2D);
|
||||
extern void free_mem2DintWithPad(int **array2D, int iPadY, int iPadX);
|
||||
extern void free_mem3Dint (int ***array3D);
|
||||
extern void free_mem4Dint (int ****array4D);
|
||||
extern void free_mem5Dint (int *****array5D);
|
||||
extern void free_mem3Dint(int ***array3D);
|
||||
extern void free_mem4Dint(int ****array4D);
|
||||
extern void free_mem5Dint(int *****array5D);
|
||||
|
||||
extern void free_mem2Duint16(uint16 **array2D);
|
||||
extern void free_mem3Duint16(uint16 ***array3D);
|
||||
|
||||
extern void free_mem2Dint64(int64 **array2D);
|
||||
extern void free_mem3Dint64(int64 ***array3D);
|
||||
extern void free_mem4Dint64(int64 ****array4D);
|
||||
extern void free_mem2Dint64(int64 **array2D);
|
||||
extern void free_mem3Dint64(int64 ***array3D);
|
||||
extern void free_mem4Dint64(int64 ****array4D);
|
||||
|
||||
extern void free_mem2Ddistblk(distblk **array2D);
|
||||
extern void free_mem3Ddistblk(distblk ***array3D);
|
||||
extern void free_mem4Ddistblk(distblk ****array4D);
|
||||
extern void free_mem2Ddistblk(distblk **array2D);
|
||||
extern void free_mem3Ddistblk(distblk ***array3D);
|
||||
extern void free_mem4Ddistblk(distblk ****array4D);
|
||||
|
||||
extern void free_mem2Dshort(short **array2D);
|
||||
extern void free_mem3Dshort(short ***array3D);
|
||||
extern void free_mem4Dshort(short ****array4D);
|
||||
extern void free_mem5Dshort(short *****array5D);
|
||||
extern void free_mem6Dshort(short ******array6D);
|
||||
extern void free_mem2Dshort(short **array2D);
|
||||
extern void free_mem3Dshort(short ***array3D);
|
||||
extern void free_mem4Dshort(short ****array4D);
|
||||
extern void free_mem5Dshort(short *****array5D);
|
||||
extern void free_mem6Dshort(short ******array6D);
|
||||
extern void free_mem7Dshort(short *******array7D);
|
||||
|
||||
extern void free_mem1Dpel (imgpel *array1D);
|
||||
extern void free_mem2Dpel (imgpel **array2D);
|
||||
extern void free_mem1Dpel(imgpel *array1D);
|
||||
extern void free_mem2Dpel(imgpel **array2D);
|
||||
extern void free_mem2DpelWithPad(imgpel **array2D, int iPadY, int iPadX);
|
||||
extern void free_mem3Dpel (imgpel ***array3D);
|
||||
extern void free_mem3Dpel(imgpel ***array3D);
|
||||
extern void free_mem3DpelWithPad(imgpel ***array3D, int iPadY, int iPadX);
|
||||
extern void free_mem3DpelWithPadSeparately(imgpel ***array3D, int iDim12, int iPadY, int iPadX);
|
||||
extern void free_mem4Dpel (imgpel ****array4D);
|
||||
extern void free_mem4DpelWithPad(imgpel ****array4D, int iPadY, int iPadX);
|
||||
extern void free_mem4DpelWithPadSeparately(imgpel ****array4D, int iFrames, int iPadY, int iPadX);
|
||||
extern void free_mem5Dpel (imgpel *****array5D);
|
||||
extern void free_mem3DpelWithPadSeparately(imgpel ***array3D, int iDim12,
|
||||
int iPadY, int iPadX);
|
||||
extern void free_mem4Dpel(imgpel ****array4D);
|
||||
extern void free_mem4DpelWithPad(imgpel ****array4D, int iPadY, int iPadX);
|
||||
extern void free_mem4DpelWithPadSeparately(imgpel ****array4D, int iFrames,
|
||||
int iPadY, int iPadX);
|
||||
extern void free_mem5Dpel(imgpel *****array5D);
|
||||
extern void free_mem5DpelWithPad(imgpel *****array5D, int iPadY, int iPadX);
|
||||
extern void free_mem5DpelWithPadSeparately(imgpel *****array5D, int iFrames, int iPadY, int iPadX);
|
||||
extern void free_mem5DpelWithPadSeparately(imgpel *****array5D, int iFrames,
|
||||
int iPadY, int iPadX);
|
||||
extern void free_mem2Ddouble(double **array2D);
|
||||
extern void free_mem3Ddouble(double ***array3D);
|
||||
|
||||
extern void free_mem1Dodouble(double *array1D, int offset);
|
||||
extern void free_mem1Dodouble(double *array1D, int offset);
|
||||
extern void free_mem2Dodouble(double **array2D, int offset);
|
||||
extern void free_mem3Dodouble(double ***array3D, int rows, int columns, int offset);
|
||||
extern void free_mem2Doint (int **array2D, int offset);
|
||||
extern void free_mem3Doint (int ***array3D, int rows, int columns, int offset);
|
||||
extern void free_mem3Dodouble(double ***array3D, int rows, int columns,
|
||||
int offset);
|
||||
extern void free_mem2Doint(int **array2D, int offset);
|
||||
extern void free_mem3Doint(int ***array3D, int rows, int columns, int offset);
|
||||
|
||||
extern int init_top_bot_planes(imgpel **imgFrame, int height, imgpel ***imgTopField, imgpel ***imgBotField);
|
||||
extern int init_top_bot_planes(imgpel **imgFrame, int height,
|
||||
imgpel ***imgTopField, imgpel ***imgBotField);
|
||||
extern void free_top_bot_planes(imgpel **imgTopField, imgpel **imgBotField);
|
||||
|
||||
extern void no_mem_exit(char *where);
|
||||
|
|
|
@ -6,14 +6,16 @@
|
|||
* Declarations for Motion Vector Prediction
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _MV_PREDICTION_H_
|
||||
#define _MV_PREDICTION_H_
|
||||
|
||||
extern void init_motion_vector_prediction(Macroblock *currMB, int mb_aff_frame_flag);
|
||||
extern void init_motion_vector_prediction(Macroblock *currMB,
|
||||
int mb_aff_frame_flag);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,27 +8,26 @@
|
|||
*
|
||||
* \date 25 November 2002
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||
***************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _NALU_H_
|
||||
#define _NALU_H_
|
||||
|
||||
#include "nalucommon.h"
|
||||
|
||||
typedef struct sBitsFile
|
||||
{
|
||||
void (*OpenBitsFile) (VideoParameters *p_Vid, char *filename);
|
||||
void (*CloseBitsFile) (VideoParameters *p_Vid);
|
||||
int (*GetNALU) (VideoParameters *p_Vid, NALU_t *nalu);
|
||||
typedef struct sBitsFile {
|
||||
void (*OpenBitsFile)(VideoParameters *p_Vid, char *filename);
|
||||
void (*CloseBitsFile)(VideoParameters *p_Vid);
|
||||
int (*GetNALU)(VideoParameters *p_Vid, NALU_t *nalu);
|
||||
} BitsFile;
|
||||
|
||||
extern void initBitsFile (VideoParameters *p_Vid, int filemode);
|
||||
extern void initBitsFile(VideoParameters *p_Vid, int filemode);
|
||||
extern void CheckZeroByteNonVCL(VideoParameters *p_Vid, NALU_t *nalu);
|
||||
extern void CheckZeroByteVCL (VideoParameters *p_Vid, NALU_t *nalu);
|
||||
extern void CheckZeroByteVCL(VideoParameters *p_Vid, NALU_t *nalu);
|
||||
|
||||
extern int read_next_nalu(VideoParameters *p_Vid, NALU_t *nalu);
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* \brief
|
||||
* NALU handling common to encoder and decoder
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||
* - Karsten Suehring <suehring@hhi.de>
|
||||
***************************************************************************************
|
||||
|
@ -22,54 +23,55 @@
|
|||
|
||||
//! values for nal_unit_type
|
||||
typedef enum {
|
||||
NALU_TYPE_SLICE = 1,
|
||||
NALU_TYPE_DPA = 2,
|
||||
NALU_TYPE_DPB = 3,
|
||||
NALU_TYPE_DPC = 4,
|
||||
NALU_TYPE_IDR = 5,
|
||||
NALU_TYPE_SEI = 6,
|
||||
NALU_TYPE_SPS = 7,
|
||||
NALU_TYPE_PPS = 8,
|
||||
NALU_TYPE_AUD = 9,
|
||||
NALU_TYPE_EOSEQ = 10,
|
||||
NALU_TYPE_EOSTREAM = 11,
|
||||
NALU_TYPE_FILL = 12,
|
||||
NALU_TYPE_SLICE = 1,
|
||||
NALU_TYPE_DPA = 2,
|
||||
NALU_TYPE_DPB = 3,
|
||||
NALU_TYPE_DPC = 4,
|
||||
NALU_TYPE_IDR = 5,
|
||||
NALU_TYPE_SEI = 6,
|
||||
NALU_TYPE_SPS = 7,
|
||||
NALU_TYPE_PPS = 8,
|
||||
NALU_TYPE_AUD = 9,
|
||||
NALU_TYPE_EOSEQ = 10,
|
||||
NALU_TYPE_EOSTREAM = 11,
|
||||
NALU_TYPE_FILL = 12,
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
NALU_TYPE_PREFIX = 14,
|
||||
NALU_TYPE_SUB_SPS = 15,
|
||||
NALU_TYPE_SLC_EXT = 20,
|
||||
NALU_TYPE_VDRD = 24 // View and Dependency Representation Delimiter NAL Unit
|
||||
NALU_TYPE_PREFIX = 14,
|
||||
NALU_TYPE_SUB_SPS = 15,
|
||||
NALU_TYPE_SLC_EXT = 20,
|
||||
NALU_TYPE_VDRD = 24 // View and Dependency Representation Delimiter NAL Unit
|
||||
#endif
|
||||
} NaluType;
|
||||
|
||||
//! values for nal_ref_idc
|
||||
typedef enum {
|
||||
NALU_PRIORITY_HIGHEST = 3,
|
||||
NALU_PRIORITY_HIGH = 2,
|
||||
NALU_PRIORITY_LOW = 1,
|
||||
NALU_PRIORITY_DISPOSABLE = 0
|
||||
NALU_PRIORITY_HIGHEST = 3,
|
||||
NALU_PRIORITY_HIGH = 2,
|
||||
NALU_PRIORITY_LOW = 1,
|
||||
NALU_PRIORITY_DISPOSABLE = 0
|
||||
} NalRefIdc;
|
||||
|
||||
//! NAL unit structure
|
||||
typedef struct nalu_t
|
||||
{
|
||||
int startcodeprefix_len; //!< 4 for parameter sets and first slice in picture, 3 for everything else (suggested)
|
||||
unsigned len; //!< Length of the NAL unit (Excluding the start code, which does not belong to the NALU)
|
||||
unsigned max_size; //!< NAL Unit Buffer size
|
||||
int forbidden_bit; //!< should be always FALSE
|
||||
NaluType nal_unit_type; //!< NALU_TYPE_xxxx
|
||||
NalRefIdc nal_reference_idc; //!< NALU_PRIORITY_xxxx
|
||||
byte *buf; //!< contains the first byte followed by the EBSP
|
||||
uint16 lost_packets; //!< true, if packet loss is detected
|
||||
typedef struct nalu_t {
|
||||
int startcodeprefix_len; //!< 4 for parameter sets and first slice in picture,
|
||||
//!< 3 for everything else (suggested)
|
||||
unsigned len; //!< Length of the NAL unit (Excluding the start code, which
|
||||
//!< does not belong to the NALU)
|
||||
unsigned max_size; //!< NAL Unit Buffer size
|
||||
int forbidden_bit; //!< should be always FALSE
|
||||
NaluType nal_unit_type; //!< NALU_TYPE_xxxx
|
||||
NalRefIdc nal_reference_idc; //!< NALU_PRIORITY_xxxx
|
||||
byte *buf; //!< contains the first byte followed by the EBSP
|
||||
uint16 lost_packets; //!< true, if packet loss is detected
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
int svc_extension_flag; //!< should be always 0, for MVC
|
||||
int non_idr_flag; //!< 0 = current is IDR
|
||||
int priority_id; //!< a lower value of priority_id specifies a higher priority
|
||||
int view_id; //!< view identifier for the NAL unit
|
||||
int temporal_id; //!< temporal identifier for the NAL unit
|
||||
int anchor_pic_flag; //!< anchor access unit
|
||||
int inter_view_flag; //!< inter-view prediction enable
|
||||
int reserved_one_bit; //!< shall be equal to 1
|
||||
int svc_extension_flag; //!< should be always 0, for MVC
|
||||
int non_idr_flag; //!< 0 = current is IDR
|
||||
int priority_id; //!< a lower value of priority_id specifies a higher priority
|
||||
int view_id; //!< view identifier for the NAL unit
|
||||
int temporal_id; //!< temporal identifier for the NAL unit
|
||||
int anchor_pic_flag; //!< anchor access unit
|
||||
int inter_view_flag; //!< inter-view prediction enable
|
||||
int reserved_one_bit; //!< shall be equal to 1
|
||||
#endif
|
||||
} NALU_t;
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* \brief
|
||||
* Picture writing routine headers
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Karsten Suehring <suehring@hhi.de>
|
||||
***************************************************************************************
|
||||
*/
|
||||
|
@ -14,11 +15,12 @@
|
|||
#ifndef _OUTPUT_H_
|
||||
#define _OUTPUT_H_
|
||||
|
||||
|
||||
extern void write_stored_frame(VideoParameters *p_Vid, FrameStore *fs, int p_out);
|
||||
extern void direct_output (VideoParameters *p_Vid, StorablePicture *p, int p_out);
|
||||
extern void init_out_buffer (VideoParameters *p_Vid);
|
||||
extern void uninit_out_buffer (VideoParameters *p_Vid);
|
||||
extern void write_stored_frame(VideoParameters *p_Vid, FrameStore *fs,
|
||||
int p_out);
|
||||
extern void direct_output(VideoParameters *p_Vid, StorablePicture *p,
|
||||
int p_out);
|
||||
extern void init_out_buffer(VideoParameters *p_Vid);
|
||||
extern void uninit_out_buffer(VideoParameters *p_Vid);
|
||||
#if (PAIR_FIELDS_IN_OUTPUT)
|
||||
extern void flush_pending_output(VideoParameters *p_Vid, int p_out);
|
||||
#endif
|
||||
|
|
|
@ -14,85 +14,101 @@
|
|||
#define _PARAMS_H_
|
||||
|
||||
#include "defines.h"
|
||||
#include "types.h"
|
||||
#include "vui_params.h"
|
||||
#include "frame.h"
|
||||
#include "io_video.h"
|
||||
#include "types.h"
|
||||
#include "vui_params.h"
|
||||
|
||||
//! all input parameters
|
||||
struct inp_par_enc
|
||||
{
|
||||
int ProfileIDC; //!< value of syntax element profile_idc
|
||||
int LevelIDC; //!< value of syntax element level_idc
|
||||
int IntraProfile; //!< Enable Intra profiles
|
||||
|
||||
int no_frames; //!< number of frames to be encoded
|
||||
int qp[NUM_SLICE_TYPES]; //!< QP values for all slice types
|
||||
int qp2frame; //!< frame in display order from which to apply the Change QP offsets
|
||||
int qp2off[NUM_SLICE_TYPES]; //!< Change QP offset values for all slice types
|
||||
int qpsp; //!< QPSP quantization value
|
||||
int frame_skip; //!< number of frames to skip in input sequence (e.g 2 takes frame 0,3,6,9...)
|
||||
int jumpd; /*!< number of frames to skip in input sequence including intermediate pictures
|
||||
(e.g 2 takes frame 0,3,6,9...) */
|
||||
int DisableSubpelME; //!< Disable sub-pixel motion estimation
|
||||
int search_range; /*!< search range - integer pel search and 16x16 blocks. The search window is
|
||||
generally around the predicted vector. Max vector is 2xmcrange. */
|
||||
int num_ref_frames; //!< number of reference frames to be used
|
||||
int P_List0_refs; //!< number of reference picture in list 0 in P pictures
|
||||
int B_List0_refs; //!< number of reference picture in list 0 in B pictures
|
||||
int B_List1_refs; //!< number of reference picture in list 1 in B pictures
|
||||
int Log2MaxFNumMinus4; //!< value of syntax element log2_max_frame_num
|
||||
int Log2MaxPOCLsbMinus4; //!< value of syntax element log2_max_pic_order_cnt_lsb_minus4
|
||||
struct inp_par_enc {
|
||||
int ProfileIDC; //!< value of syntax element profile_idc
|
||||
int LevelIDC; //!< value of syntax element level_idc
|
||||
int IntraProfile; //!< Enable Intra profiles
|
||||
|
||||
int no_frames; //!< number of frames to be encoded
|
||||
int qp[NUM_SLICE_TYPES]; //!< QP values for all slice types
|
||||
int qp2frame; //!< frame in display order from which to apply the Change QP
|
||||
//!< offsets
|
||||
int qp2off[NUM_SLICE_TYPES]; //!< Change QP offset values for all slice types
|
||||
int qpsp; //!< QPSP quantization value
|
||||
int frame_skip; //!< number of frames to skip in input sequence (e.g 2 takes
|
||||
//!< frame 0,3,6,9...)
|
||||
int jumpd; /*!< number of frames to skip in input sequence including
|
||||
intermediate pictures (e.g 2 takes frame 0,3,6,9...) */
|
||||
int DisableSubpelME; //!< Disable sub-pixel motion estimation
|
||||
int search_range; /*!< search range - integer pel search and 16x16 blocks. The
|
||||
search window is generally around the predicted vector.
|
||||
Max vector is 2xmcrange. */
|
||||
int num_ref_frames; //!< number of reference frames to be used
|
||||
int P_List0_refs; //!< number of reference picture in list 0 in P pictures
|
||||
int B_List0_refs; //!< number of reference picture in list 0 in B pictures
|
||||
int B_List1_refs; //!< number of reference picture in list 1 in B pictures
|
||||
int Log2MaxFNumMinus4; //!< value of syntax element log2_max_frame_num
|
||||
int Log2MaxPOCLsbMinus4; //!< value of syntax element
|
||||
//!< log2_max_pic_order_cnt_lsb_minus4
|
||||
|
||||
// Input/output sequence format related variables
|
||||
FrameFormat source; //!< source related information
|
||||
FrameFormat output; //!< output related information
|
||||
FrameFormat source; //!< source related information
|
||||
FrameFormat output; //!< output related information
|
||||
int is_interleaved;
|
||||
int src_resize; //!< Control if input sequence will be resized (currently only cropping is supported)
|
||||
int src_BitDepthRescale; //!< Control if input sequence bitdepth should be adjusted
|
||||
int yuv_format; //!< YUV format (0=4:0:0, 1=4:2:0, 2=4:2:2, 3=4:4:4)
|
||||
int intra_upd; /*!< For error robustness. 0: no special action. 1: One GOB/frame is intra coded
|
||||
as regular 'update'. 2: One GOB every 2 frames is intra coded etc.
|
||||
In connection with this intra update, restrictions is put on motion vectors
|
||||
to prevent errors to propagate from the past */
|
||||
int src_resize; //!< Control if input sequence will be resized (currently only
|
||||
//!< cropping is supported)
|
||||
int src_BitDepthRescale; //!< Control if input sequence bitdepth should be
|
||||
//!< adjusted
|
||||
int yuv_format; //!< YUV format (0=4:0:0, 1=4:2:0, 2=4:2:2, 3=4:4:4)
|
||||
int intra_upd; /*!< For error robustness. 0: no special action. 1: One
|
||||
GOB/frame is intra coded as regular 'update'. 2: One GOB
|
||||
every 2 frames is intra coded etc. In connection with this
|
||||
intra update, restrictions is put on motion vectors to
|
||||
prevent errors to propagate from the past */
|
||||
|
||||
int slice_mode; //!< Indicate what algorithm to use for setting slices
|
||||
int slice_argument; //!< Argument to the specified slice algorithm
|
||||
int UseConstrainedIntraPred; //!< 0: Inter MB pixels are allowed for intra prediction 1: Not allowed
|
||||
int SetFirstAsLongTerm; //!< Support for temporal considerations for CB plus encoding
|
||||
int infile_header; //!< If input file has a header set this to the length of the header
|
||||
int MultiSourceData;
|
||||
VideoDataFile input_file2; //!< Input video file2
|
||||
VideoDataFile input_file3; //!< Input video file3
|
||||
int slice_mode; //!< Indicate what algorithm to use for setting slices
|
||||
int slice_argument; //!< Argument to the specified slice algorithm
|
||||
int UseConstrainedIntraPred; //!< 0: Inter MB pixels are allowed for intra
|
||||
//!< prediction 1: Not allowed
|
||||
int SetFirstAsLongTerm; //!< Support for temporal considerations for CB plus
|
||||
//!< encoding
|
||||
int infile_header; //!< If input file has a header set this to the length of
|
||||
//!< the header
|
||||
int MultiSourceData;
|
||||
VideoDataFile input_file2; //!< Input video file2
|
||||
VideoDataFile input_file3; //!< Input video file3
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
int num_of_views; //!< number of views to encode (1=1view, 2=2views)
|
||||
int MVCInterViewReorder; //!< Reorder References according to interview pictures
|
||||
int MVCFlipViews; //!< Reverse the order of the views in the bitstream (view 1 has VOIdx 0 and view 1 has VOIdx 0)
|
||||
int MVCInterViewForceB; //!< Force B slices for enhancement layer
|
||||
int View1QPOffset; //!< QP offset during rate control for View 1
|
||||
int enable_inter_view_flag; //!< Enables inter_view_flag (allows pictures that are to be used for inter-view only prediction)
|
||||
int num_of_views; //!< number of views to encode (1=1view, 2=2views)
|
||||
int MVCInterViewReorder; //!< Reorder References according to interview
|
||||
//!< pictures
|
||||
int MVCFlipViews; //!< Reverse the order of the views in the bitstream (view 1
|
||||
//!< has VOIdx 0 and view 1 has VOIdx 0)
|
||||
int MVCInterViewForceB; //!< Force B slices for enhancement layer
|
||||
int View1QPOffset; //!< QP offset during rate control for View 1
|
||||
int enable_inter_view_flag; //!< Enables inter_view_flag (allows pictures that
|
||||
//!< are to be used for inter-view only
|
||||
//!< prediction)
|
||||
#endif
|
||||
|
||||
VideoDataFile input_file1; //!< Input video file1
|
||||
signed char outfile [FILE_NAME_SIZE]; //!< H.264 compressed output bitstream
|
||||
signed char ReconFile [FILE_NAME_SIZE]; //!< Reconstructed Pictures (view 0 for MVC profile)
|
||||
signed char ReconFile2 [FILE_NAME_SIZE]; //!< Reconstructed Pictures (view 1)
|
||||
VideoDataFile input_file1; //!< Input video file1
|
||||
signed char outfile[FILE_NAME_SIZE]; //!< H.264 compressed output bitstream
|
||||
signed char ReconFile[FILE_NAME_SIZE]; //!< Reconstructed Pictures (view 0 for
|
||||
//!< MVC profile)
|
||||
signed char ReconFile2[FILE_NAME_SIZE]; //!< Reconstructed Pictures (view 1)
|
||||
|
||||
signed char TraceFile [FILE_NAME_SIZE]; //!< Trace Outputs
|
||||
signed char StatsFile [FILE_NAME_SIZE]; //!< Stats File
|
||||
signed char QmatrixFile [FILE_NAME_SIZE]; //!< Q matrix cfg file
|
||||
int ProcessInput; //!< Filter Input Sequence
|
||||
int EnableOpenGOP; //!< support for open gops.
|
||||
int EnableIDRGOP; //!< support for IDR closed gops with no shared B coded pictures.
|
||||
int grayscale; //!< encode in grayscale (Currently only works for 8 bit, YUV 420)
|
||||
signed char TraceFile[FILE_NAME_SIZE]; //!< Trace Outputs
|
||||
signed char StatsFile[FILE_NAME_SIZE]; //!< Stats File
|
||||
signed char QmatrixFile[FILE_NAME_SIZE]; //!< Q matrix cfg file
|
||||
int ProcessInput; //!< Filter Input Sequence
|
||||
int EnableOpenGOP; //!< support for open gops.
|
||||
int EnableIDRGOP; //!< support for IDR closed gops with no shared B coded
|
||||
//!< pictures.
|
||||
int grayscale; //!< encode in grayscale (Currently only works for 8 bit, YUV
|
||||
//!< 420)
|
||||
|
||||
int idr_period; //!< IDR picture period
|
||||
int intra_period; //!< intra picture period
|
||||
int intra_delay; //!< IDR picture delay
|
||||
int idr_period; //!< IDR picture period
|
||||
int intra_period; //!< intra picture period
|
||||
int intra_delay; //!< IDR picture delay
|
||||
int adaptive_idr_period;
|
||||
int adaptive_intra_period; //!< reinitialize start of intra period
|
||||
int adaptive_intra_period; //!< reinitialize start of intra period
|
||||
|
||||
int start_frame; //!< Encode sequence starting from Frame start_frame
|
||||
int start_frame; //!< Encode sequence starting from Frame start_frame
|
||||
|
||||
int enable_32_pulldown;
|
||||
|
||||
|
@ -103,77 +119,109 @@ struct inp_par_enc
|
|||
int ResendSPS;
|
||||
int ResendPPS;
|
||||
|
||||
int SendAUD; //!< send Access Unit Delimiter NALU
|
||||
int skip_gl_stats;
|
||||
int SendAUD; //!< send Access Unit Delimiter NALU
|
||||
int skip_gl_stats;
|
||||
|
||||
// B pictures
|
||||
int NumberBFrames; //!< number of B frames that will be used
|
||||
int NumberBFrames; //!< number of B frames that will be used
|
||||
int PReplaceBSlice;
|
||||
int qpBRSOffset; //!< QP for reference B slice coded pictures
|
||||
int direct_spatial_mv_pred_flag; //!< Direct Mode type to be used (0: Temporal, 1: Spatial)
|
||||
int directInferenceFlag; //!< Direct Mode Inference Flag
|
||||
int qpBRSOffset; //!< QP for reference B slice coded pictures
|
||||
int direct_spatial_mv_pred_flag; //!< Direct Mode type to be used (0:
|
||||
//!< Temporal, 1: Spatial)
|
||||
int directInferenceFlag; //!< Direct Mode Inference Flag
|
||||
|
||||
int BiPredMotionEstimation; //!< Use of Bipredictive motion estimation
|
||||
int BiPredSearch[4]; //!< Bipredictive motion estimation for modes 16x16, 16x8, 8x16, and 8x8
|
||||
int BiPredMERefinements; //!< Max number of Iterations for Bi-predictive motion estimation
|
||||
int BiPredMESearchRange; //!< Search range of Bi-predictive motion estimation
|
||||
int BiPredMESubPel; //!< Use of subpixel refinement for Bi-predictive motion estimation
|
||||
int BiPredMotionEstimation; //!< Use of Bipredictive motion estimation
|
||||
int BiPredSearch[4]; //!< Bipredictive motion estimation for modes 16x16,
|
||||
//!< 16x8, 8x16, and 8x8
|
||||
int BiPredMERefinements; //!< Max number of Iterations for Bi-predictive
|
||||
//!< motion estimation
|
||||
int BiPredMESearchRange; //!< Search range of Bi-predictive motion estimation
|
||||
int BiPredMESubPel; //!< Use of subpixel refinement for Bi-predictive motion
|
||||
//!< estimation
|
||||
|
||||
// SP/SI Pictures
|
||||
int sp_periodicity; //!< The periodicity of SP-pictures
|
||||
int sp_switch_period; //!< Switch period (in terms of switching SP/SI frames) between bitstream 1 and bitstream 2
|
||||
int si_frame_indicator; //!< Flag indicating whether SI frames should be encoded rather than SP frames (0: not used, 1: used)
|
||||
int sp2_frame_indicator; //!< Flag indicating whether switching SP frames should be encoded rather than SP frames (0: not used, 1: used)
|
||||
int sp_output_indicator; //!< Flag indicating whether coefficients are output to allow future encoding of switchin SP frames (0: not used, 1: used)
|
||||
signed char sp_output_filename[FILE_NAME_SIZE]; //!<Filename where SP coefficients are output
|
||||
signed char sp2_input_filename1[FILE_NAME_SIZE]; //!<Filename of coefficients of the first bitstream when encoding SP frames to switch bitstreams
|
||||
signed char sp2_input_filename2[FILE_NAME_SIZE]; //!<Filenames of coefficients of the second bitstream when encoding SP frames to switch bitstreams
|
||||
int sp_periodicity; //!< The periodicity of SP-pictures
|
||||
int sp_switch_period; //!< Switch period (in terms of switching SP/SI frames)
|
||||
//!< between bitstream 1 and bitstream 2
|
||||
int si_frame_indicator; //!< Flag indicating whether SI frames should be
|
||||
//!< encoded rather than SP frames (0: not used, 1:
|
||||
//!< used)
|
||||
int sp2_frame_indicator; //!< Flag indicating whether switching SP frames
|
||||
//!< should be encoded rather than SP frames (0: not
|
||||
//!< used, 1: used)
|
||||
int sp_output_indicator; //!< Flag indicating whether coefficients are output
|
||||
//!< to allow future encoding of switchin SP frames
|
||||
//!< (0: not used, 1: used)
|
||||
signed char sp_output_filename[FILE_NAME_SIZE]; //!< Filename where SP
|
||||
//!< coefficients are output
|
||||
signed char
|
||||
sp2_input_filename1[FILE_NAME_SIZE]; //!< Filename of coefficients of the
|
||||
//!< first bitstream when encoding SP
|
||||
//!< frames to switch bitstreams
|
||||
signed char
|
||||
sp2_input_filename2[FILE_NAME_SIZE]; //!< Filenames of coefficients of the
|
||||
//!< second bitstream when encoding
|
||||
//!< SP frames to switch bitstreams
|
||||
|
||||
// Weighted Prediction
|
||||
int WeightedPrediction; //!< Weighted prediction for P frames (0: not used, 1: explicit)
|
||||
int WeightedBiprediction; //!< Weighted prediction for B frames (0: not used, 1: explicit, 2: implicit)
|
||||
int WPMethod; //!< WP method (0: DC, 1: LMS)
|
||||
int WPIterMC; //!< Iterative WP method
|
||||
int WeightedPrediction; //!< Weighted prediction for P frames (0: not used, 1:
|
||||
//!< explicit)
|
||||
int WeightedBiprediction; //!< Weighted prediction for B frames (0: not used,
|
||||
//!< 1: explicit, 2: implicit)
|
||||
int WPMethod; //!< WP method (0: DC, 1: LMS)
|
||||
int WPIterMC; //!< Iterative WP method
|
||||
int WPMCPrecision;
|
||||
int WPMCPrecFullRef;
|
||||
int WPMCPrecBSlice;
|
||||
int EnhancedBWeightSupport;
|
||||
int ChromaWeightSupport; //!< Weighted prediction support for chroma (0: disabled, 1: enabled)
|
||||
int UseWeightedReferenceME; //!< Use Weighted Reference for ME.
|
||||
int RDPictureDecision; //!< Perform RD optimal decision between various coded versions of same picture
|
||||
int RDPSliceBTest; //!< Tests B slice replacement for P.
|
||||
int RDPSliceITest; //!< Tests I slice replacement for P.
|
||||
int RDPictureMaxPassISlice; //!< Max # of coding passes for I-slice
|
||||
int RDPictureMaxPassPSlice; //!< Max # of coding passes for P-slice
|
||||
int RDPictureMaxPassBSlice; //!< Max # of coding passes for B-slice
|
||||
int RDPictureDeblocking; //!< Whether to choose between deblocked and non-deblocked picture
|
||||
int RDPictureDirectMode; //!< Whether to check the other direct mode for B slices
|
||||
int RDPictureFrameQPPSlice; //!< Whether to check additional frame level QP values for P slices
|
||||
int RDPictureFrameQPBSlice; //!< Whether to check additional frame level QP values for B slices
|
||||
int ChromaWeightSupport; //!< Weighted prediction support for chroma (0:
|
||||
//!< disabled, 1: enabled)
|
||||
int UseWeightedReferenceME; //!< Use Weighted Reference for ME.
|
||||
int RDPictureDecision; //!< Perform RD optimal decision between various coded
|
||||
//!< versions of same picture
|
||||
int RDPSliceBTest; //!< Tests B slice replacement for P.
|
||||
int RDPSliceITest; //!< Tests I slice replacement for P.
|
||||
int RDPictureMaxPassISlice; //!< Max # of coding passes for I-slice
|
||||
int RDPictureMaxPassPSlice; //!< Max # of coding passes for P-slice
|
||||
int RDPictureMaxPassBSlice; //!< Max # of coding passes for B-slice
|
||||
int RDPictureDeblocking; //!< Whether to choose between deblocked and
|
||||
//!< non-deblocked picture
|
||||
int RDPictureDirectMode; //!< Whether to check the other direct mode for B
|
||||
//!< slices
|
||||
int RDPictureFrameQPPSlice; //!< Whether to check additional frame level QP
|
||||
//!< values for P slices
|
||||
int RDPictureFrameQPBSlice; //!< Whether to check additional frame level QP
|
||||
//!< values for B slices
|
||||
|
||||
int SkipIntraInInterSlices; //!< Skip intra type checking in inter slices if best_mode is skip/direct
|
||||
int BRefPictures; //!< B coded reference pictures replace P pictures (0: not used, 1: used)
|
||||
int SkipIntraInInterSlices; //!< Skip intra type checking in inter slices if
|
||||
//!< best_mode is skip/direct
|
||||
int BRefPictures; //!< B coded reference pictures replace P pictures (0: not
|
||||
//!< used, 1: used)
|
||||
int HierarchicalCoding;
|
||||
int HierarchyLevelQPEnable;
|
||||
signed char ExplicitHierarchyFormat[INPUT_TEXT_SIZE]; //!< Explicit GOP format (HierarchicalCoding==3).
|
||||
signed char
|
||||
ExplicitHierarchyFormat[INPUT_TEXT_SIZE]; //!< Explicit GOP format
|
||||
//!< (HierarchicalCoding==3).
|
||||
// explicit sequence information parameters
|
||||
int ExplicitSeqCoding;
|
||||
int ExplicitSeqCoding;
|
||||
signed char ExplicitSeqFile[FILE_NAME_SIZE];
|
||||
int LowDelay; //!< Apply HierarchicalCoding without delay (i.e., encode in the captured/display order)
|
||||
int LowDelay; //!< Apply HierarchicalCoding without delay (i.e., encode in the
|
||||
//!< captured/display order)
|
||||
|
||||
int ReferenceReorder; //!< Reordering based on Poc distances
|
||||
int PocMemoryManagement; //!< Memory management based on Poc distances for hierarchical coding
|
||||
int ReferenceReorder; //!< Reordering based on Poc distances
|
||||
int PocMemoryManagement; //!< Memory management based on Poc distances for
|
||||
//!< hierarchical coding
|
||||
|
||||
int symbol_mode; //!< Specifies the mode the symbols are mapped on bits
|
||||
int of_mode; //!< Specifies the mode of the output file
|
||||
int partition_mode; //!< Specifies the mode of data partitioning
|
||||
int symbol_mode; //!< Specifies the mode the symbols are mapped on bits
|
||||
int of_mode; //!< Specifies the mode of the output file
|
||||
int partition_mode; //!< Specifies the mode of data partitioning
|
||||
|
||||
int InterSearch[2][8];
|
||||
|
||||
int DisableIntra4x4;
|
||||
int DisableIntra16x16;
|
||||
int FastMDEnable;
|
||||
int FastIntraMD;
|
||||
int FastMDEnable;
|
||||
int FastIntraMD;
|
||||
int FastIntra4x4;
|
||||
int FastIntra16x16;
|
||||
int FastIntra8x8;
|
||||
|
@ -196,14 +244,14 @@ struct inp_par_enc
|
|||
int full_search;
|
||||
|
||||
int rdopt;
|
||||
int de; //!< the algorithm to estimate the distortion in the decoder
|
||||
int I16rdo;
|
||||
int de; //!< the algorithm to estimate the distortion in the decoder
|
||||
int I16rdo;
|
||||
int subMBCodingState;
|
||||
int Distortion[TOTAL_DIST_TYPES];
|
||||
double VisualResWavPSNR;
|
||||
int SSIMOverlapSize;
|
||||
int DistortionYUVtoRGB;
|
||||
int CtxAdptLagrangeMult; //!< context adaptive lagrangian multiplier
|
||||
int CtxAdptLagrangeMult; //!< context adaptive lagrangian multiplier
|
||||
int FastCrIntraDecision;
|
||||
int disthres;
|
||||
int nobskip;
|
||||
|
@ -211,26 +259,32 @@ struct inp_par_enc
|
|||
int ForceTrueRateRDO;
|
||||
|
||||
#ifdef _LEAKYBUCKET_
|
||||
int NumberLeakyBuckets;
|
||||
int NumberLeakyBuckets;
|
||||
signed char LeakyBucketRateFile[FILE_NAME_SIZE];
|
||||
signed char LeakyBucketParamFile[FILE_NAME_SIZE];
|
||||
#endif
|
||||
|
||||
int PicInterlace; //!< picture adaptive frame/field
|
||||
int MbInterlace; //!< macroblock adaptive frame/field
|
||||
int IntraBottom; //!< Force Intra Bottom at GOP periods.
|
||||
int PicInterlace; //!< picture adaptive frame/field
|
||||
int MbInterlace; //!< macroblock adaptive frame/field
|
||||
int IntraBottom; //!< Force Intra Bottom at GOP periods.
|
||||
|
||||
// Error resilient RDO parameters
|
||||
double LossRateA; //!< assumed loss probablility of partition A (or full slice), in per cent, used for loss-aware R/D optimization
|
||||
double LossRateB; //!< assumed loss probablility of partition B, in per cent, used for loss-aware R/D
|
||||
double LossRateC; //!< assumed loss probablility of partition C, in per cent, used for loss-aware R/D
|
||||
int FirstFrameCorrect; //!< the first frame is encoded under the assumption that it is always correctly received.
|
||||
double
|
||||
LossRateA; //!< assumed loss probablility of partition A (or full slice),
|
||||
//!< in per cent, used for loss-aware R/D optimization
|
||||
double LossRateB; //!< assumed loss probablility of partition B, in per cent,
|
||||
//!< used for loss-aware R/D
|
||||
double LossRateC; //!< assumed loss probablility of partition C, in per cent,
|
||||
//!< used for loss-aware R/D
|
||||
int FirstFrameCorrect; //!< the first frame is encoded under the assumption
|
||||
//!< that it is always correctly received.
|
||||
int NoOfDecoders;
|
||||
int ErrorConcealment; //!< Error concealment method used for loss-aware RDO (0: Copy Concealment)
|
||||
int ErrorConcealment; //!< Error concealment method used for loss-aware RDO
|
||||
//!< (0: Copy Concealment)
|
||||
int RestrictRef;
|
||||
int NumFramesInELSubSeq;
|
||||
|
||||
int RandomIntraMBRefresh; //!< Number of pseudo-random intra-MBs per picture
|
||||
int RandomIntraMBRefresh; //!< Number of pseudo-random intra-MBs per picture
|
||||
|
||||
// Chroma interpolation and buffering
|
||||
int ChromaMCBuffer;
|
||||
|
@ -239,33 +293,38 @@ struct inp_par_enc
|
|||
int MEErrorMetric[3];
|
||||
int ModeDecisionMetric;
|
||||
int SkipDeBlockNonRef;
|
||||
|
||||
|
||||
// Deblocking Filter parameters
|
||||
int DFSendParameters;
|
||||
int DFDisableIdc[2][NUM_SLICE_TYPES];
|
||||
int DFAlpha [2][NUM_SLICE_TYPES];
|
||||
int DFBeta [2][NUM_SLICE_TYPES];
|
||||
int DFAlpha[2][NUM_SLICE_TYPES];
|
||||
int DFBeta[2][NUM_SLICE_TYPES];
|
||||
|
||||
int SparePictureOption;
|
||||
int SPDetectionThreshold;
|
||||
int SPPercentageThreshold;
|
||||
|
||||
// FMO
|
||||
signed char SliceGroupConfigFileName[FILE_NAME_SIZE]; //!< Filename for config info fot type 0, 2, 6
|
||||
int num_slice_groups_minus1; //!< "FmoNumSliceGroups" in encoder.cfg, same as FmoNumSliceGroups, which should be erased later
|
||||
signed char
|
||||
SliceGroupConfigFileName[FILE_NAME_SIZE]; //!< Filename for config info
|
||||
//!< fot type 0, 2, 6
|
||||
int num_slice_groups_minus1; //!< "FmoNumSliceGroups" in encoder.cfg, same as
|
||||
//!< FmoNumSliceGroups, which should be erased
|
||||
//!< later
|
||||
int slice_group_map_type;
|
||||
|
||||
unsigned int *top_left; //!< top_left and bottom_right store values indicating foregrounds
|
||||
unsigned int *top_left; //!< top_left and bottom_right store values indicating
|
||||
//!< foregrounds
|
||||
unsigned int *bottom_right;
|
||||
byte *slice_group_id; //!< slice_group_id is for slice group type being 6
|
||||
int *run_length_minus1; //!< run_length_minus1 is for slice group type being 0
|
||||
byte *slice_group_id; //!< slice_group_id is for slice group type being 6
|
||||
int *run_length_minus1; //!< run_length_minus1 is for slice group type being 0
|
||||
|
||||
int slice_group_change_direction_flag;
|
||||
int slice_group_change_rate_minus1;
|
||||
int slice_group_change_cycle;
|
||||
|
||||
int redundant_pic_flag; //! encoding of redundant pictures
|
||||
int pic_order_cnt_type; //! POC type
|
||||
int redundant_pic_flag; //! encoding of redundant pictures
|
||||
int pic_order_cnt_type; //! POC type
|
||||
|
||||
int context_init_method;
|
||||
int model_number;
|
||||
|
@ -285,18 +344,18 @@ struct inp_par_enc
|
|||
double RCBoverPRatio;
|
||||
double RCISliceBitRatio;
|
||||
double RCBSliceBitRatio[RC_MAX_TEMPORAL_LEVELS];
|
||||
int RCMinQP[NUM_SLICE_TYPES];
|
||||
int RCMaxQP[NUM_SLICE_TYPES];
|
||||
int RCMaxQPChange;
|
||||
int RCMinQP[NUM_SLICE_TYPES];
|
||||
int RCMaxQP[NUM_SLICE_TYPES];
|
||||
int RCMaxQPChange;
|
||||
|
||||
// Motion Estimation related parameters
|
||||
int UseMVLimits;
|
||||
int SetMVXLimit;
|
||||
int SetMVYLimit;
|
||||
int UseMVLimits;
|
||||
int SetMVXLimit;
|
||||
int SetMVYLimit;
|
||||
|
||||
// Search Algorithm
|
||||
SearchType SearchMode;
|
||||
|
||||
|
||||
// UMHEX related parameters
|
||||
int UMHexDSR;
|
||||
int UMHexScale;
|
||||
|
@ -322,17 +381,22 @@ struct inp_par_enc
|
|||
double LambdaWeight[6];
|
||||
double FixedLambda[6];
|
||||
|
||||
signed char QOffsetMatrixFile[FILE_NAME_SIZE]; //!< Quantization Offset matrix cfg file
|
||||
int OffsetMatrixPresentFlag; //!< Enable Explicit Quantization Offset Matrices
|
||||
signed char QOffsetMatrixFile[FILE_NAME_SIZE]; //!< Quantization Offset matrix
|
||||
//!< cfg file
|
||||
int OffsetMatrixPresentFlag; //!< Enable Explicit Quantization Offset Matrices
|
||||
|
||||
int AdaptiveRounding; //!< Adaptive Rounding parameter based on JVT-N011
|
||||
int AdaptRoundingFixed; //!< Global rounding for all qps
|
||||
int AdaptRndPeriod; //!< Set period for adaptive rounding of JVT-N011 in MBs
|
||||
int AdaptiveRounding; //!< Adaptive Rounding parameter based on JVT-N011
|
||||
int AdaptRoundingFixed; //!< Global rounding for all qps
|
||||
int AdaptRndPeriod; //!< Set period for adaptive rounding of JVT-N011 in MBs
|
||||
int AdaptRndChroma;
|
||||
int AdaptRndWFactor [2][NUM_SLICE_TYPES]; //!< Weighting factors for luma component based on reference indicator and slice type
|
||||
int AdaptRndCrWFactor[2][NUM_SLICE_TYPES]; //!< Weighting factors for chroma components based on reference indicator and slice type
|
||||
int AdaptRndWFactor[2][NUM_SLICE_TYPES]; //!< Weighting factors for luma
|
||||
//!< component based on reference
|
||||
//!< indicator and slice type
|
||||
int AdaptRndCrWFactor[2][NUM_SLICE_TYPES]; //!< Weighting factors for chroma
|
||||
//!< components based on reference
|
||||
//!< indicator and slice type
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Fidelity Range Extensions
|
||||
int ScalingMatrixPresentFlag;
|
||||
int ScalingListPresentFlag[12];
|
||||
|
@ -348,19 +412,24 @@ struct inp_par_enc
|
|||
int DisposableP;
|
||||
int DispPQPOffset;
|
||||
|
||||
//Redundant picture
|
||||
int NumRedundantHierarchy; //!< number of entries to allocate redundant pictures in a GOP
|
||||
int PrimaryGOPLength; //!< GOP length of primary pictures
|
||||
int NumRefPrimary; //!< number of reference frames for primary picture
|
||||
// Redundant picture
|
||||
int NumRedundantHierarchy; //!< number of entries to allocate redundant
|
||||
//!< pictures in a GOP
|
||||
int PrimaryGOPLength; //!< GOP length of primary pictures
|
||||
int NumRefPrimary; //!< number of reference frames for primary picture
|
||||
|
||||
// tone mapping SEI message
|
||||
int ToneMappingSEIPresentFlag;
|
||||
signed char ToneMappingFile[FILE_NAME_SIZE]; //!< ToneMapping SEI message cfg file
|
||||
signed char
|
||||
ToneMappingFile[FILE_NAME_SIZE]; //!< ToneMapping SEI message cfg file
|
||||
|
||||
// prediction structure
|
||||
int PreferDispOrder; //!< Prefer display order when building the prediction structure as opposed to coding order
|
||||
int PreferPowerOfTwo; //!< Prefer prediction structures that have lengths expressed as powers of two
|
||||
int FrmStructBufferLength; //!< Number of frames that is populated every time populate_frm_struct is called
|
||||
int PreferDispOrder; //!< Prefer display order when building the prediction
|
||||
//!< structure as opposed to coding order
|
||||
int PreferPowerOfTwo; //!< Prefer prediction structures that have lengths
|
||||
//!< expressed as powers of two
|
||||
int FrmStructBufferLength; //!< Number of frames that is populated every time
|
||||
//!< populate_frm_struct is called
|
||||
|
||||
int separate_colour_plane_flag;
|
||||
double WeightY;
|
||||
|
@ -369,7 +438,7 @@ struct inp_par_enc
|
|||
int UseRDOQuant;
|
||||
int RDOQ_DC;
|
||||
int RDOQ_CR;
|
||||
int RDOQ_DC_CR;
|
||||
int RDOQ_DC_CR;
|
||||
int RDOQ_QP_Num;
|
||||
int RDOQ_CP_Mode;
|
||||
int RDOQ_CP_MV;
|
||||
|
@ -380,10 +449,9 @@ struct inp_par_enc
|
|||
VUIParameters VUI;
|
||||
// end of VUI parameters
|
||||
|
||||
int MinIDRDistance;
|
||||
int stdRange; //!< 1 - standard range, 0 - full range
|
||||
int videoCode; //!< 1 - 709, 3 - 601: See VideoCode in io_tiff.
|
||||
int MinIDRDistance;
|
||||
int stdRange; //!< 1 - standard range, 0 - full range
|
||||
int videoCode; //!< 1 - 709, 3 - 601: See VideoCode in io_tiff.
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -5,63 +5,70 @@
|
|||
* parset.h
|
||||
* \brief
|
||||
* Picture and Sequence Parameter Sets, decoder operations
|
||||
*
|
||||
*
|
||||
* \date 25 November 2002
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||
***************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _PARSET_H_
|
||||
#define _PARSET_H_
|
||||
|
||||
#include "parsetcommon.h"
|
||||
#include "nalucommon.h"
|
||||
#include "parsetcommon.h"
|
||||
|
||||
static const byte ZZ_SCAN[16] =
|
||||
{ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
|
||||
};
|
||||
static const byte ZZ_SCAN[16] = {0, 1, 4, 8, 5, 2, 3, 6,
|
||||
9, 12, 13, 10, 7, 11, 14, 15};
|
||||
|
||||
static const byte ZZ_SCAN8[64] =
|
||||
{ 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
|
||||
};
|
||||
static const byte ZZ_SCAN8[64] = {
|
||||
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};
|
||||
|
||||
extern void Scaling_List(int *scalingList, int sizeOfScalingList, Boolean *UseDefaultScalingMatrix, Bitstream *s);
|
||||
extern void Scaling_List(int *scalingList, int sizeOfScalingList,
|
||||
Boolean *UseDefaultScalingMatrix, Bitstream *s);
|
||||
|
||||
extern void InitVUI(seq_parameter_set_rbsp_t *sps);
|
||||
extern int ReadVUI(DataPartition *p, seq_parameter_set_rbsp_t *sps);
|
||||
extern int ReadHRDParameters(DataPartition *p, hrd_parameters_t *hrd);
|
||||
extern int ReadVUI(DataPartition *p, seq_parameter_set_rbsp_t *sps);
|
||||
extern int ReadHRDParameters(DataPartition *p, hrd_parameters_t *hrd);
|
||||
|
||||
extern void PPSConsistencyCheck (pic_parameter_set_rbsp_t *pps);
|
||||
extern void SPSConsistencyCheck (seq_parameter_set_rbsp_t *sps);
|
||||
extern void PPSConsistencyCheck(pic_parameter_set_rbsp_t *pps);
|
||||
extern void SPSConsistencyCheck(seq_parameter_set_rbsp_t *sps);
|
||||
|
||||
extern void MakePPSavailable (VideoParameters *p_Vid, int id, pic_parameter_set_rbsp_t *pps);
|
||||
extern void MakeSPSavailable (VideoParameters *p_Vid, int id, seq_parameter_set_rbsp_t *sps);
|
||||
extern void MakePPSavailable(VideoParameters *p_Vid, int id,
|
||||
pic_parameter_set_rbsp_t *pps);
|
||||
extern void MakeSPSavailable(VideoParameters *p_Vid, int id,
|
||||
seq_parameter_set_rbsp_t *sps);
|
||||
|
||||
extern void ProcessSPS (VideoParameters *p_Vid, NALU_t *nalu);
|
||||
extern void ProcessPPS (VideoParameters *p_Vid, NALU_t *nalu);
|
||||
extern void ProcessSPS(VideoParameters *p_Vid, NALU_t *nalu);
|
||||
extern void ProcessPPS(VideoParameters *p_Vid, NALU_t *nalu);
|
||||
|
||||
extern void CleanUpPPS(VideoParameters *p_Vid);
|
||||
|
||||
extern void activate_sps (VideoParameters *p_Vid, seq_parameter_set_rbsp_t *sps);
|
||||
extern void activate_pps (VideoParameters *p_Vid, pic_parameter_set_rbsp_t *pps);
|
||||
extern void activate_sps(VideoParameters *p_Vid, seq_parameter_set_rbsp_t *sps);
|
||||
extern void activate_pps(VideoParameters *p_Vid, pic_parameter_set_rbsp_t *pps);
|
||||
|
||||
extern void UseParameterSet (Slice *currSlice);
|
||||
extern void UseParameterSet(Slice *currSlice);
|
||||
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
extern void SubsetSPSConsistencyCheck (subset_seq_parameter_set_rbsp_t *subset_sps);
|
||||
extern void ProcessSubsetSPS (VideoParameters *p_Vid, NALU_t *nalu);
|
||||
extern void
|
||||
SubsetSPSConsistencyCheck(subset_seq_parameter_set_rbsp_t *subset_sps);
|
||||
extern void ProcessSubsetSPS(VideoParameters *p_Vid, NALU_t *nalu);
|
||||
|
||||
extern void mvc_vui_parameters_extension(MVCVUI_t *pMVCVUI, Bitstream *s);
|
||||
extern void seq_parameter_set_mvc_extension(subset_seq_parameter_set_rbsp_t *subset_sps, Bitstream *s);
|
||||
extern void init_subset_sps_list(subset_seq_parameter_set_rbsp_t *subset_sps_list, int iSize);
|
||||
extern void
|
||||
seq_parameter_set_mvc_extension(subset_seq_parameter_set_rbsp_t *subset_sps,
|
||||
Bitstream *s);
|
||||
extern void
|
||||
init_subset_sps_list(subset_seq_parameter_set_rbsp_t *subset_sps_list,
|
||||
int iSize);
|
||||
extern void reset_subset_sps(subset_seq_parameter_set_rbsp_t *subset_sps);
|
||||
extern int GetBaseViewId(VideoParameters *p_Vid, subset_seq_parameter_set_rbsp_t **subset_sps);
|
||||
extern int GetBaseViewId(VideoParameters *p_Vid,
|
||||
subset_seq_parameter_set_rbsp_t **subset_sps);
|
||||
extern void get_max_dec_frame_buf_size(seq_parameter_set_rbsp_t *sps);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
* \file
|
||||
* parsetcommon.h
|
||||
* \brief
|
||||
* Picture and Sequence Parameter Sets, structures common to encoder and decoder
|
||||
* Picture and Sequence Parameter Sets, structures common to encoder and
|
||||
*decoder
|
||||
*
|
||||
* \date 25 November 2002
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||
***************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// In the JVT syntax, frequently flags are used that indicate the presence of
|
||||
// certain pieces of information in the NALU. Here, these flags are also
|
||||
// present. In the encoder, those bits indicate that the values signaled to
|
||||
|
@ -28,205 +28,196 @@
|
|||
|
||||
#include "defines.h"
|
||||
|
||||
#define MAXIMUMPARSETRBSPSIZE 1500
|
||||
#define MAXIMUMPARSETNALUSIZE 1500
|
||||
#define MAXIMUMPARSETRBSPSIZE 1500
|
||||
#define MAXIMUMPARSETNALUSIZE 1500
|
||||
|
||||
#define MAXSPS 32
|
||||
#define MAXPPS 256
|
||||
#define MAXSPS 32
|
||||
#define MAXPPS 256
|
||||
|
||||
#define MAXIMUMVALUEOFcpb_cnt 32
|
||||
typedef struct
|
||||
{
|
||||
unsigned int cpb_cnt_minus1; // ue(v)
|
||||
unsigned int bit_rate_scale; // u(4)
|
||||
unsigned int cpb_size_scale; // u(4)
|
||||
unsigned int bit_rate_value_minus1 [MAXIMUMVALUEOFcpb_cnt]; // ue(v)
|
||||
unsigned int cpb_size_value_minus1 [MAXIMUMVALUEOFcpb_cnt]; // ue(v)
|
||||
unsigned int cbr_flag [MAXIMUMVALUEOFcpb_cnt]; // u(1)
|
||||
unsigned int initial_cpb_removal_delay_length_minus1; // u(5)
|
||||
unsigned int cpb_removal_delay_length_minus1; // u(5)
|
||||
unsigned int dpb_output_delay_length_minus1; // u(5)
|
||||
unsigned int time_offset_length; // u(5)
|
||||
#define MAXIMUMVALUEOFcpb_cnt 32
|
||||
typedef struct {
|
||||
unsigned int cpb_cnt_minus1; // ue(v)
|
||||
unsigned int bit_rate_scale; // u(4)
|
||||
unsigned int cpb_size_scale; // u(4)
|
||||
unsigned int bit_rate_value_minus1[MAXIMUMVALUEOFcpb_cnt]; // ue(v)
|
||||
unsigned int cpb_size_value_minus1[MAXIMUMVALUEOFcpb_cnt]; // ue(v)
|
||||
unsigned int cbr_flag[MAXIMUMVALUEOFcpb_cnt]; // u(1)
|
||||
unsigned int initial_cpb_removal_delay_length_minus1; // u(5)
|
||||
unsigned int cpb_removal_delay_length_minus1; // u(5)
|
||||
unsigned int dpb_output_delay_length_minus1; // u(5)
|
||||
unsigned int time_offset_length; // u(5)
|
||||
} hrd_parameters_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Boolean aspect_ratio_info_present_flag; // u(1)
|
||||
unsigned int aspect_ratio_idc; // u(8)
|
||||
unsigned short sar_width; // u(16)
|
||||
unsigned short sar_height; // u(16)
|
||||
Boolean overscan_info_present_flag; // u(1)
|
||||
Boolean overscan_appropriate_flag; // u(1)
|
||||
Boolean video_signal_type_present_flag; // u(1)
|
||||
unsigned int video_format; // u(3)
|
||||
Boolean video_full_range_flag; // u(1)
|
||||
Boolean colour_description_present_flag; // u(1)
|
||||
unsigned int colour_primaries; // u(8)
|
||||
unsigned int transfer_characteristics; // u(8)
|
||||
unsigned int matrix_coefficients; // u(8)
|
||||
Boolean chroma_location_info_present_flag; // u(1)
|
||||
unsigned int chroma_sample_loc_type_top_field; // ue(v)
|
||||
unsigned int chroma_sample_loc_type_bottom_field; // ue(v)
|
||||
Boolean timing_info_present_flag; // u(1)
|
||||
unsigned int num_units_in_tick; // u(32)
|
||||
unsigned int time_scale; // u(32)
|
||||
Boolean fixed_frame_rate_flag; // u(1)
|
||||
Boolean nal_hrd_parameters_present_flag; // u(1)
|
||||
hrd_parameters_t nal_hrd_parameters; // hrd_paramters_t
|
||||
Boolean vcl_hrd_parameters_present_flag; // u(1)
|
||||
hrd_parameters_t vcl_hrd_parameters; // hrd_paramters_t
|
||||
typedef struct {
|
||||
Boolean aspect_ratio_info_present_flag; // u(1)
|
||||
unsigned int aspect_ratio_idc; // u(8)
|
||||
unsigned short sar_width; // u(16)
|
||||
unsigned short sar_height; // u(16)
|
||||
Boolean overscan_info_present_flag; // u(1)
|
||||
Boolean overscan_appropriate_flag; // u(1)
|
||||
Boolean video_signal_type_present_flag; // u(1)
|
||||
unsigned int video_format; // u(3)
|
||||
Boolean video_full_range_flag; // u(1)
|
||||
Boolean colour_description_present_flag; // u(1)
|
||||
unsigned int colour_primaries; // u(8)
|
||||
unsigned int transfer_characteristics; // u(8)
|
||||
unsigned int matrix_coefficients; // u(8)
|
||||
Boolean chroma_location_info_present_flag; // u(1)
|
||||
unsigned int chroma_sample_loc_type_top_field; // ue(v)
|
||||
unsigned int chroma_sample_loc_type_bottom_field; // ue(v)
|
||||
Boolean timing_info_present_flag; // u(1)
|
||||
unsigned int num_units_in_tick; // u(32)
|
||||
unsigned int time_scale; // u(32)
|
||||
Boolean fixed_frame_rate_flag; // u(1)
|
||||
Boolean nal_hrd_parameters_present_flag; // u(1)
|
||||
hrd_parameters_t nal_hrd_parameters; // hrd_paramters_t
|
||||
Boolean vcl_hrd_parameters_present_flag; // u(1)
|
||||
hrd_parameters_t vcl_hrd_parameters; // hrd_paramters_t
|
||||
// if ((nal_hrd_parameters_present_flag || (vcl_hrd_parameters_present_flag))
|
||||
Boolean low_delay_hrd_flag; // u(1)
|
||||
Boolean pic_struct_present_flag; // u(1)
|
||||
Boolean bitstream_restriction_flag; // u(1)
|
||||
Boolean motion_vectors_over_pic_boundaries_flag; // u(1)
|
||||
unsigned int max_bytes_per_pic_denom; // ue(v)
|
||||
unsigned int max_bits_per_mb_denom; // ue(v)
|
||||
unsigned int log2_max_mv_length_vertical; // ue(v)
|
||||
unsigned int log2_max_mv_length_horizontal; // ue(v)
|
||||
unsigned int num_reorder_frames; // ue(v)
|
||||
unsigned int max_dec_frame_buffering; // ue(v)
|
||||
Boolean low_delay_hrd_flag; // u(1)
|
||||
Boolean pic_struct_present_flag; // u(1)
|
||||
Boolean bitstream_restriction_flag; // u(1)
|
||||
Boolean motion_vectors_over_pic_boundaries_flag; // u(1)
|
||||
unsigned int max_bytes_per_pic_denom; // ue(v)
|
||||
unsigned int max_bits_per_mb_denom; // ue(v)
|
||||
unsigned int log2_max_mv_length_vertical; // ue(v)
|
||||
unsigned int log2_max_mv_length_horizontal; // ue(v)
|
||||
unsigned int num_reorder_frames; // ue(v)
|
||||
unsigned int max_dec_frame_buffering; // ue(v)
|
||||
} vui_seq_parameters_t;
|
||||
|
||||
#define MAXnum_slice_groups_minus1 8
|
||||
typedef struct {
|
||||
Boolean Valid; // indicates the parameter set is valid
|
||||
unsigned int pic_parameter_set_id; // ue(v)
|
||||
unsigned int seq_parameter_set_id; // ue(v)
|
||||
Boolean entropy_coding_mode_flag; // u(1)
|
||||
Boolean transform_8x8_mode_flag; // u(1)
|
||||
|
||||
#define MAXnum_slice_groups_minus1 8
|
||||
typedef struct
|
||||
{
|
||||
Boolean Valid; // indicates the parameter set is valid
|
||||
unsigned int pic_parameter_set_id; // ue(v)
|
||||
unsigned int seq_parameter_set_id; // ue(v)
|
||||
Boolean entropy_coding_mode_flag; // u(1)
|
||||
Boolean transform_8x8_mode_flag; // u(1)
|
||||
|
||||
Boolean pic_scaling_matrix_present_flag; // u(1)
|
||||
int pic_scaling_list_present_flag[12]; // u(1)
|
||||
int ScalingList4x4[6][16]; // se(v)
|
||||
int ScalingList8x8[6][64]; // se(v)
|
||||
Boolean UseDefaultScalingMatrix4x4Flag[6];
|
||||
Boolean UseDefaultScalingMatrix8x8Flag[6];
|
||||
Boolean pic_scaling_matrix_present_flag; // u(1)
|
||||
int pic_scaling_list_present_flag[12]; // u(1)
|
||||
int ScalingList4x4[6][16]; // se(v)
|
||||
int ScalingList8x8[6][64]; // se(v)
|
||||
Boolean UseDefaultScalingMatrix4x4Flag[6];
|
||||
Boolean UseDefaultScalingMatrix8x8Flag[6];
|
||||
|
||||
// if( pic_order_cnt_type < 2 ) in the sequence parameter set
|
||||
Boolean bottom_field_pic_order_in_frame_present_flag; // u(1)
|
||||
unsigned int num_slice_groups_minus1; // ue(v)
|
||||
unsigned int slice_group_map_type; // ue(v)
|
||||
Boolean bottom_field_pic_order_in_frame_present_flag; // u(1)
|
||||
unsigned int num_slice_groups_minus1; // ue(v)
|
||||
unsigned int slice_group_map_type; // ue(v)
|
||||
// if( slice_group_map_type = = 0 )
|
||||
unsigned int run_length_minus1[MAXnum_slice_groups_minus1]; // ue(v)
|
||||
// else if( slice_group_map_type = = 2 )
|
||||
unsigned int top_left[MAXnum_slice_groups_minus1]; // ue(v)
|
||||
unsigned int bottom_right[MAXnum_slice_groups_minus1]; // ue(v)
|
||||
unsigned int top_left[MAXnum_slice_groups_minus1]; // ue(v)
|
||||
unsigned int bottom_right[MAXnum_slice_groups_minus1]; // ue(v)
|
||||
// else if( slice_group_map_type = = 3 || 4 || 5
|
||||
Boolean slice_group_change_direction_flag; // u(1)
|
||||
unsigned int slice_group_change_rate_minus1; // ue(v)
|
||||
Boolean slice_group_change_direction_flag; // u(1)
|
||||
unsigned int slice_group_change_rate_minus1; // ue(v)
|
||||
// else if( slice_group_map_type = = 6 )
|
||||
unsigned int pic_size_in_map_units_minus1; // ue(v)
|
||||
byte *slice_group_id; // complete MBAmap u(v)
|
||||
unsigned int pic_size_in_map_units_minus1; // ue(v)
|
||||
byte *slice_group_id; // complete MBAmap u(v)
|
||||
|
||||
int num_ref_idx_l0_active_minus1; // ue(v)
|
||||
int num_ref_idx_l1_active_minus1; // ue(v)
|
||||
Boolean weighted_pred_flag; // u(1)
|
||||
unsigned int weighted_bipred_idc; // u(2)
|
||||
int pic_init_qp_minus26; // se(v)
|
||||
int pic_init_qs_minus26; // se(v)
|
||||
int chroma_qp_index_offset; // se(v)
|
||||
int num_ref_idx_l0_active_minus1; // ue(v)
|
||||
int num_ref_idx_l1_active_minus1; // ue(v)
|
||||
Boolean weighted_pred_flag; // u(1)
|
||||
unsigned int weighted_bipred_idc; // u(2)
|
||||
int pic_init_qp_minus26; // se(v)
|
||||
int pic_init_qs_minus26; // se(v)
|
||||
int chroma_qp_index_offset; // se(v)
|
||||
|
||||
int second_chroma_qp_index_offset; // se(v)
|
||||
int second_chroma_qp_index_offset; // se(v)
|
||||
|
||||
Boolean deblocking_filter_control_present_flag; // u(1)
|
||||
Boolean constrained_intra_pred_flag; // u(1)
|
||||
Boolean redundant_pic_cnt_present_flag; // u(1)
|
||||
Boolean deblocking_filter_control_present_flag; // u(1)
|
||||
Boolean constrained_intra_pred_flag; // u(1)
|
||||
Boolean redundant_pic_cnt_present_flag; // u(1)
|
||||
} pic_parameter_set_rbsp_t;
|
||||
|
||||
#define MAXnum_ref_frames_in_pic_order_cnt_cycle 256
|
||||
typedef struct {
|
||||
Boolean Valid; // indicates the parameter set is valid
|
||||
|
||||
#define MAXnum_ref_frames_in_pic_order_cnt_cycle 256
|
||||
typedef struct
|
||||
{
|
||||
Boolean Valid; // indicates the parameter set is valid
|
||||
|
||||
unsigned int profile_idc; // u(8)
|
||||
Boolean constrained_set0_flag; // u(1)
|
||||
Boolean constrained_set1_flag; // u(1)
|
||||
Boolean constrained_set2_flag; // u(1)
|
||||
Boolean constrained_set3_flag; // u(1)
|
||||
unsigned int profile_idc; // u(8)
|
||||
Boolean constrained_set0_flag; // u(1)
|
||||
Boolean constrained_set1_flag; // u(1)
|
||||
Boolean constrained_set2_flag; // u(1)
|
||||
Boolean constrained_set3_flag; // u(1)
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
Boolean constrained_set4_flag; // u(1)
|
||||
Boolean constrained_set4_flag; // u(1)
|
||||
#endif
|
||||
unsigned int level_idc; // u(8)
|
||||
unsigned int seq_parameter_set_id; // ue(v)
|
||||
unsigned int chroma_format_idc; // ue(v)
|
||||
unsigned int level_idc; // u(8)
|
||||
unsigned int seq_parameter_set_id; // ue(v)
|
||||
unsigned int chroma_format_idc; // ue(v)
|
||||
|
||||
Boolean seq_scaling_matrix_present_flag; // u(1)
|
||||
int seq_scaling_list_present_flag[12]; // u(1)
|
||||
int ScalingList4x4[6][16]; // se(v)
|
||||
int ScalingList8x8[6][64]; // se(v)
|
||||
Boolean UseDefaultScalingMatrix4x4Flag[6];
|
||||
Boolean UseDefaultScalingMatrix8x8Flag[6];
|
||||
Boolean seq_scaling_matrix_present_flag; // u(1)
|
||||
int seq_scaling_list_present_flag[12]; // u(1)
|
||||
int ScalingList4x4[6][16]; // se(v)
|
||||
int ScalingList8x8[6][64]; // se(v)
|
||||
Boolean UseDefaultScalingMatrix4x4Flag[6];
|
||||
Boolean UseDefaultScalingMatrix8x8Flag[6];
|
||||
|
||||
unsigned int bit_depth_luma_minus8; // ue(v)
|
||||
unsigned int bit_depth_chroma_minus8; // ue(v)
|
||||
unsigned int log2_max_frame_num_minus4; // ue(v)
|
||||
unsigned int bit_depth_luma_minus8; // ue(v)
|
||||
unsigned int bit_depth_chroma_minus8; // ue(v)
|
||||
unsigned int log2_max_frame_num_minus4; // ue(v)
|
||||
unsigned int pic_order_cnt_type;
|
||||
// if( pic_order_cnt_type == 0 )
|
||||
unsigned int log2_max_pic_order_cnt_lsb_minus4; // ue(v)
|
||||
unsigned int log2_max_pic_order_cnt_lsb_minus4; // ue(v)
|
||||
// else if( pic_order_cnt_type == 1 )
|
||||
Boolean delta_pic_order_always_zero_flag; // u(1)
|
||||
int offset_for_non_ref_pic; // se(v)
|
||||
int offset_for_top_to_bottom_field; // se(v)
|
||||
unsigned int num_ref_frames_in_pic_order_cnt_cycle; // ue(v)
|
||||
// for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ )
|
||||
int offset_for_ref_frame[MAXnum_ref_frames_in_pic_order_cnt_cycle]; // se(v)
|
||||
unsigned int num_ref_frames; // ue(v)
|
||||
Boolean gaps_in_frame_num_value_allowed_flag; // u(1)
|
||||
unsigned int pic_width_in_mbs_minus1; // ue(v)
|
||||
unsigned int pic_height_in_map_units_minus1; // ue(v)
|
||||
Boolean frame_mbs_only_flag; // u(1)
|
||||
Boolean delta_pic_order_always_zero_flag; // u(1)
|
||||
int offset_for_non_ref_pic; // se(v)
|
||||
int offset_for_top_to_bottom_field; // se(v)
|
||||
unsigned int num_ref_frames_in_pic_order_cnt_cycle; // ue(v)
|
||||
// for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ )
|
||||
int offset_for_ref_frame[MAXnum_ref_frames_in_pic_order_cnt_cycle]; // se(v)
|
||||
unsigned int num_ref_frames; // ue(v)
|
||||
Boolean gaps_in_frame_num_value_allowed_flag; // u(1)
|
||||
unsigned int pic_width_in_mbs_minus1; // ue(v)
|
||||
unsigned int pic_height_in_map_units_minus1; // ue(v)
|
||||
Boolean frame_mbs_only_flag; // u(1)
|
||||
// if( !frame_mbs_only_flag )
|
||||
Boolean mb_adaptive_frame_field_flag; // u(1)
|
||||
Boolean direct_8x8_inference_flag; // u(1)
|
||||
Boolean frame_cropping_flag; // u(1)
|
||||
unsigned int frame_cropping_rect_left_offset; // ue(v)
|
||||
unsigned int frame_cropping_rect_right_offset; // ue(v)
|
||||
unsigned int frame_cropping_rect_top_offset; // ue(v)
|
||||
unsigned int frame_cropping_rect_bottom_offset; // ue(v)
|
||||
Boolean vui_parameters_present_flag; // u(1)
|
||||
vui_seq_parameters_t vui_seq_parameters; // vui_seq_parameters_t
|
||||
unsigned separate_colour_plane_flag; // u(1)
|
||||
Boolean mb_adaptive_frame_field_flag; // u(1)
|
||||
Boolean direct_8x8_inference_flag; // u(1)
|
||||
Boolean frame_cropping_flag; // u(1)
|
||||
unsigned int frame_cropping_rect_left_offset; // ue(v)
|
||||
unsigned int frame_cropping_rect_right_offset; // ue(v)
|
||||
unsigned int frame_cropping_rect_top_offset; // ue(v)
|
||||
unsigned int frame_cropping_rect_bottom_offset; // ue(v)
|
||||
Boolean vui_parameters_present_flag; // u(1)
|
||||
vui_seq_parameters_t vui_seq_parameters; // vui_seq_parameters_t
|
||||
unsigned separate_colour_plane_flag; // u(1)
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
int max_dec_frame_buffering;
|
||||
int max_dec_frame_buffering;
|
||||
#endif
|
||||
} seq_parameter_set_rbsp_t;
|
||||
|
||||
#if (MVC_EXTENSION_ENABLE)
|
||||
typedef struct mvcvui_tag
|
||||
{
|
||||
int num_ops_minus1;
|
||||
signed char *temporal_id;
|
||||
int *num_target_output_views_minus1;
|
||||
int **view_id;
|
||||
signed char *timing_info_present_flag;
|
||||
int *num_units_in_tick;
|
||||
int *time_scale;
|
||||
signed char *fixed_frame_rate_flag;
|
||||
signed char *nal_hrd_parameters_present_flag;
|
||||
signed char *vcl_hrd_parameters_present_flag;
|
||||
signed char *low_delay_hrd_flag;
|
||||
signed char *pic_struct_present_flag;
|
||||
typedef struct mvcvui_tag {
|
||||
int num_ops_minus1;
|
||||
signed char *temporal_id;
|
||||
int *num_target_output_views_minus1;
|
||||
int **view_id;
|
||||
signed char *timing_info_present_flag;
|
||||
int *num_units_in_tick;
|
||||
int *time_scale;
|
||||
signed char *fixed_frame_rate_flag;
|
||||
signed char *nal_hrd_parameters_present_flag;
|
||||
signed char *vcl_hrd_parameters_present_flag;
|
||||
signed char *low_delay_hrd_flag;
|
||||
signed char *pic_struct_present_flag;
|
||||
|
||||
//hrd parameters;
|
||||
signed char cpb_cnt_minus1;
|
||||
signed char bit_rate_scale;
|
||||
signed char cpb_size_scale;
|
||||
int bit_rate_value_minus1[32];
|
||||
int cpb_size_value_minus1[32];
|
||||
signed char cbr_flag[32];
|
||||
signed char initial_cpb_removal_delay_length_minus1;
|
||||
signed char cpb_removal_delay_length_minus1;
|
||||
signed char dpb_output_delay_length_minus1;
|
||||
signed char time_offset_length;
|
||||
}MVCVUI_t;
|
||||
// hrd parameters;
|
||||
signed char cpb_cnt_minus1;
|
||||
signed char bit_rate_scale;
|
||||
signed char cpb_size_scale;
|
||||
int bit_rate_value_minus1[32];
|
||||
int cpb_size_value_minus1[32];
|
||||
signed char cbr_flag[32];
|
||||
signed char initial_cpb_removal_delay_length_minus1;
|
||||
signed char cpb_removal_delay_length_minus1;
|
||||
signed char dpb_output_delay_length_minus1;
|
||||
signed char time_offset_length;
|
||||
} MVCVUI_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
seq_parameter_set_rbsp_t sps;
|
||||
|
||||
unsigned int bit_equal_to_one;
|
||||
|
@ -241,7 +232,7 @@ typedef struct
|
|||
int **non_anchor_ref_l0;
|
||||
int *num_non_anchor_refs_l1;
|
||||
int **non_anchor_ref_l1;
|
||||
|
||||
|
||||
int num_level_values_signalled_minus1;
|
||||
int *level_idc;
|
||||
int *num_applicable_ops_minus1;
|
||||
|
@ -251,21 +242,23 @@ typedef struct
|
|||
int **applicable_op_num_views_minus1;
|
||||
|
||||
unsigned int mvc_vui_parameters_present_flag;
|
||||
Boolean Valid; // indicates the parameter set is valid
|
||||
MVCVUI_t MVCVUIParams;
|
||||
Boolean Valid; // indicates the parameter set is valid
|
||||
MVCVUI_t MVCVUIParams;
|
||||
} subset_seq_parameter_set_rbsp_t;
|
||||
|
||||
subset_seq_parameter_set_rbsp_t *AllocSubsetSPS (void);
|
||||
void FreeSubsetSPS (subset_seq_parameter_set_rbsp_t *subset_sps);
|
||||
subset_seq_parameter_set_rbsp_t *AllocSubsetSPS(void);
|
||||
void FreeSubsetSPS(subset_seq_parameter_set_rbsp_t *subset_sps);
|
||||
#endif
|
||||
|
||||
pic_parameter_set_rbsp_t *AllocPPS (void);
|
||||
seq_parameter_set_rbsp_t *AllocSPS (void);
|
||||
pic_parameter_set_rbsp_t *AllocPPS(void);
|
||||
seq_parameter_set_rbsp_t *AllocSPS(void);
|
||||
|
||||
void FreePPS (pic_parameter_set_rbsp_t *pps);
|
||||
void FreeSPS (seq_parameter_set_rbsp_t *sps);
|
||||
void FreePPS(pic_parameter_set_rbsp_t *pps);
|
||||
void FreeSPS(seq_parameter_set_rbsp_t *sps);
|
||||
|
||||
int sps_is_equal(seq_parameter_set_rbsp_t *sps1, seq_parameter_set_rbsp_t *sps2);
|
||||
int pps_is_equal(pic_parameter_set_rbsp_t *pps1, pic_parameter_set_rbsp_t *pps2);
|
||||
int sps_is_equal(seq_parameter_set_rbsp_t *sps1,
|
||||
seq_parameter_set_rbsp_t *sps2);
|
||||
int pps_is_equal(pic_parameter_set_rbsp_t *pps1,
|
||||
pic_parameter_set_rbsp_t *pps2);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,155 +15,101 @@
|
|||
#define _QUANT_H_
|
||||
|
||||
// exported variables
|
||||
static const int dequant_coef8[6][8][8] =
|
||||
{
|
||||
{
|
||||
{20, 19, 25, 19, 20, 19, 25, 19},
|
||||
{19, 18, 24, 18, 19, 18, 24, 18},
|
||||
{25, 24, 32, 24, 25, 24, 32, 24},
|
||||
{19, 18, 24, 18, 19, 18, 24, 18},
|
||||
{20, 19, 25, 19, 20, 19, 25, 19},
|
||||
{19, 18, 24, 18, 19, 18, 24, 18},
|
||||
{25, 24, 32, 24, 25, 24, 32, 24},
|
||||
{19, 18, 24, 18, 19, 18, 24, 18}
|
||||
},
|
||||
{
|
||||
{22, 21, 28, 21, 22, 21, 28, 21},
|
||||
{21, 19, 26, 19, 21, 19, 26, 19},
|
||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
||||
{21, 19, 26, 19, 21, 19, 26, 19},
|
||||
{22, 21, 28, 21, 22, 21, 28, 21},
|
||||
{21, 19, 26, 19, 21, 19, 26, 19},
|
||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
||||
{21, 19, 26, 19, 21, 19, 26, 19}
|
||||
},
|
||||
{
|
||||
{26, 24, 33, 24, 26, 24, 33, 24},
|
||||
{24, 23, 31, 23, 24, 23, 31, 23},
|
||||
{33, 31, 42, 31, 33, 31, 42, 31},
|
||||
{24, 23, 31, 23, 24, 23, 31, 23},
|
||||
{26, 24, 33, 24, 26, 24, 33, 24},
|
||||
{24, 23, 31, 23, 24, 23, 31, 23},
|
||||
{33, 31, 42, 31, 33, 31, 42, 31},
|
||||
{24, 23, 31, 23, 24, 23, 31, 23}
|
||||
},
|
||||
{
|
||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
||||
{26, 25, 33, 25, 26, 25, 33, 25},
|
||||
{35, 33, 45, 33, 35, 33, 45, 33},
|
||||
{26, 25, 33, 25, 26, 25, 33, 25},
|
||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
||||
{26, 25, 33, 25, 26, 25, 33, 25},
|
||||
{35, 33, 45, 33, 35, 33, 45, 33},
|
||||
{26, 25, 33, 25, 26, 25, 33, 25}
|
||||
},
|
||||
{
|
||||
{32, 30, 40, 30, 32, 30, 40, 30},
|
||||
{30, 28, 38, 28, 30, 28, 38, 28},
|
||||
{40, 38, 51, 38, 40, 38, 51, 38},
|
||||
{30, 28, 38, 28, 30, 28, 38, 28},
|
||||
{32, 30, 40, 30, 32, 30, 40, 30},
|
||||
{30, 28, 38, 28, 30, 28, 38, 28},
|
||||
{40, 38, 51, 38, 40, 38, 51, 38},
|
||||
{30, 28, 38, 28, 30, 28, 38, 28}
|
||||
},
|
||||
{
|
||||
{36, 34, 46, 34, 36, 34, 46, 34},
|
||||
{34, 32, 43, 32, 34, 32, 43, 32},
|
||||
{46, 43, 58, 43, 46, 43, 58, 43},
|
||||
{34, 32, 43, 32, 34, 32, 43, 32},
|
||||
{36, 34, 46, 34, 36, 34, 46, 34},
|
||||
{34, 32, 43, 32, 34, 32, 43, 32},
|
||||
{46, 43, 58, 43, 46, 43, 58, 43},
|
||||
{34, 32, 43, 32, 34, 32, 43, 32}
|
||||
}
|
||||
};
|
||||
|
||||
static const int dequant_coef8[6][8][8] = {{{20, 19, 25, 19, 20, 19, 25, 19},
|
||||
{19, 18, 24, 18, 19, 18, 24, 18},
|
||||
{25, 24, 32, 24, 25, 24, 32, 24},
|
||||
{19, 18, 24, 18, 19, 18, 24, 18},
|
||||
{20, 19, 25, 19, 20, 19, 25, 19},
|
||||
{19, 18, 24, 18, 19, 18, 24, 18},
|
||||
{25, 24, 32, 24, 25, 24, 32, 24},
|
||||
{19, 18, 24, 18, 19, 18, 24, 18}},
|
||||
{{22, 21, 28, 21, 22, 21, 28, 21},
|
||||
{21, 19, 26, 19, 21, 19, 26, 19},
|
||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
||||
{21, 19, 26, 19, 21, 19, 26, 19},
|
||||
{22, 21, 28, 21, 22, 21, 28, 21},
|
||||
{21, 19, 26, 19, 21, 19, 26, 19},
|
||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
||||
{21, 19, 26, 19, 21, 19, 26, 19}},
|
||||
{{26, 24, 33, 24, 26, 24, 33, 24},
|
||||
{24, 23, 31, 23, 24, 23, 31, 23},
|
||||
{33, 31, 42, 31, 33, 31, 42, 31},
|
||||
{24, 23, 31, 23, 24, 23, 31, 23},
|
||||
{26, 24, 33, 24, 26, 24, 33, 24},
|
||||
{24, 23, 31, 23, 24, 23, 31, 23},
|
||||
{33, 31, 42, 31, 33, 31, 42, 31},
|
||||
{24, 23, 31, 23, 24, 23, 31, 23}},
|
||||
{{28, 26, 35, 26, 28, 26, 35, 26},
|
||||
{26, 25, 33, 25, 26, 25, 33, 25},
|
||||
{35, 33, 45, 33, 35, 33, 45, 33},
|
||||
{26, 25, 33, 25, 26, 25, 33, 25},
|
||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
||||
{26, 25, 33, 25, 26, 25, 33, 25},
|
||||
{35, 33, 45, 33, 35, 33, 45, 33},
|
||||
{26, 25, 33, 25, 26, 25, 33, 25}},
|
||||
{{32, 30, 40, 30, 32, 30, 40, 30},
|
||||
{30, 28, 38, 28, 30, 28, 38, 28},
|
||||
{40, 38, 51, 38, 40, 38, 51, 38},
|
||||
{30, 28, 38, 28, 30, 28, 38, 28},
|
||||
{32, 30, 40, 30, 32, 30, 40, 30},
|
||||
{30, 28, 38, 28, 30, 28, 38, 28},
|
||||
{40, 38, 51, 38, 40, 38, 51, 38},
|
||||
{30, 28, 38, 28, 30, 28, 38, 28}},
|
||||
{{36, 34, 46, 34, 36, 34, 46, 34},
|
||||
{34, 32, 43, 32, 34, 32, 43, 32},
|
||||
{46, 43, 58, 43, 46, 43, 58, 43},
|
||||
{34, 32, 43, 32, 34, 32, 43, 32},
|
||||
{36, 34, 46, 34, 36, 34, 46, 34},
|
||||
{34, 32, 43, 32, 34, 32, 43, 32},
|
||||
{46, 43, 58, 43, 46, 43, 58, 43},
|
||||
{34, 32, 43, 32, 34, 32, 43, 32}}};
|
||||
|
||||
//! Dequantization coefficients
|
||||
static const int dequant_coef[6][4][4] = {
|
||||
{
|
||||
{ 10, 13, 10, 13},
|
||||
{ 13, 16, 13, 16},
|
||||
{ 10, 13, 10, 13},
|
||||
{ 13, 16, 13, 16}},
|
||||
{
|
||||
{ 11, 14, 11, 14},
|
||||
{ 14, 18, 14, 18},
|
||||
{ 11, 14, 11, 14},
|
||||
{ 14, 18, 14, 18}},
|
||||
{
|
||||
{ 13, 16, 13, 16},
|
||||
{ 16, 20, 16, 20},
|
||||
{ 13, 16, 13, 16},
|
||||
{ 16, 20, 16, 20}},
|
||||
{
|
||||
{ 14, 18, 14, 18},
|
||||
{ 18, 23, 18, 23},
|
||||
{ 14, 18, 14, 18},
|
||||
{ 18, 23, 18, 23}},
|
||||
{
|
||||
{ 16, 20, 16, 20},
|
||||
{ 20, 25, 20, 25},
|
||||
{ 16, 20, 16, 20},
|
||||
{ 20, 25, 20, 25}},
|
||||
{
|
||||
{ 18, 23, 18, 23},
|
||||
{ 23, 29, 23, 29},
|
||||
{ 18, 23, 18, 23},
|
||||
{ 23, 29, 23, 29}}
|
||||
};
|
||||
{{10, 13, 10, 13}, {13, 16, 13, 16}, {10, 13, 10, 13}, {13, 16, 13, 16}},
|
||||
{{11, 14, 11, 14}, {14, 18, 14, 18}, {11, 14, 11, 14}, {14, 18, 14, 18}},
|
||||
{{13, 16, 13, 16}, {16, 20, 16, 20}, {13, 16, 13, 16}, {16, 20, 16, 20}},
|
||||
{{14, 18, 14, 18}, {18, 23, 18, 23}, {14, 18, 14, 18}, {18, 23, 18, 23}},
|
||||
{{16, 20, 16, 20}, {20, 25, 20, 25}, {16, 20, 16, 20}, {20, 25, 20, 25}},
|
||||
{{18, 23, 18, 23}, {23, 29, 23, 29}, {18, 23, 18, 23}, {23, 29, 23, 29}}};
|
||||
|
||||
static const int quant_coef[6][4][4] = {
|
||||
{
|
||||
{ 13107, 8066, 13107, 8066},
|
||||
{ 8066, 5243, 8066, 5243},
|
||||
{ 13107, 8066, 13107, 8066},
|
||||
{ 8066, 5243, 8066, 5243}},
|
||||
{
|
||||
{ 11916, 7490, 11916, 7490},
|
||||
{ 7490, 4660, 7490, 4660},
|
||||
{ 11916, 7490, 11916, 7490},
|
||||
{ 7490, 4660, 7490, 4660}},
|
||||
{
|
||||
{ 10082, 6554, 10082, 6554},
|
||||
{ 6554, 4194, 6554, 4194},
|
||||
{ 10082, 6554, 10082, 6554},
|
||||
{ 6554, 4194, 6554, 4194}},
|
||||
{
|
||||
{ 9362, 5825, 9362, 5825},
|
||||
{ 5825, 3647, 5825, 3647},
|
||||
{ 9362, 5825, 9362, 5825},
|
||||
{ 5825, 3647, 5825, 3647}},
|
||||
{
|
||||
{ 8192, 5243, 8192, 5243},
|
||||
{ 5243, 3355, 5243, 3355},
|
||||
{ 8192, 5243, 8192, 5243},
|
||||
{ 5243, 3355, 5243, 3355}},
|
||||
{
|
||||
{ 7282, 4559, 7282, 4559},
|
||||
{ 4559, 2893, 4559, 2893},
|
||||
{ 7282, 4559, 7282, 4559},
|
||||
{ 4559, 2893, 4559, 2893}}
|
||||
};
|
||||
static const int quant_coef[6][4][4] = {{{13107, 8066, 13107, 8066},
|
||||
{8066, 5243, 8066, 5243},
|
||||
{13107, 8066, 13107, 8066},
|
||||
{8066, 5243, 8066, 5243}},
|
||||
{{11916, 7490, 11916, 7490},
|
||||
{7490, 4660, 7490, 4660},
|
||||
{11916, 7490, 11916, 7490},
|
||||
{7490, 4660, 7490, 4660}},
|
||||
{{10082, 6554, 10082, 6554},
|
||||
{6554, 4194, 6554, 4194},
|
||||
{10082, 6554, 10082, 6554},
|
||||
{6554, 4194, 6554, 4194}},
|
||||
{{9362, 5825, 9362, 5825},
|
||||
{5825, 3647, 5825, 3647},
|
||||
{9362, 5825, 9362, 5825},
|
||||
{5825, 3647, 5825, 3647}},
|
||||
{{8192, 5243, 8192, 5243},
|
||||
{5243, 3355, 5243, 3355},
|
||||
{8192, 5243, 8192, 5243},
|
||||
{5243, 3355, 5243, 3355}},
|
||||
{{7282, 4559, 7282, 4559},
|
||||
{4559, 2893, 4559, 2893},
|
||||
{7282, 4559, 7282, 4559},
|
||||
{4559, 2893, 4559, 2893}}};
|
||||
|
||||
// SP decoding parameter (EQ. 8-425)
|
||||
static const int A[4][4] = {
|
||||
{ 16, 20, 16, 20},
|
||||
{ 20, 25, 20, 25},
|
||||
{ 16, 20, 16, 20},
|
||||
{ 20, 25, 20, 25}
|
||||
};
|
||||
{16, 20, 16, 20}, {20, 25, 20, 25}, {16, 20, 16, 20}, {20, 25, 20, 25}};
|
||||
|
||||
// exported functions
|
||||
// quantization initialization
|
||||
extern void init_qp_process (VideoParameters *p_Vid);
|
||||
extern void init_qp_process(VideoParameters *p_Vid);
|
||||
extern void free_qp_matrices(VideoParameters *p_Vid);
|
||||
|
||||
// For Q-matrix
|
||||
extern void assign_quant_params (Slice *currslice);
|
||||
extern void assign_quant_params(Slice *currslice);
|
||||
extern void CalculateQuant4x4Param(Slice *currslice);
|
||||
extern void CalculateQuant8x8Param(Slice *currslice);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#define _QUANT_PARAMS_H_
|
||||
|
||||
typedef struct level_quant_params {
|
||||
int OffsetComp;
|
||||
int ScaleComp;
|
||||
int OffsetComp;
|
||||
int ScaleComp;
|
||||
int InvScaleComp;
|
||||
} LevelQuantParams;
|
||||
|
||||
|
@ -37,12 +37,12 @@ typedef struct quant_params {
|
|||
} QuantParameters;
|
||||
|
||||
typedef struct quant_methods {
|
||||
int block_y;
|
||||
int block_x;
|
||||
int qp;
|
||||
int* ACLevel;
|
||||
int* ACRun;
|
||||
int **fadjust;
|
||||
int block_y;
|
||||
int block_x;
|
||||
int qp;
|
||||
int *ACLevel;
|
||||
int *ACRun;
|
||||
int **fadjust;
|
||||
LevelQuantParams **q_params;
|
||||
int *coeff_cost;
|
||||
const byte (*pos_scan)[2];
|
||||
|
@ -51,4 +51,3 @@ typedef struct quant_methods {
|
|||
} QuantMethods;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -13,13 +13,15 @@
|
|||
#ifndef _REPORT_H_
|
||||
#define _REPORT_H_
|
||||
#include "contributors.h"
|
||||
#include "global.h"
|
||||
#include "enc_statistics.h"
|
||||
#include "global.h"
|
||||
|
||||
extern void report ( VideoParameters *p_Vid, InputParameters *p_Inp, StatParameters *p_Stats );
|
||||
extern void information_init ( VideoParameters *p_Vid, InputParameters *p_Inp, StatParameters *p_Stats );
|
||||
extern void report_frame_statistic( VideoParameters *p_Vid, InputParameters *p_Inp );
|
||||
extern void report_stats_on_error (void);
|
||||
extern void report(VideoParameters *p_Vid, InputParameters *p_Inp,
|
||||
StatParameters *p_Stats);
|
||||
extern void information_init(VideoParameters *p_Vid, InputParameters *p_Inp,
|
||||
StatParameters *p_Stats);
|
||||
extern void report_frame_statistic(VideoParameters *p_Vid,
|
||||
InputParameters *p_Inp);
|
||||
extern void report_stats_on_error(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -13,34 +13,36 @@
|
|||
|
||||
#include "nalucommon.h"
|
||||
|
||||
#define MAXRTPPAYLOADLEN (65536 - 40) //!< Maximum payload size of an RTP packet */
|
||||
#define MAXRTPPACKETSIZE (65536 - 28) //!< Maximum size of an RTP packet incl. header */
|
||||
#define H264PAYLOADTYPE 105 //!< RTP paylaod type fixed here for simplicity*/
|
||||
#define H264SSRC 0x12345678 //!< SSRC, chosen to simplify debugging */
|
||||
#define RTP_TR_TIMESTAMP_MULT 1000 //!< should be something like 27 Mhz / 29.97 Hz */
|
||||
#define MAXRTPPAYLOADLEN \
|
||||
(65536 - 40) //!< Maximum payload size of an RTP packet */
|
||||
#define MAXRTPPACKETSIZE \
|
||||
(65536 - 28) //!< Maximum size of an RTP packet incl. header */
|
||||
#define H264PAYLOADTYPE 105 //!< RTP paylaod type fixed here for simplicity*/
|
||||
#define H264SSRC 0x12345678 //!< SSRC, chosen to simplify debugging */
|
||||
#define RTP_TR_TIMESTAMP_MULT \
|
||||
1000 //!< should be something like 27 Mhz / 29.97 Hz */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int v; //!< Version, 2 bits, MUST be 0x2
|
||||
unsigned int p; //!< Padding bit, Padding MUST NOT be used
|
||||
unsigned int x; //!< Extension, MUST be zero
|
||||
unsigned int cc; /*!< CSRC count, normally 0 in the absence
|
||||
of RTP mixers */
|
||||
unsigned int m; //!< Marker bit
|
||||
unsigned int pt; //!< 7 bits, Payload Type, dynamically established
|
||||
uint16 seq; /*!< RTP sequence number, incremented by one for
|
||||
each sent packet */
|
||||
unsigned int timestamp; //!< timestamp, 27 MHz for H.264
|
||||
unsigned int ssrc; //!< Synchronization Source, chosen randomly
|
||||
byte * payload; //!< the payload including payload headers
|
||||
unsigned int paylen; //!< length of payload in bytes
|
||||
byte * packet; //!< complete packet including header and payload
|
||||
unsigned int packlen; //!< length of packet, typically paylen+12
|
||||
typedef struct {
|
||||
unsigned int v; //!< Version, 2 bits, MUST be 0x2
|
||||
unsigned int p; //!< Padding bit, Padding MUST NOT be used
|
||||
unsigned int x; //!< Extension, MUST be zero
|
||||
unsigned int cc; /*!< CSRC count, normally 0 in the absence
|
||||
of RTP mixers */
|
||||
unsigned int m; //!< Marker bit
|
||||
unsigned int pt; //!< 7 bits, Payload Type, dynamically established
|
||||
uint16 seq; /*!< RTP sequence number, incremented by one for
|
||||
each sent packet */
|
||||
unsigned int timestamp; //!< timestamp, 27 MHz for H.264
|
||||
unsigned int ssrc; //!< Synchronization Source, chosen randomly
|
||||
byte *payload; //!< the payload including payload headers
|
||||
unsigned int paylen; //!< length of payload in bytes
|
||||
byte *packet; //!< complete packet including header and payload
|
||||
unsigned int packlen; //!< length of packet, typically paylen+12
|
||||
} RTPpacket_t;
|
||||
|
||||
void DumpRTPHeader (RTPpacket_t *p);
|
||||
int GetRTPNALU (VideoParameters *p_Vid, NALU_t *nalu);
|
||||
void OpenRTPFile (VideoParameters *p_Vid, char *fn);
|
||||
void DumpRTPHeader(RTPpacket_t *p);
|
||||
int GetRTPNALU(VideoParameters *p_Vid, NALU_t *nalu);
|
||||
void OpenRTPFile(VideoParameters *p_Vid, char *fn);
|
||||
void CloseRTPFile(VideoParameters *p_Vid);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -59,26 +59,26 @@ typedef enum {
|
|||
SEI_BASE_VIEW_TEMPORAL_HRD,
|
||||
SEI_FRAME_PACKING_ARRANGEMENT,
|
||||
|
||||
SEI_MAX_ELEMENTS //!< number of maximum syntax elements
|
||||
SEI_MAX_ELEMENTS //!< number of maximum syntax elements
|
||||
} SEI_type;
|
||||
|
||||
#define MAX_FN 256
|
||||
// tone mapping information
|
||||
#define MAX_CODED_BIT_DEPTH 12
|
||||
#define MAX_SEI_BIT_DEPTH 12
|
||||
#define MAX_NUM_PIVOTS (1<<MAX_CODED_BIT_DEPTH)
|
||||
#define MAX_CODED_BIT_DEPTH 12
|
||||
#define MAX_SEI_BIT_DEPTH 12
|
||||
#define MAX_NUM_PIVOTS (1 << MAX_CODED_BIT_DEPTH)
|
||||
|
||||
#if (ENABLE_OUTPUT_TONEMAPPING)
|
||||
typedef struct tone_mapping_struct_s
|
||||
{
|
||||
typedef struct tone_mapping_struct_s {
|
||||
Boolean seiHasTone_mapping;
|
||||
unsigned int tone_map_repetition_period;
|
||||
unsigned int tone_map_repetition_period;
|
||||
unsigned char coded_data_bit_depth;
|
||||
unsigned char sei_bit_depth;
|
||||
unsigned int model_id;
|
||||
unsigned int model_id;
|
||||
unsigned int count;
|
||||
|
||||
imgpel lut[1<<MAX_CODED_BIT_DEPTH]; //<! look up table for mapping the coded data value to output data value
|
||||
|
||||
imgpel lut[1 << MAX_CODED_BIT_DEPTH]; //<! look up table for mapping the coded
|
||||
//data value to output data value
|
||||
|
||||
Bitstream *data;
|
||||
int payloadSize;
|
||||
|
@ -86,59 +86,83 @@ typedef struct tone_mapping_struct_s
|
|||
#endif
|
||||
|
||||
//! Frame packing arrangement Information
|
||||
typedef struct
|
||||
{
|
||||
unsigned int frame_packing_arrangement_id;
|
||||
Boolean frame_packing_arrangement_cancel_flag;
|
||||
typedef struct {
|
||||
unsigned int frame_packing_arrangement_id;
|
||||
Boolean frame_packing_arrangement_cancel_flag;
|
||||
unsigned char frame_packing_arrangement_type;
|
||||
Boolean quincunx_sampling_flag;
|
||||
Boolean quincunx_sampling_flag;
|
||||
unsigned char content_interpretation_type;
|
||||
Boolean spatial_flipping_flag;
|
||||
Boolean frame0_flipped_flag;
|
||||
Boolean field_views_flag;
|
||||
Boolean current_frame_is_frame0_flag;
|
||||
Boolean frame0_self_contained_flag;
|
||||
Boolean frame1_self_contained_flag;
|
||||
Boolean spatial_flipping_flag;
|
||||
Boolean frame0_flipped_flag;
|
||||
Boolean field_views_flag;
|
||||
Boolean current_frame_is_frame0_flag;
|
||||
Boolean frame0_self_contained_flag;
|
||||
Boolean frame1_self_contained_flag;
|
||||
unsigned char frame0_grid_position_x;
|
||||
unsigned char frame0_grid_position_y;
|
||||
unsigned char frame1_grid_position_x;
|
||||
unsigned char frame1_grid_position_y;
|
||||
unsigned char frame_packing_arrangement_reserved_byte;
|
||||
unsigned int frame_packing_arrangement_repetition_period;
|
||||
Boolean frame_packing_arrangement_extension_flag;
|
||||
unsigned int frame_packing_arrangement_repetition_period;
|
||||
Boolean frame_packing_arrangement_extension_flag;
|
||||
} frame_packing_arrangement_information_struct;
|
||||
|
||||
void InterpretSEIMessage ( byte* payload, int size, VideoParameters *p_Vid, Slice *pSlice );
|
||||
void interpret_spare_pic ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_subsequence_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_subsequence_layer_characteristics_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_subsequence_characteristics_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_scene_information ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_user_data_registered_itu_t_t35_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_user_data_unregistered_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_pan_scan_rect_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_recovery_point_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_filler_payload_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_dec_ref_pic_marking_repetition_info ( byte* payload, int size, VideoParameters *p_Vid, Slice *pSlice );
|
||||
void interpret_full_frame_freeze_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_full_frame_freeze_release_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_full_frame_snapshot_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_progressive_refinement_start_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_progressive_refinement_end_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_motion_constrained_slice_group_set_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_reserved_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_buffering_period_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_picture_timing_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_film_grain_characteristics_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_deblocking_filter_display_preference_info( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_stereo_video_info_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_post_filter_hints_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_tone_mapping ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void interpret_frame_packing_arrangement_info ( byte* payload, int size, VideoParameters *p_Vid );
|
||||
void InterpretSEIMessage(byte *payload, int size, VideoParameters *p_Vid,
|
||||
Slice *pSlice);
|
||||
void interpret_spare_pic(byte *payload, int size, VideoParameters *p_Vid);
|
||||
void interpret_subsequence_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_subsequence_layer_characteristics_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_subsequence_characteristics_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_scene_information(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_user_data_registered_itu_t_t35_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_user_data_unregistered_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_pan_scan_rect_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_recovery_point_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_filler_payload_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_dec_ref_pic_marking_repetition_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid,
|
||||
Slice *pSlice);
|
||||
void interpret_full_frame_freeze_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_full_frame_freeze_release_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_full_frame_snapshot_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_progressive_refinement_start_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_progressive_refinement_end_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_motion_constrained_slice_group_set_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_reserved_info(byte *payload, int size, VideoParameters *p_Vid);
|
||||
void interpret_buffering_period_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_picture_timing_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_film_grain_characteristics_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_deblocking_filter_display_preference_info(
|
||||
byte *payload, int size, VideoParameters *p_Vid);
|
||||
void interpret_stereo_video_info_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_post_filter_hints_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
void interpret_tone_mapping(byte *payload, int size, VideoParameters *p_Vid);
|
||||
void interpret_frame_packing_arrangement_info(byte *payload, int size,
|
||||
VideoParameters *p_Vid);
|
||||
|
||||
#if (ENABLE_OUTPUT_TONEMAPPING)
|
||||
void tone_map (imgpel** imgX, imgpel* lut, int size_x, int size_y);
|
||||
void init_tone_mapping_sei (ToneMappingSEI *seiToneMapping);
|
||||
void tone_map(imgpel **imgX, imgpel *lut, int size_x, int size_y);
|
||||
void init_tone_mapping_sei(ToneMappingSEI *seiToneMapping);
|
||||
void update_tone_mapping_sei(ToneMappingSEI *seiToneMapping);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -11,22 +11,22 @@
|
|||
* 10 July 2007
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Alexis Michael Tourapis
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details) Alexis Michael Tourapis
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _TRANSFORM_H_
|
||||
#define _TRANSFORM_H_
|
||||
|
||||
extern void forward4x4 (int **block , int **tblock, int pos_y, int pos_x);
|
||||
extern void inverse4x4 (int **tblock, int **block , int pos_y, int pos_x);
|
||||
extern void forward8x8 (int **block , int **tblock, int pos_y, int pos_x);
|
||||
extern void inverse8x8 (int **tblock, int **block , int pos_y, int pos_x);
|
||||
extern void hadamard4x4 (int **block , int **tblock);
|
||||
extern void ihadamard4x4 (int **tblock, int **block);
|
||||
extern void hadamard4x2 (int **block , int **tblock);
|
||||
extern void ihadamard4x2 (int **tblock, int **block);
|
||||
extern void hadamard2x2 (int **block , int tblock[4]);
|
||||
extern void ihadamard2x2 (int block[4], int tblock[4]);
|
||||
extern void forward4x4(int **block, int **tblock, int pos_y, int pos_x);
|
||||
extern void inverse4x4(int **tblock, int **block, int pos_y, int pos_x);
|
||||
extern void forward8x8(int **block, int **tblock, int pos_y, int pos_x);
|
||||
extern void inverse8x8(int **tblock, int **block, int pos_y, int pos_x);
|
||||
extern void hadamard4x4(int **block, int **tblock);
|
||||
extern void ihadamard4x4(int **tblock, int **block);
|
||||
extern void hadamard4x2(int **block, int **tblock);
|
||||
extern void ihadamard4x2(int **tblock, int **block);
|
||||
extern void hadamard2x2(int **block, int tblock[4]);
|
||||
extern void ihadamard2x2(int block[4], int tblock[4]);
|
||||
|
||||
#endif //_TRANSFORM_H_
|
||||
|
|
|
@ -10,13 +10,14 @@
|
|||
* 9. October 2003
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Yuri Vatis
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _TRANSFORM8X8_H_
|
||||
#define _TRANSFORM8X8_H_
|
||||
|
||||
extern void itrans8x8 (Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||
extern void itrans8x8(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,11 +4,13 @@
|
|||
*
|
||||
* \brief
|
||||
* Common type definitions
|
||||
* Currently only supports Windows and Linux operating systems.
|
||||
* Need to add support for other "older systems such as VAX, DECC, Unix Alpha etc
|
||||
* Currently only supports Windows and Linux operating systems.
|
||||
* Need to add support for other "older systems such as VAX, DECC, Unix Alpha
|
||||
*etc
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
@ -18,20 +20,21 @@
|
|||
|
||||
#include "win32.h"
|
||||
|
||||
typedef unsigned char byte; //!< byte type definition
|
||||
typedef unsigned char uint8; //!< type definition for unsigned char (same as byte, 8 bits)
|
||||
typedef unsigned short uint16; //!< type definition for unsigned short (16 bits)
|
||||
typedef unsigned int uint32; //!< type definition for unsigned int (32 bits)
|
||||
typedef unsigned char byte; //!< byte type definition
|
||||
typedef unsigned char
|
||||
uint8; //!< type definition for unsigned char (same as byte, 8 bits)
|
||||
typedef unsigned short uint16; //!< type definition for unsigned short (16 bits)
|
||||
typedef unsigned int uint32; //!< type definition for unsigned int (32 bits)
|
||||
|
||||
typedef signed char int8;
|
||||
typedef short int16;
|
||||
typedef int int32;
|
||||
typedef signed char int8;
|
||||
typedef short int16;
|
||||
typedef int int32;
|
||||
|
||||
#if (IMGTYPE == 0)
|
||||
typedef byte imgpel; //!< pixel type
|
||||
typedef uint16 distpel; //!< distortion type (for pixels)
|
||||
typedef int32 distblk; //!< distortion type (for Macroblock)
|
||||
typedef int32 transpel; //!< transformed coefficient type
|
||||
typedef byte imgpel; //!< pixel type
|
||||
typedef uint16 distpel; //!< distortion type (for pixels)
|
||||
typedef int32 distblk; //!< distortion type (for Macroblock)
|
||||
typedef int32 transpel; //!< transformed coefficient type
|
||||
#elif (IMGTYPE == 2)
|
||||
typedef float imgpel;
|
||||
typedef float distpel;
|
||||
|
@ -40,8 +43,8 @@ typedef int32 transpel;
|
|||
#else
|
||||
typedef uint16 imgpel;
|
||||
typedef uint32 distpel;
|
||||
typedef int64 distblk;
|
||||
typedef int32 transpel;
|
||||
typedef int64 distblk;
|
||||
typedef int32 transpel;
|
||||
#endif
|
||||
|
||||
#ifdef SPEC
|
||||
|
@ -55,17 +58,14 @@ typedef int32 transpel;
|
|||
#else
|
||||
//! Boolean Type
|
||||
#ifdef FALSE
|
||||
# define Boolean int
|
||||
#define Boolean int
|
||||
#else
|
||||
typedef enum {
|
||||
FALSE,
|
||||
TRUE
|
||||
} Boolean;
|
||||
typedef enum { FALSE, TRUE } Boolean;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MAXINT64
|
||||
#define MAXINT64 0x7fffffffffffffff
|
||||
#define MAXINT64 0x7fffffffffffffff
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -85,4 +85,3 @@ typedef enum {
|
|||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
* type definitions.
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
*
|
||||
************************************************************************
|
||||
*/
|
||||
|
@ -19,63 +20,39 @@
|
|||
***********************************************************************
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
// YUV
|
||||
PLANE_Y = 0, // PLANE_Y
|
||||
PLANE_U = 1, // PLANE_Cb
|
||||
PLANE_V = 2, // PLANE_Cr
|
||||
// RGB
|
||||
PLANE_Y = 0, // PLANE_Y
|
||||
PLANE_U = 1, // PLANE_Cb
|
||||
PLANE_V = 2, // PLANE_Cr
|
||||
// RGB
|
||||
PLANE_G = 0,
|
||||
PLANE_B = 1,
|
||||
PLANE_R = 2
|
||||
} ColorPlane;
|
||||
|
||||
enum {
|
||||
LIST_0 = 0,
|
||||
LIST_1 = 1,
|
||||
BI_PRED = 2,
|
||||
BI_PRED_L0 = 3,
|
||||
BI_PRED_L1 = 4
|
||||
};
|
||||
enum { LIST_0 = 0, LIST_1 = 1, BI_PRED = 2, BI_PRED_L0 = 3, BI_PRED_L1 = 4 };
|
||||
|
||||
enum {
|
||||
ERROR_SAD = 0,
|
||||
ERROR_SSE = 1,
|
||||
ERROR_SATD = 2,
|
||||
ERROR_PSATD = 3
|
||||
};
|
||||
enum { ERROR_SAD = 0, ERROR_SSE = 1, ERROR_SATD = 2, ERROR_PSATD = 3 };
|
||||
|
||||
enum {
|
||||
ME_Y_ONLY = 0,
|
||||
ME_YUV_FP = 1,
|
||||
ME_YUV_FP_SP = 2
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
DISTORTION_MSE = 0
|
||||
};
|
||||
enum { ME_Y_ONLY = 0, ME_YUV_FP = 1, ME_YUV_FP_SP = 2 };
|
||||
|
||||
enum { DISTORTION_MSE = 0 };
|
||||
|
||||
//! Data Partitioning Modes
|
||||
typedef enum
|
||||
{
|
||||
PAR_DP_1, //!< no data partitioning is supported
|
||||
PAR_DP_3 //!< data partitioning with 3 partitions
|
||||
typedef enum {
|
||||
PAR_DP_1, //!< no data partitioning is supported
|
||||
PAR_DP_3 //!< data partitioning with 3 partitions
|
||||
} PAR_DP_TYPE;
|
||||
|
||||
|
||||
//! Output File Types
|
||||
typedef enum
|
||||
{
|
||||
PAR_OF_ANNEXB, //!< Annex B byte stream format
|
||||
PAR_OF_RTP //!< RTP packets in outfile
|
||||
typedef enum {
|
||||
PAR_OF_ANNEXB, //!< Annex B byte stream format
|
||||
PAR_OF_RTP //!< RTP packets in outfile
|
||||
} PAR_OF_TYPE;
|
||||
|
||||
//! Field Coding Types
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
FRAME_CODING,
|
||||
FIELD_CODING,
|
||||
ADAPTIVE_CODING,
|
||||
|
@ -83,8 +60,7 @@ typedef enum
|
|||
} CodingType;
|
||||
|
||||
//! definition of H.264 syntax elements
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
SE_HEADER,
|
||||
SE_PTYPE,
|
||||
SE_MBTYPE,
|
||||
|
@ -106,41 +82,25 @@ typedef enum
|
|||
SE_MAX_ELEMENTS = 20 //!< number of maximum syntax elements
|
||||
} SE_type; // substituting the definitions in elements.h
|
||||
|
||||
typedef enum { NO_SLICES, FIXED_MB, FIXED_RATE, CALL_BACK } SliceMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NO_SLICES,
|
||||
FIXED_MB,
|
||||
FIXED_RATE,
|
||||
CALL_BACK
|
||||
} SliceMode;
|
||||
typedef enum { CAVLC, CABAC } SymbolMode;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CAVLC,
|
||||
CABAC
|
||||
} SymbolMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FULL_SEARCH = -1,
|
||||
FAST_FULL_SEARCH = 0,
|
||||
UM_HEX = 1,
|
||||
UM_HEX_SIMPLE = 2,
|
||||
EPZS = 3
|
||||
typedef enum {
|
||||
FULL_SEARCH = -1,
|
||||
FAST_FULL_SEARCH = 0,
|
||||
UM_HEX = 1,
|
||||
UM_HEX_SIMPLE = 2,
|
||||
EPZS = 3
|
||||
} SearchType;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
FRAME,
|
||||
TOP_FIELD,
|
||||
BOTTOM_FIELD
|
||||
} PictureStructure; //!< New enum for field processing
|
||||
} PictureStructure; //!< New enum for field processing
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
P_SLICE = 0,
|
||||
B_SLICE = 1,
|
||||
I_SLICE = 2,
|
||||
|
@ -149,55 +109,46 @@ typedef enum
|
|||
NUM_SLICE_TYPES = 5
|
||||
} SliceType;
|
||||
|
||||
//Motion Estimation levels
|
||||
typedef enum
|
||||
{
|
||||
F_PEL, //!< Full Pel refinement
|
||||
H_PEL, //!< Half Pel refinement
|
||||
Q_PEL //!< Quarter Pel refinement
|
||||
// Motion Estimation levels
|
||||
typedef enum {
|
||||
F_PEL, //!< Full Pel refinement
|
||||
H_PEL, //!< Half Pel refinement
|
||||
Q_PEL //!< Quarter Pel refinement
|
||||
} MELevel;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FAST_ACCESS = 0, //!< Fast/safe reference access
|
||||
UMV_ACCESS = 1 //!< unconstrained reference access
|
||||
typedef enum {
|
||||
FAST_ACCESS = 0, //!< Fast/safe reference access
|
||||
UMV_ACCESS = 1 //!< unconstrained reference access
|
||||
} REF_ACCESS_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IS_LUMA = 0,
|
||||
IS_CHROMA = 1
|
||||
} Component_Type;
|
||||
typedef enum { IS_LUMA = 0, IS_CHROMA = 1 } Component_Type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
RC_MODE_0 = 0,
|
||||
RC_MODE_1 = 1,
|
||||
RC_MODE_2 = 2,
|
||||
RC_MODE_3 = 3
|
||||
} RCModeType;
|
||||
|
||||
|
||||
typedef enum {
|
||||
SSE = 0,
|
||||
SSE_RGB = 1,
|
||||
PSNR = 2,
|
||||
PSNR_RGB = 3,
|
||||
SSIM = 4,
|
||||
SSIM_RGB = 5,
|
||||
MS_SSIM = 6,
|
||||
MS_SSIM_RGB = 7,
|
||||
SSE = 0,
|
||||
SSE_RGB = 1,
|
||||
PSNR = 2,
|
||||
PSNR_RGB = 3,
|
||||
SSIM = 4,
|
||||
SSIM_RGB = 5,
|
||||
MS_SSIM = 6,
|
||||
MS_SSIM_RGB = 7,
|
||||
TOTAL_DIST_TYPES = 8
|
||||
} distortion_types;
|
||||
|
||||
typedef enum {
|
||||
WP_MCPREC_PLUS0 = 4,
|
||||
WP_MCPREC_PLUS1 = 5,
|
||||
WP_MCPREC_MINUS0 = 6,
|
||||
WP_MCPREC_MINUS1 = 7,
|
||||
WP_MCPREC_PLUS0 = 4,
|
||||
WP_MCPREC_PLUS1 = 5,
|
||||
WP_MCPREC_MINUS0 = 6,
|
||||
WP_MCPREC_MINUS1 = 7,
|
||||
WP_MCPREC_MINUS_PLUS0 = 8,
|
||||
WP_REGULAR = 9
|
||||
WP_REGULAR = 9
|
||||
} weighted_prediction_types;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,97 +16,101 @@
|
|||
#define _VLC_H_
|
||||
|
||||
//! gives CBP value from codeword number, both for intra and inter
|
||||
static const byte NCBP[2][48][2]=
|
||||
{
|
||||
{ // 0 1 2 3 4 5 6 7 8 9 10 11
|
||||
{15, 0},{ 0, 1},{ 7, 2},{11, 4},{13, 8},{14, 3},{ 3, 5},{ 5,10},{10,12},{12,15},{ 1, 7},{ 2,11},
|
||||
{ 4,13},{ 8,14},{ 6, 6},{ 9, 9},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},
|
||||
{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},
|
||||
{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0}
|
||||
},
|
||||
{
|
||||
{47, 0},{31,16},{15, 1},{ 0, 2},{23, 4},{27, 8},{29,32},{30, 3},{ 7, 5},{11,10},{13,12},{14,15},
|
||||
{39,47},{43, 7},{45,11},{46,13},{16,14},{ 3, 6},{ 5, 9},{10,31},{12,35},{19,37},{21,42},{26,44},
|
||||
{28,33},{35,34},{37,36},{42,40},{44,39},{ 1,43},{ 2,45},{ 4,46},{ 8,17},{17,18},{18,20},{20,24},
|
||||
{24,19},{ 6,21},{ 9,26},{22,28},{25,23},{32,27},{33,29},{34,30},{36,22},{40,25},{38,38},{41,41}
|
||||
}
|
||||
};
|
||||
static const byte NCBP[2][48][2] = {
|
||||
{// 0 1 2 3 4 5 6 7 8 9 10
|
||||
// 11
|
||||
{15, 0}, {0, 1}, {7, 2}, {11, 4}, {13, 8}, {14, 3}, {3, 5}, {5, 10},
|
||||
{10, 12}, {12, 15}, {1, 7}, {2, 11}, {4, 13}, {8, 14}, {6, 6}, {9, 9},
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
{{47, 0}, {31, 16}, {15, 1}, {0, 2}, {23, 4}, {27, 8}, {29, 32},
|
||||
{30, 3}, {7, 5}, {11, 10}, {13, 12}, {14, 15}, {39, 47}, {43, 7},
|
||||
{45, 11}, {46, 13}, {16, 14}, {3, 6}, {5, 9}, {10, 31}, {12, 35},
|
||||
{19, 37}, {21, 42}, {26, 44}, {28, 33}, {35, 34}, {37, 36}, {42, 40},
|
||||
{44, 39}, {1, 43}, {2, 45}, {4, 46}, {8, 17}, {17, 18}, {18, 20},
|
||||
{20, 24}, {24, 19}, {6, 21}, {9, 26}, {22, 28}, {25, 23}, {32, 27},
|
||||
{33, 29}, {34, 30}, {36, 22}, {40, 25}, {38, 38}, {41, 41}}};
|
||||
|
||||
//! for the linfo_levrun_inter routine
|
||||
static const byte NTAB1[4][8][2] =
|
||||
{
|
||||
{{1,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
|
||||
{{1,1},{1,2},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
|
||||
{{2,0},{1,3},{1,4},{1,5},{0,0},{0,0},{0,0},{0,0}},
|
||||
{{3,0},{2,1},{2,2},{1,6},{1,7},{1,8},{1,9},{4,0}},
|
||||
static const byte NTAB1[4][8][2] = {
|
||||
{{1, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
{{1, 1}, {1, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
{{2, 0}, {1, 3}, {1, 4}, {1, 5}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
{{3, 0}, {2, 1}, {2, 2}, {1, 6}, {1, 7}, {1, 8}, {1, 9}, {4, 0}},
|
||||
};
|
||||
|
||||
static const byte LEVRUN1[16]=
|
||||
{
|
||||
4,2,2,1,1,1,1,1,1,1,0,0,0,0,0,0,
|
||||
static const byte LEVRUN1[16] = {
|
||||
4, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
|
||||
static const byte NTAB2[4][8][2] =
|
||||
{
|
||||
{{1,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
|
||||
{{1,1},{2,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
|
||||
{{1,2},{3,0},{4,0},{5,0},{0,0},{0,0},{0,0},{0,0}},
|
||||
{{1,3},{1,4},{2,1},{3,1},{6,0},{7,0},{8,0},{9,0}},
|
||||
static const byte NTAB2[4][8][2] = {
|
||||
{{1, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
{{1, 1}, {2, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
{{1, 2}, {3, 0}, {4, 0}, {5, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
{{1, 3}, {1, 4}, {2, 1}, {3, 1}, {6, 0}, {7, 0}, {8, 0}, {9, 0}},
|
||||
};
|
||||
|
||||
//! for the linfo_levrun__c2x2 routine
|
||||
static const byte LEVRUN3[4] =
|
||||
{
|
||||
2,1,0,0
|
||||
static const byte LEVRUN3[4] = {2, 1, 0, 0};
|
||||
|
||||
static const byte NTAB3[2][2][2] = {
|
||||
{{1, 0}, {0, 0}},
|
||||
{{2, 0}, {1, 1}},
|
||||
};
|
||||
|
||||
static const byte NTAB3[2][2][2] =
|
||||
{
|
||||
{{1,0},{0,0}},
|
||||
{{2,0},{1,1}},
|
||||
};
|
||||
|
||||
extern int se_v (char *tracestring, Bitstream *bitstream);
|
||||
extern int ue_v (char *tracestring, Bitstream *bitstream);
|
||||
extern Boolean u_1 (char *tracestring, Bitstream *bitstream);
|
||||
extern int u_v (int LenInBits, char *tracestring, Bitstream *bitstream);
|
||||
extern int i_v (int LenInBits, char *tracestring, Bitstream *bitstream);
|
||||
extern int se_v(char *tracestring, Bitstream *bitstream);
|
||||
extern int ue_v(char *tracestring, Bitstream *bitstream);
|
||||
extern Boolean u_1(char *tracestring, Bitstream *bitstream);
|
||||
extern int u_v(int LenInBits, char *tracestring, Bitstream *bitstream);
|
||||
extern int i_v(int LenInBits, char *tracestring, Bitstream *bitstream);
|
||||
|
||||
// CAVLC mapping
|
||||
extern void linfo_ue(int len, int info, int *value1, int *dummy);
|
||||
extern void linfo_se(int len, int info, int *value1, int *dummy);
|
||||
|
||||
extern void linfo_cbp_intra_normal(int len,int info,int *cbp, int *dummy);
|
||||
extern void linfo_cbp_inter_normal(int len,int info,int *cbp, int *dummy);
|
||||
extern void linfo_cbp_intra_other(int len,int info,int *cbp, int *dummy);
|
||||
extern void linfo_cbp_inter_other(int len,int info,int *cbp, int *dummy);
|
||||
extern void linfo_cbp_intra_normal(int len, int info, int *cbp, int *dummy);
|
||||
extern void linfo_cbp_inter_normal(int len, int info, int *cbp, int *dummy);
|
||||
extern void linfo_cbp_intra_other(int len, int info, int *cbp, int *dummy);
|
||||
extern void linfo_cbp_inter_other(int len, int info, int *cbp, int *dummy);
|
||||
|
||||
extern void linfo_levrun_inter(int len,int info,int *level,int *irun);
|
||||
extern void linfo_levrun_c2x2(int len,int info,int *level,int *irun);
|
||||
extern void linfo_levrun_inter(int len, int info, int *level, int *irun);
|
||||
extern void linfo_levrun_c2x2(int len, int info, int *level, int *irun);
|
||||
|
||||
extern int uvlc_startcode_follows(Slice *currSlice, int dummy);
|
||||
extern int uvlc_startcode_follows(Slice *currSlice, int dummy);
|
||||
|
||||
extern int readSyntaxElement_VLC (SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int readSyntaxElement_UVLC(Macroblock *currMB, SyntaxElement *sym, struct datapartition *dp);
|
||||
extern int readSyntaxElement_Intra4x4PredictionMode(SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int readSyntaxElement_VLC(SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int readSyntaxElement_UVLC(Macroblock *currMB, SyntaxElement *sym,
|
||||
struct datapartition *dp);
|
||||
extern int readSyntaxElement_Intra4x4PredictionMode(SyntaxElement *sym,
|
||||
Bitstream *currStream);
|
||||
|
||||
extern int GetVLCSymbol (byte buffer[],int totbitoffset,int *info, int bytecount);
|
||||
extern int GetVLCSymbol_IntraMode (byte buffer[],int totbitoffset,int *info, int bytecount);
|
||||
extern int GetVLCSymbol(byte buffer[], int totbitoffset, int *info,
|
||||
int bytecount);
|
||||
extern int GetVLCSymbol_IntraMode(byte buffer[], int totbitoffset, int *info,
|
||||
int bytecount);
|
||||
|
||||
extern int readSyntaxElement_FLC (SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int readSyntaxElement_NumCoeffTrailingOnes (SyntaxElement *sym, Bitstream *currStream, signed char *type);
|
||||
extern int readSyntaxElement_NumCoeffTrailingOnesChromaDC(VideoParameters *p_Vid, SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int readSyntaxElement_Level_VLC0 (SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int readSyntaxElement_Level_VLCN (SyntaxElement *sym, int vlc, Bitstream *currStream);
|
||||
extern int readSyntaxElement_TotalZeros (SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int readSyntaxElement_TotalZerosChromaDC (VideoParameters *p_Vid, SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int readSyntaxElement_Run (SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int GetBits (byte buffer[],int totbitoffset,int *info, int bitcount, int numbits);
|
||||
extern int ShowBits (byte buffer[],int totbitoffset,int bitcount, int numbits);
|
||||
|
||||
extern int more_rbsp_data (byte buffer[],int totbitoffset,int bytecount);
|
||||
extern int readSyntaxElement_FLC(SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int readSyntaxElement_NumCoeffTrailingOnes(SyntaxElement *sym,
|
||||
Bitstream *currStream,
|
||||
signed char *type);
|
||||
extern int readSyntaxElement_NumCoeffTrailingOnesChromaDC(
|
||||
VideoParameters *p_Vid, SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int readSyntaxElement_Level_VLC0(SyntaxElement *sym,
|
||||
Bitstream *currStream);
|
||||
extern int readSyntaxElement_Level_VLCN(SyntaxElement *sym, int vlc,
|
||||
Bitstream *currStream);
|
||||
extern int readSyntaxElement_TotalZeros(SyntaxElement *sym,
|
||||
Bitstream *currStream);
|
||||
extern int readSyntaxElement_TotalZerosChromaDC(VideoParameters *p_Vid,
|
||||
SyntaxElement *sym,
|
||||
Bitstream *currStream);
|
||||
extern int readSyntaxElement_Run(SyntaxElement *sym, Bitstream *currStream);
|
||||
extern int GetBits(byte buffer[], int totbitoffset, int *info, int bitcount,
|
||||
int numbits);
|
||||
extern int ShowBits(byte buffer[], int totbitoffset, int bitcount, int numbits);
|
||||
|
||||
extern int more_rbsp_data(byte buffer[], int totbitoffset, int bytecount);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
#define _VUI_PARAMS_H_
|
||||
|
||||
// VUI Parameters
|
||||
typedef struct vui_parameters
|
||||
{
|
||||
typedef struct vui_parameters {
|
||||
int aspect_ratio_info_present_flag;
|
||||
int aspect_ratio_idc;
|
||||
int sar_width;
|
||||
|
@ -27,7 +26,7 @@ typedef struct vui_parameters
|
|||
int video_full_range_flag;
|
||||
int colour_description_present_flag;
|
||||
int colour_primaries;
|
||||
int transfer_characteristics;
|
||||
int transfer_characteristics;
|
||||
int matrix_coefficients;
|
||||
int chroma_location_info_present_flag;
|
||||
int chroma_sample_loc_type_top_field;
|
||||
|
@ -71,4 +70,3 @@ typedef struct vui_parameters
|
|||
} VUIParameters;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -14,104 +14,108 @@
|
|||
#ifndef _WIN32_H_
|
||||
#define _WIN32_H_
|
||||
|
||||
# include <fcntl.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <assert.h>
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if (defined(_OPENMP) || defined(SPEC_OPENMP)) && !defined(SPEC_SUPPRESS_OPENMP) && !defined(SPEC_AUTO_SUPPRESS_OPENMP)
|
||||
# define OPENMP
|
||||
# define NUM_THREADS 8
|
||||
#if (defined(_OPENMP) || defined(SPEC_OPENMP)) && \
|
||||
!defined(SPEC_SUPPRESS_OPENMP) && !defined(SPEC_AUTO_SUPPRESS_OPENMP)
|
||||
#define OPENMP
|
||||
#define NUM_THREADS 8
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined (WIN64) || defined(SPEC_WINDOWS)
|
||||
# include <io.h>
|
||||
#if defined(WIN32) || defined(WIN64) || defined(SPEC_WINDOWS)
|
||||
#include <io.h>
|
||||
#ifndef SPEC
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#endif /* !SPEC */
|
||||
# include <windows.h>
|
||||
#include <windows.h>
|
||||
#if (_MSC_VER < 1400)
|
||||
typedef int intptr_t;
|
||||
typedef int intptr_t;
|
||||
#else
|
||||
# include <crtdefs.h>
|
||||
#include <crtdefs.h>
|
||||
#endif
|
||||
#if (defined(_OPENMP) || defined(SPEC_OPENMP)) && !defined(SPEC_SUPPRESS_OPENMP) && !defined(SPEC_AUTO_SUPPRESS_OPENMP)
|
||||
# include <omp.h>
|
||||
#if (defined(_OPENMP) || defined(SPEC_OPENMP)) && \
|
||||
!defined(SPEC_SUPPRESS_OPENMP) && !defined(SPEC_AUTO_SUPPRESS_OPENMP)
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
# define strcmp _strcmpi
|
||||
#define strcmp _strcmpi
|
||||
|
||||
# define snprintf _snprintf
|
||||
# define open _open
|
||||
# define close _close
|
||||
# define read _read
|
||||
# define write _write
|
||||
# define lseek _lseeki64
|
||||
# define fsync _commit
|
||||
# define tell _telli64
|
||||
#define snprintf _snprintf
|
||||
#define open _open
|
||||
#define close _close
|
||||
#define read _read
|
||||
#define write _write
|
||||
#define lseek _lseeki64
|
||||
#define fsync _commit
|
||||
#define tell _telli64
|
||||
#ifndef SPEC
|
||||
# define TIMEB _timeb
|
||||
# define TIME_T LARGE_INTEGER
|
||||
#define TIMEB _timeb
|
||||
#define TIME_T LARGE_INTEGER
|
||||
#endif /*! SPEC */
|
||||
# define OPENFLAGS_WRITE _O_WRONLY|_O_CREAT|_O_BINARY|_O_TRUNC
|
||||
# define OPEN_PERMISSIONS _S_IREAD | _S_IWRITE
|
||||
# define OPENFLAGS_READ _O_RDONLY|_O_BINARY
|
||||
#define OPENFLAGS_WRITE _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC
|
||||
#define OPEN_PERMISSIONS _S_IREAD | _S_IWRITE
|
||||
#define OPENFLAGS_READ _O_RDONLY | _O_BINARY
|
||||
#ifndef SPEC_NO_UNDERBAR_INLINE
|
||||
# define inline _inline
|
||||
#define inline _inline
|
||||
#endif
|
||||
# define forceinline __forceinline
|
||||
#define forceinline __forceinline
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <sys/time.h>
|
||||
# include <sys/stat.h>
|
||||
# include <time.h>
|
||||
# include <stdint.h>
|
||||
#if (defined(_OPENMP) || defined(SPEC_OPENMP)) && !defined(SPEC_SUPPRESS_OPENMP) && !defined(SPEC_AUTO_SUPPRESS_OPENMP)
|
||||
# include <omp.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#if (defined(_OPENMP) || defined(SPEC_OPENMP)) && \
|
||||
!defined(SPEC_SUPPRESS_OPENMP) && !defined(SPEC_AUTO_SUPPRESS_OPENMP)
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
# define TIMEB timeb
|
||||
# define TIME_T struct timeval
|
||||
# define tell(fd) lseek(fd, 0, SEEK_CUR)
|
||||
# define OPENFLAGS_WRITE O_WRONLY|O_CREAT|O_TRUNC
|
||||
# define OPENFLAGS_READ O_RDONLY
|
||||
# define OPEN_PERMISSIONS S_IRUSR | S_IWUSR
|
||||
#define TIMEB timeb
|
||||
#define TIME_T struct timeval
|
||||
#define tell(fd) lseek(fd, 0, SEEK_CUR)
|
||||
#define OPENFLAGS_WRITE O_WRONLY | O_CREAT | O_TRUNC
|
||||
#define OPENFLAGS_READ O_RDONLY
|
||||
#define OPEN_PERMISSIONS S_IRUSR | S_IWUSR
|
||||
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
/* "inline" is a keyword */
|
||||
# else
|
||||
# define inline /* nothing */
|
||||
# endif
|
||||
# define forceinline inline
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
/* "inline" is a keyword */
|
||||
#else
|
||||
#define inline /* nothing */
|
||||
#endif
|
||||
#define forceinline inline
|
||||
#endif
|
||||
|
||||
#if (defined(WIN32) || defined(WIN64) || defined(SPEC_WINDOWS)) && !defined(__GNUC__)
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
# define FORMAT_OFF_T "I64d"
|
||||
# ifndef INT64_MIN
|
||||
# define INT64_MIN (-9223372036854775807i64 - 1i64)
|
||||
# endif
|
||||
#if (defined(WIN32) || defined(WIN64) || defined(SPEC_WINDOWS)) && \
|
||||
!defined(__GNUC__)
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
#define FORMAT_OFF_T "I64d"
|
||||
#ifndef INT64_MIN
|
||||
#define INT64_MIN (-9223372036854775807i64 - 1i64)
|
||||
#endif
|
||||
#else
|
||||
#if defined(SPEC_USE_LL_INT64)
|
||||
typedef long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
# define FORMAT_OFF_T "lld"
|
||||
typedef unsigned long long uint64;
|
||||
#define FORMAT_OFF_T "lld"
|
||||
#else
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
# define FORMAT_OFF_T "ld"
|
||||
#endif /* SPEC_USE_LL_INT64 */
|
||||
# ifndef INT64_MIN
|
||||
# define INT64_MIN (-9223372036854775807LL - 1LL)
|
||||
# endif
|
||||
#define FORMAT_OFF_T "ld"
|
||||
#endif /* SPEC_USE_LL_INT64 */
|
||||
#ifndef INT64_MIN
|
||||
#define INT64_MIN (-9223372036854775807LL - 1LL)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef SPEC
|
||||
void gettime(TIME_T* time);
|
||||
int64 timediff(TIME_T* start, TIME_T* end);
|
||||
void gettime(TIME_T *time);
|
||||
int64 timediff(TIME_T *start, TIME_T *end);
|
||||
int64 timenorm(int64 cur_time);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
* Input related functions
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
||||
* Main contributors (see contributors.h for copyright, address and
|
||||
*affiliation details)
|
||||
* - Karsten Sühring <suehring@hhi.de>
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
*
|
||||
*************************************************************************************
|
||||
*/
|
||||
#include "contributors.h"
|
||||
|
@ -19,14 +20,20 @@
|
|||
#include <time.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "input.h"
|
||||
#include "img_io.h"
|
||||
#include "input.h"
|
||||
#include "memalloc.h"
|
||||
|
||||
void buf2img_basic ( imgpel** imgX, unsigned char* buf, int size_x, int size_y, int o_size_x, int o_size_y, int symbol_size_in_bytes, int bitshift);
|
||||
void buf2img_endian ( imgpel** imgX, unsigned char* buf, int size_x, int size_y, int o_size_x, int o_size_y, int symbol_size_in_bytes, int bitshift);
|
||||
void buf2img_bitshift ( imgpel** imgX, unsigned char* buf, int size_x, int size_y, int o_size_x, int o_size_y, int symbol_size_in_bytes, int bitshift);
|
||||
void fillPlane ( imgpel** imgX, int nVal, int size_x, int size_y);
|
||||
void buf2img_basic(imgpel **imgX, unsigned char *buf, int size_x, int size_y,
|
||||
int o_size_x, int o_size_y, int symbol_size_in_bytes,
|
||||
int bitshift);
|
||||
void buf2img_endian(imgpel **imgX, unsigned char *buf, int size_x, int size_y,
|
||||
int o_size_x, int o_size_y, int symbol_size_in_bytes,
|
||||
int bitshift);
|
||||
void buf2img_bitshift(imgpel **imgX, unsigned char *buf, int size_x, int size_y,
|
||||
int o_size_x, int o_size_y, int symbol_size_in_bytes,
|
||||
int bitshift);
|
||||
void fillPlane(imgpel **imgX, int nVal, int size_x, int size_y);
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
|
@ -37,20 +44,18 @@ void fillPlane ( imgpel** imgX, int nVal, int size_x, int size_y);
|
|||
* 1, big-endian (e.g. SPARC, MIPS, PowerPC)
|
||||
************************************************************************
|
||||
*/
|
||||
void initInput(VideoParameters *p_Vid, FrameFormat *source, FrameFormat *output)
|
||||
{
|
||||
if (source->bit_depth[0] == output->bit_depth[0] && source->bit_depth[1] == output->bit_depth[1])
|
||||
{
|
||||
if (( sizeof(signed char) != sizeof (imgpel)) && testEndian())
|
||||
void initInput(VideoParameters *p_Vid, FrameFormat *source,
|
||||
FrameFormat *output) {
|
||||
if (source->bit_depth[0] == output->bit_depth[0] &&
|
||||
source->bit_depth[1] == output->bit_depth[1]) {
|
||||
if ((sizeof(signed char) != sizeof(imgpel)) && testEndian())
|
||||
p_Vid->buf2img = buf2img_endian;
|
||||
else
|
||||
p_Vid->buf2img = buf2img_basic;
|
||||
}
|
||||
else
|
||||
} else
|
||||
p_Vid->buf2img = buf2img_bitshift;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
|
@ -60,16 +65,15 @@ void initInput(VideoParameters *p_Vid, FrameFormat *source, FrameFormat *output)
|
|||
* 1, big-endian (e.g. SPARC, MIPS, PowerPC)
|
||||
************************************************************************
|
||||
*/
|
||||
int testEndian(void)
|
||||
{
|
||||
int testEndian(void) {
|
||||
short s;
|
||||
byte *p;
|
||||
|
||||
p=(byte*)&s;
|
||||
p = (byte *)&s;
|
||||
|
||||
s=1;
|
||||
s = 1;
|
||||
|
||||
return (*p==0);
|
||||
return (*p == 0);
|
||||
}
|
||||
|
||||
#if (DEBUG_BITDEPTH)
|
||||
|
@ -79,15 +83,12 @@ int testEndian(void)
|
|||
* Masking to ensure data within appropriate range
|
||||
************************************************************************
|
||||
*/
|
||||
static void MaskMSBs (imgpel** imgX, int mask, int width, int height)
|
||||
{
|
||||
int i,j;
|
||||
static void MaskMSBs(imgpel **imgX, int mask, int width, int height) {
|
||||
int i, j;
|
||||
|
||||
for (j=0; j < height; j++)
|
||||
{
|
||||
for (i=0; i < width; i++)
|
||||
{
|
||||
imgX[j][i]=(imgpel) (imgX[j][i] & mask);
|
||||
for (j = 0; j < height; j++) {
|
||||
for (i = 0; i < width; i++) {
|
||||
imgX[j][i] = (imgpel)(imgX[j][i] & mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,25 +100,19 @@ static void MaskMSBs (imgpel** imgX, int mask, int width, int height)
|
|||
* Fill plane with constant value
|
||||
************************************************************************
|
||||
*/
|
||||
void fillPlane ( imgpel** imgX, //!< Pointer to image plane
|
||||
int nVal, //!< Fill value (currently 0 <= nVal < 256)
|
||||
int size_x, //!< horizontal size of picture
|
||||
int size_y //!< vertical size of picture
|
||||
)
|
||||
{
|
||||
void fillPlane(imgpel **imgX, //!< Pointer to image plane
|
||||
int nVal, //!< Fill value (currently 0 <= nVal < 256)
|
||||
int size_x, //!< horizontal size of picture
|
||||
int size_y //!< vertical size of picture
|
||||
) {
|
||||
int j, i;
|
||||
|
||||
if (sizeof(imgpel) == sizeof(signed char))
|
||||
{
|
||||
if (sizeof(imgpel) == sizeof(signed char)) {
|
||||
memset(imgX[0], nVal, size_y * size_x);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < size_y; j++)
|
||||
{
|
||||
for (i = 0; i < size_x; i++)
|
||||
{
|
||||
imgX[j][i] = (imgpel) nVal;
|
||||
} else {
|
||||
for (j = 0; j < size_y; j++) {
|
||||
for (i = 0; i < size_x; i++) {
|
||||
imgX[j][i] = (imgpel)nVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,12 +124,12 @@ void fillPlane ( imgpel** imgX, //!< Pointer to image plane
|
|||
* Deinterleave file read buffer to source picture structure
|
||||
************************************************************************
|
||||
*/
|
||||
static void deinterleave ( unsigned char** input, //!< input buffer
|
||||
unsigned char** output, //!< output buffer
|
||||
FrameFormat *source, //!< format of source buffer
|
||||
int symbol_size_in_bytes //!< number of bytes per symbol
|
||||
)
|
||||
{
|
||||
static void
|
||||
deinterleave(unsigned char **input, //!< input buffer
|
||||
unsigned char **output, //!< output buffer
|
||||
FrameFormat *source, //!< format of source buffer
|
||||
int symbol_size_in_bytes //!< number of bytes per symbol
|
||||
) {
|
||||
// original buffer
|
||||
unsigned char *icmp0 = *input;
|
||||
// final buffer
|
||||
|
@ -144,11 +139,10 @@ static void deinterleave ( unsigned char** input, //!< input buffer
|
|||
unsigned char *ocmp2 = ocmp1 + symbol_size_in_bytes * source->size_cmp[1];
|
||||
|
||||
int i;
|
||||
|
||||
if (source->yuv_format == YUV420) // UYYVYY
|
||||
|
||||
if (source->yuv_format == YUV420) // UYYVYY
|
||||
{
|
||||
for (i = 0; i < source->size_cmp[1]; i++)
|
||||
{
|
||||
for (i = 0; i < source->size_cmp[1]; i++) {
|
||||
memcpy(ocmp1, icmp0, symbol_size_in_bytes);
|
||||
ocmp1 += symbol_size_in_bytes;
|
||||
icmp0 += symbol_size_in_bytes;
|
||||
|
@ -164,14 +158,14 @@ static void deinterleave ( unsigned char** input, //!< input buffer
|
|||
}
|
||||
|
||||
// flip buffers
|
||||
icmp0 = *input;
|
||||
*input = *output;
|
||||
icmp0 = *input;
|
||||
*input = *output;
|
||||
*output = icmp0;
|
||||
}
|
||||
if (source->yuv_format == YUV422) // YUYV/YUY2. We should also maybe add UYVY given it's popularity
|
||||
if (source->yuv_format ==
|
||||
YUV422) // YUYV/YUY2. We should also maybe add UYVY given it's popularity
|
||||
{
|
||||
for (i = 0; i < source->size_cmp[1]; i++)
|
||||
{
|
||||
for (i = 0; i < source->size_cmp[1]; i++) {
|
||||
// Y
|
||||
memcpy(ocmp0, icmp0, symbol_size_in_bytes);
|
||||
ocmp0 += symbol_size_in_bytes;
|
||||
|
@ -191,14 +185,11 @@ static void deinterleave ( unsigned char** input, //!< input buffer
|
|||
}
|
||||
|
||||
// flip buffers
|
||||
icmp0 = *input;
|
||||
*input = *output;
|
||||
icmp0 = *input;
|
||||
*input = *output;
|
||||
*output = icmp0;
|
||||
}
|
||||
else if (source->yuv_format == YUV444)
|
||||
{
|
||||
for (i = 0; i < source->size_cmp[0]; i++)
|
||||
{
|
||||
} else if (source->yuv_format == YUV444) {
|
||||
for (i = 0; i < source->size_cmp[0]; i++) {
|
||||
memcpy(ocmp0, icmp0, symbol_size_in_bytes);
|
||||
ocmp0 += symbol_size_in_bytes;
|
||||
icmp0 += symbol_size_in_bytes;
|
||||
|
@ -210,8 +201,8 @@ static void deinterleave ( unsigned char** input, //!< input buffer
|
|||
icmp0 += symbol_size_in_bytes;
|
||||
}
|
||||
// flip buffers
|
||||
icmp0 = *input;
|
||||
*input = *output;
|
||||
icmp0 = *input;
|
||||
*input = *output;
|
||||
*output = icmp0;
|
||||
}
|
||||
}
|
||||
|
@ -222,235 +213,236 @@ static void deinterleave ( unsigned char** input, //!< input buffer
|
|||
* Convert file read buffer to source picture structure
|
||||
************************************************************************
|
||||
*/
|
||||
void buf2img_bitshift ( imgpel** imgX, //!< Pointer to image plane
|
||||
unsigned char* buf, //!< Buffer for file output
|
||||
int size_x, //!< horizontal size of picture
|
||||
int size_y, //!< vertical size of picture
|
||||
int o_size_x, //!< horizontal size of picture
|
||||
int o_size_y, //!< vertical size of picture
|
||||
int symbol_size_in_bytes, //!< number of bytes in file used for one pixel
|
||||
int bitshift //!< variable for bitdepth expansion
|
||||
)
|
||||
{
|
||||
int i,j;
|
||||
void buf2img_bitshift(
|
||||
imgpel **imgX, //!< Pointer to image plane
|
||||
unsigned char *buf, //!< Buffer for file output
|
||||
int size_x, //!< horizontal size of picture
|
||||
int size_y, //!< vertical size of picture
|
||||
int o_size_x, //!< horizontal size of picture
|
||||
int o_size_y, //!< vertical size of picture
|
||||
int symbol_size_in_bytes, //!< number of bytes in file used for one pixel
|
||||
int bitshift //!< variable for bitdepth expansion
|
||||
) {
|
||||
int i, j;
|
||||
|
||||
uint16 tmp16, ui16;
|
||||
unsigned long tmp32, ui32;
|
||||
unsigned long tmp32, ui32;
|
||||
// This test should be done once.
|
||||
if (((symbol_size_in_bytes << 3) - bitshift) > (int) (sizeof(imgpel)<< 3))
|
||||
{
|
||||
error ("Source picture has higher bit depth than imgpel data type. \nPlease recompile with larger data type for imgpel.", 500);
|
||||
if (((symbol_size_in_bytes << 3) - bitshift) > (int)(sizeof(imgpel) << 3)) {
|
||||
error("Source picture has higher bit depth than imgpel data type. \nPlease "
|
||||
"recompile with larger data type for imgpel.",
|
||||
500);
|
||||
}
|
||||
|
||||
if (testEndian())
|
||||
{
|
||||
if (size_x != o_size_x || size_y != o_size_y)
|
||||
{
|
||||
error ("Rescaling not supported in big endian architectures. ", 500);
|
||||
if (testEndian()) {
|
||||
if (size_x != o_size_x || size_y != o_size_y) {
|
||||
error("Rescaling not supported in big endian architectures. ", 500);
|
||||
}
|
||||
|
||||
// big endian
|
||||
switch (symbol_size_in_bytes)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
for(j = 0; j < o_size_y; j++)
|
||||
for(i = 0; i < o_size_x; i++)
|
||||
{
|
||||
imgX[j][i]= (imgpel) rshift_rnd(buf[i + j*size_x], bitshift);
|
||||
}
|
||||
break;
|
||||
switch (symbol_size_in_bytes) {
|
||||
case 1: {
|
||||
for (j = 0; j < o_size_y; j++)
|
||||
for (i = 0; i < o_size_x; i++) {
|
||||
imgX[j][i] = (imgpel)rshift_rnd(buf[i + j * size_x], bitshift);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
for (j = 0; j < o_size_y; j++)
|
||||
for (i = 0; i < o_size_x; i++) {
|
||||
memcpy(&tmp16, buf + ((i + j * size_x) * 2), 2);
|
||||
ui16 = (tmp16 >> 8) | ((tmp16 & 0xFF) << 8);
|
||||
imgX[j][i] = (imgpel)rshift_rnd(ui16, bitshift);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
for (j = 0; j < o_size_y; j++)
|
||||
for (i = 0; i < o_size_x; i++) {
|
||||
memcpy(&tmp32, buf + ((i + j * size_x) * 4), 4);
|
||||
ui32 = ((tmp32 & 0xFF00) << 8) | ((tmp32 & 0xFF) << 24) |
|
||||
((tmp32 & 0xFF0000) >> 8) | ((tmp32 & 0xFF000000) >> 24);
|
||||
imgX[j][i] = (imgpel)rshift_rnd(ui32, bitshift);
|
||||
}
|
||||
}
|
||||
default: {
|
||||
error("reading only from formats of 8, 16 or 32 bit allowed on big "
|
||||
"endian architecture",
|
||||
500);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// little endian
|
||||
int j_pos;
|
||||
if (size_x == o_size_x && size_y == o_size_y) {
|
||||
for (j = 0; j < o_size_y; j++) {
|
||||
j_pos = j * size_x;
|
||||
for (i = 0; i < o_size_x; i++) {
|
||||
ui16 = 0;
|
||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes),
|
||||
symbol_size_in_bytes);
|
||||
imgX[j][i] = (imgpel)rshift_rnd(ui16, bitshift);
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
for(j = 0; j < o_size_y; j++)
|
||||
for(i = 0; i < o_size_x; i++)
|
||||
{
|
||||
memcpy(&tmp16, buf+((i+j*size_x)*2), 2);
|
||||
ui16 = (tmp16 >> 8) | ((tmp16&0xFF)<<8);
|
||||
imgX[j][i] = (imgpel) rshift_rnd(ui16, bitshift);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
for(j = 0; j < o_size_y; j++)
|
||||
for(i = 0; i < o_size_x; i++)
|
||||
{
|
||||
memcpy(&tmp32, buf+((i+j*size_x)*4), 4);
|
||||
ui32 = ((tmp32&0xFF00)<<8) | ((tmp32&0xFF)<<24) | ((tmp32&0xFF0000)>>8) | ((tmp32&0xFF000000)>>24);
|
||||
imgX[j][i] = (imgpel) rshift_rnd(ui32, bitshift);
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
error ("reading only from formats of 8, 16 or 32 bit allowed on big endian architecture", 500);
|
||||
break;
|
||||
} else {
|
||||
int iminwidth = imin(size_x, o_size_x);
|
||||
int iminheight = imin(size_y, o_size_y);
|
||||
int dst_offset_x = 0, dst_offset_y = 0;
|
||||
int offset_x = 0, offset_y = 0; // currently not used
|
||||
|
||||
// determine whether we need to center the copied frame or crop it
|
||||
if (o_size_x >= size_x)
|
||||
dst_offset_x = (o_size_x - size_x) >> 1;
|
||||
|
||||
if (o_size_y >= size_y)
|
||||
dst_offset_y = (o_size_y - size_y) >> 1;
|
||||
|
||||
// check copied area to avoid copying memory garbage
|
||||
// source
|
||||
iminwidth =
|
||||
((offset_x + iminwidth) > size_x) ? (size_x - offset_x) : iminwidth;
|
||||
iminheight =
|
||||
((offset_y + iminheight) > size_y) ? (size_y - offset_y) : iminheight;
|
||||
// destination
|
||||
iminwidth = ((dst_offset_x + iminwidth) > o_size_x)
|
||||
? (o_size_x - dst_offset_x)
|
||||
: iminwidth;
|
||||
iminheight = ((dst_offset_y + iminheight) > o_size_y)
|
||||
? (o_size_y - dst_offset_y)
|
||||
: iminheight;
|
||||
|
||||
for (j = 0; j < iminheight; j++) {
|
||||
j_pos = (j + offset_y) * size_x + offset_x;
|
||||
for (i = 0; i < iminwidth; i++) {
|
||||
ui16 = 0;
|
||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes),
|
||||
symbol_size_in_bytes);
|
||||
imgX[j + dst_offset_y][i + dst_offset_x] =
|
||||
(imgpel)rshift_rnd(ui16, bitshift);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// little endian
|
||||
int j_pos;
|
||||
if (size_x == o_size_x && size_y == o_size_y)
|
||||
{
|
||||
for (j = 0; j < o_size_y; j++)
|
||||
{
|
||||
j_pos = j*size_x;
|
||||
for (i = 0; i < o_size_x; i++)
|
||||
{
|
||||
ui16=0;
|
||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes), symbol_size_in_bytes);
|
||||
imgX[j][i] = (imgpel) rshift_rnd(ui16,bitshift);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int iminwidth = imin(size_x, o_size_x);
|
||||
int iminheight = imin(size_y, o_size_y);
|
||||
int dst_offset_x = 0, dst_offset_y = 0;
|
||||
int offset_x = 0, offset_y = 0; // currently not used
|
||||
|
||||
// determine whether we need to center the copied frame or crop it
|
||||
if ( o_size_x >= size_x )
|
||||
dst_offset_x = ( o_size_x - size_x ) >> 1;
|
||||
|
||||
if (o_size_y >= size_y)
|
||||
dst_offset_y = ( o_size_y - size_y ) >> 1;
|
||||
|
||||
// check copied area to avoid copying memory garbage
|
||||
// source
|
||||
iminwidth = ( (offset_x + iminwidth ) > size_x ) ? (size_x - offset_x) : iminwidth;
|
||||
iminheight = ( (offset_y + iminheight) > size_y ) ? (size_y - offset_y) : iminheight;
|
||||
// destination
|
||||
iminwidth = ( (dst_offset_x + iminwidth ) > o_size_x ) ? (o_size_x - dst_offset_x) : iminwidth;
|
||||
iminheight = ( (dst_offset_y + iminheight) > o_size_y ) ? (o_size_y - dst_offset_y) : iminheight;
|
||||
|
||||
for (j=0; j < iminheight; j++)
|
||||
{
|
||||
j_pos = (j + offset_y) * size_x + offset_x;
|
||||
for (i=0; i < iminwidth; i++)
|
||||
{
|
||||
ui16=0;
|
||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes), symbol_size_in_bytes);
|
||||
imgX[j + dst_offset_y][i + dst_offset_x] = (imgpel) rshift_rnd(ui16,bitshift);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
* Convert file read buffer to source picture structure
|
||||
************************************************************************
|
||||
*/
|
||||
void buf2img_basic (imgpel** imgX, //!< Pointer to image plane
|
||||
unsigned char* buf, //!< Buffer for file output
|
||||
int size_x, //!< horizontal size of picture
|
||||
int size_y, //!< vertical size of picture
|
||||
int o_size_x, //!< horizontal size of picture
|
||||
int o_size_y, //!< vertical size of picture
|
||||
int symbol_size_in_bytes, //!< number of bytes in file used for one pixel
|
||||
int dummy //!< dummy variable used for allowing function pointer use
|
||||
)
|
||||
{
|
||||
int i,j;
|
||||
unsigned char* temp_buf = buf;
|
||||
void buf2img_basic(
|
||||
imgpel **imgX, //!< Pointer to image plane
|
||||
unsigned char *buf, //!< Buffer for file output
|
||||
int size_x, //!< horizontal size of picture
|
||||
int size_y, //!< vertical size of picture
|
||||
int o_size_x, //!< horizontal size of picture
|
||||
int o_size_y, //!< vertical size of picture
|
||||
int symbol_size_in_bytes, //!< number of bytes in file used for one pixel
|
||||
int dummy //!< dummy variable used for allowing function pointer use
|
||||
) {
|
||||
int i, j;
|
||||
unsigned char *temp_buf = buf;
|
||||
|
||||
if (symbol_size_in_bytes> (int) sizeof(imgpel))
|
||||
{
|
||||
error ("Source picture has higher bit depth than imgpel data type. \nPlease recompile with larger data type for imgpel.", 500);
|
||||
if (symbol_size_in_bytes > (int)sizeof(imgpel)) {
|
||||
error("Source picture has higher bit depth than imgpel data type. \nPlease "
|
||||
"recompile with larger data type for imgpel.",
|
||||
500);
|
||||
}
|
||||
|
||||
if (( sizeof (imgpel) == symbol_size_in_bytes))
|
||||
{
|
||||
if ((sizeof(imgpel) == symbol_size_in_bytes)) {
|
||||
// imgpel == pixel_in_file -> simple copy
|
||||
if (size_x == o_size_x && size_y == o_size_y)
|
||||
memcpy(&imgX[0][0], temp_buf, size_x * size_y * sizeof(imgpel));
|
||||
else
|
||||
{
|
||||
int iminwidth = imin(size_x, o_size_x);
|
||||
int iminheight = imin(size_y, o_size_y);
|
||||
int dst_offset_x = 0, dst_offset_y = 0;
|
||||
else {
|
||||
int iminwidth = imin(size_x, o_size_x);
|
||||
int iminheight = imin(size_y, o_size_y);
|
||||
int dst_offset_x = 0, dst_offset_y = 0;
|
||||
int offset_x = 0, offset_y = 0; // currently not used
|
||||
|
||||
// determine whether we need to center the copied frame or crop it
|
||||
if ( o_size_x >= size_x )
|
||||
dst_offset_x = ( o_size_x - size_x ) >> 1;
|
||||
|
||||
if (o_size_y >= size_y)
|
||||
dst_offset_y = ( o_size_y - size_y ) >> 1;
|
||||
// determine whether we need to center the copied frame or crop it
|
||||
if (o_size_x >= size_x)
|
||||
dst_offset_x = (o_size_x - size_x) >> 1;
|
||||
|
||||
if (o_size_y >= size_y)
|
||||
dst_offset_y = (o_size_y - size_y) >> 1;
|
||||
|
||||
// check copied area to avoid copying memory garbage
|
||||
// source
|
||||
iminwidth = ( (offset_x + iminwidth ) > size_x ) ? (size_x - offset_x) : iminwidth;
|
||||
iminheight = ( (offset_y + iminheight) > size_y ) ? (size_y - offset_y) : iminheight;
|
||||
iminwidth =
|
||||
((offset_x + iminwidth) > size_x) ? (size_x - offset_x) : iminwidth;
|
||||
iminheight =
|
||||
((offset_y + iminheight) > size_y) ? (size_y - offset_y) : iminheight;
|
||||
// destination
|
||||
iminwidth = ( (dst_offset_x + iminwidth ) > o_size_x ) ? (o_size_x - dst_offset_x) : iminwidth;
|
||||
iminheight = ( (dst_offset_y + iminheight) > o_size_y ) ? (o_size_y - dst_offset_y) : iminheight;
|
||||
iminwidth = ((dst_offset_x + iminwidth) > o_size_x)
|
||||
? (o_size_x - dst_offset_x)
|
||||
: iminwidth;
|
||||
iminheight = ((dst_offset_y + iminheight) > o_size_y)
|
||||
? (o_size_y - dst_offset_y)
|
||||
: iminheight;
|
||||
|
||||
for (i=0; i<iminheight;i++) {
|
||||
memcpy(&imgX[i + dst_offset_y][dst_offset_x], &(temp_buf[(i + offset_y) * size_x + offset_x]), iminwidth * sizeof(imgpel));
|
||||
for (i = 0; i < iminheight; i++) {
|
||||
memcpy(&imgX[i + dst_offset_y][dst_offset_x],
|
||||
&(temp_buf[(i + offset_y) * size_x + offset_x]),
|
||||
iminwidth * sizeof(imgpel));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int j_pos;
|
||||
uint16 ui16;
|
||||
if (size_x == o_size_x && size_y == o_size_y)
|
||||
{
|
||||
for (j=0; j < o_size_y; j++)
|
||||
{
|
||||
if (size_x == o_size_x && size_y == o_size_y) {
|
||||
for (j = 0; j < o_size_y; j++) {
|
||||
j_pos = j * size_x;
|
||||
for (i=0; i < o_size_x; i++)
|
||||
{
|
||||
ui16=0;
|
||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes), symbol_size_in_bytes);
|
||||
imgX[j][i]= (imgpel) ui16;
|
||||
for (i = 0; i < o_size_x; i++) {
|
||||
ui16 = 0;
|
||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes),
|
||||
symbol_size_in_bytes);
|
||||
imgX[j][i] = (imgpel)ui16;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int iminwidth = imin(size_x, o_size_x);
|
||||
int iminheight = imin(size_y, o_size_y);
|
||||
int dst_offset_x = 0, dst_offset_y = 0;
|
||||
}
|
||||
} else {
|
||||
int iminwidth = imin(size_x, o_size_x);
|
||||
int iminheight = imin(size_y, o_size_y);
|
||||
int dst_offset_x = 0, dst_offset_y = 0;
|
||||
int offset_x = 0, offset_y = 0; // currently not used
|
||||
|
||||
// determine whether we need to center the copied frame or crop it
|
||||
if ( o_size_x >= size_x )
|
||||
dst_offset_x = ( o_size_x - size_x ) >> 1;
|
||||
|
||||
if (o_size_y >= size_y)
|
||||
dst_offset_y = ( o_size_y - size_y ) >> 1;
|
||||
// determine whether we need to center the copied frame or crop it
|
||||
if (o_size_x >= size_x)
|
||||
dst_offset_x = (o_size_x - size_x) >> 1;
|
||||
|
||||
if (o_size_y >= size_y)
|
||||
dst_offset_y = (o_size_y - size_y) >> 1;
|
||||
|
||||
// check copied area to avoid copying memory garbage
|
||||
// source
|
||||
iminwidth = ( (offset_x + iminwidth ) > size_x ) ? (size_x - offset_x) : iminwidth;
|
||||
iminheight = ( (offset_y + iminheight) > size_y ) ? (size_y - offset_y) : iminheight;
|
||||
iminwidth =
|
||||
((offset_x + iminwidth) > size_x) ? (size_x - offset_x) : iminwidth;
|
||||
iminheight =
|
||||
((offset_y + iminheight) > size_y) ? (size_y - offset_y) : iminheight;
|
||||
// destination
|
||||
iminwidth = ( (dst_offset_x + iminwidth ) > o_size_x ) ? (o_size_x - dst_offset_x) : iminwidth;
|
||||
iminheight = ( (dst_offset_y + iminheight) > o_size_y ) ? (o_size_y - dst_offset_y) : iminheight;
|
||||
iminwidth = ((dst_offset_x + iminwidth) > o_size_x)
|
||||
? (o_size_x - dst_offset_x)
|
||||
: iminwidth;
|
||||
iminheight = ((dst_offset_y + iminheight) > o_size_y)
|
||||
? (o_size_y - dst_offset_y)
|
||||
: iminheight;
|
||||
|
||||
for (j = 0; j < iminheight; j++) {
|
||||
memcpy(&imgX[j + dst_offset_y][dst_offset_x], &(temp_buf[(j + offset_y) * size_x + offset_x]), iminwidth * sizeof(imgpel));
|
||||
memcpy(&imgX[j + dst_offset_y][dst_offset_x],
|
||||
&(temp_buf[(j + offset_y) * size_x + offset_x]),
|
||||
iminwidth * sizeof(imgpel));
|
||||
}
|
||||
for (j=0; j < iminheight; j++)
|
||||
{
|
||||
for (j = 0; j < iminheight; j++) {
|
||||
j_pos = (j + offset_y) * size_x + offset_x;
|
||||
for (i=0; i < iminwidth; i++)
|
||||
{
|
||||
for (i = 0; i < iminwidth; i++) {
|
||||
ui16 = 0;
|
||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes), symbol_size_in_bytes);
|
||||
imgX[j + dst_offset_y][i + dst_offset_x]= (imgpel) ui16;
|
||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes),
|
||||
symbol_size_in_bytes);
|
||||
imgX[j + dst_offset_y][i + dst_offset_x] = (imgpel)ui16;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -461,77 +453,69 @@ void buf2img_basic (imgpel** imgX, //!< Pointer to image plane
|
|||
* Convert file read buffer to source picture structure
|
||||
************************************************************************
|
||||
*/
|
||||
void buf2img_endian (imgpel** imgX, //!< Pointer to image plane
|
||||
unsigned char* buf, //!< Buffer for file output
|
||||
int size_x, //!< horizontal size of picture
|
||||
int size_y, //!< vertical size of picture
|
||||
int o_size_x, //!< horizontal size of picture
|
||||
int o_size_y, //!< vertical size of picture
|
||||
int symbol_size_in_bytes, //!< number of bytes in file used for one pixel
|
||||
int dummy //!< dummy variable used for allowing function pointer use
|
||||
)
|
||||
{
|
||||
int i,j;
|
||||
void buf2img_endian(
|
||||
imgpel **imgX, //!< Pointer to image plane
|
||||
unsigned char *buf, //!< Buffer for file output
|
||||
int size_x, //!< horizontal size of picture
|
||||
int size_y, //!< vertical size of picture
|
||||
int o_size_x, //!< horizontal size of picture
|
||||
int o_size_y, //!< vertical size of picture
|
||||
int symbol_size_in_bytes, //!< number of bytes in file used for one pixel
|
||||
int dummy //!< dummy variable used for allowing function pointer use
|
||||
) {
|
||||
int i, j;
|
||||
|
||||
uint16 tmp16, ui16;
|
||||
unsigned long tmp32, ui32;
|
||||
unsigned long tmp32, ui32;
|
||||
|
||||
if (symbol_size_in_bytes > (int) sizeof(imgpel))
|
||||
{
|
||||
error ("Source picture has higher bit depth than imgpel data type. \nPlease recompile with larger data type for imgpel.", 500);
|
||||
if (symbol_size_in_bytes > (int)sizeof(imgpel)) {
|
||||
error("Source picture has higher bit depth than imgpel data type. \nPlease "
|
||||
"recompile with larger data type for imgpel.",
|
||||
500);
|
||||
}
|
||||
|
||||
if (size_x != o_size_x || size_y != o_size_y)
|
||||
{
|
||||
error ("Rescaling not supported in big endian architectures. ", 500);
|
||||
if (size_x != o_size_x || size_y != o_size_y) {
|
||||
error("Rescaling not supported in big endian architectures. ", 500);
|
||||
}
|
||||
|
||||
// big endian
|
||||
switch (symbol_size_in_bytes)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
for(j=0;j<size_y;j++)
|
||||
{
|
||||
for(i=0;i<size_x;i++)
|
||||
{
|
||||
imgX[j][i]= (imgpel) buf[i + j*size_x];
|
||||
}
|
||||
switch (symbol_size_in_bytes) {
|
||||
case 1: {
|
||||
for (j = 0; j < size_y; j++) {
|
||||
for (i = 0; i < size_x; i++) {
|
||||
imgX[j][i] = (imgpel)buf[i + j * size_x];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
for(j=0;j<size_y;j++)
|
||||
{
|
||||
for(i=0;i<size_x;i++)
|
||||
{
|
||||
memcpy(&tmp16, buf+((i+j*size_x)*2), 2);
|
||||
ui16 = (tmp16 >> 8) | ((tmp16&0xFF)<<8);
|
||||
imgX[j][i] = (imgpel) ui16;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
for (j = 0; j < size_y; j++) {
|
||||
for (i = 0; i < size_x; i++) {
|
||||
memcpy(&tmp16, buf + ((i + j * size_x) * 2), 2);
|
||||
ui16 = (tmp16 >> 8) | ((tmp16 & 0xFF) << 8);
|
||||
imgX[j][i] = (imgpel)ui16;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
for(j=0;j<size_y;j++)
|
||||
{
|
||||
for(i=0;i<size_x;i++)
|
||||
{
|
||||
memcpy(&tmp32, buf+((i+j*size_x)*4), 4);
|
||||
ui32 = ((tmp32&0xFF00)<<8) | ((tmp32&0xFF)<<24) | ((tmp32&0xFF0000)>>8) | ((tmp32&0xFF000000)>>24);
|
||||
imgX[j][i] = (imgpel) ui32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
for (j = 0; j < size_y; j++) {
|
||||
for (i = 0; i < size_x; i++) {
|
||||
memcpy(&tmp32, buf + ((i + j * size_x) * 4), 4);
|
||||
ui32 = ((tmp32 & 0xFF00) << 8) | ((tmp32 & 0xFF) << 24) |
|
||||
((tmp32 & 0xFF0000) >> 8) | ((tmp32 & 0xFF000000) >> 24);
|
||||
imgX[j][i] = (imgpel)ui32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
error ("reading only from formats of 8, 16 or 32 bit allowed on big endian architecture", 500);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
error("reading only from formats of 8, 16 or 32 bit allowed on big endian "
|
||||
"architecture",
|
||||
500);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -541,13 +525,14 @@ void buf2img_endian (imgpel** imgX, //!< Pointer to image plane
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
void AllocateFrameMemory (VideoParameters *p_Vid, InputParameters *p_Inp, FrameFormat *source)
|
||||
{
|
||||
if (NULL == (p_Vid->buf = malloc (source->size * source->pic_unit_size_shift3)))
|
||||
void AllocateFrameMemory(VideoParameters *p_Vid, InputParameters *p_Inp,
|
||||
FrameFormat *source) {
|
||||
if (NULL ==
|
||||
(p_Vid->buf = malloc(source->size * source->pic_unit_size_shift3)))
|
||||
no_mem_exit("AllocateFrameMemory: p_Vid->buf");
|
||||
if (p_Inp->input_file1.is_interleaved)
|
||||
{
|
||||
if (NULL == (p_Vid->ibuf = malloc (source->size * source->pic_unit_size_shift3)))
|
||||
if (p_Inp->input_file1.is_interleaved) {
|
||||
if (NULL ==
|
||||
(p_Vid->ibuf = malloc(source->size * source->pic_unit_size_shift3)))
|
||||
no_mem_exit("AllocateFrameMemory: p_Vid->ibuf");
|
||||
}
|
||||
}
|
||||
|
@ -559,12 +544,11 @@ void AllocateFrameMemory (VideoParameters *p_Vid, InputParameters *p_Inp, FrameF
|
|||
*
|
||||
************************************************************************
|
||||
*/
|
||||
void DeleteFrameMemory (VideoParameters *p_Vid)
|
||||
{
|
||||
void DeleteFrameMemory(VideoParameters *p_Vid) {
|
||||
if (p_Vid->buf != NULL)
|
||||
free (p_Vid->buf);
|
||||
free(p_Vid->buf);
|
||||
if (p_Vid->ibuf != NULL)
|
||||
free (p_Vid->ibuf);
|
||||
free(p_Vid->ibuf);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -579,87 +563,98 @@ void DeleteFrameMemory (VideoParameters *p_Vid)
|
|||
* \param HeaderSize
|
||||
* Number of bytes in the source file to be skipped
|
||||
* \param source
|
||||
* source file (on disk) information
|
||||
* source file (on disk) information
|
||||
* \param output
|
||||
* output file (for encoding) information
|
||||
* \param pImage
|
||||
* Image planes
|
||||
************************************************************************
|
||||
*/
|
||||
int read_one_frame (VideoParameters *p_Vid, VideoDataFile *input_file, int FrameNoInFile, int HeaderSize, FrameFormat *source, FrameFormat *output, imgpel **pImage[3])
|
||||
{
|
||||
int read_one_frame(VideoParameters *p_Vid, VideoDataFile *input_file,
|
||||
int FrameNoInFile, int HeaderSize, FrameFormat *source,
|
||||
FrameFormat *output, imgpel **pImage[3]) {
|
||||
InputParameters *p_Inp = p_Vid->p_Inp;
|
||||
int file_read = 0;
|
||||
unsigned int symbol_size_in_bytes = source->pic_unit_size_shift3;
|
||||
unsigned int symbol_size_in_bytes = source->pic_unit_size_shift3;
|
||||
|
||||
const int bytes_y = source->size_cmp[0] * symbol_size_in_bytes;
|
||||
const int bytes_uv = source->size_cmp[1] * symbol_size_in_bytes;
|
||||
int bit_scale;
|
||||
const int bytes_y = source->size_cmp[0] * symbol_size_in_bytes;
|
||||
const int bytes_uv = source->size_cmp[1] * symbol_size_in_bytes;
|
||||
int bit_scale;
|
||||
|
||||
Boolean rgb_input = (Boolean) (source->color_model == CM_RGB && source->yuv_format == YUV444);
|
||||
Boolean rgb_input =
|
||||
(Boolean)(source->color_model == CM_RGB && source->yuv_format == YUV444);
|
||||
|
||||
if (input_file->is_concatenated == 0)
|
||||
{
|
||||
if (input_file->vdtype == VIDEO_TIFF)
|
||||
{
|
||||
file_read = ReadTIFFImage (p_Inp, input_file, FrameNoInFile, source, p_Vid->buf);
|
||||
if (input_file->is_concatenated == 0) {
|
||||
if (input_file->vdtype == VIDEO_TIFF) {
|
||||
file_read =
|
||||
ReadTIFFImage(p_Inp, input_file, FrameNoInFile, source, p_Vid->buf);
|
||||
} else {
|
||||
file_read = ReadFrameSeparate(p_Inp, input_file, FrameNoInFile,
|
||||
HeaderSize, source, p_Vid->buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
file_read = ReadFrameSeparate (p_Inp, input_file, FrameNoInFile, HeaderSize, source, p_Vid->buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
file_read = ReadFrameConcatenated (p_Inp, input_file, FrameNoInFile, HeaderSize, source, p_Vid->buf);
|
||||
}
|
||||
if ( !file_read )
|
||||
{
|
||||
} else {
|
||||
file_read = ReadFrameConcatenated(p_Inp, input_file, FrameNoInFile,
|
||||
HeaderSize, source, p_Vid->buf);
|
||||
}
|
||||
if (!file_read) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Deinterleave input source
|
||||
if (input_file->is_interleaved)
|
||||
{
|
||||
deinterleave ( &p_Vid->buf, &p_Vid->ibuf, source, symbol_size_in_bytes);
|
||||
}
|
||||
// Deinterleave input source
|
||||
if (input_file->is_interleaved) {
|
||||
deinterleave(&p_Vid->buf, &p_Vid->ibuf, source, symbol_size_in_bytes);
|
||||
}
|
||||
|
||||
bit_scale = source->bit_depth[0] - output->bit_depth[0];
|
||||
bit_scale = source->bit_depth[0] - output->bit_depth[0];
|
||||
|
||||
if(rgb_input)
|
||||
p_Vid->buf2img(pImage[0], p_Vid->buf + bytes_y, source->width[0], source->height[0], output->width[0], output->height[0], symbol_size_in_bytes, bit_scale);
|
||||
else
|
||||
p_Vid->buf2img(pImage[0], p_Vid->buf, source->width[0], source->height[0], output->width[0], output->height[0], symbol_size_in_bytes, bit_scale);
|
||||
if (rgb_input)
|
||||
p_Vid->buf2img(pImage[0], p_Vid->buf + bytes_y, source->width[0],
|
||||
source->height[0], output->width[0], output->height[0],
|
||||
symbol_size_in_bytes, bit_scale);
|
||||
else
|
||||
p_Vid->buf2img(pImage[0], p_Vid->buf, source->width[0], source->height[0],
|
||||
output->width[0], output->height[0], symbol_size_in_bytes,
|
||||
bit_scale);
|
||||
|
||||
#if (DEBUG_BITDEPTH)
|
||||
MaskMSBs(pImage[0], ((1 << output->bit_depth[0]) - 1), output->width[0], output->height[0]);
|
||||
MaskMSBs(pImage[0], ((1 << output->bit_depth[0]) - 1), output->width[0],
|
||||
output->height[0]);
|
||||
#endif
|
||||
|
||||
if (p_Vid->yuv_format != YUV400)
|
||||
{
|
||||
bit_scale = source->bit_depth[1] - output->bit_depth[1];
|
||||
if (p_Vid->yuv_format != YUV400) {
|
||||
bit_scale = source->bit_depth[1] - output->bit_depth[1];
|
||||
#if (ALLOW_GRAYSCALE)
|
||||
if (!p_Inp->grayscale)
|
||||
if (!p_Inp->grayscale)
|
||||
#endif
|
||||
{
|
||||
if(rgb_input)
|
||||
p_Vid->buf2img(pImage[1], p_Vid->buf + bytes_y + bytes_uv, source->width[1], source->height[1], output->width[1], output->height[1], symbol_size_in_bytes, bit_scale);
|
||||
else
|
||||
p_Vid->buf2img(pImage[1], p_Vid->buf + bytes_y, source->width[1], source->height[1], output->width[1], output->height[1], symbol_size_in_bytes, bit_scale);
|
||||
{
|
||||
if (rgb_input)
|
||||
p_Vid->buf2img(pImage[1], p_Vid->buf + bytes_y + bytes_uv,
|
||||
source->width[1], source->height[1], output->width[1],
|
||||
output->height[1], symbol_size_in_bytes, bit_scale);
|
||||
else
|
||||
p_Vid->buf2img(pImage[1], p_Vid->buf + bytes_y, source->width[1],
|
||||
source->height[1], output->width[1], output->height[1],
|
||||
symbol_size_in_bytes, bit_scale);
|
||||
|
||||
bit_scale = source->bit_depth[2] - output->bit_depth[2];
|
||||
if(rgb_input)
|
||||
p_Vid->buf2img(pImage[2], p_Vid->buf, source->width[1], source->height[1], output->width[1], output->height[1], symbol_size_in_bytes, bit_scale);
|
||||
else
|
||||
p_Vid->buf2img(pImage[2], p_Vid->buf + bytes_y + bytes_uv, source->width[1], source->height[1], output->width[1], output->height[1], symbol_size_in_bytes, bit_scale);
|
||||
}
|
||||
bit_scale = source->bit_depth[2] - output->bit_depth[2];
|
||||
if (rgb_input)
|
||||
p_Vid->buf2img(pImage[2], p_Vid->buf, source->width[1],
|
||||
source->height[1], output->width[1], output->height[1],
|
||||
symbol_size_in_bytes, bit_scale);
|
||||
else
|
||||
p_Vid->buf2img(pImage[2], p_Vid->buf + bytes_y + bytes_uv,
|
||||
source->width[1], source->height[1], output->width[1],
|
||||
output->height[1], symbol_size_in_bytes, bit_scale);
|
||||
}
|
||||
#if (DEBUG_BITDEPTH)
|
||||
MaskMSBs(pImage[1], ((1 << output->bit_depth[1]) - 1), output->width[1], output->height[1]);
|
||||
MaskMSBs(pImage[2], ((1 << output->bit_depth[2]) - 1), output->width[1], output->height[1]);
|
||||
MaskMSBs(pImage[1], ((1 << output->bit_depth[1]) - 1), output->width[1],
|
||||
output->height[1]);
|
||||
MaskMSBs(pImage[2], ((1 << output->bit_depth[2]) - 1), output->width[1],
|
||||
output->height[1]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return file_read;
|
||||
return file_read;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -682,39 +677,38 @@ int read_one_frame (VideoParameters *p_Vid, VideoDataFile *input_file, int Frame
|
|||
* image planes
|
||||
************************************************************************
|
||||
*/
|
||||
void pad_borders (FrameFormat output, int img_size_x, int img_size_y, int img_size_x_cr, int img_size_y_cr, imgpel **pImage[3])
|
||||
{
|
||||
void pad_borders(FrameFormat output, int img_size_x, int img_size_y,
|
||||
int img_size_x_cr, int img_size_y_cr, imgpel **pImage[3]) {
|
||||
int x, y;
|
||||
|
||||
// Luma or 1st component
|
||||
//padding right border
|
||||
// padding right border
|
||||
if (output.width[0] < img_size_x)
|
||||
for (y=0; y < output.height[0]; y++)
|
||||
for (y = 0; y < output.height[0]; y++)
|
||||
for (x = output.width[0]; x < img_size_x; x++)
|
||||
pImage[0] [y][x] = pImage[0][y][x-1];
|
||||
pImage[0][y][x] = pImage[0][y][x - 1];
|
||||
|
||||
//padding bottom border
|
||||
// padding bottom border
|
||||
if (output.height[0] < img_size_y)
|
||||
for (y = output.height[0]; y<img_size_y; y++)
|
||||
for (y = output.height[0]; y < img_size_y; y++)
|
||||
memcpy(pImage[0][y], pImage[0][y - 1], img_size_x * sizeof(imgpel));
|
||||
|
||||
// Chroma or all other components
|
||||
if (output.yuv_format != YUV400)
|
||||
{
|
||||
if (output.yuv_format != YUV400) {
|
||||
int k;
|
||||
|
||||
for (k = 1; k < 3; k++)
|
||||
{
|
||||
//padding right border
|
||||
for (k = 1; k < 3; k++) {
|
||||
// padding right border
|
||||
if (output.width[1] < img_size_x_cr)
|
||||
for (y=0; y < output.height[1]; y++)
|
||||
for (y = 0; y < output.height[1]; y++)
|
||||
for (x = output.width[1]; x < img_size_x_cr; x++)
|
||||
pImage [k][y][x] = pImage[k][y][x-1];
|
||||
pImage[k][y][x] = pImage[k][y][x - 1];
|
||||
|
||||
//padding bottom border
|
||||
// padding bottom border
|
||||
if (output.height[1] < img_size_y_cr)
|
||||
for (y = output.height[1]; y < img_size_y_cr; y++)
|
||||
memcpy(pImage[k][y], pImage[k][y - 1], img_size_x_cr * sizeof(imgpel));
|
||||
memcpy(pImage[k][y], pImage[k][y - 1],
|
||||
img_size_x_cr * sizeof(imgpel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,42 +6,39 @@
|
|||
* Functions for intra 16x16 prediction
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* address and affiliation details)
|
||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||
*
|
||||
*************************************************************************************
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "intra16x16_pred.h"
|
||||
#include "mb_access.h"
|
||||
#include "global.h"
|
||||
#include "image.h"
|
||||
#include "mb_access.h"
|
||||
|
||||
|
||||
extern int intrapred_16x16_mbaff (Macroblock *currMB, ColorPlane pl, int predmode);
|
||||
extern int intrapred_16x16_normal(Macroblock *currMB, ColorPlane pl, int predmode);
|
||||
extern int intrapred_16x16_mbaff(Macroblock *currMB, ColorPlane pl,
|
||||
int predmode);
|
||||
extern int intrapred_16x16_normal(Macroblock *currMB, ColorPlane pl,
|
||||
int predmode);
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
* makes and returns 16x16 intra prediction blocks
|
||||
* makes and returns 16x16 intra prediction blocks
|
||||
*
|
||||
* \return
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
* SEARCH_SYNC search next sync element as errors while decoding occured
|
||||
***********************************************************************
|
||||
*/
|
||||
int intrapred16x16(Macroblock *currMB, //!< Current Macroblock
|
||||
ColorPlane pl, //!< Current colorplane (for 4:4:4)
|
||||
int predmode) //!< prediction mode
|
||||
int intrapred16x16(Macroblock *currMB, //!< Current Macroblock
|
||||
ColorPlane pl, //!< Current colorplane (for 4:4:4)
|
||||
int predmode) //!< prediction mode
|
||||
{
|
||||
if (currMB->p_Slice->mb_aff_frame_flag)
|
||||
{
|
||||
if (currMB->p_Slice->mb_aff_frame_flag) {
|
||||
return intrapred_16x16_mbaff(currMB, pl, predmode);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return intrapred_16x16_normal(currMB, pl, predmode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Functions for intra 16x16 prediction (MBAFF)
|
||||
*
|
||||
* \author
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* Main contributors (see contributors.h for copyright,
|
||||
* address and affiliation details)
|
||||
* - Yuri Vatis
|
||||
* - Jan Muenster
|
||||
|
@ -15,9 +15,9 @@
|
|||
*************************************************************************************
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "image.h"
|
||||
#include "intra16x16_pred.h"
|
||||
#include "mb_access.h"
|
||||
#include "image.h"
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
|
@ -25,73 +25,69 @@
|
|||
* makes and returns 16x16 DC prediction mode
|
||||
*
|
||||
* \return
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
*
|
||||
***********************************************************************
|
||||
*/
|
||||
static int intra16x16_dc_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||
{
|
||||
static int intra16x16_dc_pred_mbaff(Macroblock *currMB, ColorPlane pl) {
|
||||
Slice *currSlice = currMB->p_Slice;
|
||||
VideoParameters *p_Vid = currMB->p_Vid;
|
||||
|
||||
int s0 = 0, s1 = 0, s2 = 0;
|
||||
|
||||
int i,j;
|
||||
int i, j;
|
||||
|
||||
imgpel **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1] : currSlice->dec_picture->imgY;
|
||||
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
||||
imgpel **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1]
|
||||
: currSlice->dec_picture->imgY;
|
||||
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
||||
|
||||
PixelPos b; //!< pixel position p(0,-1)
|
||||
PixelPos left[17]; //!< pixel positions p(-1, -1..15)
|
||||
PixelPos b; //!< pixel position p(0,-1)
|
||||
PixelPos left[17]; //!< pixel positions p(-1, -1..15)
|
||||
|
||||
int up_avail, left_avail, left_up_avail;
|
||||
|
||||
s1=s2=0;
|
||||
s1 = s2 = 0;
|
||||
|
||||
for (i=0;i<17;++i)
|
||||
{
|
||||
p_Vid->getNeighbour(currMB, -1, i-1, p_Vid->mb_size[IS_LUMA], &left[i]);
|
||||
for (i = 0; i < 17; ++i) {
|
||||
p_Vid->getNeighbour(currMB, -1, i - 1, p_Vid->mb_size[IS_LUMA], &left[i]);
|
||||
}
|
||||
p_Vid->getNeighbour(currMB, 0, -1, p_Vid->mb_size[IS_LUMA], &b);
|
||||
p_Vid->getNeighbour(currMB, 0, -1, p_Vid->mb_size[IS_LUMA], &b);
|
||||
|
||||
if (!p_Vid->active_pps->constrained_intra_pred_flag)
|
||||
{
|
||||
up_avail = b.available;
|
||||
left_avail = left[1].available;
|
||||
if (!p_Vid->active_pps->constrained_intra_pred_flag) {
|
||||
up_avail = b.available;
|
||||
left_avail = left[1].available;
|
||||
left_up_avail = left[0].available;
|
||||
}
|
||||
else
|
||||
{
|
||||
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
||||
} else {
|
||||
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
||||
for (i = 1, left_avail = 1; i < 17; ++i)
|
||||
left_avail &= left[i].available ? currSlice->intra_block[left[i].mb_addr]: 0;
|
||||
left_up_avail = left[0].available ? currSlice->intra_block[left[0].mb_addr]: 0;
|
||||
left_avail &=
|
||||
left[i].available ? currSlice->intra_block[left[i].mb_addr] : 0;
|
||||
left_up_avail =
|
||||
left[0].available ? currSlice->intra_block[left[0].mb_addr] : 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < MB_BLOCK_SIZE; ++i)
|
||||
{
|
||||
for (i = 0; i < MB_BLOCK_SIZE; ++i) {
|
||||
if (up_avail)
|
||||
s1 += imgY[b.pos_y][b.pos_x+i]; // sum hor pix
|
||||
s1 += imgY[b.pos_y][b.pos_x + i]; // sum hor pix
|
||||
if (left_avail)
|
||||
s2 += imgY[left[i + 1].pos_y][left[i + 1].pos_x]; // sum vert pix
|
||||
s2 += imgY[left[i + 1].pos_y][left[i + 1].pos_x]; // sum vert pix
|
||||
}
|
||||
if (up_avail && left_avail)
|
||||
s0 = (s1 + s2 + 16)>>5; // no edge
|
||||
s0 = (s1 + s2 + 16) >> 5; // no edge
|
||||
else if (!up_avail && left_avail)
|
||||
s0 = (s2 + 8)>>4; // upper edge
|
||||
s0 = (s2 + 8) >> 4; // upper edge
|
||||
else if (up_avail && !left_avail)
|
||||
s0 = (s1 + 8)>>4; // left edge
|
||||
s0 = (s1 + 8) >> 4; // left edge
|
||||
else
|
||||
s0 = p_Vid->dc_pred_value_comp[pl]; // top left corner, nothing to predict from
|
||||
|
||||
for(j = 0; j < MB_BLOCK_SIZE; ++j)
|
||||
{
|
||||
s0 = p_Vid->dc_pred_value_comp[pl]; // top left corner, nothing to predict
|
||||
// from
|
||||
|
||||
for (j = 0; j < MB_BLOCK_SIZE; ++j) {
|
||||
#if (IMGTYPE == 0)
|
||||
memset(mb_pred[j], s0, MB_BLOCK_SIZE * sizeof(imgpel));
|
||||
#else
|
||||
for(i = 0; i < MB_BLOCK_SIZE; ++i)
|
||||
{
|
||||
mb_pred[j][i]=(imgpel) s0;
|
||||
for (i = 0; i < MB_BLOCK_SIZE; ++i) {
|
||||
mb_pred[j][i] = (imgpel)s0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -99,51 +95,45 @@ static int intra16x16_dc_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
|||
return DECODING_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
* makes and returns 16x16 vertical prediction mode
|
||||
*
|
||||
* \return
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
*
|
||||
***********************************************************************
|
||||
*/
|
||||
static int intra16x16_vert_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||
{
|
||||
static int intra16x16_vert_pred_mbaff(Macroblock *currMB, ColorPlane pl) {
|
||||
Slice *currSlice = currMB->p_Slice;
|
||||
VideoParameters *p_Vid = currMB->p_Vid;
|
||||
|
||||
|
||||
int j;
|
||||
|
||||
imgpel **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1] : currSlice->dec_picture->imgY;
|
||||
imgpel **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1]
|
||||
: currSlice->dec_picture->imgY;
|
||||
|
||||
PixelPos b; //!< pixel position p(0,-1)
|
||||
PixelPos b; //!< pixel position p(0,-1)
|
||||
|
||||
int up_avail;
|
||||
|
||||
//getNonAffNeighbour(currMB, 0, -1, p_Vid->mb_size[IS_LUMA], &b);
|
||||
p_Vid->getNeighbour(currMB, 0, -1, p_Vid->mb_size[IS_LUMA], &b);
|
||||
// getNonAffNeighbour(currMB, 0, -1, p_Vid->mb_size[IS_LUMA], &b);
|
||||
p_Vid->getNeighbour(currMB, 0, -1, p_Vid->mb_size[IS_LUMA], &b);
|
||||
|
||||
if (!p_Vid->active_pps->constrained_intra_pred_flag)
|
||||
{
|
||||
if (!p_Vid->active_pps->constrained_intra_pred_flag) {
|
||||
up_avail = b.available;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
||||
}
|
||||
|
||||
if (!up_avail)
|
||||
error ("invalid 16x16 intra pred Mode VERT_PRED_16",500);
|
||||
error("invalid 16x16 intra pred Mode VERT_PRED_16", 500);
|
||||
{
|
||||
imgpel **prd = &currSlice->mb_pred[pl][0];
|
||||
imgpel *src = &(imgY[b.pos_y][b.pos_x]);
|
||||
|
||||
for(j=0;j<MB_BLOCK_SIZE; j+= 4)
|
||||
{
|
||||
for (j = 0; j < MB_BLOCK_SIZE; j += 4) {
|
||||
memcpy(*prd++, src, MB_BLOCK_SIZE * sizeof(imgpel));
|
||||
memcpy(*prd++, src, MB_BLOCK_SIZE * sizeof(imgpel));
|
||||
memcpy(*prd++, src, MB_BLOCK_SIZE * sizeof(imgpel));
|
||||
|
@ -154,56 +144,52 @@ static int intra16x16_vert_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
|||
return DECODING_OK;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
* makes and returns 16x16 horizontal prediction mode
|
||||
*
|
||||
* \return
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
*
|
||||
***********************************************************************
|
||||
*/
|
||||
static int intra16x16_hor_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||
{
|
||||
static int intra16x16_hor_pred_mbaff(Macroblock *currMB, ColorPlane pl) {
|
||||
Slice *currSlice = currMB->p_Slice;
|
||||
VideoParameters *p_Vid = currMB->p_Vid;
|
||||
int i,j;
|
||||
int i, j;
|
||||
|
||||
imgpel **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1] : currSlice->dec_picture->imgY;
|
||||
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
||||
imgpel **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1]
|
||||
: currSlice->dec_picture->imgY;
|
||||
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
||||
imgpel prediction;
|
||||
|
||||
PixelPos left[17]; //!< pixel positions p(-1, -1..15)
|
||||
PixelPos left[17]; //!< pixel positions p(-1, -1..15)
|
||||
|
||||
int left_avail, left_up_avail;
|
||||
|
||||
for (i=0;i<17;++i)
|
||||
{
|
||||
p_Vid->getNeighbour(currMB, -1, i-1, p_Vid->mb_size[IS_LUMA], &left[i]);
|
||||
for (i = 0; i < 17; ++i) {
|
||||
p_Vid->getNeighbour(currMB, -1, i - 1, p_Vid->mb_size[IS_LUMA], &left[i]);
|
||||
}
|
||||
|
||||
if (!p_Vid->active_pps->constrained_intra_pred_flag)
|
||||
{
|
||||
left_avail = left[1].available;
|
||||
if (!p_Vid->active_pps->constrained_intra_pred_flag) {
|
||||
left_avail = left[1].available;
|
||||
left_up_avail = left[0].available;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
for (i = 1, left_avail = 1; i < 17; ++i)
|
||||
left_avail &= left[i].available ? currSlice->intra_block[left[i].mb_addr]: 0;
|
||||
left_up_avail = left[0].available ? currSlice->intra_block[left[0].mb_addr]: 0;
|
||||
left_avail &=
|
||||
left[i].available ? currSlice->intra_block[left[i].mb_addr] : 0;
|
||||
left_up_avail =
|
||||
left[0].available ? currSlice->intra_block[left[0].mb_addr] : 0;
|
||||
}
|
||||
|
||||
if (!left_avail)
|
||||
error ("invalid 16x16 intra pred Mode HOR_PRED_16",500);
|
||||
error("invalid 16x16 intra pred Mode HOR_PRED_16", 500);
|
||||
|
||||
for(j = 0; j < MB_BLOCK_SIZE; ++j)
|
||||
{
|
||||
prediction = imgY[left[j+1].pos_y][left[j+1].pos_x];
|
||||
for(i = 0; i < MB_BLOCK_SIZE; ++i)
|
||||
mb_pred[j][i]= prediction; // store predicted 16x16 block
|
||||
for (j = 0; j < MB_BLOCK_SIZE; ++j) {
|
||||
prediction = imgY[left[j + 1].pos_y][left[j + 1].pos_x];
|
||||
for (i = 0; i < MB_BLOCK_SIZE; ++i)
|
||||
mb_pred[j][i] = prediction; // store predicted 16x16 block
|
||||
}
|
||||
|
||||
return DECODING_OK;
|
||||
|
@ -215,74 +201,72 @@ static int intra16x16_hor_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
|||
* makes and returns 16x16 horizontal prediction mode
|
||||
*
|
||||
* \return
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
*
|
||||
***********************************************************************
|
||||
*/
|
||||
static int intra16x16_plane_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||
{
|
||||
static int intra16x16_plane_pred_mbaff(Macroblock *currMB, ColorPlane pl) {
|
||||
Slice *currSlice = currMB->p_Slice;
|
||||
VideoParameters *p_Vid = currMB->p_Vid;
|
||||
|
||||
int i,j;
|
||||
|
||||
int i, j;
|
||||
|
||||
int ih = 0, iv = 0;
|
||||
int ib,ic,iaa;
|
||||
int ib, ic, iaa;
|
||||
|
||||
imgpel **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1] : currSlice->dec_picture->imgY;
|
||||
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
||||
imgpel **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1]
|
||||
: currSlice->dec_picture->imgY;
|
||||
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
||||
imgpel *mpr_line;
|
||||
int max_imgpel_value = p_Vid->max_pel_value_comp[pl];
|
||||
|
||||
PixelPos b; //!< pixel position p(0,-1)
|
||||
PixelPos left[17]; //!< pixel positions p(-1, -1..15)
|
||||
PixelPos b; //!< pixel position p(0,-1)
|
||||
PixelPos left[17]; //!< pixel positions p(-1, -1..15)
|
||||
|
||||
int up_avail, left_avail, left_up_avail;
|
||||
|
||||
for (i=0;i<17; ++i)
|
||||
{
|
||||
p_Vid->getNeighbour(currMB, -1, i-1, p_Vid->mb_size[IS_LUMA], &left[i]);
|
||||
for (i = 0; i < 17; ++i) {
|
||||
p_Vid->getNeighbour(currMB, -1, i - 1, p_Vid->mb_size[IS_LUMA], &left[i]);
|
||||
}
|
||||
p_Vid->getNeighbour(currMB, 0, -1, p_Vid->mb_size[IS_LUMA], &b);
|
||||
p_Vid->getNeighbour(currMB, 0, -1, p_Vid->mb_size[IS_LUMA], &b);
|
||||
|
||||
if (!p_Vid->active_pps->constrained_intra_pred_flag)
|
||||
{
|
||||
up_avail = b.available;
|
||||
left_avail = left[1].available;
|
||||
if (!p_Vid->active_pps->constrained_intra_pred_flag) {
|
||||
up_avail = b.available;
|
||||
left_avail = left[1].available;
|
||||
left_up_avail = left[0].available;
|
||||
}
|
||||
else
|
||||
{
|
||||
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
||||
} else {
|
||||
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
||||
for (i = 1, left_avail = 1; i < 17; ++i)
|
||||
left_avail &= left[i].available ? currSlice->intra_block[left[i].mb_addr]: 0;
|
||||
left_up_avail = left[0].available ? currSlice->intra_block[left[0].mb_addr]: 0;
|
||||
left_avail &=
|
||||
left[i].available ? currSlice->intra_block[left[i].mb_addr] : 0;
|
||||
left_up_avail =
|
||||
left[0].available ? currSlice->intra_block[left[0].mb_addr] : 0;
|
||||
}
|
||||
|
||||
if (!up_avail || !left_up_avail || !left_avail)
|
||||
error ("invalid 16x16 intra pred Mode PLANE_16",500);
|
||||
if (!up_avail || !left_up_avail || !left_avail)
|
||||
error("invalid 16x16 intra pred Mode PLANE_16", 500);
|
||||
|
||||
mpr_line = &imgY[b.pos_y][b.pos_x+7];
|
||||
for (i = 1; i < 8; ++i)
|
||||
{
|
||||
ih += i*(mpr_line[i] - mpr_line[-i]);
|
||||
iv += i*(imgY[left[8+i].pos_y][left[8+i].pos_x] - imgY[left[8-i].pos_y][left[8-i].pos_x]);
|
||||
mpr_line = &imgY[b.pos_y][b.pos_x + 7];
|
||||
for (i = 1; i < 8; ++i) {
|
||||
ih += i * (mpr_line[i] - mpr_line[-i]);
|
||||
iv += i * (imgY[left[8 + i].pos_y][left[8 + i].pos_x] -
|
||||
imgY[left[8 - i].pos_y][left[8 - i].pos_x]);
|
||||
}
|
||||
|
||||
ih += 8*(mpr_line[8] - imgY[left[0].pos_y][left[0].pos_x]);
|
||||
iv += 8*(imgY[left[16].pos_y][left[16].pos_x] - imgY[left[0].pos_y][left[0].pos_x]);
|
||||
ih += 8 * (mpr_line[8] - imgY[left[0].pos_y][left[0].pos_x]);
|
||||
iv += 8 * (imgY[left[16].pos_y][left[16].pos_x] -
|
||||
imgY[left[0].pos_y][left[0].pos_x]);
|
||||
|
||||
ib=(5 * ih + 32)>>6;
|
||||
ic=(5 * iv + 32)>>6;
|
||||
ib = (5 * ih + 32) >> 6;
|
||||
ic = (5 * iv + 32) >> 6;
|
||||
|
||||
iaa=16 * (mpr_line[8] + imgY[left[16].pos_y][left[16].pos_x]);
|
||||
for (j = 0;j < MB_BLOCK_SIZE; ++j)
|
||||
{
|
||||
for (i = 0;i < MB_BLOCK_SIZE; ++i)
|
||||
{
|
||||
mb_pred[j][i] = (imgpel) iClip1(max_imgpel_value, ((iaa + (i - 7) * ib + (j - 7) * ic + 16) >> 5));
|
||||
iaa = 16 * (mpr_line[8] + imgY[left[16].pos_y][left[16].pos_x]);
|
||||
for (j = 0; j < MB_BLOCK_SIZE; ++j) {
|
||||
for (i = 0; i < MB_BLOCK_SIZE; ++i) {
|
||||
mb_pred[j][i] = (imgpel)iClip1(
|
||||
max_imgpel_value, ((iaa + (i - 7) * ib + (j - 7) * ic + 16) >> 5));
|
||||
}
|
||||
}// store plane prediction
|
||||
} // store plane prediction
|
||||
|
||||
return DECODING_OK;
|
||||
}
|
||||
|
@ -290,36 +274,33 @@ static int intra16x16_plane_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
|||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
* makes and returns 16x16 intra prediction blocks
|
||||
* makes and returns 16x16 intra prediction blocks
|
||||
*
|
||||
* \return
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
* DECODING_OK decoding of intraprediction mode was successful \n
|
||||
* SEARCH_SYNC search next sync element as errors while decoding occured
|
||||
***********************************************************************
|
||||
*/
|
||||
int intrapred_16x16_mbaff(Macroblock *currMB, //!< Current Macroblock
|
||||
ColorPlane pl, //!< Current colorplane (for 4:4:4)
|
||||
int predmode) //!< prediction mode
|
||||
int intrapred_16x16_mbaff(Macroblock *currMB, //!< Current Macroblock
|
||||
ColorPlane pl, //!< Current colorplane (for 4:4:4)
|
||||
int predmode) //!< prediction mode
|
||||
{
|
||||
switch (predmode)
|
||||
{
|
||||
case VERT_PRED_16: // vertical prediction from block above
|
||||
switch (predmode) {
|
||||
case VERT_PRED_16: // vertical prediction from block above
|
||||
return (intra16x16_vert_pred_mbaff(currMB, pl));
|
||||
break;
|
||||
case HOR_PRED_16: // horizontal prediction from left block
|
||||
case HOR_PRED_16: // horizontal prediction from left block
|
||||
return (intra16x16_hor_pred_mbaff(currMB, pl));
|
||||
break;
|
||||
case DC_PRED_16: // DC prediction
|
||||
case DC_PRED_16: // DC prediction
|
||||
return (intra16x16_dc_pred_mbaff(currMB, pl));
|
||||
break;
|
||||
case PLANE_16:// 16 bit integer plan pred
|
||||
case PLANE_16: // 16 bit integer plan pred
|
||||
return (intra16x16_plane_pred_mbaff(currMB, pl));
|
||||
break;
|
||||
default:
|
||||
{ // indication of fault in bitstream,exit
|
||||
printf("illegal 16x16 intra prediction mode input: %d\n",predmode);
|
||||
return SEARCH_SYNC;
|
||||
}
|
||||
}
|
||||
default: { // indication of fault in bitstream,exit
|
||||
printf("illegal 16x16 intra prediction mode input: %d\n", predmode);
|
||||
return SEARCH_SYNC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue