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/
|
build/
|
||||||
!.gitignore
|
!.gitignore
|
||||||
.vscode
|
.vscode
|
||||||
!mersenne-riscv32e.bin
|
abstract-machine/
|
||||||
|
|
62
Makefile
62
Makefile
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
BENCH_LIBS := bench openlibm soft-fp
|
BENCH_LIBS := bench openlibm soft-fp
|
||||||
|
|
||||||
$(BENCH_LIBS): %: latest
|
$(BENCH_LIBS): %:
|
||||||
$(MAKE) -s -C ./src/common/$* archive
|
$(MAKE) -s -C ./src/common/$* archive
|
||||||
|
|
||||||
COLOR_RED = \033[1;31m
|
COLOR_RED = \033[1;31m
|
||||||
|
@ -11,38 +11,78 @@ COLOR_NONE = \033[0m
|
||||||
RESULT = .result
|
RESULT = .result
|
||||||
$(shell > $(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)
|
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;\
|
TMP=$*.tmp;\
|
||||||
make -C ./src/$* ARCH=$(ARCH) run 2>&1 | tee -a $$TMP;\
|
$(MAKE) -C ./src/$* ARCH=$(ARCH) run 2>&1 | tee -a $$TMP;\
|
||||||
if [ $${PIPESTATUS[0]} -eq 0 ]; then \
|
if [ $${PIPESTATUS[0]} -eq 0 ]; then \
|
||||||
printf "[%14s] $(COLOR_GREEN)PASS$(COLOR_NONE) " $* >> $(RESULT); \
|
printf "[%14s] $(COLOR_GREEN)PASS$(COLOR_NONE) " $* >> $(RESULT); \
|
||||||
cat $$TMP | grep -E -i -e "time: ([0-9]*\.)?[0-9]* ms" >> $(RESULT); \
|
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; \
|
rm $$TMP; \
|
||||||
|
fi \
|
||||||
else \
|
else \
|
||||||
printf "[%14s] $(COLOR_RED)***FAIL***$(COLOR_NONE)\n" $* >> $(RESULT); \
|
printf "[%14s] $(COLOR_RED)***FAIL***$(COLOR_NONE)\n" $* >> $(RESULT); \
|
||||||
|
if $(KEEP_LOG_FAILED); then \
|
||||||
|
mkdir -p "logs/$(TIME)/"; \
|
||||||
|
mv $$TMP "logs/$(TIME)/"; \
|
||||||
|
else \
|
||||||
rm $$TMP; \
|
rm $$TMP; \
|
||||||
fi \
|
fi \
|
||||||
|
fi \
|
||||||
}
|
}
|
||||||
|
|
||||||
run: $(BENCH_LIBS) all
|
run: $(BENCH_LIBS) all
|
||||||
@cat $(RESULT)
|
@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)
|
@rm $(RESULT)
|
||||||
|
|
||||||
|
|
||||||
CLEAN_ALL = $(dir $(shell find . -mindepth 2 -name Makefile))
|
CLEAN_ALL = $(dir $(shell find . -mindepth 2 -name Makefile))
|
||||||
clean-all: $(CLEAN_ALL)
|
clean-all: $(CLEAN_ALL)
|
||||||
|
|
||||||
$(CLEAN_ALL):
|
$(CLEAN_ALL):
|
||||||
-@$(MAKE) -s -C $@ clean
|
-@$(MAKE) -s -C $@ clean
|
||||||
|
|
||||||
.PHONY: $(BENCH_LIBS) $(CLEAN_ALL) $(ALL) all run clean-all latest
|
.PHONY: $(BENCH_LIBS) $(CLEAN_ALL) $(ALL) all run clean-all
|
||||||
|
|
||||||
latest:
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,42 @@
|
||||||
#include <am.h>
|
#include <am.h>
|
||||||
#include <klib.h>
|
#include <bench_debug.h>
|
||||||
#include <klib-macros.h>
|
#include <klib-macros.h>
|
||||||
|
#include <klib.h>
|
||||||
|
|
||||||
uint64_t uptime()
|
uint64_t uptime() { return (io_read(AM_TIMER_UPTIME).us); }
|
||||||
{
|
|
||||||
return (io_read(AM_TIMER_UPTIME).us);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *format_time(uint64_t 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];
|
static char buf[32];
|
||||||
uint64_t ms = us / 1000;
|
uint64_t ms = us / 1000;
|
||||||
us -= ms * 1000;
|
us -= ms * 1000;
|
||||||
|
@ -19,7 +48,7 @@ char *format_time(uint64_t us) {
|
||||||
us /= 10;
|
us /= 10;
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
} */
|
||||||
|
|
||||||
// FNV hash
|
// FNV hash
|
||||||
uint32_t checksum(void *start, void *end) {
|
uint32_t checksum(void *start, void *end) {
|
||||||
|
|
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 <bench_malloc.h>
|
||||||
#include <klib.h>
|
#include <klib.h>
|
||||||
#include <am.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
static intptr_t program_break = 0;
|
static intptr_t program_break = 0;
|
||||||
|
@ -50,15 +50,14 @@ static void *malloc_base() {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
//We need this function because we use variable `heap`
|
// We need this function because the variable `heap` is used
|
||||||
//and it is initialized in run time.
|
// and initialized at runtime.
|
||||||
void bench_malloc_init() {
|
void bench_malloc_init() { program_break = (intptr_t)heap.start; }
|
||||||
program_break = (intptr_t)heap.start;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Chunk malloc_chunk_find(size_t s, Chunk *heap) {
|
static Chunk malloc_chunk_find(size_t s, Chunk *heap) {
|
||||||
Chunk c = malloc_base();
|
Chunk c = malloc_base();
|
||||||
for (; c && (!c->free || c->size < s); *heap = c, c = c->next);
|
for (; c && (!c->free || c->size < s); *heap = c, c = c->next)
|
||||||
|
;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +84,8 @@ static void malloc_split_next(Chunk c, size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void *bench_malloc(size_t size) {
|
void *bench_malloc(size_t size) {
|
||||||
if (!size) return NULL;
|
if (!size)
|
||||||
|
return NULL;
|
||||||
size_t length = word_align(size + sizeof(struct chunk));
|
size_t length = word_align(size + sizeof(struct chunk));
|
||||||
Chunk prev = NULL;
|
Chunk prev = NULL;
|
||||||
Chunk c = malloc_chunk_find(size, &prev);
|
Chunk c = malloc_chunk_find(size, &prev);
|
||||||
|
@ -108,9 +108,11 @@ void *bench_malloc(size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void bench_free(void *ptr) {
|
void bench_free(void *ptr) {
|
||||||
if (!ptr || ptr < malloc_base() || ptr > sbrk(0)) return;
|
if (!ptr || ptr < malloc_base() || ptr > sbrk(0))
|
||||||
|
return;
|
||||||
Chunk c = (Chunk)ptr - 1;
|
Chunk c = (Chunk)ptr - 1;
|
||||||
if (c->data != ptr) return;
|
if (c->data != ptr)
|
||||||
|
return;
|
||||||
c->free = 1;
|
c->free = 1;
|
||||||
|
|
||||||
if (c->next && c->next->free) {
|
if (c->next && c->next->free) {
|
||||||
|
@ -130,7 +132,8 @@ void *bench_calloc(size_t nmemb, size_t size) {
|
||||||
void *ptr = bench_malloc(length);
|
void *ptr = bench_malloc(length);
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
char *dst = ptr;
|
char *dst = ptr;
|
||||||
for (size_t i = 0; i < length; *dst = 0, ++dst, ++i);
|
for (size_t i = 0; i < length; *dst = 0, ++dst, ++i)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
@ -142,18 +145,12 @@ void *bench_realloc(void *ptr, size_t size) {
|
||||||
if (c->data == ptr) {
|
if (c->data == ptr) {
|
||||||
size_t length = c->size > size ? size : c->size;
|
size_t length = c->size > size ? size : c->size;
|
||||||
char *dst = newptr, *src = ptr;
|
char *dst = newptr, *src = ptr;
|
||||||
for (size_t i = 0; i < length; *dst = *src, ++src, ++dst, ++i);
|
for (size_t i = 0; i < length; *dst = *src, ++src, ++dst, ++i)
|
||||||
|
;
|
||||||
bench_free(ptr);
|
bench_free(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newptr;
|
return newptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bench_all_free() {
|
void bench_all_free() { program_break = (intptr_t)heap.start; }
|
||||||
program_break = (intptr_t)heap.start;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,31 @@
|
||||||
#include <klib.h>
|
|
||||||
#include <bench_malloc.h>
|
#include <bench_malloc.h>
|
||||||
|
#include <klib.h>
|
||||||
|
|
||||||
#define __tolower(c) ((('A' <= (c)) && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c))
|
#define __tolower(c) ((('A' <= (c)) && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c))
|
||||||
int strcasecmp(const char *s1, const char *s2)
|
int strcasecmp(const char *s1, const char *s2) {
|
||||||
{
|
|
||||||
if (s1 == NULL || s2 == NULL)
|
if (s1 == NULL || s2 == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while((*s1 != '\0') && (__tolower(*s1) == __tolower(*s2)))
|
while ((*s1 != '\0') && (__tolower(*s1) == __tolower(*s2))) {
|
||||||
{
|
s1++;
|
||||||
s1++; s2++;
|
s2++;
|
||||||
}
|
}
|
||||||
return (*s1 - *s2);
|
return (*s1 - *s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int strncasecmp(const char *s1, const char *s2, size_t n)
|
int strncasecmp(const char *s1, const char *s2, size_t n) {
|
||||||
{
|
|
||||||
if (s1 == NULL || s2 == NULL)
|
if (s1 == NULL || s2 == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while((*s1 != '\0') && (__tolower(*s1) == __tolower(*s2)) && (n > 1))
|
while ((*s1 != '\0') && (__tolower(*s1) == __tolower(*s2)) && (n > 1)) {
|
||||||
{
|
s1++;
|
||||||
s1++; s2++;
|
s2++;
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
return (*s1 - *s2);
|
return (*s1 - *s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* strdup(const char* str)
|
char *strdup(const char *str) {
|
||||||
{
|
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -39,31 +35,26 @@ char* strdup(const char* str)
|
||||||
len++;
|
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);
|
return ret - (len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t strspn(const char *str, const char *group)
|
size_t strspn(const char *str, const char *group) {
|
||||||
{
|
|
||||||
const char *p = NULL;
|
const char *p = NULL;
|
||||||
const char *a = NULL;
|
const char *a = NULL;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
for (p = str; *p != '\0'; ++p)
|
for (p = str; *p != '\0'; ++p) {
|
||||||
{
|
for (a = group; *a != '\0'; ++a) {
|
||||||
for (a = group; *a != '\0'; ++a)
|
if (*p == *a) {
|
||||||
{
|
|
||||||
if (*p == *a)
|
|
||||||
{
|
|
||||||
++count;
|
++count;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*a == '\0')
|
if (*a == '\0') {
|
||||||
{
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +68,8 @@ size_t strcspn ( const char * str1, const char * str2 ) {
|
||||||
while (*p1 != '\0') {
|
while (*p1 != '\0') {
|
||||||
p2 = (char *)str2;
|
p2 = (char *)str2;
|
||||||
while (*p2 != '\0') {
|
while (*p2 != '\0') {
|
||||||
if (*p2 == *p1) return p1-str1;
|
if (*p2 == *p1)
|
||||||
|
return p1 - str1;
|
||||||
++p2;
|
++p2;
|
||||||
}
|
}
|
||||||
++p1;
|
++p1;
|
||||||
|
@ -85,8 +77,7 @@ size_t strcspn ( const char * str1, const char * str2 ) {
|
||||||
return p1 - str1;
|
return p1 - str1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long strtoul(const char *pstart, char **pend, int base)
|
unsigned long strtoul(const char *pstart, char **pend, int base) {
|
||||||
{
|
|
||||||
const char *s = pstart;
|
const char *s = pstart;
|
||||||
unsigned long result = 0;
|
unsigned long result = 0;
|
||||||
char c;
|
char c;
|
||||||
|
@ -99,10 +90,8 @@ unsigned long strtoul(const char *pstart, char **pend, int base)
|
||||||
if (c == '-' || c == '+') {
|
if (c == '-' || c == '+') {
|
||||||
c = *s++;
|
c = *s++;
|
||||||
}
|
}
|
||||||
if ((base == 0 || base == 16) &&
|
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X') &&
|
||||||
c == '0' && (*s == 'x' || *s == 'X') &&
|
((s[1] >= '0' && s[1] <= '9') || (s[1] >= 'A' && s[1] <= 'F') ||
|
||||||
((s[1] >= '0' && s[1] <= '9') ||
|
|
||||||
(s[1] >= 'A' && s[1] <= 'F') ||
|
|
||||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||||
c = s[1];
|
c = s[1];
|
||||||
s += 2;
|
s += 2;
|
||||||
|
@ -130,8 +119,7 @@ unsigned long strtoul(const char *pstart, char **pend, int base)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long strtoull(const char *pstart, char **pend, int base)
|
unsigned long long strtoull(const char *pstart, char **pend, int base) {
|
||||||
{
|
|
||||||
const char *s = pstart;
|
const char *s = pstart;
|
||||||
unsigned long long result = 0;
|
unsigned long long result = 0;
|
||||||
char c;
|
char c;
|
||||||
|
@ -144,10 +132,8 @@ unsigned long long strtoull(const char *pstart, char **pend, int base)
|
||||||
if (c == '-' || c == '+') {
|
if (c == '-' || c == '+') {
|
||||||
c = *s++;
|
c = *s++;
|
||||||
}
|
}
|
||||||
if ((base == 0 || base == 16) &&
|
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X') &&
|
||||||
c == '0' && (*s == 'x' || *s == 'X') &&
|
((s[1] >= '0' && s[1] <= '9') || (s[1] >= 'A' && s[1] <= 'F') ||
|
||||||
((s[1] >= '0' && s[1] <= '9') ||
|
|
||||||
(s[1] >= 'A' && s[1] <= 'F') ||
|
|
||||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||||
c = s[1];
|
c = s[1];
|
||||||
s += 2;
|
s += 2;
|
||||||
|
@ -175,8 +161,7 @@ unsigned long long strtoull(const char *pstart, char **pend, int base)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
long strtol(const char *pstart, char **pend, int base)
|
long strtol(const char *pstart, char **pend, int base) {
|
||||||
{
|
|
||||||
const char *s = pstart;
|
const char *s = pstart;
|
||||||
long result = 0;
|
long result = 0;
|
||||||
char c;
|
char c;
|
||||||
|
@ -192,10 +177,8 @@ long strtol(const char *pstart, char **pend, int base)
|
||||||
c = *s++;
|
c = *s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((base == 0 || base == 16) &&
|
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X') &&
|
||||||
c == '0' && (*s == 'x' || *s == 'X') &&
|
((s[1] >= '0' && s[1] <= '9') || (s[1] >= 'A' && s[1] <= 'F') ||
|
||||||
((s[1] >= '0' && s[1] <= '9') ||
|
|
||||||
(s[1] >= 'A' && s[1] <= 'F') ||
|
|
||||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||||
c = s[1];
|
c = s[1];
|
||||||
s += 2;
|
s += 2;
|
||||||
|
@ -223,8 +206,7 @@ long strtol(const char *pstart, char **pend, int base)
|
||||||
return sign * result;
|
return sign * result;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long strtoll(const char *pstart, char **pend, int base)
|
long long strtoll(const char *pstart, char **pend, int base) {
|
||||||
{
|
|
||||||
const char *s = pstart;
|
const char *s = pstart;
|
||||||
long long result = 0;
|
long long result = 0;
|
||||||
char c;
|
char c;
|
||||||
|
@ -240,10 +222,8 @@ long long strtoll(const char *pstart, char **pend, int base)
|
||||||
c = *s++;
|
c = *s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((base == 0 || base == 16) &&
|
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X') &&
|
||||||
c == '0' && (*s == 'x' || *s == 'X') &&
|
((s[1] >= '0' && s[1] <= '9') || (s[1] >= 'A' && s[1] <= 'F') ||
|
||||||
((s[1] >= '0' && s[1] <= '9') ||
|
|
||||||
(s[1] >= 'A' && s[1] <= 'F') ||
|
|
||||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||||
c = s[1];
|
c = s[1];
|
||||||
s += 2;
|
s += 2;
|
||||||
|
@ -271,8 +251,7 @@ long long strtoll(const char *pstart, char **pend, int base)
|
||||||
return sign * result;
|
return sign * result;
|
||||||
}
|
}
|
||||||
|
|
||||||
double strtod(const char *pstart, char **pend)
|
double strtod(const char *pstart, char **pend) {
|
||||||
{
|
|
||||||
const char *s = pstart;
|
const char *s = pstart;
|
||||||
double result = 0;
|
double result = 0;
|
||||||
char c;
|
char c;
|
||||||
|
@ -315,8 +294,7 @@ double strtod(const char *pstart, char **pend)
|
||||||
return (sign * result);
|
return (sign * result);
|
||||||
}
|
}
|
||||||
|
|
||||||
long double strtold(const char *pstart, char **pend)
|
long double strtold(const char *pstart, char **pend) {
|
||||||
{
|
|
||||||
const char *s = pstart;
|
const char *s = pstart;
|
||||||
long double result = 0;
|
long double result = 0;
|
||||||
char c;
|
char c;
|
||||||
|
@ -359,8 +337,7 @@ long double strtold(const char *pstart, char **pend)
|
||||||
return (sign * result);
|
return (sign * result);
|
||||||
}
|
}
|
||||||
|
|
||||||
float strtof(const char *pstart, char **pend)
|
float strtof(const char *pstart, char **pend) {
|
||||||
{
|
|
||||||
const char *s = pstart;
|
const char *s = pstart;
|
||||||
float result = 0;
|
float result = 0;
|
||||||
char c;
|
char c;
|
||||||
|
@ -403,54 +380,39 @@ float strtof(const char *pstart, char **pend)
|
||||||
return (sign * result);
|
return (sign * result);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strchr(const char *s, const char ch)
|
char *strchr(const char *s, const char ch) {
|
||||||
{
|
|
||||||
if (NULL == s)
|
if (NULL == s)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const char *pSrc = s;
|
const char *pSrc = s;
|
||||||
while ('\0' != *pSrc)
|
while ('\0' != *pSrc) {
|
||||||
{
|
if (*pSrc == ch) {
|
||||||
if (*pSrc == ch)
|
|
||||||
{
|
|
||||||
return (char *)pSrc;
|
return (char *)pSrc;
|
||||||
}
|
}
|
||||||
pSrc++;
|
pSrc++;
|
||||||
}
|
}
|
||||||
if(ch == 0)
|
if (ch == 0) {
|
||||||
{
|
|
||||||
return (char *)pSrc;
|
return (char *)pSrc;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strrchr(const char *s, const char ch)
|
char *strrchr(const char *s, const char ch) {
|
||||||
{
|
if (s == NULL) {
|
||||||
if(s == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *p_char = NULL;
|
char *p_char = NULL;
|
||||||
while(*s != '\0')
|
while (*s != '\0') {
|
||||||
{
|
if (*s == ch) {
|
||||||
if(*s == ch)
|
|
||||||
{
|
|
||||||
p_char = (char *)s;
|
p_char = (char *)s;
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
if(ch == 0)
|
if (ch == 0) {
|
||||||
{
|
|
||||||
p_char = (char *)s;
|
p_char = (char *)s;
|
||||||
}
|
}
|
||||||
return p_char;
|
return p_char;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* strstr(const char* dest, const char* src)
|
char *strstr(const char *dest, const char *src) { assert(0); }
|
||||||
{
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __BENCH_COMMON
|
#ifndef __BENCH_COMMON
|
||||||
#define __BENCH_COMMON
|
#define __BENCH_COMMON
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
uint64_t uptime();
|
uint64_t uptime();
|
||||||
char *format_time(uint64_t us);
|
char *format_time(uint64_t us);
|
||||||
|
|
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
|
|
@ -12,4 +12,3 @@ void bench_free (void *ptr);
|
||||||
void bench_all_free(void);
|
void bench_all_free(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ char* strdup (const char* str);
|
||||||
size_t strspn(const char *str, const char *group);
|
size_t strspn(const char *str, const char *group);
|
||||||
size_t strcspn(const char *str1, const char *str2);
|
size_t strcspn(const char *str1, const char *str2);
|
||||||
|
|
||||||
|
|
||||||
unsigned long strtoul(const char *pstart, char **pend, int base);
|
unsigned long strtoul(const char *pstart, char **pend, int base);
|
||||||
unsigned long long strtoull(const char *pstart, char **pend, int base);
|
unsigned long long strtoull(const char *pstart, char **pend, int base);
|
||||||
long strtol(const char *pstart, char **pend, int base);
|
long strtol(const char *pstart, char **pend, int base);
|
||||||
|
@ -21,6 +20,4 @@ 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);
|
char *strrchr(const char *s, const char ch);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -7,34 +7,30 @@
|
||||||
* Annex B Byte Stream format
|
* Annex B Byte Stream format
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "annexb.h"
|
#include "annexb.h"
|
||||||
#include "memalloc.h"
|
|
||||||
#include "fast_memory.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)
|
void malloc_annex_b(VideoParameters *p_Vid) {
|
||||||
{
|
if ((p_Vid->annex_b = (ANNEXB_t *)calloc(1, sizeof(ANNEXB_t))) == NULL) {
|
||||||
if ( (p_Vid->annex_b = (ANNEXB_t *) calloc(1, sizeof(ANNEXB_t))) == NULL)
|
|
||||||
{
|
|
||||||
snprintf(errortext, ET_SIZE, "Memory allocation for Annex_B file failed");
|
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);
|
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->BitStreamFile = -1;
|
||||||
annex_b->iobuffer = NULL;
|
annex_b->iobuffer = NULL;
|
||||||
annex_b->iobufferread = NULL;
|
annex_b->iobufferread = NULL;
|
||||||
|
@ -44,8 +40,7 @@ void init_annex_b(ANNEXB_t *annex_b)
|
||||||
annex_b->nextstartcodebytes = 0;
|
annex_b->nextstartcodebytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_annex_b(VideoParameters *p_Vid)
|
void free_annex_b(VideoParameters *p_Vid) {
|
||||||
{
|
|
||||||
free(p_Vid->annex_b->Buf);
|
free(p_Vid->annex_b->Buf);
|
||||||
p_Vid->annex_b->Buf = NULL;
|
p_Vid->annex_b->Buf = NULL;
|
||||||
free(p_Vid->annex_b);
|
free(p_Vid->annex_b);
|
||||||
|
@ -58,11 +53,10 @@ void free_annex_b(VideoParameters *p_Vid)
|
||||||
* fill IO buffer
|
* fill IO buffer
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static inline int getChunk(ANNEXB_t *annex_b)
|
static inline int getChunk(ANNEXB_t *annex_b) {
|
||||||
{
|
unsigned int readbytes =
|
||||||
unsigned int readbytes = read (annex_b->BitStreamFile, annex_b->iobuffer, annex_b->iIOBufferSize);
|
read(annex_b->BitStreamFile, annex_b->iobuffer, annex_b->iIOBufferSize);
|
||||||
if (0==readbytes)
|
if (0 == readbytes) {
|
||||||
{
|
|
||||||
annex_b->is_eof = TRUE;
|
annex_b->is_eof = TRUE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -78,10 +72,8 @@ static inline int getChunk(ANNEXB_t *annex_b)
|
||||||
* returns a byte from IO buffer
|
* returns a byte from IO buffer
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static inline byte getfbyte(ANNEXB_t *annex_b)
|
static inline byte getfbyte(ANNEXB_t *annex_b) {
|
||||||
{
|
if (0 == annex_b->bytesinbuffer) {
|
||||||
if (0 == annex_b->bytesinbuffer)
|
|
||||||
{
|
|
||||||
if (0 == getChunk(annex_b))
|
if (0 == getChunk(annex_b))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -105,14 +97,11 @@ static inline byte getfbyte(ANNEXB_t *annex_b)
|
||||||
* indicates number of 0x00 bytes in start-code.
|
* 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;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < zeros_in_startcode; i++)
|
for (i = 0; i < zeros_in_startcode; i++) {
|
||||||
{
|
if (*(Buf++) != 0) {
|
||||||
if(*(Buf++) != 0)
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +112,6 @@ static inline int FindStartCode (unsigned char *Buf, int zeros_in_startcode)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \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;
|
ANNEXB_t *annex_b = p_Vid->annex_b;
|
||||||
int i;
|
int i;
|
||||||
int info2 = 0, info3 = 0, pos = 0;
|
int info2 = 0, info3 = 0, pos = 0;
|
||||||
|
@ -152,70 +139,56 @@ int GetAnnexbNALU (VideoParameters *p_Vid, NALU_t *nalu)
|
||||||
int LeadingZero8BitsCount = 0;
|
int LeadingZero8BitsCount = 0;
|
||||||
byte *pBuf = annex_b->Buf;
|
byte *pBuf = annex_b->Buf;
|
||||||
|
|
||||||
if (annex_b->nextstartcodebytes != 0)
|
if (annex_b->nextstartcodebytes != 0) {
|
||||||
{
|
for (i = 0; i < annex_b->nextstartcodebytes - 1; i++) {
|
||||||
for (i=0; i<annex_b->nextstartcodebytes-1; i++)
|
|
||||||
{
|
|
||||||
(*pBuf++) = 0;
|
(*pBuf++) = 0;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
(*pBuf++) = 1;
|
(*pBuf++) = 1;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
} else {
|
||||||
else
|
while (!annex_b->is_eof) {
|
||||||
{
|
|
||||||
while(!annex_b->is_eof)
|
|
||||||
{
|
|
||||||
pos++;
|
pos++;
|
||||||
if ((*(pBuf++) = getfbyte(annex_b)) != 0)
|
if ((*(pBuf++) = getfbyte(annex_b)) != 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(annex_b->is_eof == TRUE)
|
if (annex_b->is_eof == TRUE) {
|
||||||
{
|
if (pos == 0) {
|
||||||
if(pos==0)
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("GetAnnexbNALU can't read start code\n");
|
printf("GetAnnexbNALU can't read start code\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*(pBuf - 1) != 1 || pos < 3)
|
if (*(pBuf - 1) != 1 || pos < 3) {
|
||||||
{
|
printf("GetAnnexbNALU: no Start Code at the beginning of the NALU, return "
|
||||||
printf ("GetAnnexbNALU: no Start Code at the beginning of the NALU, return -1\n");
|
"-1\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos == 3)
|
if (pos == 3) {
|
||||||
{
|
|
||||||
nalu->startcodeprefix_len = 3;
|
nalu->startcodeprefix_len = 3;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
LeadingZero8BitsCount = pos - 4;
|
LeadingZero8BitsCount = pos - 4;
|
||||||
nalu->startcodeprefix_len = 4;
|
nalu->startcodeprefix_len = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
//the 1st byte stream NAL unit can has leading_zero_8bits, but subsequent ones are not
|
// the 1st byte stream NAL unit can has leading_zero_8bits, but subsequent
|
||||||
//allowed to contain it since these zeros(if any) are considered trailing_zero_8bits
|
// ones are not allowed to contain it since these zeros(if any) are considered
|
||||||
//of the previous byte stream NAL unit.
|
// trailing_zero_8bits of the previous byte stream NAL unit.
|
||||||
if(!annex_b->IsFirstByteStreamNALU && LeadingZero8BitsCount > 0)
|
if (!annex_b->IsFirstByteStreamNALU && LeadingZero8BitsCount > 0) {
|
||||||
{
|
printf("GetAnnexbNALU: The leading_zero_8bits syntax can only be present "
|
||||||
printf ("GetAnnexbNALU: The leading_zero_8bits syntax can only be present in the first byte stream NAL unit, return -1\n");
|
"in the first byte stream NAL unit, return -1\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LeadingZero8BitsCount = pos;
|
LeadingZero8BitsCount = pos;
|
||||||
annex_b->IsFirstByteStreamNALU = 0;
|
annex_b->IsFirstByteStreamNALU = 0;
|
||||||
|
|
||||||
while (!StartCodeFound)
|
while (!StartCodeFound) {
|
||||||
{
|
if (annex_b->is_eof == TRUE) {
|
||||||
if (annex_b->is_eof == TRUE)
|
|
||||||
{
|
|
||||||
pBuf -= 2;
|
pBuf -= 2;
|
||||||
while (*(pBuf--) == 0)
|
while (*(pBuf--) == 0)
|
||||||
pos--;
|
pos--;
|
||||||
|
@ -227,12 +200,18 @@ int GetAnnexbNALU (VideoParameters *p_Vid, NALU_t *nalu)
|
||||||
nalu->nal_unit_type = (NaluType)((*(nalu->buf)) & 0x1f);
|
nalu->nal_unit_type = (NaluType)((*(nalu->buf)) & 0x1f);
|
||||||
annex_b->nextstartcodebytes = 0;
|
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
|
#if TRACE
|
||||||
fprintf(p_Dec->p_trace, "\n\nLast NALU in File\n\n");
|
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",
|
fprintf(p_Dec->p_trace,
|
||||||
nalu->startcodeprefix_len == 4?"long":"short", nalu->len, nalu->forbidden_bit, nalu->nal_reference_idc, nalu->nal_unit_type);
|
"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);
|
fflush(p_Dec->p_trace);
|
||||||
#endif
|
#endif
|
||||||
return (pos - 1);
|
return (pos - 1);
|
||||||
|
@ -241,39 +220,35 @@ int GetAnnexbNALU (VideoParameters *p_Vid, NALU_t *nalu)
|
||||||
pos++;
|
pos++;
|
||||||
*(pBuf++) = getfbyte(annex_b);
|
*(pBuf++) = getfbyte(annex_b);
|
||||||
info3 = FindStartCode(pBuf - 4, 3);
|
info3 = FindStartCode(pBuf - 4, 3);
|
||||||
if(info3 != 1)
|
if (info3 != 1) {
|
||||||
{
|
|
||||||
info2 = FindStartCode(pBuf - 3, 2);
|
info2 = FindStartCode(pBuf - 3, 2);
|
||||||
StartCodeFound = info2 & 0x01;
|
StartCodeFound = info2 & 0x01;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
StartCodeFound = 1;
|
StartCodeFound = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here, we have found another start code (and read length of startcode bytes more than we should
|
// Here, we have found another start code (and read length of startcode bytes
|
||||||
// have. Hence, go back in the file
|
// 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
|
if (info3 == 1) // if the detected start code is 00 00 01, trailing_zero_8bits
|
||||||
|
// is sure not to be present
|
||||||
{
|
{
|
||||||
pBuf -= 5;
|
pBuf -= 5;
|
||||||
while (*(pBuf--) == 0)
|
while (*(pBuf--) == 0)
|
||||||
pos--;
|
pos--;
|
||||||
annex_b->nextstartcodebytes = 4;
|
annex_b->nextstartcodebytes = 4;
|
||||||
}
|
} else if (info2 == 1)
|
||||||
else if (info2 == 1)
|
|
||||||
annex_b->nextstartcodebytes = 3;
|
annex_b->nextstartcodebytes = 3;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
printf(" Panic: Error in next start code search \n");
|
printf(" Panic: Error in next start code search \n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos -= annex_b->nextstartcodebytes;
|
pos -= annex_b->nextstartcodebytes;
|
||||||
|
|
||||||
// Here the leading zeros(if any), Start code, the complete NALU, trailing zeros(if any)
|
// Here the leading zeros(if any), Start code, the complete NALU, trailing
|
||||||
// and the next start code is in the Buf.
|
// zeros(if any) and the next start code is in the Buf. The size of Buf is pos
|
||||||
// The size of Buf is pos - rewind, pos are the number of bytes excluding the next
|
// - rewind, pos are the number of bytes excluding the next start code, and
|
||||||
// start code, and (pos) - LeadingZero8BitsCount
|
// (pos) - LeadingZero8BitsCount is the size of the NALU.
|
||||||
// is the size of the NALU.
|
|
||||||
|
|
||||||
nalu->len = pos - LeadingZero8BitsCount;
|
nalu->len = pos - LeadingZero8BitsCount;
|
||||||
fast_memcpy(nalu->buf, annex_b->Buf + LeadingZero8BitsCount, nalu->len);
|
fast_memcpy(nalu->buf, annex_b->Buf + LeadingZero8BitsCount, nalu->len);
|
||||||
|
@ -282,20 +257,21 @@ int GetAnnexbNALU (VideoParameters *p_Vid, NALU_t *nalu)
|
||||||
nalu->nal_unit_type = (NaluType)((*(nalu->buf)) & 0x1f);
|
nalu->nal_unit_type = (NaluType)((*(nalu->buf)) & 0x1f);
|
||||||
nalu->lost_packets = 0;
|
nalu->lost_packets = 0;
|
||||||
|
|
||||||
|
// printf ("GetAnnexbNALU, regular case: pos %d nalu->len %d,
|
||||||
//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);
|
// nalu->reference_idc %d, nal_unit_type %d \n", pos, nalu->len,
|
||||||
|
// nalu->nal_reference_idc, nalu->nal_unit_type);
|
||||||
#if TRACE
|
#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",
|
fprintf(p_Dec->p_trace,
|
||||||
nalu->startcodeprefix_len == 4?"long":"short", nalu->len, nalu->forbidden_bit, nalu->nal_reference_idc, nalu->nal_unit_type);
|
"\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);
|
fflush(p_Dec->p_trace);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return (pos);
|
return (pos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -304,41 +280,35 @@ int GetAnnexbNALU (VideoParameters *p_Vid, NALU_t *nalu)
|
||||||
* none
|
* none
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void OpenAnnexBFile (VideoParameters *p_Vid, char *fn)
|
void OpenAnnexBFile(VideoParameters *p_Vid, char *fn) {
|
||||||
{
|
|
||||||
ANNEXB_t *annex_b = p_Vid->annex_b;
|
ANNEXB_t *annex_b = p_Vid->annex_b;
|
||||||
if (NULL != annex_b->iobuffer)
|
if (NULL != annex_b->iobuffer) {
|
||||||
{
|
|
||||||
error("OpenAnnexBFile: tried to open Annex B file twice", 500);
|
error("OpenAnnexBFile: tried to open Annex B file twice", 500);
|
||||||
}
|
}
|
||||||
if ((annex_b->BitStreamFile = open(fn, OPENFLAGS_READ)) == -1)
|
if ((annex_b->BitStreamFile = open(fn, OPENFLAGS_READ)) == -1) {
|
||||||
{
|
snprintf(errortext, ET_SIZE, "Cannot open Annex B ByteStream file '%s'",
|
||||||
snprintf (errortext, ET_SIZE, "Cannot open Annex B ByteStream file '%s'", fn);
|
fn);
|
||||||
error(errortext, 500);
|
error(errortext, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
annex_b->iIOBufferSize = IOBUFFERSIZE * sizeof(byte);
|
annex_b->iIOBufferSize = IOBUFFERSIZE * sizeof(byte);
|
||||||
annex_b->iobuffer = malloc(annex_b->iIOBufferSize);
|
annex_b->iobuffer = malloc(annex_b->iIOBufferSize);
|
||||||
if (NULL == annex_b->iobuffer)
|
if (NULL == annex_b->iobuffer) {
|
||||||
{
|
|
||||||
error("OpenAnnexBFile: cannot allocate IO buffer", 500);
|
error("OpenAnnexBFile: cannot allocate IO buffer", 500);
|
||||||
}
|
}
|
||||||
annex_b->is_eof = FALSE;
|
annex_b->is_eof = FALSE;
|
||||||
getChunk(annex_b);
|
getChunk(annex_b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Closes the bit stream file
|
* Closes the bit stream file
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void CloseAnnexBFile(VideoParameters *p_Vid)
|
void CloseAnnexBFile(VideoParameters *p_Vid) {
|
||||||
{
|
|
||||||
ANNEXB_t *annex_b = p_Vid->annex_b;
|
ANNEXB_t *annex_b = p_Vid->annex_b;
|
||||||
if (annex_b->BitStreamFile != -1)
|
if (annex_b->BitStreamFile != -1) {
|
||||||
{
|
|
||||||
close(annex_b->BitStreamFile);
|
close(annex_b->BitStreamFile);
|
||||||
annex_b->BitStreamFile = -1;
|
annex_b->BitStreamFile = -1;
|
||||||
}
|
}
|
||||||
|
@ -346,9 +316,7 @@ void CloseAnnexBFile(VideoParameters *p_Vid)
|
||||||
annex_b->iobuffer = NULL;
|
annex_b->iobuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResetAnnexB(ANNEXB_t *annex_b) {
|
||||||
void ResetAnnexB(ANNEXB_t *annex_b)
|
|
||||||
{
|
|
||||||
annex_b->is_eof = FALSE;
|
annex_b->is_eof = FALSE;
|
||||||
annex_b->bytesinbuffer = 0;
|
annex_b->bytesinbuffer = 0;
|
||||||
annex_b->iobufferread = annex_b->iobuffer;
|
annex_b->iobufferread = annex_b->iobuffer;
|
||||||
|
|
|
@ -11,17 +11,17 @@
|
||||||
* \date
|
* \date
|
||||||
* 21. Oct 2000
|
* 21. Oct 2000
|
||||||
* \author
|
* \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>
|
* - Detlev Marpe <marpe@hhi.de>
|
||||||
* - Gabi Blaettermann
|
* - Gabi Blaettermann
|
||||||
* - Gunnar Marten
|
* - Gunnar Marten
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "biaridecod.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "memalloc.h"
|
#include "memalloc.h"
|
||||||
#include "biaridecod.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define B_BITS 10 // Number of bits to represent the whole coding interval
|
#define B_BITS 10 // Number of bits to represent the whole coding interval
|
||||||
#define HALF 0x01FE //(1 << (B_BITS-1)) - 2
|
#define HALF 0x01FE //(1 << (B_BITS-1)) - 2
|
||||||
|
@ -35,8 +35,7 @@
|
||||||
* allocates memory
|
* allocates memory
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
DecodingEnvironmentPtr arideco_create_decoding_environment()
|
DecodingEnvironmentPtr arideco_create_decoding_environment() {
|
||||||
{
|
|
||||||
DecodingEnvironmentPtr dep;
|
DecodingEnvironmentPtr dep;
|
||||||
|
|
||||||
if ((dep = calloc(1, sizeof(DecodingEnvironment))) == NULL)
|
if ((dep = calloc(1, sizeof(DecodingEnvironment))) == NULL)
|
||||||
|
@ -44,21 +43,17 @@ DecodingEnvironmentPtr arideco_create_decoding_environment()
|
||||||
return dep;
|
return dep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Frees memory of the DecodingEnvironment struct
|
* Frees memory of the DecodingEnvironment struct
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
void arideco_delete_decoding_environment(DecodingEnvironmentPtr dep)
|
void arideco_delete_decoding_environment(DecodingEnvironmentPtr dep) {
|
||||||
{
|
if (dep == NULL) {
|
||||||
if (dep == NULL)
|
|
||||||
{
|
|
||||||
snprintf(errortext, ET_SIZE, "Error freeing dep (NULL pointer)");
|
snprintf(errortext, ET_SIZE, "Error freeing dep (NULL pointer)");
|
||||||
error(errortext, 200);
|
error(errortext, 200);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
free(dep);
|
free(dep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +63,7 @@ void arideco_delete_decoding_environment(DecodingEnvironmentPtr dep)
|
||||||
* finalize arithetic decoding():
|
* finalize arithetic decoding():
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void arideco_done_decoding(DecodingEnvironmentPtr dep)
|
void arideco_done_decoding(DecodingEnvironmentPtr dep) {
|
||||||
{
|
|
||||||
(*dep->Dcodestrm_len)++;
|
(*dep->Dcodestrm_len)++;
|
||||||
#if (TRACE == 2)
|
#if (TRACE == 2)
|
||||||
fprintf(p_trace, "done_decoding: %d\n", *dep->Dcodestrm_len);
|
fprintf(p_trace, "done_decoding: %d\n", *dep->Dcodestrm_len);
|
||||||
|
@ -82,8 +76,7 @@ void arideco_done_decoding(DecodingEnvironmentPtr dep)
|
||||||
* read one byte from the bitstream
|
* read one byte from the bitstream
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
unsigned int getbyte(DecodingEnvironmentPtr dep)
|
unsigned int getbyte(DecodingEnvironmentPtr dep) {
|
||||||
{
|
|
||||||
#if (TRACE == 2)
|
#if (TRACE == 2)
|
||||||
fprintf(p_trace, "get_byte: %d\n", (*dep->Dcodestrm_len));
|
fprintf(p_trace, "get_byte: %d\n", (*dep->Dcodestrm_len));
|
||||||
#endif
|
#endif
|
||||||
|
@ -96,8 +89,7 @@ unsigned int getbyte(DecodingEnvironmentPtr dep)
|
||||||
* read two bytes from the bitstream
|
* read two bytes from the bitstream
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
unsigned int getword(DecodingEnvironmentPtr dep)
|
unsigned int getword(DecodingEnvironmentPtr dep) {
|
||||||
{
|
|
||||||
int d = *dep->Dcodestrm_len;
|
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);
|
||||||
|
@ -112,34 +104,35 @@ unsigned int getword(DecodingEnvironmentPtr dep)
|
||||||
* Initializes the DecodingEnvironment for the arithmetic coder
|
* Initializes the DecodingEnvironment for the arithmetic coder
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void arideco_start_decoding(DecodingEnvironmentPtr dep, unsigned char *code_buffer,
|
void arideco_start_decoding(DecodingEnvironmentPtr dep,
|
||||||
int firstbyte, int *code_len)
|
unsigned char *code_buffer, int firstbyte,
|
||||||
{
|
int *code_len) {
|
||||||
|
|
||||||
dep->Dcodestrm = code_buffer;
|
dep->Dcodestrm = code_buffer;
|
||||||
dep->Dcodestrm_len = code_len;
|
dep->Dcodestrm_len = code_len;
|
||||||
*dep->Dcodestrm_len = firstbyte;
|
*dep->Dcodestrm_len = firstbyte;
|
||||||
|
|
||||||
dep->Dvalue = getbyte(dep);
|
dep->Dvalue = getbyte(dep);
|
||||||
dep->Dvalue = (dep->Dvalue << 16) | getword(dep); // lookahead of 2 bytes: always make sure that bitstream buffer
|
dep->Dvalue =
|
||||||
// contains 2 more bytes than actual bitstream
|
(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->DbitsLeft = 15;
|
||||||
dep->Drange = HALF;
|
dep->Drange = HALF;
|
||||||
|
|
||||||
#if (2 == TRACE)
|
#if (2 == TRACE)
|
||||||
fprintf(p_trace, "value: %d firstbyte: %d code_len: %d\n", dep->Dvalue >> dep->DbitsLeft, firstbyte, *code_len);
|
fprintf(p_trace, "value: %d firstbyte: %d code_len: %d\n",
|
||||||
|
dep->Dvalue >> dep->DbitsLeft, firstbyte, *code_len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* arideco_bits_read
|
* arideco_bits_read
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
int arideco_bits_read(DecodingEnvironmentPtr dep)
|
int arideco_bits_read(DecodingEnvironmentPtr dep) {
|
||||||
{
|
|
||||||
int tmp = ((*dep->Dcodestrm_len) << 3) - dep->DbitsLeft;
|
int tmp = ((*dep->Dcodestrm_len) << 3) - dep->DbitsLeft;
|
||||||
|
|
||||||
#if (2 == TRACE)
|
#if (2 == TRACE)
|
||||||
|
@ -148,7 +141,6 @@ int arideco_bits_read(DecodingEnvironmentPtr dep)
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -157,8 +149,8 @@ int arideco_bits_read(DecodingEnvironmentPtr dep)
|
||||||
* the decoded symbol
|
* the decoded symbol
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi_ct )
|
unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep,
|
||||||
{
|
BiContextTypePtr bi_ct) {
|
||||||
unsigned int bit = bi_ct->MPS;
|
unsigned int bit = bi_ct->MPS;
|
||||||
unsigned int *value = &dep->Dvalue;
|
unsigned int *value = &dep->Dvalue;
|
||||||
unsigned int *range = &dep->Drange;
|
unsigned int *range = &dep->Drange;
|
||||||
|
@ -172,16 +164,13 @@ unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi
|
||||||
{
|
{
|
||||||
*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);
|
return (bit);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
*range <<= 1;
|
*range <<= 1;
|
||||||
|
|
||||||
(*DbitsLeft)--;
|
(*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);
|
*value -= (*range << dep->DbitsLeft);
|
||||||
|
@ -196,14 +185,12 @@ unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi
|
||||||
*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);
|
return (bit);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
*value <<= 16;
|
*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
|
// contains 2 more bytes than actual bitstream
|
||||||
(*DbitsLeft) += 16;
|
(*DbitsLeft) += 16;
|
||||||
|
|
||||||
|
@ -211,7 +198,6 @@ unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -220,26 +206,23 @@ unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi
|
||||||
* the decoded symbol
|
* the decoded symbol
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
unsigned int biari_decode_symbol_eq_prob(DecodingEnvironmentPtr dep)
|
unsigned int biari_decode_symbol_eq_prob(DecodingEnvironmentPtr dep) {
|
||||||
{
|
|
||||||
int tmp_value;
|
int tmp_value;
|
||||||
unsigned int *value = &dep->Dvalue;
|
unsigned int *value = &dep->Dvalue;
|
||||||
int *DbitsLeft = &dep->DbitsLeft;
|
int *DbitsLeft = &dep->DbitsLeft;
|
||||||
|
|
||||||
if(--(*DbitsLeft) == 0)
|
if (--(*DbitsLeft) == 0) {
|
||||||
{
|
*value =
|
||||||
*value = (*value << 16) | getword( dep ); // lookahead of 2 bytes: always make sure that bitstream buffer
|
(*value << 16) |
|
||||||
// contains 2 more bytes than actual bitstream
|
getword(dep); // lookahead of 2 bytes: always make sure that bitstream
|
||||||
|
// buffer contains 2 more bytes than actual bitstream
|
||||||
*DbitsLeft = 16;
|
*DbitsLeft = 16;
|
||||||
}
|
}
|
||||||
tmp_value = *value - (dep->Drange << *DbitsLeft);
|
tmp_value = *value - (dep->Drange << *DbitsLeft);
|
||||||
|
|
||||||
if (tmp_value < 0)
|
if (tmp_value < 0) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
*value = tmp_value;
|
*value = tmp_value;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -253,35 +236,30 @@ unsigned int biari_decode_symbol_eq_prob(DecodingEnvironmentPtr dep)
|
||||||
* the decoded symbol
|
* the decoded symbol
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
unsigned int biari_decode_final(DecodingEnvironmentPtr dep)
|
unsigned int biari_decode_final(DecodingEnvironmentPtr dep) {
|
||||||
{
|
|
||||||
unsigned int range = dep->Drange - 2;
|
unsigned int range = dep->Drange - 2;
|
||||||
int value = dep->Dvalue;
|
int value = dep->Dvalue;
|
||||||
value -= (range << dep->DbitsLeft);
|
value -= (range << dep->DbitsLeft);
|
||||||
|
|
||||||
if (value < 0)
|
if (value < 0) {
|
||||||
{
|
if (range >= QUARTER) {
|
||||||
if( range >= QUARTER )
|
|
||||||
{
|
|
||||||
dep->Drange = range;
|
dep->Drange = range;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
dep->Drange = (range << 1);
|
dep->Drange = (range << 1);
|
||||||
if (--(dep->DbitsLeft) > 0)
|
if (--(dep->DbitsLeft) > 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else {
|
||||||
{
|
dep->Dvalue =
|
||||||
dep->Dvalue = (dep->Dvalue << 16) | getword( dep ); // lookahead of 2 bytes: always make sure that bitstream buffer
|
(dep->Dvalue << 16) |
|
||||||
// contains 2 more bytes than actual bitstream
|
getword(
|
||||||
|
dep); // lookahead of 2 bytes: always make sure that bitstream
|
||||||
|
// buffer contains 2 more bytes than actual bitstream
|
||||||
dep->DbitsLeft = 16;
|
dep->DbitsLeft = 16;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,21 +270,16 @@ unsigned int biari_decode_final(DecodingEnvironmentPtr dep)
|
||||||
* Initializes a given context with some pre-defined probability state
|
* Initializes a given context with some pre-defined probability state
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void biari_init_context (int qp, BiContextTypePtr ctx, const signed char* ini)
|
void biari_init_context(int qp, BiContextTypePtr ctx, const signed char *ini) {
|
||||||
{
|
|
||||||
int pstate = ((ini[0] * qp) >> 4) + ini[1];
|
int pstate = ((ini[0] * qp) >> 4) + ini[1];
|
||||||
|
|
||||||
if ( pstate >= 64 )
|
if (pstate >= 64) {
|
||||||
{
|
|
||||||
pstate = imin(126, pstate);
|
pstate = imin(126, pstate);
|
||||||
ctx->state = (uint16)(pstate - 64);
|
ctx->state = (uint16)(pstate - 64);
|
||||||
ctx->MPS = 1;
|
ctx->MPS = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
pstate = imax(1, pstate);
|
pstate = imax(1, pstate);
|
||||||
ctx->state = (uint16)(63 - pstate);
|
ctx->state = (uint16)(63 - pstate);
|
||||||
ctx->MPS = 0;
|
ctx->MPS = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* Block Prediction related functions
|
* Block Prediction related functions
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
*
|
*
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
|
@ -14,49 +15,48 @@
|
||||||
|
|
||||||
#include "contributors.h"
|
#include "contributors.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include "macroblock.h"
|
|
||||||
#include "mc_prediction.h"
|
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "macroblock.h"
|
||||||
#include "mb_access.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;
|
imgpel *imgOrg, *imgPred;
|
||||||
int *m7;
|
int *m7;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++) {
|
||||||
{
|
|
||||||
imgOrg = &curImg[j][opix_x];
|
imgOrg = &curImg[j][opix_x];
|
||||||
imgPred = &mpr[j][mb_x];
|
imgPred = &mpr[j][mb_x];
|
||||||
m7 = &mb_rres[j][mb_x];
|
m7 = &mb_rres[j][mb_x];
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++) {
|
||||||
{
|
|
||||||
*m7++ = *imgOrg++ - *imgPred++;
|
*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;
|
imgpel *imgOrg, *imgPred;
|
||||||
int *m7;
|
int *m7;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++) {
|
||||||
{
|
|
||||||
imgOrg = &curImg[j][opix_x];
|
imgOrg = &curImg[j][opix_x];
|
||||||
imgPred = &mpr[j][mb_x];
|
imgPred = &mpr[j][mb_x];
|
||||||
m7 = &mb_rres[j][mb_x];
|
m7 = &mb_rres[j][mb_x];
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
*imgOrg++ = (imgpel) iClip1( max_imgpel_value, rshift_rnd_sf(*m7++, dq_bits) + *imgPred++);
|
*imgOrg++ = (imgpel)iClip1(max_imgpel_value,
|
||||||
|
rshift_rnd_sf(*m7++, dq_bits) + *imgPred++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
* Block functions
|
* Block functions
|
||||||
*
|
*
|
||||||
* \author
|
* \author
|
||||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
* Main contributors (see contributors.h for copyright, address and
|
||||||
|
*affiliation details)
|
||||||
* - Inge Lille-Langoy <inge.lille-langoy@telenor.com>
|
* - Inge Lille-Langoy <inge.lille-langoy@telenor.com>
|
||||||
* - Rickard Sjoberg <rickard.sjoberg@era.ericsson.se>
|
* - Rickard Sjoberg <rickard.sjoberg@era.ericsson.se>
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
|
@ -16,14 +17,14 @@
|
||||||
|
|
||||||
#include "contributors.h"
|
#include "contributors.h"
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "block.h"
|
|
||||||
#include "blk_prediction.h"
|
#include "blk_prediction.h"
|
||||||
|
#include "block.h"
|
||||||
|
#include "global.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "mb_access.h"
|
#include "mb_access.h"
|
||||||
#include "transform.h"
|
|
||||||
#include "quant.h"
|
|
||||||
#include "memalloc.h"
|
#include "memalloc.h"
|
||||||
|
#include "quant.h"
|
||||||
|
#include "transform.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
|
@ -41,7 +42,10 @@ void itrans4x4(Macroblock *currMB, //!< current macroblock
|
||||||
|
|
||||||
inverse4x4(currSlice->cof[pl], mb_rres, joff, ioff);
|
inverse4x4(currSlice->cof[pl], mb_rres, joff, ioff);
|
||||||
|
|
||||||
sample_reconstruct (&currSlice->mb_rec[pl][joff], &currSlice->mb_pred[pl][joff], &mb_rres[joff], ioff, ioff, BLOCK_SIZE, BLOCK_SIZE, currMB->p_Vid->max_pel_value_comp[pl], DQ_BITS);
|
sample_reconstruct(&currSlice->mb_rec[pl][joff],
|
||||||
|
&currSlice->mb_pred[pl][joff], &mb_rres[joff], ioff, ioff,
|
||||||
|
BLOCK_SIZE, BLOCK_SIZE,
|
||||||
|
currMB->p_Vid->max_pel_value_comp[pl], DQ_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -65,11 +69,10 @@ void itrans4x4_ls(Macroblock *currMB, //!< current macroblock
|
||||||
imgpel **mb_rec = currSlice->mb_rec[pl];
|
imgpel **mb_rec = currSlice->mb_rec[pl];
|
||||||
int **mb_rres = currSlice->mb_rres[pl];
|
int **mb_rres = currSlice->mb_rres[pl];
|
||||||
|
|
||||||
for (j = joff; j < joff + BLOCK_SIZE; ++j)
|
for (j = joff; j < joff + BLOCK_SIZE; ++j) {
|
||||||
{
|
for (i = ioff; i < ioff + BLOCK_SIZE; ++i) {
|
||||||
for (i = ioff; i < ioff + BLOCK_SIZE; ++i)
|
mb_rec[j][i] =
|
||||||
{
|
(imgpel)iClip1(max_imgpel_value, mb_pred[j][i] + mb_rres[j][i]);
|
||||||
mb_rec[j][i] = (imgpel) iClip1(max_imgpel_value, mb_pred[j][i] + mb_rres[j][i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,53 +97,42 @@ void Inv_Residual_trans_4x4(Macroblock *currMB, //!< current macroblock
|
||||||
int **mb_rres = currSlice->mb_rres[pl];
|
int **mb_rres = currSlice->mb_rres[pl];
|
||||||
int **cof = currSlice->cof[pl];
|
int **cof = currSlice->cof[pl];
|
||||||
|
|
||||||
if(currMB->ipmode_DPCM == VERT_PRED)
|
if (currMB->ipmode_DPCM == VERT_PRED) {
|
||||||
{
|
for (i = 0; i < 4; ++i) {
|
||||||
for(i=0; i<4; ++i)
|
|
||||||
{
|
|
||||||
temp[0][i] = cof[joff + 0][ioff + i];
|
temp[0][i] = cof[joff + 0][ioff + i];
|
||||||
temp[1][i] = cof[joff + 1][ioff + i] + temp[0][i];
|
temp[1][i] = cof[joff + 1][ioff + i] + temp[0][i];
|
||||||
temp[2][i] = cof[joff + 2][ioff + i] + temp[1][i];
|
temp[2][i] = cof[joff + 2][ioff + i] + temp[1][i];
|
||||||
temp[3][i] = cof[joff + 3][ioff + i] + temp[2][i];
|
temp[3][i] = cof[joff + 3][ioff + i] + temp[2][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i<4; ++i)
|
for (i = 0; i < 4; ++i) {
|
||||||
{
|
|
||||||
mb_rres[joff][ioff + i] = temp[0][i];
|
mb_rres[joff][ioff + i] = temp[0][i];
|
||||||
mb_rres[joff + 1][ioff + i] = temp[1][i];
|
mb_rres[joff + 1][ioff + i] = temp[1][i];
|
||||||
mb_rres[joff + 2][ioff + i] = temp[2][i];
|
mb_rres[joff + 2][ioff + i] = temp[2][i];
|
||||||
mb_rres[joff + 3][ioff + i] = temp[3][i];
|
mb_rres[joff + 3][ioff + i] = temp[3][i];
|
||||||
}
|
}
|
||||||
}
|
} else if (currMB->ipmode_DPCM == HOR_PRED) {
|
||||||
else if(currMB->ipmode_DPCM == HOR_PRED)
|
for (j = 0; j < 4; ++j) {
|
||||||
{
|
|
||||||
for(j=0; j<4; ++j)
|
|
||||||
{
|
|
||||||
temp[j][0] = cof[joff + j][ioff];
|
temp[j][0] = cof[joff + j][ioff];
|
||||||
temp[j][1] = cof[joff + j][ioff + 1] + temp[j][0];
|
temp[j][1] = cof[joff + j][ioff + 1] + temp[j][0];
|
||||||
temp[j][2] = cof[joff + j][ioff + 2] + temp[j][1];
|
temp[j][2] = cof[joff + j][ioff + 2] + temp[j][1];
|
||||||
temp[j][3] = cof[joff + j][ioff + 3] + temp[j][2];
|
temp[j][3] = cof[joff + j][ioff + 3] + temp[j][2];
|
||||||
}
|
}
|
||||||
|
|
||||||
for(j=0; j<4; ++j)
|
for (j = 0; j < 4; ++j) {
|
||||||
{
|
|
||||||
mb_rres[joff + j][ioff] = temp[j][0];
|
mb_rres[joff + j][ioff] = temp[j][0];
|
||||||
mb_rres[joff + j][ioff + 1] = temp[j][1];
|
mb_rres[joff + j][ioff + 1] = temp[j][1];
|
||||||
mb_rres[joff + j][ioff + 2] = temp[j][2];
|
mb_rres[joff + j][ioff + 2] = temp[j][2];
|
||||||
mb_rres[joff + j][ioff + 3] = temp[j][3];
|
mb_rres[joff + j][ioff + 3] = temp[j][3];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
for (j = joff; j < joff + BLOCK_SIZE; ++j)
|
for (j = joff; j < joff + BLOCK_SIZE; ++j)
|
||||||
for (i = ioff; i < ioff + BLOCK_SIZE; ++i)
|
for (i = ioff; i < ioff + BLOCK_SIZE; ++i)
|
||||||
mb_rres[j][i] = cof[j][i];
|
mb_rres[j][i] = cof[j][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = joff; j < joff + BLOCK_SIZE; ++j)
|
for (j = joff; j < joff + BLOCK_SIZE; ++j) {
|
||||||
{
|
for (i = ioff; i < ioff + BLOCK_SIZE; ++i) {
|
||||||
for (i = ioff; i < ioff + BLOCK_SIZE; ++i)
|
|
||||||
{
|
|
||||||
mb_rec[j][i] = (imgpel)(mb_rres[j][i] + mb_pred[j][i]);
|
mb_rec[j][i] = (imgpel)(mb_rres[j][i] + mb_pred[j][i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,8 +148,8 @@ void Inv_Residual_trans_4x4(Macroblock *currMB, //!< current macroblock
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
// For residual DPCM
|
// For residual DPCM
|
||||||
void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,int joff)
|
void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,
|
||||||
{
|
int joff) {
|
||||||
Slice *currSlice = currMB->p_Slice;
|
Slice *currSlice = currMB->p_Slice;
|
||||||
int i, j;
|
int i, j;
|
||||||
int temp[8][8];
|
int temp[8][8];
|
||||||
|
@ -165,10 +157,8 @@ void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,int joff
|
||||||
imgpel **mb_rec = currSlice->mb_rec[pl];
|
imgpel **mb_rec = currSlice->mb_rec[pl];
|
||||||
int **mb_rres = currSlice->mb_rres[pl];
|
int **mb_rres = currSlice->mb_rres[pl];
|
||||||
|
|
||||||
if(currMB->ipmode_DPCM == VERT_PRED)
|
if (currMB->ipmode_DPCM == VERT_PRED) {
|
||||||
{
|
for (i = 0; i < 8; ++i) {
|
||||||
for(i=0; i<8; ++i)
|
|
||||||
{
|
|
||||||
temp[0][i] = mb_rres[joff + 0][ioff + i];
|
temp[0][i] = mb_rres[joff + 0][ioff + i];
|
||||||
temp[1][i] = mb_rres[joff + 1][ioff + i] + temp[0][i];
|
temp[1][i] = mb_rres[joff + 1][ioff + i] + temp[0][i];
|
||||||
temp[2][i] = mb_rres[joff + 2][ioff + i] + temp[1][i];
|
temp[2][i] = mb_rres[joff + 2][ioff + i] + temp[1][i];
|
||||||
|
@ -178,8 +168,7 @@ void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,int joff
|
||||||
temp[6][i] = mb_rres[joff + 6][ioff + i] + temp[5][i];
|
temp[6][i] = mb_rres[joff + 6][ioff + i] + temp[5][i];
|
||||||
temp[7][i] = mb_rres[joff + 7][ioff + i] + temp[6][i];
|
temp[7][i] = mb_rres[joff + 7][ioff + i] + temp[6][i];
|
||||||
}
|
}
|
||||||
for(i=0; i<8; ++i)
|
for (i = 0; i < 8; ++i) {
|
||||||
{
|
|
||||||
mb_rres[joff][ioff + i] = temp[0][i];
|
mb_rres[joff][ioff + i] = temp[0][i];
|
||||||
mb_rres[joff + 1][ioff + i] = temp[1][i];
|
mb_rres[joff + 1][ioff + i] = temp[1][i];
|
||||||
mb_rres[joff + 2][ioff + i] = temp[2][i];
|
mb_rres[joff + 2][ioff + i] = temp[2][i];
|
||||||
|
@ -189,11 +178,9 @@ void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,int joff
|
||||||
mb_rres[joff + 6][ioff + i] = temp[6][i];
|
mb_rres[joff + 6][ioff + i] = temp[6][i];
|
||||||
mb_rres[joff + 7][ioff + i] = temp[7][i];
|
mb_rres[joff + 7][ioff + i] = temp[7][i];
|
||||||
}
|
}
|
||||||
}
|
} else if (currMB->ipmode_DPCM == HOR_PRED) // HOR_PRED
|
||||||
else if(currMB->ipmode_DPCM == HOR_PRED)//HOR_PRED
|
|
||||||
{
|
|
||||||
for(i=0; i<8; ++i)
|
|
||||||
{
|
{
|
||||||
|
for (i = 0; i < 8; ++i) {
|
||||||
temp[i][0] = mb_rres[joff + i][ioff + 0];
|
temp[i][0] = mb_rres[joff + i][ioff + 0];
|
||||||
temp[i][1] = mb_rres[joff + i][ioff + 1] + temp[i][0];
|
temp[i][1] = mb_rres[joff + i][ioff + 1] + temp[i][0];
|
||||||
temp[i][2] = mb_rres[joff + i][ioff + 2] + temp[i][1];
|
temp[i][2] = mb_rres[joff + i][ioff + 2] + temp[i][1];
|
||||||
|
@ -203,8 +190,7 @@ void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,int joff
|
||||||
temp[i][6] = mb_rres[joff + i][ioff + 6] + temp[i][5];
|
temp[i][6] = mb_rres[joff + i][ioff + 6] + temp[i][5];
|
||||||
temp[i][7] = mb_rres[joff + i][ioff + 7] + temp[i][6];
|
temp[i][7] = mb_rres[joff + i][ioff + 7] + temp[i][6];
|
||||||
}
|
}
|
||||||
for(i=0; i<8; ++i)
|
for (i = 0; i < 8; ++i) {
|
||||||
{
|
|
||||||
mb_rres[joff + i][ioff + 0] = temp[i][0];
|
mb_rres[joff + i][ioff + 0] = temp[i][0];
|
||||||
mb_rres[joff + i][ioff + 1] = temp[i][1];
|
mb_rres[joff + i][ioff + 1] = temp[i][1];
|
||||||
mb_rres[joff + i][ioff + 2] = temp[i][2];
|
mb_rres[joff + i][ioff + 2] = temp[i][2];
|
||||||
|
@ -216,17 +202,13 @@ void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,int joff
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = joff; j < joff + BLOCK_SIZE*2; ++j)
|
for (j = joff; j < joff + BLOCK_SIZE * 2; ++j) {
|
||||||
{
|
for (i = ioff; i < ioff + BLOCK_SIZE * 2; ++i) {
|
||||||
for (i = ioff; i < ioff + BLOCK_SIZE*2; ++i)
|
|
||||||
{
|
|
||||||
mb_rec[j][i] = (imgpel)(mb_rres[j][i] + mb_pred[j][i]);
|
mb_rec[j][i] = (imgpel)(mb_rres[j][i] + mb_pred[j][i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -245,53 +227,41 @@ void Inv_Residual_trans_16x16(Macroblock *currMB, //!< current macroblock
|
||||||
int **mb_rres = currSlice->mb_rres[pl];
|
int **mb_rres = currSlice->mb_rres[pl];
|
||||||
int **cof = currSlice->cof[pl];
|
int **cof = currSlice->cof[pl];
|
||||||
|
|
||||||
if(currMB->ipmode_DPCM == VERT_PRED_16)
|
if (currMB->ipmode_DPCM == VERT_PRED_16) {
|
||||||
{
|
for (i = 0; i < MB_BLOCK_SIZE; ++i) {
|
||||||
for(i=0; i<MB_BLOCK_SIZE; ++i)
|
|
||||||
{
|
|
||||||
temp[0][i] = cof[0][i];
|
temp[0][i] = cof[0][i];
|
||||||
for (j = 1; j < MB_BLOCK_SIZE; j++)
|
for (j = 1; j < MB_BLOCK_SIZE; j++)
|
||||||
temp[j][i] = cof[j][i] + temp[j - 1][i];
|
temp[j][i] = cof[j][i] + temp[j - 1][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i<MB_BLOCK_SIZE; ++i)
|
for (i = 0; i < MB_BLOCK_SIZE; ++i) {
|
||||||
{
|
|
||||||
for (j = 0; j < MB_BLOCK_SIZE; j++)
|
for (j = 0; j < MB_BLOCK_SIZE; j++)
|
||||||
mb_rres[j][i] = temp[j][i];
|
mb_rres[j][i] = temp[j][i];
|
||||||
}
|
}
|
||||||
}
|
} else if (currMB->ipmode_DPCM == HOR_PRED_16) {
|
||||||
else if(currMB->ipmode_DPCM == HOR_PRED_16)
|
for (j = 0; j < MB_BLOCK_SIZE; ++j) {
|
||||||
{
|
|
||||||
for(j=0; j<MB_BLOCK_SIZE; ++j)
|
|
||||||
{
|
|
||||||
temp[j][0] = cof[j][0];
|
temp[j][0] = cof[j][0];
|
||||||
for (i = 1; i < MB_BLOCK_SIZE; i++)
|
for (i = 1; i < MB_BLOCK_SIZE; i++)
|
||||||
temp[j][i] = cof[j][i] + temp[j][i - 1];
|
temp[j][i] = cof[j][i] + temp[j][i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
for(j=0; j<MB_BLOCK_SIZE; ++j)
|
for (j = 0; j < MB_BLOCK_SIZE; ++j) {
|
||||||
{
|
|
||||||
for (i = 0; i < MB_BLOCK_SIZE; ++i)
|
for (i = 0; i < MB_BLOCK_SIZE; ++i)
|
||||||
mb_rres[j][i] = temp[j][i];
|
mb_rres[j][i] = temp[j][i];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
for (j = 0; j < MB_BLOCK_SIZE; ++j)
|
for (j = 0; j < MB_BLOCK_SIZE; ++j)
|
||||||
for (i = 0; i < MB_BLOCK_SIZE; ++i)
|
for (i = 0; i < MB_BLOCK_SIZE; ++i)
|
||||||
mb_rres[j][i] = cof[j][i];
|
mb_rres[j][i] = cof[j][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < MB_BLOCK_SIZE; ++j)
|
for (j = 0; j < MB_BLOCK_SIZE; ++j) {
|
||||||
{
|
for (i = 0; i < MB_BLOCK_SIZE; ++i) {
|
||||||
for (i = 0; i < MB_BLOCK_SIZE; ++i)
|
|
||||||
{
|
|
||||||
mb_rec[j][i] = (imgpel)(mb_rres[j][i] + mb_pred[j][i]);
|
mb_rec[j][i] = (imgpel)(mb_rres[j][i] + mb_pred[j][i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -299,8 +269,7 @@ void Inv_Residual_trans_16x16(Macroblock *currMB, //!< current macroblock
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void Inv_Residual_trans_Chroma(Macroblock *currMB, int uv)
|
void Inv_Residual_trans_Chroma(Macroblock *currMB, int uv) {
|
||||||
{
|
|
||||||
int i, j;
|
int i, j;
|
||||||
int temp[16][16];
|
int temp[16][16];
|
||||||
Slice *currSlice = currMB->p_Slice;
|
Slice *currSlice = currMB->p_Slice;
|
||||||
|
@ -313,37 +282,30 @@ void Inv_Residual_trans_Chroma(Macroblock *currMB, int uv)
|
||||||
width = currMB->p_Vid->mb_cr_size_x;
|
width = currMB->p_Vid->mb_cr_size_x;
|
||||||
height = currMB->p_Vid->mb_cr_size_y;
|
height = currMB->p_Vid->mb_cr_size_y;
|
||||||
|
|
||||||
if(currMB->c_ipred_mode == VERT_PRED_8)
|
if (currMB->c_ipred_mode == VERT_PRED_8) {
|
||||||
{
|
for (i = 0; i < width; i++) {
|
||||||
for(i=0; i<width; i++)
|
|
||||||
{
|
|
||||||
temp[0][i] = cof[0][i];
|
temp[0][i] = cof[0][i];
|
||||||
for (j = 1; j < height; j++)
|
for (j = 1; j < height; j++)
|
||||||
temp[j][i] = temp[j - 1][i] + cof[j][i];
|
temp[j][i] = temp[j - 1][i] + cof[j][i];
|
||||||
}
|
}
|
||||||
for(i=0; i<width; i++)
|
for (i = 0; i < width; i++) {
|
||||||
{
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
mb_rres[j][i] = temp[j][i];
|
mb_rres[j][i] = temp[j][i];
|
||||||
}
|
}
|
||||||
}
|
} else // HOR_PRED_8
|
||||||
else //HOR_PRED_8
|
|
||||||
{
|
|
||||||
for(i=0; i<height; i++)
|
|
||||||
{
|
{
|
||||||
|
for (i = 0; i < height; i++) {
|
||||||
temp[i][0] = cof[i][0];
|
temp[i][0] = cof[i][0];
|
||||||
for (j = 1; j < width; j++)
|
for (j = 1; j < width; j++)
|
||||||
temp[i][j] = temp[i][j - 1] + cof[i][j];
|
temp[i][j] = temp[i][j - 1] + cof[i][j];
|
||||||
}
|
}
|
||||||
for(i=0; i<height; i++)
|
for (i = 0; i < height; i++) {
|
||||||
{
|
|
||||||
for (j = 0; j < width; j++)
|
for (j = 0; j < width; j++)
|
||||||
mb_rres[i][j] = temp[i][j];
|
mb_rres[i][j] = temp[i][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -357,7 +319,9 @@ void itrans_2(Macroblock *currMB, //!< current macroblock
|
||||||
VideoParameters *p_Vid = currMB->p_Vid;
|
VideoParameters *p_Vid = currMB->p_Vid;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
int transform_pl = (p_Vid->separate_colour_plane_flag != 0) ? PLANE_Y /*p_Vid->colour_plane_id*/ : pl;
|
int transform_pl = (p_Vid->separate_colour_plane_flag != 0)
|
||||||
|
? PLANE_Y /*p_Vid->colour_plane_id*/
|
||||||
|
: pl;
|
||||||
int **cof = currSlice->cof[transform_pl];
|
int **cof = currSlice->cof[transform_pl];
|
||||||
int qp_scaled = currMB->qp_scaled[pl];
|
int qp_scaled = currMB->qp_scaled[pl];
|
||||||
|
|
||||||
|
@ -369,8 +333,7 @@ void itrans_2(Macroblock *currMB, //!< current macroblock
|
||||||
get_mem2Dint(&M4, BLOCK_SIZE, BLOCK_SIZE);
|
get_mem2Dint(&M4, BLOCK_SIZE, BLOCK_SIZE);
|
||||||
|
|
||||||
// horizontal
|
// horizontal
|
||||||
for (j=0; j < 4;++j)
|
for (j = 0; j < 4; ++j) {
|
||||||
{
|
|
||||||
M4[j][0] = cof[j << 2][0];
|
M4[j][0] = cof[j << 2][0];
|
||||||
M4[j][1] = cof[j << 2][4];
|
M4[j][1] = cof[j << 2][4];
|
||||||
M4[j][2] = cof[j << 2][8];
|
M4[j][2] = cof[j << 2][8];
|
||||||
|
@ -380,8 +343,7 @@ void itrans_2(Macroblock *currMB, //!< current macroblock
|
||||||
ihadamard4x4(M4, M4);
|
ihadamard4x4(M4, M4);
|
||||||
|
|
||||||
// vertical
|
// vertical
|
||||||
for (j=0; j < 4;++j)
|
for (j = 0; j < 4; ++j) {
|
||||||
{
|
|
||||||
cof[j << 2][0] = rshift_rnd(((M4[j][0] * invLevelScale) << qp_per), 6);
|
cof[j << 2][0] = rshift_rnd(((M4[j][0] * invLevelScale) << qp_per), 6);
|
||||||
cof[j << 2][4] = rshift_rnd(((M4[j][1] * invLevelScale) << qp_per), 6);
|
cof[j << 2][4] = rshift_rnd(((M4[j][1] * invLevelScale) << qp_per), 6);
|
||||||
cof[j << 2][8] = rshift_rnd(((M4[j][2] * invLevelScale) << qp_per), 6);
|
cof[j << 2][8] = rshift_rnd(((M4[j][2] * invLevelScale) << qp_per), 6);
|
||||||
|
@ -391,7 +353,6 @@ void itrans_2(Macroblock *currMB, //!< current macroblock
|
||||||
free_mem2Dint(M4);
|
free_mem2Dint(M4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void itrans_sp(Macroblock *currMB, //!< current macroblock
|
void itrans_sp(Macroblock *currMB, //!< current macroblock
|
||||||
ColorPlane pl, //!< used color plane
|
ColorPlane pl, //!< used color plane
|
||||||
int ioff, //!< index to 4x4 block
|
int ioff, //!< index to 4x4 block
|
||||||
|
@ -422,8 +383,7 @@ void itrans_sp(Macroblock *currMB, //!< current macroblock
|
||||||
|
|
||||||
get_mem2Dint(&PBlock, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
|
get_mem2Dint(&PBlock, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
|
||||||
|
|
||||||
for (j=0; j< BLOCK_SIZE; ++j)
|
for (j = 0; j < BLOCK_SIZE; ++j) {
|
||||||
{
|
|
||||||
PBlock[j][0] = mb_pred[j + joff][ioff];
|
PBlock[j][0] = mb_pred[j + joff][ioff];
|
||||||
PBlock[j][1] = mb_pred[j + joff][ioff + 1];
|
PBlock[j][1] = mb_pred[j + joff][ioff + 1];
|
||||||
PBlock[j][2] = mb_pred[j + joff][ioff + 2];
|
PBlock[j][2] = mb_pred[j + joff][ioff + 2];
|
||||||
|
@ -432,35 +392,36 @@ void itrans_sp(Macroblock *currMB, //!< current macroblock
|
||||||
|
|
||||||
forward4x4(PBlock, PBlock, 0, 0);
|
forward4x4(PBlock, PBlock, 0, 0);
|
||||||
|
|
||||||
if(currSlice->sp_switch || currSlice->slice_type==SI_SLICE)
|
if (currSlice->sp_switch || currSlice->slice_type == SI_SLICE) {
|
||||||
{
|
for (j = 0; j < BLOCK_SIZE; ++j) {
|
||||||
for (j=0;j<BLOCK_SIZE;++j)
|
for (i = 0; i < BLOCK_SIZE; ++i) {
|
||||||
{
|
|
||||||
for (i=0;i<BLOCK_SIZE;++i)
|
|
||||||
{
|
|
||||||
// recovering coefficient since they are already dequantized earlier
|
// recovering coefficient since they are already dequantized earlier
|
||||||
icof = (cof[joff + j][ioff + i] >> qp_per) / InvLevelScale4x4[j][i];
|
icof = (cof[joff + j][ioff + i] >> qp_per) / InvLevelScale4x4[j][i];
|
||||||
//icof = ((cof[joff + j][ioff + i] * quant_coef[qp_rem][j][i])>> (qp_per + 15)) ;
|
// icof = ((cof[joff + j][ioff + i] * quant_coef[qp_rem][j][i])>>
|
||||||
// icof = rshift_rnd_sf(cof[joff + j][ioff + i] * quant_coef[qp_rem][j][i], qp_per + 15);
|
// (qp_per + 15)) ;
|
||||||
ilev = rshift_rnd_sf(iabs(PBlock[j][i]) * quant_coef[qp_rem_sp][j][i], q_bits_sp);
|
// icof = rshift_rnd_sf(cof[joff + j][ioff + i] *
|
||||||
|
// quant_coef[qp_rem][j][i], qp_per + 15);
|
||||||
|
ilev = rshift_rnd_sf(iabs(PBlock[j][i]) * quant_coef[qp_rem_sp][j][i],
|
||||||
|
q_bits_sp);
|
||||||
ilev = isignab(ilev, PBlock[j][i]) + icof;
|
ilev = isignab(ilev, PBlock[j][i]) + icof;
|
||||||
cof[joff + j][ioff + i] = ilev * InvLevelScale4x4SP[j][i] << qp_per_sp;
|
cof[joff + j][ioff + i] = ilev * InvLevelScale4x4SP[j][i] << qp_per_sp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
for (j = 0; j < BLOCK_SIZE; ++j) {
|
||||||
{
|
for (i = 0; i < BLOCK_SIZE; ++i) {
|
||||||
for (j=0;j<BLOCK_SIZE;++j)
|
|
||||||
{
|
|
||||||
for (i=0;i<BLOCK_SIZE;++i)
|
|
||||||
{
|
|
||||||
// recovering coefficient since they are already dequantized earlier
|
// recovering coefficient since they are already dequantized earlier
|
||||||
icof = (cof[joff + j][ioff + i] >> qp_per) / InvLevelScale4x4[j][i];
|
icof = (cof[joff + j][ioff + i] >> qp_per) / InvLevelScale4x4[j][i];
|
||||||
// icof = cof[joff + j][ioff + i];
|
// icof = cof[joff + j][ioff + i];
|
||||||
//icof = rshift_rnd_sf(cof[joff + j][ioff + i] * quant_coef[qp_rem][j][i], qp_per + 15);
|
// icof = rshift_rnd_sf(cof[joff + j][ioff + i] *
|
||||||
ilev = PBlock[j][i] + ((icof * InvLevelScale4x4[j][i] * A[j][i] << qp_per) >> 6);
|
// quant_coef[qp_rem][j][i], qp_per + 15);
|
||||||
ilev = isign(ilev) * rshift_rnd_sf(iabs(ilev) * quant_coef[qp_rem_sp][j][i], q_bits_sp);
|
ilev = PBlock[j][i] +
|
||||||
//cof[joff + j][ioff + i] = ilev * InvLevelScale4x4SP[j][i] << qp_per_sp;
|
((icof * InvLevelScale4x4[j][i] * A[j][i] << qp_per) >> 6);
|
||||||
|
ilev =
|
||||||
|
isign(ilev) *
|
||||||
|
rshift_rnd_sf(iabs(ilev) * quant_coef[qp_rem_sp][j][i], q_bits_sp);
|
||||||
|
// cof[joff + j][ioff + i] = ilev * InvLevelScale4x4SP[j][i] <<
|
||||||
|
// qp_per_sp;
|
||||||
cof[joff + j][ioff + i] = ilev * InvLevelScale4x4SP[j][i] << qp_per_sp;
|
cof[joff + j][ioff + i] = ilev * InvLevelScale4x4SP[j][i] << qp_per_sp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -468,20 +429,21 @@ void itrans_sp(Macroblock *currMB, //!< current macroblock
|
||||||
|
|
||||||
inverse4x4(cof, mb_rres, joff, ioff);
|
inverse4x4(cof, mb_rres, joff, ioff);
|
||||||
|
|
||||||
for (j=joff; j<joff +BLOCK_SIZE;++j)
|
for (j = joff; j < joff + BLOCK_SIZE; ++j) {
|
||||||
{
|
mb_rec[j][ioff] = (imgpel)iClip1(max_imgpel_value,
|
||||||
mb_rec[j][ioff ] = (imgpel) iClip1(max_imgpel_value,rshift_rnd_sf(mb_rres[j][ioff ], DQ_BITS));
|
rshift_rnd_sf(mb_rres[j][ioff], DQ_BITS));
|
||||||
mb_rec[j][ioff+ 1] = (imgpel) iClip1(max_imgpel_value,rshift_rnd_sf(mb_rres[j][ioff+ 1], DQ_BITS));
|
mb_rec[j][ioff + 1] = (imgpel)iClip1(
|
||||||
mb_rec[j][ioff+ 2] = (imgpel) iClip1(max_imgpel_value,rshift_rnd_sf(mb_rres[j][ioff+ 2], DQ_BITS));
|
max_imgpel_value, rshift_rnd_sf(mb_rres[j][ioff + 1], DQ_BITS));
|
||||||
mb_rec[j][ioff+ 3] = (imgpel) iClip1(max_imgpel_value,rshift_rnd_sf(mb_rres[j][ioff+ 3], DQ_BITS));
|
mb_rec[j][ioff + 2] = (imgpel)iClip1(
|
||||||
|
max_imgpel_value, rshift_rnd_sf(mb_rres[j][ioff + 2], DQ_BITS));
|
||||||
|
mb_rec[j][ioff + 3] = (imgpel)iClip1(
|
||||||
|
max_imgpel_value, rshift_rnd_sf(mb_rres[j][ioff + 3], DQ_BITS));
|
||||||
}
|
}
|
||||||
|
|
||||||
free_mem2Dint(PBlock);
|
free_mem2Dint(PBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void itrans_sp_cr(Macroblock *currMB, int uv) {
|
||||||
void itrans_sp_cr(Macroblock *currMB, int uv)
|
|
||||||
{
|
|
||||||
Slice *currSlice = currMB->p_Slice;
|
Slice *currSlice = currMB->p_Slice;
|
||||||
VideoParameters *p_Vid = currMB->p_Vid;
|
VideoParameters *p_Vid = currMB->p_Vid;
|
||||||
int i, j, ilev, icof, n2, n1;
|
int i, j, ilev, icof, n2, n1;
|
||||||
|
@ -492,32 +454,31 @@ void itrans_sp_cr(Macroblock *currMB, int uv)
|
||||||
int **cof = currSlice->cof[uv + 1];
|
int **cof = currSlice->cof[uv + 1];
|
||||||
int **PBlock = new_mem2Dint(MB_BLOCK_SIZE, MB_BLOCK_SIZE);
|
int **PBlock = new_mem2Dint(MB_BLOCK_SIZE, MB_BLOCK_SIZE);
|
||||||
|
|
||||||
qp_per = p_Vid->qp_per_matrix[ ((currSlice->qp < 0 ? currSlice->qp : QP_SCALE_CR[currSlice->qp]))];
|
qp_per = p_Vid->qp_per_matrix[(
|
||||||
qp_rem = p_Vid->qp_rem_matrix[ ((currSlice->qp < 0 ? currSlice->qp : QP_SCALE_CR[currSlice->qp]))];
|
(currSlice->qp < 0 ? currSlice->qp : QP_SCALE_CR[currSlice->qp]))];
|
||||||
|
qp_rem = p_Vid->qp_rem_matrix[(
|
||||||
|
(currSlice->qp < 0 ? currSlice->qp : QP_SCALE_CR[currSlice->qp]))];
|
||||||
|
|
||||||
qp_per_sp = p_Vid->qp_per_matrix[ ((currSlice->qs < 0 ? currSlice->qs : QP_SCALE_CR[currSlice->qs]))];
|
qp_per_sp = p_Vid->qp_per_matrix[(
|
||||||
qp_rem_sp = p_Vid->qp_rem_matrix[ ((currSlice->qs < 0 ? currSlice->qs : QP_SCALE_CR[currSlice->qs]))];
|
(currSlice->qs < 0 ? currSlice->qs : QP_SCALE_CR[currSlice->qs]))];
|
||||||
|
qp_rem_sp = p_Vid->qp_rem_matrix[(
|
||||||
|
(currSlice->qs < 0 ? currSlice->qs : QP_SCALE_CR[currSlice->qs]))];
|
||||||
q_bits_sp = Q_BITS + qp_per_sp;
|
q_bits_sp = Q_BITS + qp_per_sp;
|
||||||
|
|
||||||
if (currSlice->slice_type == SI_SLICE)
|
if (currSlice->slice_type == SI_SLICE) {
|
||||||
{
|
|
||||||
qp_per = qp_per_sp;
|
qp_per = qp_per_sp;
|
||||||
qp_rem = qp_rem_sp;
|
qp_rem = qp_rem_sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j=0; j < p_Vid->mb_cr_size_y; ++j)
|
for (j = 0; j < p_Vid->mb_cr_size_y; ++j) {
|
||||||
{
|
for (i = 0; i < p_Vid->mb_cr_size_x; ++i) {
|
||||||
for (i=0; i < p_Vid->mb_cr_size_x; ++i)
|
|
||||||
{
|
|
||||||
PBlock[j][i] = mb_pred[j][i];
|
PBlock[j][i] = mb_pred[j][i];
|
||||||
mb_pred[j][i] = 0;
|
mb_pred[j][i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n2=0; n2 < p_Vid->mb_cr_size_y; n2 += BLOCK_SIZE)
|
for (n2 = 0; n2 < p_Vid->mb_cr_size_y; n2 += BLOCK_SIZE) {
|
||||||
{
|
for (n1 = 0; n1 < p_Vid->mb_cr_size_x; n1 += BLOCK_SIZE) {
|
||||||
for (n1=0; n1 < p_Vid->mb_cr_size_x; n1 += BLOCK_SIZE)
|
|
||||||
{
|
|
||||||
forward4x4(PBlock, PBlock, n2, n1);
|
forward4x4(PBlock, PBlock, n2, n1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -528,14 +489,13 @@ void itrans_sp_cr(Macroblock *currMB, int uv)
|
||||||
mp1[2] = (PBlock[0][0] + PBlock[4][0] - PBlock[0][4] - PBlock[4][4]);
|
mp1[2] = (PBlock[0][0] + PBlock[4][0] - PBlock[0][4] - PBlock[4][4]);
|
||||||
mp1[3] = (PBlock[0][0] - PBlock[4][0] - PBlock[0][4] + PBlock[4][4]);
|
mp1[3] = (PBlock[0][0] - PBlock[4][0] - PBlock[0][4] + PBlock[4][4]);
|
||||||
|
|
||||||
if (currSlice->sp_switch || currSlice->slice_type == SI_SLICE)
|
if (currSlice->sp_switch || currSlice->slice_type == SI_SLICE) {
|
||||||
{
|
for (n2 = 0; n2 < 2; ++n2) {
|
||||||
for (n2=0; n2 < 2; ++n2 )
|
for (n1 = 0; n1 < 2; ++n1) {
|
||||||
{
|
|
||||||
for (n1=0; n1 < 2; ++n1 )
|
|
||||||
{
|
|
||||||
// quantization fo predicted block
|
// quantization fo predicted block
|
||||||
ilev = rshift_rnd_sf(iabs (mp1[n1+n2*2]) * quant_coef[qp_rem_sp][0][0], q_bits_sp + 1);
|
ilev =
|
||||||
|
rshift_rnd_sf(iabs(mp1[n1 + n2 * 2]) * quant_coef[qp_rem_sp][0][0],
|
||||||
|
q_bits_sp + 1);
|
||||||
// addition
|
// addition
|
||||||
ilev = isignab(ilev, mp1[n1 + n2 * 2]) + cof[n2 << 2][n1 << 2];
|
ilev = isignab(ilev, mp1[n1 + n2 * 2]) + cof[n2 << 2][n1 << 2];
|
||||||
// dequantization
|
// dequantization
|
||||||
|
@ -543,57 +503,61 @@ void itrans_sp_cr(Macroblock *currMB, int uv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n2 = 0; n2 < p_Vid->mb_cr_size_y; n2 += BLOCK_SIZE)
|
for (n2 = 0; n2 < p_Vid->mb_cr_size_y; n2 += BLOCK_SIZE) {
|
||||||
{
|
for (n1 = 0; n1 < p_Vid->mb_cr_size_x; n1 += BLOCK_SIZE) {
|
||||||
for (n1 = 0; n1 < p_Vid->mb_cr_size_x; n1 += BLOCK_SIZE)
|
for (j = 0; j < BLOCK_SIZE; ++j) {
|
||||||
{
|
for (i = 0; i < BLOCK_SIZE; ++i) {
|
||||||
for (j = 0; j < BLOCK_SIZE; ++j)
|
|
||||||
{
|
|
||||||
for (i = 0; i < BLOCK_SIZE; ++i)
|
|
||||||
{
|
|
||||||
// recovering coefficient since they are already dequantized earlier
|
// recovering coefficient since they are already dequantized earlier
|
||||||
cof[n2 + j][n1 + i] = (cof[n2 + j][n1 + i] >> qp_per) / dequant_coef[qp_rem][j][i];
|
cof[n2 + j][n1 + i] =
|
||||||
|
(cof[n2 + j][n1 + i] >> qp_per) / dequant_coef[qp_rem][j][i];
|
||||||
|
|
||||||
// quantization of the predicted block
|
// quantization of the predicted block
|
||||||
ilev = rshift_rnd_sf(iabs(PBlock[n2 + j][n1 + i]) * quant_coef[qp_rem_sp][j][i], q_bits_sp);
|
ilev = rshift_rnd_sf(iabs(PBlock[n2 + j][n1 + i]) *
|
||||||
|
quant_coef[qp_rem_sp][j][i],
|
||||||
|
q_bits_sp);
|
||||||
// addition of the residual
|
// addition of the residual
|
||||||
ilev = isignab(ilev, PBlock[n2 + j][n1 + i]) + cof[n2 + j][n1 + i];
|
ilev = isignab(ilev, PBlock[n2 + j][n1 + i]) + cof[n2 + j][n1 + i];
|
||||||
// Inverse quantization
|
// Inverse quantization
|
||||||
cof[n2 + j][n1 + i] = ilev * dequant_coef[qp_rem_sp][j][i] << qp_per_sp;
|
cof[n2 + j][n1 + i] = ilev * dequant_coef[qp_rem_sp][j][i]
|
||||||
|
<< qp_per_sp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
for (n2 = 0; n2 < 2; ++n2) {
|
||||||
{
|
for (n1 = 0; n1 < 2; ++n1) {
|
||||||
for (n2=0; n2 < 2; ++n2 )
|
ilev = mp1[n1 + n2 * 2] +
|
||||||
{
|
(((cof[n2 << 2][n1 << 2] * dequant_coef[qp_rem][0][0] * A[0][0])
|
||||||
for (n1=0; n1 < 2; ++n1 )
|
<< qp_per) >>
|
||||||
{
|
5);
|
||||||
ilev = mp1[n1+n2*2] + (((cof[n2<<2][n1<<2] * dequant_coef[qp_rem][0][0] * A[0][0]) << qp_per) >> 5);
|
ilev = isign(ilev) *
|
||||||
ilev = isign(ilev) * rshift_rnd_sf(iabs(ilev) * quant_coef[qp_rem_sp][0][0], q_bits_sp + 1);
|
rshift_rnd_sf(iabs(ilev) * quant_coef[qp_rem_sp][0][0],
|
||||||
//ilev = isignab(rshift_rnd_sf(iabs(ilev)* quant_coef[qp_rem_sp][0][0], q_bits_sp + 1), ilev);
|
q_bits_sp + 1);
|
||||||
|
// ilev = isignab(rshift_rnd_sf(iabs(ilev)* quant_coef[qp_rem_sp][0][0],
|
||||||
|
// q_bits_sp + 1), ilev);
|
||||||
mp1[n1 + n2 * 2] = ilev * dequant_coef[qp_rem_sp][0][0] << qp_per_sp;
|
mp1[n1 + n2 * 2] = ilev * dequant_coef[qp_rem_sp][0][0] << qp_per_sp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n2 = 0; n2 < p_Vid->mb_cr_size_y; n2 += BLOCK_SIZE)
|
for (n2 = 0; n2 < p_Vid->mb_cr_size_y; n2 += BLOCK_SIZE) {
|
||||||
{
|
for (n1 = 0; n1 < p_Vid->mb_cr_size_x; n1 += BLOCK_SIZE) {
|
||||||
for (n1 = 0; n1 < p_Vid->mb_cr_size_x; n1 += BLOCK_SIZE)
|
for (j = 0; j < BLOCK_SIZE; ++j) {
|
||||||
{
|
for (i = 0; i < BLOCK_SIZE; ++i) {
|
||||||
for (j = 0; j< BLOCK_SIZE; ++j)
|
|
||||||
{
|
|
||||||
for (i = 0; i< BLOCK_SIZE; ++i)
|
|
||||||
{
|
|
||||||
// recovering coefficient since they are already dequantized earlier
|
// recovering coefficient since they are already dequantized earlier
|
||||||
//icof = ((((cof[n2 + j][n1 + i] << 4) + qp_per/2)>> qp_per) + dequant_coef[qp_rem][j][i]/2) / dequant_coef[qp_rem][j][i];
|
// icof = ((((cof[n2 + j][n1 + i] << 4) + qp_per/2)>> qp_per) +
|
||||||
|
// dequant_coef[qp_rem][j][i]/2) / dequant_coef[qp_rem][j][i];
|
||||||
icof = (cof[n2 + j][n1 + i] >> qp_per) / dequant_coef[qp_rem][j][i];
|
icof = (cof[n2 + j][n1 + i] >> qp_per) / dequant_coef[qp_rem][j][i];
|
||||||
// dequantization and addition of the predicted block
|
// dequantization and addition of the predicted block
|
||||||
ilev = PBlock[n2 + j][n1 + i] + ((icof * dequant_coef[qp_rem][j][i] * A[j][i] << qp_per) >> 6);
|
ilev =
|
||||||
|
PBlock[n2 + j][n1 + i] +
|
||||||
|
((icof * dequant_coef[qp_rem][j][i] * A[j][i] << qp_per) >> 6);
|
||||||
// quantization and dequantization
|
// quantization and dequantization
|
||||||
ilev = isign(ilev) * rshift_rnd_sf(iabs(ilev) * quant_coef[qp_rem_sp][j][i], q_bits_sp);
|
ilev = isign(ilev) *
|
||||||
cof[n2 + j][n1 + i] = ilev * dequant_coef[qp_rem_sp][j][i] << qp_per_sp;
|
rshift_rnd_sf(iabs(ilev) * quant_coef[qp_rem_sp][j][i],
|
||||||
|
q_bits_sp);
|
||||||
|
cof[n2 + j][n1 + i] = ilev * dequant_coef[qp_rem_sp][j][i]
|
||||||
|
<< qp_per_sp;
|
||||||
// printf( " %d %d %d\n", j, i, quant_coef[qp_rem_sp][j][i]);
|
// printf( " %d %d %d\n", j, i, quant_coef[qp_rem_sp][j][i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,8 +573,7 @@ void itrans_sp_cr(Macroblock *currMB, int uv)
|
||||||
free_mem2Dint(PBlock);
|
free_mem2Dint(PBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void iMBtrans4x4(Macroblock *currMB, ColorPlane pl, int smb)
|
void iMBtrans4x4(Macroblock *currMB, ColorPlane pl, int smb) {
|
||||||
{
|
|
||||||
Slice *currSlice = currMB->p_Slice;
|
Slice *currSlice = currMB->p_Slice;
|
||||||
// VideoParameters *p_Vid = currMB->p_Vid;
|
// VideoParameters *p_Vid = currMB->p_Vid;
|
||||||
|
|
||||||
|
@ -623,47 +586,45 @@ void iMBtrans4x4(Macroblock *currMB, ColorPlane pl, int smb)
|
||||||
|
|
||||||
// =============== 4x4 itrans ================
|
// =============== 4x4 itrans ================
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
if (currMB->is_lossless && currMB->mb_type == I16MB)
|
if (currMB->is_lossless && currMB->mb_type == I16MB) {
|
||||||
{
|
|
||||||
Inv_Residual_trans_16x16(currMB, pl);
|
Inv_Residual_trans_16x16(currMB, pl);
|
||||||
}
|
} else if (smb || currMB->is_lossless == TRUE) {
|
||||||
else
|
currMB->itrans_4x4 =
|
||||||
if (smb || currMB->is_lossless == TRUE)
|
(smb) ? itrans_sp
|
||||||
{
|
: ((currMB->is_lossless == FALSE) ? itrans4x4
|
||||||
currMB->itrans_4x4 = (smb) ? itrans_sp : ((currMB->is_lossless == FALSE) ? itrans4x4 : Inv_Residual_trans_4x4);
|
: Inv_Residual_trans_4x4);
|
||||||
for (block8x8=0; block8x8 < MB_BLOCK_SIZE; block8x8 += 4)
|
for (block8x8 = 0; block8x8 < MB_BLOCK_SIZE; block8x8 += 4) {
|
||||||
{
|
for (k = block8x8; k < block8x8 + 4; ++k) {
|
||||||
for (k = block8x8; k < block8x8 + 4; ++k )
|
|
||||||
{
|
|
||||||
jj = ((decode_block_scan[k] >> 2) & 3) << BLOCK_SHIFT;
|
jj = ((decode_block_scan[k] >> 2) & 3) << BLOCK_SHIFT;
|
||||||
ii = (decode_block_scan[k] & 3) << BLOCK_SHIFT;
|
ii = (decode_block_scan[k] & 3) << BLOCK_SHIFT;
|
||||||
|
|
||||||
currMB->itrans_4x4(currMB, pl, ii, jj); // use integer transform and make 4x4 block mb_rres from prediction block mb_pred
|
currMB->itrans_4x4(currMB, pl, ii,
|
||||||
|
jj); // use integer transform and make 4x4 block
|
||||||
|
// mb_rres from prediction block mb_pred
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int **cof = currSlice->cof[pl];
|
int **cof = currSlice->cof[pl];
|
||||||
int **mb_rres = currSlice->mb_rres[pl];
|
int **mb_rres = currSlice->mb_rres[pl];
|
||||||
|
|
||||||
for (jj = 0; jj < MB_BLOCK_SIZE; jj += BLOCK_SIZE)
|
for (jj = 0; jj < MB_BLOCK_SIZE; jj += BLOCK_SIZE) {
|
||||||
{
|
|
||||||
inverse4x4(cof, mb_rres, jj, 0);
|
inverse4x4(cof, mb_rres, jj, 0);
|
||||||
inverse4x4(cof, mb_rres, jj, 4);
|
inverse4x4(cof, mb_rres, jj, 4);
|
||||||
inverse4x4(cof, mb_rres, jj, 8);
|
inverse4x4(cof, mb_rres, jj, 8);
|
||||||
inverse4x4(cof, mb_rres, jj, 12);
|
inverse4x4(cof, mb_rres, jj, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
sample_reconstruct (currSlice->mb_rec[pl], currSlice->mb_pred[pl], mb_rres, 0, 0, MB_BLOCK_SIZE, MB_BLOCK_SIZE, currMB->p_Vid->max_pel_value_comp[pl], DQ_BITS);
|
sample_reconstruct(currSlice->mb_rec[pl], currSlice->mb_pred[pl], mb_rres,
|
||||||
|
0, 0, MB_BLOCK_SIZE, MB_BLOCK_SIZE,
|
||||||
|
currMB->p_Vid->max_pel_value_comp[pl], DQ_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct picture from 4x4 blocks
|
// construct picture from 4x4 blocks
|
||||||
copy_image_data_16x16(&curr_img[currMB->pix_y], currSlice->mb_rec[pl], currMB->pix_x, 0);
|
copy_image_data_16x16(&curr_img[currMB->pix_y], currSlice->mb_rec[pl],
|
||||||
|
currMB->pix_x, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void iMBtrans8x8(Macroblock *currMB, ColorPlane pl)
|
void iMBtrans8x8(Macroblock *currMB, ColorPlane pl) {
|
||||||
{
|
|
||||||
// VideoParameters *p_Vid = currMB->p_Vid;
|
// VideoParameters *p_Vid = currMB->p_Vid;
|
||||||
StorablePicture *dec_picture = currMB->p_Slice->dec_picture;
|
StorablePicture *dec_picture = currMB->p_Slice->dec_picture;
|
||||||
imgpel **curr_img = pl ? dec_picture->imgUV[pl - 1] : dec_picture->imgY;
|
imgpel **curr_img = pl ? dec_picture->imgUV[pl - 1] : dec_picture->imgY;
|
||||||
|
@ -674,59 +635,51 @@ void iMBtrans8x8(Macroblock *currMB, ColorPlane pl)
|
||||||
itrans8x8(currMB, pl, 0, 8);
|
itrans8x8(currMB, pl, 0, 8);
|
||||||
itrans8x8(currMB, pl, 8, 8);
|
itrans8x8(currMB, pl, 8, 8);
|
||||||
|
|
||||||
copy_image_data_16x16(&curr_img[currMB->pix_y], currMB->p_Slice->mb_rec[pl], currMB->pix_x, 0);
|
copy_image_data_16x16(&curr_img[currMB->pix_y], currMB->p_Slice->mb_rec[pl],
|
||||||
|
currMB->pix_x, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void iTransform(Macroblock *currMB, ColorPlane pl, int smb)
|
void iTransform(Macroblock *currMB, ColorPlane pl, int smb) {
|
||||||
{
|
|
||||||
Slice *currSlice = currMB->p_Slice;
|
Slice *currSlice = currMB->p_Slice;
|
||||||
VideoParameters *p_Vid = currMB->p_Vid;
|
VideoParameters *p_Vid = currMB->p_Vid;
|
||||||
StorablePicture *dec_picture = currSlice->dec_picture;
|
StorablePicture *dec_picture = currSlice->dec_picture;
|
||||||
imgpel **curr_img;
|
imgpel **curr_img;
|
||||||
int uv = pl - 1;
|
int uv = pl - 1;
|
||||||
|
|
||||||
if ((currMB->cbp & 15) != 0 || smb)
|
if ((currMB->cbp & 15) != 0 || smb) {
|
||||||
{
|
|
||||||
if (currMB->luma_transform_size_8x8_flag == 0) // 4x4 inverse transform
|
if (currMB->luma_transform_size_8x8_flag == 0) // 4x4 inverse transform
|
||||||
{
|
{
|
||||||
iMBtrans4x4(currMB, pl, smb);
|
iMBtrans4x4(currMB, pl, smb);
|
||||||
}
|
} else // 8x8 inverse transform
|
||||||
else // 8x8 inverse transform
|
|
||||||
{
|
{
|
||||||
iMBtrans8x8(currMB, pl);
|
iMBtrans8x8(currMB, pl);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
curr_img = pl ? dec_picture->imgUV[uv] : dec_picture->imgY;
|
curr_img = pl ? dec_picture->imgUV[uv] : dec_picture->imgY;
|
||||||
copy_image_data_16x16(&curr_img[currMB->pix_y], currSlice->mb_pred[pl], currMB->pix_x, 0);
|
copy_image_data_16x16(&curr_img[currMB->pix_y], currSlice->mb_pred[pl],
|
||||||
|
currMB->pix_x, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((dec_picture->chroma_format_idc != YUV400) &&
|
||||||
if ((dec_picture->chroma_format_idc != YUV400) && (dec_picture->chroma_format_idc != YUV444))
|
(dec_picture->chroma_format_idc != YUV444)) {
|
||||||
{
|
|
||||||
imgpel **curUV;
|
imgpel **curUV;
|
||||||
int b8;
|
int b8;
|
||||||
int ioff, joff;
|
int ioff, joff;
|
||||||
imgpel **mb_rec;
|
imgpel **mb_rec;
|
||||||
|
|
||||||
for(uv = PLANE_U; uv <= PLANE_V; ++uv)
|
for (uv = PLANE_U; uv <= PLANE_V; ++uv) {
|
||||||
{
|
|
||||||
// =============== 4x4 itrans ================
|
// =============== 4x4 itrans ================
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
curUV = &dec_picture->imgUV[uv - 1][currMB->pix_c_y];
|
curUV = &dec_picture->imgUV[uv - 1][currMB->pix_c_y];
|
||||||
mb_rec = currSlice->mb_rec[uv];
|
mb_rec = currSlice->mb_rec[uv];
|
||||||
|
|
||||||
if (!smb && (currMB->cbp>>4))
|
if (!smb && (currMB->cbp >> 4)) {
|
||||||
{
|
if (currMB->is_lossless == FALSE) {
|
||||||
if (currMB->is_lossless == FALSE)
|
|
||||||
{
|
|
||||||
const unsigned char *x_pos, *y_pos;
|
const unsigned char *x_pos, *y_pos;
|
||||||
// const unsigned char *xx_pos = subblk_offset_x[1];
|
// const unsigned char *xx_pos = subblk_offset_x[1];
|
||||||
// const unsigned char *xy_pos = subblk_offset_y[1];
|
// const unsigned char *xy_pos = subblk_offset_y[1];
|
||||||
|
|
||||||
for (b8 = 0; b8 < (p_Vid->num_uv_blocks); ++b8)
|
for (b8 = 0; b8 < (p_Vid->num_uv_blocks); ++b8) {
|
||||||
{
|
|
||||||
x_pos = subblk_offset_x[1][b8];
|
x_pos = subblk_offset_x[1][b8];
|
||||||
y_pos = subblk_offset_y[1][b8];
|
y_pos = subblk_offset_y[1][b8];
|
||||||
|
|
||||||
|
@ -738,16 +691,14 @@ void iTransform(Macroblock *currMB, ColorPlane pl, int smb)
|
||||||
// itrans4x4(currMB, uv, *(*xx_pos + 1), *(*xy_pos + 1));
|
// itrans4x4(currMB, uv, *(*xx_pos + 1), *(*xy_pos + 1));
|
||||||
// itrans4x4(currMB, uv, *(*xx_pos + 2), *(*xy_pos + 2));
|
// itrans4x4(currMB, uv, *(*xx_pos + 2), *(*xy_pos + 2));
|
||||||
// itrans4x4(currMB, uv, *(*xx_pos++ + 3), *(*xy_pos++ + 3));
|
// itrans4x4(currMB, uv, *(*xx_pos++ + 3), *(*xy_pos++ + 3));
|
||||||
|
|
||||||
}
|
}
|
||||||
sample_reconstruct (mb_rec, currSlice->mb_pred[uv], currSlice->mb_rres[uv], 0, 0,
|
sample_reconstruct(mb_rec, currSlice->mb_pred[uv],
|
||||||
p_Vid->mb_size[1][0], p_Vid->mb_size[1][1], currMB->p_Vid->max_pel_value_comp[uv], DQ_BITS);
|
currSlice->mb_rres[uv], 0, 0, p_Vid->mb_size[1][0],
|
||||||
}
|
p_Vid->mb_size[1][1],
|
||||||
else
|
currMB->p_Vid->max_pel_value_comp[uv], DQ_BITS);
|
||||||
{
|
} else {
|
||||||
const unsigned char *x_pos, *y_pos;
|
const unsigned char *x_pos, *y_pos;
|
||||||
for (b8 = 0; b8 < (p_Vid->num_uv_blocks); ++b8)
|
for (b8 = 0; b8 < (p_Vid->num_uv_blocks); ++b8) {
|
||||||
{
|
|
||||||
x_pos = subblk_offset_x[1][b8];
|
x_pos = subblk_offset_x[1][b8];
|
||||||
y_pos = subblk_offset_y[1][b8];
|
y_pos = subblk_offset_y[1][b8];
|
||||||
|
|
||||||
|
@ -757,26 +708,24 @@ void iTransform(Macroblock *currMB, ColorPlane pl, int smb)
|
||||||
itrans4x4_ls(currMB, uv, *x_pos, *y_pos);
|
itrans4x4_ls(currMB, uv, *x_pos, *y_pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
copy_image_data(curUV, mb_rec, currMB->pix_c_x, 0, p_Vid->mb_size[1][0], p_Vid->mb_size[1][1]);
|
copy_image_data(curUV, mb_rec, currMB->pix_c_x, 0, p_Vid->mb_size[1][0],
|
||||||
}
|
p_Vid->mb_size[1][1]);
|
||||||
else if (smb)
|
} else if (smb) {
|
||||||
{
|
currMB->itrans_4x4 =
|
||||||
currMB->itrans_4x4 = (currMB->is_lossless == FALSE) ? itrans4x4 : itrans4x4_ls;
|
(currMB->is_lossless == FALSE) ? itrans4x4 : itrans4x4_ls;
|
||||||
itrans_sp_cr(currMB, uv - 1);
|
itrans_sp_cr(currMB, uv - 1);
|
||||||
|
|
||||||
for (joff = 0; joff < p_Vid->mb_cr_size_y; joff += BLOCK_SIZE)
|
for (joff = 0; joff < p_Vid->mb_cr_size_y; joff += BLOCK_SIZE) {
|
||||||
{
|
for (ioff = 0; ioff < p_Vid->mb_cr_size_x; ioff += BLOCK_SIZE) {
|
||||||
for(ioff = 0; ioff < p_Vid->mb_cr_size_x ;ioff += BLOCK_SIZE)
|
|
||||||
{
|
|
||||||
currMB->itrans_4x4(currMB, uv, ioff, joff);
|
currMB->itrans_4x4(currMB, uv, ioff, joff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_image_data(curUV, mb_rec, currMB->pix_c_x, 0, p_Vid->mb_size[1][0], p_Vid->mb_size[1][1]);
|
copy_image_data(curUV, mb_rec, currMB->pix_c_x, 0, p_Vid->mb_size[1][0],
|
||||||
}
|
p_Vid->mb_size[1][1]);
|
||||||
else
|
} else {
|
||||||
{
|
copy_image_data(curUV, currSlice->mb_pred[uv], currMB->pix_c_x, 0,
|
||||||
copy_image_data(curUV, currSlice->mb_pred[uv], currMB->pix_c_x, 0, p_Vid->mb_size[1][0], p_Vid->mb_size[1][1]);
|
p_Vid->mb_size[1][0], p_Vid->mb_size[1][1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -788,15 +737,18 @@ void iTransform(Macroblock *currMB, ColorPlane pl, int smb)
|
||||||
* Copy ImgPel Data from one structure to another (16x16)
|
* Copy ImgPel Data from one structure to another (16x16)
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
void copy_image_data_16x16(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2)
|
void copy_image_data_16x16(imgpel **imgBuf1, imgpel **imgBuf2, int off1,
|
||||||
{
|
int off2) {
|
||||||
int j;
|
int j;
|
||||||
for(j = 0; j < MB_BLOCK_SIZE; j += 4)
|
for (j = 0; j < MB_BLOCK_SIZE; j += 4) {
|
||||||
{
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2),
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), MB_BLOCK_SIZE * sizeof (imgpel));
|
MB_BLOCK_SIZE * sizeof(imgpel));
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), MB_BLOCK_SIZE * sizeof (imgpel));
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2),
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), MB_BLOCK_SIZE * sizeof (imgpel));
|
MB_BLOCK_SIZE * sizeof(imgpel));
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), MB_BLOCK_SIZE * sizeof (imgpel));
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2),
|
||||||
|
MB_BLOCK_SIZE * sizeof(imgpel));
|
||||||
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2),
|
||||||
|
MB_BLOCK_SIZE * sizeof(imgpel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,58 +758,59 @@ void copy_image_data_16x16(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int o
|
||||||
* Copy ImgPel Data from one structure to another (8x8)
|
* Copy ImgPel Data from one structure to another (8x8)
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
void copy_image_data_8x8(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2)
|
void copy_image_data_8x8(imgpel **imgBuf1, imgpel **imgBuf2, int off1,
|
||||||
{
|
int off2) {
|
||||||
int j;
|
int j;
|
||||||
for(j = 0; j < BLOCK_SIZE_8x8; j+=4)
|
for (j = 0; j < BLOCK_SIZE_8x8; j += 4) {
|
||||||
{
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2),
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), BLOCK_SIZE_8x8 * sizeof (imgpel));
|
BLOCK_SIZE_8x8 * sizeof(imgpel));
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), BLOCK_SIZE_8x8 * sizeof (imgpel));
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2),
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), BLOCK_SIZE_8x8 * sizeof (imgpel));
|
BLOCK_SIZE_8x8 * sizeof(imgpel));
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), BLOCK_SIZE_8x8 * sizeof (imgpel));
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2),
|
||||||
|
BLOCK_SIZE_8x8 * sizeof(imgpel));
|
||||||
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2),
|
||||||
|
BLOCK_SIZE_8x8 * sizeof(imgpel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Copy ImgPel Data from one structure to another (4x4)
|
* Copy ImgPel Data from one structure to another (4x4)
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
void copy_image_data_4x4(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2)
|
void copy_image_data_4x4(imgpel **imgBuf1, imgpel **imgBuf2, int off1,
|
||||||
{
|
int off2) {
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), BLOCK_SIZE * sizeof(imgpel));
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), BLOCK_SIZE * sizeof(imgpel));
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), BLOCK_SIZE * sizeof(imgpel));
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), BLOCK_SIZE * sizeof(imgpel));
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), BLOCK_SIZE * sizeof(imgpel));
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), BLOCK_SIZE * sizeof(imgpel));
|
||||||
memcpy((*imgBuf1 + off1), (*imgBuf2 + off2), BLOCK_SIZE * sizeof(imgpel));
|
memcpy((*imgBuf1 + off1), (*imgBuf2 + off2), BLOCK_SIZE * sizeof(imgpel));
|
||||||
}
|
}
|
||||||
|
|
||||||
int CheckVertMV(Macroblock *currMB, int vec1_y, int block_size_y)
|
int CheckVertMV(Macroblock *currMB, int vec1_y, int block_size_y) {
|
||||||
{
|
|
||||||
VideoParameters *p_Vid = currMB->p_Vid;
|
VideoParameters *p_Vid = currMB->p_Vid;
|
||||||
StorablePicture *dec_picture = currMB->p_Slice->dec_picture;
|
StorablePicture *dec_picture = currMB->p_Slice->dec_picture;
|
||||||
int y_pos = vec1_y >> 2;
|
int y_pos = vec1_y >> 2;
|
||||||
int maxold_y = (currMB->mb_field) ? (dec_picture->size_y >> 1) - 1 : dec_picture->size_y_m1;
|
int maxold_y = (currMB->mb_field) ? (dec_picture->size_y >> 1) - 1
|
||||||
|
: dec_picture->size_y_m1;
|
||||||
|
|
||||||
if(y_pos < (-p_Vid->iLumaPadY + 2) || y_pos > (maxold_y + p_Vid->iLumaPadY - block_size_y - 2))
|
if (y_pos < (-p_Vid->iLumaPadY + 2) ||
|
||||||
|
y_pos > (maxold_y + p_Vid->iLumaPadY - block_size_y - 2))
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Copy ImgPel Data from one structure to another (8x8)
|
* Copy ImgPel Data from one structure to another (8x8)
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
void copy_image_data(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2, int width, int height)
|
void copy_image_data(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2,
|
||||||
{
|
int width, int height) {
|
||||||
int j;
|
int j;
|
||||||
for(j = 0; j < height; ++j)
|
for (j = 0; j < height; ++j) {
|
||||||
{
|
|
||||||
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), width * sizeof(imgpel));
|
memcpy((*imgBuf1++ + off1), (*imgBuf2++ + off2), width * sizeof(imgpel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,39 +6,36 @@
|
||||||
* \brief
|
* \brief
|
||||||
* Configuration handling.
|
* Configuration handling.
|
||||||
* \author
|
* \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>
|
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||||
* \note
|
* \note
|
||||||
* In the future this module should hide the Parameters and offer only
|
* In the future this module should hide the Parameters and offer only
|
||||||
* Functions for their access. Modules which make frequent use of some parameters
|
* Functions for their access. Modules which make frequent use of some
|
||||||
* (e.g. picture size in macroblocks) are free to buffer them on local variables.
|
*parameters (e.g. picture size in macroblocks) are free to buffer them on local
|
||||||
* This will not only avoid global variable and make the code more readable, but also
|
*variables. This will not only avoid global variable and make the code more
|
||||||
* speed it up. It will also greatly facilitate future enhancements such as the
|
*readable, but also speed it up. It will also greatly facilitate future
|
||||||
* handling of different picture sizes in the same sequence. \n
|
*enhancements such as the handling of different picture sizes in the same
|
||||||
* \n
|
*sequence. \n \n For now, everything is just copied to
|
||||||
* For now, everything is just copied to the inp_par structure (gulp)
|
*the inp_par structure (gulp)
|
||||||
*
|
*
|
||||||
**************************************************************************************
|
**************************************************************************************
|
||||||
* \par Configuration File Format
|
* \par Configuration File Format
|
||||||
**************************************************************************************
|
**************************************************************************************
|
||||||
* Format is line oriented, maximum of one parameter per line \n
|
* Format is line oriented, maximum of one parameter per line \n \n Lines have
|
||||||
* \n
|
*the following format: \n
|
||||||
* Lines have the following format: \n
|
* \<ParameterName\> = \<ParameterValue\> # Comments \\n \n Whitespace is space
|
||||||
* \<ParameterName\> = \<ParameterValue\> # Comments \\n \n
|
*and \\t \par
|
||||||
* Whitespace is space and \\t
|
* \<ParameterName\> are the predefined names for Parameters and are case
|
||||||
* \par
|
*sensitive. See configfile.h for the definition of those names and their
|
||||||
* \<ParameterName\> are the predefined names for Parameters and are case sensitive.
|
*mapping to cfgparams->values. \par
|
||||||
* See configfile.h for the definition of those names and their mapping to
|
|
||||||
* cfgparams->values.
|
|
||||||
* \par
|
|
||||||
* \<ParameterValue\> are either integers [0..9]* or strings.
|
* \<ParameterValue\> are either integers [0..9]* or strings.
|
||||||
* Integers must fit into the wordlengths, signed values are generally assumed.
|
* Integers must fit into the wordlengths, signed values are generally
|
||||||
* Strings containing no whitespace characters can be used directly. Strings containing
|
*assumed. Strings containing no whitespace characters can be used directly.
|
||||||
* whitespace characters are to be inclosed in double quotes ("string with whitespace")
|
*Strings containing whitespace characters are to be inclosed in double quotes
|
||||||
* The double quote character is forbidden (may want to implement something smarter here).
|
*("string with whitespace") The double quote character is forbidden (may want
|
||||||
* \par
|
*to implement something smarter here). \par Any Parameters whose ParameterName
|
||||||
* Any Parameters whose ParameterName is undefined lead to the termination of the program
|
*is undefined lead to the termination of the program with an error message.
|
||||||
* with an error message.
|
|
||||||
*
|
*
|
||||||
* \par Known bug/Shortcoming:
|
* \par Known bug/Shortcoming:
|
||||||
* zero-length strings (i.e. to signal an non-existing file
|
* zero-length strings (i.e. to signal an non-existing file
|
||||||
|
@ -46,25 +43,25 @@
|
||||||
*
|
*
|
||||||
* \par Rules for using command files
|
* \par Rules for using command files
|
||||||
* \n
|
* \n
|
||||||
* All Parameters are initially taken from DEFAULTCONFIGFILENAME, defined in configfile.h.
|
* All Parameters are initially taken from DEFAULTCONFIGFILENAME, defined in
|
||||||
* If an -f \<config\> parameter is present in the command line then this file is used to
|
*configfile.h. If an -f \<config\> parameter is present in the command line
|
||||||
* update the defaults of DEFAULTCONFIGFILENAME. There can be more than one -f parameters
|
*then this file is used to update the defaults of DEFAULTCONFIGFILENAME. There
|
||||||
* present. If -p <ParameterName = ParameterValue> parameters are present then these
|
*can be more than one -f parameters present. If -p <ParameterName =
|
||||||
* override the default and the additional config file's settings, and are themselves
|
*ParameterValue> parameters are present then these override the default and the
|
||||||
* overridden by future -p parameters. There must be whitespace between -f and -p commands
|
*additional config file's settings, and are themselves overridden by future -p
|
||||||
* and their respective parameters
|
*parameters. There must be whitespace between -f and -p commands and their
|
||||||
|
*respective parameters
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
#include "global.h"
|
||||||
#include "memalloc.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
|
||||||
#ifdef SPEC_WINDOWS
|
#ifdef SPEC_WINDOWS
|
||||||
|
@ -88,69 +85,66 @@ static int ParameterNameToMapIndex (Mapping *Map, char *s);
|
||||||
* NULL in case of error. Error message will be set in errortext
|
* NULL in case of error. Error message will be set in errortext
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
char *GetConfigFileContent (char *Filename)
|
char *GetConfigFileContent(char *Filename) {
|
||||||
{
|
|
||||||
long FileSize;
|
long FileSize;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (NULL == (f = fopen (Filename, "r")))
|
if (NULL == (f = fopen(Filename, "r"))) {
|
||||||
{
|
snprintf(errortext, ET_SIZE, "Cannot open configuration file %s.",
|
||||||
snprintf (errortext, ET_SIZE, "Cannot open configuration file %s.", Filename);
|
Filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != fseek (f, 0, SEEK_END))
|
if (0 != fseek(f, 0, SEEK_END)) {
|
||||||
{
|
snprintf(errortext, ET_SIZE, "Cannot fseek in configuration file %s.",
|
||||||
snprintf (errortext, ET_SIZE, "Cannot fseek in configuration file %s.", Filename);
|
Filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSize = ftell(f);
|
FileSize = ftell(f);
|
||||||
if (FileSize < 0 || FileSize > 100000)
|
if (FileSize < 0 || FileSize > 100000) {
|
||||||
{
|
snprintf(errortext, ET_SIZE,
|
||||||
snprintf (errortext, ET_SIZE, "Unreasonable Filesize %ld reported by ftell for configuration file %s.", FileSize, Filename);
|
"Unreasonable Filesize %ld reported by ftell for configuration "
|
||||||
|
"file %s.",
|
||||||
|
FileSize, Filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (0 != fseek (f, 0, SEEK_SET))
|
if (0 != fseek(f, 0, SEEK_SET)) {
|
||||||
{
|
snprintf(errortext, ET_SIZE, "Cannot fseek in configuration file %s.",
|
||||||
snprintf (errortext, ET_SIZE, "Cannot fseek in configuration file %s.", Filename);
|
Filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((buf = malloc (FileSize + 1))==NULL) no_mem_exit("GetConfigFileContent: buf");
|
if ((buf = malloc(FileSize + 1)) == NULL)
|
||||||
|
no_mem_exit("GetConfigFileContent: buf");
|
||||||
|
|
||||||
// Note that ftell() gives us the file size as the file system sees it. The actual file size,
|
// Note that ftell() gives us the file size as the file system sees it. The
|
||||||
// as reported by fread() below will be often smaller due to CR/LF to CR conversion and/or
|
// actual file size, as reported by fread() below will be often smaller due to
|
||||||
// control characters after the dos EOF marker in the file.
|
// CR/LF to CR conversion and/or control characters after the dos EOF marker
|
||||||
|
// in the file.
|
||||||
|
|
||||||
FileSize = (long)fread(buf, 1, FileSize, f);
|
FileSize = (long)fread(buf, 1, FileSize, f);
|
||||||
buf[FileSize] = '\0';
|
buf[FileSize] = '\0';
|
||||||
|
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Parses the character array buf and writes global variable input, which is defined in
|
* Parses the character array buf and writes global variable input, which is
|
||||||
* configfile.h. This hack will continue to be necessary to facilitate the addition of
|
*defined in configfile.h. This hack will continue to be necessary to
|
||||||
* new parameters through the Map[] mechanism (Need compiler-generated addresses in map[]).
|
*facilitate the addition of new parameters through the Map[] mechanism (Need
|
||||||
* \param p_Inp
|
*compiler-generated addresses in map[]). \param p_Inp InputParameters of
|
||||||
* InputParameters of configuration
|
*configuration \param Map Mapping structure to specify the name and value
|
||||||
* \param Map
|
*mapping relation \param buf buffer to be parsed \param bufsize buffer size of
|
||||||
* Mapping structure to specify the name and value mapping relation
|
*buffer
|
||||||
* \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};
|
char *items[MAX_ITEMS_TO_PARSE] = {NULL};
|
||||||
int MapIdx;
|
int MapIdx;
|
||||||
int item = 0;
|
int item = 0;
|
||||||
|
@ -161,19 +155,20 @@ void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
||||||
double DoubleContent;
|
double DoubleContent;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Stage one: Generate an argc/argv-type list in items[], without comments and whitespace.
|
// Stage one: Generate an argc/argv-type list in items[], without comments and
|
||||||
// This is context insensitive and could be done most easily with lex(1).
|
// whitespace. This is context insensitive and could be done most easily with
|
||||||
|
// lex(1).
|
||||||
|
|
||||||
while (p < bufend)
|
while (p < bufend) {
|
||||||
{
|
switch (*p) {
|
||||||
switch (*p)
|
|
||||||
{
|
|
||||||
case 13:
|
case 13:
|
||||||
++p;
|
++p;
|
||||||
break;
|
break;
|
||||||
case '#': // Found comment
|
case '#': // Found comment
|
||||||
*p = '\0'; // Replace '#' with '\0' in case of comment immediately following integer or string
|
*p = '\0'; // Replace '#' with '\0' in case of comment immediately
|
||||||
while (*p != '\n' && p < bufend) // Skip till EOL or EOF, whichever comes first
|
// following integer or string
|
||||||
|
while (*p != '\n' &&
|
||||||
|
p < bufend) // Skip till EOL or EOF, whichever comes first
|
||||||
++p;
|
++p;
|
||||||
InString = 0;
|
InString = 0;
|
||||||
InItem = 0;
|
InItem = 0;
|
||||||
|
@ -187,8 +182,7 @@ void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
||||||
case '\t': // Skip whitespace, leave state unchanged
|
case '\t': // Skip whitespace, leave state unchanged
|
||||||
if (InString)
|
if (InString)
|
||||||
p++;
|
p++;
|
||||||
else
|
else { // Terminate non-strings once whitespace is found
|
||||||
{ // Terminate non-strings once whitespace is found
|
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
InItem = 0;
|
InItem = 0;
|
||||||
}
|
}
|
||||||
|
@ -196,19 +190,16 @@ void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
||||||
|
|
||||||
case '"': // Begin/End of String
|
case '"': // Begin/End of String
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
if (!InString)
|
if (!InString) {
|
||||||
{
|
|
||||||
items[item++] = p;
|
items[item++] = p;
|
||||||
InItem = ~InItem;
|
InItem = ~InItem;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
InItem = 0;
|
InItem = 0;
|
||||||
InString = ~InString; // Toggle
|
InString = ~InString; // Toggle
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!InItem)
|
if (!InItem) {
|
||||||
{
|
|
||||||
items[item++] = p;
|
items[item++] = p;
|
||||||
InItem = ~InItem;
|
InItem = ~InItem;
|
||||||
}
|
}
|
||||||
|
@ -218,30 +209,32 @@ void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
||||||
|
|
||||||
item--;
|
item--;
|
||||||
|
|
||||||
for (i=0; i<item; i+= 3)
|
for (i = 0; i < item; i += 3) {
|
||||||
{
|
if (0 > (MapIdx = ParameterNameToMapIndex(Map, items[i]))) {
|
||||||
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);
|
||||||
//snprintf (errortext, ET_SIZE, " Parsing error in config file: Parameter Name '%s' not recognized.", items[i]);
|
printf("\n\tParsing error in config file: Parameter Name '%s' not "
|
||||||
//error (errortext, 300);
|
"recognized.",
|
||||||
printf ("\n\tParsing error in config file: Parameter Name '%s' not recognized.", items[i]);
|
items[i]);
|
||||||
i -= 2;
|
i -= 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (STRCMP ("=", items[i+1]))
|
if (STRCMP("=", items[i + 1])) {
|
||||||
{
|
snprintf(errortext, ET_SIZE,
|
||||||
snprintf (errortext, ET_SIZE, " Parsing error in config file: '=' expected as the second token in each line.");
|
" Parsing error in config file: '=' expected as the second "
|
||||||
|
"token in each line.");
|
||||||
error(errortext, 300);
|
error(errortext, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now interpret the Value, context sensitive...
|
// Now interpret the Value, context sensitive...
|
||||||
|
|
||||||
switch (Map[MapIdx].Type)
|
switch (Map[MapIdx].Type) {
|
||||||
{
|
|
||||||
case 0: // Numerical
|
case 0: // Numerical
|
||||||
if (1 != sscanf (items[i+2], "%d", &IntContent))
|
if (1 != sscanf(items[i + 2], "%d", &IntContent)) {
|
||||||
{
|
snprintf(errortext, ET_SIZE,
|
||||||
snprintf (errortext, ET_SIZE, " Parsing error: Expected numerical value for Parameter of %s, found '%s'.", items[i], items[i+2]);
|
" Parsing error: Expected numerical value for Parameter of "
|
||||||
|
"%s, found '%s'.",
|
||||||
|
items[i], items[i + 2]);
|
||||||
error(errortext, 300);
|
error(errortext, 300);
|
||||||
}
|
}
|
||||||
*(int *)(Map[MapIdx].Place) = IntContent;
|
*(int *)(Map[MapIdx].Place) = IntContent;
|
||||||
|
@ -255,9 +248,11 @@ void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
||||||
printf(".");
|
printf(".");
|
||||||
break;
|
break;
|
||||||
case 2: // Numerical double
|
case 2: // Numerical double
|
||||||
if (1 != sscanf (items[i+2], "%lf", &DoubleContent))
|
if (1 != sscanf(items[i + 2], "%lf", &DoubleContent)) {
|
||||||
{
|
snprintf(errortext, ET_SIZE,
|
||||||
snprintf (errortext, ET_SIZE, " Parsing error: Expected numerical value for Parameter of %s, found '%s'.", items[i], items[i+2]);
|
" Parsing error: Expected numerical value for Parameter of "
|
||||||
|
"%s, found '%s'.",
|
||||||
|
items[i], items[i + 2]);
|
||||||
error(errortext, 300);
|
error(errortext, 300);
|
||||||
}
|
}
|
||||||
*(double *)(Map[MapIdx].Place) = DoubleContent;
|
*(double *)(Map[MapIdx].Place) = DoubleContent;
|
||||||
|
@ -283,8 +278,7 @@ void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
|
||||||
* -1 for error
|
* -1 for error
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
static int ParameterNameToMapIndex (Mapping *Map, char *s)
|
static int ParameterNameToMapIndex(Mapping *Map, char *s) {
|
||||||
{
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (Map[i].TokenName != NULL)
|
while (Map[i].TokenName != NULL)
|
||||||
|
@ -303,12 +297,10 @@ static int ParameterNameToMapIndex (Mapping *Map, char *s)
|
||||||
* -1 for error
|
* -1 for error
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
int InitParams(Mapping *Map)
|
int InitParams(Mapping *Map) {
|
||||||
{
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (Map[i].TokenName != NULL)
|
while (Map[i].TokenName != NULL) {
|
||||||
{
|
|
||||||
if (Map[i].Type == 0)
|
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)
|
else if (Map[i].Type == 2)
|
||||||
|
@ -326,63 +318,64 @@ int InitParams(Mapping *Map)
|
||||||
* -1 for error
|
* -1 for error
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
int TestParams(Mapping *Map, int bitdepth_qp_scale[3])
|
int TestParams(Mapping *Map, int bitdepth_qp_scale[3]) {
|
||||||
{
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (Map[i].TokenName != NULL)
|
while (Map[i].TokenName != NULL) {
|
||||||
{
|
if (Map[i].param_limits == 1) {
|
||||||
if (Map[i].param_limits == 1)
|
if (Map[i].Type == 0) {
|
||||||
{
|
if (*(int *)(Map[i].Place) < (int)Map[i].min_limit ||
|
||||||
if (Map[i].Type == 0)
|
*(int *)(Map[i].Place) > (int)Map[i].max_limit) {
|
||||||
{
|
snprintf(errortext, ET_SIZE,
|
||||||
if ( * (int *) (Map[i].Place) < (int) Map[i].min_limit || * (int *) (Map[i].Place) > (int) Map[i].max_limit )
|
"Error in input parameter %s. Check configuration file. "
|
||||||
{
|
"Value should be in [%d, %d] range.",
|
||||||
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 );
|
Map[i].TokenName, (int)Map[i].min_limit,
|
||||||
|
(int)Map[i].max_limit);
|
||||||
error(errortext, 400);
|
error(errortext, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if (Map[i].Type == 2) {
|
||||||
else if (Map[i].Type == 2)
|
if (*(double *)(Map[i].Place) < Map[i].min_limit ||
|
||||||
{
|
*(double *)(Map[i].Place) > Map[i].max_limit) {
|
||||||
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. "
|
||||||
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 );
|
"Value should be in [%.2f, %.2f] range.",
|
||||||
|
Map[i].TokenName, Map[i].min_limit, Map[i].max_limit);
|
||||||
error(errortext, 400);
|
error(errortext, 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} 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].param_limits == 2)
|
} else if (Map[i].Type == 2) {
|
||||||
{
|
if (*(double *)(Map[i].Place) < Map[i].min_limit) {
|
||||||
if (Map[i].Type == 0)
|
snprintf(errortext, ET_SIZE,
|
||||||
{
|
"Error in input parameter %s. Check configuration file. "
|
||||||
if ( * (int *) (Map[i].Place) < (int) Map[i].min_limit )
|
"Value should not be smaller than %2.f.",
|
||||||
{
|
Map[i].TokenName, 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);
|
error(errortext, 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Map[i].Type == 2)
|
} else if (Map[i].param_limits == 3) // Only used for QPs
|
||||||
{
|
|
||||||
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 (Map[i].Type == 0) {
|
||||||
{
|
|
||||||
int cur_qp = *(int *)(Map[i].Place);
|
int cur_qp = *(int *)(Map[i].Place);
|
||||||
int min_qp = (int) (Map[i].min_limit - (bitdepth_qp_scale? bitdepth_qp_scale[0]: 0));
|
int min_qp = (int)(Map[i].min_limit -
|
||||||
|
(bitdepth_qp_scale ? bitdepth_qp_scale[0] : 0));
|
||||||
int max_qp = (int)Map[i].max_limit;
|
int max_qp = (int)Map[i].max_limit;
|
||||||
|
|
||||||
if (( cur_qp < min_qp ) || ( cur_qp > max_qp ))
|
if ((cur_qp < min_qp) || (cur_qp > max_qp)) {
|
||||||
{
|
snprintf(errortext, ET_SIZE,
|
||||||
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 in input parameter %s. Check configuration file. "
|
||||||
|
"Value should be in [%d, %d] range.",
|
||||||
|
Map[i].TokenName, min_qp, max_qp);
|
||||||
error(errortext, 400);
|
error(errortext, 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,8 +386,6 @@ int TestParams(Mapping *Map, int bitdepth_qp_scale[3])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -403,24 +394,25 @@ int TestParams(Mapping *Map, int bitdepth_qp_scale[3])
|
||||||
* -1 for error
|
* -1 for error
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
int DisplayParams(Mapping *Map, char *message)
|
int DisplayParams(Mapping *Map, char *message) {
|
||||||
{
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
printf("******************************************************\n");
|
printf("******************************************************\n");
|
||||||
printf("* %s *\n", message);
|
printf("* %s *\n", message);
|
||||||
printf("******************************************************\n");
|
printf("******************************************************\n");
|
||||||
while (Map[i].TokenName != NULL)
|
while (Map[i].TokenName != NULL) {
|
||||||
{
|
|
||||||
if (Map[i].Type == 0)
|
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)
|
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)
|
else if (Map[i].Type == 2)
|
||||||
printf("Parameter %s = %.2f\n",Map[i].TokenName,* (double *) (Map[i].Place));
|
printf("Parameter %s = %.2f\n", Map[i].TokenName,
|
||||||
|
*(double *)(Map[i].Place));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
printf("******************************************************\n");
|
printf("******************************************************\n");
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,39 +6,36 @@
|
||||||
* \brief
|
* \brief
|
||||||
* Configuration handling.
|
* Configuration handling.
|
||||||
* \author
|
* \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>
|
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||||
* \note
|
* \note
|
||||||
* In the future this module should hide the Parameters and offer only
|
* In the future this module should hide the Parameters and offer only
|
||||||
* Functions for their access. Modules which make frequent use of some parameters
|
* Functions for their access. Modules which make frequent use of some
|
||||||
* (e.g. picture size in macroblocks) are free to buffer them on local variables.
|
*parameters (e.g. picture size in macroblocks) are free to buffer them on local
|
||||||
* This will not only avoid global variable and make the code more readable, but also
|
*variables. This will not only avoid global variable and make the code more
|
||||||
* speed it up. It will also greatly facilitate future enhancements such as the
|
*readable, but also speed it up. It will also greatly facilitate future
|
||||||
* handling of different picture sizes in the same sequence. \n
|
*enhancements such as the handling of different picture sizes in the same
|
||||||
* \n
|
*sequence. \n \n For now, everything is just copied to
|
||||||
* For now, everything is just copied to the inp_par structure (gulp)
|
*the inp_par structure (gulp)
|
||||||
*
|
*
|
||||||
**************************************************************************************
|
**************************************************************************************
|
||||||
* \par Configuration File Format
|
* \par Configuration File Format
|
||||||
**************************************************************************************
|
**************************************************************************************
|
||||||
* Format is line oriented, maximum of one parameter per line \n
|
* Format is line oriented, maximum of one parameter per line \n \n Lines have
|
||||||
* \n
|
*the following format: \n
|
||||||
* Lines have the following format: \n
|
* \<ParameterName\> = \<ParameterValue\> # Comments \\n \n Whitespace is space
|
||||||
* \<ParameterName\> = \<ParameterValue\> # Comments \\n \n
|
*and \\t \par
|
||||||
* Whitespace is space and \\t
|
* \<ParameterName\> are the predefined names for Parameters and are case
|
||||||
* \par
|
*sensitive. See configfile.h for the definition of those names and their
|
||||||
* \<ParameterName\> are the predefined names for Parameters and are case sensitive.
|
*mapping to cfgparams->values. \par
|
||||||
* See configfile.h for the definition of those names and their mapping to
|
|
||||||
* cfgparams->values.
|
|
||||||
* \par
|
|
||||||
* \<ParameterValue\> are either integers [0..9]* or strings.
|
* \<ParameterValue\> are either integers [0..9]* or strings.
|
||||||
* Integers must fit into the wordlengths, signed values are generally assumed.
|
* Integers must fit into the wordlengths, signed values are generally
|
||||||
* Strings containing no whitespace characters can be used directly. Strings containing
|
*assumed. Strings containing no whitespace characters can be used directly.
|
||||||
* whitespace characters are to be inclosed in double quotes ("string with whitespace")
|
*Strings containing whitespace characters are to be inclosed in double quotes
|
||||||
* The double quote character is forbidden (may want to implement something smarter here).
|
*("string with whitespace") The double quote character is forbidden (may want
|
||||||
* \par
|
*to implement something smarter here). \par Any Parameters whose ParameterName
|
||||||
* Any Parameters whose ParameterName is undefined lead to the termination of the program
|
*is undefined lead to the termination of the program with an error message.
|
||||||
* with an error message.
|
|
||||||
*
|
*
|
||||||
* \par Known bug/Shortcoming:
|
* \par Known bug/Shortcoming:
|
||||||
* zero-length strings (i.e. to signal an non-existing file
|
* zero-length strings (i.e. to signal an non-existing file
|
||||||
|
@ -46,13 +43,14 @@
|
||||||
*
|
*
|
||||||
* \par Rules for using command files
|
* \par Rules for using command files
|
||||||
* \n
|
* \n
|
||||||
* All Parameters are initially taken from DEFAULTCONFIGFILENAME, defined in configfile.h.
|
* All Parameters are initially taken from DEFAULTCONFIGFILENAME, defined in
|
||||||
* If an -f \<config\> parameter is present in the command line then this file is used to
|
*configfile.h. If an -f \<config\> parameter is present in the command line
|
||||||
* update the defaults of DEFAULTCONFIGFILENAME. There can be more than one -f parameters
|
*then this file is used to update the defaults of DEFAULTCONFIGFILENAME. There
|
||||||
* present. If -p <ParameterName = ParameterValue> parameters are present then these
|
*can be more than one -f parameters present. If -p <ParameterName =
|
||||||
* override the default and the additional config file's settings, and are themselves
|
*ParameterValue> parameters are present then these override the default and the
|
||||||
* overridden by future -p parameters. There must be whitespace between -f and -p commands
|
*additional config file's settings, and are themselves overridden by future -p
|
||||||
* and their respective parameters
|
*parameters. There must be whitespace between -f and -p commands and their
|
||||||
|
*respective parameters
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -60,10 +58,10 @@
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "memalloc.h"
|
|
||||||
#include "config_common.h"
|
#include "config_common.h"
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
#include "global.h"
|
||||||
|
#include "memalloc.h"
|
||||||
#define MAX_ITEMS_TO_PARSE 10000
|
#define MAX_ITEMS_TO_PARSE 10000
|
||||||
|
|
||||||
static void PatchInp(InputParameters *p_Inp);
|
static void PatchInp(InputParameters *p_Inp);
|
||||||
|
@ -74,42 +72,45 @@ static void PatchInp (InputParameters *p_Inp);
|
||||||
* print help message and exit
|
* print help message and exit
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
void JMDecHelpExit (void)
|
void JMDecHelpExit(void) {
|
||||||
{
|
fprintf(
|
||||||
fprintf( stderr, "\n ldecod [-h] [-d defdec.cfg] {[-f curenc1.cfg]...[-f curencN.cfg]}"
|
stderr,
|
||||||
|
"\n ldecod [-h] [-d defdec.cfg] {[-f curenc1.cfg]...[-f curencN.cfg]}"
|
||||||
" {[-p EncParam1=EncValue1]..[-p EncParamM=EncValueM]}\n\n"
|
" {[-p EncParam1=EncValue1]..[-p EncParamM=EncValueM]}\n\n"
|
||||||
"## Parameters\n\n"
|
"## Parameters\n\n"
|
||||||
|
|
||||||
"## Options\n"
|
"## Options\n"
|
||||||
" -h : prints function usage\n"
|
" -h : prints function usage\n"
|
||||||
" -d : use <defdec.cfg> as default file for parameter initializations.\n"
|
" -d : use <defdec.cfg> as default file for parameter "
|
||||||
" If not used then file defaults to encoder.cfg in local directory.\n"
|
"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"
|
" -f : read <curencM.cfg> for reseting selected encoder parameters.\n"
|
||||||
" Multiple files could be used that set different parameters\n"
|
" Multiple files could be used that set different parameters\n"
|
||||||
" -p : Set parameter <DecParamM> to <DecValueM>.\n"
|
" -p : Set parameter <DecParamM> to <DecValueM>.\n"
|
||||||
" See default decoder.cfg file for description of all parameters.\n\n"
|
" See default decoder.cfg file for description of all "
|
||||||
|
"parameters.\n\n"
|
||||||
|
|
||||||
"## Examples of usage:\n"
|
"## Examples of usage:\n"
|
||||||
" ldecod\n"
|
" ldecod\n"
|
||||||
" ldecod -h\n"
|
" ldecod -h\n"
|
||||||
" ldecod -d default.cfg\n"
|
" ldecod -d default.cfg\n"
|
||||||
" ldecod -f curenc1.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");
|
" ldecod -f curenc1.cfg -p "
|
||||||
|
"InputFile=\"e:\\data\\container_qcif_30.264\" -p OutputFile=\"dec.yuv\" "
|
||||||
|
"-p RefFile=\"Rec.yuv\"\n");
|
||||||
|
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* exit with error message if reading from config file failed
|
* exit with error message if reading from config file failed
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static inline void conf_read_check (int val, int expected)
|
static inline void conf_read_check(int val, int expected) {
|
||||||
{
|
if (val != expected) {
|
||||||
if (val != expected)
|
|
||||||
{
|
|
||||||
error("init_conf: error reading from config file", 500);
|
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
|
* command line parameters
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
void ParseCommand(InputParameters *p_Inp, int ac, char *av[]) {
|
||||||
{
|
|
||||||
char *content = NULL;
|
char *content = NULL;
|
||||||
int CLcount, ContentLen, NumberParams;
|
int CLcount, ContentLen, NumberParams;
|
||||||
char *filename = DEFAULTCONFIGFILENAME;
|
char *filename = DEFAULTCONFIGFILENAME;
|
||||||
|
|
||||||
if (ac==2)
|
if (ac == 2) {
|
||||||
{
|
if (0 == strncmp(av[1], "-v", 2)) {
|
||||||
if (0 == strncmp (av[1], "-v", 2))
|
|
||||||
{
|
|
||||||
#if !defined(SPEC)
|
#if !defined(SPEC)
|
||||||
printf("JM " JM ": compiled " __DATE__ " " __TIME__ "\n");
|
printf("JM " JM ": compiled " __DATE__ " " __TIME__ "\n");
|
||||||
#else
|
#else
|
||||||
|
@ -146,8 +144,7 @@ void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strncmp (av[1], "-h", 2))
|
if (0 == strncmp(av[1], "-h", 2)) {
|
||||||
{
|
|
||||||
JMDecHelpExit();
|
JMDecHelpExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,27 +157,22 @@ void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
||||||
// Process default config file
|
// Process default config file
|
||||||
CLcount = 1;
|
CLcount = 1;
|
||||||
|
|
||||||
if (ac>=3)
|
if (ac >= 3) {
|
||||||
{
|
if (0 == strncmp(av[1], "-d", 2)) {
|
||||||
if (0 == strncmp (av[1], "-d", 2))
|
|
||||||
{
|
|
||||||
if (0 == strncmp(av[2], "null", 4))
|
if (0 == strncmp(av[2], "null", 4))
|
||||||
filename = NULL;
|
filename = NULL;
|
||||||
else
|
else
|
||||||
filename = av[2];
|
filename = av[2];
|
||||||
CLcount = 3;
|
CLcount = 3;
|
||||||
}
|
}
|
||||||
if (0 == strncmp (av[1], "-h", 2))
|
if (0 == strncmp(av[1], "-h", 2)) {
|
||||||
{
|
|
||||||
JMDecHelpExit();
|
JMDecHelpExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(filename)
|
if (filename) {
|
||||||
{
|
|
||||||
printf("Parsing Configfile %s\n", filename);
|
printf("Parsing Configfile %s\n", filename);
|
||||||
content = GetConfigFileContent(filename);
|
content = GetConfigFileContent(filename);
|
||||||
if (NULL != content)
|
if (NULL != content) {
|
||||||
{
|
|
||||||
// error (errortext, 300);
|
// error (errortext, 300);
|
||||||
ParseContent(p_Inp, Map, content, (int)strlen(content));
|
ParseContent(p_Inp, Map, content, (int)strlen(content));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -189,14 +181,13 @@ void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
||||||
}
|
}
|
||||||
// Parse the command line
|
// Parse the command line
|
||||||
|
|
||||||
while (CLcount < ac)
|
while (CLcount < ac) {
|
||||||
{
|
if (0 == strncmp(av[CLcount], "-h", 2)) {
|
||||||
if (0 == strncmp (av[CLcount], "-h", 2))
|
|
||||||
{
|
|
||||||
JMDecHelpExit();
|
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]);
|
content = GetConfigFileContent(av[CLcount + 1]);
|
||||||
if (NULL == content)
|
if (NULL == content)
|
||||||
|
@ -206,43 +197,46 @@ void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
||||||
printf("\n");
|
printf("\n");
|
||||||
free(content);
|
free(content);
|
||||||
CLcount += 2;
|
CLcount += 2;
|
||||||
}
|
} else if (0 == strncmp(av[CLcount], "-i", 2) ||
|
||||||
else if (0 == strncmp (av[CLcount], "-i", 2) || 0 == strncmp (av[CLcount], "-I", 2)) // A file parameter?
|
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;
|
CLcount += 2;
|
||||||
}
|
} else if (0 == strncmp(av[CLcount], "-r", 2) ||
|
||||||
else if (0 == strncmp (av[CLcount], "-r", 2) || 0 == strncmp (av[CLcount], "-R", 2)) // A file parameter?
|
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;
|
CLcount += 2;
|
||||||
}
|
} else if (0 == strncmp(av[CLcount], "-o", 2) ||
|
||||||
else if (0 == strncmp (av[CLcount], "-o", 2) || 0 == strncmp (av[CLcount], "-O", 2)) // A file parameter?
|
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;
|
CLcount += 2;
|
||||||
}
|
} else if (0 == strncmp(av[CLcount], "-s", 2) ||
|
||||||
else if (0 == strncmp (av[CLcount], "-s", 2) || 0 == strncmp (av[CLcount], "-S", 2)) // A file parameter?
|
0 == strncmp(av[CLcount], "-S", 2)) // A file parameter?
|
||||||
{
|
{
|
||||||
p_Inp->silent = 1;
|
p_Inp->silent = 1;
|
||||||
CLcount += 1;
|
CLcount += 1;
|
||||||
}
|
} else if (0 == strncmp(av[CLcount], "-n", 2) ||
|
||||||
else if (0 == strncmp (av[CLcount], "-n", 2) || 0 == strncmp (av[CLcount], "-N", 2)) // A file parameter?
|
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;
|
CLcount += 2;
|
||||||
}
|
}
|
||||||
#if (MVC_EXTENSION_ENABLE)
|
#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;
|
CLcount += 2;
|
||||||
}
|
}
|
||||||
#endif
|
#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)),
|
// Collect all data until next parameter (starting with -<x> (x is any
|
||||||
// put it into content, and parse content.
|
// character)), put it into content, and parse content.
|
||||||
|
|
||||||
++CLcount;
|
++CLcount;
|
||||||
ContentLen = 0;
|
ContentLen = 0;
|
||||||
|
@ -250,27 +244,29 @@ void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
||||||
|
|
||||||
// determine the necessary size for content
|
// determine the necessary size for content
|
||||||
while (NumberParams < ac && av[NumberParams][0] != '-')
|
while (NumberParams < ac && av[NumberParams][0] != '-')
|
||||||
ContentLen += (int) strlen (av[NumberParams++]); // Space for all the strings
|
ContentLen +=
|
||||||
|
(int)strlen(av[NumberParams++]); // Space for all the strings
|
||||||
ContentLen += 1000; // Additional 1000 bytes for spaces and \0s
|
ContentLen += 1000; // Additional 1000 bytes for spaces and \0s
|
||||||
|
|
||||||
|
if ((content = malloc(ContentLen)) == NULL)
|
||||||
if ((content = malloc (ContentLen))==NULL) no_mem_exit("Configure: content");;
|
no_mem_exit("Configure: content");
|
||||||
|
;
|
||||||
content[0] = '\0';
|
content[0] = '\0';
|
||||||
|
|
||||||
// concatenate all parameters identified before
|
// concatenate all parameters identified before
|
||||||
|
|
||||||
while (CLcount < NumberParams)
|
while (CLcount < NumberParams) {
|
||||||
{
|
|
||||||
char *source = &av[CLcount][0];
|
char *source = &av[CLcount][0];
|
||||||
char *destin = &content[(int)strlen(content)];
|
char *destin = &content[(int)strlen(content)];
|
||||||
|
|
||||||
while (*source != '\0')
|
while (*source != '\0') {
|
||||||
|
if (*source ==
|
||||||
|
'=') // The Parser expects whitespace before and after '='
|
||||||
{
|
{
|
||||||
if (*source == '=') // The Parser expects whitespace before and after '='
|
*destin++ = ' ';
|
||||||
{
|
*destin++ = '=';
|
||||||
*destin++=' '; *destin++='='; *destin++=' '; // Hence make sure we add it
|
*destin++ = ' '; // Hence make sure we add it
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
*destin++ = *source;
|
*destin++ = *source;
|
||||||
source++;
|
source++;
|
||||||
}
|
}
|
||||||
|
@ -281,10 +277,11 @@ void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
||||||
ParseContent(p_Inp, Map, content, (int)strlen(content));
|
ParseContent(p_Inp, Map, content, (int)strlen(content));
|
||||||
free(content);
|
free(content);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
} else {
|
||||||
else
|
snprintf(errortext, ET_SIZE,
|
||||||
{
|
"Error in command line, ac %d, around string '%s', missing -f "
|
||||||
snprintf (errortext, ET_SIZE, "Error in command line, ac %d, around string '%s', missing -f or -p parameters?", CLcount, av[CLcount]);
|
"or -p parameters?",
|
||||||
|
CLcount, av[CLcount]);
|
||||||
error(errortext, 300);
|
error(errortext, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,19 +294,15 @@ void ParseCommand(InputParameters *p_Inp, int ac, char *av[])
|
||||||
DisplayParams(Map, "Decoder Parameters");
|
DisplayParams(Map, "Decoder Parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Checks the input parameters for consistency.
|
* Checks the input parameters for consistency.
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
static void PatchInp (InputParameters *p_Inp)
|
static void PatchInp(InputParameters *p_Inp) {
|
||||||
{
|
|
||||||
// int i;
|
// int i;
|
||||||
// int storedBplus1;
|
// int storedBplus1;
|
||||||
|
|
||||||
TestParams(Map, NULL);
|
TestParams(Map, NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
* CABAC context initializations
|
* CABAC context initializations
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Detlev Marpe <marpe@hhi.de>
|
||||||
* - Heiko Schwarz <hschwarz@hhi.de>
|
* - Heiko Schwarz <hschwarz@hhi.de>
|
||||||
**************************************************************************************
|
**************************************************************************************
|
||||||
|
@ -15,17 +16,15 @@
|
||||||
|
|
||||||
#define CONTEXT_INI_C
|
#define CONTEXT_INI_C
|
||||||
|
|
||||||
#include "defines.h"
|
|
||||||
#include "global.h"
|
|
||||||
#include "biaridecod.h"
|
#include "biaridecod.h"
|
||||||
#include "ctx_tables.h"
|
#include "ctx_tables.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
#define IBIARI_CTX_INIT2(ii, jj, ctx, tab, num, qp) \
|
#define IBIARI_CTX_INIT2(ii, jj, ctx, tab, num, qp) \
|
||||||
{ \
|
{ \
|
||||||
for (i = 0; i < ii; ++i) \
|
for (i = 0; i < ii; ++i) \
|
||||||
for (j=0; j<jj; ++j) \
|
for (j = 0; j < jj; ++j) { \
|
||||||
{ \
|
|
||||||
biari_init_context(qp, &(ctx[i][j]), tab##_I[num][i][j]); \
|
biari_init_context(qp, &(ctx[i][j]), tab##_I[num][i][j]); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
@ -33,34 +32,26 @@
|
||||||
#define PBIARI_CTX_INIT2(ii, jj, ctx, tab, num, qp) \
|
#define PBIARI_CTX_INIT2(ii, jj, ctx, tab, num, qp) \
|
||||||
{ \
|
{ \
|
||||||
for (i = 0; i < ii; ++i) \
|
for (i = 0; i < ii; ++i) \
|
||||||
for (j=0; j<jj; ++j) \
|
for (j = 0; j < jj; ++j) { \
|
||||||
{ \
|
|
||||||
biari_init_context(qp, &(ctx[i][j]), tab##_P[num][i][j]); \
|
biari_init_context(qp, &(ctx[i][j]), tab##_P[num][i][j]); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define IBIARI_CTX_INIT1(jj, ctx, tab, num, qp) \
|
#define IBIARI_CTX_INIT1(jj, ctx, tab, num, qp) \
|
||||||
{ \
|
{ \
|
||||||
for (j=0; j<jj; ++j) \
|
for (j = 0; j < jj; ++j) { \
|
||||||
{ \
|
|
||||||
biari_init_context(qp, &(ctx[j]), tab##_I[num][0][j]); \
|
biari_init_context(qp, &(ctx[j]), tab##_I[num][0][j]); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define PBIARI_CTX_INIT1(jj, ctx, tab, num, qp) \
|
#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]); \
|
||||||
for (j=0; j<jj; ++j) \
|
|
||||||
{ \
|
|
||||||
biari_init_context (qp, &(ctx[j]), tab ## _P[num][0][j]); \
|
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_contexts (Slice *currSlice)
|
void init_contexts(Slice *currSlice) {
|
||||||
{
|
|
||||||
MotionInfoContexts *mc = currSlice->mot_ctx;
|
MotionInfoContexts *mc = currSlice->mot_ctx;
|
||||||
TextureInfoContexts *tc = currSlice->tex_ctx;
|
TextureInfoContexts *tc = currSlice->tex_ctx;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -70,53 +61,82 @@ void init_contexts (Slice *currSlice)
|
||||||
// printf("%d -", p_Vid->currentSlice->model_number);
|
// printf("%d -", p_Vid->currentSlice->model_number);
|
||||||
|
|
||||||
//--- motion coding contexts ---
|
//--- motion coding contexts ---
|
||||||
if ((currSlice->slice_type == I_SLICE)||(currSlice->slice_type == SI_SLICE))
|
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(3, NUM_MB_TYPE_CTX, mc->mb_type_contexts, INIT_MB_TYPE,
|
||||||
IBIARI_CTX_INIT2 (2, NUM_B8_TYPE_CTX, mc->b8_type_contexts, INIT_B8_TYPE, model_number, qp);
|
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_B8_TYPE_CTX, mc->b8_type_contexts, INIT_B8_TYPE,
|
||||||
IBIARI_CTX_INIT2 (2, NUM_REF_NO_CTX, mc->ref_no_contexts, INIT_REF_NO, model_number, qp);
|
model_number, qp);
|
||||||
IBIARI_CTX_INIT1 ( NUM_DELTA_QP_CTX, mc->delta_qp_contexts, INIT_DELTA_QP, model_number, qp);
|
IBIARI_CTX_INIT2(2, NUM_MV_RES_CTX, mc->mv_res_contexts, INIT_MV_RES,
|
||||||
IBIARI_CTX_INIT1 ( NUM_MB_AFF_CTX, mc->mb_aff_contexts, INIT_MB_AFF, model_number, qp);
|
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 ---
|
//--- texture coding contexts ---
|
||||||
IBIARI_CTX_INIT1 ( NUM_TRANSFORM_SIZE_CTX, tc->transform_size_contexts, INIT_TRANSFORM_SIZE, 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_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_INIT1(NUM_CIPR_CTX, tc->cipr_contexts, INIT_CIPR, model_number,
|
||||||
IBIARI_CTX_INIT2 (3, NUM_CBP_CTX, tc->cbp_contexts, INIT_CBP, model_number, qp);
|
qp);
|
||||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_BCBP_CTX, tc->bcbp_contexts, INIT_BCBP, model_number, qp);
|
IBIARI_CTX_INIT2(3, NUM_CBP_CTX, tc->cbp_contexts, INIT_CBP, model_number,
|
||||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[0], INIT_MAP, model_number, qp);
|
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
|
#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_MAP_CTX, tc->map_contexts[1],
|
||||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[1], INIT_FLD_LAST, model_number, qp);
|
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
|
#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_LAST_CTX, tc->last_contexts[0],
|
||||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ONE_CTX, tc->one_contexts, INIT_ONE, model_number, qp);
|
INIT_LAST, model_number, qp);
|
||||||
IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ABS_CTX, tc->abs_contexts, INIT_ABS, model_number, qp);
|
IBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_ONE_CTX, tc->one_contexts, INIT_ONE,
|
||||||
}
|
model_number, qp);
|
||||||
else
|
IBIARI_CTX_INIT2(NUM_BLOCK_TYPES, NUM_ABS_CTX, tc->abs_contexts, INIT_ABS,
|
||||||
{
|
model_number, qp);
|
||||||
PBIARI_CTX_INIT2 (3, NUM_MB_TYPE_CTX, mc->mb_type_contexts, INIT_MB_TYPE, model_number, qp);
|
} else {
|
||||||
PBIARI_CTX_INIT2 (2, NUM_B8_TYPE_CTX, mc->b8_type_contexts, INIT_B8_TYPE, model_number, qp);
|
PBIARI_CTX_INIT2(3, NUM_MB_TYPE_CTX, mc->mb_type_contexts, INIT_MB_TYPE,
|
||||||
PBIARI_CTX_INIT2 (2, NUM_MV_RES_CTX, mc->mv_res_contexts, INIT_MV_RES, model_number, qp);
|
model_number, qp);
|
||||||
PBIARI_CTX_INIT2 (2, NUM_REF_NO_CTX, mc->ref_no_contexts, INIT_REF_NO, model_number, qp);
|
PBIARI_CTX_INIT2(2, NUM_B8_TYPE_CTX, mc->b8_type_contexts, INIT_B8_TYPE,
|
||||||
PBIARI_CTX_INIT1 ( NUM_DELTA_QP_CTX, mc->delta_qp_contexts, INIT_DELTA_QP, model_number, qp);
|
model_number, qp);
|
||||||
PBIARI_CTX_INIT1 ( NUM_MB_AFF_CTX, mc->mb_aff_contexts, INIT_MB_AFF, 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 ---
|
//--- texture coding contexts ---
|
||||||
PBIARI_CTX_INIT1 ( NUM_TRANSFORM_SIZE_CTX, tc->transform_size_contexts, INIT_TRANSFORM_SIZE, 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_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_INIT1(NUM_CIPR_CTX, tc->cipr_contexts, INIT_CIPR, model_number,
|
||||||
PBIARI_CTX_INIT2 (3, NUM_CBP_CTX, tc->cbp_contexts, INIT_CBP, model_number, qp);
|
qp);
|
||||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_BCBP_CTX, tc->bcbp_contexts, INIT_BCBP, model_number, qp);
|
PBIARI_CTX_INIT2(3, NUM_CBP_CTX, tc->cbp_contexts, INIT_CBP, model_number,
|
||||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[0], INIT_MAP, model_number, qp);
|
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
|
#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_MAP_CTX, tc->map_contexts[1],
|
||||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[1], INIT_FLD_LAST, model_number, qp);
|
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
|
#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_LAST_CTX, tc->last_contexts[0],
|
||||||
PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ONE_CTX, tc->one_contexts, INIT_ONE, model_number, qp);
|
INIT_LAST, 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_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* \brief
|
* \brief
|
||||||
* H.264/AVC decoder test
|
* H.264/AVC decoder test
|
||||||
* \author
|
* \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>
|
* - Yuwen He <yhe@dolby.com>
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -16,8 +17,8 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
// #include "global.h"
|
// #include "global.h"
|
||||||
#include "h264decoder.h"
|
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
#include "h264decoder.h"
|
||||||
|
|
||||||
#define DECOUTPUT_TEST 0
|
#define DECOUTPUT_TEST 0
|
||||||
|
|
||||||
|
@ -28,9 +29,7 @@
|
||||||
#define DECOUTPUT_VIEW0_FILENAME "H264_Decoder_Output_View0.yuv"
|
#define DECOUTPUT_VIEW0_FILENAME "H264_Decoder_Output_View0.yuv"
|
||||||
#define DECOUTPUT_VIEW1_FILENAME "H264_Decoder_Output_View1.yuv"
|
#define DECOUTPUT_VIEW1_FILENAME "H264_Decoder_Output_View1.yuv"
|
||||||
|
|
||||||
|
static void Configure(InputParameters *p_Inp, int ac, char *av[]) {
|
||||||
static void Configure(InputParameters *p_Inp, int ac, char *av[])
|
|
||||||
{
|
|
||||||
// char *config_filename=NULL;
|
// char *config_filename=NULL;
|
||||||
// char errortext[ET_SIZE];
|
// char errortext[ET_SIZE];
|
||||||
memset(p_Inp, 0, sizeof(InputParameters));
|
memset(p_Inp, 0, sizeof(InputParameters));
|
||||||
|
@ -48,7 +47,9 @@ static void Configure(InputParameters *p_Inp, int ac, char *av[])
|
||||||
p_Inp->R_decoder = 500000; //! Decoder rate
|
p_Inp->R_decoder = 500000; //! Decoder rate
|
||||||
p_Inp->B_decoder = 104000; //! Decoder buffer size
|
p_Inp->B_decoder = 104000; //! Decoder buffer size
|
||||||
p_Inp->F_decoder = 73000; //! Decoder initial delay
|
p_Inp->F_decoder = 73000; //! Decoder initial delay
|
||||||
strcpy(p_Inp->LeakyBucketParamFile,"leakybucketparam.cfg"); // file where Leaky Bucket parameters (computed by encoder) are stored
|
strcpy(p_Inp->LeakyBucketParamFile,
|
||||||
|
"leakybucketparam.cfg"); // file where Leaky Bucket parameters
|
||||||
|
// (computed by encoder) are stored
|
||||||
#endif
|
#endif
|
||||||
p_Inp->iDecFrmNum = 0;
|
p_Inp->iDecFrmNum = 0;
|
||||||
|
|
||||||
|
@ -60,48 +61,60 @@ static void Configure(InputParameters *p_Inp, int ac, char *av[])
|
||||||
|
|
||||||
ParseCommand(p_Inp, ac, av);
|
ParseCommand(p_Inp, ac, av);
|
||||||
|
|
||||||
fprintf(stdout,"----------------------------- JM %s %s -----------------------------\n", VERSION, EXT_VERSION);
|
fprintf(
|
||||||
//fprintf(stdout," Decoder config file : %s \n",config_filename);
|
stdout,
|
||||||
if(!p_Inp->bDisplayDecParams)
|
"----------------------------- JM %s %s -----------------------------\n",
|
||||||
{
|
VERSION, EXT_VERSION);
|
||||||
fprintf(stdout,"--------------------------------------------------------------------------\n");
|
// fprintf(stdout," Decoder config file : %s
|
||||||
fprintf(stdout," Input H.264 bitstream : %s \n",p_Inp->infile);
|
// \n",config_filename);
|
||||||
fprintf(stdout," Output decoded YUV : %s \n",p_Inp->outfile);
|
if (!p_Inp->bDisplayDecParams) {
|
||||||
//fprintf(stdout," Output status file : %s \n",LOGFILE);
|
fprintf(stdout, "----------------------------------------------------------"
|
||||||
fprintf(stdout," Input reference file : %s \n",p_Inp->reffile);
|
"----------------\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");
|
fprintf(stdout, "----------------------------------------------------------"
|
||||||
|
"----------------\n");
|
||||||
#ifdef _LEAKYBUCKET_
|
#ifdef _LEAKYBUCKET_
|
||||||
fprintf(stdout, " Rate_decoder : %8ld \n", p_Inp->R_decoder);
|
fprintf(stdout, " Rate_decoder : %8ld \n", p_Inp->R_decoder);
|
||||||
fprintf(stdout, " B_decoder : %8ld \n", p_Inp->B_decoder);
|
fprintf(stdout, " B_decoder : %8ld \n", p_Inp->B_decoder);
|
||||||
fprintf(stdout, " F_decoder : %8ld \n", p_Inp->F_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, " LeakyBucketParamFile: %s \n",
|
||||||
|
p_Inp->LeakyBucketParamFile); // Leaky Bucket Param file
|
||||||
calc_buffer(p_Inp);
|
calc_buffer(p_Inp);
|
||||||
fprintf(stdout,"--------------------------------------------------------------------------\n");
|
fprintf(stdout, "----------------------------------------------------------"
|
||||||
|
"----------------\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p_Inp->silent)
|
if (!p_Inp->silent) {
|
||||||
{
|
|
||||||
fprintf(stdout, "POC must = frame# or field# for SNRs to be correct\n");
|
fprintf(stdout, "POC must = frame# or field# for SNRs to be correct\n");
|
||||||
fprintf(stdout,"--------------------------------------------------------------------------\n");
|
fprintf(stdout, "----------------------------------------------------------"
|
||||||
fprintf(stdout," Frame POC Pic# QP SnrY SnrU SnrV Y:U:V Time(ms)\n");
|
"----------------\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;
|
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)
|
static int WriteOneFrame(DecodedPicList *pDecPic, int hFileOutput0,
|
||||||
{
|
int hFileOutput1, int bOutputAllFrames) {
|
||||||
int iOutputFrame = 0;
|
int iOutputFrame = 0;
|
||||||
DecodedPicList *pPic = pDecPic;
|
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;
|
int i, iWidth, iHeight, iStride, iWidthUV, iHeightUV, iStrideUV;
|
||||||
byte *pbBuf;
|
byte *pbBuf;
|
||||||
int hFileOutput;
|
int hFileOutput;
|
||||||
|
@ -120,21 +133,18 @@ static int WriteOneFrame(DecodedPicList *pDecPic, int hFileOutput0, int hFileOut
|
||||||
iWidthUV *= ((pPic->iBitDepth + 7) >> 3);
|
iWidthUV *= ((pPic->iBitDepth + 7) >> 3);
|
||||||
iStrideUV = pPic->iUVBufStride;
|
iStrideUV = pPic->iUVBufStride;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
if (pPic->iYUVStorageFormat == 2)
|
if (pPic->iYUVStorageFormat == 2)
|
||||||
hFileOutput = (pPic->iViewId & 0xffff) ? hFileOutput1 : hFileOutput0;
|
hFileOutput = (pPic->iViewId & 0xffff) ? hFileOutput1 : hFileOutput0;
|
||||||
else
|
else
|
||||||
hFileOutput = hFileOutput0;
|
hFileOutput = hFileOutput0;
|
||||||
if(hFileOutput >=0)
|
if (hFileOutput >= 0) {
|
||||||
{
|
|
||||||
// Y;
|
// Y;
|
||||||
pbBuf = pPic->pY;
|
pbBuf = pPic->pY;
|
||||||
for (i = 0; i < iHeight; i++)
|
for (i = 0; i < iHeight; i++)
|
||||||
write(hFileOutput, pbBuf + i * iStride, iWidth);
|
write(hFileOutput, pbBuf + i * iStride, iWidth);
|
||||||
|
|
||||||
if(pPic->iYUVFormat != YUV400)
|
if (pPic->iYUVFormat != YUV400) {
|
||||||
{
|
|
||||||
// U;
|
// U;
|
||||||
pbBuf = pPic->pU;
|
pbBuf = pPic->pU;
|
||||||
for (i = 0; i < iHeightUV; i++)
|
for (i = 0; i < iHeightUV; i++)
|
||||||
|
@ -148,19 +158,17 @@ static int WriteOneFrame(DecodedPicList *pDecPic, int hFileOutput0, int hFileOut
|
||||||
iOutputFrame++;
|
iOutputFrame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((pPic->iYUVStorageFormat==2))
|
if ((pPic->iYUVStorageFormat == 2)) {
|
||||||
{
|
hFileOutput =
|
||||||
hFileOutput = ((pPic->iViewId>>16)&0xffff)? hFileOutput1 : hFileOutput0;
|
((pPic->iViewId >> 16) & 0xffff) ? hFileOutput1 : hFileOutput0;
|
||||||
if(hFileOutput>=0)
|
if (hFileOutput >= 0) {
|
||||||
{
|
|
||||||
int iPicSize = iHeight * iStride;
|
int iPicSize = iHeight * iStride;
|
||||||
// Y;
|
// Y;
|
||||||
pbBuf = pPic->pY + iPicSize;
|
pbBuf = pPic->pY + iPicSize;
|
||||||
for (i = 0; i < iHeight; i++)
|
for (i = 0; i < iHeight; i++)
|
||||||
write(hFileOutput, pbBuf + i * iStride, iWidth);
|
write(hFileOutput, pbBuf + i * iStride, iWidth);
|
||||||
|
|
||||||
if(pPic->iYUVFormat != YUV400)
|
if (pPic->iYUVFormat != YUV400) {
|
||||||
{
|
|
||||||
iPicSize = iHeightUV * iStrideUV;
|
iPicSize = iHeightUV * iStrideUV;
|
||||||
// U;
|
// U;
|
||||||
pbBuf = pPic->pU + iPicSize;
|
pbBuf = pPic->pU + iPicSize;
|
||||||
|
@ -197,8 +205,7 @@ static int WriteOneFrame(DecodedPicList *pDecPic, int hFileOutput0, int hFileOut
|
||||||
* main function for JM decoder
|
* main function for JM decoder
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
|
||||||
int iRet;
|
int iRet;
|
||||||
DecodedPicList *pDecPicList;
|
DecodedPicList *pDecPicList;
|
||||||
int hFileDecOutput0 = -1, hFileDecOutput1 = -1;
|
int hFileDecOutput0 = -1, hFileDecOutput1 = -1;
|
||||||
|
@ -206,9 +213,11 @@ int main(int argc, char **argv)
|
||||||
InputParameters InputParams;
|
InputParameters InputParams;
|
||||||
|
|
||||||
#if DECOUTPUT_TEST
|
#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);
|
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);
|
fprintf(stdout, "Decoder output view1: %s\n", DECOUTPUT_VIEW1_FILENAME);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -216,46 +225,42 @@ int main(int argc, char **argv)
|
||||||
Configure(&InputParams, argc, argv);
|
Configure(&InputParams, argc, argv);
|
||||||
// open decoder;
|
// open decoder;
|
||||||
iRet = OpenDecoder(&InputParams);
|
iRet = OpenDecoder(&InputParams);
|
||||||
if(iRet != DEC_OPEN_NOERR)
|
if (iRet != DEC_OPEN_NOERR) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Open encoder failed: 0x%x!\n", iRet);
|
fprintf(stderr, "Open encoder failed: 0x%x!\n", iRet);
|
||||||
return -1; // failed;
|
return -1; // failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// decoding;
|
// decoding;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
iRet = DecodeOneFrame(&pDecPicList);
|
iRet = DecodeOneFrame(&pDecPicList);
|
||||||
if(iRet==DEC_EOS || iRet==DEC_SUCCEED)
|
if (iRet == DEC_EOS || iRet == DEC_SUCCEED) {
|
||||||
{
|
|
||||||
// process the decoded picture, output or display;
|
// process the decoded picture, output or display;
|
||||||
iFramesOutput += WriteOneFrame(pDecPicList, hFileDecOutput0, hFileDecOutput1, 0);
|
iFramesOutput +=
|
||||||
|
WriteOneFrame(pDecPicList, hFileDecOutput0, hFileDecOutput1, 0);
|
||||||
iFramesDecoded++;
|
iFramesDecoded++;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// error handling;
|
// error handling;
|
||||||
fprintf(stderr, "Error in decoding process: 0x%x\n", iRet);
|
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);
|
iRet = FinitDecoder(&pDecPicList);
|
||||||
iFramesOutput += WriteOneFrame(pDecPicList, hFileDecOutput0, hFileDecOutput1 , 1);
|
iFramesOutput +=
|
||||||
|
WriteOneFrame(pDecPicList, hFileDecOutput0, hFileDecOutput1, 1);
|
||||||
iRet = CloseDecoder();
|
iRet = CloseDecoder();
|
||||||
|
|
||||||
// quit;
|
// quit;
|
||||||
if(hFileDecOutput0>=0)
|
if (hFileDecOutput0 >= 0) {
|
||||||
{
|
|
||||||
close(hFileDecOutput0);
|
close(hFileDecOutput0);
|
||||||
}
|
}
|
||||||
if(hFileDecOutput1>=0)
|
if (hFileDecOutput1 >= 0) {
|
||||||
{
|
|
||||||
close(hFileDecOutput1);
|
close(hFileDecOutput1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("%d frames are decoded.\n", iFramesDecoded);
|
// printf("%d frames are decoded.\n", iFramesDecoded);
|
||||||
//printf("%d frames are decoded, %d frames output.\n", iFramesDecoded, iFramesOutput);
|
// printf("%d frames are decoded, %d frames output.\n", iFramesDecoded,
|
||||||
|
// iFramesOutput);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
* \file erc_api.c
|
* \file erc_api.c
|
||||||
*
|
*
|
||||||
* \brief
|
* \brief
|
||||||
* External (still inside video decoder) interface for error concealment module
|
* External (still inside video decoder) interface for error concealment
|
||||||
|
*module
|
||||||
*
|
*
|
||||||
* \author
|
* \author
|
||||||
* - Ari Hourunranta <ari.hourunranta@nokia.com>
|
* - Ari Hourunranta <ari.hourunranta@nokia.com>
|
||||||
|
@ -14,11 +15,10 @@
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "memalloc.h"
|
|
||||||
#include "erc_api.h"
|
#include "erc_api.h"
|
||||||
#include "fast_memory.h"
|
#include "fast_memory.h"
|
||||||
|
#include "global.h"
|
||||||
|
#include "memalloc.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
@ -26,11 +26,12 @@
|
||||||
* Initinize the error concealment module
|
* 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);
|
ercClose(p_Vid, p_Vid->erc_errorVar);
|
||||||
p_Vid->erc_object_list = (objectBuffer_t *) calloc((pic_sizex * pic_sizey) >> 6, sizeof(objectBuffer_t));
|
p_Vid->erc_object_list = (objectBuffer_t *)calloc(
|
||||||
if (p_Vid->erc_object_list == NULL) no_mem_exit("ercInit: erc_object_list");
|
(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
|
// the error concealment instance is allocated
|
||||||
p_Vid->erc_errorVar = ercOpen();
|
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.
|
* The allocated ercVariables_t is returned.
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
ercVariables_t *ercOpen( void )
|
ercVariables_t *ercOpen(void) {
|
||||||
{
|
|
||||||
ercVariables_t *errorVar = NULL;
|
ercVariables_t *errorVar = NULL;
|
||||||
|
|
||||||
errorVar = (ercVariables_t *)malloc(sizeof(ercVariables_t));
|
errorVar = (ercVariables_t *)malloc(sizeof(ercVariables_t));
|
||||||
if ( errorVar == NULL ) no_mem_exit("ercOpen: errorVar");
|
if (errorVar == NULL)
|
||||||
|
no_mem_exit("ercOpen: errorVar");
|
||||||
|
|
||||||
errorVar->nOfMBs = 0;
|
errorVar->nOfMBs = 0;
|
||||||
errorVar->segments = NULL;
|
errorVar->segments = NULL;
|
||||||
|
@ -82,17 +83,15 @@ ercVariables_t *ercOpen( void )
|
||||||
* Width of the frame in pixels.
|
* 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;
|
signed char *tmp = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if ( errorVar && errorVar->concealment )
|
if (errorVar && errorVar->concealment) {
|
||||||
{
|
|
||||||
ercSegment_t *segments = NULL;
|
ercSegment_t *segments = NULL;
|
||||||
// If frame size has been changed
|
// If frame size has been changed
|
||||||
if ( nOfMBs != errorVar->nOfMBs && errorVar->yCondition != NULL )
|
if (nOfMBs != errorVar->nOfMBs && errorVar->yCondition != NULL) {
|
||||||
{
|
|
||||||
free(errorVar->yCondition);
|
free(errorVar->yCondition);
|
||||||
errorVar->yCondition = NULL;
|
errorVar->yCondition = NULL;
|
||||||
free(errorVar->prevFrameYCondition);
|
free(errorVar->prevFrameYCondition);
|
||||||
|
@ -105,26 +104,34 @@ void ercReset( ercVariables_t *errorVar, int nOfMBs, int numOfSegments, int picS
|
||||||
errorVar->segments = NULL;
|
errorVar->segments = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the structures are uninitialized (first frame, or frame size is changed)
|
// If the structures are uninitialized (first frame, or frame size is
|
||||||
if ( errorVar->yCondition == NULL )
|
// changed)
|
||||||
{
|
if (errorVar->yCondition == NULL) {
|
||||||
errorVar->segments = (ercSegment_t *)malloc( numOfSegments*sizeof(ercSegment_t) );
|
errorVar->segments =
|
||||||
if ( errorVar->segments == NULL ) no_mem_exit("ercReset: 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));
|
fast_memset(errorVar->segments, 0, numOfSegments * sizeof(ercSegment_t));
|
||||||
errorVar->nOfSegments = numOfSegments;
|
errorVar->nOfSegments = numOfSegments;
|
||||||
|
|
||||||
errorVar->yCondition = (signed char *)malloc( 4*nOfMBs*sizeof(signed char) );
|
errorVar->yCondition =
|
||||||
if ( errorVar->yCondition == NULL ) no_mem_exit("ercReset: errorVar->yCondition");
|
(signed char *)malloc(4 * nOfMBs * sizeof(signed char));
|
||||||
errorVar->prevFrameYCondition = (signed char *)malloc( 4*nOfMBs*sizeof(signed char) );
|
if (errorVar->yCondition == NULL)
|
||||||
if ( errorVar->prevFrameYCondition == NULL ) no_mem_exit("ercReset: errorVar->prevFrameYCondition");
|
no_mem_exit("ercReset: errorVar->yCondition");
|
||||||
errorVar->uCondition = (signed char *)malloc( nOfMBs*sizeof(signed char) );
|
errorVar->prevFrameYCondition =
|
||||||
if ( errorVar->uCondition == NULL ) no_mem_exit("ercReset: errorVar->uCondition");
|
(signed char *)malloc(4 * nOfMBs * sizeof(signed char));
|
||||||
errorVar->vCondition = (signed char *)malloc( nOfMBs*sizeof(signed char) );
|
if (errorVar->prevFrameYCondition == NULL)
|
||||||
if ( errorVar->vCondition == NULL ) no_mem_exit("ercReset: errorVar->vCondition");
|
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;
|
errorVar->nOfMBs = nOfMBs;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Store the yCondition struct of the previous frame
|
// Store the yCondition struct of the previous frame
|
||||||
tmp = errorVar->prevFrameYCondition;
|
tmp = errorVar->prevFrameYCondition;
|
||||||
errorVar->prevFrameYCondition = errorVar->yCondition;
|
errorVar->prevFrameYCondition = errorVar->yCondition;
|
||||||
|
@ -132,24 +139,28 @@ void ercReset( ercVariables_t *errorVar, int nOfMBs, int numOfSegments, int picS
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset tables and parameters
|
// Reset tables and parameters
|
||||||
fast_memset( errorVar->yCondition, 0, 4*nOfMBs*sizeof(*errorVar->yCondition));
|
fast_memset(errorVar->yCondition, 0,
|
||||||
fast_memset( errorVar->uCondition, 0, nOfMBs*sizeof(*errorVar->uCondition));
|
4 * nOfMBs * sizeof(*errorVar->yCondition));
|
||||||
fast_memset( errorVar->vCondition, 0, nOfMBs*sizeof(*errorVar->vCondition));
|
fast_memset(errorVar->uCondition, 0,
|
||||||
|
nOfMBs * sizeof(*errorVar->uCondition));
|
||||||
|
fast_memset(errorVar->vCondition, 0,
|
||||||
|
nOfMBs * sizeof(*errorVar->vCondition));
|
||||||
|
|
||||||
if (errorVar->nOfSegments != numOfSegments)
|
if (errorVar->nOfSegments != numOfSegments) {
|
||||||
{
|
|
||||||
free(errorVar->segments);
|
free(errorVar->segments);
|
||||||
errorVar->segments = NULL;
|
errorVar->segments = NULL;
|
||||||
errorVar->segments = (ercSegment_t *)malloc( numOfSegments*sizeof(ercSegment_t) );
|
errorVar->segments =
|
||||||
if ( errorVar->segments == NULL ) no_mem_exit("ercReset: errorVar->segments");
|
(ercSegment_t *)malloc(numOfSegments * sizeof(ercSegment_t));
|
||||||
|
if (errorVar->segments == NULL)
|
||||||
|
no_mem_exit("ercReset: errorVar->segments");
|
||||||
errorVar->nOfSegments = numOfSegments;
|
errorVar->nOfSegments = numOfSegments;
|
||||||
}
|
}
|
||||||
|
|
||||||
//memset( errorVar->segments, 0, errorVar->nOfSegments * sizeof(ercSegment_t));
|
// memset( errorVar->segments, 0, errorVar->nOfSegments *
|
||||||
|
// sizeof(ercSegment_t));
|
||||||
|
|
||||||
segments = errorVar->segments;
|
segments = errorVar->segments;
|
||||||
for ( i = 0; i < errorVar->nOfSegments; i++ )
|
for (i = 0; i < errorVar->nOfSegments; i++) {
|
||||||
{
|
|
||||||
segments->startMBPos = 0;
|
segments->startMBPos = 0;
|
||||||
segments->endMBPos = (short)(nOfMBs - 1);
|
segments->endMBPos = (short)(nOfMBs - 1);
|
||||||
(segments++)->fCorrupted = 1; //! mark segments as corrupted
|
(segments++)->fCorrupted = 1; //! mark segments as corrupted
|
||||||
|
@ -171,12 +182,9 @@ void ercReset( ercVariables_t *errorVar, int nOfMBs, int numOfSegments, int picS
|
||||||
* Variables for error concealment
|
* Variables for error concealment
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void ercClose(VideoParameters *p_Vid, ercVariables_t *errorVar )
|
void ercClose(VideoParameters *p_Vid, ercVariables_t *errorVar) {
|
||||||
{
|
if (errorVar != NULL) {
|
||||||
if ( errorVar != NULL )
|
if (errorVar->yCondition != NULL) {
|
||||||
{
|
|
||||||
if (errorVar->yCondition != NULL)
|
|
||||||
{
|
|
||||||
free(errorVar->segments);
|
free(errorVar->segments);
|
||||||
free(errorVar->yCondition);
|
free(errorVar->yCondition);
|
||||||
free(errorVar->uCondition);
|
free(errorVar->uCondition);
|
||||||
|
@ -187,8 +195,7 @@ void ercClose(VideoParameters *p_Vid, ercVariables_t *errorVar )
|
||||||
errorVar = NULL;
|
errorVar = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_Vid->erc_object_list)
|
if (p_Vid->erc_object_list) {
|
||||||
{
|
|
||||||
free(p_Vid->erc_object_list);
|
free(p_Vid->erc_object_list);
|
||||||
p_Vid->erc_object_list = NULL;
|
p_Vid->erc_object_list = NULL;
|
||||||
}
|
}
|
||||||
|
@ -197,15 +204,12 @@ void ercClose(VideoParameters *p_Vid, ercVariables_t *errorVar )
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Sets error concealment ON/OFF. Can be invoked only between frames, not during a frame
|
* Sets error concealment ON/OFF. Can be invoked only between frames, not
|
||||||
* \param errorVar
|
*during a frame \param errorVar Variables for error concealment \param value
|
||||||
* Variables for error concealment
|
|
||||||
* \param value
|
|
||||||
* New value
|
* New value
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void ercSetErrorConcealment( ercVariables_t *errorVar, int value )
|
void ercSetErrorConcealment(ercVariables_t *errorVar, int value) {
|
||||||
{
|
|
||||||
if (errorVar != NULL)
|
if (errorVar != NULL)
|
||||||
errorVar->concealment = value;
|
errorVar->concealment = value;
|
||||||
}
|
}
|
||||||
|
@ -213,29 +217,22 @@ void ercSetErrorConcealment( ercVariables_t *errorVar, int value )
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Creates a new segment in the segment-list, and marks the start MB and bit position.
|
* Creates a new segment in the segment-list, and marks the start MB and
|
||||||
* If the end of the previous segment was not explicitly marked by "ercStopSegment",
|
*bit position. If the end of the previous segment was not explicitly marked by
|
||||||
* also marks the end of the previous segment.
|
*"ercStopSegment", also marks the end of the previous segment. If needed, it
|
||||||
* If needed, it reallocates the segment-list for a larger storage place.
|
*reallocates the segment-list for a larger storage place. \param currMBNum The
|
||||||
* \param currMBNum
|
*MB number where the new slice/segment starts \param segment Segment/Slice No.
|
||||||
* The MB number where the new slice/segment starts
|
*counted by the caller \param bitPos Bitstream pointer: number of bits read
|
||||||
* \param segment
|
*from the buffer. \param errorVar Variables for error detector
|
||||||
* 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 )
|
void ercStartSegment(int currMBNum, int segment, unsigned int bitPos,
|
||||||
{
|
ercVariables_t *errorVar) {
|
||||||
if ( errorVar && errorVar->concealment )
|
if (errorVar && errorVar->concealment) {
|
||||||
{
|
|
||||||
errorVar->currSegmentCorrupted = 0;
|
errorVar->currSegmentCorrupted = 0;
|
||||||
|
|
||||||
errorVar->segments[segment].fCorrupted = 0;
|
errorVar->segments[segment].fCorrupted = 0;
|
||||||
errorVar->segments[segment].startMBPos = (short)currMBNum;
|
errorVar->segments[segment].startMBPos = (short)currMBNum;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,10 +251,9 @@ void ercStartSegment( int currMBNum, int segment, unsigned int bitPos, ercVariab
|
||||||
* Variables for error detector
|
* Variables for error detector
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void ercStopSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar )
|
void ercStopSegment(int currMBNum, int segment, unsigned int bitPos,
|
||||||
{
|
ercVariables_t *errorVar) {
|
||||||
if ( errorVar && errorVar->concealment )
|
if (errorVar && errorVar->concealment) {
|
||||||
{
|
|
||||||
errorVar->segments[segment].endMBPos = (short)currMBNum;
|
errorVar->segments[segment].endMBPos = (short)currMBNum;
|
||||||
errorVar->currSegment++;
|
errorVar->currSegment++;
|
||||||
}
|
}
|
||||||
|
@ -274,22 +270,19 @@ void ercStopSegment( int currMBNum, int segment, unsigned int bitPos, ercVariabl
|
||||||
* Variables for error detector
|
* Variables for error detector
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar )
|
void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar) {
|
||||||
{
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int current_segment;
|
int current_segment;
|
||||||
|
|
||||||
current_segment = errorVar->currSegment - 1;
|
current_segment = errorVar->currSegment - 1;
|
||||||
if ( errorVar && errorVar->concealment )
|
if (errorVar && errorVar->concealment) {
|
||||||
{
|
if (errorVar->currSegmentCorrupted == 0) {
|
||||||
if (errorVar->currSegmentCorrupted == 0)
|
|
||||||
{
|
|
||||||
errorVar->nOfCorruptedSegments++;
|
errorVar->nOfCorruptedSegments++;
|
||||||
errorVar->currSegmentCorrupted = 1;
|
errorVar->currSegmentCorrupted = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( j = errorVar->segments[current_segment].startMBPos; j <= errorVar->segments[current_segment].endMBPos; j++ )
|
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, 0, picSizeX)] = ERC_BLOCK_CORRUPTED;
|
||||||
errorVar->yCondition[MBNum2YBlock(j, 1, 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, 2, picSizeX)] = ERC_BLOCK_CORRUPTED;
|
||||||
|
@ -312,17 +305,15 @@ void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar )
|
||||||
* Variables for error detector
|
* Variables for error detector
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar )
|
void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar) {
|
||||||
{
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int current_segment;
|
int current_segment;
|
||||||
|
|
||||||
current_segment = errorVar->currSegment - 1;
|
current_segment = errorVar->currSegment - 1;
|
||||||
if ( errorVar && errorVar->concealment )
|
if (errorVar && errorVar->concealment) {
|
||||||
{
|
|
||||||
// mark all the Blocks belonging to the segment as OK */
|
// mark all the Blocks belonging to the segment as OK */
|
||||||
for ( j = errorVar->segments[current_segment].startMBPos; j <= errorVar->segments[current_segment].endMBPos; j++ )
|
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, 0, picSizeX)] = ERC_BLOCK_OK;
|
||||||
errorVar->yCondition[MBNum2YBlock(j, 1, 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, 2, picSizeX)] = ERC_BLOCK_OK;
|
||||||
|
@ -337,9 +328,8 @@ void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar )
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Marks the Blocks of the given component (YUV) of the current MB as concealed.
|
* Marks the Blocks of the given component (YUV) of the current MB as
|
||||||
* \param currMBNum
|
*concealed. \param currMBNum Selects the segment where this MB number is in.
|
||||||
* Selects the segment where this MB number is in.
|
|
||||||
* \param comp
|
* \param comp
|
||||||
* Component to mark (0:Y, 1:U, 2:V, <0:All)
|
* Component to mark (0:Y, 1:U, 2:V, <0:All)
|
||||||
* \param picSizeX
|
* \param picSizeX
|
||||||
|
@ -348,25 +338,26 @@ void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar )
|
||||||
* Variables for error detector
|
* 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;
|
int setAll = 0;
|
||||||
|
|
||||||
if ( errorVar && errorVar->concealment )
|
if (errorVar && errorVar->concealment) {
|
||||||
{
|
if (comp < 0) {
|
||||||
if (comp < 0)
|
|
||||||
{
|
|
||||||
setAll = 1;
|
setAll = 1;
|
||||||
comp = 0;
|
comp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (comp)
|
switch (comp) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
errorVar->yCondition[MBNum2YBlock (currMBNum, 0, picSizeX)] = ERC_BLOCK_CONCEALED;
|
errorVar->yCondition[MBNum2YBlock(currMBNum, 0, picSizeX)] =
|
||||||
errorVar->yCondition[MBNum2YBlock (currMBNum, 1, picSizeX)] = ERC_BLOCK_CONCEALED;
|
ERC_BLOCK_CONCEALED;
|
||||||
errorVar->yCondition[MBNum2YBlock (currMBNum, 2, picSizeX)] = ERC_BLOCK_CONCEALED;
|
errorVar->yCondition[MBNum2YBlock(currMBNum, 1, picSizeX)] =
|
||||||
errorVar->yCondition[MBNum2YBlock (currMBNum, 3, picSizeX)] = ERC_BLOCK_CONCEALED;
|
ERC_BLOCK_CONCEALED;
|
||||||
|
errorVar->yCondition[MBNum2YBlock(currMBNum, 2, picSizeX)] =
|
||||||
|
ERC_BLOCK_CONCEALED;
|
||||||
|
errorVar->yCondition[MBNum2YBlock(currMBNum, 3, picSizeX)] =
|
||||||
|
ERC_BLOCK_CONCEALED;
|
||||||
if (!setAll)
|
if (!setAll)
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
@ -15,11 +15,15 @@
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "erc_do.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 concealBlocks(VideoParameters *p_Vid, int lastColumn, int lastRow,
|
||||||
static void pixMeanInterpolateBlock( VideoParameters *p_Vid, imgpel *src[], imgpel *block, int blockSize, int frameWidth );
|
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.
|
* The main function for Intra frame concealment.
|
||||||
* Calls "concealBlocks" for each color component (Y,U,V) separately
|
* Calls "concealBlocks" for each color component (Y,U,V) separately
|
||||||
* \return
|
* \return
|
||||||
* 0, if the concealment was not successful and simple concealment should be used
|
* 0, if the concealment was not successful and simple concealment should
|
||||||
* 1, otherwise (even if none of the blocks were concealed)
|
*be used 1, otherwise (even if none of the blocks were concealed) \param p_Vid
|
||||||
* \param p_Vid
|
|
||||||
* video encoding parameters for current picture
|
* video encoding parameters for current picture
|
||||||
* \param recfr
|
* \param recfr
|
||||||
* Reconstructed frame buffer
|
* Reconstructed frame buffer
|
||||||
|
@ -41,32 +44,32 @@ static void pixMeanInterpolateBlock( VideoParameters *p_Vid, imgpel *src[], imgp
|
||||||
* Variables for error concealment
|
* 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;
|
int lastColumn = 0, lastRow = 0;
|
||||||
|
|
||||||
// if concealment is on
|
// if concealment is on
|
||||||
if ( errorVar && errorVar->concealment )
|
if (errorVar && errorVar->concealment) {
|
||||||
{
|
|
||||||
// if there are segments to be concealed
|
// if there are segments to be concealed
|
||||||
if ( errorVar->nOfCorruptedSegments )
|
if (errorVar->nOfCorruptedSegments) {
|
||||||
{
|
|
||||||
// Y
|
// Y
|
||||||
lastRow = (int)(picSizeY >> 3);
|
lastRow = (int)(picSizeY >> 3);
|
||||||
lastColumn = (int)(picSizeX >> 3);
|
lastColumn = (int)(picSizeX >> 3);
|
||||||
concealBlocks( p_Vid, lastColumn, lastRow, 0, recfr, picSizeX, errorVar->yCondition );
|
concealBlocks(p_Vid, lastColumn, lastRow, 0, recfr, picSizeX,
|
||||||
|
errorVar->yCondition);
|
||||||
|
|
||||||
// U (dimensions halved compared to Y)
|
// U (dimensions halved compared to Y)
|
||||||
lastRow = (int)(picSizeY >> 4);
|
lastRow = (int)(picSizeY >> 4);
|
||||||
lastColumn = (int)(picSizeX >> 4);
|
lastColumn = (int)(picSizeX >> 4);
|
||||||
concealBlocks( p_Vid, lastColumn, lastRow, 1, recfr, picSizeX, errorVar->uCondition );
|
concealBlocks(p_Vid, lastColumn, lastRow, 1, recfr, picSizeX,
|
||||||
|
errorVar->uCondition);
|
||||||
|
|
||||||
// V ( dimensions equal to U )
|
// 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;
|
return 1;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,27 +87,30 @@ int ercConcealIntraFrame( VideoParameters *p_Vid, frame *recfr, int picSizeX, in
|
||||||
* \param column
|
* \param column
|
||||||
* x coordinate in blocks
|
* x coordinate in blocks
|
||||||
* \param predBlocks[]
|
* \param predBlocks[]
|
||||||
* list of neighboring source blocks (numbering 0 to 7, 1 means: use the neighbor)
|
* list of neighboring source blocks (numbering 0 to 7, 1 means: use the
|
||||||
* \param frameWidth
|
*neighbor) \param frameWidth width of frame in pixels \param mbWidthInBlocks 2
|
||||||
* width of frame in pixels
|
*for Y, 1 for U/V components
|
||||||
* \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)
|
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 *src[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
||||||
imgpel *currBlock = NULL;
|
imgpel *currBlock = NULL;
|
||||||
|
|
||||||
// collect the reliable neighboring blocks
|
// collect the reliable neighboring blocks
|
||||||
if (predBlocks[0])
|
if (predBlocks[0])
|
||||||
src[0] = currFrame + (row-mbWidthInBlocks)*frameWidth*8 + (column+mbWidthInBlocks)*8;
|
src[0] = currFrame + (row - mbWidthInBlocks) * frameWidth * 8 +
|
||||||
|
(column + mbWidthInBlocks) * 8;
|
||||||
if (predBlocks[1])
|
if (predBlocks[1])
|
||||||
src[1] = currFrame + (row-mbWidthInBlocks)*frameWidth*8 + (column-mbWidthInBlocks)*8;
|
src[1] = currFrame + (row - mbWidthInBlocks) * frameWidth * 8 +
|
||||||
|
(column - mbWidthInBlocks) * 8;
|
||||||
if (predBlocks[2])
|
if (predBlocks[2])
|
||||||
src[2] = currFrame + (row+mbWidthInBlocks)*frameWidth*8 + (column-mbWidthInBlocks)*8;
|
src[2] = currFrame + (row + mbWidthInBlocks) * frameWidth * 8 +
|
||||||
|
(column - mbWidthInBlocks) * 8;
|
||||||
if (predBlocks[3])
|
if (predBlocks[3])
|
||||||
src[3] = currFrame + (row+mbWidthInBlocks)*frameWidth*8 + (column+mbWidthInBlocks)*8;
|
src[3] = currFrame + (row + mbWidthInBlocks) * frameWidth * 8 +
|
||||||
|
(column + mbWidthInBlocks) * 8;
|
||||||
if (predBlocks[4])
|
if (predBlocks[4])
|
||||||
src[4] = currFrame + (row - mbWidthInBlocks) * frameWidth * 8 + column * 8;
|
src[4] = currFrame + (row - mbWidthInBlocks) * frameWidth * 8 + column * 8;
|
||||||
if (predBlocks[5])
|
if (predBlocks[5])
|
||||||
|
@ -115,7 +121,8 @@ void ercPixConcealIMB(VideoParameters *p_Vid, imgpel *currFrame, int row, int co
|
||||||
src[7] = currFrame + row * frameWidth * 8 + (column + mbWidthInBlocks) * 8;
|
src[7] = currFrame + row * frameWidth * 8 + (column + mbWidthInBlocks) * 8;
|
||||||
|
|
||||||
currBlock = currFrame + row * frameWidth * 8 + column * 8;
|
currBlock = currFrame + row * frameWidth * 8 + column * 8;
|
||||||
pixMeanInterpolateBlock( p_Vid, src, currBlock, mbWidthInBlocks*8, frameWidth );
|
pixMeanInterpolateBlock(p_Vid, src, currBlock, mbWidthInBlocks * 8,
|
||||||
|
frameWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -151,9 +158,9 @@ void ercPixConcealIMB(VideoParameters *p_Vid, imgpel *currFrame, int row, int co
|
||||||
* No corner neighbors are considered
|
* No corner neighbors are considered
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
int ercCollect8PredBlocks( int predBlocks[], int currRow, int currColumn, signed char *condition,
|
int ercCollect8PredBlocks(int predBlocks[], int currRow, int currColumn,
|
||||||
int maxRow, int maxColumn, int step, byte fNoCornerNeigh )
|
signed char *condition, int maxRow, int maxColumn,
|
||||||
{
|
int step, byte fNoCornerNeigh) {
|
||||||
int srcCounter = 0;
|
int srcCounter = 0;
|
||||||
int srcCountMin = (fNoCornerNeigh ? 2 : 4);
|
int srcCountMin = (fNoCornerNeigh ? 2 : 4);
|
||||||
int threshold = ERC_BLOCK_OK;
|
int threshold = ERC_BLOCK_OK;
|
||||||
|
@ -161,69 +168,70 @@ int ercCollect8PredBlocks( int predBlocks[], int currRow, int currColumn, signed
|
||||||
memset(predBlocks, 0, 8 * sizeof(int));
|
memset(predBlocks, 0, 8 * sizeof(int));
|
||||||
|
|
||||||
// collect the reliable neighboring blocks
|
// collect the reliable neighboring blocks
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
srcCounter = 0;
|
srcCounter = 0;
|
||||||
// top
|
// top
|
||||||
if (currRow > 0 && condition[ (currRow-1)*maxColumn + currColumn ] >= threshold )
|
if (currRow > 0 &&
|
||||||
{ //ERC_BLOCK_OK (3) or ERC_BLOCK_CONCEALED (2)
|
condition[(currRow - 1) * maxColumn + currColumn] >=
|
||||||
|
threshold) { // ERC_BLOCK_OK (3) or ERC_BLOCK_CONCEALED (2)
|
||||||
predBlocks[4] = condition[(currRow - 1) * maxColumn + currColumn];
|
predBlocks[4] = condition[(currRow - 1) * maxColumn + currColumn];
|
||||||
srcCounter++;
|
srcCounter++;
|
||||||
}
|
}
|
||||||
// bottom
|
// bottom
|
||||||
if ( currRow < (maxRow-step) && condition[ (currRow+step)*maxColumn + currColumn ] >= threshold )
|
if (currRow < (maxRow - step) &&
|
||||||
{
|
condition[(currRow + step) * maxColumn + currColumn] >= threshold) {
|
||||||
predBlocks[6] = condition[(currRow + step) * maxColumn + currColumn];
|
predBlocks[6] = condition[(currRow + step) * maxColumn + currColumn];
|
||||||
srcCounter++;
|
srcCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( currColumn > 0 )
|
if (currColumn > 0) {
|
||||||
{
|
|
||||||
// left
|
// left
|
||||||
if ( condition[ currRow*maxColumn + currColumn - 1 ] >= threshold )
|
if (condition[currRow * maxColumn + currColumn - 1] >= threshold) {
|
||||||
{
|
|
||||||
predBlocks[5] = condition[currRow * maxColumn + currColumn - 1];
|
predBlocks[5] = condition[currRow * maxColumn + currColumn - 1];
|
||||||
srcCounter++;
|
srcCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !fNoCornerNeigh )
|
if (!fNoCornerNeigh) {
|
||||||
{
|
|
||||||
// top-left
|
// top-left
|
||||||
if ( currRow > 0 && condition[ (currRow-1)*maxColumn + currColumn - 1 ] >= threshold )
|
if (currRow > 0 &&
|
||||||
{
|
condition[(currRow - 1) * maxColumn + currColumn - 1] >=
|
||||||
|
threshold) {
|
||||||
predBlocks[1] = condition[(currRow - 1) * maxColumn + currColumn - 1];
|
predBlocks[1] = condition[(currRow - 1) * maxColumn + currColumn - 1];
|
||||||
srcCounter++;
|
srcCounter++;
|
||||||
}
|
}
|
||||||
// bottom-left
|
// bottom-left
|
||||||
if ( currRow < (maxRow-step) && condition[ (currRow+step)*maxColumn + currColumn - 1 ] >= threshold )
|
if (currRow < (maxRow - step) &&
|
||||||
{
|
condition[(currRow + step) * maxColumn + currColumn - 1] >=
|
||||||
predBlocks[2] = condition[ (currRow+step)*maxColumn + currColumn - 1 ];
|
threshold) {
|
||||||
|
predBlocks[2] =
|
||||||
|
condition[(currRow + step) * maxColumn + currColumn - 1];
|
||||||
srcCounter++;
|
srcCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( currColumn < (maxColumn-step) )
|
if (currColumn < (maxColumn - step)) {
|
||||||
{
|
|
||||||
// right
|
// right
|
||||||
if ( condition[ currRow*maxColumn+currColumn + step ] >= threshold )
|
if (condition[currRow * maxColumn + currColumn + step] >= threshold) {
|
||||||
{
|
|
||||||
predBlocks[7] = condition[currRow * maxColumn + currColumn + step];
|
predBlocks[7] = condition[currRow * maxColumn + currColumn + step];
|
||||||
srcCounter++;
|
srcCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !fNoCornerNeigh )
|
if (!fNoCornerNeigh) {
|
||||||
{
|
|
||||||
// top-right
|
// top-right
|
||||||
if ( currRow > 0 && condition[ (currRow-1)*maxColumn + currColumn + step ] >= threshold )
|
if (currRow > 0 &&
|
||||||
{
|
condition[(currRow - 1) * maxColumn + currColumn + step] >=
|
||||||
predBlocks[0] = condition[ (currRow-1)*maxColumn + currColumn + step ];
|
threshold) {
|
||||||
|
predBlocks[0] =
|
||||||
|
condition[(currRow - 1) * maxColumn + currColumn + step];
|
||||||
srcCounter++;
|
srcCounter++;
|
||||||
}
|
}
|
||||||
// bottom-right
|
// bottom-right
|
||||||
if ( currRow < (maxRow-step) && condition[ (currRow+step)*maxColumn + currColumn + step ] >= threshold )
|
if (currRow < (maxRow - step) &&
|
||||||
{
|
condition[(currRow + step) * maxColumn + currColumn + step] >=
|
||||||
predBlocks[3] = condition[ (currRow+step)*maxColumn + currColumn + step ];
|
threshold) {
|
||||||
|
predBlocks[3] =
|
||||||
|
condition[(currRow + step) * maxColumn + currColumn + step];
|
||||||
srcCounter++;
|
srcCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,20 +268,19 @@ int ercCollect8PredBlocks( int predBlocks[], int currRow, int currColumn, signed
|
||||||
* in vertical/horizontal direction. (Y:2 U,V:1)
|
* 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;
|
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
|
// 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;
|
predBlocks[4] = 1;
|
||||||
srcCounter++;
|
srcCounter++;
|
||||||
}
|
}
|
||||||
if ( condition[ (currRow+step)*maxColumn + currColumn ] > threshold )
|
if (condition[(currRow + step) * maxColumn + currColumn] > threshold) {
|
||||||
{
|
|
||||||
predBlocks[6] = 1;
|
predBlocks[6] = 1;
|
||||||
srcCounter++;
|
srcCounter++;
|
||||||
}
|
}
|
||||||
|
@ -289,25 +296,17 @@ int ercCollectColumnBlocks( int predBlocks[], int currRow, int currColumn, signe
|
||||||
* Finds the corrupted blocks and calls pixel interpolation functions
|
* Finds the corrupted blocks and calls pixel interpolation functions
|
||||||
* to correct them, one block at a time.
|
* to correct them, one block at a time.
|
||||||
* Scanning is done vertically and each corrupted column is corrected
|
* Scanning is done vertically and each corrupted column is corrected
|
||||||
* bi-directionally, i.e., first block, last block, first block+1, last block -1 ...
|
* bi-directionally, i.e., first block, last block, first block+1, last
|
||||||
* \param p_Vid
|
*block -1 ... \param p_Vid video encoding parameters for current picture \param
|
||||||
* video encoding parameters for current picture
|
*lastColumn Number of block columns in the frame \param lastRow Number of block
|
||||||
* \param lastColumn
|
*rows in the frame \param comp color component \param recfr Reconstructed frame
|
||||||
* Number of block columns in the frame
|
*buffer \param picSizeX Width of the frame in pixels \param condition The block
|
||||||
* \param lastRow
|
*condition (ok, lost) table
|
||||||
* 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 )
|
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,
|
int row, column, srcCounter = 0, thr = ERC_BLOCK_CORRUPTED,
|
||||||
lastCorruptedRow = -1, firstCorruptedRow = -1, currRow = 0,
|
lastCorruptedRow = -1, firstCorruptedRow = -1, currRow = 0,
|
||||||
areaHeight = 0, i = 0, smoothColumn = 0;
|
areaHeight = 0, i = 0, smoothColumn = 0;
|
||||||
|
@ -320,150 +319,147 @@ static void concealBlocks( VideoParameters *p_Vid, int lastColumn, int lastRow,
|
||||||
else
|
else
|
||||||
step = 1;
|
step = 1;
|
||||||
|
|
||||||
for ( column = 0; column < lastColumn; column += step )
|
for (column = 0; column < lastColumn; column += step) {
|
||||||
{
|
for (row = 0; row < lastRow; row += step) {
|
||||||
for ( row = 0; row < lastRow; row += step )
|
if (condition[row * lastColumn + column] <= thr) {
|
||||||
{
|
|
||||||
if ( condition[row*lastColumn+column] <= thr )
|
|
||||||
{
|
|
||||||
firstCorruptedRow = row;
|
firstCorruptedRow = row;
|
||||||
// find the last row which has corrupted blocks (in same continuous area)
|
// find the last row which has corrupted blocks (in same continuous
|
||||||
for ( lastCorruptedRow = row+step; lastCorruptedRow < lastRow; lastCorruptedRow += step )
|
// area)
|
||||||
{
|
for (lastCorruptedRow = row + step; lastCorruptedRow < lastRow;
|
||||||
|
lastCorruptedRow += step) {
|
||||||
// check blocks in the current column
|
// 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
|
// current one is already OK, so the last was the previous one
|
||||||
lastCorruptedRow -= step;
|
lastCorruptedRow -= step;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( lastCorruptedRow >= lastRow )
|
if (lastCorruptedRow >= lastRow) {
|
||||||
{
|
|
||||||
// correct only from above
|
// correct only from above
|
||||||
lastCorruptedRow = lastRow - step;
|
lastCorruptedRow = lastRow - step;
|
||||||
for ( currRow = firstCorruptedRow; currRow < lastRow; currRow += step )
|
for (currRow = firstCorruptedRow; currRow < lastRow;
|
||||||
{
|
currRow += step) {
|
||||||
srcCounter = ercCollect8PredBlocks( predBlocks, currRow, column, condition, lastRow, lastColumn, step, 1 );
|
srcCounter =
|
||||||
|
ercCollect8PredBlocks(predBlocks, currRow, column, condition,
|
||||||
|
lastRow, lastColumn, step, 1);
|
||||||
|
|
||||||
switch( comp )
|
switch (comp) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
ercPixConcealIMB( p_Vid, recfr->yptr, currRow, column, predBlocks, picSizeX, 2 );
|
ercPixConcealIMB(p_Vid, recfr->yptr, currRow, column, predBlocks,
|
||||||
|
picSizeX, 2);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ercPixConcealIMB( p_Vid, recfr->uptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
ercPixConcealIMB(p_Vid, recfr->uptr, currRow, column, predBlocks,
|
||||||
|
(picSizeX >> 1), 1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ercPixConcealIMB( p_Vid, recfr->vptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
ercPixConcealIMB(p_Vid, recfr->vptr, currRow, column, predBlocks,
|
||||||
|
(picSizeX >> 1), 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( comp == 0 )
|
if (comp == 0) {
|
||||||
{
|
|
||||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||||
condition[ currRow*lastColumn+column + 1] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column + 1] =
|
||||||
condition[ currRow*lastColumn+column + lastColumn] = ERC_BLOCK_CONCEALED;
|
ERC_BLOCK_CONCEALED;
|
||||||
condition[ currRow*lastColumn+column + lastColumn + 1] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column + lastColumn] =
|
||||||
}
|
ERC_BLOCK_CONCEALED;
|
||||||
else
|
condition[currRow * lastColumn + column + lastColumn + 1] =
|
||||||
{
|
ERC_BLOCK_CONCEALED;
|
||||||
|
} else {
|
||||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
row = lastRow;
|
row = lastRow;
|
||||||
}
|
} else if (firstCorruptedRow == 0) {
|
||||||
else if ( firstCorruptedRow == 0 )
|
|
||||||
{
|
|
||||||
// correct only from below
|
// correct only from below
|
||||||
for ( currRow = lastCorruptedRow; currRow >= 0; currRow -= step )
|
for (currRow = lastCorruptedRow; currRow >= 0; currRow -= step) {
|
||||||
{
|
srcCounter =
|
||||||
srcCounter = ercCollect8PredBlocks( predBlocks, currRow, column, condition, lastRow, lastColumn, step, 1 );
|
ercCollect8PredBlocks(predBlocks, currRow, column, condition,
|
||||||
|
lastRow, lastColumn, step, 1);
|
||||||
|
|
||||||
switch( comp )
|
switch (comp) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
ercPixConcealIMB( p_Vid, recfr->yptr, currRow, column, predBlocks, picSizeX, 2 );
|
ercPixConcealIMB(p_Vid, recfr->yptr, currRow, column, predBlocks,
|
||||||
|
picSizeX, 2);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ercPixConcealIMB( p_Vid, recfr->uptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
ercPixConcealIMB(p_Vid, recfr->uptr, currRow, column, predBlocks,
|
||||||
|
(picSizeX >> 1), 1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ercPixConcealIMB( p_Vid, recfr->vptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
ercPixConcealIMB(p_Vid, recfr->vptr, currRow, column, predBlocks,
|
||||||
|
(picSizeX >> 1), 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( comp == 0 )
|
if (comp == 0) {
|
||||||
{
|
|
||||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||||
condition[ currRow*lastColumn+column + 1] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column + 1] =
|
||||||
condition[ currRow*lastColumn+column + lastColumn] = ERC_BLOCK_CONCEALED;
|
ERC_BLOCK_CONCEALED;
|
||||||
condition[ currRow*lastColumn+column + lastColumn + 1] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column + lastColumn] =
|
||||||
}
|
ERC_BLOCK_CONCEALED;
|
||||||
else
|
condition[currRow * lastColumn + column + lastColumn + 1] =
|
||||||
{
|
ERC_BLOCK_CONCEALED;
|
||||||
|
} else {
|
||||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
row = lastCorruptedRow + step;
|
row = lastCorruptedRow + step;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// correct bi-directionally
|
// correct bi-directionally
|
||||||
|
|
||||||
row = lastCorruptedRow + step;
|
row = lastCorruptedRow + step;
|
||||||
areaHeight = lastCorruptedRow - firstCorruptedRow + step;
|
areaHeight = lastCorruptedRow - firstCorruptedRow + step;
|
||||||
|
|
||||||
// Conceal the corrupted area switching between the up and the bottom rows
|
// Conceal the corrupted area switching between the up and the bottom
|
||||||
for ( i = 0; i < areaHeight; i += step )
|
// rows
|
||||||
{
|
for (i = 0; i < areaHeight; i += step) {
|
||||||
if ( i % 2 )
|
if (i % 2) {
|
||||||
{
|
|
||||||
currRow = lastCorruptedRow;
|
currRow = lastCorruptedRow;
|
||||||
lastCorruptedRow -= step;
|
lastCorruptedRow -= step;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
currRow = firstCorruptedRow;
|
currRow = firstCorruptedRow;
|
||||||
firstCorruptedRow += step;
|
firstCorruptedRow += step;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smoothColumn > 0)
|
if (smoothColumn > 0) {
|
||||||
{
|
srcCounter =
|
||||||
srcCounter = ercCollectColumnBlocks( predBlocks, currRow, column, condition, lastRow, lastColumn, step );
|
ercCollectColumnBlocks(predBlocks, currRow, column, condition,
|
||||||
}
|
lastRow, lastColumn, step);
|
||||||
else
|
} else {
|
||||||
{
|
srcCounter =
|
||||||
srcCounter = ercCollect8PredBlocks( predBlocks, currRow, column, condition, lastRow, lastColumn, step, 1 );
|
ercCollect8PredBlocks(predBlocks, currRow, column, condition,
|
||||||
|
lastRow, lastColumn, step, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( comp )
|
switch (comp) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
ercPixConcealIMB( p_Vid, recfr->yptr, currRow, column, predBlocks, picSizeX, 2 );
|
ercPixConcealIMB(p_Vid, recfr->yptr, currRow, column, predBlocks,
|
||||||
|
picSizeX, 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
ercPixConcealIMB( p_Vid, recfr->uptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
ercPixConcealIMB(p_Vid, recfr->uptr, currRow, column, predBlocks,
|
||||||
|
(picSizeX >> 1), 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
ercPixConcealIMB( p_Vid, recfr->vptr, currRow, column, predBlocks, (picSizeX>>1), 1 );
|
ercPixConcealIMB(p_Vid, recfr->vptr, currRow, column, predBlocks,
|
||||||
|
(picSizeX >> 1), 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( comp == 0 )
|
if (comp == 0) {
|
||||||
{
|
|
||||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||||
condition[ currRow*lastColumn+column + 1] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column + 1] =
|
||||||
condition[ currRow*lastColumn+column + lastColumn] = ERC_BLOCK_CONCEALED;
|
ERC_BLOCK_CONCEALED;
|
||||||
condition[ currRow*lastColumn+column + lastColumn + 1] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column + lastColumn] =
|
||||||
}
|
ERC_BLOCK_CONCEALED;
|
||||||
else
|
condition[currRow * lastColumn + column + lastColumn + 1] =
|
||||||
{
|
ERC_BLOCK_CONCEALED;
|
||||||
|
} else {
|
||||||
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
condition[currRow * lastColumn + column] = ERC_BLOCK_CONCEALED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -471,7 +467,6 @@ static void concealBlocks( VideoParameters *p_Vid, int lastColumn, int lastRow,
|
||||||
|
|
||||||
lastCorruptedRow = -1;
|
lastCorruptedRow = -1;
|
||||||
firstCorruptedRow = -1;
|
firstCorruptedRow = -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,41 +489,36 @@ static void concealBlocks( VideoParameters *p_Vid, int lastColumn, int lastRow,
|
||||||
* Width of the frame in pixels
|
* 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;
|
int row, column, k, tmp, srcCounter = 0, weight = 0, bmax = blockSize - 1;
|
||||||
|
|
||||||
k = 0;
|
k = 0;
|
||||||
for ( row = 0; row < blockSize; row++ )
|
for (row = 0; row < blockSize; row++) {
|
||||||
{
|
for (column = 0; column < blockSize; column++) {
|
||||||
for ( column = 0; column < blockSize; column++ )
|
|
||||||
{
|
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
srcCounter = 0;
|
srcCounter = 0;
|
||||||
// above
|
// above
|
||||||
if ( src[4] != NULL )
|
if (src[4] != NULL) {
|
||||||
{
|
|
||||||
weight = blockSize - row;
|
weight = blockSize - row;
|
||||||
tmp += weight * (*(src[4] + bmax * frameWidth + column));
|
tmp += weight * (*(src[4] + bmax * frameWidth + column));
|
||||||
srcCounter += weight;
|
srcCounter += weight;
|
||||||
}
|
}
|
||||||
// left
|
// left
|
||||||
if ( src[5] != NULL )
|
if (src[5] != NULL) {
|
||||||
{
|
|
||||||
weight = blockSize - column;
|
weight = blockSize - column;
|
||||||
tmp += weight * (*(src[5] + row * frameWidth + bmax));
|
tmp += weight * (*(src[5] + row * frameWidth + bmax));
|
||||||
srcCounter += weight;
|
srcCounter += weight;
|
||||||
}
|
}
|
||||||
// below
|
// below
|
||||||
if ( src[6] != NULL )
|
if (src[6] != NULL) {
|
||||||
{
|
|
||||||
weight = row + 1;
|
weight = row + 1;
|
||||||
tmp += weight * (*(src[6] + column));
|
tmp += weight * (*(src[6] + column));
|
||||||
srcCounter += weight;
|
srcCounter += weight;
|
||||||
}
|
}
|
||||||
// right
|
// right
|
||||||
if ( src[7] != NULL )
|
if (src[7] != NULL) {
|
||||||
{
|
|
||||||
weight = column + 1;
|
weight = column + 1;
|
||||||
tmp += weight * (*(src[7] + row * frameWidth));
|
tmp += weight * (*(src[7] + row * frameWidth));
|
||||||
srcCounter += weight;
|
srcCounter += weight;
|
||||||
|
@ -537,7 +527,9 @@ static void pixMeanInterpolateBlock( VideoParameters *p_Vid, imgpel *src[], imgp
|
||||||
if (srcCounter > 0)
|
if (srcCounter > 0)
|
||||||
block[k + column] = (imgpel)(tmp / srcCounter);
|
block[k + column] = (imgpel)(tmp / srcCounter);
|
||||||
else
|
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;
|
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
|
* This simple error concealment implemented in this decoder uses
|
||||||
* the existing dependencies of syntax elements.
|
* the existing dependencies of syntax elements.
|
||||||
* In case that an element is detected as false this elements and all
|
* 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[]
|
* dependend elements are marked as elements to conceal in the
|
||||||
* array. If the decoder requests a new element by the function
|
*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
|
* readSyntaxElement_xxxx() this array is checked first if an error
|
||||||
* to be applied on this element.
|
*concealment has to be applied on this element. In case that an error occured a
|
||||||
* In case that an error occured a concealed element is given to the
|
*concealed element is given to the decoding function in macroblock().
|
||||||
* decoding function in macroblock().
|
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Sebastian Purreiter <sebastian.purreiter@mch.siemens.de>
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contributors.h"
|
#include "contributors.h"
|
||||||
#include "global.h"
|
|
||||||
#include "elements.h"
|
#include "elements.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
|
@ -49,15 +47,13 @@
|
||||||
* EX_SYNC sync on next header
|
* 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)
|
if (p_Vid->ec_flag[se] == NO_EC)
|
||||||
printf("Error concealment on element %s\n",SEtypes[se]);
|
printf("Error concealment on element %s\n",SEtypes[se]);
|
||||||
*/
|
*/
|
||||||
switch (se)
|
switch (se) {
|
||||||
{
|
|
||||||
case SE_HEADER:
|
case SE_HEADER:
|
||||||
p_Vid->ec_flag[SE_HEADER] = EC_REQ;
|
p_Vid->ec_flag[SE_HEADER] = EC_REQ;
|
||||||
case SE_PTYPE:
|
case SE_PTYPE:
|
||||||
|
@ -84,8 +80,7 @@ int set_ec_flag(VideoParameters *p_Vid, int se)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (se)
|
switch (se) {
|
||||||
{
|
|
||||||
case SE_CBP_INTRA:
|
case SE_CBP_INTRA:
|
||||||
p_Vid->ec_flag[SE_CBP_INTRA] = EC_REQ;
|
p_Vid->ec_flag[SE_CBP_INTRA] = EC_REQ;
|
||||||
case SE_LUM_DC_INTRA:
|
case SE_LUM_DC_INTRA:
|
||||||
|
@ -117,7 +112,6 @@ int set_ec_flag(VideoParameters *p_Vid, int se)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
return EC_REQ;
|
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;
|
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;
|
p_Vid->ec_flag[i] = NO_EC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -148,8 +140,7 @@ void reset_ec_flags(VideoParameters *p_Vid)
|
||||||
* EC_REQ if element requires error concealment
|
* 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)
|
if (p_Vid->ec_flag[sym->type] == NO_EC)
|
||||||
return NO_EC;
|
return NO_EC;
|
||||||
/*
|
/*
|
||||||
|
@ -157,8 +148,7 @@ int get_concealed_element(VideoParameters *p_Vid, SyntaxElement *sym)
|
||||||
printf("TRACE: get concealed element for %s!!!\n", SEtypes[sym->type]);
|
printf("TRACE: get concealed element for %s!!!\n", SEtypes[sym->type]);
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
switch (sym->type)
|
switch (sym->type) {
|
||||||
{
|
|
||||||
case SE_HEADER:
|
case SE_HEADER:
|
||||||
sym->len = 31;
|
sym->len = 31;
|
||||||
sym->inf = 0; // Picture Header
|
sym->inf = 0; // Picture Header
|
||||||
|
@ -217,4 +207,3 @@ int get_concealed_element(VideoParameters *p_Vid, SyntaxElement *sym)
|
||||||
|
|
||||||
return EC_REQ;
|
return EC_REQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* \brief
|
* \brief
|
||||||
* Trace file handling and standard error handling function.
|
* Trace file handling and standard error handling function.
|
||||||
* \author
|
* \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>
|
* - Karsten Suehring <suehring@hhi.de>
|
||||||
***************************************************************************************
|
***************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -15,7 +16,6 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "mbuffer.h"
|
#include "mbuffer.h"
|
||||||
|
|
||||||
|
|
||||||
#if TRACE
|
#if TRACE
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -24,10 +24,7 @@
|
||||||
* decrement trace p_Dec->bitcounter (used for special case in mb aff)
|
* decrement trace p_Dec->bitcounter (used for special case in mb aff)
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void dectracebitcnt(int count)
|
void dectracebitcnt(int count) { p_Dec->bitcounter -= count; }
|
||||||
{
|
|
||||||
p_Dec->bitcounter -= count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
@ -37,17 +34,17 @@ void dectracebitcnt(int count)
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void tracebits(
|
void tracebits(
|
||||||
const signed char *trace_str, //!< tracing information, signed char array describing the symbol
|
const signed char *trace_str, //!< tracing information, signed char array
|
||||||
|
//!< describing the symbol
|
||||||
int len, //!< length of syntax element in bits
|
int len, //!< length of syntax element in bits
|
||||||
int info, //!< infoword of syntax element
|
int info, //!< infoword of syntax element
|
||||||
int value1)
|
int value1) {
|
||||||
{
|
|
||||||
int i, chars;
|
int i, chars;
|
||||||
// int outint = 1;
|
// int outint = 1;
|
||||||
|
|
||||||
if(len>=64)
|
if (len >= 64) {
|
||||||
{
|
snprintf(errortext, ET_SIZE,
|
||||||
snprintf(errortext, ET_SIZE, "Length argument to put too long for trace to work");
|
"Length argument to put too long for trace to work");
|
||||||
error(errortext, 600);
|
error(errortext, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,23 +58,20 @@ void tracebits(
|
||||||
putc(' ', p_Dec->p_trace);
|
putc(' ', p_Dec->p_trace);
|
||||||
|
|
||||||
// Align bitpattern
|
// Align bitpattern
|
||||||
if(len<15)
|
if (len < 15) {
|
||||||
{
|
|
||||||
for (i = 0; i < 15 - len; i++)
|
for (i = 0; i < 15 - len; i++)
|
||||||
fputc(' ', p_Dec->p_trace);
|
fputc(' ', p_Dec->p_trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print bitpattern
|
// Print bitpattern
|
||||||
for(i=0 ; i<len/2 ; i++)
|
for (i = 0; i < len / 2; i++) {
|
||||||
{
|
|
||||||
fputc('0', p_Dec->p_trace);
|
fputc('0', p_Dec->p_trace);
|
||||||
}
|
}
|
||||||
// put 1
|
// put 1
|
||||||
fprintf(p_Dec->p_trace, "1");
|
fprintf(p_Dec->p_trace, "1");
|
||||||
|
|
||||||
// Print bitpattern
|
// Print bitpattern
|
||||||
for(i=0 ; i<len/2 ; i++)
|
for (i = 0; i < len / 2; i++) {
|
||||||
{
|
|
||||||
if (0x01 & (info >> ((len / 2 - i) - 1)))
|
if (0x01 & (info >> ((len / 2 - i) - 1)))
|
||||||
fputc('1', p_Dec->p_trace);
|
fputc('1', p_Dec->p_trace);
|
||||||
else
|
else
|
||||||
|
@ -97,17 +91,17 @@ void tracebits(
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void tracebits2(
|
void tracebits2(
|
||||||
const signed char *trace_str, //!< tracing information, signed char array describing the symbol
|
const signed char *trace_str, //!< tracing information, signed char array
|
||||||
|
//!< describing the symbol
|
||||||
int len, //!< length of syntax element in bits
|
int len, //!< length of syntax element in bits
|
||||||
int info)
|
int info) {
|
||||||
{
|
|
||||||
|
|
||||||
int i, chars;
|
int i, chars;
|
||||||
// int outint = 1;
|
// int outint = 1;
|
||||||
|
|
||||||
if(len>=64)
|
if (len >= 64) {
|
||||||
{
|
snprintf(errortext, ET_SIZE,
|
||||||
snprintf(errortext, ET_SIZE, "Length argument to put too long for trace to work");
|
"Length argument to put too long for trace to work");
|
||||||
error(errortext, 600);
|
error(errortext, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,25 +117,21 @@ void tracebits2(
|
||||||
putc(' ', p_Dec->p_trace);
|
putc(' ', p_Dec->p_trace);
|
||||||
|
|
||||||
// Align bitpattern
|
// Align bitpattern
|
||||||
if(len < 15)
|
if (len < 15) {
|
||||||
{
|
|
||||||
for (i = 0; i < 15 - len; i++)
|
for (i = 0; i < 15 - len; i++)
|
||||||
fputc(' ', p_Dec->p_trace);
|
fputc(' ', p_Dec->p_trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_Dec->bitcounter += len;
|
p_Dec->bitcounter += len;
|
||||||
while (len >= 32)
|
while (len >= 32) {
|
||||||
{
|
for (i = 0; i < 8; i++) {
|
||||||
for(i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
fputc('0', p_Dec->p_trace);
|
fputc('0', p_Dec->p_trace);
|
||||||
}
|
}
|
||||||
len -= 8;
|
len -= 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print bitpattern
|
// Print bitpattern
|
||||||
for(i=0 ; i<len ; i++)
|
for (i = 0; i < len; i++) {
|
||||||
{
|
|
||||||
if (0x01 & (info >> (len - i - 1)))
|
if (0x01 & (info >> (len - i - 1)))
|
||||||
fputc('1', p_Dec->p_trace);
|
fputc('1', p_Dec->p_trace);
|
||||||
else
|
else
|
||||||
|
@ -153,4 +143,3 @@ void tracebits2(
|
||||||
fflush(p_Dec->p_trace);
|
fflush(p_Dec->p_trace);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -8,29 +8,39 @@
|
||||||
* Support for Flexible Macroblock Ordering (FMO)
|
* Support for Flexible Macroblock Ordering (FMO)
|
||||||
*
|
*
|
||||||
* \author
|
* \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
|
* - Stephan Wenger stewe@cs.tu-berlin.de
|
||||||
* - Karsten Suehring suehring@hhi.de
|
* - Karsten Suehring suehring@hhi.de
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "elements.h"
|
|
||||||
#include "defines.h"
|
|
||||||
#include "header.h"
|
|
||||||
#include "fmo.h"
|
#include "fmo.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "elements.h"
|
||||||
#include "fast_memory.h"
|
#include "fast_memory.h"
|
||||||
|
#include "global.h"
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
// #define PRINT_FMO_MAPS
|
// #define PRINT_FMO_MAPS
|
||||||
|
|
||||||
static void FmoGenerateType0MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits );
|
static void FmoGenerateType0MapUnitMap(VideoParameters *p_Vid,
|
||||||
static void FmoGenerateType1MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits );
|
unsigned PicSizeInMapUnits);
|
||||||
static void FmoGenerateType2MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits );
|
static void FmoGenerateType1MapUnitMap(VideoParameters *p_Vid,
|
||||||
static void FmoGenerateType3MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice );
|
unsigned PicSizeInMapUnits);
|
||||||
static void FmoGenerateType4MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice );
|
static void FmoGenerateType2MapUnitMap(VideoParameters *p_Vid,
|
||||||
static void FmoGenerateType5MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice );
|
unsigned PicSizeInMapUnits);
|
||||||
static void FmoGenerateType6MapUnitMap (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,40 +53,43 @@ static void FmoGenerateType6MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static int FmoGenerateMapUnitToSliceGroupMap (VideoParameters *p_Vid, Slice *currSlice)
|
static int FmoGenerateMapUnitToSliceGroupMap(VideoParameters *p_Vid,
|
||||||
{
|
Slice *currSlice) {
|
||||||
seq_parameter_set_rbsp_t *sps = p_Vid->active_sps;
|
seq_parameter_set_rbsp_t *sps = p_Vid->active_sps;
|
||||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||||
|
|
||||||
unsigned int NumSliceGroupMapUnits;
|
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->slice_group_map_type == 6) {
|
||||||
{
|
if ((pps->pic_size_in_map_units_minus1 + 1) != NumSliceGroupMapUnits) {
|
||||||
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",
|
||||||
error ("wrong pps->pic_size_in_map_units_minus1 for used SPS and FMO type 6", 500);
|
500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate memory for p_Vid->MapUnitToSliceGroupMap
|
// allocate memory for p_Vid->MapUnitToSliceGroupMap
|
||||||
if (p_Vid->MapUnitToSliceGroupMap)
|
if (p_Vid->MapUnitToSliceGroupMap)
|
||||||
free(p_Vid->MapUnitToSliceGroupMap);
|
free(p_Vid->MapUnitToSliceGroupMap);
|
||||||
if ((p_Vid->MapUnitToSliceGroupMap = malloc ((NumSliceGroupMapUnits) * sizeof (int))) == NULL)
|
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)));
|
printf(
|
||||||
|
"cannot allocated %d bytes for p_Vid->MapUnitToSliceGroupMap, exit\n",
|
||||||
|
(int)((pps->pic_size_in_map_units_minus1 + 1) * sizeof(int)));
|
||||||
exit(-1);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pps->slice_group_map_type)
|
switch (pps->slice_group_map_type) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
FmoGenerateType0MapUnitMap(p_Vid, NumSliceGroupMapUnits);
|
FmoGenerateType0MapUnitMap(p_Vid, NumSliceGroupMapUnits);
|
||||||
break;
|
break;
|
||||||
|
@ -99,13 +112,13 @@ static int FmoGenerateMapUnitToSliceGroupMap (VideoParameters *p_Vid, Slice *cur
|
||||||
FmoGenerateType6MapUnitMap(p_Vid, NumSliceGroupMapUnits);
|
FmoGenerateType6MapUnitMap(p_Vid, NumSliceGroupMapUnits);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf ("Illegal slice_group_map_type %d , exit \n", (int) pps->slice_group_map_type);
|
printf("Illegal slice_group_map_type %d , exit \n",
|
||||||
|
(int)pps->slice_group_map_type);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -116,8 +129,7 @@ static int FmoGenerateMapUnitToSliceGroupMap (VideoParameters *p_Vid, Slice *cur
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static int FmoGenerateMbToSliceGroupMap (VideoParameters *p_Vid, Slice *pSlice)
|
static int FmoGenerateMbToSliceGroupMap(VideoParameters *p_Vid, Slice *pSlice) {
|
||||||
{
|
|
||||||
seq_parameter_set_rbsp_t *sps = p_Vid->active_sps;
|
seq_parameter_set_rbsp_t *sps = p_Vid->active_sps;
|
||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
@ -126,52 +138,45 @@ static int FmoGenerateMbToSliceGroupMap (VideoParameters *p_Vid, Slice *pSlice)
|
||||||
if (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)
|
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)));
|
printf("cannot allocate %d bytes for p_Vid->MbToSliceGroupMap, exit\n",
|
||||||
|
(int)((p_Vid->PicSizeInMbs) * sizeof(int)));
|
||||||
exit(-1);
|
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 *MbToSliceGroupMap = p_Vid->MbToSliceGroupMap;
|
||||||
int *MapUnitToSliceGroupMap = p_Vid->MapUnitToSliceGroupMap;
|
int *MapUnitToSliceGroupMap = p_Vid->MapUnitToSliceGroupMap;
|
||||||
for (i=0; i<p_Vid->PicSizeInMbs; i++)
|
for (i = 0; i < p_Vid->PicSizeInMbs; i++) {
|
||||||
{
|
|
||||||
*MbToSliceGroupMap++ = *MapUnitToSliceGroupMap++;
|
*MbToSliceGroupMap++ = *MapUnitToSliceGroupMap++;
|
||||||
}
|
}
|
||||||
}
|
} else if (sps->mb_adaptive_frame_field_flag && (!pSlice->field_pic_flag)) {
|
||||||
else
|
for (i = 0; i < p_Vid->PicSizeInMbs; i++) {
|
||||||
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];
|
p_Vid->MbToSliceGroupMap[i] = p_Vid->MapUnitToSliceGroupMap[i / 2];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
for (i = 0; i < p_Vid->PicSizeInMbs; i++) {
|
||||||
{
|
p_Vid->MbToSliceGroupMap[i] =
|
||||||
for (i=0; i<p_Vid->PicSizeInMbs; i++)
|
p_Vid->MapUnitToSliceGroupMap[(i / (2 * p_Vid->PicWidthInMbs)) *
|
||||||
{
|
p_Vid->PicWidthInMbs +
|
||||||
p_Vid->MbToSliceGroupMap[i] = p_Vid->MapUnitToSliceGroupMap[(i/(2*p_Vid->PicWidthInMbs))*p_Vid->PicWidthInMbs+(i%p_Vid->PicWidthInMbs)];
|
(i % p_Vid->PicWidthInMbs)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* FMO initialization: Generates p_Vid->MapUnitToSliceGroupMap and p_Vid->MbToSliceGroupMap.
|
* FMO initialization: Generates p_Vid->MapUnitToSliceGroupMap and
|
||||||
|
*p_Vid->MbToSliceGroupMap.
|
||||||
*
|
*
|
||||||
* \param p_Vid
|
* \param p_Vid
|
||||||
* video encoding parameters for current picture
|
* video encoding parameters for current picture
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
int fmo_init(VideoParameters *p_Vid, Slice *pSlice)
|
int fmo_init(VideoParameters *p_Vid, Slice *pSlice) {
|
||||||
{
|
|
||||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||||
|
|
||||||
#ifdef PRINT_FMO_MAPS
|
#ifdef PRINT_FMO_MAPS
|
||||||
|
@ -187,21 +192,18 @@ int fmo_init(VideoParameters *p_Vid, Slice *pSlice)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("FMO Map (Units):\n");
|
printf("FMO Map (Units):\n");
|
||||||
|
|
||||||
for (j=0; j<p_Vid->PicHeightInMapUnits; j++)
|
for (j = 0; j < p_Vid->PicHeightInMapUnits; j++) {
|
||||||
{
|
for (i = 0; i < p_Vid->PicWidthInMbs; i++) {
|
||||||
for (i=0; i<p_Vid->PicWidthInMbs; i++)
|
printf("%c",
|
||||||
{
|
48 + p_Vid->MapUnitToSliceGroupMap[i + j * p_Vid->PicWidthInMbs]);
|
||||||
printf("%c",48+p_Vid->MapUnitToSliceGroupMap[i+j*p_Vid->PicWidthInMbs]);
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("FMO Map (Mb):\n");
|
printf("FMO Map (Mb):\n");
|
||||||
|
|
||||||
for (j=0; j<p_Vid->PicHeightInMbs; j++)
|
for (j = 0; j < p_Vid->PicHeightInMbs; j++) {
|
||||||
{
|
for (i = 0; i < p_Vid->PicWidthInMbs; i++) {
|
||||||
for (i=0; i<p_Vid->PicWidthInMbs; i++)
|
|
||||||
{
|
|
||||||
printf("%c", 48 + p_Vid->MbToSliceGroupMap[i + j * p_Vid->PicWidthInMbs]);
|
printf("%c", 48 + p_Vid->MbToSliceGroupMap[i + j * p_Vid->PicWidthInMbs]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -213,29 +215,24 @@ int fmo_init(VideoParameters *p_Vid, Slice *pSlice)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Free memory allocated by FMO functions
|
* Free memory allocated by FMO functions
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
int FmoFinit(VideoParameters *p_Vid)
|
int FmoFinit(VideoParameters *p_Vid) {
|
||||||
{
|
if (p_Vid->MbToSliceGroupMap) {
|
||||||
if (p_Vid->MbToSliceGroupMap)
|
|
||||||
{
|
|
||||||
free(p_Vid->MbToSliceGroupMap);
|
free(p_Vid->MbToSliceGroupMap);
|
||||||
p_Vid->MbToSliceGroupMap = NULL;
|
p_Vid->MbToSliceGroupMap = NULL;
|
||||||
}
|
}
|
||||||
if (p_Vid->MapUnitToSliceGroupMap)
|
if (p_Vid->MapUnitToSliceGroupMap) {
|
||||||
{
|
|
||||||
free(p_Vid->MapUnitToSliceGroupMap);
|
free(p_Vid->MapUnitToSliceGroupMap);
|
||||||
p_Vid->MapUnitToSliceGroupMap = NULL;
|
p_Vid->MapUnitToSliceGroupMap = NULL;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -245,12 +242,10 @@ int FmoFinit(VideoParameters *p_Vid)
|
||||||
* VideoParameters
|
* VideoParameters
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
int FmoGetNumberOfSliceGroup(VideoParameters *p_Vid)
|
int FmoGetNumberOfSliceGroup(VideoParameters *p_Vid) {
|
||||||
{
|
|
||||||
return p_Vid->NumberOfSliceGroups;
|
return p_Vid->NumberOfSliceGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -263,12 +258,10 @@ int FmoGetNumberOfSliceGroup(VideoParameters *p_Vid)
|
||||||
* None
|
* None
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
int FmoGetLastMBOfPicture(VideoParameters *p_Vid)
|
int FmoGetLastMBOfPicture(VideoParameters *p_Vid) {
|
||||||
{
|
|
||||||
return FmoGetLastMBInSliceGroup(p_Vid, FmoGetNumberOfSliceGroup(p_Vid) - 1);
|
return FmoGetLastMBInSliceGroup(p_Vid, FmoGetNumberOfSliceGroup(p_Vid) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \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;
|
int i;
|
||||||
|
|
||||||
for (i = p_Vid->PicSizeInMbs - 1; i >= 0; i--)
|
for (i = p_Vid->PicSizeInMbs - 1; i >= 0; i--)
|
||||||
if (FmoGetSliceGroupId(p_Vid, i) == SliceGroup)
|
if (FmoGetSliceGroupId(p_Vid, i) == SliceGroup)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -302,14 +292,12 @@ int FmoGetLastMBInSliceGroup (VideoParameters *p_Vid, int SliceGroup)
|
||||||
* Macroblock number (in scan order)
|
* Macroblock number (in scan order)
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
int FmoGetSliceGroupId (VideoParameters *p_Vid, int mb)
|
int FmoGetSliceGroupId(VideoParameters *p_Vid, int mb) {
|
||||||
{
|
|
||||||
assert(mb < (int)p_Vid->PicSizeInMbs);
|
assert(mb < (int)p_Vid->PicSizeInMbs);
|
||||||
assert(p_Vid->MbToSliceGroupMap != NULL);
|
assert(p_Vid->MbToSliceGroupMap != NULL);
|
||||||
return p_Vid->MbToSliceGroupMap[mb];
|
return p_Vid->MbToSliceGroupMap[mb];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -322,11 +310,11 @@ int FmoGetSliceGroupId (VideoParameters *p_Vid, int mb)
|
||||||
* number of the current macroblock
|
* number of the current macroblock
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
int FmoGetNextMBNr (VideoParameters *p_Vid, int CurrentMbNr)
|
int FmoGetNextMBNr(VideoParameters *p_Vid, int CurrentMbNr) {
|
||||||
{
|
|
||||||
int SliceGroup = FmoGetSliceGroupId(p_Vid, 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)
|
if (CurrentMbNr >= (int)p_Vid->PicSizeInMbs)
|
||||||
|
@ -335,7 +323,6 @@ int FmoGetNextMBNr (VideoParameters *p_Vid, int CurrentMbNr)
|
||||||
return CurrentMbNr;
|
return CurrentMbNr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -343,24 +330,22 @@ int FmoGetNextMBNr (VideoParameters *p_Vid, int CurrentMbNr)
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static void FmoGenerateType0MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits )
|
static void FmoGenerateType0MapUnitMap(VideoParameters *p_Vid,
|
||||||
{
|
unsigned PicSizeInMapUnits) {
|
||||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||||
unsigned iGroup, j;
|
unsigned iGroup, j;
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
for (iGroup = 0;
|
for (iGroup = 0;
|
||||||
(iGroup <= pps->num_slice_groups_minus1) && (i < PicSizeInMapUnits);
|
(iGroup <= pps->num_slice_groups_minus1) && (i < PicSizeInMapUnits);
|
||||||
i += pps->run_length_minus1[iGroup++] + 1 )
|
i += pps->run_length_minus1[iGroup++] + 1) {
|
||||||
{
|
for (j = 0;
|
||||||
for( j = 0; j <= pps->run_length_minus1[ iGroup ] && i + j < PicSizeInMapUnits; j++ )
|
j <= pps->run_length_minus1[iGroup] && i + j < PicSizeInMapUnits;
|
||||||
|
j++)
|
||||||
p_Vid->MapUnitToSliceGroupMap[i + j] = iGroup;
|
p_Vid->MapUnitToSliceGroupMap[i + j] = iGroup;
|
||||||
}
|
}
|
||||||
|
} while (i < PicSizeInMapUnits);
|
||||||
}
|
}
|
||||||
while( i < PicSizeInMapUnits );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
@ -369,26 +354,29 @@ static void FmoGenerateType0MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static void FmoGenerateType1MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits )
|
static void FmoGenerateType1MapUnitMap(VideoParameters *p_Vid,
|
||||||
{
|
unsigned PicSizeInMapUnits) {
|
||||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for( i = 0; i < PicSizeInMapUnits; i++ )
|
for (i = 0; i < PicSizeInMapUnits; i++) {
|
||||||
{
|
p_Vid->MapUnitToSliceGroupMap[i] =
|
||||||
p_Vid->MapUnitToSliceGroupMap[i] = ((i%p_Vid->PicWidthInMbs)+(((i/p_Vid->PicWidthInMbs)*(pps->num_slice_groups_minus1+1))/2))
|
((i % p_Vid->PicWidthInMbs) +
|
||||||
%(pps->num_slice_groups_minus1+1);
|
(((i / p_Vid->PicWidthInMbs) * (pps->num_slice_groups_minus1 + 1)) /
|
||||||
|
2)) %
|
||||||
|
(pps->num_slice_groups_minus1 + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \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 )
|
static void FmoGenerateType2MapUnitMap(VideoParameters *p_Vid,
|
||||||
{
|
unsigned PicSizeInMapUnits) {
|
||||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||||
int iGroup;
|
int iGroup;
|
||||||
unsigned i, x, y;
|
unsigned i, x, y;
|
||||||
|
@ -397,8 +385,7 @@ static void FmoGenerateType2MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
||||||
for (i = 0; i < PicSizeInMapUnits; i++)
|
for (i = 0; i < PicSizeInMapUnits; i++)
|
||||||
p_Vid->MapUnitToSliceGroupMap[i] = pps->num_slice_groups_minus1;
|
p_Vid->MapUnitToSliceGroupMap[i] = pps->num_slice_groups_minus1;
|
||||||
|
|
||||||
for( iGroup = pps->num_slice_groups_minus1 - 1 ; iGroup >= 0; iGroup-- )
|
for (iGroup = pps->num_slice_groups_minus1 - 1; iGroup >= 0; iGroup--) {
|
||||||
{
|
|
||||||
yTopLeft = pps->top_left[iGroup] / p_Vid->PicWidthInMbs;
|
yTopLeft = pps->top_left[iGroup] / p_Vid->PicWidthInMbs;
|
||||||
xTopLeft = pps->top_left[iGroup] % p_Vid->PicWidthInMbs;
|
xTopLeft = pps->top_left[iGroup] % p_Vid->PicWidthInMbs;
|
||||||
yBottomRight = pps->bottom_right[iGroup] / p_Vid->PicWidthInMbs;
|
yBottomRight = pps->bottom_right[iGroup] / p_Vid->PicWidthInMbs;
|
||||||
|
@ -409,7 +396,6 @@ static void FmoGenerateType2MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -417,15 +403,19 @@ static void FmoGenerateType2MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static void FmoGenerateType3MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice )
|
static void FmoGenerateType3MapUnitMap(VideoParameters *p_Vid,
|
||||||
{
|
unsigned PicSizeInMapUnits,
|
||||||
|
Slice *currSlice) {
|
||||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||||
unsigned i, k;
|
unsigned i, k;
|
||||||
int leftBound, topBound, rightBound, bottomBound;
|
int leftBound, topBound, rightBound, bottomBound;
|
||||||
int x, y, xDir, yDir;
|
int x, y, xDir, yDir;
|
||||||
int mapUnitVacant;
|
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++)
|
for (i = 0; i < PicSizeInMapUnits; i++)
|
||||||
p_Vid->MapUnitToSliceGroupMap[i] = 2;
|
p_Vid->MapUnitToSliceGroupMap[i] = 2;
|
||||||
|
@ -441,50 +431,38 @@ static void FmoGenerateType3MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
||||||
xDir = pps->slice_group_change_direction_flag - 1;
|
xDir = pps->slice_group_change_direction_flag - 1;
|
||||||
yDir = pps->slice_group_change_direction_flag;
|
yDir = pps->slice_group_change_direction_flag;
|
||||||
|
|
||||||
for( k = 0; k < PicSizeInMapUnits; k += mapUnitVacant )
|
for (k = 0; k < PicSizeInMapUnits; k += mapUnitVacant) {
|
||||||
{
|
mapUnitVacant =
|
||||||
mapUnitVacant = ( p_Vid->MapUnitToSliceGroupMap[ y * p_Vid->PicWidthInMbs + x ] == 2 );
|
(p_Vid->MapUnitToSliceGroupMap[y * p_Vid->PicWidthInMbs + x] == 2);
|
||||||
if (mapUnitVacant)
|
if (mapUnitVacant)
|
||||||
p_Vid->MapUnitToSliceGroupMap[ y * p_Vid->PicWidthInMbs + x ] = ( k >= mapUnitsInSliceGroup0 );
|
p_Vid->MapUnitToSliceGroupMap[y * p_Vid->PicWidthInMbs + x] =
|
||||||
|
(k >= mapUnitsInSliceGroup0);
|
||||||
|
|
||||||
if( xDir == -1 && x == leftBound )
|
if (xDir == -1 && x == leftBound) {
|
||||||
{
|
|
||||||
leftBound = imax(leftBound - 1, 0);
|
leftBound = imax(leftBound - 1, 0);
|
||||||
x = leftBound;
|
x = leftBound;
|
||||||
xDir = 0;
|
xDir = 0;
|
||||||
yDir = 2 * pps->slice_group_change_direction_flag - 1;
|
yDir = 2 * pps->slice_group_change_direction_flag - 1;
|
||||||
}
|
} else if (xDir == 1 && x == rightBound) {
|
||||||
else
|
|
||||||
if( xDir == 1 && x == rightBound )
|
|
||||||
{
|
|
||||||
rightBound = imin(rightBound + 1, (int)p_Vid->PicWidthInMbs - 1);
|
rightBound = imin(rightBound + 1, (int)p_Vid->PicWidthInMbs - 1);
|
||||||
x = rightBound;
|
x = rightBound;
|
||||||
xDir = 0;
|
xDir = 0;
|
||||||
yDir = 1 - 2 * pps->slice_group_change_direction_flag;
|
yDir = 1 - 2 * pps->slice_group_change_direction_flag;
|
||||||
}
|
} else if (yDir == -1 && y == topBound) {
|
||||||
else
|
|
||||||
if( yDir == -1 && y == topBound )
|
|
||||||
{
|
|
||||||
topBound = imax(topBound - 1, 0);
|
topBound = imax(topBound - 1, 0);
|
||||||
y = topBound;
|
y = topBound;
|
||||||
xDir = 1 - 2 * pps->slice_group_change_direction_flag;
|
xDir = 1 - 2 * pps->slice_group_change_direction_flag;
|
||||||
yDir = 0;
|
yDir = 0;
|
||||||
}
|
} else if (yDir == 1 && y == bottomBound) {
|
||||||
else
|
|
||||||
if( yDir == 1 && y == bottomBound )
|
|
||||||
{
|
|
||||||
bottomBound = imin(bottomBound + 1, (int)p_Vid->PicHeightInMapUnits - 1);
|
bottomBound = imin(bottomBound + 1, (int)p_Vid->PicHeightInMapUnits - 1);
|
||||||
y = bottomBound;
|
y = bottomBound;
|
||||||
xDir = 2 * pps->slice_group_change_direction_flag - 1;
|
xDir = 2 * pps->slice_group_change_direction_flag - 1;
|
||||||
yDir = 0;
|
yDir = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
x = x + xDir;
|
x = x + xDir;
|
||||||
y = y + yDir;
|
y = y + yDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -494,12 +472,19 @@ static void FmoGenerateType3MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static void FmoGenerateType4MapUnitMap (VideoParameters *p_Vid, unsigned PicSizeInMapUnits, Slice *currSlice )
|
static void FmoGenerateType4MapUnitMap(VideoParameters *p_Vid,
|
||||||
{
|
unsigned PicSizeInMapUnits,
|
||||||
|
Slice *currSlice) {
|
||||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
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 mapUnitsInSliceGroup0 =
|
||||||
unsigned sizeOfUpperLeftGroup = pps->slice_group_change_direction_flag ? ( PicSizeInMapUnits - mapUnitsInSliceGroup0 ) : 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;
|
unsigned i;
|
||||||
|
|
||||||
|
@ -507,8 +492,8 @@ static void FmoGenerateType4MapUnitMap (VideoParameters *p_Vid, unsigned PicSize
|
||||||
if (i < sizeOfUpperLeftGroup)
|
if (i < sizeOfUpperLeftGroup)
|
||||||
p_Vid->MapUnitToSliceGroupMap[i] = pps->slice_group_change_direction_flag;
|
p_Vid->MapUnitToSliceGroupMap[i] = pps->slice_group_change_direction_flag;
|
||||||
else
|
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 )
|
static void FmoGenerateType5MapUnitMap(VideoParameters *p_Vid,
|
||||||
{
|
unsigned PicSizeInMapUnits,
|
||||||
|
Slice *currSlice) {
|
||||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
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 mapUnitsInSliceGroup0 =
|
||||||
unsigned sizeOfUpperLeftGroup = pps->slice_group_change_direction_flag ? ( PicSizeInMapUnits - mapUnitsInSliceGroup0 ) : 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;
|
unsigned i, j, k = 0;
|
||||||
|
|
||||||
for (j = 0; j < p_Vid->PicWidthInMbs; j++)
|
for (j = 0; j < p_Vid->PicWidthInMbs; j++)
|
||||||
for (i = 0; i < p_Vid->PicHeightInMapUnits; i++)
|
for (i = 0; i < p_Vid->PicHeightInMapUnits; i++)
|
||||||
if (k++ < sizeOfUpperLeftGroup)
|
if (k++ < sizeOfUpperLeftGroup)
|
||||||
p_Vid->MapUnitToSliceGroupMap[ i * p_Vid->PicWidthInMbs + j ] = pps->slice_group_change_direction_flag;
|
p_Vid->MapUnitToSliceGroupMap[i * p_Vid->PicWidthInMbs + j] =
|
||||||
|
pps->slice_group_change_direction_flag;
|
||||||
else
|
else
|
||||||
p_Vid->MapUnitToSliceGroupMap[ i * p_Vid->PicWidthInMbs + j ] = 1 - pps->slice_group_change_direction_flag;
|
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 )
|
static void FmoGenerateType6MapUnitMap(VideoParameters *p_Vid,
|
||||||
{
|
unsigned PicSizeInMapUnits) {
|
||||||
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
pic_parameter_set_rbsp_t *pps = p_Vid->active_pps;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i=0; i<PicSizeInMapUnits; i++)
|
for (i = 0; i < PicSizeInMapUnits; i++) {
|
||||||
{
|
|
||||||
p_Vid->MapUnitToSliceGroupMap[i] = pps->slice_group_id[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
|
* image I/O related functions
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
#include "img_io.h"
|
||||||
#include "contributors.h"
|
#include "contributors.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "img_io.h"
|
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
#ifdef SPEC
|
#ifdef SPEC
|
||||||
#define STRCMP strcmp
|
#define STRCMP strcmp
|
||||||
|
@ -22,19 +23,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const VIDEO_SIZE VideoRes[] = {
|
static const VIDEO_SIZE VideoRes[] = {
|
||||||
{ "qcif" , 176, 144},
|
{"qcif", 176, 144}, {"qqvga", 160, 128}, {"qvga", 320, 240},
|
||||||
{ "qqvga" , 160, 128},
|
{"sif", 352, 240}, {"cif", 352, 288}, {"vga", 640, 480},
|
||||||
{ "qvga" , 320, 240},
|
{"sd1", 720, 480}, {"sd2", 704, 576}, {"sd3", 720, 576},
|
||||||
{ "sif" , 352, 240},
|
{"720p", 1280, 720}, {"1080p", 1920, 1080}, {NULL, 0, 0}};
|
||||||
{ "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 *p1, *p2, *tail;
|
||||||
char *fn = input_file->fname;
|
char *fn = input_file->fname;
|
||||||
char c;
|
char c;
|
||||||
|
@ -52,8 +44,7 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
||||||
|
|
||||||
*x_size = *y_size = -1;
|
*x_size = *y_size = -1;
|
||||||
p1 = p2 = fn;
|
p1 = p2 = fn;
|
||||||
while (p1 != NULL && p2 != NULL)
|
while (p1 != NULL && p2 != NULL) {
|
||||||
{
|
|
||||||
// Search for first '_'
|
// Search for first '_'
|
||||||
p1 = strstr(p1, "_");
|
p1 = strstr(p1, "_");
|
||||||
if (p1 == NULL)
|
if (p1 == NULL)
|
||||||
|
@ -70,9 +61,9 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
||||||
*p2 = 0;
|
*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 there are characters left in the string, or the string is null,
|
||||||
if (*tail != '\0' || *(p1 + 1) == '\0')
|
// discard conversion
|
||||||
{
|
if (*tail != '\0' || *(p1 + 1) == '\0') {
|
||||||
*p2 = 'x';
|
*p2 = 'x';
|
||||||
p1 = tail;
|
p1 = tail;
|
||||||
continue;
|
continue;
|
||||||
|
@ -84,8 +75,7 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
||||||
// Search for end character of y_size (first '_' or '.' after last '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 no '_' or '.' is found, try again from current position
|
||||||
if (p1 == NULL)
|
if (p1 == NULL) {
|
||||||
{
|
|
||||||
p1 = p2 + 1;
|
p1 = p2 + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -95,9 +85,9 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
||||||
*p1 = 0;
|
*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 there are characters left in the string, or the string is null,
|
||||||
if (*tail != '\0' || *(p2 + 1) == '\0')
|
// discard conversion
|
||||||
{
|
if (*tail != '\0' || *(p2 + 1) == '\0') {
|
||||||
*p1 = c;
|
*p1 = c;
|
||||||
p1 = tail;
|
p1 = tail;
|
||||||
continue;
|
continue;
|
||||||
|
@ -118,9 +108,9 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
||||||
*p2 = 0;
|
*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 there are characters left in the string, or the string is null,
|
||||||
if (*tail != '\0' || *(p1 + 1) == '\0')
|
// discard conversion
|
||||||
{
|
if (*tail != '\0' || *(p1 + 1) == '\0') {
|
||||||
*p2 = c;
|
*p2 = c;
|
||||||
p1 = tail;
|
p1 = tail;
|
||||||
continue;
|
continue;
|
||||||
|
@ -132,12 +122,9 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now lets test some common video file formats
|
// Now lets test some common video file formats
|
||||||
if (p1 == NULL || p2 == NULL)
|
if (p1 == NULL || p2 == NULL) {
|
||||||
{
|
for (i = 0; VideoRes[i].name != NULL; i++) {
|
||||||
for (i = 0; VideoRes[i].name != NULL; i++)
|
if (STRCMP(fn, VideoRes[i].name)) {
|
||||||
{
|
|
||||||
if (STRCMP (fn, VideoRes[i].name))
|
|
||||||
{
|
|
||||||
*x_size = VideoRes[i].x_size;
|
*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
|
// Should add frame rate support as well
|
||||||
|
@ -156,8 +143,7 @@ int ParseSizeFromString (VideoDataFile *input_file, int *x_size, int *y_size, do
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void ParseFrameNoFormatFromString (VideoDataFile *input_file)
|
void ParseFrameNoFormatFromString(VideoDataFile *input_file) {
|
||||||
{
|
|
||||||
char *p1, *p2, *tail;
|
char *p1, *p2, *tail;
|
||||||
char *fn = input_file->fname;
|
char *fn = input_file->fname;
|
||||||
char *fhead = input_file->fhead;
|
char *fhead = input_file->fhead;
|
||||||
|
@ -168,8 +154,7 @@ void ParseFrameNoFormatFromString (VideoDataFile *input_file)
|
||||||
*zero_pad = 0;
|
*zero_pad = 0;
|
||||||
*num_digits = -1;
|
*num_digits = -1;
|
||||||
p1 = p2 = fn;
|
p1 = p2 = fn;
|
||||||
while (p1 != NULL && p2 != NULL)
|
while (p1 != NULL && p2 != NULL) {
|
||||||
{
|
|
||||||
// Search for first '_'
|
// Search for first '_'
|
||||||
p1 = strstr(p1, "%");
|
p1 = strstr(p1, "%");
|
||||||
if (p1 == NULL)
|
if (p1 == NULL)
|
||||||
|
@ -192,9 +177,9 @@ void ParseFrameNoFormatFromString (VideoDataFile *input_file)
|
||||||
|
|
||||||
*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 there are characters left in the string, or the string is null,
|
||||||
if (*tail != '\0' || *(p1 + 1) == '\0')
|
// discard conversion
|
||||||
{
|
if (*tail != '\0' || *(p1 + 1) == '\0') {
|
||||||
*p2 = 'd';
|
*p2 = 'd';
|
||||||
p1 = tail;
|
p1 = tail;
|
||||||
continue;
|
continue;
|
||||||
|
@ -208,11 +193,9 @@ void ParseFrameNoFormatFromString (VideoDataFile *input_file)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_file->vdtype == VIDEO_TIFF)
|
if (input_file->vdtype == VIDEO_TIFF) {
|
||||||
{
|
|
||||||
input_file->is_concatenated = 0;
|
input_file->is_concatenated = 0;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
input_file->is_concatenated = (*num_digits == -1) ? 1 : 0;
|
input_file->is_concatenated = (*num_digits == -1) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,8 +205,7 @@ void ParseFrameNoFormatFromString (VideoDataFile *input_file)
|
||||||
* Open file containing a single frame
|
* Open file containing a single frame
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void OpenFrameFile( VideoDataFile *input_file, int FrameNumberInFile)
|
void OpenFrameFile(VideoDataFile *input_file, int FrameNumberInFile) {
|
||||||
{
|
|
||||||
char infile[FILE_NAME_SIZE], in_number[16];
|
char infile[FILE_NAME_SIZE], in_number[16];
|
||||||
int length = 0;
|
int length = 0;
|
||||||
in_number[length] = '\0';
|
in_number[length] = '\0';
|
||||||
|
@ -242,8 +224,7 @@ void OpenFrameFile( VideoDataFile *input_file, int FrameNumberInFile)
|
||||||
length += (int)strlen(input_file->ftail);
|
length += (int)strlen(input_file->ftail);
|
||||||
infile[length] = '\0';
|
infile[length] = '\0';
|
||||||
|
|
||||||
if ((input_file->f_num = open(infile, OPENFLAGS_READ)) == -1)
|
if ((input_file->f_num = open(infile, OPENFLAGS_READ)) == -1) {
|
||||||
{
|
|
||||||
printf("OpenFrameFile: cannot open file %s\n", infile);
|
printf("OpenFrameFile: cannot open file %s\n", infile);
|
||||||
report_stats_on_error();
|
report_stats_on_error();
|
||||||
}
|
}
|
||||||
|
@ -255,19 +236,17 @@ void OpenFrameFile( VideoDataFile *input_file, int FrameNumberInFile)
|
||||||
* Open file(s) containing the entire frame sequence
|
* Open file(s) containing the entire frame sequence
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void OpenFiles( VideoDataFile *input_file)
|
void OpenFiles(VideoDataFile *input_file) {
|
||||||
{
|
if (input_file->is_concatenated == 1) {
|
||||||
if (input_file->is_concatenated == 1)
|
if ((int)strlen(input_file->fname) == 0) {
|
||||||
{
|
snprintf(errortext, ET_SIZE,
|
||||||
if ((int) strlen(input_file->fname) == 0)
|
"No input sequence name was provided. Please check settings.");
|
||||||
{
|
|
||||||
snprintf(errortext, ET_SIZE, "No input sequence name was provided. Please check settings.");
|
|
||||||
error(errortext, 500);
|
error(errortext, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((input_file->f_num = open(input_file->fname, OPENFLAGS_READ)) == -1)
|
if ((input_file->f_num = open(input_file->fname, OPENFLAGS_READ)) == -1) {
|
||||||
{
|
snprintf(errortext, ET_SIZE, "Input file %s does not exist",
|
||||||
snprintf(errortext, ET_SIZE, "Input file %s does not exist",input_file->fname);
|
input_file->fname);
|
||||||
error(errortext, 500);
|
error(errortext, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,8 +258,7 @@ void OpenFiles( VideoDataFile *input_file)
|
||||||
* Close input file
|
* Close input file
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void CloseFiles(VideoDataFile *input_file)
|
void CloseFiles(VideoDataFile *input_file) {
|
||||||
{
|
|
||||||
if (input_file->f_num != -1)
|
if (input_file->f_num != -1)
|
||||||
close(input_file->f_num);
|
close(input_file->f_num);
|
||||||
input_file->f_num = -1;
|
input_file->f_num = -1;
|
||||||
|
@ -292,35 +270,25 @@ void CloseFiles(VideoDataFile *input_file)
|
||||||
*
|
*
|
||||||
* ==========================================================================
|
* ==========================================================================
|
||||||
*/
|
*/
|
||||||
VideoFileType ParseVideoType (VideoDataFile *input_file)
|
VideoFileType ParseVideoType(VideoDataFile *input_file) {
|
||||||
{
|
|
||||||
char *format;
|
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->vdtype = VIDEO_YUV;
|
||||||
input_file->format.yuv_format = YUV420;
|
input_file->format.yuv_format = YUV420;
|
||||||
input_file->avi = NULL;
|
input_file->avi = NULL;
|
||||||
}
|
} else if (STRCMP(format, "rgb") == 0) {
|
||||||
else if (STRCMP (format, "rgb") == 0)
|
|
||||||
{
|
|
||||||
input_file->vdtype = VIDEO_RGB;
|
input_file->vdtype = VIDEO_RGB;
|
||||||
input_file->format.yuv_format = YUV444;
|
input_file->format.yuv_format = YUV444;
|
||||||
input_file->avi = NULL;
|
input_file->avi = NULL;
|
||||||
}
|
} else if (STRCMP(format, "tif") == 0) {
|
||||||
else if (STRCMP (format, "tif") == 0)
|
|
||||||
{
|
|
||||||
input_file->vdtype = VIDEO_TIFF;
|
input_file->vdtype = VIDEO_TIFF;
|
||||||
input_file->avi = NULL;
|
input_file->avi = NULL;
|
||||||
}
|
} else if (STRCMP(format, "avi") == 0) {
|
||||||
else if (STRCMP (format, "avi") == 0)
|
|
||||||
{
|
|
||||||
input_file->vdtype = VIDEO_AVI;
|
input_file->vdtype = VIDEO_AVI;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// snprintf(errortext, ET_SIZE, "ERROR: video file format not supported");
|
// snprintf(errortext, ET_SIZE, "ERROR: video file format not supported");
|
||||||
// error (errortext, 500);
|
// error (errortext, 500);
|
||||||
input_file->vdtype = VIDEO_YUV;
|
input_file->vdtype = VIDEO_YUV;
|
||||||
|
|
|
@ -6,42 +6,40 @@
|
||||||
* Input data Image Processing functions
|
* Input data Image Processing functions
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Michael Tourapis <alexis.tourapis@dolby.com>
|
||||||
*
|
*
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contributors.h"
|
|
||||||
#include "global.h"
|
|
||||||
#include "img_process.h"
|
#include "img_process.h"
|
||||||
|
#include "contributors.h"
|
||||||
|
#include "fast_memory.h"
|
||||||
|
#include "global.h"
|
||||||
#include "io_image.h"
|
#include "io_image.h"
|
||||||
#include "memalloc.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)
|
if (imgOut->format.yuv_format != YUV400) {
|
||||||
{
|
if (sizeof(imgpel) == sizeof(signed char)) {
|
||||||
fast_memset(imgOut->frm_data[0][0], 0, imgOut->format.height[0] * imgOut->format.width[0] * sizeof (imgpel));
|
fast_memset(imgOut->frm_data[1][0], 128,
|
||||||
|
imgOut->format.height[1] * imgOut->format.width[1] *
|
||||||
if (imgOut->format.yuv_format != YUV400)
|
sizeof(imgpel));
|
||||||
{
|
fast_memset(imgOut->frm_data[2][0], 128,
|
||||||
if (sizeof(imgpel) == sizeof(signed char))
|
imgOut->format.height[1] * imgOut->format.width[1] *
|
||||||
{
|
sizeof(imgpel));
|
||||||
fast_memset(imgOut->frm_data[1][0], 128, imgOut->format.height[1] * imgOut->format.width[1] * sizeof (imgpel));
|
} else {
|
||||||
fast_memset(imgOut->frm_data[2][0], 128, imgOut->format.height[1] * imgOut->format.width[1] * sizeof (imgpel));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
imgpel med_value;
|
imgpel med_value;
|
||||||
for (k = 1; k <=2; k++)
|
for (k = 1; k <= 2; k++) {
|
||||||
{
|
|
||||||
med_value = (imgpel)(imgOut->format.max_value[k] + 1) >> 1;
|
med_value = (imgpel)(imgOut->format.max_value[k] + 1) >> 1;
|
||||||
for (j = 0; j < imgOut->format.height[1]; j++)
|
for (j = 0; j < imgOut->format.height[1]; j++) {
|
||||||
{
|
for (i = 0; i < imgOut->format.width[1]; i++) {
|
||||||
for (i = 0; i < imgOut->format.width[1]; i++)
|
|
||||||
{
|
|
||||||
imgOut->frm_data[k][j][i] = med_value;
|
imgOut->frm_data[k][j][i] = med_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,66 +48,66 @@ 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)
|
if (imgIn->format.yuv_format != YUV400) {
|
||||||
{
|
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[1][0],
|
||||||
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0], imgIn->format.height[0] * imgIn->format.width[0] * sizeof (imgpel));
|
imgIn->format.height[1] * imgIn->format.width[1] * sizeof(imgpel));
|
||||||
|
memcpy(imgOut->frm_data[2][0], imgIn->frm_data[2][0],
|
||||||
if (imgIn->format.yuv_format != YUV400)
|
imgIn->format.height[1] * imgIn->format.width[1] * sizeof(imgpel));
|
||||||
{
|
|
||||||
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
|
// to be modified
|
||||||
static inline void FilterImage(ImageData *imgOut, ImageData *imgIn)
|
static inline void FilterImage(ImageData *imgOut, ImageData *imgIn) {
|
||||||
{
|
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0],
|
||||||
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0], imgIn->format.height[0] * imgIn->format.width[0] * sizeof (imgpel));
|
imgIn->format.height[0] * imgIn->format.width[0] * sizeof(imgpel));
|
||||||
|
|
||||||
if (imgIn->format.yuv_format != YUV400)
|
if (imgIn->format.yuv_format != YUV400) {
|
||||||
{
|
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[1][0],
|
||||||
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[1][0], imgIn->format.height[1] * imgIn->format.width[1] * sizeof (imgpel));
|
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));
|
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
|
// Line interleaving for 3:2 pulldown
|
||||||
static inline void BlendImageLines(ImageData *imgIn0, ImageData *imgIn1)
|
static inline void BlendImageLines(ImageData *imgIn0, ImageData *imgIn1) {
|
||||||
{
|
|
||||||
int j;
|
int j;
|
||||||
for (j = 1; j < imgIn1->format.height[0]; j += 2)
|
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)
|
if (imgIn1->format.yuv_format != YUV400) {
|
||||||
{
|
for (j = 1; j < imgIn1->format.height[1]; j += 2) {
|
||||||
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));
|
||||||
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)
|
for (j = 1; j < imgIn1->format.height[2]; j += 2) {
|
||||||
{
|
memcpy(imgIn0->frm_data[2][j], imgIn1->frm_data[2][j],
|
||||||
memcpy(imgIn0->frm_data[2][j], imgIn1->frm_data[2][j], imgIn1->format.width[2] * sizeof (imgpel));
|
imgIn1->format.width[2] * sizeof(imgpel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// to be modified
|
// to be modified
|
||||||
static inline void FilterImageSep(ImageData *imgOut, ImageData *imgIn)
|
static inline void FilterImageSep(ImageData *imgOut, ImageData *imgIn) {
|
||||||
{
|
|
||||||
int i, j;
|
int i, j;
|
||||||
static const int SepFilter[6] = {1, -5, 20, 20, -5, 1};
|
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 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
|
// implementation was not optimized. only just implemented as proof of concept
|
||||||
// horizontal filtering
|
// horizontal filtering
|
||||||
for (j = 0; j < imgOut->format.height[0]; j++)
|
for (j = 0; j < imgOut->format.height[0]; j++) {
|
||||||
{
|
for (i = 0; i < imgOut->format.width[0]; i++) {
|
||||||
for (i = 0; i < imgOut->format.width[0]; i++)
|
|
||||||
{
|
|
||||||
temp_data[j][i] =
|
temp_data[j][i] =
|
||||||
SepFilter[0] * imgIn->frm_data[0][j][iClip3(0, max_width, i - 2)] +
|
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[1] * imgIn->frm_data[0][j][iClip3(0, max_width, i - 1)] +
|
||||||
|
@ -120,54 +118,59 @@ static inline void FilterImageSep(ImageData *imgOut, ImageData *imgIn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < imgOut->format.height[0]; j++)
|
for (j = 0; j < imgOut->format.height[0]; j++) {
|
||||||
{
|
for (i = 0; i < imgOut->format.width[0]; i++) {
|
||||||
for (i = 0; i < imgOut->format.width[0]; i++)
|
imgOut->frm_data[0][j][i] = (imgpel)iClip3(
|
||||||
{
|
0, imgOut->format.max_value[0],
|
||||||
imgOut->frm_data[0][j][i] = (imgpel) iClip3(0, imgOut->format.max_value[0], rshift_rnd_sign(
|
rshift_rnd_sign(
|
||||||
SepFilter[0] * temp_data[iClip3(0, max_height, j - 2)][i] +
|
SepFilter[0] * temp_data[iClip3(0, max_height, j - 2)][i] +
|
||||||
SepFilter[1] * temp_data[iClip3(0, max_height, j - 1)][i] +
|
SepFilter[1] * temp_data[iClip3(0, max_height, j - 1)][i] +
|
||||||
SepFilter[2] * temp_data[iClip3(0, max_height, j)][i] +
|
SepFilter[2] * temp_data[iClip3(0, max_height, j)][i] +
|
||||||
SepFilter[3] * temp_data[iClip3(0, max_height, j + 1)][i] +
|
SepFilter[3] * temp_data[iClip3(0, max_height, j + 1)][i] +
|
||||||
SepFilter[4] * temp_data[iClip3(0, max_height, j + 2)][i] +
|
SepFilter[4] * temp_data[iClip3(0, max_height, j + 2)][i] +
|
||||||
SepFilter[5] * temp_data[iClip3(0, max_height, j + 3)][i], 10));
|
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;
|
int k;
|
||||||
max_width = imgOut->format.width[1] - 1;
|
max_width = imgOut->format.width[1] - 1;
|
||||||
max_height = imgOut->format.height[1] - 1;
|
max_height = imgOut->format.height[1] - 1;
|
||||||
|
|
||||||
for (k = 1; k <=2; k++)
|
for (k = 1; k <= 2; k++) {
|
||||||
{
|
|
||||||
// horizontal filtering
|
// horizontal filtering
|
||||||
for (j = 0; j < imgOut->format.height[1]; j++)
|
for (j = 0; j < imgOut->format.height[1]; j++) {
|
||||||
{
|
for (i = 0; i < imgOut->format.width[1]; i++) {
|
||||||
for (i = 0; i < imgOut->format.width[1]; i++)
|
|
||||||
{
|
|
||||||
temp_data[j][i] =
|
temp_data[j][i] =
|
||||||
SepFilter[0] * imgIn->frm_data[k][j][iClip3(0, max_width, i - 2)] +
|
SepFilter[0] *
|
||||||
SepFilter[1] * imgIn->frm_data[k][j][iClip3(0, max_width, i - 1)] +
|
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[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[3] *
|
||||||
SepFilter[4] * imgIn->frm_data[k][j][iClip3(0, max_width, i + 2)] +
|
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)];
|
SepFilter[5] * imgIn->frm_data[k][j][iClip3(0, max_width, i + 3)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < imgOut->format.height[1]; j++)
|
for (j = 0; j < imgOut->format.height[1]; j++) {
|
||||||
{
|
for (i = 0; i < imgOut->format.width[1]; i++) {
|
||||||
for (i = 0; i < imgOut->format.width[1]; i++)
|
imgOut->frm_data[k][j][i] = (imgpel)iClip3(
|
||||||
{
|
0, imgOut->format.max_value[k],
|
||||||
imgOut->frm_data[k][j][i] = (imgpel) iClip3(0, imgOut->format.max_value[k], rshift_rnd_sign(
|
rshift_rnd_sign(
|
||||||
SepFilter[0] * temp_data[iClip3(0, max_height, j - 2)][i] +
|
SepFilter[0] * temp_data[iClip3(0, max_height, j - 2)][i] +
|
||||||
SepFilter[1] * temp_data[iClip3(0, max_height, j - 1)][i] +
|
SepFilter[1] *
|
||||||
|
temp_data[iClip3(0, max_height, j - 1)][i] +
|
||||||
SepFilter[2] * temp_data[iClip3(0, max_height, j)][i] +
|
SepFilter[2] * temp_data[iClip3(0, max_height, j)][i] +
|
||||||
SepFilter[3] * temp_data[iClip3(0, max_height, j + 1)][i] +
|
SepFilter[3] *
|
||||||
SepFilter[4] * temp_data[iClip3(0, max_height, j + 2)][i] +
|
temp_data[iClip3(0, max_height, j + 1)][i] +
|
||||||
SepFilter[5] * temp_data[iClip3(0, max_height, j + 3)][i], 10));
|
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);
|
free_mem2Dint(temp_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// to be modified
|
// 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;
|
int i, j;
|
||||||
for (j = 0; j < imgOut->format.height[0]; j++)
|
for (j = 0; j < imgOut->format.height[0]; j++) {
|
||||||
{
|
for (i = 0; i < imgOut->format.width[0]; i++) {
|
||||||
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] *
|
||||||
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]);
|
(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;
|
int k;
|
||||||
for (k = 1; k <=2; k++)
|
for (k = 1; k <= 2; k++) {
|
||||||
{
|
for (j = 0; j < imgOut->format.height[1]; j++) {
|
||||||
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(
|
||||||
for (i = 0; i < imgOut->format.width[1]; i++)
|
imgIn0->frm_data[k][j][i] *
|
||||||
{
|
(Map->format.max_value[k] - Map->frm_data[k][j][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]);
|
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)
|
static inline void YV12toYUV(ImageData *imgOut, ImageData *imgIn) {
|
||||||
{
|
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0],
|
||||||
memcpy(imgOut->frm_data[0][0], imgIn->frm_data[0][0], imgIn->format.height[0] * imgIn->format.width[0] * sizeof (imgpel));
|
imgIn->format.height[0] * imgIn->format.width[0] * sizeof(imgpel));
|
||||||
|
|
||||||
if (imgIn->format.yuv_format != YUV400)
|
if (imgIn->format.yuv_format != YUV400) {
|
||||||
{
|
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[2][0],
|
||||||
memcpy(imgOut->frm_data[1][0], imgIn->frm_data[2][0], imgIn->format.height[1] * imgIn->format.width[1] * sizeof (imgpel));
|
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));
|
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;
|
int memory_size = 0;
|
||||||
switch( p_Inp->ProcessInput )
|
switch (p_Inp->ProcessInput) {
|
||||||
{
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return memory_size;
|
return memory_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_process_image( VideoParameters *p_Vid, InputParameters *p_Inp)
|
void clear_process_image(VideoParameters *p_Vid, InputParameters *p_Inp) {
|
||||||
{
|
switch (p_Inp->ProcessInput) {
|
||||||
switch( p_Inp->ProcessInput )
|
|
||||||
{
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_image( VideoParameters *p_Vid, InputParameters *p_Inp )
|
void process_image(VideoParameters *p_Vid, InputParameters *p_Inp) {
|
||||||
{
|
switch (p_Inp->ProcessInput) {
|
||||||
switch( p_Inp->ProcessInput )
|
|
||||||
{
|
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
CPImage(&p_Vid->imgData, &p_Vid->imgData0);
|
CPImage(&p_Vid->imgData, &p_Vid->imgData0);
|
||||||
|
@ -248,33 +247,31 @@ void process_image( VideoParameters *p_Vid, InputParameters *p_Inp )
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
FilterImage(&p_Vid->imgData, &p_Vid->imgData0);
|
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);
|
FilterImage(&p_Vid->imgData32, &p_Vid->imgData4);
|
||||||
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
YV12toYUV(&p_Vid->imgData, &p_Vid->imgData0);
|
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);
|
YV12toYUV(&p_Vid->imgData32, &p_Vid->imgData4);
|
||||||
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
MuxImages(&p_Vid->imgData, &p_Vid->imgData0, &p_Vid->imgData1, &p_Vid->imgData2);
|
MuxImages(&p_Vid->imgData, &p_Vid->imgData0, &p_Vid->imgData1,
|
||||||
if (p_Inp->enable_32_pulldown)
|
&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->imgData32, &p_Vid->imgData4, &p_Vid->imgData5,
|
||||||
|
&p_Vid->imgData6);
|
||||||
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
FilterImageSep(&p_Vid->imgData, &p_Vid->imgData0);
|
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);
|
FilterImageSep(&p_Vid->imgData, &p_Vid->imgData4);
|
||||||
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
BlendImageLines(&p_Vid->imgData, &p_Vid->imgData32);
|
||||||
}
|
}
|
||||||
|
@ -282,6 +279,3 @@ void process_image( VideoParameters *p_Vid, InputParameters *p_Inp )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
|
|
||||||
#include "nalucommon.h"
|
#include "nalucommon.h"
|
||||||
|
|
||||||
typedef struct annex_b_struct
|
typedef struct annex_b_struct {
|
||||||
{
|
|
||||||
int BitStreamFile; //!< the bit stream file
|
int BitStreamFile; //!< the bit stream file
|
||||||
byte *iobuffer;
|
byte *iobuffer;
|
||||||
byte *iobufferread;
|
byte *iobufferread;
|
||||||
|
@ -36,4 +35,3 @@ extern void free_annex_b (VideoParameters *p_Vid);
|
||||||
extern void init_annex_b(ANNEXB_t *annex_b);
|
extern void init_annex_b(ANNEXB_t *annex_b);
|
||||||
extern void ResetAnnexB(ANNEXB_t *annex_b);
|
extern void ResetAnnexB(ANNEXB_t *annex_b);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -20,116 +20,63 @@
|
||||||
#ifndef _BIARIDECOD_H_
|
#ifndef _BIARIDECOD_H_
|
||||||
#define _BIARIDECOD_H_
|
#define _BIARIDECOD_H_
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* D e f i n i t i o n s
|
* D e f i n i t i o n s
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Range table for LPS */
|
/* Range table for LPS */
|
||||||
static const byte rLPS_table_64x4[64][4]=
|
static const byte rLPS_table_64x4[64][4] = {
|
||||||
{
|
{128, 176, 208, 240}, {128, 167, 197, 227}, {128, 158, 187, 216},
|
||||||
{ 128, 176, 208, 240},
|
{123, 150, 178, 205}, {116, 142, 169, 195}, {111, 135, 160, 185},
|
||||||
{ 128, 167, 197, 227},
|
{105, 128, 152, 175}, {100, 122, 144, 166}, {95, 116, 137, 158},
|
||||||
{ 128, 158, 187, 216},
|
{90, 110, 130, 150}, {85, 104, 123, 142}, {81, 99, 117, 135},
|
||||||
{ 123, 150, 178, 205},
|
{77, 94, 111, 128}, {73, 89, 105, 122}, {69, 85, 100, 116},
|
||||||
{ 116, 142, 169, 195},
|
{66, 80, 95, 110}, {62, 76, 90, 104}, {59, 72, 86, 99},
|
||||||
{ 111, 135, 160, 185},
|
{56, 69, 81, 94}, {53, 65, 77, 89}, {51, 62, 73, 85},
|
||||||
{ 105, 128, 152, 175},
|
{48, 59, 69, 80}, {46, 56, 66, 76}, {43, 53, 63, 72},
|
||||||
{ 100, 122, 144, 166},
|
{41, 50, 59, 69}, {39, 48, 56, 65}, {37, 45, 54, 62},
|
||||||
{ 95, 116, 137, 158},
|
{35, 43, 51, 59}, {33, 41, 48, 56}, {32, 39, 46, 53},
|
||||||
{ 90, 110, 130, 150},
|
{30, 37, 43, 50}, {29, 35, 41, 48}, {27, 33, 39, 45},
|
||||||
{ 85, 104, 123, 142},
|
{26, 31, 37, 43}, {24, 30, 35, 41}, {23, 28, 33, 39},
|
||||||
{ 81, 99, 117, 135},
|
{22, 27, 32, 37}, {21, 26, 30, 35}, {20, 24, 29, 33},
|
||||||
{ 77, 94, 111, 128},
|
{19, 23, 27, 31}, {18, 22, 26, 30}, {17, 21, 25, 28},
|
||||||
{ 73, 89, 105, 122},
|
{16, 20, 23, 27}, {15, 19, 22, 25}, {14, 18, 21, 24},
|
||||||
{ 69, 85, 100, 116},
|
{14, 17, 20, 23}, {13, 16, 19, 22}, {12, 15, 18, 21},
|
||||||
{ 66, 80, 95, 110},
|
{12, 14, 17, 20}, {11, 14, 16, 19}, {11, 13, 15, 18},
|
||||||
{ 62, 76, 90, 104},
|
{10, 12, 15, 17}, {10, 12, 14, 16}, {9, 11, 13, 15},
|
||||||
{ 59, 72, 86, 99},
|
{9, 11, 12, 14}, {8, 10, 12, 14}, {8, 9, 11, 13},
|
||||||
{ 56, 69, 81, 94},
|
{7, 9, 11, 12}, {7, 9, 10, 12}, {7, 8, 10, 11},
|
||||||
{ 53, 65, 77, 89},
|
{6, 8, 9, 11}, {6, 7, 9, 10}, {6, 7, 8, 9},
|
||||||
{ 51, 62, 73, 85},
|
{2, 2, 2, 2}};
|
||||||
{ 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] =
|
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,
|
||||||
1,2,3,4,5,6,7,8,9,10,
|
13, 13, 15, 15, 16, 16, 18, 18, 19, 19, 21, 21, 22, 22, 23, 24,
|
||||||
11,12,13,14,15,16,17,18,19,20,
|
24, 25, 26, 26, 27, 27, 28, 29, 29, 30, 30, 30, 31, 32, 32, 33,
|
||||||
21,22,23,24,25,26,27,28,29,30,
|
33, 33, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 63};
|
||||||
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 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] =
|
extern void arideco_start_decoding(DecodingEnvironmentPtr eep,
|
||||||
{
|
unsigned char *code_buffer, int firstbyte,
|
||||||
0, 0, 1, 2, 2, 4, 4, 5, 6, 7,
|
int *code_len);
|
||||||
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 int arideco_bits_read(DecodingEnvironmentPtr dep);
|
||||||
extern void arideco_done_decoding(DecodingEnvironmentPtr dep);
|
extern void arideco_done_decoding(DecodingEnvironmentPtr dep);
|
||||||
extern void biari_init_context (int qp, BiContextTypePtr ctx, const signed char* ini);
|
extern void biari_init_context(int qp, BiContextTypePtr ctx,
|
||||||
extern unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi_ct );
|
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_symbol_eq_prob(DecodingEnvironmentPtr dep);
|
||||||
extern unsigned int biari_decode_final(DecodingEnvironmentPtr dep);
|
extern unsigned int biari_decode_final(DecodingEnvironmentPtr dep);
|
||||||
extern unsigned int getbyte(DecodingEnvironmentPtr dep);
|
extern unsigned int getbyte(DecodingEnvironmentPtr dep);
|
||||||
extern unsigned int getword(DecodingEnvironmentPtr dep);
|
extern unsigned int getword(DecodingEnvironmentPtr dep);
|
||||||
#endif // BIARIDECOD_H_
|
#endif // BIARIDECOD_H_
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
#define _BLK_PREDICTION_H_
|
#define _BLK_PREDICTION_H_
|
||||||
#include "mbuffer.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 compute_residue(imgpel **curImg, imgpel **mb_pred, int **mb_rres,
|
||||||
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);
|
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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -21,19 +21,15 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "transform8x8.h"
|
#include "transform8x8.h"
|
||||||
|
|
||||||
static const byte QP_SCALE_CR[52]=
|
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,
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,
|
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 29, 30, 31, 32, 32, 33,
|
||||||
12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
|
34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 39
|
||||||
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
|
//! look up tables for FRExt_chroma support
|
||||||
static const unsigned char subblk_offset_x[3][8][4] =
|
static const unsigned char subblk_offset_x[3][8][4] = {{
|
||||||
{
|
|
||||||
{
|
|
||||||
{0, 4, 0, 4},
|
{0, 4, 0, 4},
|
||||||
{0, 4, 0, 4},
|
{0, 4, 0, 4},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
|
@ -53,54 +49,42 @@ static const unsigned char subblk_offset_x[3][8][4] =
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
},
|
},
|
||||||
{
|
{{0, 4, 0, 4},
|
||||||
{0, 4, 0, 4},
|
|
||||||
{8, 12, 8, 12},
|
{8, 12, 8, 12},
|
||||||
{0, 4, 0, 4},
|
{0, 4, 0, 4},
|
||||||
{8, 12, 8, 12},
|
{8, 12, 8, 12},
|
||||||
{0, 4, 0, 4},
|
{0, 4, 0, 4},
|
||||||
{8, 12, 8, 12},
|
{8, 12, 8, 12},
|
||||||
{0, 4, 0, 4},
|
{0, 4, 0, 4},
|
||||||
{8,12, 8,12}
|
{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] =
|
static const byte decode_block_scan[16] = {0, 1, 4, 5, 2, 3, 6, 7,
|
||||||
{
|
8, 9, 12, 13, 10, 11, 14, 15};
|
||||||
{
|
|
||||||
{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};
|
|
||||||
|
|
||||||
extern void iMBtrans4x4(Macroblock *currMB, ColorPlane pl, int smb);
|
extern void iMBtrans4x4(Macroblock *currMB, ColorPlane pl, int smb);
|
||||||
extern void iMBtrans8x8(Macroblock *currMB, ColorPlane pl);
|
extern void iMBtrans8x8(Macroblock *currMB, ColorPlane pl);
|
||||||
|
@ -110,22 +94,28 @@ 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 intrapred_chroma_mbaff(Macroblock *currMB);
|
||||||
|
|
||||||
extern void Inv_Residual_trans_4x4(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
extern void Inv_Residual_trans_4x4(Macroblock *currMB, ColorPlane pl, int ioff,
|
||||||
extern void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,int joff);
|
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_16x16(Macroblock *currMB, ColorPlane pl);
|
||||||
extern void Inv_Residual_trans_Chroma(Macroblock *currMB, int uv);
|
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 itrans4x4_ls(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||||
extern void itrans_sp(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 int intrapred(Macroblock *currMB, ColorPlane pl, int ioff, int joff,
|
||||||
|
int i4, int j4);
|
||||||
extern void itrans_2(Macroblock *currMB, ColorPlane pl);
|
extern void itrans_2(Macroblock *currMB, ColorPlane pl);
|
||||||
extern void iTransform(Macroblock *currMB, ColorPlane pl, int smb);
|
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(imgpel **imgBuf1, imgpel **imgBuf2, int off1,
|
||||||
extern void copy_image_data_16x16 (imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2);
|
int off2, int width, int height);
|
||||||
extern void copy_image_data_8x8 (imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2);
|
extern void copy_image_data_16x16(imgpel **imgBuf1, imgpel **imgBuf2, int off1,
|
||||||
extern void copy_image_data_4x4 (imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2);
|
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);
|
extern int CheckVertMV(Macroblock *currMB, int vec1_y, int block_size_y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -28,35 +28,54 @@ extern void delete_contexts_TextureInfo(TextureInfoContexts *enco_ctx);
|
||||||
|
|
||||||
extern void cabac_new_slice(Slice *currSlice);
|
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_i_slice(Macroblock *currMB, SyntaxElement *se,
|
||||||
extern void readMB_typeInfo_CABAC_p_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
DecodingEnvironmentPtr dep_dp);
|
||||||
extern void readMB_typeInfo_CABAC_b_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
extern void readMB_typeInfo_CABAC_p_slice(Macroblock *currMB, SyntaxElement *se,
|
||||||
extern void readB8_typeInfo_CABAC_p_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
DecodingEnvironmentPtr dep_dp);
|
||||||
extern void readB8_typeInfo_CABAC_b_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
extern void readMB_typeInfo_CABAC_b_slice(Macroblock *currMB, SyntaxElement *se,
|
||||||
extern void readIntraPredMode_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
DecodingEnvironmentPtr dep_dp);
|
||||||
extern void readRefFrame_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
extern void readB8_typeInfo_CABAC_p_slice(Macroblock *currMB, SyntaxElement *se,
|
||||||
extern void read_MVD_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
DecodingEnvironmentPtr dep_dp);
|
||||||
extern void read_CBP_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
extern void readB8_typeInfo_CABAC_b_slice(Macroblock *currMB, SyntaxElement *se,
|
||||||
extern void readRunLevel_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
DecodingEnvironmentPtr dep_dp);
|
||||||
extern void read_dQuant_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
extern void readIntraPredMode_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||||
extern void readCIPredMode_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
DecodingEnvironmentPtr dep_dp);
|
||||||
extern void read_skip_flag_CABAC_p_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
extern void readRefFrame_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||||
extern void read_skip_flag_CABAC_b_slice (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
DecodingEnvironmentPtr dep_dp);
|
||||||
extern void readFieldModeInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
extern void read_MVD_CABAC(Macroblock *currMB, SyntaxElement *se,
|
||||||
extern void readMB_transform_size_flag_CABAC(Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp);
|
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 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_p_slice(
|
||||||
extern int check_next_mb_and_get_field_mode_CABAC_b_slice( Slice *currSlice, SyntaxElement *se, DataPartition *act_dp);
|
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 CheckAvailabilityOfNeighborsCABAC(Macroblock *currMB);
|
||||||
|
|
||||||
extern void set_read_and_store_CBP(Macroblock **currMB, int chroma_format_idc);
|
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
|
* Common Config parsing functions
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Tourapis <alexismt@ieee.org>
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
@ -21,7 +22,9 @@ typedef struct {
|
||||||
void *Place; //!< address
|
void *Place; //!< address
|
||||||
int Type; //!< type: 0-int, 1-char[], 2-double
|
int Type; //!< type: 0-int, 1-char[], 2-double
|
||||||
double Default; //!< default value
|
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
|
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 min_limit;
|
||||||
double max_limit;
|
double max_limit;
|
||||||
int char_size; //!< Dimension of type char[]
|
int char_size; //!< Dimension of type char[]
|
||||||
|
@ -31,5 +34,6 @@ extern char *GetConfigFileContent (char *Filename);
|
||||||
extern int InitParams(Mapping *Map);
|
extern int InitParams(Mapping *Map);
|
||||||
extern int TestParams(Mapping *Map, int bitdepth_qp_scale[3]);
|
extern int TestParams(Mapping *Map, int bitdepth_qp_scale[3]);
|
||||||
extern int DisplayParams(Mapping *Map, char *message);
|
extern int DisplayParams(Mapping *Map, char *message);
|
||||||
extern void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize);
|
extern void ParseContent(InputParameters *p_Inp, Mapping *Map, char *buf,
|
||||||
|
int bufsize);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,19 +17,45 @@
|
||||||
// #define PROFILE_IDC 88
|
// #define PROFILE_IDC 88
|
||||||
// #define LEVEL_IDC 21
|
// #define LEVEL_IDC 21
|
||||||
|
|
||||||
|
|
||||||
InputParameters cfgparams;
|
InputParameters cfgparams;
|
||||||
|
|
||||||
#ifdef INCLUDED_BY_CONFIGFILE_C
|
#ifdef INCLUDED_BY_CONFIGFILE_C
|
||||||
// Mapping_Map Syntax:
|
// Mapping_Map Syntax:
|
||||||
// {NAMEinConfigFile, &cfgparams.VariableName, Type, InitialValue, LimitType, MinLimit, MaxLimit, CharSize}
|
// {NAMEinConfigFile, &cfgparams.VariableName, Type, InitialValue, LimitType,
|
||||||
// Types : {0:int, 1:text, 2: double}
|
// MinLimit, MaxLimit, CharSize} Types : {0:int, 1:text, 2: double} LimitType:
|
||||||
// LimitType: {0:none, 1:both, 2:minimum, 3: QP based}
|
// {0:none, 1:both, 2:minimum, 3: QP based} We could separate this based on
|
||||||
// We could separate this based on types to make it more flexible and allow also defaults for text types.
|
// types to make it more flexible and allow also defaults for text types.
|
||||||
Mapping Map[] = {
|
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, },
|
"InputFile",
|
||||||
{"RefFile", &cfgparams.reffile, 1, 0.0, 0, 0.0, 0.0, FILE_NAME_SIZE, },
|
&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},
|
{"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},
|
{"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},
|
{"RefOffset", &cfgparams.ref_offset, 0, 0.0, 1, 0.0, 256.0, 0},
|
||||||
|
@ -38,14 +64,24 @@ Mapping Map[] = {
|
||||||
{"R_decoder", &cfgparams.R_decoder, 0, 0.0, 2, 0.0, 0.0, 0},
|
{"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},
|
{"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},
|
{"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, },
|
{
|
||||||
|
"LeakyBucketParamFile",
|
||||||
|
&cfgparams.LeakyBucketParamFile,
|
||||||
|
1,
|
||||||
|
0.0,
|
||||||
|
0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
FILE_NAME_SIZE,
|
||||||
|
},
|
||||||
#endif
|
#endif
|
||||||
{"DisplayDecParams", &cfgparams.bDisplayDecParams, 0, 1.0, 1, 0.0, 1.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},
|
{"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},
|
{"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},
|
{"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},
|
{"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 },
|
{"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},
|
{"DecFrmNum", &cfgparams.iDecFrmNum, 0, 0.0, 2, 0.0, 0.0, 0},
|
||||||
#if (MVC_EXTENSION_ENABLE)
|
#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},
|
||||||
|
@ -61,4 +97,3 @@ extern void JMDecHelpExit ();
|
||||||
extern void ParseCommand(InputParameters *p_Inp, int ac, char *av[]);
|
extern void ParseCommand(InputParameters *p_Inp, int ac, char *av[]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,16 @@
|
||||||
* CABAC context initializations
|
* CABAC context initializations
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Detlev Marpe <marpe@hhi.de>
|
||||||
* - Heiko Schwarz <hschwarz@hhi.de>
|
* - Heiko Schwarz <hschwarz@hhi.de>
|
||||||
**************************************************************************************
|
**************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _CONTEXT_INI_
|
#ifndef _CONTEXT_INI_
|
||||||
#define _CONTEXT_INI_
|
#define _CONTEXT_INI_
|
||||||
|
|
||||||
extern void init_contexts(Slice *currslice);
|
extern void init_contexts(Slice *currslice);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
Nokia Inc., USA
|
Nokia Inc., USA
|
||||||
Nokia Corporation, Finland
|
Nokia Corporation, Finland
|
||||||
Siemens AG, Germany
|
Siemens AG, Germany
|
||||||
Fraunhofer-Institute for Telecommunications Heinrich-Hertz-Institut (HHI), Germany
|
Fraunhofer-Institute for Telecommunications Heinrich-Hertz-Institut (HHI),
|
||||||
University of Hannover, Institut of Communication Theory and Signal Processing, Germany
|
Germany University of Hannover, Institut of Communication Theory and Signal
|
||||||
TICSP, Tampere University of Technology, Finland
|
Processing, Germany TICSP, Tampere University of Technology, Finland Munich
|
||||||
Munich University of Technology, Institute for Communications Engineering, Germany
|
University of Technology, Institute for Communications Engineering, Germany
|
||||||
Videolocus, Canada
|
Videolocus, Canada
|
||||||
Motorola Inc., USA
|
Motorola Inc., USA
|
||||||
Microsoft Corp., USA
|
Microsoft Corp., USA
|
||||||
|
@ -30,12 +30,9 @@
|
||||||
\par Full Contact Information
|
\par Full Contact Information
|
||||||
\verbatim
|
\verbatim
|
||||||
|
|
||||||
Lowell Winger <lwinger@videolocus.com><lwinger@uwaterloo.ca>
|
Lowell Winger <lwinger@videolocus.com><lwinger@uwaterloo.ca> Guy Côté
|
||||||
Guy Côté <gcote@videolocus.com>
|
<gcote@videolocus.com> Michael Gallant <mgallant@videolocus.com> VideoLocus
|
||||||
Michael Gallant <mgallant@videolocus.com>
|
Inc. 97 Randall Dr. Waterloo, ON, Canada N2V1C5
|
||||||
VideoLocus Inc.
|
|
||||||
97 Randall Dr.
|
|
||||||
Waterloo, ON, Canada N2V1C5
|
|
||||||
|
|
||||||
Inge Lille-Langøy <inge.lille-langoy@telenor.com>
|
Inge Lille-Langøy <inge.lille-langoy@telenor.com>
|
||||||
Telenor Satellite Services
|
Telenor Satellite Services
|
||||||
|
@ -152,10 +149,8 @@
|
||||||
San Diego, CA 92121 USA
|
San Diego, CA 92121 USA
|
||||||
|
|
||||||
Feng Wu <fengwu@microsoft.com>
|
Feng Wu <fengwu@microsoft.com>
|
||||||
Xiaoyan Sun <sunxiaoyan@msrchina.research.microsoft.com>
|
Xiaoyan Sun <sunxiaoyan@msrchina.research.microsoft.com> Microsoft
|
||||||
Microsoft Research Asia
|
Research Asia 3/F, Beijing Sigma Center No.49, Zhichun Road, Hai Dian District,
|
||||||
3/F, Beijing Sigma Center
|
|
||||||
No.49, Zhichun Road, Hai Dian District,
|
|
||||||
Beijing China 100080
|
Beijing China 100080
|
||||||
|
|
||||||
Yoshihiro Kikuchi <yoshihiro.kikuchi@toshiba.co.jp>
|
Yoshihiro Kikuchi <yoshihiro.kikuchi@toshiba.co.jp>
|
||||||
|
@ -222,11 +217,9 @@
|
||||||
Sejong University
|
Sejong University
|
||||||
98 Kunja-Dong, Kwangjin-Gu, Seoul 143-747, Korea
|
98 Kunja-Dong, Kwangjin-Gu, Seoul 143-747, Korea
|
||||||
|
|
||||||
Jianhua Wu <jianhua.wu@sg.panasonic.com>
|
Jianhua Wu <jianhua.wu@sg.panasonic.com> Panasonic
|
||||||
Panasonic Singapore Laboratories Pte Ltd
|
Singapore Laboratories Pte Ltd Blk 1022 Tai Seng Ave #06-3530 Tai Seng Ind Est
|
||||||
Blk 1022 Tai Seng Ave #06-3530 Tai Seng Ind Est
|
|
||||||
Singapore 534415
|
Singapore 534415
|
||||||
|
|
||||||
\endverbatim
|
\endverbatim
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,8 @@
|
||||||
* Header file containing some useful global definitions
|
* Header file containing some useful global definitions
|
||||||
*
|
*
|
||||||
* \author
|
* \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
|
* - Detlev Marpe
|
||||||
* - Karsten Sühring <suehring@hhi.de>
|
* - Karsten Sühring <suehring@hhi.de>
|
||||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
|
@ -18,7 +19,6 @@
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _DEFINES_H_
|
#ifndef _DEFINES_H_
|
||||||
#define _DEFINES_H_
|
#define _DEFINES_H_
|
||||||
#ifdef TRACE
|
#ifdef TRACE
|
||||||
|
@ -37,22 +37,36 @@
|
||||||
#define DUMP_DPB 0 //!< Dump DPB info for debug purposes
|
#define DUMP_DPB 0 //!< Dump DPB info for debug purposes
|
||||||
#define PRINTREFLIST 0 //!< Print ref list 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 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 IMGTYPE \
|
||||||
#define ENABLE_FIELD_CTX 1 //!< Enables Field mode related context types for CABAC
|
1 //!< Define imgpel size type. 0 implies byte (cannot handle >8 bit depths)
|
||||||
#define ENABLE_HIGH444_CTX 1 //!< Enables High 444 profile context types for CABAC.
|
//!< 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 ZEROSNR 0 //!< PSNR computation method
|
||||||
#define ENABLE_OUTPUT_TONEMAPPING 1 //!< enable tone map the output if tone mapping SEI present
|
#define ENABLE_OUTPUT_TONEMAPPING \
|
||||||
#define JCOST_CALC_SCALEUP 1 //!< 1: J = (D<<LAMBDA_ACCURACY_BITS)+Lambda*R; 0: J = D + ((Lambda*R+Rounding)>>LAMBDA_ACCURACY_BITS)
|
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 DISABLE_ERC 1 //!< Disable any error concealment processes
|
||||||
#define JM_PARALLEL_DEBLOCK 0 //!< Enables Parallel Deblocking
|
#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)
|
#if (MVC_EXTENSION_ENABLE)
|
||||||
#define MVC_INIT_VIEW_ID -1
|
#define MVC_INIT_VIEW_ID -1
|
||||||
#define MAX_VIEW_NUM 1024
|
#define MAX_VIEW_NUM 1024
|
||||||
#define BASE_VIEW_IDX 0
|
#define BASE_VIEW_IDX 0
|
||||||
#define FREEPTR(ptr) { if(ptr) {free(ptr); (ptr)=NULL;} }
|
#define FREEPTR(ptr) \
|
||||||
|
{ \
|
||||||
|
if (ptr) { \
|
||||||
|
free(ptr); \
|
||||||
|
(ptr) = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
|
@ -93,7 +107,6 @@ typedef enum {
|
||||||
#define NUM_BLOCK_TYPES 10
|
#define NUM_BLOCK_TYPES 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// #define _LEAKYBUCKET_
|
// #define _LEAKYBUCKET_
|
||||||
|
|
||||||
#define BLOCK_SHIFT 2
|
#define BLOCK_SHIFT 2
|
||||||
|
@ -188,7 +201,6 @@ typedef enum {
|
||||||
#define Q_BITS_8 16
|
#define Q_BITS_8 16
|
||||||
#define DQ_BITS_8 6
|
#define DQ_BITS_8 6
|
||||||
|
|
||||||
|
|
||||||
#define IS_I16MB(MB) ((MB)->mb_type == I16MB || (MB)->mb_type == IPCM)
|
#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_DIRECT(MB) ((MB)->mb_type == 0 && (currSlice->slice_type == B_SLICE))
|
||||||
|
|
||||||
|
@ -243,23 +255,24 @@ typedef enum {
|
||||||
MVPRED_UR = 3
|
MVPRED_UR = 3
|
||||||
} MVPredTypes;
|
} MVPredTypes;
|
||||||
|
|
||||||
enum {
|
enum { DECODING_OK = 0, SEARCH_SYNC = 1, PICTURE_DECODED = 2 };
|
||||||
DECODING_OK = 0,
|
|
||||||
SEARCH_SYNC = 1,
|
|
||||||
PICTURE_DECODED = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
#define LAMBDA_ACCURACY_BITS 16
|
#define LAMBDA_ACCURACY_BITS 16
|
||||||
#define INVALIDINDEX (-135792468)
|
#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
|
// Start code and Emulation Prevention need this to be defined in identical
|
||||||
#define ZEROBYTES_SHORTSTARTCODE 2 //indicates the number of zero bytes in the short start-code prefix
|
// 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 MAX_PLANE 3
|
||||||
#define IS_FREXT_PROFILE(profile_idc) ( profile_idc>=FREXT_HP || profile_idc == FREXT_CAVLC444 )
|
#define IS_FREXT_PROFILE(profile_idc) \
|
||||||
#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))
|
(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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
// Distortion data structure. Could be extended in the future to support
|
// Distortion data structure. Could be extended in the future to support
|
||||||
// other data
|
// other data
|
||||||
typedef struct distortion_data
|
typedef struct distortion_data {
|
||||||
{
|
|
||||||
int i4x4rd[4][4]; //! i4x4 rd cost
|
int i4x4rd[4][4]; //! i4x4 rd cost
|
||||||
distblk i4x4[4][4]; //! i4x4 cost
|
distblk i4x4[4][4]; //! i4x4 cost
|
||||||
distblk i8x8[2][2]; //! i8x8 cost
|
distblk i8x8[2][2]; //! i8x8 cost
|
||||||
|
@ -28,4 +27,3 @@ typedef struct distortion_data
|
||||||
} DistortionData;
|
} DistortionData;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
* TYPE_CBP | SE_CBP_INTRA, SE_CBP_INTER
|
* TYPE_CBP | SE_CBP_INTRA, SE_CBP_INTER
|
||||||
* SE_DELTA_QUANT_INTER
|
* SE_DELTA_QUANT_INTER
|
||||||
* SE_DELTA_QUANT_INTRA
|
* SE_DELTA_QUANT_INTRA
|
||||||
* TYPE_COEFF_Y | SE_LUM_DC_INTRA, SE_LUM_AC_INTRA, SE_LUM_DC_INTER, SE_LUM_AC_INTER
|
* TYPE_COEFF_Y | SE_LUM_DC_INTRA, SE_LUM_AC_INTRA, SE_LUM_DC_INTER,
|
||||||
* TYPE_2x2DC | SE_CHR_DC_INTRA, SE_CHR_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_COEFF_C | SE_CHR_AC_INTRA, SE_CHR_AC_INTER
|
||||||
* TYPE_EOS | SE_EOS
|
* TYPE_EOS | SE_EOS
|
||||||
*/
|
*/
|
||||||
|
@ -67,12 +67,12 @@
|
||||||
#define SE_EOS 19
|
#define SE_EOS 19
|
||||||
#define SE_MAX_ELEMENTS 20
|
#define SE_MAX_ELEMENTS 20
|
||||||
|
|
||||||
|
|
||||||
#define NO_EC 0 //!< no error concealment necessary
|
#define NO_EC 0 //!< no error concealment necessary
|
||||||
#define EC_REQ 1 //!< error concealment required
|
#define EC_REQ 1 //!< error concealment required
|
||||||
#define EC_SYNC 2 //!< search and sync on next header element
|
#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
|
* \brief lookup-table to assign different elements to partition
|
||||||
|
@ -99,14 +99,14 @@
|
||||||
* outlined in document Q15-J-23.
|
* outlined in document Q15-J-23.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static const byte assignSE2partition[][SE_MAX_ELEMENTS] = {
|
||||||
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 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, 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, 0, 0}, //!< all elements in one partition no data
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 0 } //!< three partitions per slice
|
//!< 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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* statistics reports for the encoding process.
|
* statistics reports for the encoding process.
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Tourapis <alexismt@ieee.org>
|
||||||
* - Karsten Sühring <suehring@hhi.de>
|
* - Karsten Sühring <suehring@hhi.de>
|
||||||
*
|
*
|
||||||
|
@ -17,14 +18,15 @@
|
||||||
#define _ENC_STATISTICS_H_
|
#define _ENC_STATISTICS_H_
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
struct stat_parameters
|
struct stat_parameters {
|
||||||
{
|
|
||||||
float bitrate; //!< average bit rate for the sequence except first frame
|
float bitrate; //!< average bit rate for the sequence except first frame
|
||||||
int64 bit_ctr; //!< counter for bit usage
|
int64 bit_ctr; //!< counter for bit usage
|
||||||
int64 bit_ctr_n; //!< bit usage for the current frame
|
int64 bit_ctr_n; //!< bit usage for the current frame
|
||||||
int64 bit_ctr_emulationprevention; //!< stored bits needed to prevent start code emulation
|
int64 bit_ctr_emulationprevention; //!< stored bits needed to prevent start
|
||||||
|
//!< code emulation
|
||||||
int bit_slice; //!< number of bits in current slice
|
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 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];
|
int b8_mode_0_use[NUM_SLICE_TYPES][2];
|
||||||
int64 mode_use_transform[NUM_SLICE_TYPES][MAXMODE][2];
|
int64 mode_use_transform[NUM_SLICE_TYPES][MAXMODE][2];
|
||||||
int64 intra_chroma_mode[4];
|
int64 intra_chroma_mode[4];
|
||||||
|
@ -38,7 +40,8 @@ struct stat_parameters
|
||||||
int frame_ctr[NUM_SLICE_TYPES];
|
int frame_ctr[NUM_SLICE_TYPES];
|
||||||
int64 bit_counter[NUM_SLICE_TYPES];
|
int64 bit_counter[NUM_SLICE_TYPES];
|
||||||
float bitrate_st[NUM_SLICE_TYPES];
|
float bitrate_st[NUM_SLICE_TYPES];
|
||||||
int64 mode_use [NUM_SLICE_TYPES][MAXMODE]; //!< Macroblock mode usage for Intra frames
|
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_mode[NUM_SLICE_TYPES][MAXMODE]; //!< statistics of bit usage
|
||||||
int64 bit_use_mb_type[NUM_SLICE_TYPES];
|
int64 bit_use_mb_type[NUM_SLICE_TYPES];
|
||||||
int64 bit_use_header[NUM_SLICE_TYPES];
|
int64 bit_use_header[NUM_SLICE_TYPES];
|
||||||
|
@ -57,7 +60,8 @@ struct stat_parameters
|
||||||
float bitrate_v[2]; //!< average bit rate for the sequence except first frame
|
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_v[2]; //!< counter for bit usage
|
||||||
int64 bit_ctr_n_v[2]; //!< bit usage for the current frame
|
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_ctr_emulationprevention_v[2]; //!< stored bits needed to prevent
|
||||||
|
//!< start code emulation
|
||||||
int64 bit_counter_v[2][NUM_SLICE_TYPES];
|
int64 bit_counter_v[2][NUM_SLICE_TYPES];
|
||||||
int bit_ctr_parametersets_v[2];
|
int bit_ctr_parametersets_v[2];
|
||||||
int bit_ctr_parametersets_n_v[2];
|
int bit_ctr_parametersets_n_v[2];
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
* \file erc_api.h
|
* \file erc_api.h
|
||||||
*
|
*
|
||||||
* \brief
|
* \brief
|
||||||
* External (still inside video decoder) interface for error concealment module
|
* External (still inside video decoder) interface for error concealment
|
||||||
|
*module
|
||||||
*
|
*
|
||||||
* \author
|
* \author
|
||||||
* - Ari Hourunranta <ari.hourunranta@nokia.com>
|
* - Ari Hourunranta <ari.hourunranta@nokia.com>
|
||||||
|
@ -17,7 +18,6 @@
|
||||||
* ************************************************************************
|
* ************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _ERC_API_H_
|
#ifndef _ERC_API_H_
|
||||||
#define _ERC_API_H_
|
#define _ERC_API_H_
|
||||||
|
|
||||||
|
@ -27,11 +27,12 @@
|
||||||
* Defines
|
* Defines
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* If the average motion vector of the correctly received macroblocks is less than the
|
/* If the average motion vector of the correctly received macroblocks is less
|
||||||
threshold, concealByCopy is used, otherwise concealByTrial is used. */
|
than the threshold, concealByCopy is used, otherwise concealByTrial is used. */
|
||||||
#define MVPERMB_THR 8
|
#define MVPERMB_THR 8
|
||||||
|
|
||||||
/* used to determine the size of the allocated memory for a temporal Region (MB) */
|
/* used to determine the size of the allocated memory for a temporal Region (MB)
|
||||||
|
*/
|
||||||
#define DEF_REGION_SIZE 384 /* 8*8*6 */
|
#define DEF_REGION_SIZE 384 /* 8*8*6 */
|
||||||
|
|
||||||
#define ERC_BLOCK_OK 3
|
#define ERC_BLOCK_OK 3
|
||||||
|
@ -39,7 +40,6 @@ threshold, concealByCopy is used, otherwise concealByTrial is used. */
|
||||||
#define ERC_BLOCK_CORRUPTED 1
|
#define ERC_BLOCK_CORRUPTED 1
|
||||||
#define ERC_BLOCK_EMPTY 0
|
#define ERC_BLOCK_EMPTY 0
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions to convert MBNum representation to blockNum
|
* Functions to convert MBNum representation to blockNum
|
||||||
*/
|
*/
|
||||||
|
@ -50,34 +50,31 @@ threshold, concealByCopy is used, otherwise concealByTrial is used. */
|
||||||
#define yPosYBlock(currYBlockNum, picSizeX) \
|
#define yPosYBlock(currYBlockNum, picSizeX) \
|
||||||
((currYBlockNum) / ((picSizeX) >> 3))
|
((currYBlockNum) / ((picSizeX) >> 3))
|
||||||
|
|
||||||
#define xPosMB(currMBNum,picSizeX) \
|
#define xPosMB(currMBNum, picSizeX) ((currMBNum) % ((picSizeX) >> 4))
|
||||||
((currMBNum)%((picSizeX)>>4))
|
|
||||||
|
|
||||||
#define yPosMB(currMBNum,picSizeX) \
|
#define yPosMB(currMBNum, picSizeX) ((currMBNum) / ((picSizeX) >> 4))
|
||||||
((currMBNum)/((picSizeX)>>4))
|
|
||||||
|
|
||||||
#define MBxy2YBlock(currXPos, currYPos, comp, picSizeX) \
|
#define MBxy2YBlock(currXPos, currYPos, comp, picSizeX) \
|
||||||
((((currYPos)<<1)+((comp)>>1))*((picSizeX)>>3)+((currXPos)<<1)+((comp)&1))
|
((((currYPos) << 1) + ((comp) >> 1)) * ((picSizeX) >> 3) + \
|
||||||
|
((currXPos) << 1) + ((comp) & 1))
|
||||||
|
|
||||||
#define MBNum2YBlock(currMBNum, comp, picSizeX) \
|
#define MBNum2YBlock(currMBNum, comp, picSizeX) \
|
||||||
MBxy2YBlock(xPosMB((currMBNum),(picSizeX)),yPosMB((currMBNum),(picSizeX)),(comp),(picSizeX))
|
MBxy2YBlock(xPosMB((currMBNum), (picSizeX)), \
|
||||||
|
yPosMB((currMBNum), (picSizeX)), (comp), (picSizeX))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* typedefs
|
* typedefs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* segment data structure */
|
/* segment data structure */
|
||||||
typedef struct ercSegment_s
|
typedef struct ercSegment_s {
|
||||||
{
|
|
||||||
short startMBPos;
|
short startMBPos;
|
||||||
short endMBPos;
|
short endMBPos;
|
||||||
signed char fCorrupted;
|
signed char fCorrupted;
|
||||||
} ercSegment_t;
|
} ercSegment_t;
|
||||||
|
|
||||||
/* Error detector & concealment instance data structure */
|
/* Error detector & concealment instance data structure */
|
||||||
typedef struct ercVariables_s
|
typedef struct ercVariables_s {
|
||||||
{
|
|
||||||
/* Number of macroblocks (size or size/4 of the arrays) */
|
/* Number of macroblocks (size or size/4 of the arrays) */
|
||||||
int nOfMBs;
|
int nOfMBs;
|
||||||
/* Number of segments (slices) in frame */
|
/* Number of segments (slices) in frame */
|
||||||
|
@ -113,20 +110,25 @@ typedef struct ercVariables_s
|
||||||
|
|
||||||
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);
|
||||||
ercVariables_t *ercOpen(void);
|
ercVariables_t *ercOpen(void);
|
||||||
void ercReset( ercVariables_t *errorVar, int nOfMBs, int numOfSegments, int picSizeX );
|
void ercReset(ercVariables_t *errorVar, int nOfMBs, int numOfSegments,
|
||||||
|
int picSizeX);
|
||||||
void ercClose(VideoParameters *p_Vid, ercVariables_t *errorVar);
|
void ercClose(VideoParameters *p_Vid, ercVariables_t *errorVar);
|
||||||
void ercSetErrorConcealment(ercVariables_t *errorVar, int value);
|
void ercSetErrorConcealment(ercVariables_t *errorVar, int value);
|
||||||
|
|
||||||
void ercStartSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar );
|
void ercStartSegment(int currMBNum, int segment, unsigned int bitPos,
|
||||||
void ercStopSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar );
|
ercVariables_t *errorVar);
|
||||||
|
void ercStopSegment(int currMBNum, int segment, unsigned int bitPos,
|
||||||
|
ercVariables_t *errorVar);
|
||||||
void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar);
|
void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar);
|
||||||
void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar);
|
void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar);
|
||||||
void ercMarkCurrMBConcealed( int currMBNum, int comp, 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 ercConcealIntraFrame(VideoParameters *p_Vid, frame *recfr, int picSizeX,
|
||||||
|
int picSizeY, ercVariables_t *errorVar);
|
||||||
int ercConcealInterFrame(frame *recfr, objectBuffer_t *object_list,
|
int ercConcealInterFrame(frame *recfr, objectBuffer_t *object_list,
|
||||||
int picSizeX, int picSizeY, ercVariables_t *errorVar, int chroma_format_idc );
|
int picSizeX, int picSizeY, ercVariables_t *errorVar,
|
||||||
|
int chroma_format_idc);
|
||||||
|
|
||||||
/* Thomson APIs for concealing entire frame loss */
|
/* Thomson APIs for concealing entire frame loss */
|
||||||
|
|
||||||
|
@ -142,17 +144,18 @@ struct concealment_node {
|
||||||
extern struct concealment_node *init_node(StorablePicture *, int);
|
extern struct concealment_node *init_node(StorablePicture *, int);
|
||||||
extern void print_node(struct concealment_node *);
|
extern void print_node(struct concealment_node *);
|
||||||
extern void print_list(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 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_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 sliding_window_poc_management(DecodedPictureBuffer *p_Dpb,
|
||||||
extern void write_lost_non_ref_pic (DecodedPictureBuffer *p_Dpb, int poc, int p_out);
|
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 write_lost_ref_after_idr(DecodedPictureBuffer *p_Dpb, int pos);
|
||||||
|
|
||||||
extern int comp(const void *, const void *);
|
extern int comp(const void *, const void *);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -16,29 +16,35 @@
|
||||||
#ifndef _ERC_DO_H_
|
#ifndef _ERC_DO_H_
|
||||||
#define _ERC_DO_H_
|
#define _ERC_DO_H_
|
||||||
|
|
||||||
|
|
||||||
#include "erc_api.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 ercCollect8PredBlocks(int predBlocks[], int currRow, int currColumn,
|
||||||
int maxRow, int maxColumn, int step, byte fNoCornerNeigh );
|
signed char *condition, int maxRow, int maxColumn,
|
||||||
int ercCollectColumnBlocks( int predBlocks[], int currRow, int currColumn, signed char *condition, int maxRow, int maxColumn, int step );
|
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) \
|
#define isSplitted(object_list, currMBNum) \
|
||||||
((object_list + ((currMBNum) << 2))->regionMode >= REGMODE_SPLITTED)
|
((object_list + ((currMBNum) << 2))->regionMode >= REGMODE_SPLITTED)
|
||||||
|
|
||||||
/* this can be used as isBlock(...,INTRA) or isBlock(...,INTER_COPY) */
|
/* this can be used as isBlock(...,INTRA) or isBlock(...,INTER_COPY) */
|
||||||
#define isBlock(object_list, currMBNum, comp, regMode) \
|
#define isBlock(object_list, currMBNum, comp, regMode) \
|
||||||
(isSplitted(object_list,currMBNum) ? \
|
(isSplitted(object_list, currMBNum) \
|
||||||
((object_list+((currMBNum)<<2)+(comp))->regionMode == REGMODE_##regMode##_8x8) : \
|
? ((object_list + ((currMBNum) << 2) + (comp))->regionMode == \
|
||||||
((object_list+((currMBNum)<<2))->regionMode == REGMODE_##regMode))
|
REGMODE_##regMode##_8x8) \
|
||||||
|
: ((object_list + ((currMBNum) << 2))->regionMode == \
|
||||||
|
REGMODE_##regMode))
|
||||||
|
|
||||||
/* this can be used as getParam(...,mv) or getParam(...,xMin) or getParam(...,yMin) */
|
/* this can be used as getParam(...,mv) or getParam(...,xMin) or
|
||||||
|
* getParam(...,yMin) */
|
||||||
#define getParam(object_list, currMBNum, comp, param) \
|
#define getParam(object_list, currMBNum, comp, param) \
|
||||||
(isSplitted(object_list,currMBNum) ? \
|
(isSplitted(object_list, currMBNum) \
|
||||||
((object_list+((currMBNum)<<2)+(comp))->param) : \
|
? ((object_list + ((currMBNum) << 2) + (comp))->param) \
|
||||||
((object_list+((currMBNum)<<2))->param))
|
: ((object_list + ((currMBNum) << 2))->param))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,30 +23,31 @@
|
||||||
#define REGMODE_INTER_COPY 0 //!< Copy region
|
#define REGMODE_INTER_COPY 0 //!< Copy region
|
||||||
#define REGMODE_INTER_PRED 1 //!< Inter region with motion vectors
|
#define REGMODE_INTER_PRED 1 //!< Inter region with motion vectors
|
||||||
#define REGMODE_INTRA 2 //!< Intra region
|
#define REGMODE_INTRA 2 //!< Intra region
|
||||||
#define REGMODE_SPLITTED 3 //!< Any region mode higher than this indicates that the region
|
#define REGMODE_SPLITTED \
|
||||||
|
3 //!< Any region mode higher than this indicates that the region
|
||||||
//!< is splitted which means 8x8 block
|
//!< is splitted which means 8x8 block
|
||||||
#define REGMODE_INTER_COPY_8x8 4
|
#define REGMODE_INTER_COPY_8x8 4
|
||||||
#define REGMODE_INTER_PRED_8x8 5
|
#define REGMODE_INTER_PRED_8x8 5
|
||||||
#define REGMODE_INTRA_8x8 6
|
#define REGMODE_INTRA_8x8 6
|
||||||
|
|
||||||
//! YUV pixel domain image arrays for a video frame
|
//! YUV pixel domain image arrays for a video frame
|
||||||
typedef struct frame_s
|
typedef struct frame_s {
|
||||||
{
|
|
||||||
VideoParameters *p_Vid;
|
VideoParameters *p_Vid;
|
||||||
imgpel *yptr;
|
imgpel *yptr;
|
||||||
imgpel *uptr;
|
imgpel *uptr;
|
||||||
imgpel *vptr;
|
imgpel *vptr;
|
||||||
} frame;
|
} frame;
|
||||||
|
|
||||||
//! region structure stores information about a region that is needed for concealment
|
//! region structure stores information about a region that is needed for
|
||||||
typedef struct object_buffer
|
//! concealment
|
||||||
{
|
typedef struct object_buffer {
|
||||||
byte regionMode; //!< region mode as above
|
byte regionMode; //!< region mode as above
|
||||||
int xMin; //!< X coordinate of the pixel position of the top-left corner of the region
|
int xMin; //!< X coordinate of the pixel position of the top-left corner of
|
||||||
int yMin; //!< Y coordinate of the pixel position of the top-left corner of the region
|
//!< 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],
|
int mv[3]; //!< motion vectors in 1/4 pixel units: mvx = mv[0], mvy = mv[1],
|
||||||
//!< and ref_frame = mv[2]
|
//!< and ref_frame = mv[2]
|
||||||
} objectBuffer_t;
|
} objectBuffer_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -18,4 +18,3 @@ extern int set_ec_flag (VideoParameters *p_Vid, int se);
|
||||||
extern void reset_ec_flags(VideoParameters *p_Vid);
|
extern void reset_ec_flags(VideoParameters *p_Vid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* Memory handling operations
|
* Memory handling operations
|
||||||
*
|
*
|
||||||
* \author
|
* \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
|
* - Chris Vogt
|
||||||
*
|
*
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
@ -17,16 +18,12 @@
|
||||||
|
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
|
|
||||||
|
static inline void fast_memset(void *dst, int value, int width) {
|
||||||
static inline void fast_memset(void *dst,int value,int width)
|
|
||||||
{
|
|
||||||
memset(dst, value, width);
|
memset(dst, value, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void fast_memcpy(void *dst,void *src,int width)
|
static inline void fast_memcpy(void *dst, void *src, int width) {
|
||||||
{
|
|
||||||
memcpy(dst, src, width);
|
memcpy(dst, src, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#ifndef _FMO_H_
|
#ifndef _FMO_H_
|
||||||
#define _FMO_H_
|
#define _FMO_H_
|
||||||
|
|
||||||
|
|
||||||
extern int fmo_init(VideoParameters *p_Vid, Slice *pSlice);
|
extern int fmo_init(VideoParameters *p_Vid, Slice *pSlice);
|
||||||
extern int FmoFinit(VideoParameters *p_Vid);
|
extern int FmoFinit(VideoParameters *p_Vid);
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,7 @@
|
||||||
#ifndef _FRAME_H_
|
#ifndef _FRAME_H_
|
||||||
#define _FRAME_H_
|
#define _FRAME_H_
|
||||||
|
|
||||||
typedef enum {
|
typedef enum { CM_UNKNOWN = -1, CM_YUV = 0, CM_RGB = 1, CM_XYZ = 2 } ColorModel;
|
||||||
CM_UNKNOWN = -1,
|
|
||||||
CM_YUV = 0,
|
|
||||||
CM_RGB = 1,
|
|
||||||
CM_XYZ = 2
|
|
||||||
} ColorModel;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CF_UNKNOWN = -1, //!< Unknown color format
|
CF_UNKNOWN = -1, //!< Unknown color format
|
||||||
|
@ -27,8 +22,7 @@ typedef enum {
|
||||||
YUV444 = 3 //!< 4:4:4
|
YUV444 = 3 //!< 4:4:4
|
||||||
} ColorFormat;
|
} ColorFormat;
|
||||||
|
|
||||||
typedef struct frame_format
|
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)
|
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)
|
ColorModel color_model; //!< 4:4:4 format (0: YUV, 1: RGB, 2: XYZ)
|
||||||
double frame_rate; //!< frame rate
|
double frame_rate; //!< frame rate
|
||||||
|
|
|
@ -26,28 +26,29 @@
|
||||||
#ifndef _GLOBAL_H_
|
#ifndef _GLOBAL_H_
|
||||||
#define _GLOBAL_H_
|
#define _GLOBAL_H_
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#ifndef SPEC
|
#ifndef SPEC
|
||||||
#include <time.h>
|
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
|
#include <time.h>
|
||||||
#endif /* !SPEC */
|
#endif /* !SPEC */
|
||||||
#include "win32.h"
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
#include "distortion.h"
|
||||||
|
#include "frame.h"
|
||||||
#include "ifunctions.h"
|
#include "ifunctions.h"
|
||||||
|
#include "io_image.h"
|
||||||
|
#include "io_video.h"
|
||||||
#include "parsetcommon.h"
|
#include "parsetcommon.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "io_image.h"
|
#include "win32.h"
|
||||||
#include "frame.h"
|
|
||||||
#include "distortion.h"
|
|
||||||
#include "io_video.h"
|
|
||||||
|
|
||||||
typedef struct bit_stream Bitstream;
|
typedef struct bit_stream Bitstream;
|
||||||
|
|
||||||
#define ET_SIZE 300 //!< size of error text buffer
|
#define ET_SIZE 300 //!< size of error text buffer
|
||||||
extern char errortext[ET_SIZE]; //!< buffer for error message for exit with error()
|
extern char
|
||||||
|
errortext[ET_SIZE]; //!< buffer for error message for exit with error()
|
||||||
|
|
||||||
struct pic_motion_params_old;
|
struct pic_motion_params_old;
|
||||||
struct pic_motion_params;
|
struct pic_motion_params;
|
||||||
|
@ -56,26 +57,19 @@ struct pic_motion_params;
|
||||||
* T y p e d e f i n i t i o n s f o r J M
|
* T y p e d e f i n i t i o n s f o r J M
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
DEC_OPENED = 0,
|
DEC_OPENED = 0,
|
||||||
DEC_STOPPED,
|
DEC_STOPPED,
|
||||||
} DecoderStatus_e;
|
} DecoderStatus_e;
|
||||||
|
|
||||||
typedef enum
|
typedef enum { LumaComp = 0, CrComp = 1, CbComp = 2 } Color_Component;
|
||||||
{
|
|
||||||
LumaComp = 0,
|
|
||||||
CrComp = 1,
|
|
||||||
CbComp = 2
|
|
||||||
} Color_Component;
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* D a t a t y p e s f o r C A B A C
|
* D a t a t y p e s f o r C A B A C
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct pix_pos
|
typedef struct pix_pos {
|
||||||
{
|
|
||||||
int available;
|
int available;
|
||||||
int mb_addr;
|
int mb_addr;
|
||||||
short x;
|
short x;
|
||||||
|
@ -85,8 +79,7 @@ typedef struct pix_pos
|
||||||
} PixelPos;
|
} PixelPos;
|
||||||
|
|
||||||
//! struct to characterize the state of the arithmetic coding engine
|
//! struct to characterize the state of the arithmetic coding engine
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
unsigned int Drange;
|
unsigned int Drange;
|
||||||
unsigned int Dvalue;
|
unsigned int Dvalue;
|
||||||
int DbitsLeft;
|
int DbitsLeft;
|
||||||
|
@ -97,16 +90,14 @@ typedef struct
|
||||||
typedef DecodingEnvironment *DecodingEnvironmentPtr;
|
typedef DecodingEnvironment *DecodingEnvironmentPtr;
|
||||||
|
|
||||||
// Motion Vector structure
|
// Motion Vector structure
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
short mv_x;
|
short mv_x;
|
||||||
short mv_y;
|
short mv_y;
|
||||||
} MotionVector;
|
} MotionVector;
|
||||||
|
|
||||||
static const MotionVector zero_mv = {0, 0};
|
static const MotionVector zero_mv = {0, 0};
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
short x;
|
short x;
|
||||||
short y;
|
short y;
|
||||||
} BlockPos;
|
} BlockPos;
|
||||||
|
@ -114,8 +105,7 @@ typedef struct
|
||||||
extern BlockPos *PicPos;
|
extern BlockPos *PicPos;
|
||||||
|
|
||||||
//! struct for context management
|
//! struct for context management
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint16 state; // index into state-table CP
|
uint16 state; // index into state-table CP
|
||||||
unsigned char MPS; // Least Probable Symbol 0/1 CP
|
unsigned char MPS; // Least Probable Symbol 0/1 CP
|
||||||
unsigned char dummy; // for alignment
|
unsigned char dummy; // for alignment
|
||||||
|
@ -123,7 +113,6 @@ typedef struct
|
||||||
|
|
||||||
typedef BiContextType *BiContextTypePtr;
|
typedef BiContextType *BiContextTypePtr;
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* C O N T E X T S F O R T M L S Y N T A X E L E M E N T S
|
* C O N T E X T S F O R T M L S Y N T A X E L E M E N T S
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
@ -142,8 +131,7 @@ struct storable_picture;
|
||||||
struct datapartition;
|
struct datapartition;
|
||||||
struct syntaxelement;
|
struct syntaxelement;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
BiContextType mb_type_contexts[3][NUM_MB_TYPE_CTX];
|
BiContextType mb_type_contexts[3][NUM_MB_TYPE_CTX];
|
||||||
BiContextType b8_type_contexts[2][NUM_B8_TYPE_CTX];
|
BiContextType b8_type_contexts[2][NUM_B8_TYPE_CTX];
|
||||||
BiContextType mv_res_contexts[2][NUM_MV_RES_CTX];
|
BiContextType mv_res_contexts[2][NUM_MV_RES_CTX];
|
||||||
|
@ -161,8 +149,7 @@ typedef struct
|
||||||
#define NUM_ONE_CTX 5
|
#define NUM_ONE_CTX 5
|
||||||
#define NUM_ABS_CTX 5
|
#define NUM_ABS_CTX 5
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
BiContextType transform_size_contexts[NUM_TRANSFORM_SIZE_CTX];
|
BiContextType transform_size_contexts[NUM_TRANSFORM_SIZE_CTX];
|
||||||
BiContextType ipr_contexts[NUM_IPR_CTX];
|
BiContextType ipr_contexts[NUM_IPR_CTX];
|
||||||
BiContextType cipr_contexts[NUM_CIPR_CTX];
|
BiContextType cipr_contexts[NUM_CIPR_CTX];
|
||||||
|
@ -174,8 +161,8 @@ typedef struct
|
||||||
BiContextType abs_contexts[NUM_BLOCK_TYPES][NUM_ABS_CTX];
|
BiContextType abs_contexts[NUM_BLOCK_TYPES][NUM_ABS_CTX];
|
||||||
} TextureInfoContexts;
|
} TextureInfoContexts;
|
||||||
|
|
||||||
|
//*********************** end of data type definition for CABAC
|
||||||
//*********************** end of data type definition for CABAC *******************
|
//*******************
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* N e w D a t a t y p e s f o r T M L
|
* N e w D a t a t y p e s f o r T M L
|
||||||
|
@ -183,8 +170,7 @@ typedef struct
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! Buffer structure for decoded referenc picture marking commands */
|
/*! Buffer structure for decoded referenc picture marking commands */
|
||||||
typedef struct DecRefPicMarking_s
|
typedef struct DecRefPicMarking_s {
|
||||||
{
|
|
||||||
int memory_management_control_operation;
|
int memory_management_control_operation;
|
||||||
int difference_of_pic_nums_minus1;
|
int difference_of_pic_nums_minus1;
|
||||||
int long_term_pic_num;
|
int long_term_pic_num;
|
||||||
|
@ -194,8 +180,7 @@ typedef struct DecRefPicMarking_s
|
||||||
} DecRefPicMarking_t;
|
} DecRefPicMarking_t;
|
||||||
|
|
||||||
//! Macroblock
|
//! Macroblock
|
||||||
typedef struct macroblock
|
typedef struct macroblock {
|
||||||
{
|
|
||||||
struct slice *p_Slice; //!< pointer to the current slice
|
struct slice *p_Slice; //!< pointer to the current slice
|
||||||
struct video_par *p_Vid; //!< pointer to VideoParameters
|
struct video_par *p_Vid; //!< pointer to VideoParameters
|
||||||
struct inp_par *p_Inp;
|
struct inp_par *p_Inp;
|
||||||
|
@ -222,7 +207,8 @@ typedef struct macroblock
|
||||||
|
|
||||||
short slice_nr;
|
short slice_nr;
|
||||||
signed char ei_flag; //!< error indicator flag that enables concealment
|
signed char ei_flag; //!< error indicator flag that enables concealment
|
||||||
signed char dpl_flag; //!< error indicator flag that signals a missing data partition
|
signed char
|
||||||
|
dpl_flag; //!< error indicator flag that signals a missing data partition
|
||||||
short delta_quant; //!< for rate control
|
short delta_quant; //!< for rate control
|
||||||
short list_offset;
|
short list_offset;
|
||||||
|
|
||||||
|
@ -234,8 +220,10 @@ typedef struct macroblock
|
||||||
|
|
||||||
// some storage of macroblock syntax elements for global access
|
// some storage of macroblock syntax elements for global access
|
||||||
short mb_type;
|
short mb_type;
|
||||||
short mvd[2][BLOCK_MULTIPLE][BLOCK_MULTIPLE][2]; //!< indices correspond to [forw,backw][block_y][block_x][x,y]
|
short mvd[2][BLOCK_MULTIPLE][BLOCK_MULTIPLE]
|
||||||
//short ****mvd; //!< indices correspond to [forw,backw][block_y][block_x][x,y]
|
[2]; //!< indices correspond to [forw,backw][block_y][block_x][x,y]
|
||||||
|
// short ****mvd; //!< indices correspond to
|
||||||
|
// [forw,backw][block_y][block_x][x,y]
|
||||||
int cbp;
|
int cbp;
|
||||||
int64 cbp_blk[3];
|
int64 cbp_blk[3];
|
||||||
int64 cbp_bits[3];
|
int64 cbp_bits[3];
|
||||||
|
@ -259,22 +247,29 @@ typedef struct macroblock
|
||||||
Boolean luma_transform_size_8x8_flag;
|
Boolean luma_transform_size_8x8_flag;
|
||||||
Boolean NoMbPartLessThan8x8Flag;
|
Boolean NoMbPartLessThan8x8Flag;
|
||||||
|
|
||||||
void (*itrans_4x4)(struct macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
void (*itrans_4x4)(struct macroblock *currMB, ColorPlane pl, int ioff,
|
||||||
void (*itrans_8x8)(struct macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
int joff);
|
||||||
|
void (*itrans_8x8)(struct macroblock *currMB, ColorPlane pl, int ioff,
|
||||||
|
int joff);
|
||||||
|
|
||||||
void (*GetMVPredictor)(struct macroblock *currMB, PixelPos *block,
|
void (*GetMVPredictor)(struct macroblock *currMB, PixelPos *block,
|
||||||
MotionVector *pmv, short ref_frame, struct pic_motion_params **mv_info, int list, int mb_x, int mb_y, int blockshape_x, int blockshape_y);
|
MotionVector *pmv, short ref_frame,
|
||||||
|
struct pic_motion_params **mv_info, int list, int mb_x,
|
||||||
|
int mb_y, int blockshape_x, int blockshape_y);
|
||||||
|
|
||||||
int (*read_and_store_CBP_block_bit) (struct macroblock *currMB, DecodingEnvironmentPtr dep_dp, int type);
|
int (*read_and_store_CBP_block_bit)(struct macroblock *currMB,
|
||||||
signed char (*readRefPictureIdx) (struct macroblock *currMB, struct syntaxelement *currSE, struct datapartition *dP, signed char b8mode, int list);
|
DecodingEnvironmentPtr dep_dp, int type);
|
||||||
|
signed char (*readRefPictureIdx)(struct macroblock *currMB,
|
||||||
|
struct syntaxelement *currSE,
|
||||||
|
struct datapartition *dP, signed char b8mode,
|
||||||
|
int list);
|
||||||
|
|
||||||
// MBAFF case;
|
// MBAFF case;
|
||||||
byte mixedModeEdgeFlag;
|
byte mixedModeEdgeFlag;
|
||||||
} Macroblock;
|
} Macroblock;
|
||||||
|
|
||||||
//! Syntaxelement
|
//! Syntaxelement
|
||||||
typedef struct syntaxelement
|
typedef struct syntaxelement {
|
||||||
{
|
|
||||||
int type; //!< type of syntax element for data part.
|
int type; //!< type of syntax element for data part.
|
||||||
int value1; //!< numerical value of syntax element
|
int value1; //!< numerical value of syntax element
|
||||||
int value2; //!< for blocked symbols, e.g. run/level
|
int value2; //!< for blocked symbols, e.g. run/level
|
||||||
|
@ -291,19 +286,20 @@ typedef struct syntaxelement
|
||||||
|
|
||||||
//! for mapping of CAVLC to syntaxElement
|
//! for mapping of CAVLC to syntaxElement
|
||||||
void (*mapping)(int len, int info, int *value1, int *value2);
|
void (*mapping)(int len, int info, int *value1, int *value2);
|
||||||
//! used for CABAC: refers to actual coding method of each individual syntax element type
|
//! used for CABAC: refers to actual coding method of each individual syntax
|
||||||
void (*reading)(Macroblock *currMB, struct syntaxelement *, DecodingEnvironmentPtr);
|
//! element type
|
||||||
|
void (*reading)(Macroblock *currMB, struct syntaxelement *,
|
||||||
|
DecodingEnvironmentPtr);
|
||||||
} SyntaxElement;
|
} SyntaxElement;
|
||||||
|
|
||||||
|
|
||||||
//! Bitstream
|
//! Bitstream
|
||||||
struct bit_stream
|
struct bit_stream {
|
||||||
{
|
|
||||||
// CABAC Decoding
|
// CABAC Decoding
|
||||||
int read_len; //!< actual position in the codebuffer, CABAC only
|
int read_len; //!< actual position in the codebuffer, CABAC only
|
||||||
int code_len; //!< overall codebuffer length, CABAC only
|
int code_len; //!< overall codebuffer length, CABAC only
|
||||||
// CAVLC Decoding
|
// CAVLC Decoding
|
||||||
int frame_bitoffset; //!< actual position in the codebuffer, bit-oriented, CAVLC only
|
int frame_bitoffset; //!< actual position in the codebuffer, bit-oriented,
|
||||||
|
//!< CAVLC only
|
||||||
int bitstream_length; //!< over codebuffer lnegth, byte oriented, CAVLC only
|
int bitstream_length; //!< over codebuffer lnegth, byte oriented, CAVLC only
|
||||||
// ErrorConcealment
|
// ErrorConcealment
|
||||||
byte *streamBuffer; //!< actual codebuffer for read bytes
|
byte *streamBuffer; //!< actual codebuffer for read bytes
|
||||||
|
@ -311,21 +307,20 @@ struct bit_stream
|
||||||
};
|
};
|
||||||
|
|
||||||
//! DataPartition
|
//! DataPartition
|
||||||
typedef struct datapartition
|
typedef struct datapartition {
|
||||||
{
|
|
||||||
|
|
||||||
Bitstream *bitstream;
|
Bitstream *bitstream;
|
||||||
DecodingEnvironment de_cabac;
|
DecodingEnvironment de_cabac;
|
||||||
|
|
||||||
int (*readSyntaxElement)(Macroblock *currMB, SyntaxElement *, struct datapartition *);
|
int (*readSyntaxElement)(Macroblock *currMB, SyntaxElement *,
|
||||||
|
struct datapartition *);
|
||||||
/*!< virtual function;
|
/*!< virtual function;
|
||||||
actual method depends on chosen data partition and
|
actual method depends on chosen data partition and
|
||||||
entropy coding method */
|
entropy coding method */
|
||||||
} DataPartition;
|
} DataPartition;
|
||||||
|
|
||||||
#if (MVC_EXTENSION_ENABLE)
|
#if (MVC_EXTENSION_ENABLE)
|
||||||
typedef struct nalunitheadermvcext_tag
|
typedef struct nalunitheadermvcext_tag {
|
||||||
{
|
|
||||||
unsigned int non_idr_flag;
|
unsigned int non_idr_flag;
|
||||||
unsigned int priority_id;
|
unsigned int priority_id;
|
||||||
unsigned int view_id;
|
unsigned int view_id;
|
||||||
|
@ -338,8 +333,7 @@ typedef struct nalunitheadermvcext_tag
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! Slice
|
//! Slice
|
||||||
typedef struct slice
|
typedef struct slice {
|
||||||
{
|
|
||||||
struct video_par *p_Vid;
|
struct video_par *p_Vid;
|
||||||
struct inp_par *p_Inp;
|
struct inp_par *p_Inp;
|
||||||
pic_parameter_set_rbsp_t *active_pps;
|
pic_parameter_set_rbsp_t *active_pps;
|
||||||
|
@ -377,8 +371,8 @@ typedef struct slice
|
||||||
// for POC mode 1:
|
// for POC mode 1:
|
||||||
unsigned int AbsFrameNum;
|
unsigned int AbsFrameNum;
|
||||||
int ThisPOC;
|
int ThisPOC;
|
||||||
//signed int ExpectedPicOrderCnt, PicOrderCntCycleCnt, FrameNumInPicOrderCntCycle;
|
// signed int ExpectedPicOrderCnt, PicOrderCntCycleCnt,
|
||||||
//unsigned int PreviousFrameNum, FrameNumOffset;
|
// FrameNumInPicOrderCntCycle; unsigned int PreviousFrameNum, FrameNumOffset;
|
||||||
// int ExpectedDeltaPerPicOrderCntCycle;
|
// int ExpectedDeltaPerPicOrderCntCycle;
|
||||||
// int PreviousFrameNumOffset;
|
// int PreviousFrameNumOffset;
|
||||||
// /////////////////////////
|
// /////////////////////////
|
||||||
|
@ -398,10 +392,12 @@ typedef struct slice
|
||||||
// end;
|
// end;
|
||||||
|
|
||||||
int mb_aff_frame_flag;
|
int mb_aff_frame_flag;
|
||||||
int direct_spatial_mv_pred_flag; //!< Indicator for direct mode type (1 for Spatial, 0 for Temporal)
|
int direct_spatial_mv_pred_flag; //!< Indicator for direct mode type (1 for
|
||||||
|
//!< Spatial, 0 for Temporal)
|
||||||
int num_ref_idx_active[2]; //!< number of available list references
|
int num_ref_idx_active[2]; //!< number of available list references
|
||||||
//int num_ref_idx_l0_active; //!< number of available list 0 references
|
// int num_ref_idx_l0_active; //!< number of
|
||||||
//int num_ref_idx_l1_active; //!< number of available list 1 references
|
// available list 0 references int num_ref_idx_l1_active; //!<
|
||||||
|
// number of available list 1 references
|
||||||
|
|
||||||
int ei_flag; //!< 0 if the partArr[0] contains valid information
|
int ei_flag; //!< 0 if the partArr[0] contains valid information
|
||||||
int qp;
|
int qp;
|
||||||
|
@ -431,15 +427,20 @@ typedef struct slice
|
||||||
int no_output_of_prior_pics_flag;
|
int no_output_of_prior_pics_flag;
|
||||||
int long_term_reference_flag;
|
int long_term_reference_flag;
|
||||||
int adaptive_ref_pic_buffering_flag;
|
int adaptive_ref_pic_buffering_flag;
|
||||||
DecRefPicMarking_t *dec_ref_pic_marking_buffer; //!< stores the memory management control operations
|
DecRefPicMarking_t
|
||||||
|
*dec_ref_pic_marking_buffer; //!< stores the memory management control
|
||||||
|
//!< operations
|
||||||
|
|
||||||
signed char listXsize[6];
|
signed char listXsize[6];
|
||||||
struct storable_picture **listX[6];
|
struct storable_picture **listX[6];
|
||||||
|
|
||||||
// int last_mb_nr; //!< only valid when entropy coding == CABAC
|
// int last_mb_nr; //!< only valid when entropy coding ==
|
||||||
|
// CABAC
|
||||||
DataPartition *partArr; //!< array of partitions
|
DataPartition *partArr; //!< array of partitions
|
||||||
MotionInfoContexts *mot_ctx; //!< pointer to struct of context models for use in CABAC
|
MotionInfoContexts
|
||||||
TextureInfoContexts *tex_ctx; //!< pointer to struct of context models for use in CABAC
|
*mot_ctx; //!< pointer to struct of context models for use in CABAC
|
||||||
|
TextureInfoContexts
|
||||||
|
*tex_ctx; //!< pointer to struct of context models for use in CABAC
|
||||||
|
|
||||||
int mvscale[6][MAX_REFERENCE_PICTURES];
|
int mvscale[6][MAX_REFERENCE_PICTURES];
|
||||||
|
|
||||||
|
@ -462,7 +463,8 @@ typedef struct slice
|
||||||
short DFAlphaC0Offset; //!< Alpha and C0 offset for filtering slice
|
short DFAlphaC0Offset; //!< Alpha and C0 offset for filtering slice
|
||||||
short DFBetaOffset; //!< Beta offset for filtering slice
|
short DFBetaOffset; //!< Beta offset for filtering slice
|
||||||
|
|
||||||
int pic_parameter_set_id; //!<the ID of the picture parameter set the slice is reffering to
|
int pic_parameter_set_id; //!< the ID of the picture parameter set the slice
|
||||||
|
//!< is reffering to
|
||||||
|
|
||||||
int dpB_NotPresent; //!< non-zero, if data partition B is lost
|
int dpB_NotPresent; //!< non-zero, if data partition B is lost
|
||||||
int dpC_NotPresent; //!< non-zero, if data partition C is lost
|
int dpC_NotPresent; //!< non-zero, if data partition C is lost
|
||||||
|
@ -495,7 +497,6 @@ typedef struct slice
|
||||||
int coeff_ctr;
|
int coeff_ctr;
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
|
|
||||||
// weighted prediction
|
// weighted prediction
|
||||||
unsigned short weighted_pred_flag;
|
unsigned short weighted_pred_flag;
|
||||||
unsigned short weighted_bipred_idc;
|
unsigned short weighted_bipred_idc;
|
||||||
|
@ -517,11 +518,14 @@ typedef struct slice
|
||||||
|
|
||||||
// for signalling to the neighbour logic that this is a deblocker call
|
// for signalling to the neighbour logic that this is a deblocker call
|
||||||
// byte mixedModeEdgeFlag;
|
// byte mixedModeEdgeFlag;
|
||||||
int max_mb_vmv_r; //!< maximum vertical motion vector range in luma quarter pixel units for the current level_idc
|
int max_mb_vmv_r; //!< maximum vertical motion vector range in luma quarter
|
||||||
|
//!< pixel units for the current level_idc
|
||||||
int ref_flag[17]; //!< 0: i-th previous frame is incorrect
|
int ref_flag[17]; //!< 0: i-th previous frame is incorrect
|
||||||
|
|
||||||
void (*read_CBP_and_coeffs_from_NAL)(Macroblock *currMB);
|
void (*read_CBP_and_coeffs_from_NAL)(Macroblock *currMB);
|
||||||
int (*decode_one_component ) (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, struct storable_picture *dec_picture);
|
int (*decode_one_component)(Macroblock *currMB, ColorPlane curr_plane,
|
||||||
|
imgpel **currImg,
|
||||||
|
struct storable_picture *dec_picture);
|
||||||
int (*readSlice)(struct video_par *, struct inp_par *);
|
int (*readSlice)(struct video_par *, struct inp_par *);
|
||||||
int (*nal_startcode_follows)(struct slice *, int);
|
int (*nal_startcode_follows)(struct slice *, int);
|
||||||
void (*read_motion_info_from_NAL)(Macroblock *currMB);
|
void (*read_motion_info_from_NAL)(Macroblock *currMB);
|
||||||
|
@ -541,8 +545,7 @@ typedef struct slice
|
||||||
signed char chroma_vector_adjustment[6][16];
|
signed char chroma_vector_adjustment[6][16];
|
||||||
} Slice;
|
} Slice;
|
||||||
|
|
||||||
typedef struct decodedpic_t
|
typedef struct decodedpic_t {
|
||||||
{
|
|
||||||
int bValid; // 0: invalid, 1: valid, 3: valid for 3D output;
|
int bValid; // 0: invalid, 1: valid, 3: valid for 3D output;
|
||||||
int iViewId; //-1: single view, >=0 multiview[VIEW1|VIEW0];
|
int iViewId; //-1: single view, >=0 multiview[VIEW1|VIEW0];
|
||||||
int iPOC;
|
int iPOC;
|
||||||
|
@ -563,8 +566,7 @@ typedef struct decodedpic_t
|
||||||
//****************************** ~DM ***********************************
|
//****************************** ~DM ***********************************
|
||||||
|
|
||||||
// video parameters
|
// video parameters
|
||||||
typedef struct video_par
|
typedef struct video_par {
|
||||||
{
|
|
||||||
struct inp_par *p_Inp;
|
struct inp_par *p_Inp;
|
||||||
pic_parameter_set_rbsp_t *active_pps;
|
pic_parameter_set_rbsp_t *active_pps;
|
||||||
seq_parameter_set_rbsp_t *active_sps;
|
seq_parameter_set_rbsp_t *active_sps;
|
||||||
|
@ -595,9 +597,11 @@ typedef struct video_par
|
||||||
Slice **ppSliceList;
|
Slice **ppSliceList;
|
||||||
signed char *intra_block;
|
signed char *intra_block;
|
||||||
signed char *intra_block_JV[MAX_PLANE];
|
signed char *intra_block_JV[MAX_PLANE];
|
||||||
//int qp; //!< quant for the current frame
|
// int qp; //!< quant for the current
|
||||||
|
// frame
|
||||||
|
|
||||||
//int sp_switch; //!< 1 for switching sp, 0 for normal sp
|
// int sp_switch; //!< 1 for switching sp, 0 for
|
||||||
|
// normal sp
|
||||||
int type; //!< image type INTER/INTRA
|
int type; //!< image type INTER/INTRA
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
@ -613,11 +617,14 @@ typedef struct video_par
|
||||||
int newframe;
|
int newframe;
|
||||||
int structure; //!< Identify picture structure type
|
int structure; //!< Identify picture structure type
|
||||||
|
|
||||||
//Slice *currentSlice; //!< pointer to current Slice data struct
|
// Slice *currentSlice; //!< pointer to current Slice data
|
||||||
|
// struct
|
||||||
Slice *pNextSlice; //!< pointer to first Slice of next picture;
|
Slice *pNextSlice; //!< pointer to first Slice of next picture;
|
||||||
Macroblock *mb_data; //!< array containing all MBs of a whole frame
|
Macroblock *mb_data; //!< array containing all MBs of a whole frame
|
||||||
Macroblock *mb_data_JV[MAX_PLANE]; //!< mb_data to be used for 4:4:4 independent mode
|
Macroblock
|
||||||
//int colour_plane_id; //!< colour_plane_id of the current coded slice
|
*mb_data_JV[MAX_PLANE]; //!< mb_data to be used for 4:4:4 independent mode
|
||||||
|
// int colour_plane_id; //!< colour_plane_id of the current
|
||||||
|
// coded slice
|
||||||
int ChromaArrayType;
|
int ChromaArrayType;
|
||||||
|
|
||||||
// picture error concealment
|
// picture error concealment
|
||||||
|
@ -626,7 +633,8 @@ typedef struct video_par
|
||||||
struct concealment_node *concealment_head;
|
struct concealment_node *concealment_head;
|
||||||
struct concealment_node *concealment_end;
|
struct concealment_node *concealment_end;
|
||||||
|
|
||||||
unsigned int pre_frame_num; //!< store the frame_num in the last decoded slice. For detecting gap in frame_num.
|
unsigned int pre_frame_num; //!< store the frame_num in the last decoded
|
||||||
|
//!< slice. For detecting gap in frame_num.
|
||||||
int non_conforming_stream;
|
int non_conforming_stream;
|
||||||
|
|
||||||
// ////////////////////////
|
// ////////////////////////
|
||||||
|
@ -635,7 +643,8 @@ typedef struct video_par
|
||||||
unsigned int PrevPicOrderCntLsb;
|
unsigned int PrevPicOrderCntLsb;
|
||||||
|
|
||||||
// for POC mode 1:
|
// for POC mode 1:
|
||||||
signed int ExpectedPicOrderCnt, PicOrderCntCycleCnt, FrameNumInPicOrderCntCycle;
|
signed int ExpectedPicOrderCnt, PicOrderCntCycleCnt,
|
||||||
|
FrameNumInPicOrderCntCycle;
|
||||||
unsigned int PreviousFrameNum, FrameNumOffset;
|
unsigned int PreviousFrameNum, FrameNumOffset;
|
||||||
int ExpectedDeltaPerPicOrderCntCycle;
|
int ExpectedDeltaPerPicOrderCntCycle;
|
||||||
int ThisPOC;
|
int ThisPOC;
|
||||||
|
@ -664,8 +673,12 @@ typedef struct video_par
|
||||||
int bitdepth_scale[2];
|
int bitdepth_scale[2];
|
||||||
int bitdepth_luma_qp_scale;
|
int bitdepth_luma_qp_scale;
|
||||||
int bitdepth_chroma_qp_scale;
|
int bitdepth_chroma_qp_scale;
|
||||||
unsigned int dc_pred_value_comp[MAX_PLANE]; //!< component value for DC prediction (depends on component pel bit depth)
|
unsigned int
|
||||||
int max_pel_value_comp[MAX_PLANE]; //!< max value that one picture element (pixel) can take (depends on pic_unit_bitdepth)
|
dc_pred_value_comp[MAX_PLANE]; //!< component value for DC prediction
|
||||||
|
//!< (depends on component pel bit depth)
|
||||||
|
int max_pel_value_comp[MAX_PLANE]; //!< max value that one picture element
|
||||||
|
//!< (pixel) can take (depends on
|
||||||
|
//!< pic_unit_bitdepth)
|
||||||
|
|
||||||
int profile_idc;
|
int profile_idc;
|
||||||
int yuv_format;
|
int yuv_format;
|
||||||
|
@ -686,8 +699,10 @@ typedef struct video_par
|
||||||
int shiftpel_y;
|
int shiftpel_y;
|
||||||
int total_scale;
|
int total_scale;
|
||||||
|
|
||||||
int max_vmv_r; //!< maximum vertical motion vector range in luma quarter frame pixel units for the current level_idc
|
int max_vmv_r; //!< maximum vertical motion vector range in luma quarter frame
|
||||||
//int max_mb_vmv_r; //!< maximum vertical motion vector range in luma quarter pixel units for the current level_idc
|
//!< pixel units for the current level_idc
|
||||||
|
// int max_mb_vmv_r; //!< maximum vertical motion
|
||||||
|
// vector range in luma quarter pixel units for the current level_idc
|
||||||
|
|
||||||
int idr_psnr_number;
|
int idr_psnr_number;
|
||||||
int psnr_number;
|
int psnr_number;
|
||||||
|
@ -730,8 +745,8 @@ typedef struct video_par
|
||||||
ImageData imgData5;
|
ImageData imgData5;
|
||||||
ImageData imgData6;
|
ImageData imgData6;
|
||||||
|
|
||||||
|
// Redundant slices. Should be moved to another structure and allocated only
|
||||||
// Redundant slices. Should be moved to another structure and allocated only if extended profile
|
// if extended profile
|
||||||
unsigned int previous_frame_num; //!< frame number of previous slice
|
unsigned int previous_frame_num; //!< frame number of previous slice
|
||||||
//!< non-zero: i-th previous frame is correct
|
//!< non-zero: i-th previous frame is correct
|
||||||
int Is_primary_correct; //!< if primary frame is correct, 0: incorrect
|
int Is_primary_correct; //!< if primary frame is correct, 0: incorrect
|
||||||
|
@ -769,8 +784,11 @@ typedef struct video_par
|
||||||
int pocs_in_dpb[100];
|
int pocs_in_dpb[100];
|
||||||
|
|
||||||
struct storable_picture *dec_picture;
|
struct storable_picture *dec_picture;
|
||||||
struct storable_picture *dec_picture_JV[MAX_PLANE]; //!< dec_picture to be used during 4:4:4 independent mode decoding
|
struct storable_picture
|
||||||
struct storable_picture *no_reference_picture; //!< dummy storable picture for recovery point
|
*dec_picture_JV[MAX_PLANE]; //!< dec_picture to be used during 4:4:4
|
||||||
|
//!< independent mode decoding
|
||||||
|
struct storable_picture
|
||||||
|
*no_reference_picture; //!< dummy storable picture for recovery point
|
||||||
|
|
||||||
// Error parameters
|
// Error parameters
|
||||||
struct object_buffer *erc_object_list;
|
struct object_buffer *erc_object_list;
|
||||||
|
@ -792,31 +810,46 @@ typedef struct video_par
|
||||||
int BitStreamFile;
|
int BitStreamFile;
|
||||||
// dpb
|
// dpb
|
||||||
struct decoded_picture_buffer *p_Dpb;
|
struct decoded_picture_buffer *p_Dpb;
|
||||||
struct decoded_picture_buffer *p_Dpb_legacy; // This is the old JM dpb method and will be removed at some point
|
struct decoded_picture_buffer
|
||||||
|
*p_Dpb_legacy; // This is the old JM dpb method and will be removed at
|
||||||
|
// some point
|
||||||
struct decoded_picture_buffer *p_Dpb_layer[2];
|
struct decoded_picture_buffer *p_Dpb_layer[2];
|
||||||
|
|
||||||
|
|
||||||
// report
|
// report
|
||||||
char cslice_type[9];
|
char cslice_type[9];
|
||||||
// FMO
|
// FMO
|
||||||
int *MbToSliceGroupMap;
|
int *MbToSliceGroupMap;
|
||||||
int *MapUnitToSliceGroupMap;
|
int *MapUnitToSliceGroupMap;
|
||||||
int NumberOfSliceGroups; // the number of slice groups -1 (0 == scan order, 7 == maximum)
|
int NumberOfSliceGroups; // the number of slice groups -1 (0 == scan order, 7
|
||||||
|
// == maximum)
|
||||||
|
|
||||||
#if (ENABLE_OUTPUT_TONEMAPPING)
|
#if (ENABLE_OUTPUT_TONEMAPPING)
|
||||||
struct tone_mapping_struct_s *seiToneMapping;
|
struct tone_mapping_struct_s *seiToneMapping;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void (*buf2img) (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)(imgpel **imgX, unsigned char *buf, int size_x, int size_y,
|
||||||
void (*getNeighbour) (Macroblock *currMB, int xN, int yN, int mb_size[2], PixelPos *pix);
|
int o_size_x, int o_size_y, int symbol_size_in_bytes,
|
||||||
|
int bitshift);
|
||||||
|
void (*getNeighbour)(Macroblock *currMB, int xN, int yN, int mb_size[2],
|
||||||
|
PixelPos *pix);
|
||||||
void (*get_mb_block_pos)(int mb_addr, short *x, short *y);
|
void (*get_mb_block_pos)(int mb_addr, short *x, short *y);
|
||||||
void (*GetStrengthVer) (byte Strength[16], Macroblock *MbQ, int edge, int mvlimit, struct storable_picture *p);
|
void (*GetStrengthVer)(byte Strength[16], Macroblock *MbQ, int edge,
|
||||||
void (*GetStrengthHor) (byte Strength[16], Macroblock *MbQ, int edge, int mvlimit, struct storable_picture *p);
|
int mvlimit, struct storable_picture *p);
|
||||||
void (*EdgeLoopLumaVer) (ColorPlane pl, imgpel** Img, byte Strength[16], Macroblock *MbQ, int edge, struct storable_picture *p);
|
void (*GetStrengthHor)(byte Strength[16], Macroblock *MbQ, int edge,
|
||||||
void (*EdgeLoopLumaHor) (ColorPlane pl, imgpel** Img, byte Strength[16], Macroblock *MbQ, int edge, struct storable_picture *p);
|
int mvlimit, struct storable_picture *p);
|
||||||
void (*EdgeLoopChromaVer)(imgpel** Img, byte Strength[16], Macroblock *MbQ, int edge, int uv, struct storable_picture *p);
|
void (*EdgeLoopLumaVer)(ColorPlane pl, imgpel **Img, byte Strength[16],
|
||||||
void (*EdgeLoopChromaHor)(imgpel** Img, byte Strength[16], Macroblock *MbQ, int edge, int uv, struct storable_picture *p);
|
Macroblock *MbQ, int edge,
|
||||||
void (*img2buf) (imgpel** imgX, unsigned char* buf, int size_x, int size_y, int symbol_size_in_bytes, int crop_left, int crop_right, int crop_top, int crop_bottom, int iOutStride);
|
struct storable_picture *p);
|
||||||
|
void (*EdgeLoopLumaHor)(ColorPlane pl, imgpel **Img, byte Strength[16],
|
||||||
|
Macroblock *MbQ, int edge,
|
||||||
|
struct storable_picture *p);
|
||||||
|
void (*EdgeLoopChromaVer)(imgpel **Img, byte Strength[16], Macroblock *MbQ,
|
||||||
|
int edge, int uv, struct storable_picture *p);
|
||||||
|
void (*EdgeLoopChromaHor)(imgpel **Img, byte Strength[16], Macroblock *MbQ,
|
||||||
|
int edge, int uv, struct storable_picture *p);
|
||||||
|
void (*img2buf)(imgpel **imgX, unsigned char *buf, int size_x, int size_y,
|
||||||
|
int symbol_size_in_bytes, int crop_left, int crop_right,
|
||||||
|
int crop_top, int crop_bottom, int iOutStride);
|
||||||
|
|
||||||
DecodedPicList *pDecOuputPic;
|
DecodedPicList *pDecOuputPic;
|
||||||
int iDeblockMode; // 0: deblock in picture, 1: deblock in slice;
|
int iDeblockMode; // 0: deblock in picture, 1: deblock in slice;
|
||||||
|
@ -836,8 +869,7 @@ typedef struct video_par
|
||||||
} VideoParameters;
|
} VideoParameters;
|
||||||
|
|
||||||
// signal to noise ratio parameters
|
// signal to noise ratio parameters
|
||||||
typedef struct snr_par
|
typedef struct snr_par {
|
||||||
{
|
|
||||||
int frame_ctr;
|
int frame_ctr;
|
||||||
float snr[3]; //!< current SNR (component)
|
float snr[3]; //!< current SNR (component)
|
||||||
float snr1[3]; //!< SNR (dB) first frame (component)
|
float snr1[3]; //!< SNR (dB) first frame (component)
|
||||||
|
@ -847,18 +879,20 @@ typedef struct snr_par
|
||||||
} SNRParameters;
|
} SNRParameters;
|
||||||
|
|
||||||
// input parameters from configuration file
|
// input parameters from configuration file
|
||||||
typedef struct inp_par
|
typedef struct inp_par {
|
||||||
{
|
|
||||||
char infile[FILE_NAME_SIZE]; //!< H.264 inputfile
|
char infile[FILE_NAME_SIZE]; //!< H.264 inputfile
|
||||||
char outfile[FILE_NAME_SIZE]; //!< Decoded YUV 4:2:0 output
|
char outfile[FILE_NAME_SIZE]; //!< Decoded YUV 4:2:0 output
|
||||||
char reffile[FILE_NAME_SIZE]; //!< Optional YUV 4:2:0 reference file for SNR measurement
|
char reffile[FILE_NAME_SIZE]; //!< Optional YUV 4:2:0 reference file for SNR
|
||||||
|
//!< measurement
|
||||||
|
|
||||||
int FileFormat; //!< File format of the Input file, PAR_OF_ANNEXB or PAR_OF_RTP
|
int FileFormat; //!< File format of the Input file, PAR_OF_ANNEXB or
|
||||||
|
//!< PAR_OF_RTP
|
||||||
int ref_offset;
|
int ref_offset;
|
||||||
int poc_scale;
|
int poc_scale;
|
||||||
int write_uv;
|
int write_uv;
|
||||||
int silent;
|
int silent;
|
||||||
int intra_profile_deblocking; //!< Loop filter usage determined by flags and parameters in bitstream
|
int intra_profile_deblocking; //!< Loop filter usage determined by flags and
|
||||||
|
//!< parameters in bitstream
|
||||||
|
|
||||||
// Input/output sequence format related variables
|
// Input/output sequence format related variables
|
||||||
FrameFormat source; //!< source related information
|
FrameFormat source; //!< source related information
|
||||||
|
@ -885,11 +919,11 @@ typedef struct inp_par
|
||||||
int ref_poc_gap;
|
int ref_poc_gap;
|
||||||
int poc_gap;
|
int poc_gap;
|
||||||
|
|
||||||
|
|
||||||
// dummy for encoder
|
// dummy for encoder
|
||||||
int start_frame;
|
int start_frame;
|
||||||
|
|
||||||
// Needed to allow compilation for decoder. May be used later for distortion computation operations
|
// Needed to allow compilation for decoder. May be used later for distortion
|
||||||
|
// computation operations
|
||||||
int stdRange; //!< 1 - standard range, 0 - full range
|
int stdRange; //!< 1 - standard range, 0 - full range
|
||||||
int videoCode; //!< 1 - 709, 3 - 601: See VideoCode in io_tiff.
|
int videoCode; //!< 1 - 709, 3 - 601: See VideoCode in io_tiff.
|
||||||
int export_views;
|
int export_views;
|
||||||
|
@ -899,8 +933,7 @@ typedef struct inp_par
|
||||||
int bDisplayDecParams;
|
int bDisplayDecParams;
|
||||||
} InputParameters;
|
} InputParameters;
|
||||||
|
|
||||||
typedef struct old_slice_par
|
typedef struct old_slice_par {
|
||||||
{
|
|
||||||
unsigned field_pic_flag;
|
unsigned field_pic_flag;
|
||||||
unsigned frame_num;
|
unsigned frame_num;
|
||||||
int nal_ref_idc;
|
int nal_ref_idc;
|
||||||
|
@ -918,8 +951,7 @@ typedef struct old_slice_par
|
||||||
#endif
|
#endif
|
||||||
} OldSliceParams;
|
} OldSliceParams;
|
||||||
|
|
||||||
typedef struct decoder_params
|
typedef struct decoder_params {
|
||||||
{
|
|
||||||
InputParameters *p_Inp; //!< Input Parameters
|
InputParameters *p_Inp; //!< Input Parameters
|
||||||
VideoParameters *p_Vid; //!< Image Parameters
|
VideoParameters *p_Vid; //!< Image Parameters
|
||||||
int64 bufferSize; //!< buffersize for tiff reads (not currently supported)
|
int64 bufferSize; //!< buffersize for tiff reads (not currently supported)
|
||||||
|
@ -928,8 +960,7 @@ typedef struct decoder_params
|
||||||
int bitcounter;
|
int bitcounter;
|
||||||
} DecoderParams;
|
} DecoderParams;
|
||||||
|
|
||||||
typedef struct threadparameter
|
typedef struct threadparameter {
|
||||||
{
|
|
||||||
DecoderParams *pDecoder;
|
DecoderParams *pDecoder;
|
||||||
int iThreadIdx;
|
int iThreadIdx;
|
||||||
} ThreadParam_t;
|
} ThreadParam_t;
|
||||||
|
@ -960,13 +991,15 @@ extern void change_plane_JV ( VideoParameters *p_Vid, int nplane, Slice *pS
|
||||||
extern void make_frame_picture_JV(VideoParameters *p_Vid);
|
extern void make_frame_picture_JV(VideoParameters *p_Vid);
|
||||||
|
|
||||||
#if (MVC_EXTENSION_ENABLE)
|
#if (MVC_EXTENSION_ENABLE)
|
||||||
extern void nal_unit_header_mvc_extension(NALUnitHeaderMVCExt_t *NaluHeaderMVCExt, struct bit_stream *bitstream);
|
extern void
|
||||||
|
nal_unit_header_mvc_extension(NALUnitHeaderMVCExt_t *NaluHeaderMVCExt,
|
||||||
|
struct bit_stream *bitstream);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void FreeDecPicList(DecodedPicList *pDecPicList);
|
extern void FreeDecPicList(DecodedPicList *pDecPicList);
|
||||||
extern void ClearDecPicList(VideoParameters *p_Vid);
|
extern void ClearDecPicList(VideoParameters *p_Vid);
|
||||||
extern DecodedPicList *GetOneAvailDecPicFromList(DecodedPicList *pDecPicList, int b3D);
|
extern DecodedPicList *GetOneAvailDecPicFromList(DecodedPicList *pDecPicList,
|
||||||
|
int b3D);
|
||||||
extern Slice *malloc_slice(InputParameters *p_Inp, VideoParameters *p_Vid);
|
extern Slice *malloc_slice(InputParameters *p_Inp, VideoParameters *p_Vid);
|
||||||
extern void CopySliceInfo(Slice *currSlice, OldSliceParams *p_old_slice);
|
extern void CopySliceInfo(Slice *currSlice, OldSliceParams *p_old_slice);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
DEC_GEN_NOERR = 0,
|
DEC_GEN_NOERR = 0,
|
||||||
DEC_OPEN_NOERR = 0,
|
DEC_OPEN_NOERR = 0,
|
||||||
DEC_CLOSE_NOERR = 0,
|
DEC_CLOSE_NOERR = 0,
|
||||||
|
@ -29,8 +28,7 @@ typedef enum
|
||||||
// DEC_ERRMASK = 0x80000000
|
// DEC_ERRMASK = 0x80000000
|
||||||
} DecErrCode;
|
} DecErrCode;
|
||||||
|
|
||||||
typedef struct dec_set_t
|
typedef struct dec_set_t {
|
||||||
{
|
|
||||||
int iPostprocLevel; // valid interval are [0..100]
|
int iPostprocLevel; // valid interval are [0..100]
|
||||||
int bDBEnable;
|
int bDBEnable;
|
||||||
int bAllLayers;
|
int bAllLayers;
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
extern int FirstPartOfSliceHeader(Slice *currSlice);
|
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 void decode_poc(VideoParameters *p_Vid, Slice *pSlice);
|
||||||
extern int dumppoc(VideoParameters *p_Vid);
|
extern int dumppoc(VideoParameters *p_Vid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
* define some inline functions that are used within the encoder.
|
* define some inline functions that are used within the encoder.
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Karsten Sühring <suehring@hhi.de>
|
||||||
* - Alexis Tourapis <alexismt@ieee.org>
|
* - Alexis Tourapis <alexismt@ieee.org>
|
||||||
*
|
*
|
||||||
|
@ -25,32 +26,22 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
static inline short smin(short a, short b) {
|
||||||
static inline short smin(short a, short b)
|
|
||||||
{
|
|
||||||
return (short)(((a) < (b)) ? (a) : (b));
|
return (short)(((a) < (b)) ? (a) : (b));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline short smax(short a, short b)
|
static inline short smax(short a, short b) {
|
||||||
{
|
|
||||||
return (short)(((a) > (b)) ? (a) : (b));
|
return (short)(((a) > (b)) ? (a) : (b));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int imin(int a, int b)
|
static inline int imin(int a, int b) { return ((a) < (b)) ? (a) : (b); }
|
||||||
{
|
|
||||||
return ((a) < (b)) ? (a) : (b);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int imax(int a, int b)
|
static inline int imax(int a, int b) { return ((a) > (b)) ? (a) : (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 (a > b) // a > b
|
||||||
{
|
{
|
||||||
if (b > c)
|
if (b > c)
|
||||||
|
@ -59,8 +50,7 @@ static inline int imedian(int a,int b,int c)
|
||||||
return (c); // a > c > b
|
return (c); // a > c > b
|
||||||
else
|
else
|
||||||
return (a); // c > a > b
|
return (a); // c > a > b
|
||||||
}
|
} else // b > a
|
||||||
else // b > a
|
|
||||||
{
|
{
|
||||||
if (a > c)
|
if (a > c)
|
||||||
return (a); // b > a > c
|
return (a); // b > a > c
|
||||||
|
@ -71,157 +61,114 @@ static inline int imedian(int a,int b,int c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int imedian_old(int a, int b, int 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)));
|
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);
|
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);
|
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);
|
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);
|
return ((a) > (b)) ? (a) : (b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline distblk distblkmin(distblk a, distblk b)
|
static inline short sabs(short x) {
|
||||||
{
|
|
||||||
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 const short SHORT_BITS = (sizeof(short) * CHAR_BIT) - 1;
|
static const short SHORT_BITS = (sizeof(short) * CHAR_BIT) - 1;
|
||||||
short y = (short)(x >> SHORT_BITS);
|
short y = (short)(x >> SHORT_BITS);
|
||||||
return (short)((x ^ y) - y);
|
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;
|
static const int INT_BITS = (sizeof(int) * CHAR_BIT) - 1;
|
||||||
int y = x >> INT_BITS;
|
int y = x >> INT_BITS;
|
||||||
return (x ^ y) - y;
|
return (x ^ y) - y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double dabs(double x)
|
static inline double dabs(double x) { return ((x) < 0) ? -(x) : (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;
|
static const int64 INT64_BITS = (sizeof(int64) * CHAR_BIT) - 1;
|
||||||
int64 y = x >> INT64_BITS;
|
int64 y = x >> INT64_BITS;
|
||||||
return (x ^ y) - y;
|
return (x ^ y) - y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double dabs2(double x)
|
static inline double dabs2(double x) { return (x) * (x); }
|
||||||
{
|
|
||||||
return (x) * (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int iabs2(int x)
|
static inline int iabs2(int x) { return (x) * (x); }
|
||||||
{
|
|
||||||
return (x) * (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int64 i64abs2(int64 x)
|
static inline int64 i64abs2(int64 x) { return (x) * (x); }
|
||||||
{
|
|
||||||
return (x) * (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int isign(int x)
|
static inline int isign(int x) { return ((x > 0) - (x < 0)); }
|
||||||
{
|
|
||||||
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);
|
return ((b) < 0) ? -iabs(a) : iabs(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int rshift_rnd(int x, int a)
|
static inline int rshift_rnd(int x, int a) {
|
||||||
{
|
|
||||||
return (a > 0) ? ((x + (1 << (a - 1))) >> a) : (x << (-a));
|
return (a > 0) ? ((x + (1 << (a - 1))) >> a) : (x << (-a));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int rshift_rnd_sign(int x, int a)
|
static inline int rshift_rnd_sign(int x, int a) {
|
||||||
{
|
return (x > 0) ? ((x + (1 << (a - 1))) >> a)
|
||||||
return (x > 0) ? ( ( x + (1 << (a-1)) ) >> a ) : (-( ( iabs(x) + (1 << (a-1)) ) >> a ));
|
: (-((iabs(x) + (1 << (a - 1))) >> a));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int rshift_rnd_us(unsigned int x, unsigned int a)
|
static inline unsigned int rshift_rnd_us(unsigned int x, unsigned int a) {
|
||||||
{
|
|
||||||
return (a > 0) ? ((x + (1 << (a - 1))) >> a) : x;
|
return (a > 0) ? ((x + (1 << (a - 1))) >> a) : x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int rshift_rnd_sf(int x, int a)
|
static inline int rshift_rnd_sf(int x, int a) {
|
||||||
{
|
|
||||||
return ((x + (1 << (a - 1))) >> a);
|
return ((x + (1 << (a - 1))) >> a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int shift_off_sf(int x, int o, int a)
|
static inline int shift_off_sf(int x, int o, int a) { return ((x + o) >> a); }
|
||||||
{
|
|
||||||
return ((x + o) >> a);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned int rshift_rnd_us_sf(unsigned int x, unsigned int a)
|
static inline unsigned int rshift_rnd_us_sf(unsigned int x, unsigned int a) {
|
||||||
{
|
|
||||||
return ((x + (1 << (a - 1))) >> 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 = imax(x, 0);
|
||||||
x = imin(x, high);
|
x = imin(x, high);
|
||||||
|
|
||||||
return x;
|
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 = imax(x, low);
|
||||||
x = imin(x, high);
|
x = imin(x, high);
|
||||||
|
|
||||||
return x;
|
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 = smax(x, low);
|
||||||
x = smin(x, high);
|
x = smin(x, high);
|
||||||
|
|
||||||
return x;
|
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 = dmax(x, low);
|
||||||
x = dmin(x, high);
|
x = dmin(x, high);
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline distblk weighted_cost(int factor, int bits) {
|
||||||
static inline distblk weighted_cost(int factor, int bits)
|
|
||||||
{
|
|
||||||
#if JCOST_CALC_SCALEUP
|
#if JCOST_CALC_SCALEUP
|
||||||
return (((distblk)(factor)) * ((distblk)(bits)));
|
return (((distblk)(factor)) * ((distblk)(bits)));
|
||||||
#else
|
#else
|
||||||
|
@ -233,69 +180,113 @@ static inline distblk weighted_cost(int factor, int bits)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int RSD(int x)
|
static inline int RSD(int x) { return ((x & 2) ? (x | 1) : (x & (~1))); }
|
||||||
{
|
|
||||||
return ((x&2)?(x|1):(x&(~1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int power2(int x)
|
static inline int power2(int x) { return 1 << (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,
|
static inline int64 i64_power2(int x) { return ((x > 63) ? 0 : po2[x]); }
|
||||||
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)
|
static inline int float2int(float x) {
|
||||||
{
|
|
||||||
return((x > 63) ? 0 : po2[x]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int float2int (float x)
|
|
||||||
{
|
|
||||||
return (int)((x < 0) ? (x - 0.5f) : (x + 0.5f));
|
return (int)((x < 0) ? (x - 0.5f) : (x + 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_bit(int64 x,int n)
|
static inline int get_bit(int64 x, int n) { return (int)(((x >> n) & 1)); }
|
||||||
{
|
|
||||||
return (int)(((x >> n) & 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ZEROSNR
|
#if ZEROSNR
|
||||||
static inline float psnr(int max_sample_sq, int samples, float sse_distortion )
|
static inline float psnr(int max_sample_sq, int samples, float sse_distortion) {
|
||||||
{
|
return (
|
||||||
return (float) (10.0 * log10(max_sample_sq * (double) ((double) samples / (sse_distortion < 1.0 ? 1.0 : sse_distortion))));
|
float)(10.0 *
|
||||||
|
log10(max_sample_sq *
|
||||||
|
(double)((double)samples /
|
||||||
|
(sse_distortion < 1.0 ? 1.0 : sse_distortion))));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline float psnr(int max_sample_sq, int samples, float sse_distortion )
|
static inline float psnr(int max_sample_sq, int samples, float sse_distortion) {
|
||||||
{
|
return (
|
||||||
return (float) (sse_distortion == 0.0 ? 0.0 : (10.0 * log10(max_sample_sq * (double) ((double) samples / sse_distortion))));
|
float)(sse_distortion == 0.0
|
||||||
|
? 0.0
|
||||||
|
: (10.0 * log10(max_sample_sq *
|
||||||
|
(double)((double)samples / sse_distortion))));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline int CheckCost_Shift(int64 mcost, int64 min_mcost)
|
static inline int CheckCost_Shift(int64 mcost, int64 min_mcost) {
|
||||||
{
|
|
||||||
if ((mcost << LAMBDA_ACCURACY_BITS) >= min_mcost)
|
if ((mcost << LAMBDA_ACCURACY_BITS) >= min_mcost)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
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));
|
return ((mcost) >= (min_mcost));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void down_scale(distblk *pblkdistCost)
|
static inline void down_scale(distblk *pblkdistCost) {
|
||||||
{
|
|
||||||
#if JCOST_CALC_SCALEUP
|
#if JCOST_CALC_SCALEUP
|
||||||
#if (IMGTYPE < 2)
|
#if (IMGTYPE < 2)
|
||||||
*pblkdistCost = (*pblkdistCost) >> LAMBDA_ACCURACY_BITS;
|
*pblkdistCost = (*pblkdistCost) >> LAMBDA_ACCURACY_BITS;
|
||||||
|
@ -305,8 +296,7 @@ static inline void down_scale(distblk *pblkdistCost)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void up_scale(distblk *pblkdistCost)
|
static inline void up_scale(distblk *pblkdistCost) {
|
||||||
{
|
|
||||||
#if JCOST_CALC_SCALEUP
|
#if JCOST_CALC_SCALEUP
|
||||||
#if (IMGTYPE < 2)
|
#if (IMGTYPE < 2)
|
||||||
*pblkdistCost = (*pblkdistCost) << LAMBDA_ACCURACY_BITS;
|
*pblkdistCost = (*pblkdistCost) << LAMBDA_ACCURACY_BITS;
|
||||||
|
@ -316,8 +306,7 @@ static inline void up_scale(distblk *pblkdistCost)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline distblk dist_scale(distblk blkdistCost)
|
static inline distblk dist_scale(distblk blkdistCost) {
|
||||||
{
|
|
||||||
#if JCOST_CALC_SCALEUP
|
#if JCOST_CALC_SCALEUP
|
||||||
#if (IMGTYPE < 2)
|
#if (IMGTYPE < 2)
|
||||||
return ((blkdistCost) << LAMBDA_ACCURACY_BITS);
|
return ((blkdistCost) << LAMBDA_ACCURACY_BITS);
|
||||||
|
@ -329,8 +318,7 @@ static inline distblk dist_scale(distblk blkdistCost)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int dist_down(distblk blkdistCost)
|
static inline int dist_down(distblk blkdistCost) {
|
||||||
{
|
|
||||||
#if JCOST_CALC_SCALEUP
|
#if JCOST_CALC_SCALEUP
|
||||||
#if (IMGTYPE < 2)
|
#if (IMGTYPE < 2)
|
||||||
return ((int)((blkdistCost) >> LAMBDA_ACCURACY_BITS));
|
return ((int)((blkdistCost) >> LAMBDA_ACCURACY_BITS));
|
||||||
|
@ -348,4 +336,3 @@ static inline int dist_down(distblk blkdistCost)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,21 +23,23 @@ extern int read_new_slice (Slice *currSlice);
|
||||||
extern void exit_picture(VideoParameters *p_Vid, StorablePicture **dec_picture);
|
extern void exit_picture(VideoParameters *p_Vid, StorablePicture **dec_picture);
|
||||||
extern int decode_one_frame(DecoderParams *pDecoder);
|
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);
|
extern void init_old_slice(OldSliceParams *p_old_slice);
|
||||||
// For 4:4:4 independent mode
|
// 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 frame_postprocessing(VideoParameters *p_Vid);
|
||||||
extern void field_postprocessing(VideoParameters *p_Vid);
|
extern void field_postprocessing(VideoParameters *p_Vid);
|
||||||
|
|
||||||
#if (MVC_EXTENSION_ENABLE)
|
#if (MVC_EXTENSION_ENABLE)
|
||||||
extern int GetVOIdx(VideoParameters *p_Vid, int iViewId);
|
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
|
#endif
|
||||||
|
|
||||||
extern void init_slice(VideoParameters *p_Vid, Slice *currSlice);
|
extern void init_slice(VideoParameters *p_Vid, Slice *currSlice);
|
||||||
extern void decode_slice(Slice *currSlice, int current_header);
|
extern void decode_slice(Slice *currSlice, int current_header);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* image I/O related functions
|
* image I/O related functions
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -15,11 +16,12 @@
|
||||||
#ifndef _IMG_IO_H_
|
#ifndef _IMG_IO_H_
|
||||||
#define _IMG_IO_H_
|
#define _IMG_IO_H_
|
||||||
|
|
||||||
#include "io_video.h"
|
|
||||||
#include "io_raw.h"
|
#include "io_raw.h"
|
||||||
#include "io_tiff.h"
|
#include "io_tiff.h"
|
||||||
|
#include "io_video.h"
|
||||||
|
|
||||||
extern int ParseSizeFromString (VideoDataFile *input_file, int *xlen, int *ylen, double *fps);
|
extern int ParseSizeFromString(VideoDataFile *input_file, int *xlen, int *ylen,
|
||||||
|
double *fps);
|
||||||
extern void ParseFrameNoFormatFromString(VideoDataFile *input_file);
|
extern void ParseFrameNoFormatFromString(VideoDataFile *input_file);
|
||||||
extern void OpenFrameFile(VideoDataFile *input_file, int FrameNumberInFile);
|
extern void OpenFrameFile(VideoDataFile *input_file, int FrameNumberInFile);
|
||||||
extern void OpenFiles(VideoDataFile *input_file);
|
extern void OpenFiles(VideoDataFile *input_file);
|
||||||
|
@ -27,4 +29,3 @@ extern void CloseFiles (VideoDataFile *input_file);
|
||||||
extern VideoFileType ParseVideoType(VideoDataFile *input_file);
|
extern VideoFileType ParseVideoType(VideoDataFile *input_file);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* Input data Image Processing functions
|
* Input data Image Processing functions
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Michael Tourapis <alexis.tourapis@dolby.com>
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
@ -15,11 +16,8 @@
|
||||||
#ifndef _IMG_PROCESS_H_
|
#ifndef _IMG_PROCESS_H_
|
||||||
#define _IMG_PROCESS_H_
|
#define _IMG_PROCESS_H_
|
||||||
|
|
||||||
|
|
||||||
extern int init_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 clear_process_image(VideoParameters *p_Vid, InputParameters *p_Inp);
|
||||||
extern void process_image(VideoParameters *p_Vid, InputParameters *p_Inp);
|
extern void process_image(VideoParameters *p_Vid, InputParameters *p_Inp);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* Input data Image Processing Types
|
* Input data Image Processing Types
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Michael Tourapis <alexis.tourapis@dolby.com>
|
||||||
* - Athanasios Leontaris <aleon@dolby.com>
|
* - Athanasios Leontaris <aleon@dolby.com>
|
||||||
*
|
*
|
||||||
|
|
|
@ -14,12 +14,18 @@
|
||||||
#define _INPUT_H_
|
#define _INPUT_H_
|
||||||
|
|
||||||
extern int testEndian(void);
|
extern int testEndian(void);
|
||||||
extern void initInput(VideoParameters *p_Vid, FrameFormat *source, FrameFormat *output);
|
extern void initInput(VideoParameters *p_Vid, FrameFormat *source,
|
||||||
extern void AllocateFrameMemory (VideoParameters *p_Vid, InputParameters *p_Inp, FrameFormat *source);
|
FrameFormat *output);
|
||||||
|
extern void AllocateFrameMemory(VideoParameters *p_Vid, InputParameters *p_Inp,
|
||||||
|
FrameFormat *source);
|
||||||
extern void DeleteFrameMemory(VideoParameters *p_Vid);
|
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 int read_one_frame(VideoParameters *p_Vid, VideoDataFile *input_file,
|
||||||
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]);
|
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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,3 @@
|
||||||
extern int intrapred16x16(Macroblock *currMB, ColorPlane pl, int b8);
|
extern int intrapred16x16(Macroblock *currMB, ColorPlane pl, int b8);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "mbuffer.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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,3 @@
|
||||||
extern int intrapred8x8(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
extern int intrapred8x8(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
|
||||||
typedef struct image_data
|
typedef struct image_data {
|
||||||
{
|
|
||||||
FrameFormat format; //!< image format
|
FrameFormat format; //!< image format
|
||||||
// Standard data
|
// Standard data
|
||||||
imgpel **frm_data[MAX_PLANE]; //!< Frame Data
|
imgpel **frm_data[MAX_PLANE]; //!< Frame Data
|
||||||
|
@ -26,8 +25,8 @@ typedef struct image_data
|
||||||
imgpel **bot_data[MAX_PLANE]; //!< pointers to bottom 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)
|
//! 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
|
//! These can be useful for enabling input/conversion of content of different
|
||||||
//! while keeping optimal processing size.
|
//! types while keeping optimal processing size.
|
||||||
uint16 **frm_uint16[MAX_PLANE]; //!< optional frame Data for uint16
|
uint16 **frm_uint16[MAX_PLANE]; //!< optional frame Data for uint16
|
||||||
uint16 **top_uint16[MAX_PLANE]; //!< optional pointers to top field data
|
uint16 **top_uint16[MAX_PLANE]; //!< optional pointers to top field data
|
||||||
uint16 **bot_uint16[MAX_PLANE]; //!< optional pointers to bottom field data
|
uint16 **bot_uint16[MAX_PLANE]; //!< optional pointers to bottom field data
|
||||||
|
@ -38,4 +37,3 @@ typedef struct image_data
|
||||||
} ImageData;
|
} ImageData;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,12 @@
|
||||||
#ifndef _IO_RAW_H_
|
#ifndef _IO_RAW_H_
|
||||||
#define _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 ReadFrameConcatenated(InputParameters *p_Inp,
|
||||||
extern int ReadFrameSeparate (InputParameters *p_Inp, VideoDataFile *input_file, int FrameNoInFile, int HeaderSize, FrameFormat *source, unsigned char *buf);
|
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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
// See TIFF 6.0 Specification
|
// See TIFF 6.0 Specification
|
||||||
// http://partners.adobe.com/public/developer/tiff/index.html
|
// http://partners.adobe.com/public/developer/tiff/index.html
|
||||||
|
|
||||||
|
extern int ReadTIFFImage(InputParameters *p_Inp, VideoDataFile *input_file,
|
||||||
extern int ReadTIFFImage (InputParameters *p_Inp, VideoDataFile *input_file, int FrameNoInFile, FrameFormat *source, unsigned char *buf);
|
int FrameNoInFile, FrameFormat *source,
|
||||||
|
unsigned char *buf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,8 +31,7 @@ typedef enum {
|
||||||
VIDEO_AVI = 4
|
VIDEO_AVI = 4
|
||||||
} VideoFileType;
|
} VideoFileType;
|
||||||
|
|
||||||
typedef struct video_data_file
|
typedef struct video_data_file {
|
||||||
{
|
|
||||||
// char* fname; //!< video file name
|
// char* fname; //!< video file name
|
||||||
char fname[FILE_NAME_SIZE]; //!< video file name
|
char fname[FILE_NAME_SIZE]; //!< video file name
|
||||||
char fhead[FILE_NAME_SIZE]; //!< header of video file
|
char fhead[FILE_NAME_SIZE]; //!< header of video file
|
||||||
|
@ -41,8 +40,10 @@ typedef struct video_data_file
|
||||||
VideoFileType vdtype; //!< File format
|
VideoFileType vdtype; //!< File format
|
||||||
FrameFormat format; //!< video format information
|
FrameFormat format; //!< video format information
|
||||||
int is_concatenated; //!< Single or multifile input?
|
int is_concatenated; //!< Single or multifile input?
|
||||||
int is_interleaved; //!< Support for interleaved and non-interleaved input sources
|
int is_interleaved; //!< Support for interleaved and non-interleaved input
|
||||||
int zero_pad; //!< Used when separate image files are used as input. Enables zero padding for file numbering
|
//!< 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 num_digits; //!< Number of digits for file numbering
|
||||||
int start_frame; //!< start frame
|
int start_frame; //!< start frame
|
||||||
int end_frame; //!< end frame
|
int end_frame; //!< end frame
|
||||||
|
@ -60,4 +61,3 @@ typedef struct video_data_file
|
||||||
} VideoDataFile;
|
} VideoDataFile;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
#ifndef _LAGRANGIAN_H_
|
#ifndef _LAGRANGIAN_H_
|
||||||
#define _LAGRANGIAN_H_
|
#define _LAGRANGIAN_H_
|
||||||
|
|
||||||
typedef struct lambda_params
|
typedef struct lambda_params {
|
||||||
{
|
|
||||||
double md; //!< Mode decision Lambda
|
double md; //!< Mode decision Lambda
|
||||||
double me[3]; //!< Motion Estimation Lambda
|
double me[3]; //!< Motion Estimation Lambda
|
||||||
int mf[3]; //!< Integer formatted Motion Estimation Lambda
|
int mf[3]; //!< Integer formatted Motion Estimation Lambda
|
||||||
} LambdaParams;
|
} LambdaParams;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
* Header for Leaky Buffer parameters
|
* Header for Leaky Buffer parameters
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Shankar Regunathan <shanre@microsoft.com>
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -23,4 +24,3 @@ void calc_buffer(InputParameters *p_Inp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
* \brief
|
* \brief
|
||||||
* Headerfile for loopfilter processing
|
* Headerfile for loopfilter processing
|
||||||
* \author
|
* \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>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
|
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
@ -20,49 +21,61 @@
|
||||||
|
|
||||||
#include "global.h"
|
#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)
|
// Alpha( qp ) = 0.8 * (2^(qp/6) - 1)
|
||||||
// Beta ( qp ) = 0.5 * qp - 7
|
// Beta ( qp ) = 0.5 * qp - 7
|
||||||
|
|
||||||
// The tables actually used have been "hand optimized" though (by Anthony Joch). So, the
|
// The tables actually used have been "hand optimized" though (by Anthony Joch).
|
||||||
// table values might be a little different to formula-generated values. Also, the first
|
// So, the table values might be a little different to formula-generated values.
|
||||||
// few values of both tables is set to zero to force the filter off at low qp’s
|
// 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 ALPHA_TABLE[52] = {
|
||||||
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} ;
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
static const byte CLIP_TAB[52][5] =
|
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,
|
||||||
{ 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},
|
71, 80, 90, 101, 113, 127, 144, 162, 182, 203, 226, 255, 255};
|
||||||
{ 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},
|
static const byte BETA_TABLE[52] = {
|
||||||
{ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,
|
||||||
{ 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},
|
2, 3, 3, 3, 3, 4, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
|
||||||
{ 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},
|
11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18};
|
||||||
{ 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},
|
static const byte CLIP_TAB[52][5] = {
|
||||||
{ 0, 9,12,18,18},{ 0,10,13,20,20},{ 0,11,15,23,23},{ 0,13,17,25,25}
|
{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]
|
static const signed char chroma_edge[2][4][4] = //[dir][edge][yuv_format]
|
||||||
{ { {-4, 0, 0, 0},
|
{{{-4, 0, 0, 0}, {-4, -4, -4, 4}, {-4, 4, 4, 8}, {-4, -4, -4, 12}},
|
||||||
{-4,-4,-4, 4},
|
|
||||||
{-4, 4, 4, 8},
|
|
||||||
{-4,-4,-4, 12}},
|
|
||||||
|
|
||||||
{ {-4, 0, 0, 0},
|
{{-4, 0, 0, 0}, {-4, -4, 4, 4}, {-4, 4, 8, 8}, {-4, -4, 12, 12}}};
|
||||||
{-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,
|
||||||
static inline int compare_mvs(const MotionVector *mv0, const MotionVector *mv1, int mvlimit)
|
int mvlimit) {
|
||||||
{
|
return ((iabs(mv0->mv_x - mv1->mv_x) >= 4) |
|
||||||
return ((iabs( mv0->mv_x - mv1->mv_x) >= 4) | (iabs( mv0->mv_y - mv1->mv_y) >= mvlimit));
|
(iabs(mv0->mv_y - mv1->mv_y) >= mvlimit));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "mbuffer.h"
|
#include "mbuffer.h"
|
||||||
|
|
||||||
extern void DeblockPicture(VideoParameters *p_Vid, StorablePicture *p);
|
extern void DeblockPicture(VideoParameters *p_Vid, StorablePicture *p);
|
||||||
extern void DeblockPicturePartially(VideoParameters *p_Vid, StorablePicture *p, int iStart, int iEnd) ;
|
extern void DeblockPicturePartially(VideoParameters *p_Vid, StorablePicture *p,
|
||||||
|
int iStart, int iEnd);
|
||||||
void init_Deblock(VideoParameters *p_Vid, int mb_aff_frame_flag);
|
void init_Deblock(VideoParameters *p_Vid, int mb_aff_frame_flag);
|
||||||
#endif //_LOOPFILTER_H_
|
#endif //_LOOPFILTER_H_
|
||||||
|
|
|
@ -14,73 +14,55 @@
|
||||||
#ifndef _MACROBLOCK_H_
|
#ifndef _MACROBLOCK_H_
|
||||||
#define _MACROBLOCK_H_
|
#define _MACROBLOCK_H_
|
||||||
|
|
||||||
|
#include "block.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "mbuffer.h"
|
#include "mbuffer.h"
|
||||||
#include "block.h"
|
|
||||||
|
|
||||||
//! single scan pattern
|
//! single scan pattern
|
||||||
static const byte SNGL_SCAN[16][2] =
|
static const byte SNGL_SCAN[16][2] = {
|
||||||
{
|
{0, 0}, {1, 0}, {0, 1}, {0, 2}, {1, 1}, {2, 0}, {3, 0}, {2, 1},
|
||||||
{0,0},{1,0},{0,1},{0,2},
|
{1, 2}, {0, 3}, {1, 3}, {2, 2}, {3, 1}, {3, 2}, {2, 3}, {3, 3}};
|
||||||
{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
|
//! field scan pattern
|
||||||
static const byte FIELD_SCAN[16][2] =
|
static const byte FIELD_SCAN[16][2] = {
|
||||||
{
|
{0, 0}, {0, 1}, {1, 0}, {0, 2}, {0, 3}, {1, 1}, {1, 2}, {1, 3},
|
||||||
{0,0},{0,1},{1,0},{0,2},
|
{2, 0}, {2, 1}, {2, 2}, {2, 3}, {3, 0}, {3, 1}, {3, 2}, {3, 3}};
|
||||||
{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
|
//! used to control block sizes : Not used/16x16/16x8/8x16/8x8/8x4/4x8/4x4
|
||||||
static const int BLOCK_STEP[8][2]=
|
static const int BLOCK_STEP[8][2] = {{0, 0}, {4, 4}, {4, 2}, {2, 4},
|
||||||
{
|
{2, 2}, {2, 1}, {1, 2}, {1, 1}};
|
||||||
{0,0},{4,4},{4,2},{2,4},{2,2},{2,1},{1,2},{1,1}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! single scan pattern
|
//! single scan pattern
|
||||||
static const byte SNGL_SCAN8x8[64][2] = {
|
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},
|
{0, 0}, {1, 0}, {0, 1}, {0, 2}, {1, 1}, {2, 0}, {3, 0}, {2, 1},
|
||||||
{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},
|
{1, 2}, {0, 3}, {0, 4}, {1, 3}, {2, 2}, {3, 1}, {4, 0}, {5, 0},
|
||||||
{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},
|
{4, 1}, {3, 2}, {2, 3}, {1, 4}, {0, 5}, {0, 6}, {1, 5}, {2, 4},
|
||||||
{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}
|
{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
|
//! field scan pattern
|
||||||
static const byte FIELD_SCAN8x8[64][2] = { // 8x8
|
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},
|
{0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, {0, 4}, {1, 2},
|
||||||
{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},
|
{2, 0}, {1, 3}, {0, 5}, {0, 6}, {0, 7}, {1, 4}, {2, 1}, {3, 0},
|
||||||
{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},
|
{2, 2}, {1, 5}, {1, 6}, {1, 7}, {2, 3}, {3, 1}, {4, 0}, {3, 2},
|
||||||
{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}
|
{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
|
//! single scan pattern
|
||||||
static const byte SCAN_YUV422[8][2] =
|
static const byte SCAN_YUV422[8][2] = {{0, 0}, {0, 1}, {1, 0}, {0, 2},
|
||||||
{
|
{0, 3}, {1, 1}, {1, 2}, {1, 3}};
|
||||||
{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] =
|
static const unsigned char cbp_blk_chroma[8][4] = {
|
||||||
{ {16, 17, 18, 19},
|
{16, 17, 18, 19}, {20, 21, 22, 23}, {24, 25, 26, 27}, {28, 29, 30, 31},
|
||||||
{20, 21, 22, 23},
|
{32, 33, 34, 35}, {36, 37, 38, 39}, {40, 41, 42, 43}, {44, 45, 46, 47}};
|
||||||
{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] =
|
static const unsigned char cofuv_blk_x[3][8][4] = {{{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},
|
||||||
|
@ -105,12 +87,9 @@ static const unsigned char cofuv_blk_x[3][8][4] =
|
||||||
{0, 1, 0, 1},
|
{0, 1, 0, 1},
|
||||||
{2, 3, 2, 3},
|
{2, 3, 2, 3},
|
||||||
{0, 1, 0, 1},
|
{0, 1, 0, 1},
|
||||||
{2, 3, 2, 3} }
|
{2, 3, 2, 3}}};
|
||||||
};
|
|
||||||
|
|
||||||
static const unsigned char cofuv_blk_y[3][8][4] =
|
static const unsigned char cofuv_blk_y[3][8][4] = {{{0, 0, 1, 1},
|
||||||
{
|
|
||||||
{ { 0, 0, 1, 1},
|
|
||||||
{0, 0, 1, 1},
|
{0, 0, 1, 1},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
|
@ -135,18 +114,16 @@ static const unsigned char cofuv_blk_y[3][8][4] =
|
||||||
{0, 0, 1, 1},
|
{0, 0, 1, 1},
|
||||||
{0, 0, 1, 1},
|
{0, 0, 1, 1},
|
||||||
{2, 2, 3, 3},
|
{2, 2, 3, 3},
|
||||||
{ 2, 2, 3, 3}}
|
{2, 2, 3, 3}}};
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
extern void setup_slice_methods(Slice *currSlice);
|
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 get_neighbors(Macroblock *currMB, PixelPos *block, int mb_x,
|
||||||
|
int mb_y, int blockshape_x);
|
||||||
|
|
||||||
extern void start_macroblock(Slice *currSlice, Macroblock **currMB);
|
extern void start_macroblock(Slice *currSlice, Macroblock **currMB);
|
||||||
extern int decode_one_macroblock(Macroblock *currMB, StorablePicture *dec_picture);
|
extern int decode_one_macroblock(Macroblock *currMB,
|
||||||
|
StorablePicture *dec_picture);
|
||||||
extern Boolean exit_macroblock(Slice *currSlice, int eos_bit);
|
extern Boolean exit_macroblock(Slice *currSlice, int eos_bit);
|
||||||
extern void update_qp(Macroblock *currMB, int qp);
|
extern void update_qp(Macroblock *currMB, int qp);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
* Functions for macroblock neighborhoods
|
* Functions for macroblock neighborhoods
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Karsten Sühring <suehring@hhi.de>
|
||||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
|
@ -18,14 +19,18 @@
|
||||||
|
|
||||||
extern void CheckAvailabilityOfNeighbors(Macroblock *currMB);
|
extern void CheckAvailabilityOfNeighbors(Macroblock *currMB);
|
||||||
|
|
||||||
extern void getAffNeighbour (Macroblock *currMB, int xN, int yN, int mb_size[2], PixelPos *pix);
|
extern void getAffNeighbour(Macroblock *currMB, int xN, int yN, int mb_size[2],
|
||||||
extern void getNonAffNeighbour (Macroblock *currMB, int xN, int yN, int mb_size[2], PixelPos *pix);
|
PixelPos *pix);
|
||||||
extern void get4x4Neighbour (Macroblock *currMB, int xN, int yN, int mb_size[2], PixelPos *pix);
|
extern void getNonAffNeighbour(Macroblock *currMB, int xN, int yN,
|
||||||
extern void get4x4NeighbourBase (Macroblock *currMB, int block_x, int block_y, int mb_size[2], PixelPos *pix);
|
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 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_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_normal(int mb_addr, short *x, short *y);
|
||||||
extern void get_mb_block_pos_mbaff(int mb_addr, short *x, short *y);
|
extern void get_mb_block_pos_mbaff(int mb_addr, short *x, short *y);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
* Functions for macroblock prediction
|
* Functions for macroblock prediction
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -15,21 +16,39 @@
|
||||||
#ifndef _MB_PREDICTION_H_
|
#ifndef _MB_PREDICTION_H_
|
||||||
#define _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_intra4x4(Macroblock *currMB, ColorPlane curr_plane,
|
||||||
extern int mb_pred_intra16x16 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
imgpel **currImg, StorablePicture *dec_picture);
|
||||||
extern int mb_pred_intra8x8 (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_skip(Macroblock *currMB, ColorPlane curr_plane,
|
||||||
extern int mb_pred_sp_skip (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
imgpel **currImg, StorablePicture *dec_picture);
|
||||||
extern int mb_pred_p_inter8x8 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
extern int mb_pred_sp_skip(Macroblock *currMB, ColorPlane curr_plane,
|
||||||
extern int mb_pred_p_inter16x16 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
StorablePicture *dec_picture);
|
||||||
extern int mb_pred_p_inter16x8 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
extern int mb_pred_p_inter8x8(Macroblock *currMB, ColorPlane curr_plane,
|
||||||
extern int mb_pred_p_inter8x16 (Macroblock *currMB, ColorPlane curr_plane, StorablePicture *dec_picture);
|
StorablePicture *dec_picture);
|
||||||
extern int mb_pred_b_d4x4spatial (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
extern int mb_pred_p_inter16x16(Macroblock *currMB, ColorPlane curr_plane,
|
||||||
extern int mb_pred_b_d8x8spatial (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
StorablePicture *dec_picture);
|
||||||
extern int mb_pred_b_d4x4temporal(Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
extern int mb_pred_p_inter16x8(Macroblock *currMB, ColorPlane curr_plane,
|
||||||
extern int mb_pred_b_d8x8temporal(Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture);
|
StorablePicture *dec_picture);
|
||||||
extern int mb_pred_b_inter8x8 (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_ipcm(Macroblock *currMB);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
* Frame buffer functions
|
* Frame buffer functions
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Karsten Sühring <suehring@hhi.de>
|
||||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
|
|
||||||
|
@ -26,25 +27,23 @@
|
||||||
|
|
||||||
#define MAX_LIST_SIZE 33
|
#define MAX_LIST_SIZE 33
|
||||||
//! definition of pic motion parameters
|
//! definition of pic motion parameters
|
||||||
typedef struct pic_motion_params_old
|
typedef struct pic_motion_params_old {
|
||||||
{
|
|
||||||
byte *mb_field; //!< field macroblock indicator
|
byte *mb_field; //!< field macroblock indicator
|
||||||
|
|
||||||
} PicMotionParamsOld;
|
} PicMotionParamsOld;
|
||||||
|
|
||||||
//! definition of pic motion parameters
|
//! definition of pic motion parameters
|
||||||
typedef struct pic_motion_params
|
typedef struct pic_motion_params {
|
||||||
{
|
|
||||||
struct storable_picture *ref_pic[2]; //!< referrence picture pointer
|
struct storable_picture *ref_pic[2]; //!< referrence picture pointer
|
||||||
MotionVector mv[2]; //!< motion vector
|
MotionVector mv[2]; //!< motion vector
|
||||||
signed char ref_idx[2]; //!< reference picture [list][subblock_y][subblock_x]
|
signed char ref_idx[2]; //!< reference picture [list][subblock_y][subblock_x]
|
||||||
// byte mb_field; //!< field macroblock indicator
|
// byte mb_field; //!< field macroblock indicator
|
||||||
//byte field_frame; //!< indicates if co_located is field or frame. Will be removed at some point
|
// byte field_frame; //!< indicates if co_located is field
|
||||||
|
// or frame. Will be removed at some point
|
||||||
} PicMotionParams;
|
} PicMotionParams;
|
||||||
|
|
||||||
//! definition a picture (field or frame)
|
//! definition a picture (field or frame)
|
||||||
typedef struct storable_picture
|
typedef struct storable_picture {
|
||||||
{
|
|
||||||
PictureStructure structure;
|
PictureStructure structure;
|
||||||
|
|
||||||
int poc;
|
int poc;
|
||||||
|
@ -75,23 +74,25 @@ typedef struct storable_picture
|
||||||
int iLumaPadY, iLumaPadX;
|
int iLumaPadY, iLumaPadX;
|
||||||
int iChromaPadY, iChromaPadX;
|
int iChromaPadY, iChromaPadX;
|
||||||
|
|
||||||
|
|
||||||
imgpel **imgY; //!< Y picture component
|
imgpel **imgY; //!< Y picture component
|
||||||
imgpel ***imgUV; //!< U and V picture components
|
imgpel ***imgUV; //!< U and V picture components
|
||||||
imgpel ***img_comp; //!< Y,U, and V components
|
imgpel ***img_comp; //!< Y,U, and V components
|
||||||
|
|
||||||
|
|
||||||
struct pic_motion_params **mv_info; //!< Motion info
|
struct pic_motion_params **mv_info; //!< Motion info
|
||||||
struct pic_motion_params **JVmv_info[MAX_PLANE]; //!< 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 motion; //!< Motion info
|
||||||
struct pic_motion_params_old JVmotion[MAX_PLANE]; //!< Motion info for 4:4:4 independent mode decoding
|
struct pic_motion_params_old
|
||||||
|
JVmotion[MAX_PLANE]; //!< Motion info for 4:4:4 independent mode decoding
|
||||||
|
|
||||||
short **slice_id; //!< reference picture [mb_x][mb_y]
|
short **slice_id; //!< reference picture [mb_x][mb_y]
|
||||||
|
|
||||||
struct storable_picture *top_field; // for mb aff, if frame for referencing the top field
|
struct storable_picture
|
||||||
struct storable_picture *bottom_field; // for mb aff, if frame for referencing the bottom field
|
*top_field; // for mb aff, if frame for referencing the top field
|
||||||
struct storable_picture *frame; // for mb aff, if field for referencing the combined frame
|
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 slice_type;
|
||||||
int idr_flag;
|
int idr_flag;
|
||||||
|
@ -109,7 +110,9 @@ typedef struct storable_picture
|
||||||
int qp;
|
int qp;
|
||||||
int chroma_qp_offset[2];
|
int chroma_qp_offset[2];
|
||||||
int slice_qp_delta;
|
int slice_qp_delta;
|
||||||
DecRefPicMarking_t *dec_ref_pic_marking_buffer; //!< stores the memory management control operations
|
DecRefPicMarking_t
|
||||||
|
*dec_ref_pic_marking_buffer; //!< stores the memory management control
|
||||||
|
//!< operations
|
||||||
|
|
||||||
// picture error concealment
|
// picture error concealment
|
||||||
int concealed_pic; // indicates if this is a concealed picture
|
int concealed_pic; // indicates if this is a concealed picture
|
||||||
|
@ -140,8 +143,7 @@ typedef struct storable_picture
|
||||||
typedef StorablePicture *StorablePicturePtr;
|
typedef StorablePicture *StorablePicturePtr;
|
||||||
|
|
||||||
//! definition a picture (field or frame)
|
//! definition a picture (field or frame)
|
||||||
typedef struct colocated_params
|
typedef struct colocated_params {
|
||||||
{
|
|
||||||
int mb_adaptive_frame_field_flag;
|
int mb_adaptive_frame_field_flag;
|
||||||
int size_x, size_y;
|
int size_x, size_y;
|
||||||
byte is_long_term;
|
byte is_long_term;
|
||||||
|
@ -149,12 +151,15 @@ typedef struct colocated_params
|
||||||
} ColocatedParams;
|
} ColocatedParams;
|
||||||
|
|
||||||
//! Frame Stores for Decoded Picture Buffer
|
//! Frame Stores for Decoded Picture Buffer
|
||||||
typedef struct frame_store
|
typedef struct frame_store {
|
||||||
{
|
|
||||||
int is_used; //!< 0=empty; 1=top; 2=bottom; 3=both fields (or frame)
|
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_reference; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both
|
||||||
int is_long_term; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
|
//!< 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_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;
|
||||||
|
|
||||||
|
@ -181,10 +186,8 @@ typedef struct frame_store
|
||||||
|
|
||||||
} FrameStore;
|
} FrameStore;
|
||||||
|
|
||||||
|
|
||||||
//! Decoded Picture Buffer
|
//! Decoded Picture Buffer
|
||||||
typedef struct decoded_picture_buffer
|
typedef struct decoded_picture_buffer {
|
||||||
{
|
|
||||||
VideoParameters *p_Vid;
|
VideoParameters *p_Vid;
|
||||||
InputParameters *p_Inp;
|
InputParameters *p_Inp;
|
||||||
FrameStore **fs;
|
FrameStore **fs;
|
||||||
|
@ -213,22 +216,25 @@ extern void re_init_dpb(VideoParameters *p_Vid, DecodedPictureBuffe
|
||||||
extern void free_dpb(DecodedPictureBuffer *p_Dpb);
|
extern void free_dpb(DecodedPictureBuffer *p_Dpb);
|
||||||
extern FrameStore *alloc_frame_store(void);
|
extern FrameStore *alloc_frame_store(void);
|
||||||
extern void free_frame_store(FrameStore *f);
|
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 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 free_storable_picture(StorablePicture *p);
|
||||||
extern void store_picture_in_dpb(DecodedPictureBuffer *p_Dpb, StorablePicture* p);
|
extern void store_picture_in_dpb(DecodedPictureBuffer *p_Dpb,
|
||||||
extern StorablePicture* get_short_term_pic (DecodedPictureBuffer *p_Dpb, int picNum);
|
StorablePicture *p);
|
||||||
extern StorablePicture* get_long_term_pic (DecodedPictureBuffer *p_Dpb, int LongtermPicNum);
|
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)
|
#if (MVC_EXTENSION_ENABLE)
|
||||||
extern void flush_dpb(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 int GetMaxDecFrameBuffering(VideoParameters *p_Vid);
|
||||||
extern void append_interview_list(DecodedPictureBuffer *p_Dpb,
|
extern void append_interview_list(DecodedPictureBuffer *p_Dpb,
|
||||||
PictureStructure currPicStructure,
|
PictureStructure currPicStructure,
|
||||||
int list_idx,
|
int list_idx, FrameStore **list,
|
||||||
FrameStore **list,
|
int *listXsize, int currPOC, int curr_view_id,
|
||||||
int *listXsize,
|
|
||||||
int currPOC,
|
|
||||||
int curr_view_id,
|
|
||||||
int anchor_pic_flag);
|
int anchor_pic_flag);
|
||||||
extern void update_ref_list(DecodedPictureBuffer *p_Dpb, int curr_view_id);
|
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 update_ltref_list(DecodedPictureBuffer *p_Dpb, int curr_view_id);
|
||||||
|
@ -255,11 +261,13 @@ 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,
|
||||||
extern void pad_dec_picture(VideoParameters *p_Vid, StorablePicture *dec_picture);
|
int iPadX, int iPadY);
|
||||||
extern void pad_buf(imgpel *pImgBuf, int iWidth, int iHeight, int iStride, int iPadX, int iPadY);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
* MVC Frame buffer functions
|
* MVC Frame buffer functions
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Athanasios Leontaris <aleon@dolby.com>
|
||||||
* - Karsten Sühring <suehring@hhi.de>
|
* - Karsten Sühring <suehring@hhi.de>
|
||||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
|
@ -27,12 +28,18 @@ extern void init_lists_p_slice_mvc(Slice *currSlice);
|
||||||
extern void init_lists_b_slice_mvc(Slice *currSlice);
|
extern void init_lists_b_slice_mvc(Slice *currSlice);
|
||||||
extern void init_lists_i_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,
|
extern void reorder_ref_pic_list_mvc(Slice *currSlice, int cur_list,
|
||||||
int view_id, int anchor_pic_flag, int currPOC, int listidx);
|
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_short_term(Slice *currSlice, int cur_list,
|
||||||
extern void reorder_long_term(Slice *currSlice, StorablePicture **RefPicListX, int num_ref_idx_lX_active_minus1, int LongTermPicNum, int *refIdxLX, int currViewID);
|
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
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,19 @@
|
||||||
extern int allocate_pred_mem(Slice *currSlice);
|
extern int allocate_pred_mem(Slice *currSlice);
|
||||||
extern void free_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,
|
extern void get_block_luma(StorablePicture *curr_ref, int x_pos, int y_pos,
|
||||||
int shift_x,int maxold_x,int maxold_y,int **tmp_res,int max_imgpel_value,imgpel no_ref_value,Macroblock *currMB);
|
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 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 prepare_direct_params(Macroblock *currMB,
|
||||||
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);
|
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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
* Memory allocation and free helper funtions
|
* Memory allocation and free helper funtions
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Karsten Sühring <suehring@hhi.de>
|
||||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
*
|
*
|
||||||
|
@ -17,31 +18,40 @@
|
||||||
#ifndef _MEMALLOC_H_
|
#ifndef _MEMALLOC_H_
|
||||||
#define _MEMALLOC_H_
|
#define _MEMALLOC_H_
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "mbuffer.h"
|
|
||||||
#include "distortion.h"
|
#include "distortion.h"
|
||||||
|
#include "global.h"
|
||||||
#include "lagrangian.h"
|
#include "lagrangian.h"
|
||||||
|
#include "mbuffer.h"
|
||||||
#include "quant_params.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_mem2Dlm(LambdaParams ***array2D, int dim0, int dim1);
|
||||||
extern int get_mem2Dolm (LambdaParams ***array2D, int dim0, int dim1, int offset);
|
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_mem2Dmp(PicMotionParams ***array2D, int dim0, int dim1);
|
||||||
extern int get_mem3Dmp (PicMotionParams ****array3D, int dim0, int dim1, int dim2);
|
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_mem2Dquant(LevelQuantParams ***array2D, int dim0, int dim1);
|
||||||
extern int get_mem3Dquant(LevelQuantParams ****array3D, int dim0, int dim1, int dim2);
|
extern int get_mem3Dquant(LevelQuantParams ****array3D, int dim0, int dim1,
|
||||||
extern int get_mem4Dquant(LevelQuantParams *****array4D, int dim0, int dim1, int dim2, int dim3);
|
int dim2);
|
||||||
extern int get_mem5Dquant(LevelQuantParams ******array5D, int dim0, int dim1, int dim2, int dim3, int dim4);
|
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_mem2Dmv(MotionVector ***array2D, int dim0, int dim1);
|
||||||
extern int get_mem3Dmv(MotionVector ****array3D, int dim0, int dim1, int dim2);
|
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_mem4Dmv(MotionVector *****array4D, int dim0, int dim1, int dim2,
|
||||||
extern int get_mem5Dmv (MotionVector ******array5D, int dim0, int dim1, int dim2, int dim3, int dim4);
|
int dim3);
|
||||||
extern int get_mem6Dmv (MotionVector *******array6D, int dim0, int dim1, int dim2, int dim3, int dim4, int dim5);
|
extern int get_mem5Dmv(MotionVector ******array5D, int dim0, int dim1, int dim2,
|
||||||
extern int get_mem7Dmv (MotionVector ********array7D, int dim0, int dim1, int dim2, int dim3, int dim4, int dim5, int dim6);
|
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 byte **new_mem2D(int dim0, int dim1);
|
||||||
extern int get_mem2D(byte ***array2D, int dim0, int dim1);
|
extern int get_mem2D(byte ***array2D, int dim0, int dim1);
|
||||||
|
@ -50,54 +60,81 @@ extern int get_mem4D(byte *****array4D, int dim0, int dim1, int dim2, int dim3)
|
||||||
|
|
||||||
extern int **new_mem2Dint(int dim0, int dim1);
|
extern int **new_mem2Dint(int dim0, int dim1);
|
||||||
extern int get_mem2Dint(int ***array2D, int rows, int columns);
|
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_mem2DintWithPad(int ***array2D, int dim0, int dim1, int iPadY,
|
||||||
|
int iPadX);
|
||||||
extern int get_mem2Dint64(int64 ***array2D, int rows, int columns);
|
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_mem3Dint(int ****array3D, int frames, int rows, int columns);
|
||||||
extern int get_mem3Dint64(int64 ****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_mem4Dint(int *****array4D, int idx, int frames, int rows,
|
||||||
extern int get_mem4Dint64(int64 *****array4D, int idx, int frames, int rows, int columns );
|
int columns);
|
||||||
extern int get_mem5Dint(int ******array5D, int refs, int blocktype, int rows, int columns, int component);
|
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_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_mem2Ddistblk(distblk ***array2D, int rows, int columns);
|
||||||
extern int get_mem3Ddistblk(distblk ****array3D, int frames, int rows, int columns);
|
extern int get_mem3Ddistblk(distblk ****array3D, int frames, int rows,
|
||||||
extern int get_mem4Ddistblk(distblk *****array4D, int idx, int frames, int rows, int columns );
|
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_mem2Dshort(short ***array2D, int dim0, int dim1);
|
||||||
extern int get_mem3Dshort(short ****array3D, int dim0, int dim1, int dim2);
|
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_mem4Dshort(short *****array4D, int dim0, int dim1, int dim2,
|
||||||
extern int get_mem5Dshort(short ******array5D, int dim0, int dim1, int dim2, int dim3, int dim4);
|
int dim3);
|
||||||
extern int get_mem6Dshort(short *******array6D, int dim0, int dim1, int dim2, int dim3, int dim4, int dim5);
|
extern int get_mem5Dshort(short ******array5D, int dim0, int dim1, int dim2,
|
||||||
extern int get_mem7Dshort(short ********array7D, int dim0, int dim1, int dim2, int dim3, int dim4, int dim5, int dim6);
|
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_mem1Dpel(imgpel **array2D, int rows);
|
||||||
extern int get_mem2Dpel(imgpel ***array2D, int rows, int columns);
|
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_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_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_mem3DpelWithPad(imgpel ****array3D, int dim0, int dim1, int dim2,
|
||||||
extern int get_mem3DpelWithPadSeparately(imgpel ****array3D, int dim0, int dim1, int dim2, int iPadY, int iPadX);
|
int iPadY, int iPadX);
|
||||||
extern int get_mem4Dpel(imgpel *****array4D, int sub_x, int sub_y, int rows, int columns);
|
extern int get_mem3DpelWithPadSeparately(imgpel ****array3D, int dim0, int dim1,
|
||||||
extern int get_mem4DpelWithPad(imgpel *****array4D, int sub_x, int sub_y, int rows, int columns, int iPadY, int iPadX);
|
int dim2, 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_mem4Dpel(imgpel *****array4D, int sub_x, int sub_y, int rows,
|
||||||
extern int get_mem5Dpel(imgpel ******array5D, int dims, int sub_x, int sub_y, int rows, int columns);
|
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_mem4DpelWithPad(imgpel *****array4D, int sub_x, int sub_y,
|
||||||
extern int get_mem5DpelWithPadSeparately(imgpel ******array5D, int dim0, int dim1, int dim2, int dim3, int dim4, int iPadY, int iPadX);
|
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_mem2Ddouble(double ***array2D, int rows, int columns);
|
||||||
|
|
||||||
extern int get_mem1Dodouble(double **array1D, int dim0, 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_mem2Dodouble(double ***array2D, int rows, int columns,
|
||||||
extern int get_mem3Dodouble(double ****array2D, int rows, int columns, int pels, int offset);
|
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_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_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);
|
||||||
|
|
||||||
|
@ -120,7 +157,8 @@ extern void free_mem6Dmv (MotionVector ******array2D);
|
||||||
extern void free_mem7Dmv(MotionVector *******array7D);
|
extern void free_mem7Dmv(MotionVector *******array7D);
|
||||||
|
|
||||||
extern int get_mem2D_spp(StorablePicturePtr ***array3D, int dim0, int dim1);
|
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_mem3D_spp(StorablePicturePtr ****array3D, int dim0, int dim1,
|
||||||
|
int dim2);
|
||||||
|
|
||||||
extern void free_mem2D_spp(StorablePicturePtr **array2D);
|
extern void free_mem2D_spp(StorablePicturePtr **array2D);
|
||||||
extern void free_mem3D_spp(StorablePicturePtr ***array2D);
|
extern void free_mem3D_spp(StorablePicturePtr ***array2D);
|
||||||
|
@ -158,23 +196,28 @@ extern void free_mem2Dpel (imgpel **array2D);
|
||||||
extern void free_mem2DpelWithPad(imgpel **array2D, int iPadY, int iPadX);
|
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_mem3DpelWithPad(imgpel ***array3D, int iPadY, int iPadX);
|
||||||
extern void free_mem3DpelWithPadSeparately(imgpel ***array3D, int iDim12, 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_mem4Dpel(imgpel ****array4D);
|
||||||
extern void free_mem4DpelWithPad(imgpel ****array4D, int iPadY, int iPadX);
|
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_mem4DpelWithPadSeparately(imgpel ****array4D, int iFrames,
|
||||||
|
int iPadY, int iPadX);
|
||||||
extern void free_mem5Dpel(imgpel *****array5D);
|
extern void free_mem5Dpel(imgpel *****array5D);
|
||||||
extern void free_mem5DpelWithPad(imgpel *****array5D, int iPadY, int iPadX);
|
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_mem2Ddouble(double **array2D);
|
||||||
extern void free_mem3Ddouble(double ***array3D);
|
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_mem2Dodouble(double **array2D, int offset);
|
||||||
extern void free_mem3Dodouble(double ***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_mem2Doint(int **array2D, int offset);
|
||||||
extern void free_mem3Doint(int ***array3D, int rows, int columns, 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 free_top_bot_planes(imgpel **imgTopField, imgpel **imgBotField);
|
||||||
|
|
||||||
extern void no_mem_exit(char *where);
|
extern void no_mem_exit(char *where);
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* Declarations for Motion Vector Prediction
|
* Declarations for Motion Vector Prediction
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -14,6 +15,7 @@
|
||||||
#ifndef _MV_PREDICTION_H_
|
#ifndef _MV_PREDICTION_H_
|
||||||
#define _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
|
#endif
|
||||||
|
|
|
@ -8,19 +8,18 @@
|
||||||
*
|
*
|
||||||
* \date 25 November 2002
|
* \date 25 November 2002
|
||||||
* \author
|
* \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>
|
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||||
***************************************************************************************
|
***************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _NALU_H_
|
#ifndef _NALU_H_
|
||||||
#define _NALU_H_
|
#define _NALU_H_
|
||||||
|
|
||||||
#include "nalucommon.h"
|
#include "nalucommon.h"
|
||||||
|
|
||||||
typedef struct sBitsFile
|
typedef struct sBitsFile {
|
||||||
{
|
|
||||||
void (*OpenBitsFile)(VideoParameters *p_Vid, char *filename);
|
void (*OpenBitsFile)(VideoParameters *p_Vid, char *filename);
|
||||||
void (*CloseBitsFile)(VideoParameters *p_Vid);
|
void (*CloseBitsFile)(VideoParameters *p_Vid);
|
||||||
int (*GetNALU)(VideoParameters *p_Vid, NALU_t *nalu);
|
int (*GetNALU)(VideoParameters *p_Vid, NALU_t *nalu);
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* \brief
|
* \brief
|
||||||
* NALU handling common to encoder and decoder
|
* NALU handling common to encoder and decoder
|
||||||
* \author
|
* \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>
|
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||||
* - Karsten Suehring <suehring@hhi.de>
|
* - Karsten Suehring <suehring@hhi.de>
|
||||||
***************************************************************************************
|
***************************************************************************************
|
||||||
|
@ -51,10 +52,11 @@ typedef enum {
|
||||||
} NalRefIdc;
|
} NalRefIdc;
|
||||||
|
|
||||||
//! NAL unit structure
|
//! NAL unit structure
|
||||||
typedef struct nalu_t
|
typedef struct nalu_t {
|
||||||
{
|
int startcodeprefix_len; //!< 4 for parameter sets and first slice in picture,
|
||||||
int startcodeprefix_len; //!< 4 for parameter sets and first slice in picture, 3 for everything else (suggested)
|
//!< 3 for everything else (suggested)
|
||||||
unsigned len; //!< Length of the NAL unit (Excluding the start code, which does not belong to the NALU)
|
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
|
unsigned max_size; //!< NAL Unit Buffer size
|
||||||
int forbidden_bit; //!< should be always FALSE
|
int forbidden_bit; //!< should be always FALSE
|
||||||
NaluType nal_unit_type; //!< NALU_TYPE_xxxx
|
NaluType nal_unit_type; //!< NALU_TYPE_xxxx
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* \brief
|
* \brief
|
||||||
* Picture writing routine headers
|
* Picture writing routine headers
|
||||||
* \author
|
* \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>
|
* - Karsten Suehring <suehring@hhi.de>
|
||||||
***************************************************************************************
|
***************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -14,9 +15,10 @@
|
||||||
#ifndef _OUTPUT_H_
|
#ifndef _OUTPUT_H_
|
||||||
#define _OUTPUT_H_
|
#define _OUTPUT_H_
|
||||||
|
|
||||||
|
extern void write_stored_frame(VideoParameters *p_Vid, FrameStore *fs,
|
||||||
extern void write_stored_frame(VideoParameters *p_Vid, FrameStore *fs, int p_out);
|
int p_out);
|
||||||
extern void direct_output (VideoParameters *p_Vid, StorablePicture *p, 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 init_out_buffer(VideoParameters *p_Vid);
|
||||||
extern void uninit_out_buffer(VideoParameters *p_Vid);
|
extern void uninit_out_buffer(VideoParameters *p_Vid);
|
||||||
#if (PAIR_FIELDS_IN_OUTPUT)
|
#if (PAIR_FIELDS_IN_OUTPUT)
|
||||||
|
|
|
@ -14,68 +14,82 @@
|
||||||
#define _PARAMS_H_
|
#define _PARAMS_H_
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "types.h"
|
|
||||||
#include "vui_params.h"
|
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
#include "io_video.h"
|
#include "io_video.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "vui_params.h"
|
||||||
|
|
||||||
//! all input parameters
|
//! all input parameters
|
||||||
struct inp_par_enc
|
struct inp_par_enc {
|
||||||
{
|
|
||||||
int ProfileIDC; //!< value of syntax element profile_idc
|
int ProfileIDC; //!< value of syntax element profile_idc
|
||||||
int LevelIDC; //!< value of syntax element level_idc
|
int LevelIDC; //!< value of syntax element level_idc
|
||||||
int IntraProfile; //!< Enable Intra profiles
|
int IntraProfile; //!< Enable Intra profiles
|
||||||
|
|
||||||
int no_frames; //!< number of frames to be encoded
|
int no_frames; //!< number of frames to be encoded
|
||||||
int qp[NUM_SLICE_TYPES]; //!< QP values for all slice types
|
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 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 qp2off[NUM_SLICE_TYPES]; //!< Change QP offset values for all slice types
|
||||||
int qpsp; //!< QPSP quantization value
|
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 frame_skip; //!< number of frames to skip in input sequence (e.g 2 takes
|
||||||
int jumpd; /*!< number of frames to skip in input sequence including intermediate pictures
|
//!< frame 0,3,6,9...)
|
||||||
(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 DisableSubpelME; //!< Disable sub-pixel motion estimation
|
||||||
int search_range; /*!< search range - integer pel search and 16x16 blocks. The search window is
|
int search_range; /*!< search range - integer pel search and 16x16 blocks. The
|
||||||
generally around the predicted vector. Max vector is 2xmcrange. */
|
search window is generally around the predicted vector.
|
||||||
|
Max vector is 2xmcrange. */
|
||||||
int num_ref_frames; //!< number of reference frames to be used
|
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 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_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 B_List1_refs; //!< number of reference picture in list 1 in B pictures
|
||||||
int Log2MaxFNumMinus4; //!< value of syntax element log2_max_frame_num
|
int Log2MaxFNumMinus4; //!< value of syntax element log2_max_frame_num
|
||||||
int Log2MaxPOCLsbMinus4; //!< value of syntax element log2_max_pic_order_cnt_lsb_minus4
|
int Log2MaxPOCLsbMinus4; //!< value of syntax element
|
||||||
|
//!< log2_max_pic_order_cnt_lsb_minus4
|
||||||
|
|
||||||
// Input/output sequence format related variables
|
// Input/output sequence format related variables
|
||||||
FrameFormat source; //!< source related information
|
FrameFormat source; //!< source related information
|
||||||
FrameFormat output; //!< output related information
|
FrameFormat output; //!< output related information
|
||||||
int is_interleaved;
|
int is_interleaved;
|
||||||
int src_resize; //!< Control if input sequence will be resized (currently only cropping is supported)
|
int src_resize; //!< Control if input sequence will be resized (currently only
|
||||||
int src_BitDepthRescale; //!< Control if input sequence bitdepth should be adjusted
|
//!< 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 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
|
int intra_upd; /*!< For error robustness. 0: no special action. 1: One
|
||||||
as regular 'update'. 2: One GOB every 2 frames is intra coded etc.
|
GOB/frame is intra coded as regular 'update'. 2: One GOB
|
||||||
In connection with this intra update, restrictions is put on motion vectors
|
every 2 frames is intra coded etc. In connection with this
|
||||||
to prevent errors to propagate from the past */
|
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_mode; //!< Indicate what algorithm to use for setting slices
|
||||||
int slice_argument; //!< Argument to the specified slice algorithm
|
int slice_argument; //!< Argument to the specified slice algorithm
|
||||||
int UseConstrainedIntraPred; //!< 0: Inter MB pixels are allowed for intra prediction 1: Not allowed
|
int UseConstrainedIntraPred; //!< 0: Inter MB pixels are allowed for intra
|
||||||
int SetFirstAsLongTerm; //!< Support for temporal considerations for CB plus encoding
|
//!< prediction 1: Not allowed
|
||||||
int infile_header; //!< If input file has a header set this to the length of the header
|
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;
|
int MultiSourceData;
|
||||||
VideoDataFile input_file2; //!< Input video file2
|
VideoDataFile input_file2; //!< Input video file2
|
||||||
VideoDataFile input_file3; //!< Input video file3
|
VideoDataFile input_file3; //!< Input video file3
|
||||||
#if (MVC_EXTENSION_ENABLE)
|
#if (MVC_EXTENSION_ENABLE)
|
||||||
int num_of_views; //!< number of views to encode (1=1view, 2=2views)
|
int num_of_views; //!< number of views to encode (1=1view, 2=2views)
|
||||||
int MVCInterViewReorder; //!< Reorder References according to interview pictures
|
int MVCInterViewReorder; //!< Reorder References according to interview
|
||||||
int MVCFlipViews; //!< Reverse the order of the views in the bitstream (view 1 has VOIdx 0 and view 1 has VOIdx 0)
|
//!< 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 MVCInterViewForceB; //!< Force B slices for enhancement layer
|
||||||
int View1QPOffset; //!< QP offset during rate control for View 1
|
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 enable_inter_view_flag; //!< Enables inter_view_flag (allows pictures that
|
||||||
|
//!< are to be used for inter-view only
|
||||||
|
//!< prediction)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VideoDataFile input_file1; //!< Input video file1
|
VideoDataFile input_file1; //!< Input video file1
|
||||||
signed char outfile[FILE_NAME_SIZE]; //!< H.264 compressed output bitstream
|
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 ReconFile[FILE_NAME_SIZE]; //!< Reconstructed Pictures (view 0 for
|
||||||
|
//!< MVC profile)
|
||||||
signed char ReconFile2[FILE_NAME_SIZE]; //!< Reconstructed Pictures (view 1)
|
signed char ReconFile2[FILE_NAME_SIZE]; //!< Reconstructed Pictures (view 1)
|
||||||
|
|
||||||
signed char TraceFile[FILE_NAME_SIZE]; //!< Trace Outputs
|
signed char TraceFile[FILE_NAME_SIZE]; //!< Trace Outputs
|
||||||
|
@ -83,8 +97,10 @@ struct inp_par_enc
|
||||||
signed char QmatrixFile[FILE_NAME_SIZE]; //!< Q matrix cfg file
|
signed char QmatrixFile[FILE_NAME_SIZE]; //!< Q matrix cfg file
|
||||||
int ProcessInput; //!< Filter Input Sequence
|
int ProcessInput; //!< Filter Input Sequence
|
||||||
int EnableOpenGOP; //!< support for open gops.
|
int EnableOpenGOP; //!< support for open gops.
|
||||||
int EnableIDRGOP; //!< support for IDR closed gops with no shared B coded pictures.
|
int EnableIDRGOP; //!< support for IDR closed gops with no shared B coded
|
||||||
int grayscale; //!< encode in grayscale (Currently only works for 8 bit, YUV 420)
|
//!< pictures.
|
||||||
|
int grayscale; //!< encode in grayscale (Currently only works for 8 bit, YUV
|
||||||
|
//!< 420)
|
||||||
|
|
||||||
int idr_period; //!< IDR picture period
|
int idr_period; //!< IDR picture period
|
||||||
int intra_period; //!< intra picture period
|
int intra_period; //!< intra picture period
|
||||||
|
@ -110,59 +126,91 @@ struct inp_par_enc
|
||||||
int NumberBFrames; //!< number of B frames that will be used
|
int NumberBFrames; //!< number of B frames that will be used
|
||||||
int PReplaceBSlice;
|
int PReplaceBSlice;
|
||||||
int qpBRSOffset; //!< QP for reference B slice coded pictures
|
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 direct_spatial_mv_pred_flag; //!< Direct Mode type to be used (0:
|
||||||
|
//!< Temporal, 1: Spatial)
|
||||||
int directInferenceFlag; //!< Direct Mode Inference Flag
|
int directInferenceFlag; //!< Direct Mode Inference Flag
|
||||||
|
|
||||||
int BiPredMotionEstimation; //!< Use of Bipredictive motion estimation
|
int BiPredMotionEstimation; //!< Use of Bipredictive motion estimation
|
||||||
int BiPredSearch[4]; //!< Bipredictive motion estimation for modes 16x16, 16x8, 8x16, and 8x8
|
int BiPredSearch[4]; //!< Bipredictive motion estimation for modes 16x16,
|
||||||
int BiPredMERefinements; //!< Max number of Iterations for Bi-predictive motion estimation
|
//!< 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 BiPredMESearchRange; //!< Search range of Bi-predictive motion estimation
|
||||||
int BiPredMESubPel; //!< Use of subpixel refinement for Bi-predictive motion estimation
|
int BiPredMESubPel; //!< Use of subpixel refinement for Bi-predictive motion
|
||||||
|
//!< estimation
|
||||||
|
|
||||||
// SP/SI Pictures
|
// SP/SI Pictures
|
||||||
int sp_periodicity; //!< The periodicity of SP-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 sp_switch_period; //!< Switch period (in terms of switching SP/SI frames)
|
||||||
int si_frame_indicator; //!< Flag indicating whether SI frames should be encoded rather than SP frames (0: not used, 1: used)
|
//!< between bitstream 1 and bitstream 2
|
||||||
int sp2_frame_indicator; //!< Flag indicating whether switching SP frames should be encoded rather than SP frames (0: not used, 1: used)
|
int si_frame_indicator; //!< Flag indicating whether SI frames should be
|
||||||
int sp_output_indicator; //!< Flag indicating whether coefficients are output to allow future encoding of switchin SP frames (0: not used, 1: used)
|
//!< encoded rather than SP frames (0: not used, 1:
|
||||||
signed char sp_output_filename[FILE_NAME_SIZE]; //!<Filename where SP coefficients are output
|
//!< used)
|
||||||
signed char sp2_input_filename1[FILE_NAME_SIZE]; //!<Filename of coefficients of the first bitstream when encoding SP frames to switch bitstreams
|
int sp2_frame_indicator; //!< Flag indicating whether switching SP frames
|
||||||
signed char sp2_input_filename2[FILE_NAME_SIZE]; //!<Filenames of coefficients of the second bitstream when encoding SP frames to switch bitstreams
|
//!< 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
|
// Weighted Prediction
|
||||||
int WeightedPrediction; //!< Weighted prediction for P frames (0: not used, 1: explicit)
|
int WeightedPrediction; //!< Weighted prediction for P frames (0: not used, 1:
|
||||||
int WeightedBiprediction; //!< Weighted prediction for B frames (0: not used, 1: explicit, 2: implicit)
|
//!< explicit)
|
||||||
|
int WeightedBiprediction; //!< Weighted prediction for B frames (0: not used,
|
||||||
|
//!< 1: explicit, 2: implicit)
|
||||||
int WPMethod; //!< WP method (0: DC, 1: LMS)
|
int WPMethod; //!< WP method (0: DC, 1: LMS)
|
||||||
int WPIterMC; //!< Iterative WP method
|
int WPIterMC; //!< Iterative WP method
|
||||||
int WPMCPrecision;
|
int WPMCPrecision;
|
||||||
int WPMCPrecFullRef;
|
int WPMCPrecFullRef;
|
||||||
int WPMCPrecBSlice;
|
int WPMCPrecBSlice;
|
||||||
int EnhancedBWeightSupport;
|
int EnhancedBWeightSupport;
|
||||||
int ChromaWeightSupport; //!< Weighted prediction support for chroma (0: disabled, 1: enabled)
|
int ChromaWeightSupport; //!< Weighted prediction support for chroma (0:
|
||||||
|
//!< disabled, 1: enabled)
|
||||||
int UseWeightedReferenceME; //!< Use Weighted Reference for ME.
|
int UseWeightedReferenceME; //!< Use Weighted Reference for ME.
|
||||||
int RDPictureDecision; //!< Perform RD optimal decision between various coded versions of same picture
|
int RDPictureDecision; //!< Perform RD optimal decision between various coded
|
||||||
|
//!< versions of same picture
|
||||||
int RDPSliceBTest; //!< Tests B slice replacement for P.
|
int RDPSliceBTest; //!< Tests B slice replacement for P.
|
||||||
int RDPSliceITest; //!< Tests I slice replacement for P.
|
int RDPSliceITest; //!< Tests I slice replacement for P.
|
||||||
int RDPictureMaxPassISlice; //!< Max # of coding passes for I-slice
|
int RDPictureMaxPassISlice; //!< Max # of coding passes for I-slice
|
||||||
int RDPictureMaxPassPSlice; //!< Max # of coding passes for P-slice
|
int RDPictureMaxPassPSlice; //!< Max # of coding passes for P-slice
|
||||||
int RDPictureMaxPassBSlice; //!< Max # of coding passes for B-slice
|
int RDPictureMaxPassBSlice; //!< Max # of coding passes for B-slice
|
||||||
int RDPictureDeblocking; //!< Whether to choose between deblocked and non-deblocked picture
|
int RDPictureDeblocking; //!< Whether to choose between deblocked and
|
||||||
int RDPictureDirectMode; //!< Whether to check the other direct mode for B slices
|
//!< non-deblocked picture
|
||||||
int RDPictureFrameQPPSlice; //!< Whether to check additional frame level QP values for P slices
|
int RDPictureDirectMode; //!< Whether to check the other direct mode for B
|
||||||
int RDPictureFrameQPBSlice; //!< Whether to check additional frame level QP values for B slices
|
//!< 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 SkipIntraInInterSlices; //!< Skip intra type checking in inter slices if
|
||||||
int BRefPictures; //!< B coded reference pictures replace P pictures (0: not used, 1: used)
|
//!< best_mode is skip/direct
|
||||||
|
int BRefPictures; //!< B coded reference pictures replace P pictures (0: not
|
||||||
|
//!< used, 1: used)
|
||||||
int HierarchicalCoding;
|
int HierarchicalCoding;
|
||||||
int HierarchyLevelQPEnable;
|
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
|
// explicit sequence information parameters
|
||||||
int ExplicitSeqCoding;
|
int ExplicitSeqCoding;
|
||||||
signed char ExplicitSeqFile[FILE_NAME_SIZE];
|
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 ReferenceReorder; //!< Reordering based on Poc distances
|
||||||
int PocMemoryManagement; //!< Memory management based on Poc distances for hierarchical coding
|
int PocMemoryManagement; //!< Memory management based on Poc distances for
|
||||||
|
//!< hierarchical coding
|
||||||
|
|
||||||
int symbol_mode; //!< Specifies the mode the symbols are mapped on bits
|
int symbol_mode; //!< Specifies the mode the symbols are mapped on bits
|
||||||
int of_mode; //!< Specifies the mode of the output file
|
int of_mode; //!< Specifies the mode of the output file
|
||||||
|
@ -221,12 +269,18 @@ struct inp_par_enc
|
||||||
int IntraBottom; //!< Force Intra Bottom at GOP periods.
|
int IntraBottom; //!< Force Intra Bottom at GOP periods.
|
||||||
|
|
||||||
// Error resilient RDO parameters
|
// 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
|
||||||
double LossRateB; //!< assumed loss probablility of partition B, in per cent, used for loss-aware R/D
|
LossRateA; //!< assumed loss probablility of partition A (or full slice),
|
||||||
double LossRateC; //!< assumed loss probablility of partition C, in per cent, used for loss-aware R/D
|
//!< in per cent, used for loss-aware R/D optimization
|
||||||
int FirstFrameCorrect; //!< the first frame is encoded under the assumption that it is always correctly received.
|
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 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 RestrictRef;
|
||||||
int NumFramesInELSubSeq;
|
int NumFramesInELSubSeq;
|
||||||
|
|
||||||
|
@ -251,11 +305,16 @@ struct inp_par_enc
|
||||||
int SPPercentageThreshold;
|
int SPPercentageThreshold;
|
||||||
|
|
||||||
// FMO
|
// FMO
|
||||||
signed char SliceGroupConfigFileName[FILE_NAME_SIZE]; //!< Filename for config info fot type 0, 2, 6
|
signed char
|
||||||
int num_slice_groups_minus1; //!< "FmoNumSliceGroups" in encoder.cfg, same as FmoNumSliceGroups, which should be erased later
|
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;
|
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;
|
unsigned int *bottom_right;
|
||||||
byte *slice_group_id; //!< slice_group_id is for slice group type being 6
|
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 *run_length_minus1; //!< run_length_minus1 is for slice group type being 0
|
||||||
|
@ -322,15 +381,20 @@ struct inp_par_enc
|
||||||
double LambdaWeight[6];
|
double LambdaWeight[6];
|
||||||
double FixedLambda[6];
|
double FixedLambda[6];
|
||||||
|
|
||||||
signed char QOffsetMatrixFile[FILE_NAME_SIZE]; //!< Quantization Offset matrix cfg file
|
signed char QOffsetMatrixFile[FILE_NAME_SIZE]; //!< Quantization Offset matrix
|
||||||
|
//!< cfg file
|
||||||
int OffsetMatrixPresentFlag; //!< Enable Explicit Quantization Offset Matrices
|
int OffsetMatrixPresentFlag; //!< Enable Explicit Quantization Offset Matrices
|
||||||
|
|
||||||
int AdaptiveRounding; //!< Adaptive Rounding parameter based on JVT-N011
|
int AdaptiveRounding; //!< Adaptive Rounding parameter based on JVT-N011
|
||||||
int AdaptRoundingFixed; //!< Global rounding for all qps
|
int AdaptRoundingFixed; //!< Global rounding for all qps
|
||||||
int AdaptRndPeriod; //!< Set period for adaptive rounding of JVT-N011 in MBs
|
int AdaptRndPeriod; //!< Set period for adaptive rounding of JVT-N011 in MBs
|
||||||
int AdaptRndChroma;
|
int AdaptRndChroma;
|
||||||
int AdaptRndWFactor [2][NUM_SLICE_TYPES]; //!< Weighting factors for luma component based on reference indicator and slice type
|
int AdaptRndWFactor[2][NUM_SLICE_TYPES]; //!< Weighting factors for luma
|
||||||
int AdaptRndCrWFactor[2][NUM_SLICE_TYPES]; //!< Weighting factors for chroma components based on reference indicator and slice type
|
//!< 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
|
// Fidelity Range Extensions
|
||||||
|
@ -349,18 +413,23 @@ struct inp_par_enc
|
||||||
int DispPQPOffset;
|
int DispPQPOffset;
|
||||||
|
|
||||||
// Redundant picture
|
// Redundant picture
|
||||||
int NumRedundantHierarchy; //!< number of entries to allocate redundant pictures in a GOP
|
int NumRedundantHierarchy; //!< number of entries to allocate redundant
|
||||||
|
//!< pictures in a GOP
|
||||||
int PrimaryGOPLength; //!< GOP length of primary pictures
|
int PrimaryGOPLength; //!< GOP length of primary pictures
|
||||||
int NumRefPrimary; //!< number of reference frames for primary picture
|
int NumRefPrimary; //!< number of reference frames for primary picture
|
||||||
|
|
||||||
// tone mapping SEI message
|
// tone mapping SEI message
|
||||||
int ToneMappingSEIPresentFlag;
|
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
|
// prediction structure
|
||||||
int PreferDispOrder; //!< Prefer display order when building the prediction structure as opposed to coding order
|
int PreferDispOrder; //!< Prefer display order when building the prediction
|
||||||
int PreferPowerOfTwo; //!< Prefer prediction structures that have lengths expressed as powers of two
|
//!< structure as opposed to coding order
|
||||||
int FrmStructBufferLength; //!< Number of frames that is populated every time populate_frm_struct is called
|
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;
|
int separate_colour_plane_flag;
|
||||||
double WeightY;
|
double WeightY;
|
||||||
|
@ -386,4 +455,3 @@ struct inp_par_enc
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -8,30 +8,29 @@
|
||||||
*
|
*
|
||||||
* \date 25 November 2002
|
* \date 25 November 2002
|
||||||
* \author
|
* \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>
|
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||||
***************************************************************************************
|
***************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _PARSET_H_
|
#ifndef _PARSET_H_
|
||||||
#define _PARSET_H_
|
#define _PARSET_H_
|
||||||
|
|
||||||
#include "parsetcommon.h"
|
|
||||||
#include "nalucommon.h"
|
#include "nalucommon.h"
|
||||||
|
#include "parsetcommon.h"
|
||||||
|
|
||||||
static const byte ZZ_SCAN[16] =
|
static const byte ZZ_SCAN[16] = {0, 1, 4, 8, 5, 2, 3, 6,
|
||||||
{ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
|
9, 12, 13, 10, 7, 11, 14, 15};
|
||||||
};
|
|
||||||
|
|
||||||
static const byte ZZ_SCAN8[64] =
|
static const byte ZZ_SCAN8[64] = {
|
||||||
{ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
|
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,
|
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,
|
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
|
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 void InitVUI(seq_parameter_set_rbsp_t *sps);
|
||||||
extern int ReadVUI(DataPartition *p, seq_parameter_set_rbsp_t *sps);
|
extern int ReadVUI(DataPartition *p, seq_parameter_set_rbsp_t *sps);
|
||||||
|
@ -40,8 +39,10 @@ extern int ReadHRDParameters(DataPartition *p, hrd_parameters_t *hrd);
|
||||||
extern void PPSConsistencyCheck(pic_parameter_set_rbsp_t *pps);
|
extern void PPSConsistencyCheck(pic_parameter_set_rbsp_t *pps);
|
||||||
extern void SPSConsistencyCheck(seq_parameter_set_rbsp_t *sps);
|
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 MakePPSavailable(VideoParameters *p_Vid, int id,
|
||||||
extern void MakeSPSavailable (VideoParameters *p_Vid, int id, seq_parameter_set_rbsp_t *sps);
|
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 ProcessSPS(VideoParameters *p_Vid, NALU_t *nalu);
|
||||||
extern void ProcessPPS(VideoParameters *p_Vid, NALU_t *nalu);
|
extern void ProcessPPS(VideoParameters *p_Vid, NALU_t *nalu);
|
||||||
|
@ -54,14 +55,20 @@ 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)
|
#if (MVC_EXTENSION_ENABLE)
|
||||||
extern void SubsetSPSConsistencyCheck (subset_seq_parameter_set_rbsp_t *subset_sps);
|
extern void
|
||||||
|
SubsetSPSConsistencyCheck(subset_seq_parameter_set_rbsp_t *subset_sps);
|
||||||
extern void ProcessSubsetSPS(VideoParameters *p_Vid, NALU_t *nalu);
|
extern void ProcessSubsetSPS(VideoParameters *p_Vid, NALU_t *nalu);
|
||||||
|
|
||||||
extern void mvc_vui_parameters_extension(MVCVUI_t *pMVCVUI, Bitstream *s);
|
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
|
||||||
extern void init_subset_sps_list(subset_seq_parameter_set_rbsp_t *subset_sps_list, int iSize);
|
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 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);
|
extern void get_max_dec_frame_buf_size(seq_parameter_set_rbsp_t *sps);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
* \file
|
* \file
|
||||||
* parsetcommon.h
|
* parsetcommon.h
|
||||||
* \brief
|
* \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
|
* \date 25 November 2002
|
||||||
* \author
|
* \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>
|
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
||||||
***************************************************************************************
|
***************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// In the JVT syntax, frequently flags are used that indicate the presence of
|
// 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
|
// certain pieces of information in the NALU. Here, these flags are also
|
||||||
// present. In the encoder, those bits indicate that the values signaled to
|
// present. In the encoder, those bits indicate that the values signaled to
|
||||||
|
@ -35,8 +35,7 @@
|
||||||
#define MAXPPS 256
|
#define MAXPPS 256
|
||||||
|
|
||||||
#define MAXIMUMVALUEOFcpb_cnt 32
|
#define MAXIMUMVALUEOFcpb_cnt 32
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
unsigned int cpb_cnt_minus1; // ue(v)
|
unsigned int cpb_cnt_minus1; // ue(v)
|
||||||
unsigned int bit_rate_scale; // u(4)
|
unsigned int bit_rate_scale; // u(4)
|
||||||
unsigned int cpb_size_scale; // u(4)
|
unsigned int cpb_size_scale; // u(4)
|
||||||
|
@ -49,9 +48,7 @@ typedef struct
|
||||||
unsigned int time_offset_length; // u(5)
|
unsigned int time_offset_length; // u(5)
|
||||||
} hrd_parameters_t;
|
} hrd_parameters_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
Boolean aspect_ratio_info_present_flag; // u(1)
|
Boolean aspect_ratio_info_present_flag; // u(1)
|
||||||
unsigned int aspect_ratio_idc; // u(8)
|
unsigned int aspect_ratio_idc; // u(8)
|
||||||
unsigned short sar_width; // u(16)
|
unsigned short sar_width; // u(16)
|
||||||
|
@ -89,10 +86,8 @@ typedef struct
|
||||||
unsigned int max_dec_frame_buffering; // ue(v)
|
unsigned int max_dec_frame_buffering; // ue(v)
|
||||||
} vui_seq_parameters_t;
|
} vui_seq_parameters_t;
|
||||||
|
|
||||||
|
|
||||||
#define MAXnum_slice_groups_minus1 8
|
#define MAXnum_slice_groups_minus1 8
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
Boolean Valid; // indicates the parameter set is valid
|
Boolean Valid; // indicates the parameter set is valid
|
||||||
unsigned int pic_parameter_set_id; // ue(v)
|
unsigned int pic_parameter_set_id; // ue(v)
|
||||||
unsigned int seq_parameter_set_id; // ue(v)
|
unsigned int seq_parameter_set_id; // ue(v)
|
||||||
|
@ -137,10 +132,8 @@ typedef struct
|
||||||
Boolean redundant_pic_cnt_present_flag; // u(1)
|
Boolean redundant_pic_cnt_present_flag; // u(1)
|
||||||
} pic_parameter_set_rbsp_t;
|
} pic_parameter_set_rbsp_t;
|
||||||
|
|
||||||
|
|
||||||
#define MAXnum_ref_frames_in_pic_order_cnt_cycle 256
|
#define MAXnum_ref_frames_in_pic_order_cnt_cycle 256
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
Boolean Valid; // indicates the parameter set is valid
|
Boolean Valid; // indicates the parameter set is valid
|
||||||
|
|
||||||
unsigned int profile_idc; // u(8)
|
unsigned int profile_idc; // u(8)
|
||||||
|
@ -197,8 +190,7 @@ typedef struct
|
||||||
} seq_parameter_set_rbsp_t;
|
} seq_parameter_set_rbsp_t;
|
||||||
|
|
||||||
#if (MVC_EXTENSION_ENABLE)
|
#if (MVC_EXTENSION_ENABLE)
|
||||||
typedef struct mvcvui_tag
|
typedef struct mvcvui_tag {
|
||||||
{
|
|
||||||
int num_ops_minus1;
|
int num_ops_minus1;
|
||||||
signed char *temporal_id;
|
signed char *temporal_id;
|
||||||
int *num_target_output_views_minus1;
|
int *num_target_output_views_minus1;
|
||||||
|
@ -225,8 +217,7 @@ typedef struct mvcvui_tag
|
||||||
signed char time_offset_length;
|
signed char time_offset_length;
|
||||||
} MVCVUI_t;
|
} MVCVUI_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
seq_parameter_set_rbsp_t sps;
|
seq_parameter_set_rbsp_t sps;
|
||||||
|
|
||||||
unsigned int bit_equal_to_one;
|
unsigned int bit_equal_to_one;
|
||||||
|
@ -265,7 +256,9 @@ seq_parameter_set_rbsp_t *AllocSPS (void);
|
||||||
void FreePPS(pic_parameter_set_rbsp_t *pps);
|
void FreePPS(pic_parameter_set_rbsp_t *pps);
|
||||||
void FreeSPS(seq_parameter_set_rbsp_t *sps);
|
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 sps_is_equal(seq_parameter_set_rbsp_t *sps1,
|
||||||
int pps_is_equal(pic_parameter_set_rbsp_t *pps1, pic_parameter_set_rbsp_t *pps2);
|
seq_parameter_set_rbsp_t *sps2);
|
||||||
|
int pps_is_equal(pic_parameter_set_rbsp_t *pps1,
|
||||||
|
pic_parameter_set_rbsp_t *pps2);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,145 +15,92 @@
|
||||||
#define _QUANT_H_
|
#define _QUANT_H_
|
||||||
|
|
||||||
// exported variables
|
// exported variables
|
||||||
static const int dequant_coef8[6][8][8] =
|
static const int dequant_coef8[6][8][8] = {{{20, 19, 25, 19, 20, 19, 25, 19},
|
||||||
{
|
|
||||||
{
|
|
||||||
{20, 19, 25, 19, 20, 19, 25, 19},
|
|
||||||
{19, 18, 24, 18, 19, 18, 24, 18},
|
{19, 18, 24, 18, 19, 18, 24, 18},
|
||||||
{25, 24, 32, 24, 25, 24, 32, 24},
|
{25, 24, 32, 24, 25, 24, 32, 24},
|
||||||
{19, 18, 24, 18, 19, 18, 24, 18},
|
{19, 18, 24, 18, 19, 18, 24, 18},
|
||||||
{20, 19, 25, 19, 20, 19, 25, 19},
|
{20, 19, 25, 19, 20, 19, 25, 19},
|
||||||
{19, 18, 24, 18, 19, 18, 24, 18},
|
{19, 18, 24, 18, 19, 18, 24, 18},
|
||||||
{25, 24, 32, 24, 25, 24, 32, 24},
|
{25, 24, 32, 24, 25, 24, 32, 24},
|
||||||
{19, 18, 24, 18, 19, 18, 24, 18}
|
{19, 18, 24, 18, 19, 18, 24, 18}},
|
||||||
},
|
{{22, 21, 28, 21, 22, 21, 28, 21},
|
||||||
{
|
|
||||||
{22, 21, 28, 21, 22, 21, 28, 21},
|
|
||||||
{21, 19, 26, 19, 21, 19, 26, 19},
|
{21, 19, 26, 19, 21, 19, 26, 19},
|
||||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
{28, 26, 35, 26, 28, 26, 35, 26},
|
||||||
{21, 19, 26, 19, 21, 19, 26, 19},
|
{21, 19, 26, 19, 21, 19, 26, 19},
|
||||||
{22, 21, 28, 21, 22, 21, 28, 21},
|
{22, 21, 28, 21, 22, 21, 28, 21},
|
||||||
{21, 19, 26, 19, 21, 19, 26, 19},
|
{21, 19, 26, 19, 21, 19, 26, 19},
|
||||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
{28, 26, 35, 26, 28, 26, 35, 26},
|
||||||
{21, 19, 26, 19, 21, 19, 26, 19}
|
{21, 19, 26, 19, 21, 19, 26, 19}},
|
||||||
},
|
{{26, 24, 33, 24, 26, 24, 33, 24},
|
||||||
{
|
|
||||||
{26, 24, 33, 24, 26, 24, 33, 24},
|
|
||||||
{24, 23, 31, 23, 24, 23, 31, 23},
|
{24, 23, 31, 23, 24, 23, 31, 23},
|
||||||
{33, 31, 42, 31, 33, 31, 42, 31},
|
{33, 31, 42, 31, 33, 31, 42, 31},
|
||||||
{24, 23, 31, 23, 24, 23, 31, 23},
|
{24, 23, 31, 23, 24, 23, 31, 23},
|
||||||
{26, 24, 33, 24, 26, 24, 33, 24},
|
{26, 24, 33, 24, 26, 24, 33, 24},
|
||||||
{24, 23, 31, 23, 24, 23, 31, 23},
|
{24, 23, 31, 23, 24, 23, 31, 23},
|
||||||
{33, 31, 42, 31, 33, 31, 42, 31},
|
{33, 31, 42, 31, 33, 31, 42, 31},
|
||||||
{24, 23, 31, 23, 24, 23, 31, 23}
|
{24, 23, 31, 23, 24, 23, 31, 23}},
|
||||||
},
|
{{28, 26, 35, 26, 28, 26, 35, 26},
|
||||||
{
|
|
||||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
|
||||||
{26, 25, 33, 25, 26, 25, 33, 25},
|
{26, 25, 33, 25, 26, 25, 33, 25},
|
||||||
{35, 33, 45, 33, 35, 33, 45, 33},
|
{35, 33, 45, 33, 35, 33, 45, 33},
|
||||||
{26, 25, 33, 25, 26, 25, 33, 25},
|
{26, 25, 33, 25, 26, 25, 33, 25},
|
||||||
{28, 26, 35, 26, 28, 26, 35, 26},
|
{28, 26, 35, 26, 28, 26, 35, 26},
|
||||||
{26, 25, 33, 25, 26, 25, 33, 25},
|
{26, 25, 33, 25, 26, 25, 33, 25},
|
||||||
{35, 33, 45, 33, 35, 33, 45, 33},
|
{35, 33, 45, 33, 35, 33, 45, 33},
|
||||||
{26, 25, 33, 25, 26, 25, 33, 25}
|
{26, 25, 33, 25, 26, 25, 33, 25}},
|
||||||
},
|
{{32, 30, 40, 30, 32, 30, 40, 30},
|
||||||
{
|
|
||||||
{32, 30, 40, 30, 32, 30, 40, 30},
|
|
||||||
{30, 28, 38, 28, 30, 28, 38, 28},
|
{30, 28, 38, 28, 30, 28, 38, 28},
|
||||||
{40, 38, 51, 38, 40, 38, 51, 38},
|
{40, 38, 51, 38, 40, 38, 51, 38},
|
||||||
{30, 28, 38, 28, 30, 28, 38, 28},
|
{30, 28, 38, 28, 30, 28, 38, 28},
|
||||||
{32, 30, 40, 30, 32, 30, 40, 30},
|
{32, 30, 40, 30, 32, 30, 40, 30},
|
||||||
{30, 28, 38, 28, 30, 28, 38, 28},
|
{30, 28, 38, 28, 30, 28, 38, 28},
|
||||||
{40, 38, 51, 38, 40, 38, 51, 38},
|
{40, 38, 51, 38, 40, 38, 51, 38},
|
||||||
{30, 28, 38, 28, 30, 28, 38, 28}
|
{30, 28, 38, 28, 30, 28, 38, 28}},
|
||||||
},
|
{{36, 34, 46, 34, 36, 34, 46, 34},
|
||||||
{
|
|
||||||
{36, 34, 46, 34, 36, 34, 46, 34},
|
|
||||||
{34, 32, 43, 32, 34, 32, 43, 32},
|
{34, 32, 43, 32, 34, 32, 43, 32},
|
||||||
{46, 43, 58, 43, 46, 43, 58, 43},
|
{46, 43, 58, 43, 46, 43, 58, 43},
|
||||||
{34, 32, 43, 32, 34, 32, 43, 32},
|
{34, 32, 43, 32, 34, 32, 43, 32},
|
||||||
{36, 34, 46, 34, 36, 34, 46, 34},
|
{36, 34, 46, 34, 36, 34, 46, 34},
|
||||||
{34, 32, 43, 32, 34, 32, 43, 32},
|
{34, 32, 43, 32, 34, 32, 43, 32},
|
||||||
{46, 43, 58, 43, 46, 43, 58, 43},
|
{46, 43, 58, 43, 46, 43, 58, 43},
|
||||||
{34, 32, 43, 32, 34, 32, 43, 32}
|
{34, 32, 43, 32, 34, 32, 43, 32}}};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//! Dequantization coefficients
|
//! Dequantization coefficients
|
||||||
static const int dequant_coef[6][4][4] = {
|
static const int dequant_coef[6][4][4] = {
|
||||||
{
|
{{10, 13, 10, 13}, {13, 16, 13, 16}, {10, 13, 10, 13}, {13, 16, 13, 16}},
|
||||||
{ 10, 13, 10, 13},
|
{{11, 14, 11, 14}, {14, 18, 14, 18}, {11, 14, 11, 14}, {14, 18, 14, 18}},
|
||||||
{ 13, 16, 13, 16},
|
{{13, 16, 13, 16}, {16, 20, 16, 20}, {13, 16, 13, 16}, {16, 20, 16, 20}},
|
||||||
{ 10, 13, 10, 13},
|
{{14, 18, 14, 18}, {18, 23, 18, 23}, {14, 18, 14, 18}, {18, 23, 18, 23}},
|
||||||
{ 13, 16, 13, 16}},
|
{{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}}};
|
||||||
{ 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] = {
|
static const int quant_coef[6][4][4] = {{{13107, 8066, 13107, 8066},
|
||||||
{
|
|
||||||
{ 13107, 8066, 13107, 8066},
|
|
||||||
{8066, 5243, 8066, 5243},
|
{8066, 5243, 8066, 5243},
|
||||||
{13107, 8066, 13107, 8066},
|
{13107, 8066, 13107, 8066},
|
||||||
{8066, 5243, 8066, 5243}},
|
{8066, 5243, 8066, 5243}},
|
||||||
{
|
{{11916, 7490, 11916, 7490},
|
||||||
{ 11916, 7490, 11916, 7490},
|
|
||||||
{7490, 4660, 7490, 4660},
|
{7490, 4660, 7490, 4660},
|
||||||
{11916, 7490, 11916, 7490},
|
{11916, 7490, 11916, 7490},
|
||||||
{7490, 4660, 7490, 4660}},
|
{7490, 4660, 7490, 4660}},
|
||||||
{
|
{{10082, 6554, 10082, 6554},
|
||||||
{ 10082, 6554, 10082, 6554},
|
|
||||||
{6554, 4194, 6554, 4194},
|
{6554, 4194, 6554, 4194},
|
||||||
{10082, 6554, 10082, 6554},
|
{10082, 6554, 10082, 6554},
|
||||||
{6554, 4194, 6554, 4194}},
|
{6554, 4194, 6554, 4194}},
|
||||||
{
|
{{9362, 5825, 9362, 5825},
|
||||||
{ 9362, 5825, 9362, 5825},
|
|
||||||
{5825, 3647, 5825, 3647},
|
{5825, 3647, 5825, 3647},
|
||||||
{9362, 5825, 9362, 5825},
|
{9362, 5825, 9362, 5825},
|
||||||
{5825, 3647, 5825, 3647}},
|
{5825, 3647, 5825, 3647}},
|
||||||
{
|
{{8192, 5243, 8192, 5243},
|
||||||
{ 8192, 5243, 8192, 5243},
|
|
||||||
{5243, 3355, 5243, 3355},
|
{5243, 3355, 5243, 3355},
|
||||||
{8192, 5243, 8192, 5243},
|
{8192, 5243, 8192, 5243},
|
||||||
{5243, 3355, 5243, 3355}},
|
{5243, 3355, 5243, 3355}},
|
||||||
{
|
{{7282, 4559, 7282, 4559},
|
||||||
{ 7282, 4559, 7282, 4559},
|
|
||||||
{4559, 2893, 4559, 2893},
|
{4559, 2893, 4559, 2893},
|
||||||
{7282, 4559, 7282, 4559},
|
{7282, 4559, 7282, 4559},
|
||||||
{ 4559, 2893, 4559, 2893}}
|
{4559, 2893, 4559, 2893}}};
|
||||||
};
|
|
||||||
|
|
||||||
// SP decoding parameter (EQ. 8-425)
|
// SP decoding parameter (EQ. 8-425)
|
||||||
static const int A[4][4] = {
|
static const int A[4][4] = {
|
||||||
{ 16, 20, 16, 20},
|
{16, 20, 16, 20}, {20, 25, 20, 25}, {16, 20, 16, 20}, {20, 25, 20, 25}};
|
||||||
{ 20, 25, 20, 25},
|
|
||||||
{ 16, 20, 16, 20},
|
|
||||||
{ 20, 25, 20, 25}
|
|
||||||
};
|
|
||||||
|
|
||||||
// exported functions
|
// exported functions
|
||||||
// quantization initialization
|
// quantization initialization
|
||||||
|
@ -166,4 +113,3 @@ extern void CalculateQuant4x4Param(Slice *currslice);
|
||||||
extern void CalculateQuant8x8Param(Slice *currslice);
|
extern void CalculateQuant8x8Param(Slice *currslice);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -51,4 +51,3 @@ typedef struct quant_methods {
|
||||||
} QuantMethods;
|
} QuantMethods;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,15 @@
|
||||||
#ifndef _REPORT_H_
|
#ifndef _REPORT_H_
|
||||||
#define _REPORT_H_
|
#define _REPORT_H_
|
||||||
#include "contributors.h"
|
#include "contributors.h"
|
||||||
#include "global.h"
|
|
||||||
#include "enc_statistics.h"
|
#include "enc_statistics.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
extern void report ( VideoParameters *p_Vid, InputParameters *p_Inp, StatParameters *p_Stats );
|
extern void report(VideoParameters *p_Vid, InputParameters *p_Inp,
|
||||||
extern void information_init ( VideoParameters *p_Vid, InputParameters *p_Inp, StatParameters *p_Stats );
|
StatParameters *p_Stats);
|
||||||
extern void report_frame_statistic( VideoParameters *p_Vid, InputParameters *p_Inp );
|
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_stats_on_error(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,16 @@
|
||||||
|
|
||||||
#include "nalucommon.h"
|
#include "nalucommon.h"
|
||||||
|
|
||||||
#define MAXRTPPAYLOADLEN (65536 - 40) //!< Maximum payload size of an RTP packet */
|
#define MAXRTPPAYLOADLEN \
|
||||||
#define MAXRTPPACKETSIZE (65536 - 28) //!< Maximum size of an RTP packet incl. header */
|
(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 H264PAYLOADTYPE 105 //!< RTP paylaod type fixed here for simplicity*/
|
||||||
#define H264SSRC 0x12345678 //!< SSRC, chosen to simplify debugging */
|
#define H264SSRC 0x12345678 //!< SSRC, chosen to simplify debugging */
|
||||||
#define RTP_TR_TIMESTAMP_MULT 1000 //!< should be something like 27 Mhz / 29.97 Hz */
|
#define RTP_TR_TIMESTAMP_MULT \
|
||||||
|
1000 //!< should be something like 27 Mhz / 29.97 Hz */
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
unsigned int v; //!< Version, 2 bits, MUST be 0x2
|
unsigned int v; //!< Version, 2 bits, MUST be 0x2
|
||||||
unsigned int p; //!< Padding bit, Padding MUST NOT be used
|
unsigned int p; //!< Padding bit, Padding MUST NOT be used
|
||||||
unsigned int x; //!< Extension, MUST be zero
|
unsigned int x; //!< Extension, MUST be zero
|
||||||
|
|
|
@ -69,8 +69,7 @@ typedef enum {
|
||||||
#define MAX_NUM_PIVOTS (1 << MAX_CODED_BIT_DEPTH)
|
#define MAX_NUM_PIVOTS (1 << MAX_CODED_BIT_DEPTH)
|
||||||
|
|
||||||
#if (ENABLE_OUTPUT_TONEMAPPING)
|
#if (ENABLE_OUTPUT_TONEMAPPING)
|
||||||
typedef struct tone_mapping_struct_s
|
typedef struct tone_mapping_struct_s {
|
||||||
{
|
|
||||||
Boolean seiHasTone_mapping;
|
Boolean seiHasTone_mapping;
|
||||||
unsigned int tone_map_repetition_period;
|
unsigned int tone_map_repetition_period;
|
||||||
unsigned char coded_data_bit_depth;
|
unsigned char coded_data_bit_depth;
|
||||||
|
@ -78,7 +77,8 @@ typedef struct tone_mapping_struct_s
|
||||||
unsigned int model_id;
|
unsigned int model_id;
|
||||||
unsigned int count;
|
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;
|
Bitstream *data;
|
||||||
int payloadSize;
|
int payloadSize;
|
||||||
|
@ -86,8 +86,7 @@ typedef struct tone_mapping_struct_s
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! Frame packing arrangement Information
|
//! Frame packing arrangement Information
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
unsigned int frame_packing_arrangement_id;
|
unsigned int frame_packing_arrangement_id;
|
||||||
Boolean frame_packing_arrangement_cancel_flag;
|
Boolean frame_packing_arrangement_cancel_flag;
|
||||||
unsigned char frame_packing_arrangement_type;
|
unsigned char frame_packing_arrangement_type;
|
||||||
|
@ -108,33 +107,58 @@ typedef struct
|
||||||
Boolean frame_packing_arrangement_extension_flag;
|
Boolean frame_packing_arrangement_extension_flag;
|
||||||
} frame_packing_arrangement_information_struct;
|
} frame_packing_arrangement_information_struct;
|
||||||
|
|
||||||
void InterpretSEIMessage ( byte* payload, int size, VideoParameters *p_Vid, Slice *pSlice );
|
void InterpretSEIMessage(byte *payload, int size, VideoParameters *p_Vid,
|
||||||
|
Slice *pSlice);
|
||||||
void interpret_spare_pic(byte *payload, int size, VideoParameters *p_Vid);
|
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_info(byte *payload, int size,
|
||||||
void interpret_subsequence_layer_characteristics_info ( byte* payload, int size, VideoParameters *p_Vid );
|
VideoParameters *p_Vid);
|
||||||
void interpret_subsequence_characteristics_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_subsequence_layer_characteristics_info(byte *payload, int size,
|
||||||
void interpret_scene_information ( byte* payload, int size, VideoParameters *p_Vid );
|
VideoParameters *p_Vid);
|
||||||
void interpret_user_data_registered_itu_t_t35_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_subsequence_characteristics_info(byte *payload, int size,
|
||||||
void interpret_user_data_unregistered_info ( byte* payload, int size, VideoParameters *p_Vid );
|
VideoParameters *p_Vid);
|
||||||
void interpret_pan_scan_rect_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_scene_information(byte *payload, int size,
|
||||||
void interpret_recovery_point_info ( byte* payload, int size, VideoParameters *p_Vid );
|
VideoParameters *p_Vid);
|
||||||
void interpret_filler_payload_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_user_data_registered_itu_t_t35_info(byte *payload, int size,
|
||||||
void interpret_dec_ref_pic_marking_repetition_info ( byte* payload, int size, VideoParameters *p_Vid, Slice *pSlice );
|
VideoParameters *p_Vid);
|
||||||
void interpret_full_frame_freeze_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_user_data_unregistered_info(byte *payload, int size,
|
||||||
void interpret_full_frame_freeze_release_info ( byte* payload, int size, VideoParameters *p_Vid );
|
VideoParameters *p_Vid);
|
||||||
void interpret_full_frame_snapshot_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_pan_scan_rect_info(byte *payload, int size,
|
||||||
void interpret_progressive_refinement_start_info ( byte* payload, int size, VideoParameters *p_Vid );
|
VideoParameters *p_Vid);
|
||||||
void interpret_progressive_refinement_end_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_recovery_point_info(byte *payload, int size,
|
||||||
void interpret_motion_constrained_slice_group_set_info ( byte* payload, int size, VideoParameters *p_Vid );
|
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_reserved_info(byte *payload, int size, VideoParameters *p_Vid);
|
||||||
void interpret_buffering_period_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_buffering_period_info(byte *payload, int size,
|
||||||
void interpret_picture_timing_info ( byte* payload, int size, VideoParameters *p_Vid );
|
VideoParameters *p_Vid);
|
||||||
void interpret_film_grain_characteristics_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_picture_timing_info(byte *payload, int size,
|
||||||
void interpret_deblocking_filter_display_preference_info( byte* payload, int size, VideoParameters *p_Vid );
|
VideoParameters *p_Vid);
|
||||||
void interpret_stereo_video_info_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_film_grain_characteristics_info(byte *payload, int size,
|
||||||
void interpret_post_filter_hints_info ( byte* payload, int size, VideoParameters *p_Vid );
|
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_tone_mapping(byte *payload, int size, VideoParameters *p_Vid);
|
||||||
void interpret_frame_packing_arrangement_info ( byte* payload, int size, VideoParameters *p_Vid );
|
void interpret_frame_packing_arrangement_info(byte *payload, int size,
|
||||||
|
VideoParameters *p_Vid);
|
||||||
|
|
||||||
#if (ENABLE_OUTPUT_TONEMAPPING)
|
#if (ENABLE_OUTPUT_TONEMAPPING)
|
||||||
void tone_map(imgpel **imgX, imgpel *lut, int size_x, int size_y);
|
void tone_map(imgpel **imgX, imgpel *lut, int size_x, int size_y);
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
* 10 July 2007
|
* 10 July 2007
|
||||||
*
|
*
|
||||||
* \author
|
* \author
|
||||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
* Main contributors (see contributors.h for copyright, address and
|
||||||
* Alexis Michael Tourapis
|
*affiliation details) Alexis Michael Tourapis
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#ifndef _TRANSFORM_H_
|
#ifndef _TRANSFORM_H_
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
* 9. October 2003
|
* 9. October 2003
|
||||||
*
|
*
|
||||||
* \author
|
* \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
|
* - Yuri Vatis
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,12 @@
|
||||||
* \brief
|
* \brief
|
||||||
* Common type definitions
|
* Common type definitions
|
||||||
* Currently only supports Windows and Linux operating systems.
|
* Currently only supports Windows and Linux operating systems.
|
||||||
* Need to add support for other "older systems such as VAX, DECC, Unix Alpha etc
|
* Need to add support for other "older systems such as VAX, DECC, Unix Alpha
|
||||||
|
*etc
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +21,8 @@
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
|
|
||||||
typedef unsigned char byte; //!< byte type definition
|
typedef unsigned char byte; //!< byte type definition
|
||||||
typedef unsigned char uint8; //!< type definition for unsigned char (same as byte, 8 bits)
|
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 short uint16; //!< type definition for unsigned short (16 bits)
|
||||||
typedef unsigned int uint32; //!< type definition for unsigned int (32 bits)
|
typedef unsigned int uint32; //!< type definition for unsigned int (32 bits)
|
||||||
|
|
||||||
|
@ -57,10 +60,7 @@ typedef int32 transpel;
|
||||||
#ifdef FALSE
|
#ifdef FALSE
|
||||||
#define Boolean int
|
#define Boolean int
|
||||||
#else
|
#else
|
||||||
typedef enum {
|
typedef enum { FALSE, TRUE } Boolean;
|
||||||
FALSE,
|
|
||||||
TRUE
|
|
||||||
} Boolean;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -85,4 +85,3 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
* type definitions.
|
* type definitions.
|
||||||
*
|
*
|
||||||
* \author
|
* \author
|
||||||
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
* Main contributors (see contributors.h for copyright, address and
|
||||||
|
*affiliation details)
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -19,8 +20,7 @@
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
// YUV
|
// YUV
|
||||||
PLANE_Y = 0, // PLANE_Y
|
PLANE_Y = 0, // PLANE_Y
|
||||||
PLANE_U = 1, // PLANE_Cb
|
PLANE_U = 1, // PLANE_Cb
|
||||||
|
@ -31,51 +31,28 @@ typedef enum
|
||||||
PLANE_R = 2
|
PLANE_R = 2
|
||||||
} ColorPlane;
|
} ColorPlane;
|
||||||
|
|
||||||
enum {
|
enum { LIST_0 = 0, LIST_1 = 1, BI_PRED = 2, BI_PRED_L0 = 3, BI_PRED_L1 = 4 };
|
||||||
LIST_0 = 0,
|
|
||||||
LIST_1 = 1,
|
|
||||||
BI_PRED = 2,
|
|
||||||
BI_PRED_L0 = 3,
|
|
||||||
BI_PRED_L1 = 4
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum { ERROR_SAD = 0, ERROR_SSE = 1, ERROR_SATD = 2, ERROR_PSATD = 3 };
|
||||||
ERROR_SAD = 0,
|
|
||||||
ERROR_SSE = 1,
|
|
||||||
ERROR_SATD = 2,
|
|
||||||
ERROR_PSATD = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum { ME_Y_ONLY = 0, ME_YUV_FP = 1, ME_YUV_FP_SP = 2 };
|
||||||
ME_Y_ONLY = 0,
|
|
||||||
ME_YUV_FP = 1,
|
|
||||||
ME_YUV_FP_SP = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
enum {
|
|
||||||
DISTORTION_MSE = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
|
enum { DISTORTION_MSE = 0 };
|
||||||
|
|
||||||
//! Data Partitioning Modes
|
//! Data Partitioning Modes
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
PAR_DP_1, //!< no data partitioning is supported
|
PAR_DP_1, //!< no data partitioning is supported
|
||||||
PAR_DP_3 //!< data partitioning with 3 partitions
|
PAR_DP_3 //!< data partitioning with 3 partitions
|
||||||
} PAR_DP_TYPE;
|
} PAR_DP_TYPE;
|
||||||
|
|
||||||
|
|
||||||
//! Output File Types
|
//! Output File Types
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
PAR_OF_ANNEXB, //!< Annex B byte stream format
|
PAR_OF_ANNEXB, //!< Annex B byte stream format
|
||||||
PAR_OF_RTP //!< RTP packets in outfile
|
PAR_OF_RTP //!< RTP packets in outfile
|
||||||
} PAR_OF_TYPE;
|
} PAR_OF_TYPE;
|
||||||
|
|
||||||
//! Field Coding Types
|
//! Field Coding Types
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
FRAME_CODING,
|
FRAME_CODING,
|
||||||
FIELD_CODING,
|
FIELD_CODING,
|
||||||
ADAPTIVE_CODING,
|
ADAPTIVE_CODING,
|
||||||
|
@ -83,8 +60,7 @@ typedef enum
|
||||||
} CodingType;
|
} CodingType;
|
||||||
|
|
||||||
//! definition of H.264 syntax elements
|
//! definition of H.264 syntax elements
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
SE_HEADER,
|
SE_HEADER,
|
||||||
SE_PTYPE,
|
SE_PTYPE,
|
||||||
SE_MBTYPE,
|
SE_MBTYPE,
|
||||||
|
@ -106,24 +82,11 @@ typedef enum
|
||||||
SE_MAX_ELEMENTS = 20 //!< number of maximum syntax elements
|
SE_MAX_ELEMENTS = 20 //!< number of maximum syntax elements
|
||||||
} SE_type; // substituting the definitions in elements.h
|
} SE_type; // substituting the definitions in elements.h
|
||||||
|
|
||||||
|
typedef enum { NO_SLICES, FIXED_MB, FIXED_RATE, CALL_BACK } SliceMode;
|
||||||
|
|
||||||
typedef enum
|
typedef enum { CAVLC, CABAC } SymbolMode;
|
||||||
{
|
|
||||||
NO_SLICES,
|
|
||||||
FIXED_MB,
|
|
||||||
FIXED_RATE,
|
|
||||||
CALL_BACK
|
|
||||||
} SliceMode;
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
CAVLC,
|
|
||||||
CABAC
|
|
||||||
} SymbolMode;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
FULL_SEARCH = -1,
|
FULL_SEARCH = -1,
|
||||||
FAST_FULL_SEARCH = 0,
|
FAST_FULL_SEARCH = 0,
|
||||||
UM_HEX = 1,
|
UM_HEX = 1,
|
||||||
|
@ -131,16 +94,13 @@ typedef enum
|
||||||
EPZS = 3
|
EPZS = 3
|
||||||
} SearchType;
|
} SearchType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
FRAME,
|
FRAME,
|
||||||
TOP_FIELD,
|
TOP_FIELD,
|
||||||
BOTTOM_FIELD
|
BOTTOM_FIELD
|
||||||
} PictureStructure; //!< New enum for field processing
|
} PictureStructure; //!< New enum for field processing
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
P_SLICE = 0,
|
P_SLICE = 0,
|
||||||
B_SLICE = 1,
|
B_SLICE = 1,
|
||||||
I_SLICE = 2,
|
I_SLICE = 2,
|
||||||
|
@ -150,34 +110,26 @@ typedef enum
|
||||||
} SliceType;
|
} SliceType;
|
||||||
|
|
||||||
// Motion Estimation levels
|
// Motion Estimation levels
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
F_PEL, //!< Full Pel refinement
|
F_PEL, //!< Full Pel refinement
|
||||||
H_PEL, //!< Half Pel refinement
|
H_PEL, //!< Half Pel refinement
|
||||||
Q_PEL //!< Quarter Pel refinement
|
Q_PEL //!< Quarter Pel refinement
|
||||||
} MELevel;
|
} MELevel;
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
FAST_ACCESS = 0, //!< Fast/safe reference access
|
FAST_ACCESS = 0, //!< Fast/safe reference access
|
||||||
UMV_ACCESS = 1 //!< unconstrained reference access
|
UMV_ACCESS = 1 //!< unconstrained reference access
|
||||||
} REF_ACCESS_TYPE;
|
} REF_ACCESS_TYPE;
|
||||||
|
|
||||||
typedef enum
|
typedef enum { IS_LUMA = 0, IS_CHROMA = 1 } Component_Type;
|
||||||
{
|
|
||||||
IS_LUMA = 0,
|
|
||||||
IS_CHROMA = 1
|
|
||||||
} Component_Type;
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
RC_MODE_0 = 0,
|
RC_MODE_0 = 0,
|
||||||
RC_MODE_1 = 1,
|
RC_MODE_1 = 1,
|
||||||
RC_MODE_2 = 2,
|
RC_MODE_2 = 2,
|
||||||
RC_MODE_3 = 3
|
RC_MODE_3 = 3
|
||||||
} RCModeType;
|
} RCModeType;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SSE = 0,
|
SSE = 0,
|
||||||
SSE_RGB = 1,
|
SSE_RGB = 1,
|
||||||
|
@ -199,5 +151,4 @@ typedef enum {
|
||||||
WP_REGULAR = 9
|
WP_REGULAR = 9
|
||||||
} weighted_prediction_types;
|
} weighted_prediction_types;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,39 +16,36 @@
|
||||||
#define _VLC_H_
|
#define _VLC_H_
|
||||||
|
|
||||||
//! gives CBP value from codeword number, both for intra and inter
|
//! gives CBP value from codeword number, both for intra and inter
|
||||||
static const byte NCBP[2][48][2]=
|
static const byte NCBP[2][48][2] = {
|
||||||
{
|
{// 0 1 2 3 4 5 6 7 8 9 10
|
||||||
{ // 0 1 2 3 4 5 6 7 8 9 10 11
|
// 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},
|
{15, 0}, {0, 1}, {7, 2}, {11, 4}, {13, 8}, {14, 3}, {3, 5}, {5, 10},
|
||||||
{ 4,13},{ 8,14},{ 6, 6},{ 9, 9},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},
|
{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}
|
{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},
|
{{47, 0}, {31, 16}, {15, 1}, {0, 2}, {23, 4}, {27, 8}, {29, 32},
|
||||||
{39,47},{43, 7},{45,11},{46,13},{16,14},{ 3, 6},{ 5, 9},{10,31},{12,35},{19,37},{21,42},{26,44},
|
{30, 3}, {7, 5}, {11, 10}, {13, 12}, {14, 15}, {39, 47}, {43, 7},
|
||||||
{28,33},{35,34},{37,36},{42,40},{44,39},{ 1,43},{ 2,45},{ 4,46},{ 8,17},{17,18},{18,20},{20,24},
|
{45, 11}, {46, 13}, {16, 14}, {3, 6}, {5, 9}, {10, 31}, {12, 35},
|
||||||
{24,19},{ 6,21},{ 9,26},{22,28},{25,23},{32,27},{33,29},{34,30},{36,22},{40,25},{38,38},{41,41}
|
{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
|
//! for the linfo_levrun_inter routine
|
||||||
static const byte NTAB1[4][8][2] =
|
static const byte NTAB1[4][8][2] = {
|
||||||
{
|
|
||||||
{{1, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
{{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}},
|
{{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}},
|
{{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}},
|
{{3, 0}, {2, 1}, {2, 2}, {1, 6}, {1, 7}, {1, 8}, {1, 9}, {4, 0}},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte LEVRUN1[16]=
|
static const byte LEVRUN1[16] = {
|
||||||
{
|
|
||||||
4, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
|
4, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const byte NTAB2[4][8][2] = {
|
||||||
static const byte NTAB2[4][8][2] =
|
|
||||||
{
|
|
||||||
{{1, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
{{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, 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, 2}, {3, 0}, {4, 0}, {5, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||||
|
@ -56,13 +53,9 @@ static const byte NTAB2[4][8][2] =
|
||||||
};
|
};
|
||||||
|
|
||||||
//! for the linfo_levrun__c2x2 routine
|
//! for the linfo_levrun__c2x2 routine
|
||||||
static const byte LEVRUN3[4] =
|
static const byte LEVRUN3[4] = {2, 1, 0, 0};
|
||||||
{
|
|
||||||
2,1,0,0
|
|
||||||
};
|
|
||||||
|
|
||||||
static const byte NTAB3[2][2][2] =
|
static const byte NTAB3[2][2][2] = {
|
||||||
{
|
|
||||||
{{1, 0}, {0, 0}},
|
{{1, 0}, {0, 0}},
|
||||||
{{2, 0}, {1, 1}},
|
{{2, 0}, {1, 1}},
|
||||||
};
|
};
|
||||||
|
@ -88,25 +81,36 @@ 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_VLC(SyntaxElement *sym, Bitstream *currStream);
|
||||||
extern int readSyntaxElement_UVLC(Macroblock *currMB, SyntaxElement *sym, struct datapartition *dp);
|
extern int readSyntaxElement_UVLC(Macroblock *currMB, SyntaxElement *sym,
|
||||||
extern int readSyntaxElement_Intra4x4PredictionMode(SyntaxElement *sym, Bitstream *currStream);
|
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(byte buffer[], int totbitoffset, int *info,
|
||||||
extern int GetVLCSymbol_IntraMode (byte buffer[],int totbitoffset,int *info, int bytecount);
|
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_FLC(SyntaxElement *sym, Bitstream *currStream);
|
||||||
extern int readSyntaxElement_NumCoeffTrailingOnes (SyntaxElement *sym, Bitstream *currStream, signed char *type);
|
extern int readSyntaxElement_NumCoeffTrailingOnes(SyntaxElement *sym,
|
||||||
extern int readSyntaxElement_NumCoeffTrailingOnesChromaDC(VideoParameters *p_Vid, SyntaxElement *sym, Bitstream *currStream);
|
Bitstream *currStream,
|
||||||
extern int readSyntaxElement_Level_VLC0 (SyntaxElement *sym, Bitstream *currStream);
|
signed char *type);
|
||||||
extern int readSyntaxElement_Level_VLCN (SyntaxElement *sym, int vlc, Bitstream *currStream);
|
extern int readSyntaxElement_NumCoeffTrailingOnesChromaDC(
|
||||||
extern int readSyntaxElement_TotalZeros (SyntaxElement *sym, Bitstream *currStream);
|
VideoParameters *p_Vid, SyntaxElement *sym, Bitstream *currStream);
|
||||||
extern int readSyntaxElement_TotalZerosChromaDC (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 readSyntaxElement_Run(SyntaxElement *sym, Bitstream *currStream);
|
||||||
extern int GetBits (byte buffer[],int totbitoffset,int *info, int bitcount, int numbits);
|
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 ShowBits(byte buffer[], int totbitoffset, int bitcount, int numbits);
|
||||||
|
|
||||||
extern int more_rbsp_data(byte buffer[], int totbitoffset, int bytecount);
|
extern int more_rbsp_data(byte buffer[], int totbitoffset, int bytecount);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
#define _VUI_PARAMS_H_
|
#define _VUI_PARAMS_H_
|
||||||
|
|
||||||
// VUI Parameters
|
// VUI Parameters
|
||||||
typedef struct vui_parameters
|
typedef struct vui_parameters {
|
||||||
{
|
|
||||||
int aspect_ratio_info_present_flag;
|
int aspect_ratio_info_present_flag;
|
||||||
int aspect_ratio_idc;
|
int aspect_ratio_idc;
|
||||||
int sar_width;
|
int sar_width;
|
||||||
|
@ -71,4 +70,3 @@ typedef struct vui_parameters
|
||||||
} VUIParameters;
|
} VUIParameters;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,14 @@
|
||||||
#ifndef _WIN32_H_
|
#ifndef _WIN32_H_
|
||||||
#define _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)
|
#if (defined(_OPENMP) || defined(SPEC_OPENMP)) && \
|
||||||
|
!defined(SPEC_SUPPRESS_OPENMP) && !defined(SPEC_AUTO_SUPPRESS_OPENMP)
|
||||||
#define OPENMP
|
#define OPENMP
|
||||||
#define NUM_THREADS 8
|
#define NUM_THREADS 8
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,8 +29,8 @@
|
||||||
#if defined(WIN32) || defined(WIN64) || defined(SPEC_WINDOWS)
|
#if defined(WIN32) || defined(WIN64) || defined(SPEC_WINDOWS)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#ifndef SPEC
|
#ifndef SPEC
|
||||||
# include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#endif /* !SPEC */
|
#endif /* !SPEC */
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#if (_MSC_VER < 1400)
|
#if (_MSC_VER < 1400)
|
||||||
|
@ -37,7 +38,8 @@ typedef int intptr_t;
|
||||||
#else
|
#else
|
||||||
#include <crtdefs.h>
|
#include <crtdefs.h>
|
||||||
#endif
|
#endif
|
||||||
#if (defined(_OPENMP) || defined(SPEC_OPENMP)) && !defined(SPEC_SUPPRESS_OPENMP) && !defined(SPEC_AUTO_SUPPRESS_OPENMP)
|
#if (defined(_OPENMP) || defined(SPEC_OPENMP)) && \
|
||||||
|
!defined(SPEC_SUPPRESS_OPENMP) && !defined(SPEC_AUTO_SUPPRESS_OPENMP)
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -63,12 +65,13 @@ typedef int intptr_t;
|
||||||
#endif
|
#endif
|
||||||
#define forceinline __forceinline
|
#define forceinline __forceinline
|
||||||
#else
|
#else
|
||||||
# include <unistd.h>
|
|
||||||
# include <sys/time.h>
|
|
||||||
# include <sys/stat.h>
|
|
||||||
# include <time.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#if (defined(_OPENMP) || defined(SPEC_OPENMP)) && !defined(SPEC_SUPPRESS_OPENMP) && !defined(SPEC_AUTO_SUPPRESS_OPENMP)
|
#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>
|
#include <omp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -87,7 +90,8 @@ typedef int intptr_t;
|
||||||
#define forceinline inline
|
#define forceinline inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(WIN32) || defined(WIN64) || defined(SPEC_WINDOWS)) && !defined(__GNUC__)
|
#if (defined(WIN32) || defined(WIN64) || defined(SPEC_WINDOWS)) && \
|
||||||
|
!defined(__GNUC__)
|
||||||
typedef __int64 int64;
|
typedef __int64 int64;
|
||||||
typedef unsigned __int64 uint64;
|
typedef unsigned __int64 uint64;
|
||||||
#define FORMAT_OFF_T "I64d"
|
#define FORMAT_OFF_T "I64d"
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
* Input related functions
|
* Input related functions
|
||||||
*
|
*
|
||||||
* \author
|
* \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>
|
* - Karsten Sühring <suehring@hhi.de>
|
||||||
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
* - Alexis Michael Tourapis <alexismt@ieee.org>
|
||||||
*
|
*
|
||||||
|
@ -19,13 +20,19 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "input.h"
|
|
||||||
#include "img_io.h"
|
#include "img_io.h"
|
||||||
|
#include "input.h"
|
||||||
#include "memalloc.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_basic(imgpel **imgX, unsigned char *buf, int size_x, int size_y,
|
||||||
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);
|
int o_size_x, int o_size_y, int symbol_size_in_bytes,
|
||||||
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);
|
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 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)
|
* 1, big-endian (e.g. SPARC, MIPS, PowerPC)
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void initInput(VideoParameters *p_Vid, FrameFormat *source, FrameFormat *output)
|
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 (source->bit_depth[0] == output->bit_depth[0] &&
|
||||||
{
|
source->bit_depth[1] == output->bit_depth[1]) {
|
||||||
if ((sizeof(signed char) != sizeof(imgpel)) && testEndian())
|
if ((sizeof(signed char) != sizeof(imgpel)) && testEndian())
|
||||||
p_Vid->buf2img = buf2img_endian;
|
p_Vid->buf2img = buf2img_endian;
|
||||||
else
|
else
|
||||||
p_Vid->buf2img = buf2img_basic;
|
p_Vid->buf2img = buf2img_basic;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
p_Vid->buf2img = buf2img_bitshift;
|
p_Vid->buf2img = buf2img_bitshift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -60,8 +65,7 @@ void initInput(VideoParameters *p_Vid, FrameFormat *source, FrameFormat *output)
|
||||||
* 1, big-endian (e.g. SPARC, MIPS, PowerPC)
|
* 1, big-endian (e.g. SPARC, MIPS, PowerPC)
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
int testEndian(void)
|
int testEndian(void) {
|
||||||
{
|
|
||||||
short s;
|
short s;
|
||||||
byte *p;
|
byte *p;
|
||||||
|
|
||||||
|
@ -79,14 +83,11 @@ int testEndian(void)
|
||||||
* Masking to ensure data within appropriate range
|
* Masking to ensure data within appropriate range
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static void MaskMSBs (imgpel** imgX, int mask, int width, int height)
|
static void MaskMSBs(imgpel **imgX, int mask, int width, int height) {
|
||||||
{
|
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (j=0; j < height; j++)
|
for (j = 0; j < height; j++) {
|
||||||
{
|
for (i = 0; i < width; i++) {
|
||||||
for (i=0; i < width; i++)
|
|
||||||
{
|
|
||||||
imgX[j][i] = (imgpel)(imgX[j][i] & mask);
|
imgX[j][i] = (imgpel)(imgX[j][i] & mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,20 +104,14 @@ void fillPlane ( imgpel** imgX, //!< Pointer to image plane
|
||||||
int nVal, //!< Fill value (currently 0 <= nVal < 256)
|
int nVal, //!< Fill value (currently 0 <= nVal < 256)
|
||||||
int size_x, //!< horizontal size of picture
|
int size_x, //!< horizontal size of picture
|
||||||
int size_y //!< vertical size of picture
|
int size_y //!< vertical size of picture
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
int j, i;
|
int j, i;
|
||||||
|
|
||||||
if (sizeof(imgpel) == sizeof(signed char))
|
if (sizeof(imgpel) == sizeof(signed char)) {
|
||||||
{
|
|
||||||
memset(imgX[0], nVal, size_y * size_x);
|
memset(imgX[0], nVal, size_y * size_x);
|
||||||
}
|
} else {
|
||||||
else
|
for (j = 0; j < size_y; j++) {
|
||||||
{
|
for (i = 0; i < size_x; i++) {
|
||||||
for (j = 0; j < size_y; j++)
|
|
||||||
{
|
|
||||||
for (i = 0; i < size_x; i++)
|
|
||||||
{
|
|
||||||
imgX[j][i] = (imgpel)nVal;
|
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
|
* Deinterleave file read buffer to source picture structure
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
static void deinterleave ( unsigned char** input, //!< input buffer
|
static void
|
||||||
|
deinterleave(unsigned char **input, //!< input buffer
|
||||||
unsigned char **output, //!< output buffer
|
unsigned char **output, //!< output buffer
|
||||||
FrameFormat *source, //!< format of source buffer
|
FrameFormat *source, //!< format of source buffer
|
||||||
int symbol_size_in_bytes //!< number of bytes per symbol
|
int symbol_size_in_bytes //!< number of bytes per symbol
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
// original buffer
|
// original buffer
|
||||||
unsigned char *icmp0 = *input;
|
unsigned char *icmp0 = *input;
|
||||||
// final buffer
|
// final buffer
|
||||||
|
@ -147,8 +142,7 @@ static void deinterleave ( unsigned char** input, //!< input buffer
|
||||||
|
|
||||||
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);
|
memcpy(ocmp1, icmp0, symbol_size_in_bytes);
|
||||||
ocmp1 += symbol_size_in_bytes;
|
ocmp1 += symbol_size_in_bytes;
|
||||||
icmp0 += symbol_size_in_bytes;
|
icmp0 += symbol_size_in_bytes;
|
||||||
|
@ -168,10 +162,10 @@ static void deinterleave ( unsigned char** input, //!< input buffer
|
||||||
*input = *output;
|
*input = *output;
|
||||||
*output = icmp0;
|
*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
|
// Y
|
||||||
memcpy(ocmp0, icmp0, symbol_size_in_bytes);
|
memcpy(ocmp0, icmp0, symbol_size_in_bytes);
|
||||||
ocmp0 += symbol_size_in_bytes;
|
ocmp0 += symbol_size_in_bytes;
|
||||||
|
@ -194,11 +188,8 @@ static void deinterleave ( unsigned char** input, //!< input buffer
|
||||||
icmp0 = *input;
|
icmp0 = *input;
|
||||||
*input = *output;
|
*input = *output;
|
||||||
*output = icmp0;
|
*output = icmp0;
|
||||||
}
|
} else if (source->yuv_format == YUV444) {
|
||||||
else if (source->yuv_format == YUV444)
|
for (i = 0; i < source->size_cmp[0]; i++) {
|
||||||
{
|
|
||||||
for (i = 0; i < source->size_cmp[0]; i++)
|
|
||||||
{
|
|
||||||
memcpy(ocmp0, icmp0, symbol_size_in_bytes);
|
memcpy(ocmp0, icmp0, symbol_size_in_bytes);
|
||||||
ocmp0 += symbol_size_in_bytes;
|
ocmp0 += symbol_size_in_bytes;
|
||||||
icmp0 += symbol_size_in_bytes;
|
icmp0 += symbol_size_in_bytes;
|
||||||
|
@ -222,7 +213,8 @@ static void deinterleave ( unsigned char** input, //!< input buffer
|
||||||
* Convert file read buffer to source picture structure
|
* Convert file read buffer to source picture structure
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void buf2img_bitshift ( imgpel** imgX, //!< Pointer to image plane
|
void buf2img_bitshift(
|
||||||
|
imgpel **imgX, //!< Pointer to image plane
|
||||||
unsigned char *buf, //!< Buffer for file output
|
unsigned char *buf, //!< Buffer for file output
|
||||||
int size_x, //!< horizontal size of picture
|
int size_x, //!< horizontal size of picture
|
||||||
int size_y, //!< vertical size of picture
|
int size_y, //!< vertical size of picture
|
||||||
|
@ -230,84 +222,71 @@ void buf2img_bitshift ( imgpel** imgX, //!< Pointer to image plane
|
||||||
int o_size_y, //!< vertical 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 symbol_size_in_bytes, //!< number of bytes in file used for one pixel
|
||||||
int bitshift //!< variable for bitdepth expansion
|
int bitshift //!< variable for bitdepth expansion
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
uint16 tmp16, ui16;
|
uint16 tmp16, ui16;
|
||||||
unsigned long tmp32, ui32;
|
unsigned long tmp32, ui32;
|
||||||
// This test should be done once.
|
// This test should be done once.
|
||||||
if (((symbol_size_in_bytes << 3) - bitshift) > (int) (sizeof(imgpel)<< 3))
|
if (((symbol_size_in_bytes << 3) - bitshift) > (int)(sizeof(imgpel) << 3)) {
|
||||||
{
|
error("Source picture has higher bit depth than imgpel data type. \nPlease "
|
||||||
error ("Source picture has higher bit depth than imgpel data type. \nPlease recompile with larger data type for imgpel.", 500);
|
"recompile with larger data type for imgpel.",
|
||||||
|
500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testEndian())
|
if (testEndian()) {
|
||||||
{
|
if (size_x != o_size_x || size_y != o_size_y) {
|
||||||
if (size_x != o_size_x || size_y != o_size_y)
|
|
||||||
{
|
|
||||||
error("Rescaling not supported in big endian architectures. ", 500);
|
error("Rescaling not supported in big endian architectures. ", 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// big endian
|
// big endian
|
||||||
switch (symbol_size_in_bytes)
|
switch (symbol_size_in_bytes) {
|
||||||
{
|
case 1: {
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
for (j = 0; j < o_size_y; j++)
|
for (j = 0; j < o_size_y; j++)
|
||||||
for(i = 0; i < o_size_x; i++)
|
for (i = 0; i < o_size_x; i++) {
|
||||||
{
|
|
||||||
imgX[j][i] = (imgpel)rshift_rnd(buf[i + j * size_x], bitshift);
|
imgX[j][i] = (imgpel)rshift_rnd(buf[i + j * size_x], bitshift);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2: {
|
||||||
{
|
|
||||||
for (j = 0; j < o_size_y; j++)
|
for (j = 0; j < o_size_y; j++)
|
||||||
for(i = 0; i < o_size_x; i++)
|
for (i = 0; i < o_size_x; i++) {
|
||||||
{
|
|
||||||
memcpy(&tmp16, buf + ((i + j * size_x) * 2), 2);
|
memcpy(&tmp16, buf + ((i + j * size_x) * 2), 2);
|
||||||
ui16 = (tmp16 >> 8) | ((tmp16 & 0xFF) << 8);
|
ui16 = (tmp16 >> 8) | ((tmp16 & 0xFF) << 8);
|
||||||
imgX[j][i] = (imgpel)rshift_rnd(ui16, bitshift);
|
imgX[j][i] = (imgpel)rshift_rnd(ui16, bitshift);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4:
|
case 4: {
|
||||||
{
|
|
||||||
for (j = 0; j < o_size_y; j++)
|
for (j = 0; j < o_size_y; j++)
|
||||||
for(i = 0; i < o_size_x; i++)
|
for (i = 0; i < o_size_x; i++) {
|
||||||
{
|
|
||||||
memcpy(&tmp32, buf + ((i + j * size_x) * 4), 4);
|
memcpy(&tmp32, buf + ((i + j * size_x) * 4), 4);
|
||||||
ui32 = ((tmp32&0xFF00)<<8) | ((tmp32&0xFF)<<24) | ((tmp32&0xFF0000)>>8) | ((tmp32&0xFF000000)>>24);
|
ui32 = ((tmp32 & 0xFF00) << 8) | ((tmp32 & 0xFF) << 24) |
|
||||||
|
((tmp32 & 0xFF0000) >> 8) | ((tmp32 & 0xFF000000) >> 24);
|
||||||
imgX[j][i] = (imgpel)rshift_rnd(ui32, bitshift);
|
imgX[j][i] = (imgpel)rshift_rnd(ui32, bitshift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
{
|
error("reading only from formats of 8, 16 or 32 bit allowed on big "
|
||||||
error ("reading only from formats of 8, 16 or 32 bit allowed on big endian architecture", 500);
|
"endian architecture",
|
||||||
|
500);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// little endian
|
// little endian
|
||||||
int j_pos;
|
int j_pos;
|
||||||
if (size_x == o_size_x && size_y == o_size_y)
|
if (size_x == o_size_x && size_y == o_size_y) {
|
||||||
{
|
for (j = 0; j < o_size_y; j++) {
|
||||||
for (j = 0; j < o_size_y; j++)
|
|
||||||
{
|
|
||||||
j_pos = j * size_x;
|
j_pos = j * size_x;
|
||||||
for (i = 0; i < o_size_x; i++)
|
for (i = 0; i < o_size_x; i++) {
|
||||||
{
|
|
||||||
ui16 = 0;
|
ui16 = 0;
|
||||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes), symbol_size_in_bytes);
|
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes),
|
||||||
|
symbol_size_in_bytes);
|
||||||
imgX[j][i] = (imgpel)rshift_rnd(ui16, bitshift);
|
imgX[j][i] = (imgpel)rshift_rnd(ui16, bitshift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int iminwidth = imin(size_x, o_size_x);
|
int iminwidth = imin(size_x, o_size_x);
|
||||||
int iminheight = imin(size_y, o_size_y);
|
int iminheight = imin(size_y, o_size_y);
|
||||||
int dst_offset_x = 0, dst_offset_y = 0;
|
int dst_offset_x = 0, dst_offset_y = 0;
|
||||||
|
@ -322,34 +301,40 @@ void buf2img_bitshift ( imgpel** imgX, //!< Pointer to image plane
|
||||||
|
|
||||||
// check copied area to avoid copying memory garbage
|
// check copied area to avoid copying memory garbage
|
||||||
// source
|
// source
|
||||||
iminwidth = ( (offset_x + iminwidth ) > size_x ) ? (size_x - offset_x) : iminwidth;
|
iminwidth =
|
||||||
iminheight = ( (offset_y + iminheight) > size_y ) ? (size_y - offset_y) : iminheight;
|
((offset_x + iminwidth) > size_x) ? (size_x - offset_x) : iminwidth;
|
||||||
|
iminheight =
|
||||||
|
((offset_y + iminheight) > size_y) ? (size_y - offset_y) : iminheight;
|
||||||
// destination
|
// destination
|
||||||
iminwidth = ( (dst_offset_x + iminwidth ) > o_size_x ) ? (o_size_x - dst_offset_x) : iminwidth;
|
iminwidth = ((dst_offset_x + iminwidth) > o_size_x)
|
||||||
iminheight = ( (dst_offset_y + iminheight) > o_size_y ) ? (o_size_y - dst_offset_y) : iminheight;
|
? (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++)
|
for (j = 0; j < iminheight; j++) {
|
||||||
{
|
|
||||||
j_pos = (j + offset_y) * size_x + offset_x;
|
j_pos = (j + offset_y) * size_x + offset_x;
|
||||||
for (i=0; i < iminwidth; i++)
|
for (i = 0; i < iminwidth; i++) {
|
||||||
{
|
|
||||||
ui16 = 0;
|
ui16 = 0;
|
||||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes), symbol_size_in_bytes);
|
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes),
|
||||||
imgX[j + dst_offset_y][i + dst_offset_x] = (imgpel) rshift_rnd(ui16,bitshift);
|
symbol_size_in_bytes);
|
||||||
|
imgX[j + dst_offset_y][i + dst_offset_x] =
|
||||||
|
(imgpel)rshift_rnd(ui16, bitshift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
************************************************************************
|
************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
* Convert file read buffer to source picture structure
|
* Convert file read buffer to source picture structure
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void buf2img_basic (imgpel** imgX, //!< Pointer to image plane
|
void buf2img_basic(
|
||||||
|
imgpel **imgX, //!< Pointer to image plane
|
||||||
unsigned char *buf, //!< Buffer for file output
|
unsigned char *buf, //!< Buffer for file output
|
||||||
int size_x, //!< horizontal size of picture
|
int size_x, //!< horizontal size of picture
|
||||||
int size_y, //!< vertical size of picture
|
int size_y, //!< vertical size of picture
|
||||||
|
@ -357,23 +342,21 @@ void buf2img_basic (imgpel** imgX, //!< Pointer to image plane
|
||||||
int o_size_y, //!< vertical 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 symbol_size_in_bytes, //!< number of bytes in file used for one pixel
|
||||||
int dummy //!< dummy variable used for allowing function pointer use
|
int dummy //!< dummy variable used for allowing function pointer use
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
int i, j;
|
int i, j;
|
||||||
unsigned char *temp_buf = buf;
|
unsigned char *temp_buf = buf;
|
||||||
|
|
||||||
if (symbol_size_in_bytes> (int) sizeof(imgpel))
|
if (symbol_size_in_bytes > (int)sizeof(imgpel)) {
|
||||||
{
|
error("Source picture has higher bit depth than imgpel data type. \nPlease "
|
||||||
error ("Source picture has higher bit depth than imgpel data type. \nPlease recompile with larger data type for imgpel.", 500);
|
"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
|
// imgpel == pixel_in_file -> simple copy
|
||||||
if (size_x == o_size_x && size_y == o_size_y)
|
if (size_x == o_size_x && size_y == o_size_y)
|
||||||
memcpy(&imgX[0][0], temp_buf, size_x * size_y * sizeof(imgpel));
|
memcpy(&imgX[0][0], temp_buf, size_x * size_y * sizeof(imgpel));
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
int iminwidth = imin(size_x, o_size_x);
|
int iminwidth = imin(size_x, o_size_x);
|
||||||
int iminheight = imin(size_y, o_size_y);
|
int iminheight = imin(size_y, o_size_y);
|
||||||
int dst_offset_x = 0, dst_offset_y = 0;
|
int dst_offset_x = 0, dst_offset_y = 0;
|
||||||
|
@ -388,36 +371,38 @@ void buf2img_basic (imgpel** imgX, //!< Pointer to image plane
|
||||||
|
|
||||||
// check copied area to avoid copying memory garbage
|
// check copied area to avoid copying memory garbage
|
||||||
// source
|
// source
|
||||||
iminwidth = ( (offset_x + iminwidth ) > size_x ) ? (size_x - offset_x) : iminwidth;
|
iminwidth =
|
||||||
iminheight = ( (offset_y + iminheight) > size_y ) ? (size_y - offset_y) : iminheight;
|
((offset_x + iminwidth) > size_x) ? (size_x - offset_x) : iminwidth;
|
||||||
|
iminheight =
|
||||||
|
((offset_y + iminheight) > size_y) ? (size_y - offset_y) : iminheight;
|
||||||
// destination
|
// destination
|
||||||
iminwidth = ( (dst_offset_x + iminwidth ) > o_size_x ) ? (o_size_x - dst_offset_x) : iminwidth;
|
iminwidth = ((dst_offset_x + iminwidth) > o_size_x)
|
||||||
iminheight = ( (dst_offset_y + iminheight) > o_size_y ) ? (o_size_y - dst_offset_y) : iminheight;
|
? (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++) {
|
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));
|
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;
|
int j_pos;
|
||||||
uint16 ui16;
|
uint16 ui16;
|
||||||
if (size_x == o_size_x && size_y == o_size_y)
|
if (size_x == o_size_x && size_y == o_size_y) {
|
||||||
{
|
for (j = 0; j < o_size_y; j++) {
|
||||||
for (j=0; j < o_size_y; j++)
|
|
||||||
{
|
|
||||||
j_pos = j * size_x;
|
j_pos = j * size_x;
|
||||||
for (i=0; i < o_size_x; i++)
|
for (i = 0; i < o_size_x; i++) {
|
||||||
{
|
|
||||||
ui16 = 0;
|
ui16 = 0;
|
||||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes), symbol_size_in_bytes);
|
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes),
|
||||||
|
symbol_size_in_bytes);
|
||||||
imgX[j][i] = (imgpel)ui16;
|
imgX[j][i] = (imgpel)ui16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int iminwidth = imin(size_x, o_size_x);
|
int iminwidth = imin(size_x, o_size_x);
|
||||||
int iminheight = imin(size_y, o_size_y);
|
int iminheight = imin(size_y, o_size_y);
|
||||||
int dst_offset_x = 0, dst_offset_y = 0;
|
int dst_offset_x = 0, dst_offset_y = 0;
|
||||||
|
@ -432,22 +417,29 @@ void buf2img_basic (imgpel** imgX, //!< Pointer to image plane
|
||||||
|
|
||||||
// check copied area to avoid copying memory garbage
|
// check copied area to avoid copying memory garbage
|
||||||
// source
|
// source
|
||||||
iminwidth = ( (offset_x + iminwidth ) > size_x ) ? (size_x - offset_x) : iminwidth;
|
iminwidth =
|
||||||
iminheight = ( (offset_y + iminheight) > size_y ) ? (size_y - offset_y) : iminheight;
|
((offset_x + iminwidth) > size_x) ? (size_x - offset_x) : iminwidth;
|
||||||
|
iminheight =
|
||||||
|
((offset_y + iminheight) > size_y) ? (size_y - offset_y) : iminheight;
|
||||||
// destination
|
// destination
|
||||||
iminwidth = ( (dst_offset_x + iminwidth ) > o_size_x ) ? (o_size_x - dst_offset_x) : iminwidth;
|
iminwidth = ((dst_offset_x + iminwidth) > o_size_x)
|
||||||
iminheight = ( (dst_offset_y + iminheight) > o_size_y ) ? (o_size_y - dst_offset_y) : iminheight;
|
? (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++) {
|
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;
|
j_pos = (j + offset_y) * size_x + offset_x;
|
||||||
for (i=0; i < iminwidth; i++)
|
for (i = 0; i < iminwidth; i++) {
|
||||||
{
|
|
||||||
ui16 = 0;
|
ui16 = 0;
|
||||||
memcpy(&(ui16), buf + ((i + j_pos) * symbol_size_in_bytes), symbol_size_in_bytes);
|
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;
|
imgX[j + dst_offset_y][i + dst_offset_x] = (imgpel)ui16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -461,7 +453,8 @@ void buf2img_basic (imgpel** imgX, //!< Pointer to image plane
|
||||||
* Convert file read buffer to source picture structure
|
* Convert file read buffer to source picture structure
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void buf2img_endian (imgpel** imgX, //!< Pointer to image plane
|
void buf2img_endian(
|
||||||
|
imgpel **imgX, //!< Pointer to image plane
|
||||||
unsigned char *buf, //!< Buffer for file output
|
unsigned char *buf, //!< Buffer for file output
|
||||||
int size_x, //!< horizontal size of picture
|
int size_x, //!< horizontal size of picture
|
||||||
int size_y, //!< vertical size of picture
|
int size_y, //!< vertical size of picture
|
||||||
|
@ -469,43 +462,35 @@ void buf2img_endian (imgpel** imgX, //!< Pointer to image plane
|
||||||
int o_size_y, //!< vertical 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 symbol_size_in_bytes, //!< number of bytes in file used for one pixel
|
||||||
int dummy //!< dummy variable used for allowing function pointer use
|
int dummy //!< dummy variable used for allowing function pointer use
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
uint16 tmp16, ui16;
|
uint16 tmp16, ui16;
|
||||||
unsigned long tmp32, ui32;
|
unsigned long tmp32, ui32;
|
||||||
|
|
||||||
if (symbol_size_in_bytes > (int) sizeof(imgpel))
|
if (symbol_size_in_bytes > (int)sizeof(imgpel)) {
|
||||||
{
|
error("Source picture has higher bit depth than imgpel data type. \nPlease "
|
||||||
error ("Source picture has higher bit depth than imgpel data type. \nPlease recompile with larger data type for imgpel.", 500);
|
"recompile with larger data type for imgpel.",
|
||||||
|
500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size_x != o_size_x || size_y != o_size_y)
|
if (size_x != o_size_x || size_y != o_size_y) {
|
||||||
{
|
|
||||||
error("Rescaling not supported in big endian architectures. ", 500);
|
error("Rescaling not supported in big endian architectures. ", 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// big endian
|
// big endian
|
||||||
switch (symbol_size_in_bytes)
|
switch (symbol_size_in_bytes) {
|
||||||
{
|
case 1: {
|
||||||
case 1:
|
for (j = 0; j < size_y; j++) {
|
||||||
{
|
for (i = 0; i < size_x; i++) {
|
||||||
for(j=0;j<size_y;j++)
|
|
||||||
{
|
|
||||||
for(i=0;i<size_x;i++)
|
|
||||||
{
|
|
||||||
imgX[j][i] = (imgpel)buf[i + j * size_x];
|
imgX[j][i] = (imgpel)buf[i + j * size_x];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2: {
|
||||||
{
|
for (j = 0; j < size_y; j++) {
|
||||||
for(j=0;j<size_y;j++)
|
for (i = 0; i < size_x; i++) {
|
||||||
{
|
|
||||||
for(i=0;i<size_x;i++)
|
|
||||||
{
|
|
||||||
memcpy(&tmp16, buf + ((i + j * size_x) * 2), 2);
|
memcpy(&tmp16, buf + ((i + j * size_x) * 2), 2);
|
||||||
ui16 = (tmp16 >> 8) | ((tmp16 & 0xFF) << 8);
|
ui16 = (tmp16 >> 8) | ((tmp16 & 0xFF) << 8);
|
||||||
imgX[j][i] = (imgpel)ui16;
|
imgX[j][i] = (imgpel)ui16;
|
||||||
|
@ -513,22 +498,21 @@ void buf2img_endian (imgpel** imgX, //!< Pointer to image plane
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4:
|
case 4: {
|
||||||
{
|
for (j = 0; j < size_y; j++) {
|
||||||
for(j=0;j<size_y;j++)
|
for (i = 0; i < size_x; i++) {
|
||||||
{
|
|
||||||
for(i=0;i<size_x;i++)
|
|
||||||
{
|
|
||||||
memcpy(&tmp32, buf + ((i + j * size_x) * 4), 4);
|
memcpy(&tmp32, buf + ((i + j * size_x) * 4), 4);
|
||||||
ui32 = ((tmp32&0xFF00)<<8) | ((tmp32&0xFF)<<24) | ((tmp32&0xFF0000)>>8) | ((tmp32&0xFF000000)>>24);
|
ui32 = ((tmp32 & 0xFF00) << 8) | ((tmp32 & 0xFF) << 24) |
|
||||||
|
((tmp32 & 0xFF0000) >> 8) | ((tmp32 & 0xFF000000) >> 24);
|
||||||
imgX[j][i] = (imgpel)ui32;
|
imgX[j][i] = (imgpel)ui32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
{
|
error("reading only from formats of 8, 16 or 32 bit allowed on big endian "
|
||||||
error ("reading only from formats of 8, 16 or 32 bit allowed on big endian architecture", 500);
|
"architecture",
|
||||||
|
500);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -541,13 +525,14 @@ void buf2img_endian (imgpel** imgX, //!< Pointer to image plane
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void AllocateFrameMemory (VideoParameters *p_Vid, InputParameters *p_Inp, FrameFormat *source)
|
void AllocateFrameMemory(VideoParameters *p_Vid, InputParameters *p_Inp,
|
||||||
{
|
FrameFormat *source) {
|
||||||
if (NULL == (p_Vid->buf = malloc (source->size * source->pic_unit_size_shift3)))
|
if (NULL ==
|
||||||
|
(p_Vid->buf = malloc(source->size * source->pic_unit_size_shift3)))
|
||||||
no_mem_exit("AllocateFrameMemory: p_Vid->buf");
|
no_mem_exit("AllocateFrameMemory: p_Vid->buf");
|
||||||
if (p_Inp->input_file1.is_interleaved)
|
if (p_Inp->input_file1.is_interleaved) {
|
||||||
{
|
if (NULL ==
|
||||||
if (NULL == (p_Vid->ibuf = malloc (source->size * source->pic_unit_size_shift3)))
|
(p_Vid->ibuf = malloc(source->size * source->pic_unit_size_shift3)))
|
||||||
no_mem_exit("AllocateFrameMemory: p_Vid->ibuf");
|
no_mem_exit("AllocateFrameMemory: p_Vid->ibuf");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -559,8 +544,7 @@ void AllocateFrameMemory (VideoParameters *p_Vid, InputParameters *p_Inp, FrameF
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*/
|
*/
|
||||||
void DeleteFrameMemory (VideoParameters *p_Vid)
|
void DeleteFrameMemory(VideoParameters *p_Vid) {
|
||||||
{
|
|
||||||
if (p_Vid->buf != NULL)
|
if (p_Vid->buf != NULL)
|
||||||
free(p_Vid->buf);
|
free(p_Vid->buf);
|
||||||
if (p_Vid->ibuf != NULL)
|
if (p_Vid->ibuf != NULL)
|
||||||
|
@ -586,8 +570,9 @@ void DeleteFrameMemory (VideoParameters *p_Vid)
|
||||||
* Image planes
|
* 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;
|
InputParameters *p_Inp = p_Vid->p_Inp;
|
||||||
int file_read = 0;
|
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;
|
||||||
|
@ -596,66 +581,76 @@ int read_one_frame (VideoParameters *p_Vid, VideoDataFile *input_file, int Frame
|
||||||
const int bytes_uv = source->size_cmp[1] * symbol_size_in_bytes;
|
const int bytes_uv = source->size_cmp[1] * symbol_size_in_bytes;
|
||||||
int bit_scale;
|
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->is_concatenated == 0) {
|
||||||
{
|
if (input_file->vdtype == VIDEO_TIFF) {
|
||||||
if (input_file->vdtype == VIDEO_TIFF)
|
file_read =
|
||||||
{
|
ReadTIFFImage(p_Inp, input_file, FrameNoInFile, source, p_Vid->buf);
|
||||||
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
|
} else {
|
||||||
{
|
file_read = ReadFrameConcatenated(p_Inp, input_file, FrameNoInFile,
|
||||||
file_read = ReadFrameSeparate (p_Inp, input_file, FrameNoInFile, HeaderSize, source, p_Vid->buf);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deinterleave input source
|
// Deinterleave input source
|
||||||
if (input_file->is_interleaved)
|
if (input_file->is_interleaved) {
|
||||||
{
|
|
||||||
deinterleave(&p_Vid->buf, &p_Vid->ibuf, source, symbol_size_in_bytes);
|
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)
|
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);
|
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
|
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);
|
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)
|
#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
|
#endif
|
||||||
|
|
||||||
if (p_Vid->yuv_format != YUV400)
|
if (p_Vid->yuv_format != YUV400) {
|
||||||
{
|
|
||||||
bit_scale = source->bit_depth[1] - output->bit_depth[1];
|
bit_scale = source->bit_depth[1] - output->bit_depth[1];
|
||||||
#if (ALLOW_GRAYSCALE)
|
#if (ALLOW_GRAYSCALE)
|
||||||
if (!p_Inp->grayscale)
|
if (!p_Inp->grayscale)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (rgb_input)
|
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);
|
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
|
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);
|
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];
|
bit_scale = source->bit_depth[2] - output->bit_depth[2];
|
||||||
if (rgb_input)
|
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);
|
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
|
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);
|
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)
|
#if (DEBUG_BITDEPTH)
|
||||||
MaskMSBs(pImage[1], ((1 << output->bit_depth[1]) - 1), output->width[1], output->height[1]);
|
MaskMSBs(pImage[1], ((1 << output->bit_depth[1]) - 1), output->width[1],
|
||||||
MaskMSBs(pImage[2], ((1 << output->bit_depth[2]) - 1), output->width[1], output->height[1]);
|
output->height[1]);
|
||||||
|
MaskMSBs(pImage[2], ((1 << output->bit_depth[2]) - 1), output->width[1],
|
||||||
|
output->height[1]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,8 +677,8 @@ int read_one_frame (VideoParameters *p_Vid, VideoDataFile *input_file, int Frame
|
||||||
* image planes
|
* 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;
|
int x, y;
|
||||||
|
|
||||||
// Luma or 1st component
|
// Luma or 1st component
|
||||||
|
@ -699,12 +694,10 @@ void pad_borders (FrameFormat output, int img_size_x, int img_size_y, int img_si
|
||||||
memcpy(pImage[0][y], pImage[0][y - 1], img_size_x * sizeof(imgpel));
|
memcpy(pImage[0][y], pImage[0][y - 1], img_size_x * sizeof(imgpel));
|
||||||
|
|
||||||
// Chroma or all other components
|
// Chroma or all other components
|
||||||
if (output.yuv_format != YUV400)
|
if (output.yuv_format != YUV400) {
|
||||||
{
|
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
for (k = 1; k < 3; k++)
|
for (k = 1; k < 3; k++) {
|
||||||
{
|
|
||||||
// padding right border
|
// padding right border
|
||||||
if (output.width[1] < img_size_x_cr)
|
if (output.width[1] < img_size_x_cr)
|
||||||
for (y = 0; y < output.height[1]; y++)
|
for (y = 0; y < output.height[1]; y++)
|
||||||
|
@ -714,7 +707,8 @@ void pad_borders (FrameFormat output, int img_size_x, int img_size_y, int img_si
|
||||||
// padding bottom border
|
// padding bottom border
|
||||||
if (output.height[1] < img_size_y_cr)
|
if (output.height[1] < img_size_y_cr)
|
||||||
for (y = output.height[1]; y < img_size_y_cr; y++)
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,15 @@
|
||||||
*
|
*
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
#include "global.h"
|
|
||||||
#include "intra16x16_pred.h"
|
#include "intra16x16_pred.h"
|
||||||
#include "mb_access.h"
|
#include "global.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "mb_access.h"
|
||||||
|
|
||||||
|
extern int intrapred_16x16_mbaff(Macroblock *currMB, ColorPlane pl,
|
||||||
extern int intrapred_16x16_mbaff (Macroblock *currMB, ColorPlane pl, int predmode);
|
int predmode);
|
||||||
extern int intrapred_16x16_normal(Macroblock *currMB, ColorPlane pl, int predmode);
|
extern int intrapred_16x16_normal(Macroblock *currMB, ColorPlane pl,
|
||||||
|
int predmode);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
|
@ -35,13 +36,9 @@ int intrapred16x16(Macroblock *currMB, //!< Current Macroblock
|
||||||
ColorPlane pl, //!< Current colorplane (for 4:4:4)
|
ColorPlane pl, //!< Current colorplane (for 4:4:4)
|
||||||
int predmode) //!< prediction mode
|
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);
|
return intrapred_16x16_mbaff(currMB, pl, predmode);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return intrapred_16x16_normal(currMB, pl, predmode);
|
return intrapred_16x16_normal(currMB, pl, predmode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "image.h"
|
||||||
#include "intra16x16_pred.h"
|
#include "intra16x16_pred.h"
|
||||||
#include "mb_access.h"
|
#include "mb_access.h"
|
||||||
#include "image.h"
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
|
@ -29,8 +29,7 @@
|
||||||
*
|
*
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
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;
|
Slice *currSlice = currMB->p_Slice;
|
||||||
VideoParameters *p_Vid = currMB->p_Vid;
|
VideoParameters *p_Vid = currMB->p_Vid;
|
||||||
|
|
||||||
|
@ -38,7 +37,8 @@ static int intra16x16_dc_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
|
|
||||||
int i, j;
|
int i, 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;
|
||||||
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
||||||
|
|
||||||
PixelPos b; //!< pixel position p(0,-1)
|
PixelPos b; //!< pixel position p(0,-1)
|
||||||
|
@ -48,28 +48,25 @@ static int intra16x16_dc_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
|
|
||||||
s1 = s2 = 0;
|
s1 = s2 = 0;
|
||||||
|
|
||||||
for (i=0;i<17;++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, -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)
|
if (!p_Vid->active_pps->constrained_intra_pred_flag) {
|
||||||
{
|
|
||||||
up_avail = b.available;
|
up_avail = b.available;
|
||||||
left_avail = left[1].available;
|
left_avail = left[1].available;
|
||||||
left_up_avail = left[0].available;
|
left_up_avail = left[0].available;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
||||||
for (i = 1, left_avail = 1; i < 17; ++i)
|
for (i = 1, left_avail = 1; i < 17; ++i)
|
||||||
left_avail &= left[i].available ? currSlice->intra_block[left[i].mb_addr]: 0;
|
left_avail &=
|
||||||
left_up_avail = left[0].available ? currSlice->intra_block[left[0].mb_addr]: 0;
|
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)
|
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)
|
if (left_avail)
|
||||||
|
@ -82,15 +79,14 @@ static int intra16x16_dc_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
else if (up_avail && !left_avail)
|
else if (up_avail && !left_avail)
|
||||||
s0 = (s1 + 8) >> 4; // left edge
|
s0 = (s1 + 8) >> 4; // left edge
|
||||||
else
|
else
|
||||||
s0 = p_Vid->dc_pred_value_comp[pl]; // top left corner, nothing to predict from
|
s0 = p_Vid->dc_pred_value_comp[pl]; // top left corner, nothing to predict
|
||||||
|
// from
|
||||||
|
|
||||||
for(j = 0; j < MB_BLOCK_SIZE; ++j)
|
for (j = 0; j < MB_BLOCK_SIZE; ++j) {
|
||||||
{
|
|
||||||
#if (IMGTYPE == 0)
|
#if (IMGTYPE == 0)
|
||||||
memset(mb_pred[j], s0, MB_BLOCK_SIZE * sizeof(imgpel));
|
memset(mb_pred[j], s0, MB_BLOCK_SIZE * sizeof(imgpel));
|
||||||
#else
|
#else
|
||||||
for(i = 0; i < MB_BLOCK_SIZE; ++i)
|
for (i = 0; i < MB_BLOCK_SIZE; ++i) {
|
||||||
{
|
|
||||||
mb_pred[j][i] = (imgpel)s0;
|
mb_pred[j][i] = (imgpel)s0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -99,8 +95,6 @@ static int intra16x16_dc_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
return DECODING_OK;
|
return DECODING_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -111,14 +105,14 @@ static int intra16x16_dc_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
*
|
*
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
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;
|
Slice *currSlice = currMB->p_Slice;
|
||||||
VideoParameters *p_Vid = currMB->p_Vid;
|
VideoParameters *p_Vid = currMB->p_Vid;
|
||||||
|
|
||||||
int j;
|
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)
|
||||||
|
|
||||||
|
@ -127,12 +121,9 @@ static int intra16x16_vert_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
// getNonAffNeighbour(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);
|
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;
|
up_avail = b.available;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,8 +133,7 @@ static int intra16x16_vert_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
imgpel **prd = &currSlice->mb_pred[pl][0];
|
imgpel **prd = &currSlice->mb_pred[pl][0];
|
||||||
imgpel *src = &(imgY[b.pos_y][b.pos_x]);
|
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));
|
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,7 +144,6 @@ static int intra16x16_vert_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
return DECODING_OK;
|
return DECODING_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -165,13 +154,13 @@ static int intra16x16_vert_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
*
|
*
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
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;
|
Slice *currSlice = currMB->p_Slice;
|
||||||
VideoParameters *p_Vid = currMB->p_Vid;
|
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 **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1]
|
||||||
|
: currSlice->dec_picture->imgY;
|
||||||
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
||||||
imgpel prediction;
|
imgpel prediction;
|
||||||
|
|
||||||
|
@ -179,28 +168,25 @@ static int intra16x16_hor_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
|
|
||||||
int left_avail, left_up_avail;
|
int left_avail, left_up_avail;
|
||||||
|
|
||||||
for (i=0;i<17;++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, -1, i - 1, p_Vid->mb_size[IS_LUMA], &left[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p_Vid->active_pps->constrained_intra_pred_flag)
|
if (!p_Vid->active_pps->constrained_intra_pred_flag) {
|
||||||
{
|
|
||||||
left_avail = left[1].available;
|
left_avail = left[1].available;
|
||||||
left_up_avail = left[0].available;
|
left_up_avail = left[0].available;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
for (i = 1, left_avail = 1; i < 17; ++i)
|
for (i = 1, left_avail = 1; i < 17; ++i)
|
||||||
left_avail &= left[i].available ? currSlice->intra_block[left[i].mb_addr]: 0;
|
left_avail &=
|
||||||
left_up_avail = left[0].available ? currSlice->intra_block[left[0].mb_addr]: 0;
|
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)
|
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)
|
for (j = 0; j < MB_BLOCK_SIZE; ++j) {
|
||||||
{
|
|
||||||
prediction = imgY[left[j + 1].pos_y][left[j + 1].pos_x];
|
prediction = imgY[left[j + 1].pos_y][left[j + 1].pos_x];
|
||||||
for (i = 0; i < MB_BLOCK_SIZE; ++i)
|
for (i = 0; i < MB_BLOCK_SIZE; ++i)
|
||||||
mb_pred[j][i] = prediction; // store predicted 16x16 block
|
mb_pred[j][i] = prediction; // store predicted 16x16 block
|
||||||
|
@ -219,8 +205,7 @@ static int intra16x16_hor_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
*
|
*
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
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;
|
Slice *currSlice = currMB->p_Slice;
|
||||||
VideoParameters *p_Vid = currMB->p_Vid;
|
VideoParameters *p_Vid = currMB->p_Vid;
|
||||||
|
|
||||||
|
@ -229,7 +214,8 @@ static int intra16x16_plane_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
int ih = 0, iv = 0;
|
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 **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1]
|
||||||
|
: currSlice->dec_picture->imgY;
|
||||||
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);
|
||||||
imgpel *mpr_line;
|
imgpel *mpr_line;
|
||||||
int max_imgpel_value = p_Vid->max_pel_value_comp[pl];
|
int max_imgpel_value = p_Vid->max_pel_value_comp[pl];
|
||||||
|
@ -239,48 +225,46 @@ static int intra16x16_plane_pred_mbaff(Macroblock *currMB, ColorPlane pl)
|
||||||
|
|
||||||
int up_avail, left_avail, left_up_avail;
|
int up_avail, left_avail, left_up_avail;
|
||||||
|
|
||||||
for (i=0;i<17; ++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, -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)
|
if (!p_Vid->active_pps->constrained_intra_pred_flag) {
|
||||||
{
|
|
||||||
up_avail = b.available;
|
up_avail = b.available;
|
||||||
left_avail = left[1].available;
|
left_avail = left[1].available;
|
||||||
left_up_avail = left[0].available;
|
left_up_avail = left[0].available;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
up_avail = b.available ? currSlice->intra_block[b.mb_addr] : 0;
|
||||||
for (i = 1, left_avail = 1; i < 17; ++i)
|
for (i = 1, left_avail = 1; i < 17; ++i)
|
||||||
left_avail &= left[i].available ? currSlice->intra_block[left[i].mb_addr]: 0;
|
left_avail &=
|
||||||
left_up_avail = left[0].available ? currSlice->intra_block[left[0].mb_addr]: 0;
|
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)
|
if (!up_avail || !left_up_avail || !left_avail)
|
||||||
error("invalid 16x16 intra pred Mode PLANE_16", 500);
|
error("invalid 16x16 intra pred Mode PLANE_16", 500);
|
||||||
|
|
||||||
mpr_line = &imgY[b.pos_y][b.pos_x + 7];
|
mpr_line = &imgY[b.pos_y][b.pos_x + 7];
|
||||||
for (i = 1; i < 8; ++i)
|
for (i = 1; i < 8; ++i) {
|
||||||
{
|
|
||||||
ih += i * (mpr_line[i] - mpr_line[-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]);
|
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]);
|
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]);
|
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;
|
ib = (5 * ih + 32) >> 6;
|
||||||
ic = (5 * iv + 32) >> 6;
|
ic = (5 * iv + 32) >> 6;
|
||||||
|
|
||||||
iaa = 16 * (mpr_line[8] + imgY[left[16].pos_y][left[16].pos_x]);
|
iaa = 16 * (mpr_line[8] + imgY[left[16].pos_y][left[16].pos_x]);
|
||||||
for (j = 0;j < MB_BLOCK_SIZE; ++j)
|
for (j = 0; j < MB_BLOCK_SIZE; ++j) {
|
||||||
{
|
for (i = 0; i < MB_BLOCK_SIZE; ++i) {
|
||||||
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));
|
||||||
mb_pred[j][i] = (imgpel) iClip1(max_imgpel_value, ((iaa + (i - 7) * ib + (j - 7) * ic + 16) >> 5));
|
|
||||||
}
|
}
|
||||||
} // store plane prediction
|
} // store plane prediction
|
||||||
|
|
||||||
|
@ -301,8 +285,7 @@ int intrapred_16x16_mbaff(Macroblock *currMB, //!< Current Macroblock
|
||||||
ColorPlane pl, //!< Current colorplane (for 4:4:4)
|
ColorPlane pl, //!< Current colorplane (for 4:4:4)
|
||||||
int predmode) //!< prediction mode
|
int predmode) //!< prediction mode
|
||||||
{
|
{
|
||||||
switch (predmode)
|
switch (predmode) {
|
||||||
{
|
|
||||||
case VERT_PRED_16: // vertical prediction from block above
|
case VERT_PRED_16: // vertical prediction from block above
|
||||||
return (intra16x16_vert_pred_mbaff(currMB, pl));
|
return (intra16x16_vert_pred_mbaff(currMB, pl));
|
||||||
break;
|
break;
|
||||||
|
@ -315,11 +298,9 @@ int intrapred_16x16_mbaff(Macroblock *currMB, //!< Current Macroblock
|
||||||
case PLANE_16: // 16 bit integer plan pred
|
case PLANE_16: // 16 bit integer plan pred
|
||||||
return (intra16x16_plane_pred_mbaff(currMB, pl));
|
return (intra16x16_plane_pred_mbaff(currMB, pl));
|
||||||
break;
|
break;
|
||||||
default:
|
default: { // indication of fault in bitstream,exit
|
||||||
{ // indication of fault in bitstream,exit
|
|
||||||
printf("illegal 16x16 intra prediction mode input: %d\n", predmode);
|
printf("illegal 16x16 intra prediction mode input: %d\n", predmode);
|
||||||
return SEARCH_SYNC;
|
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