-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x264: add compilation script #84
Draft
niewim19
wants to merge
10
commits into
master
Choose a base branch
from
niewim19/x264
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d9ec425
x264: preliminary compilation script
niewim19 dde8200
x264: add `mmap()` arguments allignment
niewim19 01131fe
x264: switch to tarball download
niewim19 7ac82b3
xc264: adjust stack size
niewim19 18b1fc7
x264: disable malloc.h usage
niewim19 4efb0f1
x264: disable threading throug option, not patch
niewim19 dbf53c3
x264: reformat `input.patch` with `#ifdef phoenix`
niewim19 301e65c
x264: do not use `master` branch for source code
niewim19 8faa78d
x264: describe oconfiguration options
niewim19 6778959
x264: enable asm optimization for armv7a9 platform
niewim19 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
PREFIX_X264="${PREFIX_PROJECT}/phoenix-rtos-ports/x264" | ||
PREFIX_X264_BUILD="${PREFIX_BUILD}/x264" | ||
PREFIX_X264_CONFIG="${PREFIX_X264}/patches" | ||
PREFIX_X264_MARKERS="${PREFIX_X264_BUILD}/markers" | ||
|
||
PKG_NAME="x264-master.tar.bz2" | ||
PKG_URL="https://code.videolan.org/videolan/x264/-/archive/master" | ||
niewim19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
b_log "Building x264" | ||
|
||
# | ||
# Download archived source code | ||
# | ||
if [ ! -f "$PREFIX_X264/${PKG_NAME}" ]; then | ||
if ! wget "${PKG_URL}/${PKG_NAME}" -O "${PREFIX_X264}/${PKG_NAME}" --no-check-certificate; then | ||
echo "Mirror unavailable" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# | ||
# Unpack source code | ||
# | ||
if [ ! -d "${PREFIX_X264_BUILD}" ]; then | ||
tar -xjf "${PREFIX_X264}/${PKG_NAME}" -C "${PREFIX_BUILD}" | ||
(cd "${PREFIX_BUILD}" && mv x264-master x264) | ||
mkdir -p "${PREFIX_X264_MARKERS}" | ||
fi | ||
|
||
# | ||
# Apply patches | ||
# | ||
for patchfile in "$PREFIX_X264_CONFIG"/*.patch; do | ||
if [ ! -f "$PREFIX_X264_MARKERS/$(basename "$patchfile").applied" ]; then | ||
echo "applying patch: $patchfile" | ||
patch -d "$PREFIX_X264_BUILD" -p1 < "$patchfile" | ||
touch "$PREFIX_X264_MARKERS/$(basename "$patchfile").applied" | ||
fi | ||
done | ||
|
||
# | ||
# Prepare CFLAGS and LDFLAGS for x264 configure & Makefile | ||
# | ||
export LDFLAGS_EXTRA="${CFLAGS} ${LDFLAGS} -Wl,-z,stack-size=65536" | ||
export CFLAGS_EXTRA="${CFLAGS}" | ||
export LDFLAGS="" | ||
export CFLAGS="" | ||
|
||
# | ||
# Build and install x264 binary | ||
# | ||
(cd "$PREFIX_X264_BUILD" && ./configure --extra-cflags="$CFLAGS_EXTRA" --extra-ldflags="$LDFLAGS_EXTRA" --cross-prefix="$CROSS" --sysroot="$PREFIX_BUILD/sysroot/" --host=arm-linux --disable-asm --disable-avs --disable-lavf --enable-pic --enable-static --disable-opencl) | ||
niewim19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(cd "$PREFIX_X264_BUILD" && make) | ||
|
||
cp -a "${PREFIX_X264_BUILD}/x264" "$PREFIX_PROG_STRIPPED" | ||
b_install "$PREFIX_PORTS_INSTALL/x264" /bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- x264_org/common/base.c 2024-08-30 14:07:49.183495538 +0200 | ||
+++ x264/common/base.c 2024-08-30 14:14:26.584633533 +0200 | ||
@@ -37,6 +37,12 @@ | ||
|
||
#define X264_ISDIGIT(x) isdigit((unsigned char)(x)) | ||
|
||
+/* PHOENIX-RTOS patch: memalign is not supported by Phoenix-RTOS, use malloc as placeholder */ | ||
+void *memalign(size_t alignment, size_t size) | ||
+{ | ||
+ return malloc(size); | ||
niewim19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+} | ||
+ | ||
/**************************************************************************** | ||
* x264_reduce_fraction: | ||
****************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- x264_org/common/cpu.c 2024-08-30 14:07:49.184495508 +0200 | ||
+++ x264/common/cpu.c 2024-08-30 14:12:25.631746608 +0200 | ||
@@ -516,17 +516,22 @@ | ||
// Android NDK does not expose sched_getaffinity | ||
return sysconf( _SC_NPROCESSORS_CONF ); | ||
#else | ||
- cpu_set_t p_aff; | ||
- memset( &p_aff, 0, sizeof(p_aff) ); | ||
- if( sched_getaffinity( 0, sizeof(p_aff), &p_aff ) ) | ||
- return 1; | ||
-#if HAVE_CPU_COUNT | ||
- return CPU_COUNT(&p_aff); | ||
-#else | ||
- int np = 0; | ||
- for( size_t bit = 0; bit < 8 * sizeof(p_aff); bit++ ) | ||
- np += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1; | ||
- return np; | ||
+ /* Phoenix-RTOS patch - no support for 'cpu_set_t' which is part of GNU extension */ | ||
+ /* Return 1 as available processor count */ | ||
+ return 1; | ||
+#if 0 | ||
niewim19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ cpu_set_t p_aff; | ||
+ memset( &p_aff, 0, sizeof(p_aff) ); | ||
+ if( sched_getaffinity( 0, sizeof(p_aff), &p_aff ) ) | ||
+ return 1; | ||
+ #if HAVE_CPU_COUNT | ||
+ return CPU_COUNT(&p_aff); | ||
+ #else | ||
+ int np = 0; | ||
+ for( size_t bit = 0; bit < 8 * sizeof(p_aff); bit++ ) | ||
+ np += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1; | ||
+ return np; | ||
+#endif | ||
#endif | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
--- x264_org/input/input.c 2024-09-05 11:57:22.943594154 +0200 | ||
+++ x264/input/input.c 2024-09-05 11:57:41.344630765 +0200 | ||
@@ -227,6 +227,15 @@ | ||
} | ||
#else | ||
size_t padded_size = size + MMAP_PADDING; | ||
+ /** | ||
+ * PHOENIX-RTOS PATCH | ||
+ * | ||
+ * Phoenix implementation of mmap() fails if `size` is not aligned to page size | ||
+ * It is important to remove this patch when this issue is resolved. | ||
+ * | ||
+ * https://github.com/phoenix-rtos/phoenix-rtos-project/issues/1155 | ||
+ */ | ||
+ padded_size = (1 + padded_size / SIZE_PAGE) * SIZE_PAGE; | ||
nalajcie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if( (base = mmap( NULL, padded_size, PROT_READ, MAP_PRIVATE, h->fd, offset )) != MAP_FAILED ) | ||
{ | ||
/* Ask the OS to readahead pages. This improves performance whereas | ||
@@ -241,9 +250,19 @@ | ||
/* Remap the file mapping of any padding that crosses a page boundary past the end of | ||
* the file into a copy of the last valid page to prevent reads from invalid memory. */ | ||
size_t aligned_size = (padded_size - 1) & ~h->align_mask; | ||
- if( offset + aligned_size >= h->file_size ) | ||
- mmap( base + aligned_size, padded_size - aligned_size, PROT_READ, MAP_PRIVATE|MAP_FIXED, h->fd, (offset + size - 1) & ~h->align_mask ); | ||
- | ||
+ /** | ||
niewim19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ * PHOENIX-RTOS PATCH | ||
+ * | ||
+ * Phoenix implementation of mmap() fails if `size` is not aligned to page size | ||
+ * It is important to remove this patch when this issue is resolved. | ||
+ * | ||
+ * https://github.com/phoenix-rtos/phoenix-rtos-project/issues/1155 | ||
+ */ | ||
+ if( offset + aligned_size >= h->file_size ) { | ||
+ size_t paddedMinusAligned_aligned = (padded_size - aligned_size); | ||
+ paddedMinusAligned_aligned = (1 + paddedMinusAligned_aligned / SIZE_PAGE) * SIZE_PAGE; | ||
+ mmap( base + aligned_size, paddedMinusAligned_aligned, PROT_READ, MAP_PRIVATE|MAP_FIXED, h->fd, (offset + size - 1) & ~h->align_mask ); | ||
+ } | ||
return base + align; | ||
} | ||
#endif | ||
@@ -272,3 +291,4 @@ | ||
CloseHandle( h->map_handle ); | ||
#endif | ||
} | ||
+ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to base new ports on this redesign: #78
I hope it will be merged soon @Darchiv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that! I didn`t notice this PR. I will wait for that PR to be merged and then redo this script.