diff --git a/.github/ISSUE_TEMPLATE/1-bug.yml b/.github/ISSUE_TEMPLATE/1-bug.yml deleted file mode 100644 index d3e19d8ae..000000000 --- a/.github/ISSUE_TEMPLATE/1-bug.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Bug Issue -description: Use template to submit a Bug -title: "[Bug]: " -assignees: - - yefeizhou -body: -- type: dropdown - id: component - attributes: - label: Which component impacted? - multiple: true - options: - - Decode - - Encode - - Video Processing - - Build - - Not sure -- type: dropdown - id: regression - attributes: - label: Is it regression? Good in old configuration? - multiple: false - options: - - Yes, it's good in old version - - No, this issue exist a long time -- type: textarea - attributes: - label: What happened? - description: | - Please provide reproduce steps and sample cmdline if possible which help us to debug it. - If it's regression, please provide good/bad commit/configuration. - placeholder: | - 1. In Linux or Windows or Browser or Applications... - 2. With libva/libva-utils/gmmlib/media-driver version... - 3. Run '...' - 4. See error... - validations: - required: true -- type: dropdown - id: usage - attributes: - label: What's the usage scenario when you are seeing the problem? - multiple: true - options: - - Transcode for media delivery - - Playback - - Web browser - - Cloud Gaming - - Video Analytics - - Video Conference - - Immersive Media - - Content Creation - - Game Streaming - - Others - validations: - required: true -- type: textarea - attributes: - label: What impacted? - description: Any program or milestone would be impacted if issue yet resolved? Please provide the information as detail as possible to help us understand and prioritize the issues. - placeholder: If you select "Others" for above usage, please describe your usage scenario here to help us understand the impact. - validations: - required: false -- type: textarea - attributes: - label: Debug Information - description: | - Please provide debug information as detail as possible to accelerate issue resolved. - 1. What's libva/libva-utils/gmmlib/media-driver version? - 2. Could you confirm whether GPU hardware exist or not by `ls /dev/dri`? - 3. Could you provide vainfo log by `vainfo >vainfo.log 2>&1`? - 4. Could you provide libva trace log? Run cmd `export LIBVA_TRACE=/tmp/libva_trace.log` first then execute the case. - 5. Could you attach dmesg log if GPU hang by `dmesg >dmesg.log 2>&1`? - validations: - required: false -- type: dropdown - id: contribute - attributes: - label: Do you want to contribute a patch to fix the issue? - multiple: false - options: - - Yes, I'm glad to submit a patch to fix it - - No. diff --git a/.github/ISSUE_TEMPLATE/2-feature.yml b/.github/ISSUE_TEMPLATE/2-feature.yml deleted file mode 100644 index 9812490e3..000000000 --- a/.github/ISSUE_TEMPLATE/2-feature.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Feature Request -description: Use template to request a new feature -title: "[Feature]: " -labels: ["Feature Request"] -assignees: - - yefeizhou -body: -- type: textarea - attributes: - label: What Feature? - description: Please describe what feature you request and more background why you need this feature. - validations: - required: true -- type: dropdown - id: usage - attributes: - label: What's the usage scenario would be benifited? - multiple: true - options: - - Transcode for media delivery - - Playback - - Web browser - - Cloud Gaming - - Video Analytics - - Video Conference - - Immersive Media - - Content Creation - - Game Streaming - - Others - validations: - required: true -- type: textarea - attributes: - label: What impacted? - description: Any program or milestone would be benifited once the feature is enabled. Please provide the information as detail as possible to help us understand and prioritize the feature request. - placeholder: If you select "Others" for above usage, please describe your usage scenario here to help us understand the impact. - validations: - required: false -- type: dropdown - id: contribute - attributes: - label: Do you want to contribute a patch to develop this feature? - multiple: false - options: - - Yes, I'm glad to submit a patch for it - - No. \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..790926080 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,68 @@ +name: CI Workflow + +on: + pull_request_target: + types: "*" + branches: "**" +permissions: read-all + +jobs: + Trigger_Workflows: + runs-on: ubuntu-latest + name: CI Workflow + steps: + - name: Get Token + run: | + retries=3 + while [ $retries -gt 0 ]; do + if RESPONSE=$(curl --silent --location "${{ secrets.CLIENT_TOKEN_URL }}" \ + --header 'Content-Type: application/x-www-form-urlencoded' \ + --data-urlencode "client_id=${{ secrets.CLIENT_ID }}" \ + --data-urlencode "client_secret=${{ secrets.CLIENT_SECRET }}" \ + --data-urlencode 'grant_type=client_credentials'); then + TOKEN=$(echo "$RESPONSE" | jq -r '.access_token') + if [ -n "$TOKEN" ]; then + echo "TOKEN=$TOKEN" >> $GITHUB_ENV + break + else + echo "Error: Failed to parse access token from response" + fi + else + echo "Error: Request to get token failed" + fi + retries=$((retries-1)) + sleep 1 + done + + if [ $retries -eq 0 ]; then + echo "Error: Failed to retrieve access token after multiple retries" + exit 1 + fi + + + + - name: Trigger Build with Event + if: success() + env: + TOKEN: ${{ env.TOKEN }} + run: | + EVENT_DATA='${{ toJSON(github.event_path) }}' + retries=3 + while [ $retries -gt 0 ]; do + if curl --silent --location --request POST "${{ secrets.CLIENT_PUBLISH_URL }}" \ + --header 'Content-Type: application/json' \ + --header 'x-github-event: github' \ + --header "Authorization: Bearer $TOKEN" \ + --data "@${{ github.event_path }}"; then + break + else + echo "Error: Failed to trigger build" + fi + retries=$((retries-1)) + sleep 1 + done + + if [ $retries -eq 0 ]; then + echo "Error: Failed to trigger build after multiple retries" + exit 1 + fi diff --git a/.github/workflows/publish_review_event.yaml b/.github/workflows/publish_review_event.yaml new file mode 100644 index 000000000..8175520da --- /dev/null +++ b/.github/workflows/publish_review_event.yaml @@ -0,0 +1,96 @@ +name: Publish Review Event + +on: + workflow_run: + workflows: ["Store_Review_Event"] + types: + - completed +permissions: read-all + +jobs: + fetch_and_process: + runs-on: ubuntu-latest + steps: + - name: 'Download artifact' + uses: actions/github-script@v6 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "eventjson" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/eventjson.zip`, Buffer.from(download.data)); + + - name: 'Unzip artifact' + run: | + ls + unzip eventjson.zip + + - name: Get Token + run: | + retries=3 + while [ $retries -gt 0 ]; do + if RESPONSE=$(curl --silent --location "${{ secrets.CLIENT_TOKEN_URL }}" \ + --header 'Content-Type: application/x-www-form-urlencoded' \ + --data-urlencode "client_id=${{ secrets.CLIENT_ID }}" \ + --data-urlencode "client_secret=${{ secrets.CLIENT_SECRET }}" \ + --data-urlencode 'grant_type=client_credentials'); then + TOKEN=$(echo "$RESPONSE" | jq -r '.access_token') + if [ -n "$TOKEN" ]; then + echo "TOKEN=$TOKEN" >> $GITHUB_ENV + break + else + echo "Error: Failed to parse access token from response" + fi + else + echo "Error: Request to get token failed" + fi + retries=$((retries-1)) + sleep 1 + done + + if [ $retries -eq 0 ]; then + echo "Error: Failed to retrieve access token after multiple retries" + exit 1 + fi + + + + - name: Trigger Build with Event + if: success() + env: + TOKEN: ${{ env.TOKEN }} + run: | + + EVENT_DATA=$(cat event.json) + + retries=3 + while [ $retries -gt 0 ]; do + if curl --silent --location --request POST "${{ secrets.CLIENT_PUBLISH_URL }}" \ + --header 'Content-Type: application/json' \ + --header 'x-github-event: github' \ + --header "Authorization: Bearer $TOKEN" \ + --data "$EVENT_DATA"; then + break + else + echo "Error: Failed to trigger build" + fi + retries=$((retries-1)) + sleep 1 + done + + if [ $retries -eq 0 ]; then + echo "Error: Failed to trigger build after multiple retries" + exit 1 + fi diff --git a/.github/workflows/store_review_event.yaml b/.github/workflows/store_review_event.yaml new file mode 100644 index 000000000..703b24063 --- /dev/null +++ b/.github/workflows/store_review_event.yaml @@ -0,0 +1,18 @@ +name: Store_Review_Event + +on: + pull_request_review: + types: "**" +permissions: read-all + +jobs: + Store_Review_Event: + runs-on: ubuntu-latest + name: Store Review Event + steps: + - name: Upload event JSON as artifact + uses: actions/upload-artifact@v4 + with: + name: eventjson + path: "${{ github.event_path }}" + retention-days: 7 \ No newline at end of file diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml deleted file mode 100644 index 7191349a6..000000000 --- a/.github/workflows/ubuntu.yml +++ /dev/null @@ -1,363 +0,0 @@ -name: ci - -on: [ push, pull_request ] - -env: - CFLAGS: -O2 -Wformat -Wformat-security -Wall -Werror -D_FORTIFY_SOURCE=2 -fstack-protector-strong - LDFLAGS: -Wl,--as-needed - -jobs: - clang14: - runs-on: ubuntu-22.04 - env: - CC: /usr/bin/clang-14 - CXX: /usr/bin/clang++-14 - ASM: /usr/bin/clang-14 - steps: - - name: checkout libmfxgen - uses: actions/checkout@v2 - with: - path: libmfxgen - - name: checkout libva - uses: actions/checkout@v2 - with: - repository: intel/libva - path: libva - - name: install toolchain - run: | - if [[ -e $CC && -e $CXX ]]; then \ - echo "clang-14 already presents in the image"; \ - else \ - echo "clang-14 missed in the image, installing from llvm"; \ - echo "deb [trusted=yes] https://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main" | sudo tee -a /etc/apt/sources.list; \ - sudo apt-get update; \ - sudo apt-get install -y --no-install-recommends clang-14; \ - fi - - name: install prerequisites - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - cmake \ - libdrm-dev \ - libegl1-mesa-dev \ - libgl1-mesa-dev \ - libx11-dev \ - libx11-xcb-dev \ - libxcb-dri3-dev \ - libxcb-present-dev \ - libxext-dev \ - libxfixes-dev \ - libwayland-dev \ - ninja-build \ - make - - name: print tools versions - run: | - cmake --version - $CC --version - $CXX --version - - name: build libva - run: | - cd libva - ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu - make -j$(nproc) - sudo make install - - name: build libmfxgen - run: | - cd libmfxgen - mkdir build && cd build - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DMFX_ENABLE_PXP=ON -DCMAKE_C_FLAGS_RELEASE="$CFLAGS" -DCMAKE_CXX_FLAGS_RELEASE="$CFLAGS" .. - ninja - sudo ninja install - - clang14-enctools-full: - runs-on: ubuntu-22.04 - env: - CC: /usr/bin/clang-14 - CXX: /usr/bin/clang++-14 - ASM: /usr/bin/clang-14 - steps: - - name: checkout libmfxgen - uses: actions/checkout@v2 - with: - path: libmfxgen - - name: checkout libva - uses: actions/checkout@v2 - with: - repository: intel/libva - path: libva - - name: install toolchain - run: | - if [[ -e $CC && -e $CXX ]]; then \ - echo "clang-14 already presents in the image"; \ - else \ - echo "clang-14 missed in the image, installing from llvm"; \ - echo "deb [trusted=yes] https://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main" | sudo tee -a /etc/apt/sources.list; \ - sudo apt-get update; \ - sudo apt-get install -y --no-install-recommends clang-14; \ - fi - - name: install prerequisites - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - cmake \ - libdrm-dev \ - libegl1-mesa-dev \ - libgl1-mesa-dev \ - libx11-dev \ - libx11-xcb-dev \ - libxcb-dri3-dev \ - libxcb-present-dev \ - libxext-dev \ - libxfixes-dev \ - libwayland-dev \ - ninja-build \ - make - - name: print tools versions - run: | - cmake --version - $CC --version - $CXX --version - - name: build libva - run: | - cd libva - ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu - make -j$(nproc) - sudo make install - - name: build libmfxgen - run: | - cd libmfxgen - mkdir build && cd build - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="$CFLAGS" -DCMAKE_CXX_FLAGS_RELEASE="$CFLAGS" \ - -DMFX_ENABLE_USER_ENCTOOLS=ON -DMFX_ENABLE_AENC=ON -DMFX_ENABLE_PXP=ON \ - .. - ninja - sudo ninja install - - clang14-enctools-noaenc: - runs-on: ubuntu-22.04 - env: - CC: /usr/bin/clang-14 - CXX: /usr/bin/clang++-14 - ASM: /usr/bin/clang-14 - steps: - - name: checkout libmfxgen - uses: actions/checkout@v2 - with: - path: libmfxgen - - name: checkout libva - uses: actions/checkout@v2 - with: - repository: intel/libva - path: libva - - name: install toolchain - run: | - if [[ -e $CC && -e $CXX ]]; then \ - echo "clang-14 already presents in the image"; \ - else \ - echo "clang-14 missed in the image, installing from llvm"; \ - echo "deb [trusted=yes] https://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main" | sudo tee -a /etc/apt/sources.list; \ - sudo apt-get update; \ - sudo apt-get install -y --no-install-recommends clang-14; \ - fi - - name: install prerequisites - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - cmake \ - libdrm-dev \ - libegl1-mesa-dev \ - libgl1-mesa-dev \ - libx11-dev \ - libx11-xcb-dev \ - libxcb-dri3-dev \ - libxcb-present-dev \ - libxext-dev \ - libxfixes-dev \ - libwayland-dev \ - ninja-build \ - make - - name: print tools versions - run: | - cmake --version - $CC --version - $CXX --version - - name: build libva - run: | - cd libva - ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu - make -j$(nproc) - sudo make install - - name: build libmfxgen - run: | - cd libmfxgen - mkdir build && cd build - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="$CFLAGS" -DCMAKE_CXX_FLAGS_RELEASE="$CFLAGS" \ - -DMFX_ENABLE_USER_ENCTOOLS=ON -DMFX_ENABLE_AENC=OFF -DMFX_ENABLE_PXP=ON \ - .. - ninja - sudo ninja install - - clang12: - runs-on: ubuntu-20.04 - env: - CC: /usr/bin/clang-12 - CXX: /usr/bin/clang++-12 - ASM: /usr/bin/clang-12 - steps: - - name: checkout libmfxgen - uses: actions/checkout@v2 - with: - path: libmfxgen - - name: checkout libva - uses: actions/checkout@v2 - with: - repository: intel/libva - path: libva - - name: install prerequisites - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - cmake \ - libdrm-dev \ - libegl1-mesa-dev \ - libgl1-mesa-dev \ - libx11-dev \ - libx11-xcb-dev \ - libxcb-dri3-dev \ - libxcb-present-dev \ - libxext-dev \ - libxfixes-dev \ - libwayland-dev \ - ninja-build \ - make - - name: print tools versions - run: | - cmake --version - $CC --version - $CXX --version - - name: build libva - run: | - cd libva - ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu - make -j$(nproc) - sudo make install - - name: build libmfxgen - run: | - cd libmfxgen - mkdir build && cd build - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DMFX_ENABLE_PXP=ON -DCMAKE_C_FLAGS_RELEASE="$CFLAGS" -DCMAKE_CXX_FLAGS_RELEASE="$CFLAGS" .. - ninja - sudo ninja install - - gcc11: - runs-on: ubuntu-22.04 - env: - CC: /usr/bin/gcc-11 - CXX: /usr/bin/g++-11 - ASM: /usr/bin/gcc-11 - # TODO: mind no -Werror - # We stepped into https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100366 - # gcc-11 throws -Wstringop-overflow on some std:: operations - CFLAGS: -O2 -Wformat -Wformat-security -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong - steps: - - name: checkout libmfxgen - uses: actions/checkout@v2 - with: - path: libmfxgen - - name: checkout libva - uses: actions/checkout@v2 - with: - repository: intel/libva - path: libva - - name: install prerequisites - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - automake \ - cmake \ - gcc \ - g++ \ - libtool \ - libdrm-dev \ - libegl1-mesa-dev \ - libgl1-mesa-dev \ - libx11-dev \ - libx11-xcb-dev \ - libxcb-dri3-dev \ - libxcb-present-dev \ - libxext-dev \ - libxfixes-dev \ - libwayland-dev \ - ninja-build \ - pkg-config \ - make - - name: print tools versions - run: | - cmake --version - $CC --version - $CXX --version - - name: build libva - run: | - cd libva - ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu - make -j$(nproc) - sudo make install - - name: build libmfxgen - run: | - cd libmfxgen - mkdir build && cd build - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DMFX_ENABLE_PXP=ON -DCMAKE_C_FLAGS_RELEASE="$CFLAGS" -DCMAKE_CXX_FLAGS_RELEASE="$CFLAGS" .. - ninja - sudo ninja install - - gcc10: - runs-on: ubuntu-20.04 - env: - CC: /usr/bin/gcc-10 - CXX: /usr/bin/g++-10 - ASM: /usr/bin/gcc-10 - steps: - - name: checkout libmfxgen - uses: actions/checkout@v2 - with: - path: libmfxgen - - name: checkout libva - uses: actions/checkout@v2 - with: - repository: intel/libva - path: libva - - name: install prerequisites - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - cmake \ - libdrm-dev \ - libegl1-mesa-dev \ - libgl1-mesa-dev \ - libx11-dev \ - libx11-xcb-dev \ - libxcb-dri3-dev \ - libxcb-present-dev \ - libxext-dev \ - libxfixes-dev \ - libwayland-dev \ - ninja-build \ - make - - name: print tools versions - run: | - cmake --version - $CC --version - $CXX --version - - name: build libva - run: | - cd libva - ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu - make -j$(nproc) - sudo make install - - name: build libmfxgen - run: | - cd libmfxgen - mkdir build && cd build - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DMFX_ENABLE_PXP=ON -DCMAKE_C_FLAGS_RELEASE="$CFLAGS" -DCMAKE_CXX_FLAGS_RELEASE="$CFLAGS" .. - ninja - sudo ninja install diff --git a/Android.mk b/Android.mk new file mode 100644 index 000000000..bfaab8bea --- /dev/null +++ b/Android.mk @@ -0,0 +1,4 @@ +MFX_HOME:= $(call my-dir) + +# Recursively call sub-folder Android.mk +include $(call all-subdir-makefiles) diff --git a/_studio/Android.mk b/_studio/Android.mk new file mode 100644 index 000000000..86c9b78c2 --- /dev/null +++ b/_studio/Android.mk @@ -0,0 +1,3 @@ +# Recursively call sub-folder Android.mk + +include $(call all-subdir-makefiles) \ No newline at end of file diff --git a/_studio/enctools/aenc/Android.mk b/_studio/enctools/aenc/Android.mk new file mode 100644 index 000000000..0642b0dc5 --- /dev/null +++ b/_studio/enctools/aenc/Android.mk @@ -0,0 +1,26 @@ +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := $(addprefix src/, aenc.cpp \ + hevc_asc_apq_tree.cpp \ + av1_asc_agop_tree.cpp \ + av1_asc_tree.cpp \ + hevc_asc_agop_tree.cpp \ + av1_asc.cpp) + +LOCAL_C_INCLUDES := \ + $(MFX_INCLUDES_INTERNAL_HW) \ + $(MFX_HOME)/_studio/enctools/aenc/include/ + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -mavx2 \ + -Wno-error \ + -Wno-unused-parameter + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libmfx_aenc +include $(BUILD_STATIC_LIBRARY) diff --git a/_studio/mfx_lib/Android.mk b/_studio/mfx_lib/Android.mk new file mode 100644 index 000000000..a8c0f06ef --- /dev/null +++ b/_studio/mfx_lib/Android.mk @@ -0,0 +1,343 @@ + +LOCAL_PATH:= $(MFX_HOME)/_studio + +# ============================================================================= + +MFX_LOCAL_DECODERS := h265 h264 vc1 mjpeg vp8 vp9 av1 +MFX_LOCAL_ENCODERS := h264 mpeg2 mjpeg vp9 + +# Setting subdirectories to march thru +MFX_LOCAL_DIRS := \ + scheduler/linux \ + +MFX_LOCAL_DIRS_IMPL := \ + $(addprefix decode/, $(MFX_LOCAL_DECODERS)) \ + vpp + +MFX_LOCAL_DIRS_HW := \ + $(addprefix encode_hw/, $(MFX_LOCAL_ENCODERS)) \ + mctf_package/mctf \ + cmrt_cross_platform + +#scheduler/linux/src +MFX_LOCAL_SRC_FILES := \ + $(patsubst $(LOCAL_PATH)/%, %, $(foreach dir, $(MFX_LOCAL_DIRS), $(wildcard $(LOCAL_PATH)/mfx_lib/$(dir)/src/*.cpp))) + +#decode/h265 h264 vc1 mjpeg vp8 vp9 av1/src +MFX_LOCAL_SRC_FILES_IMPL := \ + $(patsubst $(LOCAL_PATH)/%, %, $(foreach dir, $(MFX_LOCAL_DIRS_IMPL), $(wildcard $(LOCAL_PATH)/mfx_lib/$(dir)/src/*.cpp))) + +#encode_hw/h264 mpeg2 mjpeg vp9/src +MFX_LOCAL_SRC_FILES_HW := \ + $(MFX_LOCAL_SRC_FILES_IMPL) \ + $(patsubst $(LOCAL_PATH)/%, %, $(foreach dir, $(MFX_LOCAL_DIRS_HW), $(wildcard $(LOCAL_PATH)/mfx_lib/$(dir)/src/*.cpp))) + +#mpeg2 hw decoder +MFX_LOCAL_SRC_FILES_HW += $(addprefix mfx_lib/decode/mpeg2/hw/src/, \ + mfx_mpeg2_decode.cpp) + +MFX_LOCAL_SRC_FILES_HW += $(addprefix mfx_lib/ext/genx/h264_encode/isa/, \ + genx_simple_me_gen12lp_isa.cpp \ + genx_histogram_gen12lp_isa.cpp) + +MFX_LOCAL_SRC_FILES_HW += \ + mfx_lib/encode_hw/av1/av1ehw_disp.cpp \ + mfx_lib/encode_hw/av1/agnostic/av1ehw_base.cpp \ + mfx_lib/encode_hw/av1/linux/base/av1ehw_base_lin.cpp \ + mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_lin.cpp \ + mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_packer_lin.cpp \ + mfx_lib/encode_hw/av1/linux/base/av1ehw_base_max_frame_size_lin.cpp \ + mfx_lib/encode_hw/av1/agnostic/Xe_HPM/av1ehw_xe_hpm_segmentation.cpp \ + mfx_lib/encode_hw/av1/linux/Xe_HPM/av1ehw_xe_hpm_lin.cpp \ + mfx_lib/encode_hw/av1/linux/Xe_LPM_plus/av1ehw_xe_lpm_plus_lin.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_alloc.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_constraints.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_qmatrix.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_enctools_com.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_general.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_general_defaults.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_impl.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_packer.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_query_impl_desc.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_segmentation.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_task.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_tile.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_encoded_frame_info.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_max_frame_size.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_enctools.cpp \ + mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_hdr.cpp \ + +MFX_LOCAL_SRC_FILES_HW += \ + mfx_lib/encode_hw/hevc/hevcehw_disp.cpp \ + mfx_lib/encode_hw/hevc/agnostic/hevcehw_base.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_impl.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_alloc.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_enctools_com.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_constraints.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_dirty_rect.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_encoded_frame_info.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_encode_stats.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_enctools.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_ext_brc.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_hdr_sei.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_hrd.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_scc.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_interlace.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_legacy.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_legacy_defaults.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_max_frame_size.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_packer.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_parser.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_recon_info.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_rext.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_roi.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_task.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_query_impl_desc.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_weighted_prediction.cpp \ + mfx_lib/encode_hw/hevc/agnostic/g12/hevcehw_g12_caps.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_interlace_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_dirty_rect_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_max_frame_size_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_roi_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_va_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_rext_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_va_packer_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_qp_modulation_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_weighted_prediction_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/g12/hevcehw_g12_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/xe_hpm/hevcehw_xe_hpm_lin.cpp \ + mfx_lib/encode_hw/hevc/linux/xe_lpm_plus/hevcehw_xe_lpm_plus_lin.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_extddi.cpp \ + mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_caps.cpp \ + mfx_lib/encode_hw/shared/ehw_resources_pool.cpp \ + mfx_lib/encode_hw/shared/ehw_task_manager.cpp \ + mfx_lib/encode_hw/shared/ehw_device_vaapi.cpp \ + mfx_lib/encode_hw/shared/ehw_utils_vaapi.cpp \ + mfx_lib/ext/cmrt_cross_platform/src/cm_mem_copy.cpp \ + mfx_lib/ext/cmrt_cross_platform/src/cmrt_cross_platform.cpp \ + mfx_lib/ext/cmrt_cross_platform/src/cmrt_utility.cpp \ + mfx_lib/ext/asc/src/asc_cm.cpp \ + mfx_lib/ext/genx/h264_encode/src/genx_simple_me_proto.cpp \ + +#scheduler/linux/include +MFX_LOCAL_INCLUDES := \ + $(foreach dir, $(MFX_LOCAL_DIRS), $(wildcard $(LOCAL_PATH)/mfx_lib/$(dir)/include)) + +#decode/h265 h264 vc1 mjpeg vp8 vp9 av1/include +MFX_LOCAL_INCLUDES_IMPL := \ + $(MFX_LOCAL_INCLUDES) \ + $(foreach dir, $(MFX_LOCAL_DIRS_IMPL), $(wildcard $(LOCAL_PATH)/mfx_lib/$(dir)/include)) + +#decode/mpeg2/hw/include +MFX_LOCAL_INCLUDES_IMPL += \ + $(MFX_HOME)/_studio/mfx_lib/decode/mpeg2/hw/include + +#encode_hw/h264 mpeg2 mjpeg vp9/include +MFX_LOCAL_INCLUDES_IMPL += \ + $(foreach dir, $(MFX_LOCAL_DIRS_HW), $(wildcard $(LOCAL_PATH)/mfx_lib/$(dir)/include)) + +MFX_LOCAL_INCLUDES_HW := \ + $(MFX_LOCAL_INCLUDES_IMPL) \ + $(MFX_HOME)/_studio/mfx_lib/ext/asc/include \ + $(MFX_HOME)/_studio/mfx_lib/ext/genx/h264_encode/isa \ + $(MFX_HOME)/_studio/mfx_lib/ext/genx/field_copy/isa \ + $(MFX_HOME)/_studio/mfx_lib/ext/genx/copy_kernels/isa \ + $(MFX_HOME)/_studio/mfx_lib/ext/cmrt_cross_platform/include \ + $(MFX_HOME)/_studio/mfx_lib/ext/genx/mctf/isa \ + $(MFX_HOME)/_studio/mfx_lib/ext/genx/asc/isa \ + $(MFX_HOME)/_studio/mfx_lib/ext/h264/include \ + $(MFX_HOME)/_studio/mfx_lib/ext/mpeg2/include \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/av1 \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/av1/agnostic \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/av1/agnostic/base \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/av1/agnostic/Xe_HPM \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/av1/agnostic/Xe_LPM_plus \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/av1/linux \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/av1/linux/base \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/av1/linux/Xe_HPM \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/av1/linux/Xe_LPM_plus \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/hevc \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/hevc/agnostic \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/hevc/agnostic/base \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/hevc/agnostic/g12 \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/hevc/linux \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/hevc/linux/base \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/hevc/linux/g12 \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/hevc/linux/xe_hpm \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/hevc/linux/xe_lpm_plus \ + $(MFX_HOME)/_studio/mfx_lib/encode_hw/shared \ + $(MFX_HOME)/_studio/mfx_lib/shared/include/feature_blocks \ + $(MFX_HOME)/_studio/mfx_lib/scheduler/linux/include \ + $(MFX_HOME)/_studio/shared/asc/include + +MFX_LOCAL_STATIC_LIBRARIES_HW := \ + libmfx_core_hw \ + libumc_codecs_hw \ + libumc_brc \ + libumc_va \ + libumc_core_hw \ + libmfx_gen_trace \ + libmfx_asc \ + libmfx_logging + +MFX_LOCAL_LDFLAGS_HW := \ + $(MFX_LDFLAGS) \ + -Wl,--version-script=$(LOCAL_PATH)/mfx_lib/libmfx-gen.map + +# ============================================================================= + +UMC_DIRS := \ + h264_enc \ + brc + +UMC_DIRS_IMPL := \ + h265_dec h264_dec mpeg2_dec vc1_dec jpeg_dec vp9_dec av1_dec \ + vc1_common jpeg_common color_space_converter + +UMC_LOCAL_INCLUDES := \ + $(foreach dir, $(UMC_DIRS), $(wildcard $(MFX_HOME)/_studio/shared/umc/codec/$(dir)/include)) + +UMC_LOCAL_INCLUDES_IMPL := \ + $(UMC_LOCAL_INCLUDES) \ + $(foreach dir, $(UMC_DIRS_IMPL), $(wildcard $(MFX_HOME)/_studio/shared/umc/codec/$(dir)/include)) + +UMC_LOCAL_INCLUDES_HW := \ + $(UMC_LOCAL_INCLUDES_IMPL) + +# ============================================================================= + +MFX_SHARED_FILES_IMPL := $(addprefix mfx_lib/shared/src/, \ + mfx_feature_blocks_base.cpp \ + mfx_brc_common.cpp \ + mfx_common_decode_int.cpp \ + mfx_common_int.cpp \ + mfx_enc_common.cpp \ + mfx_log.cpp \ + mfx_enc_enctools_common.cpp \ + mfx_mpeg2_dec_common.cpp \ + mfx_vc1_dec_common.cpp \ + mfx_ddi_enc_dump.cpp \ + mfx_vpx_dec_common.cpp) + +MFX_SHARED_FILES_HW := \ + $(MFX_SHARED_FILES_IMPL) + +MFX_SHARED_FILES_HW += $(addprefix mfx_lib/ext/genx/asc/isa/, \ + genx_scd_gen12lp_isa.cpp) + +MFX_SHARED_FILES_HW += $(addprefix mfx_lib/ext/genx/copy_kernels/isa/, \ + genx_copy_kernel_gen12lp_isa.cpp) + +MFX_SHARED_FILES_HW += $(addprefix mfx_lib/ext/genx/field_copy/isa/, \ + genx_fcopy_gen12lp_isa.cpp) + +MFX_SHARED_FILES_HW += $(addprefix mfx_lib/ext/genx/mctf/isa/, \ + genx_me_gen12lp_isa.cpp \ + genx_mc_gen12lp_isa.cpp \ + genx_sd_gen12lp_isa.cpp) + +MFX_SHARED_FILES_HW += $(addprefix mfx_lib/ext/mpeg2/src/, \ + mfx_mpeg2_encode_debug_hw.cpp \ + mfx_mpeg2_encode_full_hw.cpp \ + mfx_mpeg2_encode_hw.cpp \ + mfx_mpeg2_encode_utils_hw.cpp \ + mfx_mpeg2_encode_vaapi.cpp \ + mfx_mpeg2_encode_factory.cpp \ + mfx_mpeg2_enc_common_hw.cpp) + +MFX_SHARED_FILES_HW += $(addprefix mfx_lib/ext/h264/src/, \ + mfx_h264_encode_cm.cpp) + +MFX_LIB_SHARED_FILES_1 := $(addprefix mfx_lib/shared/src/, \ + libmfxsw.cpp \ + libmfxsw_async.cpp \ + libmfxsw_decode.cpp \ + libmfxsw_decode_vp.cpp \ + libmfxsw_functions.cpp \ + libmfxsw_enc.cpp \ + libmfxsw_encode.cpp \ + libmfxsw_pak.cpp \ + libmfxsw_plugin.cpp \ + libmfxsw_query.cpp \ + libmfxsw_session.cpp \ + libmfxsw_vpp.cpp \ + mfx_session.cpp \ + mfx_critical_error_handler.cpp) + +MFX_LIB_SHARED_FILES_2 := $(addprefix shared/src/, \ + fast_copy.cpp \ + fast_copy_c_impl.cpp \ + fast_copy_sse4_impl.cpp \ + mfx_vpp_vaapi.cpp \ + mfx_vpp_helper.cpp \ + libmfx_allocator.cpp \ + libmfx_allocator_vaapi.cpp \ + libmfx_core.cpp \ + libmfx_core_hw.cpp \ + libmfx_core_factory.cpp \ + libmfx_core_vaapi.cpp \ + mfx_umc_alloc_wrapper.cpp \ + mfx_umc_mjpeg_vpp.cpp) + +# ============================================================================= + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := \ + $(MFX_LOCAL_SRC_FILES) \ + $(MFX_LOCAL_SRC_FILES_HW) \ + $(MFX_SHARED_FILES_HW) + +LOCAL_C_INCLUDES := \ + $(MFX_LOCAL_INCLUDES_HW) \ + $(UMC_LOCAL_INCLUDES_HW) \ + $(MFX_INCLUDES_INTERNAL_HW) + +LOCAL_CPPFLAGS += -std=c++14 + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -Wno-error -Wno-unused-parameter -Wno-implicit-fallthrough + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libmfx_core_hw +LOCAL_SHARED_LIBRARIES := liblog libcutils + +include $(BUILD_STATIC_LIBRARY) + +# ============================================================================= + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := $(MFX_LIB_SHARED_FILES_1) $(MFX_LIB_SHARED_FILES_2) + +LOCAL_C_INCLUDES := \ + $(MFX_LOCAL_INCLUDES_HW) \ + $(UMC_LOCAL_INCLUDES_HW) \ + $(MFX_INCLUDES_INTERNAL_HW) + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -Wno-error -Wno-unused-parameter -Wno-implicit-fallthrough + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_LDFLAGS := $(MFX_LOCAL_LDFLAGS_HW) + +LOCAL_CPPFLAGS += -std=c++14 + +LOCAL_WHOLE_STATIC_LIBRARIES := $(MFX_LOCAL_STATIC_LIBRARIES_HW) +LOCAL_SHARED_LIBRARIES := libva liblog libcutils libdrm libva-android + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libmfx-gen + +include $(BUILD_SHARED_LIBRARY) diff --git a/_studio/mfx_lib/decode/av1/src/mfx_av1_dec_decode.cpp b/_studio/mfx_lib/decode/av1/src/mfx_av1_dec_decode.cpp index 9a385381c..b41adef20 100755 --- a/_studio/mfx_lib/decode/av1/src/mfx_av1_dec_decode.cpp +++ b/_studio/mfx_lib/decode/av1/src/mfx_av1_dec_decode.cpp @@ -293,6 +293,7 @@ mfxStatus VideoDECODEAV1::Init(mfxVideoParam* par) m_core->GetVA((mfxHDL*)&m_va, MFX_MEMTYPE_FROM_DECODE); vp.pVideoAccelerator = m_va; + vp.color_config.BitDepth = FourCcBitDepth(par->mfx.FrameInfo.FourCC); ConvertMFXParamsToUMC(par, &vp); vp.info.profile = av1_mfx_profile_to_native_profile(par->mfx.CodecProfile); @@ -1241,6 +1242,16 @@ mfxStatus VideoDECODEAV1::FillVideoParam(UMC_AV1_DECODER::AV1DecoderParams const || par->mfx.FrameInfo.FourCC == MFX_FOURCC_Y416) par->mfx.FrameInfo.Shift = 1; + // video signal section + mfxExtVideoSignalInfo * videoSignal = (mfxExtVideoSignalInfo *)GetExtendedBuffer(par->ExtParam, par->NumExtParam, MFX_EXTBUFF_VIDEO_SIGNAL_INFO); + if (videoSignal) + { + videoSignal->VideoFullRange = vp->color_config.color_range; + videoSignal->ColourPrimaries = vp->color_config.color_primaries; + videoSignal->TransferCharacteristics = vp->color_config.transfer_characteristics; + videoSignal->MatrixCoefficients = vp->color_config.matrix_coefficients; + } + return MFX_ERR_NONE; } diff --git a/_studio/mfx_lib/decode/vp9/src/mfx_vp9_dec_decode_hw.cpp b/_studio/mfx_lib/decode/vp9/src/mfx_vp9_dec_decode_hw.cpp index c248fd7f9..8d422e8f2 100644 --- a/_studio/mfx_lib/decode/vp9/src/mfx_vp9_dec_decode_hw.cpp +++ b/_studio/mfx_lib/decode/vp9/src/mfx_vp9_dec_decode_hw.cpp @@ -276,18 +276,6 @@ class FrameStorage } } - void CompleteCurFrame(UMC::FrameMemID frameId) - { - auto find_it = std::find_if(m_submittedFrames.begin(), m_submittedFrames.end(), - [frameId](const UMC_VP9_DECODER::VP9DecoderFrame & item) { return item.currFrame == frameId; }); - - if (find_it != m_submittedFrames.end() && find_it->isDecoded) - { - UnLockResources(*find_it); - m_submittedFrames.erase(find_it); - } - } - void CompleteFrames() { for (auto it = m_submittedFrames.begin(); it != m_submittedFrames.end(); ) @@ -935,7 +923,6 @@ mfxStatus MFX_CDECL VP9DECODERoutine(void *p_state, void * /* pp_param */, mfxU3 decoder.m_surface_source->SetFreeSurfaceAllowedFlag(false); } decoder.m_framesStorage->DecodeFrame(data.currFrameId); - decoder.m_framesStorage->CompleteCurFrame(data.currFrameId); return MFX_ERR_NONE; } @@ -973,7 +960,6 @@ mfxStatus MFX_CDECL VP9DECODERoutine(void *p_state, void * /* pp_param */, mfxU3 if (data.currFrameId != -1) decoder.m_surface_source->DecreaseReference(data.currFrameId); decoder.m_framesStorage->DecodeFrame(data.currFrameId); - decoder.m_framesStorage->CompleteCurFrame(data.currFrameId); return MFX_TASK_DONE; } @@ -1155,6 +1141,11 @@ mfxStatus VideoDECODEVP9_HW::DecodeFrameCheck(mfxBitstream *bs, mfxFrameSurface1 VP9DecoderFrame frameInfo = m_frameInfo; sts = DecodeFrameHeader(bs, frameInfo); + + // XXX: Overwrite profile and bit_depth from mfxparam so that we can configure + // the output bit format. + frameInfo.profile = m_vPar.mfx.CodecProfile - 1; + frameInfo.bit_depth = m_vPar.mfx.FrameInfo.BitDepthLuma; MFX_CHECK_STS(sts); MFX_VP9_Utility::FillVideoParam(m_core->GetPlatformType(), frameInfo, m_vPar); diff --git a/_studio/mfx_lib/encode_hw/h264/src/mfx_h264_enc_common_hw.cpp b/_studio/mfx_lib/encode_hw/h264/src/mfx_h264_enc_common_hw.cpp index 90cca8a3e..3fcb8fa3f 100644 --- a/_studio/mfx_lib/encode_hw/h264/src/mfx_h264_enc_common_hw.cpp +++ b/_studio/mfx_lib/encode_hw/h264/src/mfx_h264_enc_common_hw.cpp @@ -3056,7 +3056,7 @@ mfxStatus MfxHwH264Encode::CheckVideoParamQueryLike( par.mfx.CodecLevel = GetMaxSupportedLevel(); } } - else if (par.mfx.CodecLevel != 0 && par.mfx.CodecLevel < minLevel) + else if (par.mfx.CodecLevel != 0 && (par.mfx.CodecLevel != MFX_LEVEL_AVC_1b || minLevel != MFX_LEVEL_AVC_1) && par.mfx.CodecLevel < minLevel) { if (extBits->SPSBuffer) MFX_RETURN(Error(MFX_ERR_INCOMPATIBLE_VIDEO_PARAM)); @@ -3086,7 +3086,7 @@ mfxStatus MfxHwH264Encode::CheckVideoParamQueryLike( par.mfx.CodecLevel = GetMaxSupportedLevel(); } } - else if (par.mfx.CodecLevel != 0 && par.mfx.CodecLevel < minLevel) + else if (par.mfx.CodecLevel != 0 && (par.mfx.CodecLevel != MFX_LEVEL_AVC_1b || minLevel != MFX_LEVEL_AVC_1) && par.mfx.CodecLevel < minLevel) { if (extBits->SPSBuffer) MFX_RETURN(Error(MFX_ERR_INCOMPATIBLE_VIDEO_PARAM)); @@ -3110,7 +3110,7 @@ mfxStatus MfxHwH264Encode::CheckVideoParamQueryLike( par.mfx.CodecLevel = MFX_LEVEL_AVC_52; par.mfx.NumRefFrame = GetMaxNumRefFrame(par); } - else if (par.mfx.CodecLevel != 0 && par.mfx.CodecLevel < minLevel) + else if (par.mfx.CodecLevel != 0 && (par.mfx.CodecLevel != MFX_LEVEL_AVC_1b || minLevel != MFX_LEVEL_AVC_1) && par.mfx.CodecLevel < minLevel) { if (extBits->SPSBuffer) MFX_RETURN(Error(MFX_ERR_INCOMPATIBLE_VIDEO_PARAM)); @@ -3482,7 +3482,7 @@ mfxStatus MfxHwH264Encode::CheckVideoParamQueryLike( { if (mfxU16 minLevel = GetLevelLimitByMaxBitrate(profile, par.calcParam.targetKbps)) { - if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && par.mfx.CodecLevel < minLevel) + if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && (par.mfx.CodecLevel != MFX_LEVEL_AVC_1b || minLevel != MFX_LEVEL_AVC_1) && par.mfx.CodecLevel < minLevel) { if (extBits->SPSBuffer) MFX_RETURN(Error(MFX_ERR_INCOMPATIBLE_VIDEO_PARAM)); @@ -3554,7 +3554,7 @@ mfxStatus MfxHwH264Encode::CheckVideoParamQueryLike( { if (mfxU16 minLevel = GetLevelLimitByMaxBitrate(profile, par.calcParam.maxKbps)) { - if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && par.mfx.CodecLevel < minLevel) + if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && (par.mfx.CodecLevel != MFX_LEVEL_AVC_1b || minLevel != MFX_LEVEL_AVC_1) && par.mfx.CodecLevel < minLevel) { if (extBits->SPSBuffer) MFX_RETURN(Error(MFX_ERR_INCOMPATIBLE_VIDEO_PARAM)); @@ -3644,7 +3644,7 @@ mfxStatus MfxHwH264Encode::CheckVideoParamQueryLike( { if (mfxU16 minLevel = GetLevelLimitByBufferSize(profile, par.calcParam.bufferSizeInKB)) { - if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && par.mfx.CodecLevel < minLevel) + if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && (par.mfx.CodecLevel != MFX_LEVEL_AVC_1b || minLevel != MFX_LEVEL_AVC_1) && par.mfx.CodecLevel < minLevel) { if (extBits->SPSBuffer) MFX_RETURN(Error(MFX_ERR_INCOMPATIBLE_VIDEO_PARAM)); @@ -3698,7 +3698,7 @@ mfxStatus MfxHwH264Encode::CheckVideoParamQueryLike( { if (mfxU16 minLevel = GetLevelLimitByMaxBitrate(profile, par.calcParam.decorativeHrdParam.targetKbps)) { - if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && par.mfx.CodecLevel < minLevel) + if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && (par.mfx.CodecLevel != MFX_LEVEL_AVC_1b || minLevel != MFX_LEVEL_AVC_1) && par.mfx.CodecLevel < minLevel) { changed = true; par.mfx.CodecLevel = minLevel; @@ -3728,7 +3728,7 @@ mfxStatus MfxHwH264Encode::CheckVideoParamQueryLike( { if (mfxU16 minLevel = GetLevelLimitByMaxBitrate(profile, par.calcParam.decorativeHrdParam.maxKbps)) { - if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && par.mfx.CodecLevel < minLevel) + if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && (par.mfx.CodecLevel != MFX_LEVEL_AVC_1b || minLevel != MFX_LEVEL_AVC_1) && par.mfx.CodecLevel < minLevel) { changed = true; par.mfx.CodecLevel = minLevel; @@ -3752,7 +3752,7 @@ mfxStatus MfxHwH264Encode::CheckVideoParamQueryLike( { if (mfxU16 minLevel = GetLevelLimitByBufferSize(profile, par.calcParam.decorativeHrdParam.bufferSizeInKB)) { - if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && par.mfx.CodecLevel < minLevel) + if (par.mfx.CodecLevel != 0 && par.mfx.CodecProfile != 0 && (par.mfx.CodecLevel != MFX_LEVEL_AVC_1b || minLevel != MFX_LEVEL_AVC_1) && par.mfx.CodecLevel < minLevel) { changed = true; par.mfx.CodecLevel = minLevel; diff --git a/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_iddi_packer.h b/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_iddi_packer.h index 32bd38cb9..92f49d5cb 100644 --- a/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_iddi_packer.h +++ b/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_iddi_packer.h @@ -61,7 +61,7 @@ class IDDIPacker void HardcodeCapsCommon(EncodeCapsHevc& caps, const mfxVideoParam& par) { caps.SliceIPOnly = IsOn(par.mfx.LowPower); - caps.msdk.PSliceSupport = false; + caps.msdk.PSliceSupport = true; } }; diff --git a/_studio/mfx_lib/ext/mpeg2/include/mfx_mpeg2_encode_hw.h b/_studio/mfx_lib/ext/mpeg2/include/mfx_mpeg2_encode_hw.h index faa60ea97..2fc1abe80 100644 --- a/_studio/mfx_lib/ext/mpeg2/include/mfx_mpeg2_encode_hw.h +++ b/_studio/mfx_lib/ext/mpeg2/include/mfx_mpeg2_encode_hw.h @@ -187,7 +187,7 @@ class MFXVideoENCODEMPEG2_HW : public VideoENCODE }; -MFX_PROPAGATE_GetSurface_VideoENCODE_Impl(MFXVideoENCODEMPEG2_HW); + #endif // MFX_ENABLE_MPEG2_VIDEO_ENCODE #endif diff --git a/_studio/mfx_lib/ext/mpeg2/src/mfx_mpeg2_encode_hw.cpp b/_studio/mfx_lib/ext/mpeg2/src/mfx_mpeg2_encode_hw.cpp index 23d53b407..e1eaac0f0 100644 --- a/_studio/mfx_lib/ext/mpeg2/src/mfx_mpeg2_encode_hw.cpp +++ b/_studio/mfx_lib/ext/mpeg2/src/mfx_mpeg2_encode_hw.cpp @@ -21,13 +21,13 @@ #include #include "mfx_common.h" - +#include "mfx_mpeg2_encode_hw.h" #if defined (MFX_ENABLE_MPEG2_VIDEO_ENCODE) #include "mfx_mpeg2_encode_utils_hw.h" - +MFX_PROPAGATE_GetSurface_VideoENCODE_Impl(MFXVideoENCODEMPEG2_HW); diff --git a/_studio/mfx_lib/shared/src/libmfxsw.cpp b/_studio/mfx_lib/shared/src/libmfxsw.cpp index 93d744300..1aead1cf0 100644 --- a/_studio/mfx_lib/shared/src/libmfxsw.cpp +++ b/_studio/mfx_lib/shared/src/libmfxsw.cpp @@ -31,7 +31,10 @@ #include #include #include -#include "va/va_drm.h" +#include "va/drm/va_drm.h" +#include +#include "va/va_backend.h" +#include "va_drmcommon.h" #include "mediasdk_version.h" #include "libmfx_core_factory.h" @@ -610,82 +613,80 @@ GetAdapterInfo(mfxU64 adapterId) return result; } +#define MFX_VA_ANDROID_DISPLAY_ID 0x18c34078 + static bool QueryImplCaps(std::function < bool (VideoCORE&, mfxU32, mfxU32 , mfxU64, const std::vector& ) > QueryImpls) { - for (int i = 0; i < 64; ++i) - { - std::string path; - - { - mfxU32 vendorId = 0; + std::string path; - path = std::string("/sys/class/drm/renderD") + std::to_string(128 + i) + "/device/vendor"; - FILE* file = fopen(path.c_str(), "r"); + { + mfxU32 vendorId = 0; - if (!file) - break; + path = std::string("/sys/class/drm/renderD128/device/vendor"); + FILE* file = fopen(path.c_str(), "r"); - int nread = fscanf(file, "%x", &vendorId); - fclose(file); + if (!file) + return false; - if (nread != 1 || vendorId != 0x8086) - continue; - } + int nread = fscanf(file, "%x", &vendorId); + fclose(file); - mfxU32 deviceId = 0; - { - path = std::string("/sys/class/drm/renderD") + std::to_string(128 + i) + "/device/device"; - - FILE* file = fopen(path.c_str(), "r"); - if (!file) - break; + if (nread != 1 || vendorId != 0x8086) + return false; + } - int nread = fscanf(file, "%x", &deviceId); - fclose(file); + mfxU32 deviceId = 0; + { + path = std::string("/sys/class/drm/renderD128/device/device"); - if (nread != 1) - break; - } + FILE* file = fopen(path.c_str(), "r"); + if (!file) + return false; - path = std::string("/dev/dri/renderD") + std::to_string(128 + i); + int nread = fscanf(file, "%x", &deviceId); + fclose(file); - int fd = open(path.c_str(), O_RDWR); - if (fd < 0) - continue; + if (nread != 1) + return false; + } - std::shared_ptr closeFile(&fd, [fd](int*) { close(fd); }); + { + unsigned int displayId = MFX_VA_ANDROID_DISPLAY_ID; + VADisplay vaDisplay = vaGetDisplay(&displayId); + if (vaDisplay == nullptr) + return false; - { - auto displ = vaGetDisplayDRM(fd); + VADisplayContextP ctx = (VADisplayContextP)vaDisplay; + drm_state* drm = (drm_state*)ctx->pDriverContext->drm_state; + int fd = drm->fd; - int vamajor = 0, vaminor = 0; - if (VA_STATUS_SUCCESS != vaInitialize(displ, &vamajor, &vaminor)) - continue; + int vamajor = 0, vaminor = 0; + if (VA_STATUS_SUCCESS != vaInitialize(vaDisplay, &vamajor, &vaminor)) + return false; - std::shared_ptr closeVA(&displ, [displ](VADisplay*) { vaTerminate(displ); }); + std::shared_ptr closeVA(&vaDisplay, [vaDisplay](VADisplay*) { vaTerminate(vaDisplay); }); - VADisplayAttribute attr = {}; - attr.type = VADisplayAttribSubDevice; - auto sts = vaGetDisplayAttributes(displ, &attr, 1); - std::ignore = MFX_STS_TRACE(sts); + VADisplayAttribute attr = {}; + attr.type = VADisplayAttribSubDevice; + auto sts = vaGetDisplayAttributes(vaDisplay, &attr, 1); + std::ignore = MFX_STS_TRACE(sts); - VADisplayAttribValSubDevice out = {}; - out.value = attr.value; + VADisplayAttribValSubDevice out = {}; + out.value = attr.value; - std::vector subDevMask(VA_STATUS_SUCCESS == sts ? out.bits.sub_device_count : 0); - for (std::size_t id = 0; id < subDevMask.size(); ++id) - { - subDevMask[id] = !!((1 << id) & out.bits.sub_device_mask); - } - { - std::unique_ptr pCore(FactoryCORE::CreateCORE(MFX_HW_VAAPI, 0, {}, 0)); + std::vector subDevMask(VA_STATUS_SUCCESS == sts ? out.bits.sub_device_count : 0); + for (std::size_t id = 0; id < subDevMask.size(); ++id) + { + subDevMask[id] = !!((1 << id) & out.bits.sub_device_mask); + } + { + std::unique_ptr pCore(FactoryCORE::CreateCORE(MFX_HW_VAAPI, 0, {}, 0)); - if (pCore->SetHandle(MFX_HANDLE_VA_DISPLAY, (mfxHDL)displ)) - continue; + if (pCore->SetHandle(MFX_HANDLE_VA_DISPLAY, (mfxHDL)vaDisplay)) + return false; - if (!QueryImpls(*pCore, deviceId, i, fd, subDevMask)) - return false; - } + if (!QueryImpls(*pCore, deviceId, 0, fd, subDevMask)) + return false; } } return true; diff --git a/_studio/shared/Android.mk b/_studio/shared/Android.mk new file mode 100644 index 000000000..86c9b78c2 --- /dev/null +++ b/_studio/shared/Android.mk @@ -0,0 +1,3 @@ +# Recursively call sub-folder Android.mk + +include $(call all-subdir-makefiles) \ No newline at end of file diff --git a/_studio/shared/asc/Android.mk b/_studio/shared/asc/Android.mk new file mode 100644 index 000000000..03c8063a7 --- /dev/null +++ b/_studio/shared/asc/Android.mk @@ -0,0 +1,92 @@ +LOCAL_PATH:= $(call my-dir) + +# ============================================================================= + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := $(addprefix src/, asc_avx2_impl.cpp) + +LOCAL_C_INCLUDES := \ + $(MFX_INCLUDES_INTERNAL_HW) \ + $(MFX_HOME)/_studio/mfx_lib/cmrt_cross_platform/include \ + $(MFX_HOME)/_studio/mfx_lib/ext/genx/asc/isa + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -mavx2 \ + -Wno-error \ + -Wno-unused-parameter + +LOCAL_CFLAGS += -I $(MFX_HOME)/_studio/shared/asc/include/ + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libmfx_asc_avx2 +include $(BUILD_STATIC_LIBRARY) + +# ============================================================================= + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := $(addprefix src/, asc_sse4_impl.cpp) + +LOCAL_C_INCLUDES := \ + $(MFX_INCLUDES_INTERNAL_HW) \ + $(MFX_HOME)/_studio/mfx_lib/cmrt_cross_platform/include \ + $(MFX_HOME)/_studio/mfx_lib/ext/genx/asc/isa + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -msse4.1 \ + -Wno-error \ + -Wno-unused-parameter + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libmfx_asc_sse4 +include $(BUILD_STATIC_LIBRARY) + +# ============================================================================= + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +ASC_SRC_FILES := $(addprefix src/, \ + asc.cpp \ + asc_c_impl.cpp \ + iofunctions.cpp \ + motion_estimation_engine.cpp \ + tree.cpp) + +LOCAL_SRC_FILES := $(ASC_SRC_FILES) + +LOCAL_C_INCLUDES := \ + $(MFX_INCLUDES_INTERNAL_HW) \ + $(MFX_HOME)/_studio/mfx_lib/cmrt_cross_platform/include \ + $(MFX_HOME)/_studio/mfx_lib/ext/genx/asc/isa + +LOCAL_STATIC_LIBRARIES := \ + libmfx_asc_avx2 \ + libmfx_asc_sse4 + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -msse4.1 \ + -Wno-error \ + -Wno-unused-parameter + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_WHOLE_STATIC_LIBRARIES := $(LOCAL_STATIC_LIBRARIES) + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libmfx_asc + +include $(BUILD_STATIC_LIBRARY) diff --git a/_studio/shared/include/mfx_config.h b/_studio/shared/include/mfx_config.h index 2bab8e13e..fa35c62c5 100644 --- a/_studio/shared/include/mfx_config.h +++ b/_studio/shared/include/mfx_config.h @@ -29,9 +29,15 @@ #define UMC_VA_LINUX -// mfx_features.h is auto-generated file containing mediasdk per-component -// enable defines -#include "mfx_features.h" +#if defined(ANDROID) + // we don't support config auto-generation on Android and have hardcoded + // definition instead + #include "mfx_android_defs.h" +#else + // mfxconfig.h is auto-generated file containing mediasdk per-component + // enable defines + #include "mfx_features.h" +#endif #define SYNCHRONIZATION_BY_VA_MAP_BUFFER #if !defined(SYNCHRONIZATION_BY_VA_SYNC_SURFACE) diff --git a/_studio/shared/include/mfx_utils.h b/_studio/shared/include/mfx_utils.h index bab156a80..740c49250 100644 --- a/_studio/shared/include/mfx_utils.h +++ b/_studio/shared/include/mfx_utils.h @@ -92,7 +92,7 @@ static inline T mfx_sts_trace(const char* fileName, const uint32_t lineNum, cons #define MFX_FAILED(sts) (MFX_STS_TRACE(sts) != MFX_ERR_NONE) #define MFX_RETURN(sts) { return MFX_STS_TRACE(sts); } #define MFX_RETURN_IF_ERR_NONE(sts) { if (MFX_SUCCEEDED(sts)) return MFX_ERR_NONE; } -#define MFX_CHECK(EXPR, ERR) { if (!(EXPR)) MFX_RETURN(ERR); } +#define MFX_CHECK(EXPR, ERR) { if (!(EXPR)) { MFX_TRACE_S("MFX_CHECK false!") MFX_RETURN(ERR); }} #define MFX_CHECK_NO_RET(EXPR, STS, ERR){ if (!(EXPR)) { std::ignore = MFX_STS_TRACE(ERR); STS = ERR; } } diff --git a/_studio/shared/mfx_logging/Android.mk b/_studio/shared/mfx_logging/Android.mk new file mode 100644 index 000000000..93f6fc389 --- /dev/null +++ b/_studio/shared/mfx_logging/Android.mk @@ -0,0 +1,24 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := $(addprefix src/, $(notdir $(wildcard $(LOCAL_PATH)/src/*.cpp))) + +LOCAL_C_INCLUDES := \ + $(MFX_INCLUDES_INTERNAL_HW) \ + $(MFX_HOME)/api/mediasdk_structures + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -Wno-error \ + -Wno-unused-parameter + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libmfx_logging + +include $(BUILD_STATIC_LIBRARY) + diff --git a/_studio/shared/mfx_trace/Android.mk b/_studio/shared/mfx_trace/Android.mk new file mode 100644 index 000000000..93c71ffde --- /dev/null +++ b/_studio/shared/mfx_trace/Android.mk @@ -0,0 +1,23 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := $(addprefix src/, $(notdir $(wildcard $(LOCAL_PATH)/src/*.cpp))) + +LOCAL_C_INCLUDES := \ + $(MFX_INCLUDES_INTERNAL_HW) \ + $(MFX_HOME)/api/mediasdk_structures + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -Wno-error \ + -Wno-unused-parameter + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libmfx_gen_trace + +include $(BUILD_STATIC_LIBRARY) diff --git a/_studio/shared/mfx_trace/src/mfx_trace.cpp b/_studio/shared/mfx_trace/src/mfx_trace.cpp index 50b4392d3..081433c52 100644 --- a/_studio/shared/mfx_trace/src/mfx_trace.cpp +++ b/_studio/shared/mfx_trace/src/mfx_trace.cpp @@ -313,7 +313,7 @@ mfxTraceU32 mfx_trace_get_category_index(mfxTraceChar* category, mfxTraceU32& in inline bool MFXTrace_IsPrintableCategoryAndLevel(mfxTraceU32 m_OutputInitilized, mfxTraceU32 level) { - bool logFlag = false; + bool logFlag = true; if (m_OutputInitilized == MFX_TRACE_OUTPUT_TEXTLOG) { #ifndef NDEBUG if (g_Level == MFX_TXTLOG_LEVEL_MAX) @@ -400,7 +400,7 @@ mfxTraceU32 MFXTrace_Init() g_OutputMode = 0; for (i = 0; i < sizeof(g_TraceAlgorithms)/sizeof(mfxTraceAlgorithm); ++i) { - if (output_mode & g_TraceAlgorithms[i].m_OutputMask) + if (1) { sts = g_TraceAlgorithms[i].m_InitFn(); if (sts == 0) @@ -434,7 +434,7 @@ mfxTraceU32 MFXTrace_Close(void) for (i = 0; i < sizeof(g_TraceAlgorithms)/sizeof(mfxTraceAlgorithm); ++i) { - if (g_OutputMode & g_TraceAlgorithms[i].m_OutputInitilized) + if (1) { res = g_TraceAlgorithms[i].m_CloseFn(); if (!sts && res) sts = res; @@ -460,7 +460,7 @@ mfxTraceU32 MFXTrace_SetLevel(mfxTraceChar* category, mfxTraceLevel level) for (i = 0; i < sizeof(g_TraceAlgorithms)/sizeof(mfxTraceAlgorithm); ++i) { - if (g_OutputMode & g_TraceAlgorithms[i].m_OutputInitilized) + if (1) { res = g_TraceAlgorithms[i].m_SetLevelFn(category, level); if (!sts && res) sts = res; @@ -484,7 +484,7 @@ mfxTraceU32 MFXTrace_DebugMessage(mfxTraceStaticHandle *static_handle, va_start(args, format); for (i = 0; i < sizeof(g_TraceAlgorithms)/sizeof(mfxTraceAlgorithm); ++i) { - if (g_OutputMode & g_TraceAlgorithms[i].m_OutputInitilized) + if (1) { if (!MFXTrace_IsPrintableCategoryAndLevel(g_TraceAlgorithms[i].m_OutputInitilized, level)) continue; @@ -515,7 +515,7 @@ mfxTraceU32 MFXTrace_vDebugMessage(mfxTraceStaticHandle *static_handle, for (i = 0; i < sizeof(g_TraceAlgorithms)/sizeof(mfxTraceAlgorithm); ++i) { - if (g_OutputMode & g_TraceAlgorithms[i].m_OutputInitilized) + if (1) { if (!MFXTrace_IsPrintableCategoryAndLevel(g_TraceAlgorithms[i].m_OutputInitilized, level)) continue; @@ -552,7 +552,7 @@ mfxTraceU32 MFXTrace_BeginTask(mfxTraceStaticHandle *static_handle, for (i = 0; i < sizeof(g_TraceAlgorithms)/sizeof(mfxTraceAlgorithm); ++i) { - if (g_OutputMode & g_TraceAlgorithms[i].m_OutputInitilized) + if (1) { if (!MFXTrace_IsPrintableCategoryAndLevel(g_TraceAlgorithms[i].m_OutputInitilized, level)) continue; @@ -593,7 +593,7 @@ mfxTraceU32 MFXTrace_EndTask(mfxTraceStaticHandle *static_handle, for (i = 0; i < sizeof(g_TraceAlgorithms)/sizeof(mfxTraceAlgorithm); ++i) { - if (g_OutputMode & g_TraceAlgorithms[i].m_OutputInitilized) + if (1) { if (!MFXTrace_IsPrintableCategoryAndLevel(g_TraceAlgorithms[i].m_OutputInitilized, level)) continue; diff --git a/_studio/shared/mfx_trace/src/mfx_trace_textlog.cpp b/_studio/shared/mfx_trace/src/mfx_trace_textlog.cpp index cc67e1abb..554088b5b 100644 --- a/_studio/shared/mfx_trace/src/mfx_trace_textlog.cpp +++ b/_studio/shared/mfx_trace/src/mfx_trace_textlog.cpp @@ -24,7 +24,7 @@ extern "C" { -#define MFT_TRACE_PATH_TO_TEMP_LIBLOG MFX_TRACE_STRING("/tmp/mfxlib.log") +#define MFT_TRACE_PATH_TO_TEMP_LIBLOG MFX_TRACE_STRING("/data/local/tmp/mfx-gen.log") #include #include "mfx_trace_utils.h" @@ -91,8 +91,8 @@ mfxTraceU32 MFXTraceTextLog_Init() sts = MFXTraceTextLog_Close(); if (!sts) sts = MFXTraceTextLog_GetRegistryParams(); std::string StrPid = "/mfxlib_Pid"; - std::string filename_path = VplLogPath + StrPid + std::to_string(getpid()) + "_Tid" + std::to_string(pthread_self()) + ".log"; - strncpy(g_mfxTracePrintfFileName,filename_path.c_str(), MAX_PATH - 1); + // std::string filename_path = VplLogPath + StrPid + std::to_string(getpid()) + "_Tid" + std::to_string(pthread_self()) + ".log"; + // strncpy(g_mfxTracePrintfFileName,filename_path.c_str(), MAX_PATH - 1); g_mfxTracePrintfFileName[MAX_PATH - 1] = 0; if (!sts) diff --git a/_studio/shared/mfx_trace/src/mfx_trace_utils_linux.cpp b/_studio/shared/mfx_trace/src/mfx_trace_utils_linux.cpp index 64af175b5..489c7ade4 100644 --- a/_studio/shared/mfx_trace/src/mfx_trace_utils_linux.cpp +++ b/_studio/shared/mfx_trace/src/mfx_trace_utils_linux.cpp @@ -74,7 +74,7 @@ FILE* mfx_trace_open_conf_file(const char* name) std::stringstream ss; #if defined(ANDROID) - const char* home = "/data/data/com.intel.vtune/mediasdk"; + const char* home = "/data/local"; #else const char* home = getenv("HOME"); #endif diff --git a/_studio/shared/src/libmfx_core_vaapi.cpp b/_studio/shared/src/libmfx_core_vaapi.cpp index fd5fc269c..6c95c79f3 100644 --- a/_studio/shared/src/libmfx_core_vaapi.cpp +++ b/_studio/shared/src/libmfx_core_vaapi.cpp @@ -44,7 +44,7 @@ #include "va/va.h" #include -#include "va/va_drm.h" +#include "va/drm/va_drm.h" #include #include diff --git a/_studio/shared/umc/Android.mk b/_studio/shared/umc/Android.mk new file mode 100644 index 000000000..86c9b78c2 --- /dev/null +++ b/_studio/shared/umc/Android.mk @@ -0,0 +1,3 @@ +# Recursively call sub-folder Android.mk + +include $(call all-subdir-makefiles) \ No newline at end of file diff --git a/_studio/shared/umc/codec/Android.mk b/_studio/shared/umc/codec/Android.mk new file mode 100644 index 000000000..7e4cf2709 --- /dev/null +++ b/_studio/shared/umc/codec/Android.mk @@ -0,0 +1,83 @@ +LOCAL_PATH:= $(call my-dir) + +# Setting subdirectories to march thru +MFX_CODEC_LOCAL_DIRS := \ + vc1_common \ + jpeg_common \ + color_space_converter \ + mpeg2_dec \ + h265_dec \ + h264_dec \ + vc1_dec \ + jpeg_dec \ + vp9_dec \ + av1_dec + +MFX_CODEC_LOCAL_SRC_FILES := \ + $(patsubst $(LOCAL_PATH)/%, %, $(foreach dir, $(MFX_CODEC_LOCAL_DIRS), $(wildcard $(LOCAL_PATH)/$(dir)/src/*.cpp))) + +# ============================================================================= + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := \ + brc/src/umc_brc.cpp \ + brc/src/umc_h264_brc.cpp \ + brc/src/umc_mpeg2_brc.cpp \ + brc/src/umc_video_brc.cpp + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/brc/include \ + $(MFX_INCLUDES_INTERNAL_HW) + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -Wno-error \ + -Wno-unused-parameter \ + -Wno-deprecated-declarations + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_SHARED_LIBRARIES := liblog libcutils + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libumc_brc + +include $(BUILD_STATIC_LIBRARY) + +# ============================================================================= + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := $(MFX_CODEC_LOCAL_SRC_FILES) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/av1_dec/include \ + $(LOCAL_PATH)/color_space_converter/include \ + $(LOCAL_PATH)/h264_dec/include \ + $(LOCAL_PATH)/h265_dec/include \ + $(LOCAL_PATH)/jpeg_common/include \ + $(LOCAL_PATH)/jpeg_dec/include \ + $(LOCAL_PATH)/mpeg2_dec/include \ + $(LOCAL_PATH)/vc1_common/include \ + $(LOCAL_PATH)/vc1_dec/include \ + $(LOCAL_PATH)/vp9_dec/include \ + $(MFX_INCLUDES_INTERNAL_HW) + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -Wno-error \ + -Wno-unused-parameter + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_SHARED_LIBRARIES := liblog libcutils + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libumc_codecs_hw + +include $(BUILD_STATIC_LIBRARY) diff --git a/_studio/shared/umc/codec/av1_dec/include/umc_av1_dec_defs.h b/_studio/shared/umc/codec/av1_dec/include/umc_av1_dec_defs.h index a03177ccd..3a0d1c12b 100644 --- a/_studio/shared/umc/codec/av1_dec/include/umc_av1_dec_defs.h +++ b/_studio/shared/umc/codec/av1_dec/include/umc_av1_dec_defs.h @@ -104,6 +104,7 @@ namespace UMC_AV1_DECODER enum AV1_OBU_TYPE { + OBU_Reserved = 0, OBU_SEQUENCE_HEADER = 1, OBU_TEMPORAL_DELIMITER = 2, OBU_FRAME_HEADER = 3, diff --git a/_studio/shared/umc/codec/av1_dec/include/umc_av1_decoder.h b/_studio/shared/umc/codec/av1_dec/include/umc_av1_decoder.h index 89b6d1f29..fdc149697 100755 --- a/_studio/shared/umc/codec/av1_dec/include/umc_av1_decoder.h +++ b/_studio/shared/umc/codec/av1_dec/include/umc_av1_decoder.h @@ -72,6 +72,7 @@ namespace UMC_AV1_DECODER bool anchors_loaded; uint32_t skip_first_frames; mfxFrameSurface1** pre_loaded_anchors; + ColorConfig color_config; }; class ReportItem // adopted from HEVC/AVC decoders diff --git a/_studio/shared/umc/codec/av1_dec/include/umc_av1_va_packer.h b/_studio/shared/umc/codec/av1_dec/include/umc_av1_va_packer.h index c2cf35b3c..93c9ccdce 100644 --- a/_studio/shared/umc/codec/av1_dec/include/umc_av1_va_packer.h +++ b/_studio/shared/umc/codec/av1_dec/include/umc_av1_va_packer.h @@ -53,12 +53,15 @@ class Packer virtual void PackAU(std::vector&, AV1DecoderFrame const&, bool) = 0; virtual void RegisterAnchor(UMC::FrameMemID) = 0; + mfxU16 GetBitDepth() { return m_bitDepth; } + void SetBitDepth(mfxU16 bitDepth) { m_bitDepth = bitDepth; } static Packer* CreatePacker(UMC::VideoAccelerator * va); protected: UMC::VideoAccelerator *m_va; + mfxU16 m_bitDepth = 8; }; } // namespace UMC_AV1_DECODER diff --git a/_studio/shared/umc/codec/av1_dec/src/umc_av1_bitstream.cpp b/_studio/shared/umc/codec/av1_dec/src/umc_av1_bitstream.cpp index 8be3ea77c..ddcb06f1c 100644 --- a/_studio/shared/umc/codec/av1_dec/src/umc_av1_bitstream.cpp +++ b/_studio/shared/umc/codec/av1_dec/src/umc_av1_bitstream.cpp @@ -1211,7 +1211,8 @@ namespace UMC_AV1_DECODER if (info.header.obu_has_size_field) av1_read_obu_size(*this, obu_size, sizeFieldLength); - else if (info.header.obu_type != OBU_TEMPORAL_DELIMITER) + // Av1-spec section 6.2.2: Reserved units are for future use and shall be ignored by AV1 decoder. + else if (info.header.obu_type != OBU_TEMPORAL_DELIMITER && info.header.obu_type != OBU_Reserved) throw av1_exception(UMC::UMC_ERR_NOT_IMPLEMENTED); // no support for OBUs w/o size field so far info.size = headerSize + sizeFieldLength + obu_size; diff --git a/_studio/shared/umc/codec/av1_dec/src/umc_av1_decoder.cpp b/_studio/shared/umc/codec/av1_dec/src/umc_av1_decoder.cpp index f593a5832..3e8026e14 100755 --- a/_studio/shared/umc/codec/av1_dec/src/umc_av1_decoder.cpp +++ b/_studio/shared/umc/codec/av1_dec/src/umc_av1_decoder.cpp @@ -1103,6 +1103,7 @@ namespace UMC_AV1_DECODER par.lFlags = 0; par.film_grain = sh.film_grain_param_present; + par.color_config = sh.color_config; return UMC::UMC_OK; } diff --git a/_studio/shared/umc/codec/av1_dec/src/umc_av1_decoder_va.cpp b/_studio/shared/umc/codec/av1_dec/src/umc_av1_decoder_va.cpp index d24d85a2e..5db8170b6 100755 --- a/_studio/shared/umc/codec/av1_dec/src/umc_av1_decoder_va.cpp +++ b/_studio/shared/umc/codec/av1_dec/src/umc_av1_decoder_va.cpp @@ -57,6 +57,7 @@ namespace UMC_AV1_DECODER va = dp->pVideoAccelerator; packer.reset(Packer::CreatePacker(va)); + packer->SetBitDepth(dp->color_config.BitDepth); uint32_t dpb_size = std::max(params.async_depth + TOTAL_REFS, 8u); diff --git a/_studio/shared/umc/codec/av1_dec/src/umc_av1_va_packer_vaapi.cpp b/_studio/shared/umc/codec/av1_dec/src/umc_av1_va_packer_vaapi.cpp index 07e681fd7..b42f864ed 100755 --- a/_studio/shared/umc/codec/av1_dec/src/umc_av1_va_packer_vaapi.cpp +++ b/_studio/shared/umc/codec/av1_dec/src/umc_av1_va_packer_vaapi.cpp @@ -180,8 +180,7 @@ namespace UMC_AV1_DECODER seqInfo.film_grain_params_present = sh.film_grain_param_present; picParam.matrix_coefficients = sh.color_config.matrix_coefficients; - picParam.bit_depth_idx = (sh.color_config.BitDepth == 10) ? 1 : - (sh.color_config.BitDepth == 12) ? 2 : 0; + picParam.bit_depth_idx = (m_bitDepth == 10) ? 1 : (m_bitDepth == 12) ? 2 : 0; picParam.order_hint_bits_minus_1 = (uint8_t)sh.order_hint_bits_minus1; // fill pic params diff --git a/_studio/shared/umc/codec/h265_dec/include/platform/umc_h265_va_packer_vaapi_g9.hpp b/_studio/shared/umc/codec/h265_dec/include/platform/umc_h265_va_packer_vaapi_g9.hpp index fdfe92cd4..6178cdcc8 100644 --- a/_studio/shared/umc/codec/h265_dec/include/platform/umc_h265_va_packer_vaapi_g9.hpp +++ b/_studio/shared/umc/codec/h265_dec/include/platform/umc_h265_va_packer_vaapi_g9.hpp @@ -181,8 +181,6 @@ namespace UMC_HEVC_DECODER pic_fields.NoBiPredFlag = 0; pp->sps_max_dec_pic_buffering_minus1 = (uint8_t)(sps->sps_max_dec_pic_buffering[sh->nuh_temporal_id] - 1); - pp->bit_depth_luma_minus8 = (uint8_t)(sps->bit_depth_luma - 8); - pp->bit_depth_chroma_minus8 = (uint8_t)(sps->bit_depth_chroma - 8); pp->pcm_sample_bit_depth_luma_minus1 = (uint8_t)(sps->pcm_sample_bit_depth_luma - 1); pp->pcm_sample_bit_depth_chroma_minus1 = (uint8_t)(sps->pcm_sample_bit_depth_chroma - 1); pp->log2_min_luma_coding_block_size_minus3 = (uint8_t)(sps->log2_min_luma_coding_block_size- 3); @@ -441,6 +439,11 @@ namespace UMC_HEVC_DECODER VAPictureParameterBufferHEVC* pp = nullptr; PeekParamsBuffer(m_va, &pp); + // XXX: Get bit_depth from mfxParam instead of bitstream so that we can configure + // the output bit format. + pp->bit_depth_luma_minus8 = color_format2bit_depth(supplier->GetColorformat()) - 8; + pp->bit_depth_chroma_minus8 = color_format2bit_depth(supplier->GetColorformat()) - 8; + PackPicHeader(m_va, frame, dpb, pp); } diff --git a/_studio/shared/umc/codec/h265_dec/include/umc_h265_dec_defs.h b/_studio/shared/umc/codec/h265_dec/include/umc_h265_dec_defs.h index 11ddc4ead..73de7a26d 100644 --- a/_studio/shared/umc/codec/h265_dec/include/umc_h265_dec_defs.h +++ b/_studio/shared/umc/codec/h265_dec/include/umc_h265_dec_defs.h @@ -1492,6 +1492,27 @@ inline size_t CalculateSuggestedSize(const H265SeqParamSet * sps) return 2*size; } +inline +mfxU16 color_format2bit_depth(UMC::ColorFormat format) +{ + switch (format) + { + case UMC::NV12: + case UMC::YUY2: + case UMC::AYUV: return 8; + + case UMC::P010: + case UMC::Y210: + case UMC::Y410: return 10; + + case UMC::P016: + case UMC::Y216: + case UMC::Y416: return 12; + + default: return 0; + } +} + } // end namespace UMC_HEVC_DECODER #endif // H265_GLOBAL_ROM_H diff --git a/_studio/shared/umc/codec/h265_dec/include/umc_h265_task_supplier.h b/_studio/shared/umc/codec/h265_dec/include/umc_h265_task_supplier.h index 8bd51d1ac..2fe8d652b 100644 --- a/_studio/shared/umc/codec/h265_dec/include/umc_h265_task_supplier.h +++ b/_studio/shared/umc/codec/h265_dec/include/umc_h265_task_supplier.h @@ -374,6 +374,11 @@ class TaskSupplier_H265 : public Skipping_H265, public AU_Splitter_H265, public return &m_ObjHeap; } + UMC::ColorFormat GetColorformat() + { + return m_initializationParams.info.color_format; + } + protected: // Include a new slice into a set of frame slices @@ -412,7 +417,8 @@ class TaskSupplier_H265 : public Skipping_H265, public AU_Splitter_H265, public virtual UMC::Status AddOneFrame(UMC::MediaData * pSource); // Allocate frame internals - virtual UMC::Status AllocateFrameData(H265DecoderFrame * pFrame, mfxSize dimensions, const H265SeqParamSet* pSeqParamSet, const H265PicParamSet *pPicParamSet); + virtual UMC::Status AllocateFrameData(H265DecoderFrame * pFrame, mfxSize dimensions, + const H265SeqParamSet* pSeqParamSet, const H265PicParamSet *pPicParamSet, UMC::ColorFormat colorFormat); // Decode a bitstream header NAL unit virtual UMC::Status DecodeHeaders(UMC::MediaDataEx *nalUnit); diff --git a/_studio/shared/umc/codec/h265_dec/include/umc_h265_va_supplier.h b/_studio/shared/umc/codec/h265_dec/include/umc_h265_va_supplier.h index 9be27b946..717d1ee31 100644 --- a/_studio/shared/umc/codec/h265_dec/include/umc_h265_va_supplier.h +++ b/_studio/shared/umc/codec/h265_dec/include/umc_h265_va_supplier.h @@ -59,7 +59,8 @@ class VATaskSupplier : protected: - virtual UMC::Status AllocateFrameData(H265DecoderFrame * pFrame, mfxSize dimensions, const H265SeqParamSet* pSeqParamSet, const H265PicParamSet *pPicParamSet); + virtual UMC::Status AllocateFrameData(H265DecoderFrame * pFrame, mfxSize dimensions, const H265SeqParamSet* pSeqParamSet, + const H265PicParamSet *pPicParamSet, UMC::ColorFormat colorFormat); virtual void InitFrameCounter(H265DecoderFrame * pFrame, const H265Slice *pSlice); @@ -92,9 +93,10 @@ class VATaskSupplierBigSurfacePool: protected: - virtual UMC::Status AllocateFrameData(H265DecoderFrame * pFrame, mfxSize dimensions, const H265SeqParamSet* pSeqParamSet, const H265PicParamSet * pps) + virtual UMC::Status AllocateFrameData(H265DecoderFrame * pFrame, mfxSize dimensions, const H265SeqParamSet* pSeqParamSet, + const H265PicParamSet * pps, UMC::ColorFormat colorFormat) { - UMC::Status ret = BaseClass::AllocateFrameData(pFrame, dimensions, pSeqParamSet, pps); + UMC::Status ret = BaseClass::AllocateFrameData(pFrame, dimensions, pSeqParamSet, pps, colorFormat); if (ret == UMC::UMC_OK) { diff --git a/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp b/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp index 83d554889..492dec59e 100755 --- a/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp +++ b/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp @@ -2454,12 +2454,12 @@ UMC::Status TaskSupplier_H265::InitFreeFrame(H265DecoderFrame * pFrame, const H2 } // Allocate frame internals -UMC::Status TaskSupplier_H265::AllocateFrameData(H265DecoderFrame * pFrame, mfxSize dimensions, const H265SeqParamSet* pSeqParamSet, const H265PicParamSet *pPicParamSet) +UMC::Status TaskSupplier_H265::AllocateFrameData(H265DecoderFrame * pFrame, mfxSize dimensions, const H265SeqParamSet* pSeqParamSet, + const H265PicParamSet *pPicParamSet, UMC::ColorFormat colorFormat) { - UMC::ColorFormat color_format = pFrame->GetColorFormat(); - //(ColorFormat) pSeqParamSet->chroma_format_idc; + UMC::ColorFormat color_format = colorFormat; UMC::VideoDataInfo info; - int32_t bit_depth = pSeqParamSet->need16bitOutput ? 10 : 8; + int32_t bit_depth = color_format2bit_depth(color_format); info.Init(dimensions.width, dimensions.height, color_format, bit_depth); UMC::FrameMemID frmMID; @@ -2520,7 +2520,8 @@ H265DecoderFrame * TaskSupplier_H265::AllocateNewFrame(const H265Slice *pSlice) return 0; } - umcRes = AllocateFrameData(pFrame, pFrame->lumaSize(), pSlice->GetSeqParam(), pSlice->GetPicParam()); + umcRes = AllocateFrameData(pFrame, pFrame->lumaSize(), pSlice->GetSeqParam(), pSlice->GetPicParam(), + m_initializationParams.info.color_format); if (umcRes != UMC::UMC_OK) { return 0; diff --git a/_studio/shared/umc/codec/h265_dec/src/umc_h265_va_supplier.cpp b/_studio/shared/umc/codec/h265_dec/src/umc_h265_va_supplier.cpp index f154ef56c..44c231fcd 100755 --- a/_studio/shared/umc/codec/h265_dec/src/umc_h265_va_supplier.cpp +++ b/_studio/shared/umc/codec/h265_dec/src/umc_h265_va_supplier.cpp @@ -142,11 +142,12 @@ void VATaskSupplier::InitFrameCounter(H265DecoderFrame * pFrame, const H265Slice TaskSupplier_H265::InitFrameCounter(pFrame, pSlice); } -UMC::Status VATaskSupplier::AllocateFrameData(H265DecoderFrame * pFrame, mfxSize dimensions, const H265SeqParamSet* pSeqParamSet, const H265PicParamSet *) +UMC::Status VATaskSupplier::AllocateFrameData(H265DecoderFrame * pFrame, mfxSize dimensions, const H265SeqParamSet* pSeqParamSet, + const H265PicParamSet *, UMC::ColorFormat colorFormat) { - UMC::ColorFormat chroma_format_idc = pFrame->GetColorFormat(); + UMC::ColorFormat chroma_format_idc = colorFormat; UMC::VideoDataInfo info; - int32_t bit_depth = pSeqParamSet->need16bitOutput ? 10 : 8; + int32_t bit_depth = color_format2bit_depth(chroma_format_idc); info.Init(dimensions.width, dimensions.height, chroma_format_idc, bit_depth); UMC::FrameMemID frmMID; diff --git a/_studio/shared/umc/core/Android.mk b/_studio/shared/umc/core/Android.mk new file mode 100644 index 000000000..aedbfe823 --- /dev/null +++ b/_studio/shared/umc/core/Android.mk @@ -0,0 +1,40 @@ +LOCAL_PATH:= $(call my-dir) + +# Setting subdirectories to march thru +MFX_LOCAL_DIRS := \ + vm \ + vm_plus \ + umc + +MFX_LOCAL_SRC_FILES := \ + $(patsubst $(LOCAL_PATH)/%, %, $(foreach dir, $(MFX_LOCAL_DIRS), $(wildcard $(LOCAL_PATH)/$(dir)/src/*.c))) \ + $(patsubst $(LOCAL_PATH)/%, %, $(foreach dir, $(MFX_LOCAL_DIRS), $(wildcard $(LOCAL_PATH)/$(dir)/src/*.cpp))) + +MFX_LOCAL_INCLUDES := \ + $(foreach dir, $(MFX_LOCAL_DIRS), $(wildcard $(LOCAL_PATH)/$(dir)/include)) + +# ============================================================================= + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := $(MFX_LOCAL_SRC_FILES) + +LOCAL_C_INCLUDES := \ + $(MFX_LOCAL_INCLUDES) \ + $(MFX_INCLUDES_INTERNAL_HW) + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -Wno-error \ + -Wno-unused-parameter + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_STATIC_LIBRARIES += libmfx_logging + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libumc_core_hw + +include $(BUILD_STATIC_LIBRARY) diff --git a/_studio/shared/umc/io/Android.mk b/_studio/shared/umc/io/Android.mk new file mode 100644 index 000000000..0baf70d82 --- /dev/null +++ b/_studio/shared/umc/io/Android.mk @@ -0,0 +1,35 @@ +LOCAL_PATH:= $(call my-dir) + +MFX_LOCAL_DIRS_HW := \ + umc_va + +MFX_LOCAL_SRC_FILES_HW := \ + $(patsubst $(LOCAL_PATH)/%, %, $(foreach dir, $(MFX_LOCAL_DIRS_HW), $(wildcard $(LOCAL_PATH)/$(dir)/src/*.cpp))) + +MFX_LOCAL_INCLUDES_HW := \ + $(foreach dir, $(MFX_LOCAL_DIRS_HW), $(wildcard $(LOCAL_PATH)/$(dir)/include)) + +# ============================================================================= + +include $(CLEAR_VARS) +include $(MFX_HOME)/android/mfx_defs.mk + +LOCAL_SRC_FILES := $(MFX_LOCAL_SRC_FILES_HW) + +LOCAL_C_INCLUDES := \ + $(MFX_LOCAL_INCLUDES_HW) \ + $(MFX_INCLUDES_INTERNAL_HW) + +LOCAL_CFLAGS := \ + $(MFX_CFLAGS_INTERNAL_HW) \ + -Wno-error \ + -Wno-unused-parameter \ + -Wno-implicit-fallthrough + +LOCAL_CFLAGS_32 := $(MFX_CFLAGS_INTERNAL_32) +LOCAL_CFLAGS_64 := $(MFX_CFLAGS_INTERNAL_64) + +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libumc_va + +include $(BUILD_STATIC_LIBRARY) \ No newline at end of file diff --git a/android/Android.bp b/android/Android.bp new file mode 100644 index 000000000..746bac2f5 --- /dev/null +++ b/android/Android.bp @@ -0,0 +1,10 @@ + +cc_library_headers { + + name: "libmfx_android_headers", + export_include_dirs: [ + "include", + ], + + vendor: true, +} \ No newline at end of file diff --git a/android/Android.mk b/android/Android.mk new file mode 100644 index 000000000..579d32855 --- /dev/null +++ b/android/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := libmfx_gen_headers +LOCAL_EXPORT_C_INCLUDE_DIRS := \ + $(MFX_HOME)/api/vpl \ + $(MFX_HOME)/api/vpl/private \ + $(MFX_HOME)/api/mediasdk_structures \ + $(MFX_HOME)/android/include + +include $(BUILD_HEADER_LIBRARY) \ No newline at end of file diff --git a/android/include/mfx_android_config.h b/android/include/mfx_android_config.h new file mode 100644 index 000000000..1ee3135b4 --- /dev/null +++ b/android/include/mfx_android_config.h @@ -0,0 +1,24 @@ +/******************************************************************************** + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2018 Intel Corporation. All Rights Reserved. + +*********************************************************************************/ + +#ifndef __MFX_CONFIG_H__ +#define __MFX_CONFIG_H__ + +/* Google versions of Android */ +#define MFX_O 0x06 +#define MFX_O_MR1 0x07 +#define MFX_P 0x08 +#define MFX_Q 0x09 +#define MFX_R 0x0a +#define MFX_S 0x0b +#define MFX_T 0x0c +#define MFX_U 0x0d + +#endif // #ifndef __MFX_CONFIG_H__ diff --git a/android/include/mfx_android_defs.h b/android/include/mfx_android_defs.h new file mode 100644 index 000000000..7052485a3 --- /dev/null +++ b/android/include/mfx_android_defs.h @@ -0,0 +1,57 @@ +// Copyright (c) 2017-2018 Intel Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#ifndef __MFX_ANDROID_DEFS_H__ +#define __MFX_ANDROID_DEFS_H__ + + #define MFX_ENABLE_ASC + #define MFX_ENABLE_CPLIB + + #define MFX_ENABLE_VPP + + #define MFX_ENABLE_VC1_VIDEO_DECODE + + #define MFX_ENABLE_H265_VIDEO_DECODE + #define MFX_ENABLE_H265_VIDEO_ENCODE + + #define MFX_ENABLE_H264_VIDEO_DECODE + #define MFX_ENABLE_H264_VIDEO_ENCODE + + #define MFX_ENABLE_MJPEG_VIDEO_DECODE + #define MFX_ENABLE_MJPEG_VIDEO_ENCODE + + #define MFX_ENABLE_MPEG2_VIDEO_ENCODE + #define MFX_ENABLE_MPEG2_VIDEO_DECODE + + #define MFX_ENABLE_VP8_VIDEO_DECODE + + #define MFX_ENABLE_VP9_VIDEO_DECODE + #define MFX_ENABLE_VP9_VIDEO_ENCODE + + #define MFX_ENABLE_AV1_VIDEO_DECODE + #define MFX_ENABLE_AV1_VIDEO_ENCODE + + #define MFX_ENABLE_EXT + +#if MFX_ANDROID_VERSION >= MFX_P + #define MFX_ENABLE_KERNELS +#endif + +#endif // #ifndef __MFX_ANDROID_DEFS_H__ diff --git a/android/mfx_defs.mk b/android/mfx_defs.mk new file mode 100644 index 000000000..bf103599e --- /dev/null +++ b/android/mfx_defs.mk @@ -0,0 +1,115 @@ +# Purpose: +# Defines include paths, compilation flags, etc. to build Media SDK targets. +# +# Defined variables: +# MFX_CFLAGS - common flags for all targets +# MFX_CFLAGS_LIBVA - LibVA support flags (to build apps with or without LibVA support) +# MFX_INCLUDES - common include paths for all targets +# libva_headers - include paths to LibVA headers +# MFX_LDFLAGS - common link flags for all targets + +# ============================================================================= +# Common definitions + +MFX_CFLAGS := -DANDROID + +#Media Version +MEDIA_VERSION := 24.1.5 +MEDIA_VERSION_EXTRA := "" +MEDIA_VERSION_ALL := $(MEDIA_VERSION).pre$(MEDIA_VERSION_EXTRA) + +MFX_CFLAGS += -DMEDIA_VERSION_STR=\"\\\"${MEDIA_VERSION}\\\"\" +MFX_CFLAGS += -DONEVPL_EXPERIMENTAL + +# Android version preference: +ifneq ($(filter 14 14.% U% ,$(PLATFORM_VERSION)),) + MFX_ANDROID_VERSION:= MFX_U +endif +ifneq ($(filter 13 13.% T% ,$(PLATFORM_VERSION)),) + MFX_ANDROID_VERSION:= MFX_T +endif +ifneq ($(filter 12 12.% S ,$(PLATFORM_VERSION)),) + MFX_ANDROID_VERSION:= MFX_S +endif +ifneq ($(filter 11 11.% R ,$(PLATFORM_VERSION)),) + MFX_ANDROID_VERSION:= MFX_R +endif +ifneq ($(filter 10 10.% Q ,$(PLATFORM_VERSION)),) + MFX_ANDROID_VERSION:= MFX_Q +endif +ifneq ($(filter 9 9.% P ,$(PLATFORM_VERSION)),) + MFX_ANDROID_VERSION:= MFX_P +endif +ifneq ($(filter 8.% O ,$(PLATFORM_VERSION)),) + ifneq ($(filter 8.0.%,$(PLATFORM_VERSION)),) + MFX_ANDROID_VERSION:= MFX_O + else + MFX_ANDROID_VERSION:= MFX_O_MR1 + endif +endif + +# Passing Android-dependency information to the code +MFX_CFLAGS += \ + -DMFX_ANDROID_VERSION=$(MFX_ANDROID_VERSION) \ + -include mfx_android_config.h + +MFX_CFLAGS += \ + -DMFX_VERSION=2009 + +MFX_CFLAGS += \ + -DMFX_FILE_VERSION=\"`echo $(MFX_VERSION) | cut -f 1 -d.``date +.%-y.%-m.%-d`\" \ + -DMFX_PRODUCT_VERSION=\"$(MFX_VERSION)\" + +# Security +MFX_CFLAGS += \ + -fstack-protector \ + -fPIE -fPIC -pie \ + -O2 -D_FORTIFY_SOURCE=2 \ + -Wformat -Wformat-security \ + -fexceptions -frtti -msse4.1 \ + -Wno-non-virtual-dtor \ + -Wunused-command-line-argument \ + -mavx2 + +# Enable feature with output decoded frames without latency regarding +# SPS.VUI.max_num_reorder_frames +ifeq ($(ENABLE_MAX_NUM_REORDER_FRAMES_OUTPUT),) + ENABLE_MAX_NUM_REORDER_FRAMES_OUTPUT:= true +endif + +ifeq ($(ENABLE_MAX_NUM_REORDER_FRAMES_OUTPUT),true) + MFX_CFLAGS += -DENABLE_MAX_NUM_REORDER_FRAMES_OUTPUT +endif + +# LibVA support. +MFX_CFLAGS_LIBVA := -DLIBVA_SUPPORT -DLIBVA_ANDROID_SUPPORT + +ifneq ($(filter $(MFX_ANDROID_VERSION), MFX_O),) + MFX_CFLAGS_LIBVA += -DANDROID_O +endif + +# Setting usual paths to include files +MFX_INCLUDES := $(LOCAL_PATH)/include + +LOCAL_HEADER_LIBRARIES := libmfx_gen_headers libva_headers + +# Setting usual link flags +MFX_LDFLAGS := \ + -z noexecstack \ + -z relro -z now + +# Setting vendor +LOCAL_MODULE_OWNER := intel + +# Moving executables to proprietary location +LOCAL_PROPRIETARY_MODULE := true + +LOCAL_CPPFLAGS := -Wno-deprecated-declarations \ + -Wno-missing-field-initializers \ + -Wno-implicit-fallthrough + + +# ============================================================================= + +# Definitions specific to Media SDK internal things (do not apply for samples) +include $(MFX_HOME)/android/mfx_defs_internal.mk diff --git a/android/mfx_defs_internal.mk b/android/mfx_defs_internal.mk new file mode 100644 index 000000000..334d2cbba --- /dev/null +++ b/android/mfx_defs_internal.mk @@ -0,0 +1,51 @@ +# Purpose: +# Defines include paths, compilation flags, etc. to build Media SDK +# internal targets (libraries, test applications, etc.). +# +# Defined variables: +# MFX_CFLAGS_INTERNAL - all flags needed to build MFX targets +# MFX_CFLAGS_INTERNAL_HW - all flags needed to build MFX HW targets +# MFX_INCLUDES_INTERNAL - all include paths needed to build MFX targets +# MFX_INCLUDES_INTERNAL_HW - all include paths needed to build MFX HW targets + +MFX_CFLAGS_INTERNAL := $(MFX_CFLAGS) +MFX_CFLAGS_INTERNAL_HW := \ + $(MFX_CFLAGS_INTERNAL) \ + -DMFX_VA \ + -DMFX_ONEVPL \ + -DMFX_VERSION_USE_LATEST \ + -DMFX_DEPRECATED_OFF \ + -DONEVPL_EXPERIMENTAL \ + -DSYNCHRONIZATION_BY_VA_SYNC_SURFACE \ + -D_FILE_OFFSET_BITS=64 \ + -D__USE_LARGEFILE64 \ + -DMFX_GIT_COMMIT=\"c6573984\" \ + -DMFX_API_VERSION=\"2.9+\" \ + -DNDEBUG \ + -DMSDK_BUILD=\"\" + +MFX_CFLAGS_INTERNAL_32 := -DLINUX32 +MFX_CFLAGS_INTERNAL_64 := -DLINUX32 -DLINUX64 + +MFX_INCLUDES_INTERNAL := \ + $(MFX_INCLUDES) \ + $(MFX_HOME)/_studio/shared/include \ + $(MFX_HOME)/_studio/shared/umc/codec/av1_dec/include \ + $(MFX_HOME)/_studio/shared/umc/codec/h265_dec/include \ + $(MFX_HOME)/_studio/shared/umc/codec/h264_dec/include \ + $(MFX_HOME)/_studio/shared/umc/codec/vp9_dec/include \ + $(MFX_HOME)/_studio/shared/umc/core/umc/include \ + $(MFX_HOME)/_studio/shared/umc/core/vm/include \ + $(MFX_HOME)/_studio/shared/umc/core/vm_plus/include \ + $(MFX_HOME)/_studio/shared/umc/io/umc_va/include \ + $(MFX_HOME)/_studio/shared/mfx_logging/include \ + $(MFX_HOME)/_studio/shared/mfx_trace/include \ + $(MFX_HOME)/_studio/shared/mfx_trace/include/sys \ + $(MFX_HOME)/_studio/mfx_lib/shared/include \ + $(MFX_HOME)/_studio/shared/include \ + $(MFX_HOME)/_studio/enctools/aenc/include \ + $(MFX_HOME)/_studio/enctools/include \ + $(MFX_HOME)/contrib/ipp/include + +MFX_INCLUDES_INTERNAL_HW := \ + $(MFX_INCLUDES_INTERNAL) \