├── .gitignore ├── .travis.yml ├── Android.mk ├── LICENSE.md ├── Makefile.am ├── NEWS ├── README.md ├── autogen.sh ├── build └── GenVer.py ├── capi ├── Android.mk ├── Makefile.am ├── Makefile.unittest ├── VideoDecoderCapi.cpp ├── VideoEncoderCapi.cpp └── unittest_main.cpp ├── codecparsers ├── Android.mk ├── Makefile.am ├── Makefile.unittest ├── README.ijg ├── bitReader.cpp ├── bitReader.h ├── bitReader_unittest.cpp ├── bitWriter.cpp ├── bitWriter.h ├── bitWriter_unittest.cpp ├── dboolhuff.AUTHORS ├── dboolhuff.LICENSE ├── dboolhuff.PATENTS ├── dboolhuff.c ├── dboolhuff.h ├── h264Parser.cpp ├── h264Parser.h ├── h264Parser_unittest.cpp ├── h265Parser.cpp ├── h265Parser.h ├── h265Parser_unittest.cpp ├── jpegParser.cpp ├── jpegParser.h ├── jpegParser_unittest.cpp ├── mpeg2_parser.cpp ├── mpeg2_parser.h ├── mpeg2_parser_unittest.cpp ├── nalReader.cpp ├── nalReader.h ├── nalReader_unittest.cpp ├── unittest_main.cpp ├── vc1Parser.cpp ├── vc1Parser.h ├── vc1Parser_unittest.cpp ├── vp8_bool_decoder.cpp ├── vp8_bool_decoder.h ├── vp8_bool_decoder_unittest.cpp ├── vp8_parser.cpp ├── vp8_parser.h ├── vp9parser.cpp ├── vp9parser.h ├── vp9quant.AUTHORS ├── vp9quant.LICENSE ├── vp9quant.PATENTS ├── vp9quant.c └── vp9quant.h ├── common.mk ├── common ├── Android.mk ├── Array.h ├── Functional.h ├── Makefile.am ├── Makefile.unittest ├── NonCopyable.h ├── PooledFrameAllocator.cpp ├── PooledFrameAllocator.h ├── Thread.cpp ├── Thread.h ├── Thread_unittest.cpp ├── YamiVersion.cpp ├── basesurfaceallocator.h ├── common_def.h ├── condition.h ├── factory.h ├── factory_unittest.cpp ├── factory_unittest.h ├── lock.h ├── log.cpp ├── log.h ├── nalreader.cpp ├── nalreader.h ├── nalreader_unittest.cpp ├── scopedlogger.h ├── surfacepool.cpp ├── surfacepool.h ├── unittest.h ├── unittest_main.cpp ├── utils.cpp ├── utils.h ├── utils_unittest.cpp └── videopool.h ├── configure.ac ├── decoder ├── Android.mk ├── DecoderApi_unittest.cpp ├── FrameData.h ├── Makefile.am ├── Makefile.unittest ├── unittest_main.cpp ├── vaapiDecoderJPEG.cpp ├── vaapiDecoderJPEG.h ├── vaapiDecoderJPEG_unittest.cpp ├── vaapidecoder_base.cpp ├── vaapidecoder_base.h ├── vaapidecoder_factory.h ├── vaapidecoder_fake.cpp ├── vaapidecoder_fake.h ├── vaapidecoder_h264.cpp ├── vaapidecoder_h264.h ├── vaapidecoder_h264_unittest.cpp ├── vaapidecoder_h265.cpp ├── vaapidecoder_h265.h ├── vaapidecoder_h265_unittest.cpp ├── vaapidecoder_host.cpp ├── vaapidecoder_host_unittest.cpp ├── vaapidecoder_mpeg2.cpp ├── vaapidecoder_mpeg2.h ├── vaapidecoder_mpeg2_unittest.cpp ├── vaapidecoder_vc1.cpp ├── vaapidecoder_vc1.h ├── vaapidecoder_vc1_unittest.cpp ├── vaapidecoder_vp8.cpp ├── vaapidecoder_vp8.h ├── vaapidecoder_vp8_unittest.cpp ├── vaapidecoder_vp9.cpp ├── vaapidecoder_vp9.h ├── vaapidecoder_vp9_unittest.cpp ├── vaapidecpicture.cpp ├── vaapidecpicture.h ├── vaapidecsurfacepool.cpp └── vaapidecsurfacepool.h ├── doc ├── Makefile.am ├── doc.config ├── infrastructure.png ├── infrastructure.vsdx └── mainpage.dox ├── egl ├── egl_util.c ├── egl_util.h ├── egl_vaapi_image.cpp └── egl_vaapi_image.h ├── encoder ├── Android.mk ├── Makefile.am ├── Makefile.unittest ├── unittest_main.cpp ├── vaapicodedbuffer.cpp ├── vaapicodedbuffer.h ├── vaapiencoder_base.cpp ├── vaapiencoder_base.h ├── vaapiencoder_factory.h ├── vaapiencoder_h264.cpp ├── vaapiencoder_h264.h ├── vaapiencoder_h264_unittest.cpp ├── vaapiencoder_hevc.cpp ├── vaapiencoder_hevc.h ├── vaapiencoder_hevc_unittest.cpp ├── vaapiencoder_host.cpp ├── vaapiencoder_host_unittest.cpp ├── vaapiencoder_jpeg.cpp ├── vaapiencoder_jpeg.h ├── vaapiencoder_jpeg_unittest.cpp ├── vaapiencoder_vp8.cpp ├── vaapiencoder_vp8.h ├── vaapiencoder_vp8_unittest.cpp ├── vaapiencoder_vp9.cpp ├── vaapiencoder_vp9.h ├── vaapiencoder_vp9_unittest.cpp ├── vaapiencpicture.cpp ├── vaapiencpicture.h ├── vaapilayerid.cpp └── vaapilayerid.h ├── gtestsrc ├── Makefile.am └── gtest │ ├── LICENSE │ ├── README.md │ ├── docs │ ├── AdvancedGuide.md │ ├── DevGuide.md │ ├── Documentation.md │ ├── FAQ.md │ ├── Primer.md │ ├── PumpManual.md │ ├── Samples.md │ └── XcodeGuide.md │ ├── include │ └── gtest │ │ ├── gtest-death-test.h │ │ ├── gtest-message.h │ │ ├── gtest-param-test.h │ │ ├── gtest-param-test.h.pump │ │ ├── gtest-printers.h │ │ ├── gtest-spi.h │ │ ├── gtest-test-part.h │ │ ├── gtest-typed-test.h │ │ ├── gtest.h │ │ ├── gtest_pred_impl.h │ │ ├── gtest_prod.h │ │ └── internal │ │ ├── custom │ │ ├── gtest-port.h │ │ ├── gtest-printers.h │ │ └── gtest.h │ │ ├── gtest-death-test-internal.h │ │ ├── gtest-filepath.h │ │ ├── gtest-internal.h │ │ ├── gtest-linked_ptr.h │ │ ├── gtest-param-util-generated.h │ │ ├── gtest-param-util-generated.h.pump │ │ ├── gtest-param-util.h │ │ ├── gtest-port-arch.h │ │ ├── gtest-port.h │ │ ├── gtest-string.h │ │ ├── gtest-tuple.h │ │ ├── gtest-tuple.h.pump │ │ ├── gtest-type-util.h │ │ └── gtest-type-util.h.pump │ └── src │ ├── gtest-all.cc │ ├── gtest-death-test.cc │ ├── gtest-filepath.cc │ ├── gtest-internal-inl.h │ ├── gtest-port.cc │ ├── gtest-printers.cc │ ├── gtest-test-part.cc │ ├── gtest-typed-test.cc │ ├── gtest.cc │ └── gtest_main.cc ├── interface ├── VideoCommonDefs.h ├── VideoDecoderCapi.h ├── VideoDecoderDefs.h ├── VideoDecoderHost.h ├── VideoDecoderInterface.h ├── VideoEncoderCapi.h ├── VideoEncoderDefs.h ├── VideoEncoderHost.h ├── VideoEncoderInterface.h ├── VideoPostProcessDefs.h ├── VideoPostProcessHost.h ├── VideoPostProcessInterface.h ├── Yami.h ├── YamiC.h ├── YamiVersion.h.in ├── v4l2_wrapper.h └── v4l2codec_device_ops.h ├── ocl ├── kernels │ ├── blend.cl │ ├── mosaic.cl │ ├── osd.cl │ ├── transform.cl │ └── wireframe.cl ├── oclcontext.cpp └── oclcontext.h ├── pkgconfig ├── Makefile.am ├── libyami.pc.in └── libyami_v4l2.pc.in ├── pre-commit ├── v4l2 ├── Android.mk ├── BufferPipe.h ├── Makefile.am ├── v4l2_codecbase.cpp ├── v4l2_codecbase.h ├── v4l2_decode.cpp ├── v4l2_decode.h ├── v4l2_encode.cpp ├── v4l2_encode.h └── v4l2_wrapper.cpp ├── vaapi ├── Android.mk ├── Makefile.am ├── Makefile.unittest ├── VaapiBuffer.cpp ├── VaapiBuffer.h ├── VaapiSurface.cpp ├── VaapiSurface.h ├── VaapiUtils.cpp ├── VaapiUtils.h ├── unittest_main.cpp ├── vaapicontext.cpp ├── vaapicontext.h ├── vaapidisplay.cpp ├── vaapidisplay.h ├── vaapidisplay_unittest.cpp ├── vaapipicture.cpp ├── vaapipicture.h ├── vaapiptrs.h ├── vaapistreamable.h ├── vaapisurfaceallocator.cpp └── vaapisurfaceallocator.h └── vpp ├── Android.mk ├── Makefile.am ├── Makefile.unittest ├── oclpostprocess_base.cpp ├── oclpostprocess_base.h ├── oclpostprocess_blender.cpp ├── oclpostprocess_blender.h ├── oclpostprocess_blender_unittest.cpp ├── oclpostprocess_mosaic.cpp ├── oclpostprocess_mosaic.h ├── oclpostprocess_mosaic_unittest.cpp ├── oclpostprocess_osd.cpp ├── oclpostprocess_osd.h ├── oclpostprocess_osd_unittest.cpp ├── oclpostprocess_transform.cpp ├── oclpostprocess_transform.h ├── oclpostprocess_transform_unittest.cpp ├── oclpostprocess_wireframe.cpp ├── oclpostprocess_wireframe.h ├── oclpostprocess_wireframe_unittest.cpp ├── oclvppimage.cpp ├── oclvppimage.h ├── unittest_main.cpp ├── vaapipostprocess_base.cpp ├── vaapipostprocess_base.h ├── vaapipostprocess_factory.h ├── vaapipostprocess_host.cpp ├── vaapipostprocess_host_unittest.cpp ├── vaapipostprocess_scaler.cpp ├── vaapipostprocess_scaler.h ├── vaapipostprocess_scaler_unittest.cpp ├── vaapivpppicture.cpp └── vaapivpppicture.h /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | config.h 4 | config.h.in 5 | stamp-h1 6 | libtool 7 | aclocal.m4 8 | configure 9 | config.log 10 | config.status 11 | *~ 12 | *.la 13 | *.lo 14 | .libs/ 15 | .deps/ 16 | autom4te.cache/ 17 | m4/ 18 | pkgconfig/ 19 | aux/ 20 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | LIBYAMICODEC_PATH := $(LOCAL_PATH) 3 | include $(CLEAR_VARS) 4 | include $(LIBYAMICODEC_PATH)/common.mk 5 | 6 | include $(LIBYAMICODEC_PATH)/common/Android.mk 7 | include $(LIBYAMICODEC_PATH)/codecparsers/Android.mk 8 | include $(LIBYAMICODEC_PATH)/vaapi/Android.mk 9 | include $(LIBYAMICODEC_PATH)/decoder/Android.mk 10 | include $(LIBYAMICODEC_PATH)/encoder/Android.mk 11 | include $(LIBYAMICODEC_PATH)/vpp/Android.mk 12 | include $(LIBYAMICODEC_PATH)/capi/Android.mk 13 | 14 | include $(CLEAR_VARS) 15 | include $(LIBYAMICODEC_PATH)/common.mk 16 | 17 | LOCAL_SHARED_LIBRARIES := \ 18 | liblog \ 19 | libva \ 20 | libva-android \ 21 | libc++ \ 22 | 23 | LOCAL_WHOLE_STATIC_LIBRARIES := \ 24 | libyami_common \ 25 | libcodecparser \ 26 | libyami_vaapi \ 27 | libyami_vpp \ 28 | libyami_decoder \ 29 | libyami_encoder \ 30 | libyami_capi \ 31 | 32 | LOCAL_EXPORT_C_INCLUDE_DIRS := \ 33 | $(LIBYAMICODEC_PATH)/interface 34 | 35 | LOCAL_PROPRIETARY_MODULE := true 36 | LOCAL_MODULE := libyami 37 | 38 | include $(BUILD_SHARED_LIBRARY) 39 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | # Extra clean files so that maintainer-clean removes *everything* 4 | DISTCLEANFILES = \ 5 | aclocal.m4 autom4te.cache compile config.guess config.sub \ 6 | configure config.h.in config.h.in~ depcomp install-sh ltmain.sh \ 7 | Makefile.in missing 8 | 9 | if ENABLE_TESTS 10 | SUBDIRS = gtestsrc common codecparsers vaapi decoder encoder vpp pkgconfig 11 | else 12 | SUBDIRS = common codecparsers vaapi decoder encoder vpp pkgconfig 13 | endif 14 | 15 | if ENABLE_DOCS 16 | SUBDIRS += doc 17 | endif 18 | 19 | SUBDIRS += capi 20 | 21 | if ENABLE_V4L2 22 | SUBDIRS += v4l2 23 | endif 24 | 25 | libyami_source_h = \ 26 | interface/Yami.h \ 27 | interface/YamiC.h \ 28 | $(NULL) 29 | 30 | lib_LTLIBRARIES = libyami.la 31 | libyami_la_SOURCES = 32 | libyami_includedir = $(includedir)/libyami 33 | libyami_include_HEADERS = $(libyami_source_h) 34 | # Dummy C++ source to cause C++ linking 35 | nodist_EXTRA_libyami_la_SOURCES = dummy.cxx 36 | libyami_la_LDFLAGS = \ 37 | $(LIBYAMI_LT_LDFLAGS) \ 38 | $(LIBVA_LIBS) \ 39 | $(LIBVA_DRM_LIBS) \ 40 | $(NULL) 41 | 42 | libyami_la_CPPFLAGS = \ 43 | $(LIBVA_CFLAGS) \ 44 | $(LIBVA_DRM_CFLAGS) \ 45 | $(NULL) 46 | 47 | libyami_la_LIBADD = common/libyami_common.la \ 48 | codecparsers/libyami_codecparser.la \ 49 | vaapi/libyami_vaapi.la \ 50 | decoder/libyami_decoder.la \ 51 | encoder/libyami_encoder.la \ 52 | vpp/libyami_vpp.la \ 53 | $(NULL) 54 | 55 | libyami_la_LIBADD += capi/libyami_capi.la 56 | 57 | if ENABLE_X11 58 | libyami_la_LDFLAGS += $(LIBVA_X11_LIBS) $(X11_LIBS) 59 | libyami_la_CPPFLAGS += $(LIBVA_X11_CFLAGS) 60 | endif 61 | 62 | libyami_la_LDFLAGS += $(AM_LDFLAGS) 63 | libyami_la_CPPFLAGS += $(AM_CPPFLAGS) 64 | 65 | if ENABLE_V4L2 66 | lib_LTLIBRARIES += libyami_v4l2.la 67 | libyami_v4l2_la_SOURCES = 68 | # Dummy C++ source to cause C++ linking 69 | nodist_EXTRA_libyami_v4l2_la_SOURCES = dummy.cxx 70 | # for library version 71 | libyami_v4l2_la_LDFLAGS = \ 72 | $(LIBYAMI_LT_LDFLAGS) \ 73 | $(AM_LDFLAGS) \ 74 | $(LIBVA_LIBS) \ 75 | $(LIBVA_DRM_LIBS) \ 76 | $(NULL) 77 | 78 | libyami_v4l2_la_LIBADD = libyami.la \ 79 | v4l2/libyamiv4l2.la \ 80 | $(NULL) 81 | endif 82 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | 2 | PROJECT="libyami" 3 | 4 | test -n "$srcdir" || srcdir="`dirname \"$0\"`" 5 | test -n "$srcdir" || srcdir=. 6 | 7 | if ! test -f "$srcdir/configure.ac"; then 8 | echo "Failed to find the top-level $PROJECT directory" 9 | exit 1 10 | fi 11 | 12 | olddir="`pwd`" 13 | cd "$srcdir" 14 | 15 | mkdir -p m4 16 | 17 | AUTORECONF=`which autoreconf` 18 | if test -z $AUTORECONF; then 19 | echo "*** No autoreconf found ***" 20 | exit 1 21 | else 22 | autoreconf -v --install || exit $? 23 | fi 24 | 25 | cd "$olddir" 26 | 27 | if test -z "$NOCONFIGURE"; then 28 | $srcdir/configure "$@" && echo "Now type 'make' to compile $PROJECT." 29 | fi 30 | -------------------------------------------------------------------------------- /build/GenVer.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | """ 3 | * Copyright (C) 2013 Intel Corporation. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | """ 17 | 18 | import re 19 | import os.path as path 20 | 21 | def query(config, name): 22 | m = re.search('m4_define\\(\\[' + name + '\\], *([0-9]*)\\)', config) 23 | return m.group(1) 24 | 25 | def replace(tpl, config, dest, src): 26 | v = query(config, src) 27 | return tpl.replace(dest, v) 28 | 29 | cur = path.dirname(__file__) 30 | root = path.abspath(path.join(cur, "..")) 31 | with open(path.join(root, "interface/YamiVersion.h.in")) as f: 32 | tpl = f.read() 33 | with open(path.join(root, "configure.ac")) as f: 34 | config = f.read() 35 | tpl = replace(tpl, config, '@YAMI_API_MAJOR_VERSION@', 'yami_api_major_version') 36 | tpl = replace(tpl, config, '@YAMI_API_MINOR_VERSION@', 'yami_api_minor_version') 37 | tpl = replace(tpl, config, '@YAMI_API_MICRO_VERSION@', 'yami_api_micro_version') 38 | 39 | with open(path.join(root, "interface/YamiVersion.h"), "w") as f: 40 | f.write(tpl) 41 | -------------------------------------------------------------------------------- /capi/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | include $(LOCAL_PATH)/../common.mk 4 | 5 | LOCAL_SRC_FILES := \ 6 | VideoDecoderCapi.cpp \ 7 | VideoEncoderCapi.cpp \ 8 | 9 | LOCAL_C_INCLUDES:= \ 10 | $(LOCAL_PATH)/.. \ 11 | $(LOCAL_PATH)/../common \ 12 | $(LOCAL_PATH)/../interface \ 13 | external/libcxx/include \ 14 | $(TARGET_OUT_HEADERS)/libva \ 15 | 16 | LOCAL_SHARED_LIBRARIES := \ 17 | liblog \ 18 | libc++ \ 19 | libva \ 20 | 21 | LOCAL_ALLOW_UNDEFINED_SYMBOLS := true 22 | 23 | LOCAL_PROPRIETARY_MODULE := true 24 | LOCAL_MODULE := libyami_capi 25 | include $(BUILD_STATIC_LIBRARY) 26 | -------------------------------------------------------------------------------- /capi/Makefile.am: -------------------------------------------------------------------------------- 1 | libyami_capi_source_c = \ 2 | VideoDecoderCapi.cpp \ 3 | VideoEncoderCapi.cpp \ 4 | $(NULL) 5 | 6 | libyami_capi_source_h = \ 7 | ../interface/VideoDecoderCapi.h \ 8 | ../interface/VideoEncoderCapi.h \ 9 | $(NULL) 10 | 11 | libyami_capi_source_h_priv = \ 12 | $(NULL) 13 | 14 | libyami_capi_ldflags = \ 15 | $(LIBYAMI_LT_LDFLAGS) \ 16 | $(NULL) 17 | 18 | #to compile within yocto 19 | extra_includes = \ 20 | -I$(top_srcdir) \ 21 | $(NULL) 22 | 23 | libyami_capi_cppflags = \ 24 | $(LIBVA_CFLAGS) \ 25 | -I$(top_srcdir)/interface \ 26 | $(extra_includes) \ 27 | $(NULL) 28 | 29 | noinst_LTLIBRARIES = libyami_capi.la 30 | libyami_capiincludedir = $(includedir)/libyami 31 | libyami_capiinclude_HEADERS = $(libyami_capi_source_h) 32 | noinst_HEADERS = $(libyami_capi_source_h_priv) 33 | libyami_capi_la_SOURCES = $(libyami_capi_source_c) 34 | libyami_capi_la_LDFLAGS = $(libyami_capi_ldflags) $(AM_LDFLAGS) 35 | libyami_capi_la_CPPFLAGS = $(libyami_capi_cppflags) $(AM_CPPFLAGS) 36 | 37 | if ENABLE_TESTS 38 | include Makefile.unittest 39 | endif 40 | 41 | DISTCLEANFILES = \ 42 | Makefile.in 43 | 44 | 45 | -------------------------------------------------------------------------------- /capi/Makefile.unittest: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = unittest 2 | 3 | unittest_SOURCES = \ 4 | unittest_main.cpp \ 5 | $(NULL) 6 | 7 | unittest_LDFLAGS = \ 8 | $(AM_LDFLAGS) \ 9 | -pthread \ 10 | $(NULL) 11 | 12 | unittest_LDADD = \ 13 | libyami_capi.la \ 14 | $(top_srcdir)/gtestsrc/libgtest.la \ 15 | $(NULL) 16 | 17 | unittest_CPPFLAGS = \ 18 | $(AM_CPPFLAGS) \ 19 | -I$(top_srcdir)/interface \ 20 | -I$(top_srcdir)/gtestsrc/gtest/include \ 21 | $(NULL) 22 | 23 | unittest_CXXFLAGS = \ 24 | $(AM_CXXFLAGS) \ 25 | $(NULL) 26 | 27 | check-local: unittest 28 | $(builddir)/unittest 29 | 30 | -------------------------------------------------------------------------------- /capi/unittest_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // library headers 18 | #include "common/unittest.h" 19 | 20 | int main(int argc, char **argv) { 21 | ::testing::InitGoogleTest(&argc, argv); 22 | return RUN_ALL_TESTS(); 23 | } 24 | -------------------------------------------------------------------------------- /codecparsers/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | include $(LOCAL_PATH)/../common.mk 4 | 5 | LOCAL_SRC_FILES := \ 6 | bitReader.cpp \ 7 | bitWriter.cpp \ 8 | h264Parser.cpp \ 9 | h265Parser.cpp \ 10 | jpegParser.cpp \ 11 | mpeg2_parser.cpp \ 12 | nalReader.cpp \ 13 | vc1Parser.cpp \ 14 | vp8_bool_decoder.cpp \ 15 | vp8_parser.cpp \ 16 | vp9parser.cpp \ 17 | vp9quant.c \ 18 | dboolhuff.c \ 19 | 20 | LOCAL_C_INCLUDES := \ 21 | $(LOCAL_PATH)/.. \ 22 | $(LOCAL_PATH)/../interface 23 | 24 | LOCAL_SHARED_LIBRARIES := \ 25 | libcutils \ 26 | liblog 27 | 28 | LOCAL_PROPRIETARY_MODULE := true 29 | LOCAL_MODULE := libcodecparser 30 | include $(BUILD_STATIC_LIBRARY) 31 | -------------------------------------------------------------------------------- /codecparsers/Makefile.unittest: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = unittest 2 | 3 | unittest_SOURCES = \ 4 | unittest_main.cpp \ 5 | bitReader_unittest.cpp \ 6 | nalReader_unittest.cpp \ 7 | bitWriter_unittest.cpp \ 8 | $(NULL) 9 | 10 | if BUILD_VP8_DECODER 11 | unittest_SOURCES += \ 12 | vp8_bool_decoder_unittest.cpp \ 13 | $(NULL) 14 | endif 15 | 16 | if BUILD_JPEG_PARSER 17 | unittest_SOURCES += \ 18 | jpegParser_unittest.cpp \ 19 | $(NULL) 20 | endif 21 | 22 | if BUILD_H264_DECODER 23 | unittest_SOURCES += \ 24 | h264Parser_unittest.cpp \ 25 | $(NULL) 26 | endif 27 | 28 | if BUILD_H265_DECODER 29 | unittest_SOURCES += \ 30 | h265Parser_unittest.cpp \ 31 | $(NULL) 32 | endif 33 | 34 | if BUILD_MPEG2_DECODER 35 | unittest_SOURCES += \ 36 | mpeg2_parser_unittest.cpp \ 37 | $(NULL) 38 | endif 39 | 40 | if BUILD_VC1_DECODER 41 | unittest_SOURCES += \ 42 | vc1Parser_unittest.cpp \ 43 | $(NULL) 44 | endif 45 | 46 | unittest_LDFLAGS = \ 47 | $(AM_LDFLAGS) \ 48 | -pthread \ 49 | $(NULL) 50 | 51 | unittest_LDADD = \ 52 | libyami_codecparser.la \ 53 | $(top_builddir)/common/libyami_common.la \ 54 | $(top_srcdir)/gtestsrc/libgtest.la \ 55 | $(NULL) 56 | 57 | unittest_CPPFLAGS = \ 58 | $(AM_CPPFLAGS) \ 59 | -I$(top_srcdir)/interface \ 60 | -I$(top_srcdir)/gtestsrc/gtest/include \ 61 | $(NULL) 62 | 63 | unittest_CXXFLAGS = \ 64 | $(AM_CXXFLAGS) \ 65 | $(NULL) 66 | 67 | check-local: unittest 68 | $(builddir)/unittest 69 | 70 | -------------------------------------------------------------------------------- /codecparsers/bitWriter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef bitWriter_h 18 | #define bitWriter_h 19 | 20 | #include 21 | #include 22 | 23 | namespace YamiParser { 24 | 25 | #define BIT_WRITER_DEFAULT_BUFFER_SIZE 0x1000 26 | 27 | class BitWriter { 28 | public: 29 | /* size is used to set bit stream buffer capacity, 30 | a default buffer size may be set to avoid memory reallocated frequently 31 | */ 32 | BitWriter(uint32_t size = BIT_WRITER_DEFAULT_BUFFER_SIZE); 33 | 34 | /* Write a value with numBits into bitstream */ 35 | bool writeBits(uint32_t value, uint32_t numBits); 36 | 37 | /* Write an array with numBytes into bitstream */ 38 | bool writeBytes(uint8_t* data, uint32_t numBytes); 39 | 40 | /* Pad some zeros to make sure bitsteam byte aligned */ 41 | void writeToBytesAligned(bool bit = false); 42 | 43 | /* get encoded bitstream buffer */ 44 | uint8_t* getBitWriterData(); 45 | 46 | /* get encoded bits count 47 | * it is recommended to call getCodedBitsCount prior to getBitWriterData, 48 | * because getBitWriterData may pad some bits to make sure byte aligned, 49 | * then the padded bits will be caculated as coded bits. 50 | * */ 51 | uint64_t getCodedBitsCount() const 52 | { 53 | return static_cast(m_bs.size() * 8) + m_bitsInCache; 54 | } 55 | 56 | protected: 57 | void flushCache(); 58 | 59 | std::vector m_bs; /* encoded bitstream buffer */ 60 | 61 | long int m_cache; /* a 32 or 64 bits cache buffer */ 62 | uint32_t m_bitsInCache; /* used bits in cache*/ 63 | }; 64 | 65 | } /*namespace YamiParser*/ 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /codecparsers/bitWriter_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // primary header 22 | #include "bitWriter.h" 23 | 24 | // library headers 25 | #include "common/unittest.h" 26 | 27 | namespace YamiParser { 28 | 29 | static const uint16_t writeArrary[16][2] = { 30 | { 1, 1 }, { 2, 2 }, { 3, 2 }, { 4, 3 }, 31 | { 5, 3 }, { 6, 3 }, { 7, 3 }, { 8, 4 }, 32 | { 9, 4 }, { 10, 4 }, { 11, 4 }, { 12, 4 }, 33 | { 13, 4 }, { 14, 4 }, { 15, 4 }, { 16, 5 } 34 | }; 35 | 36 | class BitWriterTest 37 | : public ::testing::Test { 38 | }; 39 | 40 | #define BITWriter_TEST(name) \ 41 | TEST_F(BitWriterTest, name) 42 | 43 | BITWriter_TEST(Writer_Simple) 44 | { 45 | BitWriter Writer; 46 | 47 | EXPECT_EQ(0u, Writer.getCodedBitsCount()); 48 | EXPECT_EQ(NULL, Writer.getBitWriterData()); 49 | 50 | uint32_t i, bitsSum; 51 | 52 | for (i = 0, bitsSum = 0; i < 16; i++) { 53 | EXPECT_TRUE(Writer.writeBits(writeArrary[i][0], writeArrary[i][1])); 54 | bitsSum += writeArrary[i][1]; 55 | } 56 | 57 | EXPECT_EQ(bitsSum, Writer.getCodedBitsCount()); 58 | } 59 | 60 | } // namespace YamiParser 61 | -------------------------------------------------------------------------------- /codecparsers/dboolhuff.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, The WebM Project authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of Google, nor the WebM Project, nor the names 16 | of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written 18 | permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /codecparsers/dboolhuff.PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the WebM Project. 5 | 6 | Google hereby grants to you a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer, and otherwise run, modify and propagate the contents of this 10 | implementation of VP8, where such license applies only to those patent 11 | claims, both currently owned by Google and acquired in the future, 12 | licensable by Google that are necessarily infringed by this 13 | implementation of VP8. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of VP8 or any code incorporated within this 19 | implementation of VP8 constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of VP8 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /codecparsers/dboolhuff.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | #include "dboolhuff.h" 13 | 14 | int 15 | vp8dx_start_decode (BOOL_DECODER * br, 16 | const unsigned char *source, 17 | unsigned int source_sz, vp8_decrypt_cb * decrypt_cb, void *decrypt_state) 18 | { 19 | br->user_buffer_end = source + source_sz; 20 | br->user_buffer = source; 21 | br->value = 0; 22 | br->count = -8; 23 | br->range = 255; 24 | br->decrypt_cb = decrypt_cb; 25 | br->decrypt_state = decrypt_state; 26 | 27 | if (source_sz && !source) 28 | return 1; 29 | 30 | /* Populate the buffer */ 31 | vp8dx_bool_decoder_fill (br); 32 | 33 | return 0; 34 | } 35 | 36 | void 37 | vp8dx_bool_decoder_fill (BOOL_DECODER * br) 38 | { 39 | const unsigned char *bufptr = br->user_buffer; 40 | VP8_BD_VALUE value = br->value; 41 | int count = br->count; 42 | int shift = VP8_BD_VALUE_SIZE - 8 - (count + 8); 43 | size_t bytes_left = br->user_buffer_end - bufptr; 44 | size_t bits_left = bytes_left * CHAR_BIT; 45 | int x = (int) (shift + CHAR_BIT - bits_left); 46 | int loop_end = 0; 47 | unsigned char decrypted[sizeof (VP8_BD_VALUE) + 1]; 48 | 49 | if (br->decrypt_cb) { 50 | size_t n = 51 | bytes_left > sizeof (decrypted) ? sizeof (decrypted) : bytes_left; 52 | br->decrypt_cb (br->decrypt_state, bufptr, decrypted, (int) n); 53 | bufptr = decrypted; 54 | } 55 | 56 | if (x >= 0) { 57 | count += VP8_LOTS_OF_BITS; 58 | loop_end = x; 59 | } 60 | 61 | if (x < 0 || bits_left) { 62 | while (shift >= loop_end) { 63 | count += CHAR_BIT; 64 | value |= (VP8_BD_VALUE) * bufptr << shift; 65 | ++bufptr; 66 | ++br->user_buffer; 67 | shift -= CHAR_BIT; 68 | } 69 | } 70 | 71 | br->value = value; 72 | br->count = count; 73 | } 74 | -------------------------------------------------------------------------------- /codecparsers/nalReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef nalReader_h 18 | #define nalReader_h 19 | 20 | #include "common/log.h" 21 | #include "bitReader.h" 22 | 23 | namespace YamiParser { 24 | 25 | class NalReader : public BitReader 26 | { 27 | public: 28 | NalReader(const uint8_t *data, uint32_t size); 29 | 30 | /*parse Exp-Golomb coding*/ 31 | bool readUe(uint32_t& v); 32 | inline bool readUe(uint8_t& v); 33 | inline bool readUe(uint16_t& v); 34 | uint32_t readUe(); 35 | bool readSe(int32_t& v); 36 | inline bool readSe(int8_t& v); 37 | inline bool readSe(int16_t& v); 38 | int32_t readSe(); 39 | 40 | bool moreRbspData() const; 41 | void rbspTrailingBits(); 42 | private: 43 | void loadDataToCache(uint32_t nbytes); 44 | inline bool isEmulationBytes(const uint8_t *p) const; 45 | }; 46 | 47 | bool NalReader::readUe(uint8_t& v) 48 | { 49 | uint32_t tmp; 50 | if (!readUe(tmp)) 51 | return false; 52 | v = tmp; 53 | return true; 54 | } 55 | 56 | bool NalReader::readUe(uint16_t& v) 57 | { 58 | uint32_t tmp; 59 | if (!readUe(tmp)) 60 | return false; 61 | v = tmp; 62 | return true; 63 | } 64 | 65 | bool NalReader::readSe(int8_t& v) 66 | { 67 | int32_t tmp; 68 | if (!readSe(tmp)) 69 | return false; 70 | v = tmp; 71 | return true; 72 | } 73 | 74 | bool NalReader::readSe(int16_t& v) 75 | { 76 | int32_t tmp; 77 | if (!readSe(tmp)) 78 | return false; 79 | v = tmp; 80 | return true; 81 | } 82 | 83 | } /*namespace YamiParser*/ 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /codecparsers/unittest_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // library headers 18 | #include "common/unittest.h" 19 | 20 | int main(int argc, char **argv) { 21 | ::testing::InitGoogleTest(&argc, argv); 22 | return RUN_ALL_TESTS(); 23 | } 24 | -------------------------------------------------------------------------------- /codecparsers/vp9quant.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, The WebM Project authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of Google, nor the WebM Project, nor the names 16 | of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written 18 | permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /codecparsers/vp9quant.PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the WebM Project. 5 | 6 | Google hereby grants to you a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer, and otherwise run, modify and propagate the contents of this 10 | implementation of VP8, where such license applies only to those patent 11 | claims, both currently owned by Google and acquired in the future, 12 | licensable by Google that are necessarily infringed by this 13 | implementation of VP8. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of VP8 or any code incorporated within this 19 | implementation of VP8 constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of VP8 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /codecparsers/vp9quant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #ifndef __VP9_QUANT_H__ 11 | #define __VP9_QUANT_H__ 12 | 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #define MAXQ 255 20 | #define QINDEX_RANGE 256 21 | #define QINDEX_BITS 8 22 | 23 | int clamp(int value, int low, int high); 24 | 25 | int16_t vp9_dc_quant(int bit_depth, int qindex, int delta); 26 | 27 | int16_t vp9_ac_quant(int bit_depth, int qindex, int delta); 28 | 29 | #ifdef __cplusplus 30 | }; 31 | #endif 32 | 33 | #endif //__VP9_QUANT_H__ 34 | -------------------------------------------------------------------------------- /common.mk: -------------------------------------------------------------------------------- 1 | LOCAL_CFLAGS := -D__ENABLE_DEBUG__ -Wno-sign-compare -Wno-unused-parameter -Wno-missing-braces -Wno-overloaded-virtual -O2 2 | LOCAL_CPPFLAGS := -D__ENABLE_DEBUG__ -Wno-sign-compare -Wno-unused-parameter -Wno-missing-braces -Wno-overloaded-virtual -O2 -std=c++11 3 | 4 | ENABLE-V4L2-OPS=true 5 | -------------------------------------------------------------------------------- /common/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | include $(LOCAL_PATH)/../common.mk 4 | 5 | ROOT := $(LOCAL_PATH)/../ 6 | GEN := $(ROOT)/interface/YamiVersion.h 7 | $(GEN) : $(ROOT)/interface/YamiVersion.h.in $(ROOT)/configure.ac 8 | @python3 $(ROOT)/build/GenVer.py 9 | 10 | LOCAL_GENERATED_SOURCES += $(GEN) 11 | 12 | LOCAL_SRC_FILES := \ 13 | log.cpp \ 14 | utils.cpp \ 15 | nalreader.cpp \ 16 | surfacepool.cpp \ 17 | PooledFrameAllocator.cpp \ 18 | YamiVersion.cpp \ 19 | 20 | LOCAL_C_INCLUDES:= \ 21 | $(LOCAL_PATH)/.. \ 22 | $(LOCAL_PATH)/../interface \ 23 | external/libcxx/include \ 24 | $(TARGET_OUT_HEADERS)/libva \ 25 | 26 | LOCAL_SHARED_LIBRARIES := \ 27 | liblog \ 28 | libva 29 | 30 | LOCAL_PROPRIETARY_MODULE := true 31 | LOCAL_MODULE := libyami_common 32 | include $(BUILD_STATIC_LIBRARY) 33 | -------------------------------------------------------------------------------- /common/Array.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef Array_h 18 | #define Array_h 19 | 20 | #if __cplusplus > 199711L 21 | #include 22 | #else 23 | #include 24 | namespace std { 25 | using std::tr1::array; 26 | } 27 | #endif // __cplusplus > 199711L 28 | 29 | #endif // Array_h 30 | -------------------------------------------------------------------------------- /common/Functional.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* orignal version of this file have been defined in VideoCommonDefs.h, 18 | but it will introduce compile error in gtest, so we define it here. 19 | it's reasonable since not all files need bind 20 | */ 21 | 22 | #ifndef Functional_h 23 | #define Functional_h 24 | 25 | #if __cplusplus > 199711L 26 | #include 27 | #else 28 | #include 29 | namespace std { 30 | using std::tr1::bind; 31 | using std::tr1::function; 32 | using std::tr1::ref; 33 | namespace placeholders { 34 | using std::tr1::placeholders::_1; 35 | using std::tr1::placeholders::_2; 36 | } 37 | } 38 | #endif // __cplusplus > 199711L 39 | 40 | #endif // Functional_h 41 | -------------------------------------------------------------------------------- /common/Makefile.am: -------------------------------------------------------------------------------- 1 | libyami_common_source_c = \ 2 | log.cpp \ 3 | utils.cpp \ 4 | nalreader.cpp \ 5 | surfacepool.cpp \ 6 | PooledFrameAllocator.cpp \ 7 | YamiVersion.cpp \ 8 | Thread.cpp \ 9 | $(NULL) 10 | 11 | libyami_common_source_h = \ 12 | ../interface/YamiVersion.h \ 13 | $(NULL) 14 | 15 | libyami_common_source_h_priv = \ 16 | Array.h \ 17 | NonCopyable.h \ 18 | Functional.h \ 19 | log.h \ 20 | utils.h \ 21 | common_def.h \ 22 | nalreader.h \ 23 | videopool.h \ 24 | surfacepool.h \ 25 | Thread.h \ 26 | $(NULL) 27 | 28 | libyami_common_ldflags = \ 29 | $(LIBYAMI_LT_LDFLAGS) \ 30 | $(LIBVA_LIBS) \ 31 | $(LIBVA_DRM_LIBS) \ 32 | -lpthread \ 33 | $(NULL) 34 | 35 | #to compile within yocto 36 | extra_includes = \ 37 | -I$(top_srcdir) \ 38 | $(NULL) 39 | 40 | libyami_common_cppflags = \ 41 | $(LIBVA_CFLAGS) \ 42 | -I$(top_srcdir)/interface \ 43 | -I$(top_builddir)/interface \ 44 | $(extra_includes) \ 45 | $(NULL) 46 | 47 | noinst_LTLIBRARIES = libyami_common.la 48 | libyami_commonincludedir = ${includedir}/libyami 49 | libyami_commoninclude_HEADERS = $(libyami_common_source_h) 50 | libyami_common_la_SOURCES = $(libyami_common_source_c) 51 | libyami_common_la_LDFLAGS = $(libyami_common_ldflags) $(AM_LDFLAGS) 52 | libyami_common_la_CPPFLAGS = $(libyami_common_cppflags) $(AM_CPPFLAGS) 53 | 54 | if ENABLE_TESTS 55 | include Makefile.unittest 56 | endif 57 | 58 | DISTCLEANFILES = \ 59 | Makefile.in\ 60 | YamiVersion.h \ 61 | $(NULL) 62 | 63 | 64 | -------------------------------------------------------------------------------- /common/Makefile.unittest: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = unittest 2 | 3 | unittest_SOURCES = \ 4 | unittest_main.cpp \ 5 | factory_unittest.cpp \ 6 | nalreader_unittest.cpp \ 7 | utils_unittest.cpp \ 8 | Thread_unittest.cpp \ 9 | $(NULL) 10 | 11 | 12 | 13 | unittest_LDFLAGS = \ 14 | $(AM_LDFLAGS) \ 15 | -pthread \ 16 | $(NULL) 17 | 18 | unittest_LDADD = \ 19 | libyami_common.la \ 20 | $(top_srcdir)/gtestsrc/libgtest.la \ 21 | $(NULL) 22 | 23 | unittest_CPPFLAGS = \ 24 | $(LIBVA_CFLAGS) \ 25 | $(AM_CPPFLAGS) \ 26 | -I$(top_srcdir)/interface \ 27 | -I$(top_srcdir)/gtestsrc/gtest/include \ 28 | $(NULL) 29 | 30 | unittest_CXXFLAGS = \ 31 | $(AM_CXXFLAGS) \ 32 | $(NULL) 33 | 34 | check-local: unittest 35 | $(builddir)/unittest 36 | 37 | -------------------------------------------------------------------------------- /common/NonCopyable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef NoCopyable_h 18 | #define NoCopyable_h 19 | 20 | #ifndef DISALLOW_COPY_AND_ASSIGN 21 | #define DISALLOW_COPY_AND_ASSIGN(className) \ 22 | className(const className&); \ 23 | className& operator=(const className&); 24 | #endif 25 | 26 | #endif //NoCopyable_h 27 | -------------------------------------------------------------------------------- /common/PooledFrameAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PooledFrameAllocator_h 18 | #define PooledFrameAllocator_h 19 | 20 | #include 21 | #include 22 | #include 23 | #include "common/videopool.h" 24 | 25 | 26 | namespace YamiMediaCodec { 27 | 28 | class FrameAllocator 29 | { 30 | public: 31 | virtual bool setFormat(uint32_t fourcc, int width, int height) = 0; 32 | virtual SharedPtr alloc() = 0; 33 | virtual ~FrameAllocator() {} 34 | }; 35 | 36 | class PooledFrameAllocator : public FrameAllocator 37 | { 38 | public: 39 | PooledFrameAllocator(const SharedPtr& display, int poolsize); 40 | bool setFormat(uint32_t fourcc, int width, int height); 41 | SharedPtr alloc(); 42 | 43 | private: 44 | SharedPtr m_display; 45 | SharedPtr > m_pool; 46 | int m_poolsize; 47 | }; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /common/Thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef Thread_h 18 | #define Thread_h 19 | 20 | #include "condition.h" 21 | #include "lock.h" 22 | #include "Functional.h" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace YamiMediaCodec { 29 | 30 | typedef std::function Job; 31 | 32 | class Thread { 33 | public: 34 | explicit Thread(const char* name = ""); 35 | ~Thread(); 36 | bool start(); 37 | //stop thread, this will waiting all post/sent job done 38 | void stop(); 39 | //post job to this thread 40 | void post(const Job&); 41 | //send job and wait it done 42 | bool send(const Job&); 43 | bool isCurrent(); 44 | 45 | private: 46 | //thread loop 47 | static void* init(void*); 48 | void loop(); 49 | void enqueue(const Job& r); 50 | void sendJob(const Job& r, bool& flag); 51 | 52 | std::string m_name; 53 | bool m_started; 54 | pthread_t m_thread; 55 | 56 | Lock m_lock; 57 | Condition m_cond; 58 | Condition m_sent; 59 | std::deque m_queue; 60 | 61 | static const pthread_t INVALID_ID = (pthread_t)-1; 62 | 63 | DISALLOW_COPY_AND_ASSIGN(Thread); 64 | }; 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /common/Thread_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // primary header 22 | #include "Thread.h" 23 | 24 | #include "common/unittest.h" 25 | #include "common/log.h" 26 | 27 | namespace YamiMediaCodec { 28 | 29 | using namespace std; 30 | 31 | #define THREAD_TEST(name) \ 32 | TEST(ThreadTest, name) 33 | 34 | void add(int& v) 35 | { 36 | v++; 37 | } 38 | 39 | void sleepAndAdd(Thread& t, int seconds, int& v) 40 | { 41 | sleep(seconds); 42 | EXPECT_FALSE(t.isCurrent()); 43 | t.post(bind(add, ref(v))); 44 | } 45 | 46 | void checkSum(int& v, int expected) 47 | { 48 | EXPECT_EQ(expected, v); 49 | } 50 | 51 | void isCurrent(Thread& t) 52 | { 53 | EXPECT_TRUE(t.isCurrent()); 54 | } 55 | 56 | void emptyJob() 57 | { 58 | /* nothing */ 59 | } 60 | 61 | void sendJob(Thread& t, Job job) 62 | { 63 | t.send(job); 64 | } 65 | 66 | THREAD_TEST(FullTest) 67 | { 68 | std::cout << "this may take some time" << std::endl; 69 | 70 | Thread t[3]; 71 | 72 | //check start 73 | for (int i = 0; i < 3; i++) { 74 | EXPECT_TRUE(t[i].start()); 75 | } 76 | 77 | //post 78 | int v = 0; 79 | for (int i = 0; i < 5; i++) { 80 | t[0].post(bind(sleepAndAdd, ref(t[2]), 1, ref(v))); 81 | } 82 | for (int i = 0; i < 5; i++) { 83 | t[1].post(bind(sleepAndAdd, ref(t[2]), 2, ref(v))); 84 | } 85 | 86 | //make sure we can send message from diffrent thread 87 | t[0].send(bind(sendJob, ref(t[2]), emptyJob)); 88 | t[1].send(bind(sendJob, ref(t[2]), emptyJob)); 89 | 90 | //is current 91 | t[2].send(bind(isCurrent, ref(t[2]))); 92 | 93 | for (int i = 0; i < 3; i++) { 94 | EXPECT_TRUE(t[i].send(bind(isCurrent, ref(t[i])))); 95 | t[i].stop(); 96 | } 97 | EXPECT_EQ(10, v); 98 | 99 | //send after stop 100 | EXPECT_FALSE(t[2].send(bind(checkSum, ref(v), 11))); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /common/YamiVersion.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | #include "YamiVersion.h" 22 | 23 | void yamiGetApiVersion(uint32_t *apiVersion) 24 | { 25 | *apiVersion = YAMI_API_VERSION; 26 | } 27 | -------------------------------------------------------------------------------- /common/common_def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __COMMON_DEF_H__ 18 | #define __COMMON_DEF_H__ 19 | 20 | #ifndef BOOL 21 | #define BOOL int 22 | #endif 23 | 24 | #ifndef TRUE 25 | #define TRUE 1 26 | #endif 27 | 28 | #ifndef FALSE 29 | #define FALSE 0 30 | #endif 31 | 32 | #ifndef CHAR_BIT 33 | #define CHAR_BIT 8 34 | #endif 35 | 36 | 37 | #ifndef MIN 38 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 39 | #endif 40 | 41 | #ifndef MAX 42 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 43 | #endif 44 | 45 | #define CLIP(a, min, max) do { \ 46 | a = (MIN(max, MAX(a, min))); \ 47 | } while (0) 48 | 49 | #ifndef N_ELEMENTS 50 | #define N_ELEMENTS(array) (sizeof(array)/sizeof(array[0])) 51 | #endif 52 | 53 | #ifndef ALIGN_POW2 54 | #define ALIGN_POW2(a, b) ((a + (b - 1)) & ~(b - 1)) 55 | #endif 56 | 57 | #ifndef ALIGN2 58 | #define ALIGN2(a) ALIGN_POW2(a, 2) 59 | #endif 60 | 61 | #ifndef ALIGN8 62 | #define ALIGN8(a) ALIGN_POW2(a, 8) 63 | #endif 64 | 65 | #ifndef ALIGN16 66 | #define ALIGN16(a) ALIGN_POW2(a, 16) 67 | #endif 68 | 69 | #ifndef ALIGN32 70 | #define ALIGN32(a) ALIGN_POW2(a, 32) 71 | #endif 72 | 73 | #ifndef RETURN_IF_FAIL 74 | #define RETURN_IF_FAIL(condition) \ 75 | do{ \ 76 | if (!(condition)) \ 77 | return; \ 78 | }while(0) 79 | #endif 80 | 81 | #ifndef RETURN_VAL_IF_FAIL 82 | #define RETURN_VAL_IF_FAIL(condition, value) \ 83 | do{ \ 84 | if (!(condition)) \ 85 | return (value); \ 86 | }while(0) 87 | #endif 88 | 89 | #define PARAMETER_ASSIGN(a, b) memcpy(&(a), &(b), sizeof(b)) 90 | #endif //__COMMON_DEF_H__ 91 | -------------------------------------------------------------------------------- /common/condition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef condition_h 17 | #define condition_h 18 | 19 | #include "NonCopyable.h" 20 | #include "VideoCommonDefs.h" 21 | 22 | #include "lock.h" 23 | 24 | namespace YamiMediaCodec{ 25 | 26 | class Condition 27 | { 28 | public: 29 | explicit Condition(Lock& lock):m_lock(lock) 30 | { 31 | pthread_cond_init(&m_cond, NULL); 32 | } 33 | 34 | ~Condition() 35 | { 36 | pthread_cond_destroy(&m_cond); 37 | } 38 | 39 | void wait() 40 | { 41 | pthread_cond_wait(&m_cond, &m_lock.m_lock); 42 | } 43 | 44 | void signal() 45 | { 46 | pthread_cond_signal(&m_cond); 47 | } 48 | 49 | void broadcast() 50 | { 51 | pthread_cond_broadcast(&m_cond); 52 | } 53 | 54 | private: 55 | Lock& m_lock; 56 | pthread_cond_t m_cond; 57 | DISALLOW_COPY_AND_ASSIGN(Condition); 58 | 59 | }; 60 | 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /common/factory_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // primary header 22 | #include "factory.h" 23 | 24 | // library headers 25 | #include "common/unittest.h" 26 | 27 | #define FACTORY_TEST(name) \ 28 | TEST(FactoryTest, name) 29 | 30 | class Base { 31 | public: 32 | virtual ~Base() { } 33 | }; 34 | 35 | class A : public Base { }; 36 | class B : public Base { }; 37 | class C : public Base { }; 38 | 39 | // Attempt to expose what is commonly referred to as the 40 | // "static initialization order fiasco". 41 | // If the unittest program segfaults during pre-main static 42 | // initialization, then we've likely introduced an initialization 43 | // order bug. 44 | const bool rA = Factory::register_("A"); 45 | 46 | FACTORY_TEST(Register) { 47 | EXPECT_TRUE(rA); 48 | EXPECT_TRUE(Factory::register_("B")); 49 | EXPECT_TRUE(Factory::register_("B2")); 50 | EXPECT_TRUE(Factory::register_("C")); 51 | EXPECT_FALSE(Factory::register_("A")); 52 | EXPECT_FALSE(Factory::register_("B")); 53 | EXPECT_FALSE(Factory::register_("C")); 54 | } 55 | 56 | FACTORY_TEST(Create) { 57 | Base* a = Factory::create("A"); 58 | Base* z = Factory::create("Z"); 59 | 60 | EXPECT_TRUE(a != NULL); 61 | EXPECT_TRUE(z == NULL); 62 | EXPECT_TRUE(dynamic_cast(a) != NULL); 63 | EXPECT_TRUE(dynamic_cast(a) == NULL); 64 | 65 | delete a; 66 | delete z; 67 | } 68 | -------------------------------------------------------------------------------- /common/factory_unittest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // primary header 18 | #include "common/factory.h" 19 | 20 | // library headers 21 | #include "common/unittest.h" 22 | 23 | // system headers 24 | #include 25 | 26 | template 27 | class FactoryTest 28 | : public ::testing::Test { 29 | protected: 30 | typedef std::vector::KeyType> FactoryKeys; 31 | 32 | void doFactoryTest(const FactoryKeys& keys) { 33 | ::testing::StaticAssertTypeEq::Type>(); 34 | 35 | EXPECT_TRUE(Derived::s_registered); 36 | 37 | const typename FactoryKeys::const_iterator end(keys.end()); 38 | for ( typename FactoryKeys::const_iterator key(keys.begin()); 39 | key != end; ++key) { 40 | SCOPED_TRACE("key: " + *key); 41 | 42 | ASSERT_FALSE(Factory::template register_(*key)); 43 | 44 | Base* object(NULL); 45 | 46 | ASSERT_TRUE(object == NULL); 47 | 48 | object = Factory::create(*key); 49 | 50 | EXPECT_TRUE(object != NULL); 51 | 52 | EXPECT_TRUE(dynamic_cast(object)); 53 | 54 | delete object; 55 | } 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /common/lock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef lock_h 17 | #define lock_h 18 | 19 | #include "NonCopyable.h" 20 | #include 21 | 22 | namespace YamiMediaCodec{ 23 | 24 | class Lock 25 | { 26 | public: 27 | Lock() 28 | { 29 | pthread_mutex_init(&m_lock, NULL); 30 | } 31 | 32 | ~Lock() 33 | { 34 | pthread_mutex_destroy(&m_lock); 35 | } 36 | 37 | void acquire() 38 | { 39 | pthread_mutex_lock(&m_lock); 40 | } 41 | 42 | void release() 43 | { 44 | pthread_mutex_unlock(&m_lock); 45 | } 46 | 47 | void tryLock() 48 | { 49 | pthread_mutex_trylock(&m_lock); 50 | } 51 | 52 | friend class Condition; 53 | 54 | private: 55 | pthread_mutex_t m_lock; 56 | DISALLOW_COPY_AND_ASSIGN(Lock); 57 | }; 58 | 59 | class AutoLock 60 | { 61 | public: 62 | explicit AutoLock(Lock& lock) : m_lock(lock) 63 | { 64 | m_lock.acquire(); 65 | } 66 | ~AutoLock() 67 | { 68 | m_lock.release(); 69 | } 70 | Lock& m_lock; 71 | private: 72 | DISALLOW_COPY_AND_ASSIGN(AutoLock); 73 | }; 74 | 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /common/nalreader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | #include 22 | #include "nalreader.h" 23 | 24 | namespace YamiMediaCodec{ 25 | 26 | NalReader::NalReader(const uint8_t* buf, int32_t size, uint32_t nalLengthSize, bool asWhole) 27 | { 28 | m_begin = buf; 29 | m_next = buf; 30 | m_end = buf + size; 31 | m_asWhole = asWhole; 32 | 33 | m_nalLengthSize = nalLengthSize; 34 | m_size = 0; 35 | 36 | searchNalStart(); 37 | } 38 | 39 | bool NalReader::read(const uint8_t*& nal, int32_t& nalSize) 40 | { 41 | if (m_next == m_end) 42 | return false; 43 | 44 | nal = m_next; 45 | const uint8_t* nalEnd; 46 | if (m_asWhole) { 47 | nalEnd = m_end; 48 | m_next = m_end; 49 | } else { 50 | nalEnd = searchNalStart(); 51 | } 52 | nalSize = nalEnd - nal; 53 | return true; 54 | } 55 | 56 | static const uint8_t START_CODE[] = { 0, 0, 1 }; 57 | static const int START_CODE_SIZE = 3; 58 | static const uint8_t* START_CODE_END = START_CODE + START_CODE_SIZE; 59 | 60 | const uint8_t* NalReader::searchStartCode() 61 | { 62 | m_begin = std::search(m_next, m_end, START_CODE, START_CODE_END); 63 | 64 | if (m_begin != m_end) { 65 | m_next = m_begin + START_CODE_SIZE; 66 | } else { 67 | m_next = m_end; 68 | } 69 | return m_begin; 70 | } 71 | 72 | const uint8_t* NalReader::searchNalStart() 73 | { 74 | if (!m_nalLengthSize) 75 | return searchStartCode(); 76 | 77 | if (m_end > m_begin + m_size + m_nalLengthSize) { 78 | m_begin += m_size; 79 | } else { 80 | m_begin = m_next = m_end; 81 | return m_begin; 82 | } 83 | 84 | uint32_t i, size; 85 | m_next = m_begin + m_nalLengthSize; 86 | 87 | for (i = 0, size = 0; i < m_nalLengthSize; i++) 88 | size = (size << 8) | m_begin[i]; 89 | 90 | m_size = m_nalLengthSize + size; 91 | 92 | return m_begin; 93 | } 94 | } //namespace YamiMediaCodec 95 | -------------------------------------------------------------------------------- /common/nalreader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | namespace YamiMediaCodec{ 19 | 20 | class NalReader 21 | { 22 | public: 23 | NalReader(const uint8_t* buf, int32_t size, uint32_t nalLengthSize = 0, bool asWhole = false); 24 | 25 | /*nal point to the nal unit without start code or length bytes*/ 26 | bool read(const uint8_t*& nal, int32_t& nalSize); 27 | 28 | private: 29 | const uint8_t* searchNalStart(); 30 | const uint8_t* searchStartCode(); 31 | const uint8_t* m_begin; 32 | const uint8_t* m_next; 33 | const uint8_t* m_end; 34 | bool m_asWhole; 35 | uint32_t m_nalLengthSize; 36 | uint32_t m_size; 37 | }; 38 | 39 | } //namespace YamiMediaCodec 40 | -------------------------------------------------------------------------------- /common/scopedlogger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef scopedlogger_h 18 | #define scopedlogger_h 19 | 20 | /*it's expensive, disable it by default*/ 21 | #define DISABLE_SCOPED_LOGGER 22 | #ifndef DISABLE_SCOPED_LOGGER 23 | #include "log.h" 24 | 25 | class ScopedLogger { 26 | public: 27 | ScopedLogger(const char *str) 28 | { 29 | m_str = str; 30 | INFO("+%s", m_str); 31 | } 32 | ~ScopedLogger() 33 | { 34 | INFO("-%s", m_str); 35 | } 36 | 37 | private: 38 | const char *m_str; 39 | }; 40 | 41 | #define FUNC_ENTER() ScopedLogger __func_loggger__(__func__) 42 | #else 43 | #define FUNC_ENTER() 44 | #endif 45 | 46 | #endif //scopedlogger_h 47 | -------------------------------------------------------------------------------- /common/surfacepool.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | #include "surfacepool.h" 22 | 23 | #include "common/log.h" 24 | 25 | namespace YamiMediaCodec{ 26 | 27 | SharedPtr 28 | SurfacePool::create(const SharedPtr& alloc, 29 | uint32_t fourcc, uint32_t width, uint32_t height, uint32_t size) 30 | { 31 | SharedPtr pool(new SurfacePool); 32 | if (YAMI_SUCCESS != pool->init(alloc, fourcc, width, height, size)) 33 | pool.reset(); 34 | return pool; 35 | } 36 | 37 | SurfacePool::SurfacePool() 38 | { 39 | memset(&m_params, 0, sizeof(m_params)); 40 | } 41 | 42 | YamiStatus SurfacePool::init(const SharedPtr& alloc, 43 | uint32_t fourcc, uint32_t width, uint32_t height, uint32_t size) 44 | { 45 | m_params.fourcc = fourcc; 46 | m_params.width = width; 47 | m_params.height = height; 48 | m_params.size = size; 49 | YamiStatus status = alloc->alloc(alloc.get(), &m_params); 50 | if (status != YAMI_SUCCESS) 51 | return status; 52 | 53 | //prepare surfaces for pool 54 | std::deque surfaces; 55 | for (uint32_t i = 0; i < m_params.size; i++) { 56 | SurfacePtr s(new VaapiSurface(m_params.surfaces[i], width, height, fourcc)); 57 | surfaces.push_back(s); 58 | } 59 | m_pool.reset(new VideoPool(surfaces)); 60 | if (!m_pool) { 61 | ERROR("failed to create Surface Pool"); 62 | return YAMI_OUT_MEMORY; 63 | } 64 | 65 | m_alloc = alloc; 66 | return YAMI_SUCCESS; 67 | } 68 | 69 | SurfacePool::~SurfacePool() 70 | { 71 | if (m_alloc) { 72 | m_alloc->free(m_alloc.get(), &m_params); 73 | } 74 | } 75 | 76 | SurfacePtr SurfacePool::alloc() 77 | { 78 | return m_pool->alloc(); 79 | } 80 | 81 | } //YamiMediaCodec 82 | -------------------------------------------------------------------------------- /common/surfacepool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef surfacepool_h 18 | #define surfacepool_h 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include "config.h" 22 | #endif 23 | 24 | #include "common/log.h" 25 | #include "common/videopool.h" 26 | #include "VideoCommonDefs.h" 27 | /* we should not include vaapi surface here, 28 | * but we have no choose before we make VaapiSurface more generic, 29 | * and rename it to Surface 30 | */ 31 | #include "vaapi/vaapiptrs.h" 32 | #include "vaapi/VaapiSurface.h" 33 | #include 34 | 35 | namespace YamiMediaCodec{ 36 | 37 | class SurfacePool 38 | { 39 | public: 40 | static SharedPtr 41 | create(const SharedPtr& alloc, 42 | uint32_t fourcc, uint32_t width, uint32_t height, uint32_t size); 43 | 44 | /** 45 | * allocator surface from pool, if no avaliable surface it will return NULL 46 | */ 47 | SurfacePtr alloc(); 48 | 49 | /** 50 | * peek surfaces from surface pool. 51 | */ 52 | template 53 | void peekSurfaces(std::vector& surfaces); 54 | ~SurfacePool(); 55 | private: 56 | SurfacePool(); 57 | 58 | YamiStatus init(const SharedPtr& alloc, 59 | uint32_t fourcc, uint32_t width, uint32_t height, uint32_t size); 60 | 61 | SharedPtr m_alloc; 62 | SurfaceAllocParams m_params; 63 | SharedPtr > m_pool; 64 | DISALLOW_COPY_AND_ASSIGN(SurfacePool) 65 | 66 | }; 67 | 68 | template 69 | void SurfacePool::peekSurfaces(std::vector& surfaces) 70 | { 71 | ASSERT(surfaces.size() == 0); 72 | ASSERT(m_alloc); 73 | for (uint32_t i = 0; i < m_params.size; i++) { 74 | surfaces.push_back((S)m_params.surfaces[i]); 75 | } 76 | } 77 | 78 | } //YamiMediaCodec 79 | 80 | #endif //#define surfacepool_h 81 | -------------------------------------------------------------------------------- /common/unittest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef unittest_h 18 | #define unittest_h 19 | 20 | /* 21 | * The following #define prevents gtest from using it's own tr1 tuple 22 | * implementation. This is necessary since we use C++11 and/or the system 23 | * provided tr1/tuple[.h] in this project. The gtest header appears to 24 | * incorrectly detect the availability of the system tr1/tuple[.h] and thus 25 | * tries to use it's own implementation of it... and thus will cause compile 26 | * failures due to duplicate definitions of tr1::tuple. 27 | */ 28 | #define GTEST_USE_OWN_TR1_TUPLE 0 29 | 30 | #include 31 | 32 | #endif // unittest_h 33 | -------------------------------------------------------------------------------- /common/unittest_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // library headers 22 | #include "common/unittest.h" 23 | 24 | int main(int argc, char **argv) { 25 | ::testing::InitGoogleTest(&argc, argv); 26 | return RUN_ALL_TESTS(); 27 | } 28 | -------------------------------------------------------------------------------- /common/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef utils_h 17 | #define utils_h 18 | 19 | #include 20 | #include 21 | 22 | #include "VideoCommonDefs.h" 23 | 24 | #ifndef VA_FOURCC_I420 25 | #define VA_FOURCC_I420 VA_FOURCC('I','4','2','0') 26 | #endif 27 | 28 | namespace YamiMediaCodec{ 29 | 30 | uint32_t guessFourcc(const char* fileName); 31 | 32 | bool guessResolution(const char* filename, int& w, int& h); 33 | 34 | bool getPlaneResolution(uint32_t fourcc, uint32_t pixelWidth, uint32_t pixelHeight, uint32_t byteWidth[3], uint32_t byteHeight[3], uint32_t& planes); 35 | 36 | bool fillFrameRawData(VideoFrameRawData* frame, uint32_t fourcc, uint32_t width, uint32_t height, uint8_t* data); 37 | 38 | class CalcFps 39 | { 40 | public: 41 | CalcFps() { m_timeStart = 0;}; 42 | void setAnchor(); 43 | float fps(uint32_t frameCount); 44 | 45 | private: 46 | uint64_t m_timeStart; 47 | }; 48 | 49 | //slim version of CalcFps, hide all fps all fps detials. 50 | class FpsCalc 51 | { 52 | public: 53 | FpsCalc(); 54 | void addFrame(); 55 | void log(); 56 | private: 57 | int m_frames; 58 | uint64_t m_start; 59 | uint64_t m_netStart; 60 | static const int NET_FPS_START = 5; 61 | }; 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /common/videopool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef videopool_h 17 | #define videopool_h 18 | #include "VideoCommonDefs.h" 19 | #include "common/lock.h" 20 | #include 21 | 22 | namespace YamiMediaCodec{ 23 | 24 | template 25 | class VideoPool : public EnableSharedFromThis > 26 | { 27 | public: 28 | VideoPool(std::deque >& buffers) 29 | { 30 | m_holder.swap(buffers); 31 | for (size_t i = 0; i < m_holder.size(); i++) { 32 | m_freed.push_back(m_holder[i].get()); 33 | } 34 | } 35 | 36 | SharedPtr alloc() 37 | { 38 | SharedPtr ret; 39 | AutoLock _l(m_lock); 40 | if (!m_freed.empty()) { 41 | T* p = m_freed.front(); 42 | m_freed.pop_front(); 43 | ret.reset(p, Recycler(this->shared_from_this())); 44 | } 45 | return ret; 46 | } 47 | 48 | private: 49 | 50 | void recycle(T* ptr) 51 | { 52 | AutoLock _l(m_lock); 53 | m_freed.push_back(ptr); 54 | } 55 | 56 | class Recycler 57 | { 58 | public: 59 | Recycler(const SharedPtr >& pool) 60 | :m_pool(pool) 61 | { 62 | } 63 | void operator()(T* ptr) const 64 | { 65 | m_pool->recycle(ptr); 66 | } 67 | private: 68 | SharedPtr > m_pool; 69 | }; 70 | 71 | Lock m_lock; 72 | std::deque m_freed; 73 | std::deque > m_holder; 74 | }; 75 | 76 | }; 77 | #endif //videopool_h 78 | -------------------------------------------------------------------------------- /decoder/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | include $(LOCAL_PATH)/../common.mk 4 | 5 | LOCAL_SRC_FILES := \ 6 | vaapidecoder_base.cpp \ 7 | vaapidecoder_host.cpp \ 8 | vaapidecsurfacepool.cpp \ 9 | vaapidecpicture.cpp \ 10 | 11 | LOCAL_SRC_FILES += \ 12 | vaapidecoder_h264.cpp 13 | 14 | LOCAL_SRC_FILES += \ 15 | vaapidecoder_h265.cpp 16 | 17 | LOCAL_SRC_FILES += \ 18 | vaapidecoder_vp8.cpp 19 | 20 | LOCAL_SRC_FILES += \ 21 | vaapidecoder_vp9.cpp 22 | 23 | LOCAL_SRC_FILES += \ 24 | vaapidecoder_vc1.cpp 25 | 26 | LOCAL_SRC_FILES += \ 27 | vaapidecoder_mpeg2.cpp 28 | 29 | LOCAL_SRC_FILES += \ 30 | vaapiDecoderJPEG.cpp 31 | 32 | LOCAL_SRC_FILES += \ 33 | vaapidecoder_fake.cpp 34 | 35 | LOCAL_C_INCLUDES:= \ 36 | $(LOCAL_PATH)/.. \ 37 | $(LOCAL_PATH)/../common \ 38 | $(LOCAL_PATH)/../interface \ 39 | external/libcxx/include \ 40 | $(TARGET_OUT_HEADERS)/libva \ 41 | 42 | LOCAL_CFLAGS := \ 43 | -D__BUILD_H264_DECODER__=1 \ 44 | -D__BUILD_H265_DECODER__=1 \ 45 | -D__BUILD_VP8_DECODER__=1 \ 46 | -D__BUILD_VP9_DECODER__=1 \ 47 | -D__BUILD_VC1_DECODER__=1 \ 48 | -D__BUILD_MPEG2_DECODER__=1 \ 49 | -D__BUILD_JPEG_DECODER__=1 \ 50 | 51 | 52 | LOCAL_SHARED_LIBRARIES := \ 53 | liblog \ 54 | libc++ \ 55 | libva \ 56 | 57 | LOCAL_ALLOW_UNDEFINED_SYMBOLS := true 58 | 59 | LOCAL_PROPRIETARY_MODULE := true 60 | LOCAL_MODULE := libyami_decoder 61 | include $(BUILD_STATIC_LIBRARY) 62 | -------------------------------------------------------------------------------- /decoder/Makefile.unittest: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = unittest 2 | 3 | unittest_SOURCES = \ 4 | unittest_main.cpp \ 5 | $(NULL) 6 | 7 | if BUILD_VP8_DECODER 8 | unittest_SOURCES += vaapidecoder_vp8_unittest.cpp 9 | endif 10 | 11 | if BUILD_JPEG_DECODER 12 | unittest_SOURCES += vaapiDecoderJPEG_unittest.cpp 13 | endif 14 | 15 | if BUILD_H264_DECODER 16 | unittest_SOURCES += vaapidecoder_h264_unittest.cpp 17 | endif 18 | 19 | if BUILD_H265_DECODER 20 | unittest_SOURCES += vaapidecoder_h265_unittest.cpp 21 | endif 22 | 23 | if BUILD_MPEG2_DECODER 24 | unittest_SOURCES += vaapidecoder_mpeg2_unittest.cpp 25 | endif 26 | 27 | if BUILD_VC1_DECODER 28 | unittest_SOURCES += vaapidecoder_vc1_unittest.cpp 29 | endif 30 | 31 | if BUILD_VP9_DECODER 32 | unittest_SOURCES += vaapidecoder_vp9_unittest.cpp 33 | endif 34 | 35 | unittest_SOURCES += DecoderApi_unittest.cpp 36 | 37 | unittest_LDFLAGS = \ 38 | $(AM_LDFLAGS) \ 39 | -pthread \ 40 | $(NULL) 41 | 42 | unittest_LDADD = \ 43 | libyami_decoder.la \ 44 | $(top_builddir)/codecparsers/libyami_codecparser.la \ 45 | $(top_builddir)/vaapi/libyami_vaapi.la \ 46 | $(top_builddir)/common/libyami_common.la \ 47 | $(top_srcdir)/gtestsrc/libgtest.la \ 48 | $(NULL) 49 | 50 | unittest_CPPFLAGS = \ 51 | $(LIBVA_CFLAGS) \ 52 | $(AM_CPPFLAGS) \ 53 | -I$(top_srcdir)/interface \ 54 | -I$(top_srcdir)/gtestsrc/gtest/include \ 55 | $(NULL) 56 | 57 | unittest_CXXFLAGS = \ 58 | $(AM_CXXFLAGS) \ 59 | $(NULL) 60 | 61 | # Separate the vaapidecoder_host_unittest so that we can detect static 62 | # initialization bugs with the decoder factory. Separation is required 63 | # since any derived decoder that is explicitly constructed in another test 64 | # would hide such bugs. 65 | noinst_PROGRAMS += unittest_host 66 | unittest_host_SOURCES = \ 67 | unittest_main.cpp \ 68 | vaapidecoder_host_unittest.cpp \ 69 | $(NULL) 70 | 71 | unittest_host_LDFLAGS = \ 72 | $(AM_LDFLAGS) \ 73 | -pthread \ 74 | $(NULL) 75 | 76 | unittest_host_LDADD = \ 77 | libyami_decoder.la \ 78 | $(top_builddir)/codecparsers/libyami_codecparser.la \ 79 | $(top_builddir)/vaapi/libyami_vaapi.la \ 80 | $(top_builddir)/common/libyami_common.la \ 81 | $(top_srcdir)/gtestsrc/libgtest.la \ 82 | $(NULL) 83 | 84 | unittest_host_CPPFLAGS = \ 85 | $(LIBVA_CFLAGS) \ 86 | $(AM_CPPFLAGS) \ 87 | -I$(top_srcdir)/interface \ 88 | -I$(top_srcdir)/gtestsrc/gtest/include \ 89 | $(NULL) 90 | 91 | unittest_host_CXXFLAGS = \ 92 | $(AM_CXXFLAGS) \ 93 | $(NULL) 94 | 95 | check-local: unittest unittest_host 96 | $(builddir)/unittest 97 | $(builddir)/unittest_host 98 | -------------------------------------------------------------------------------- /decoder/unittest_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // library headers 18 | #include "common/unittest.h" 19 | 20 | int main(int argc, char **argv) { 21 | ::testing::InitGoogleTest(&argc, argv); 22 | return RUN_ALL_TESTS(); 23 | } 24 | -------------------------------------------------------------------------------- /decoder/vaapiDecoderJPEG.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapiDecoderJPEG_h 18 | #define vaapiDecoderJPEG_h 19 | 20 | // library headers 21 | #include "vaapidecpicture.h" 22 | #include "vaapidecoder_base.h" 23 | 24 | namespace YamiMediaCodec { 25 | 26 | class VaapiDecoderJPEG 27 | : public VaapiDecoderBase { 28 | public: 29 | VaapiDecoderJPEG(); 30 | 31 | virtual ~VaapiDecoderJPEG() { } 32 | 33 | virtual YamiStatus start(VideoConfigBuffer*); 34 | virtual YamiStatus reset(VideoConfigBuffer*); 35 | virtual YamiStatus decode(VideoDecodeBuffer*); 36 | 37 | private: 38 | friend class FactoryTest; 39 | friend class VaapiDecoderJPEGTest; 40 | class Impl; 41 | 42 | YamiStatus fillPictureParam(); 43 | YamiStatus fillSliceParam(); 44 | 45 | YamiStatus loadQuantizationTables(); 46 | YamiStatus loadHuffmanTables(); 47 | 48 | YamiStatus finish(); 49 | 50 | YamiStatus ensureContext(); 51 | 52 | SharedPtr m_impl; 53 | PicturePtr m_picture; 54 | 55 | /** 56 | * VaapiDecoderFactory registration result. This decoder is registered in 57 | * vaapidecoder_host.cpp 58 | */ 59 | static const bool s_registered; 60 | 61 | DISALLOW_COPY_AND_ASSIGN(VaapiDecoderJPEG); 62 | }; 63 | 64 | } // namespace YamiMediaCodec 65 | 66 | #endif // vaapiDecoderJPEG_h 67 | -------------------------------------------------------------------------------- /decoder/vaapidecoder_factory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapidecoder_factory_h 18 | #define vaapidecoder_factory_h 19 | 20 | #include "common/factory.h" 21 | #include "VideoDecoderInterface.h" 22 | 23 | namespace YamiMediaCodec { 24 | 25 | typedef Factory VaapiDecoderFactory; 26 | 27 | } // namespace YamiMediaCodec 28 | #endif // vaapidecoder_factory_h 29 | -------------------------------------------------------------------------------- /decoder/vaapidecoder_fake.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #ifdef HAVE_CONFIG_H 19 | #include "config.h" 20 | #endif 21 | 22 | #include "common/log.h" 23 | #include "vaapidecoder_fake.h" 24 | 25 | namespace YamiMediaCodec{ 26 | typedef VaapiDecoderFake::PicturePtr PicturePtr; 27 | 28 | VaapiDecoderFake::VaapiDecoderFake(int32_t width, int32_t height) 29 | :m_width(width), m_height(height), m_first(true) 30 | { 31 | } 32 | 33 | VaapiDecoderFake::~VaapiDecoderFake() 34 | { 35 | stop(); 36 | } 37 | 38 | YamiStatus VaapiDecoderFake::start(VideoConfigBuffer* buffer) 39 | { 40 | DEBUG("VP9: start() buffer size: %d x %d", buffer->width, 41 | buffer->height); 42 | 43 | VideoConfigBuffer config; 44 | config = *buffer; 45 | config.profile = VAProfileH264Main; 46 | config.surfaceNumber = FAKE_EXTRA_SURFACE_NUMBER; 47 | config.width = m_width; 48 | config.height = m_height; 49 | config.surfaceWidth = m_width; 50 | config.surfaceHeight = m_height; 51 | return VaapiDecoderBase::start(&config); 52 | } 53 | 54 | YamiStatus VaapiDecoderFake::decode(VideoDecodeBuffer* buffer) 55 | { 56 | if (m_first) { 57 | m_first = false; 58 | return YAMI_DECODE_FORMAT_CHANGE; 59 | } 60 | PicturePtr picture; 61 | YamiStatus status = createPicture(picture, buffer->timeStamp); 62 | if (status != YAMI_SUCCESS) 63 | return status; 64 | return outputPicture(picture); 65 | } 66 | 67 | } 68 | 69 | -------------------------------------------------------------------------------- /decoder/vaapidecoder_fake.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapidecoder_fake_h 18 | #define vaapidecoder_fake_h 19 | 20 | #include "vaapidecoder_base.h" 21 | #include "vaapidecpicture.h" 22 | 23 | 24 | namespace YamiMediaCodec{ 25 | enum { 26 | FAKE_EXTRA_SURFACE_NUMBER = 8, 27 | }; 28 | 29 | class VaapiDecoderFake:public VaapiDecoderBase { 30 | public: 31 | typedef SharedPtr PicturePtr; 32 | VaapiDecoderFake(int32_t width, int32_t height); 33 | virtual ~ VaapiDecoderFake(); 34 | virtual YamiStatus start(VideoConfigBuffer*); 35 | virtual YamiStatus decode(VideoDecodeBuffer*); 36 | 37 | private: 38 | int32_t m_width; 39 | int32_t m_height; 40 | bool m_first; 41 | }; 42 | 43 | }; 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /decoder/vaapidecoder_h265_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "vaapidecoder_h265.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class VaapiDecoderH265Test 40 | : public FactoryTest 41 | { 42 | protected: 43 | /* invoked by gtest before the test */ 44 | virtual void SetUp() { 45 | return; 46 | } 47 | 48 | /* invoked by gtest after the test */ 49 | virtual void TearDown() { 50 | return; 51 | } 52 | }; 53 | 54 | #define VAAPIDECODER_H265_TEST(name) \ 55 | TEST_F(VaapiDecoderH265Test, name) 56 | 57 | VAAPIDECODER_H265_TEST(Factory) { 58 | FactoryKeys mimeTypes; 59 | mimeTypes.push_back(YAMI_MIME_H265); 60 | doFactoryTest(mimeTypes); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /decoder/vaapidecoder_vc1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapidecoder_vc1_h 18 | #define vaapidecoder_vc1_h 19 | 20 | #include "codecparsers/vc1Parser.h" 21 | #include "vaapidecoder_base.h" 22 | #include "va/va.h" 23 | 24 | namespace YamiMediaCodec { 25 | class VaapiDecPictureVC1 : public VaapiDecPicture { 26 | public: 27 | VaapiDecPictureVC1(const ContextPtr& context, const SurfacePtr& surface, 28 | int64_t timeStamp) 29 | : VaapiDecPicture(context, surface, timeStamp) 30 | , m_picOutputFlag(false) 31 | { 32 | } 33 | VaapiDecPictureVC1() {} 34 | bool m_picOutputFlag; 35 | private: 36 | }; 37 | class VaapiDecoderVC1 : public VaapiDecoderBase { 38 | public: 39 | typedef SharedPtr PicturePtr; 40 | VaapiDecoderVC1(); 41 | virtual ~VaapiDecoderVC1(); 42 | virtual YamiStatus start(VideoConfigBuffer*); 43 | virtual void stop(void); 44 | virtual void flush(void); 45 | virtual YamiStatus decode(VideoDecodeBuffer*); 46 | 47 | private: 48 | friend class FactoryTest; 49 | friend class VaapiDecoderVC1Test; 50 | void bumpAll(); 51 | YamiStatus ensureContext(); 52 | YamiStatus outputPicture(const PicturePtr& picture); 53 | YamiStatus decode(uint8_t*, uint32_t, uint64_t); 54 | bool ensureSlice(PicturePtr&, void*, int); 55 | bool ensurePicture(PicturePtr&); 56 | bool makeBitPlanes(PicturePtr&, VAPictureParameterBufferVC1*); 57 | YamiParser::VC1::Parser m_parser; 58 | 59 | const static uint32_t VC1_MAX_REFRENCE_SURFACE_NUMBER = 2; 60 | 61 | //m_dpb[0] stores forward reference picture 62 | //m_dpb[1] stores backward reference picture 63 | PicturePtr m_dpb[2]; 64 | int32_t m_dpbIdx; 65 | bool m_sliceFlag; 66 | 67 | /** 68 | * VaapiDecoderFactory registration result. This decoder is registered in 69 | * vaapidecoder_host.cpp 70 | */ 71 | static const bool s_registered; 72 | }; 73 | } // namespace YamiMediaCodec 74 | #endif 75 | -------------------------------------------------------------------------------- /decoder/vaapidecoder_vp8_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "vaapidecoder_vp8.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class VaapiDecoderVP8Test 40 | : public FactoryTest 41 | { 42 | protected: 43 | /* invoked by gtest before the test */ 44 | virtual void SetUp() { 45 | return; 46 | } 47 | 48 | /* invoked by gtest after the test */ 49 | virtual void TearDown() { 50 | return; 51 | } 52 | }; 53 | 54 | #define VAAPIDECODER_VP8_TEST(name) \ 55 | TEST_F(VaapiDecoderVP8Test, name) 56 | 57 | VAAPIDECODER_VP8_TEST(Factory) { 58 | FactoryKeys mimeTypes; 59 | mimeTypes.push_back(YAMI_MIME_VP8); 60 | doFactoryTest(mimeTypes); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /decoder/vaapidecoder_vp9.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapidecoder_vp9_h 18 | #define vaapidecoder_vp9_h 19 | 20 | #include "codecparsers/vp9parser.h" 21 | #include "vaapidecoder_base.h" 22 | #include "vaapidecpicture.h" 23 | #include "va/va_dec_vp9.h" 24 | #include 25 | 26 | namespace YamiMediaCodec{ 27 | 28 | class VaapiDecoderVP9:public VaapiDecoderBase { 29 | public: 30 | typedef SharedPtr PicturePtr; 31 | VaapiDecoderVP9(); 32 | virtual ~ VaapiDecoderVP9(); 33 | virtual YamiStatus start(VideoConfigBuffer*); 34 | virtual YamiStatus reset(VideoConfigBuffer*); 35 | virtual void stop(void); 36 | virtual void flush(void); 37 | void flush(bool discardOutput); 38 | virtual YamiStatus decode(VideoDecodeBuffer*); 39 | 40 | private: 41 | friend class FactoryTest; 42 | friend class VaapiDecoderVP9Test; 43 | 44 | YamiStatus ensureContext(const Vp9FrameHdr*); 45 | YamiStatus decode(const uint8_t* data, uint32_t size, uint64_t timeStamp); 46 | YamiStatus decode(const Vp9FrameHdr* hdr, const uint8_t* data, uint32_t size, uint64_t timeStamp); 47 | bool ensureSlice(const PicturePtr& , const void* data, int size); 48 | bool ensurePicture(const PicturePtr& , const Vp9FrameHdr* ); 49 | //reference related 50 | bool fillReference(VADecPictureParameterBufferVP9* , const Vp9FrameHdr*); 51 | void updateReference(const PicturePtr&, const Vp9FrameHdr*); 52 | 53 | typedef SharedPtr ParserPtr; 54 | ParserPtr m_parser; 55 | std::vector m_reference; 56 | 57 | //Can't decode p frame without key. 58 | bool m_gotKeyFrame; 59 | 60 | /** 61 | * VaapiDecoderFactory registration result. This decoder is registered in 62 | * vaapidecoder_host.cpp 63 | */ 64 | static const bool s_registered; 65 | }; 66 | 67 | } // namespace YamiMediaCodec 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /decoder/vaapidecoder_vp9_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | #include "vaapidecoder_vp9.h" 35 | 36 | namespace YamiMediaCodec { 37 | 38 | class VaapiDecoderVP9Test 39 | : public FactoryTest 40 | { 41 | protected: 42 | /* invoked by gtest before the test */ 43 | virtual void SetUp() { 44 | return; 45 | } 46 | 47 | /* invoked by gtest after the test */ 48 | virtual void TearDown() { 49 | return; 50 | } 51 | }; 52 | 53 | #define VAAPIDECODER_VP9_TEST(name) \ 54 | TEST_F(VaapiDecoderVP9Test, name) 55 | 56 | VAAPIDECODER_VP9_TEST(Factory) { 57 | FactoryKeys mimeTypes; 58 | mimeTypes.push_back(YAMI_MIME_VP9); 59 | doFactoryTest(mimeTypes); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /decoder/vaapidecpicture.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | #include "vaapidecpicture.h" 22 | 23 | #include "common/log.h" 24 | 25 | namespace YamiMediaCodec{ 26 | VaapiDecPicture::VaapiDecPicture(const ContextPtr& context, 27 | const SurfacePtr& surface, int64_t timeStamp) 28 | :VaapiPicture(context, surface, timeStamp) 29 | { 30 | } 31 | 32 | VaapiDecPicture::VaapiDecPicture() 33 | { 34 | } 35 | 36 | bool VaapiDecPicture::decode() 37 | { 38 | return render(); 39 | } 40 | 41 | bool VaapiDecPicture::doRender() 42 | { 43 | RENDER_OBJECT(m_picture); 44 | RENDER_OBJECT(m_probTable); 45 | RENDER_OBJECT(m_iqMatrix); 46 | RENDER_OBJECT(m_bitPlane); 47 | RENDER_OBJECT(m_hufTable); 48 | RENDER_OBJECT(m_slices); 49 | return true; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | all: html 2 | install-data-local: install-html 3 | 4 | EXTRA_DIST = \ 5 | doc.config \ 6 | $(NULL) 7 | 8 | LIBYAMI_DOC_STRIP_DIR = $(top_srcdir)/common $(top_srcdir)/vaapi $(top_srcdir)/decoder $(top_srcdir)/encoder $(top_srcdir)/interface 9 | LIBYAMI_DOC_STRIP_FILES = vaapibuffer.h \ 10 | $(top_srcdir)/vaapi/vaapiimage.h \ 11 | $(top_srcdir)/vaapi/vaapiptrs.h \ 12 | $(top_srcdir)/vaapi/vaapisurface.h \ 13 | $(top_srcdir)/vaapi/vaapiutils.h \ 14 | $(top_srcdir)/decoder/vaapidecoder_base.h \ 15 | $(top_srcdir)/decoder/vaapidecoder_h264.h \ 16 | $(top_srcdir)/decoder/vaapidecoder_jpeg.h \ 17 | $(top_srcdir)/decoder/vaapidecoder_vp8.h \ 18 | $(top_srcdir)/decoder/vaapidecsurfacepool.h \ 19 | $(top_srcdir)/decoder/vaapipicture.h \ 20 | $(top_srcdir)/decoder/vaapisurfacebuf_pool.h \ 21 | $(top_srcdir)/encoder/vaapicodedbuffer.h \ 22 | $(top_srcdir)/encoder/vaapiencoder_base.h \ 23 | $(top_srcdir)/encoder/vaapiencoder_h264.h \ 24 | $(top_srcdir)/encoder/vaapiencpicture.h \ 25 | $(top_srcdir)/interface/VideoDecoderDefs.h \ 26 | $(top_srcdir)/interface/VideoDecoderHost.h \ 27 | $(top_srcdir)/interface/VideoDecoderInterface.h \ 28 | $(top_srcdir)/interface/VideoEncoderAVC.h \ 29 | $(top_srcdir)/interface/VideoEncoderBase.h \ 30 | $(top_srcdir)/interface/VideoEncoderDefs.h \ 31 | $(top_srcdir)/interface/VideoEncoderHost.h \ 32 | $(top_srcdir)/interface/VideoEncoderInterface.h \ 33 | $(NULL) 34 | 35 | export LIBYAMI_DOC_STRIP_DIR 36 | export LIBYAMI_DOC_STRIP_FILES 37 | html/index.html: doc.config 38 | $(DOXYGEN) $< 39 | 40 | if ENABLE_DOCS 41 | html: html/index.html 42 | install-html-local: 43 | install -d $(DESTDIR)$(docdir)/html 44 | for file in `ls html/` ; do \ 45 | if test -f html/$$file ; then \ 46 | install -m 0644 html/$$file $(DESTDIR)$(docdir)/html ; \ 47 | else \ 48 | install -d $(DESTDIR)$(docdir)/html/$$file ; \ 49 | install -m 0644 html/$$file/* $(DESTDIR)$(docdir)/html/$$file; \ 50 | fi ; \ 51 | done 52 | uninstall-local: 53 | rm -rf $(DESTDIR)$(docdir)/html 54 | endif 55 | 56 | # Extra clean files so that maintainer-clean removes *everything* 57 | MAINTAINERCLEANFILES = Makefile.in 58 | -------------------------------------------------------------------------------- /doc/infrastructure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/libyami/4af0db4d160c973b3d33153b42571f064ec922c7/doc/infrastructure.png -------------------------------------------------------------------------------- /doc/infrastructure.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/libyami/4af0db4d160c973b3d33153b42571f064ec922c7/doc/infrastructure.vsdx -------------------------------------------------------------------------------- /doc/mainpage.dox: -------------------------------------------------------------------------------- 1 | /** 2 | * \mainpage Entrance to the interested document 3 | *
 4 | * ==== Here are API of libyami
 5 | * == Decoder APIs
 6 | * class YamiMediaCodec::IVideoDecoder
 7 | * func createVideoDecoder()
 8 | * func releaseVideoDecoder()
 9 | *
10 | * == Encoder APIs
11 | * class YamiMediaCodec::IVideoEncoder
12 | * func createVideoEncoder()
13 | * func releaseVideoEncoder()
14 | *
15 | * ==== More information on internal implementation:
16 | * class YamiMediaCodec::VaapiDecSurfacePool
17 | * 
18 | */ 19 | -------------------------------------------------------------------------------- /egl/egl_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __EGL_UTIL_H__ 18 | #define __EGL_UTIL_H__ 19 | #include 20 | #include 21 | 22 | #include "VideoCommonDefs.h" 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif /* __cplusplus */ 26 | 27 | EGLImageKHR createImage(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint *); 28 | EGLBoolean destroyImage(EGLDisplay, EGLImageKHR); 29 | EGLImageKHR createEglImageFromHandle(EGLDisplay eglDisplay, EGLContext eglContext, VideoDataMemoryType type, uint32_t dmaBuf, int width, int height, int pitch); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif /* __cplusplus */ 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /egl/egl_vaapi_image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef egl_vaapi_image_h 18 | #define egl_vaapi_image_h 19 | 20 | #include 21 | #define EGL_EGLEXT_PROTOTYPES 22 | #include 23 | #include 24 | 25 | #include "VideoCommonDefs.h" 26 | 27 | namespace YamiMediaCodec { 28 | 29 | class EglVaapiImage 30 | { 31 | public: 32 | EglVaapiImage(VADisplay, int width, int height); 33 | bool init(); 34 | EGLImageKHR createEglImage(EGLDisplay, EGLContext, VideoDataMemoryType); 35 | bool blt(const SharedPtr& src); 36 | bool exportFrame(VideoDataMemoryType memoryType, VideoFrameRawData &frame); 37 | ~EglVaapiImage(); 38 | private: 39 | bool acquireBufferHandle(VideoDataMemoryType); 40 | VADisplay m_display; 41 | VAImageFormat m_format; 42 | VAImage m_image; 43 | VABufferInfo m_bufferInfo; 44 | 45 | int m_width; 46 | int m_height; 47 | bool m_inited; 48 | bool m_acquired; // acquired buffer handle 49 | VideoFrameRawData m_frameInfo; 50 | 51 | EGLImageKHR m_eglImage; 52 | }; 53 | 54 | }//namespace YamiMediaCodec 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /encoder/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | include $(LOCAL_PATH)/../common.mk 4 | 5 | LOCAL_SRC_FILES := \ 6 | vaapicodedbuffer.cpp \ 7 | vaapiencpicture.cpp \ 8 | vaapiencoder_base.cpp \ 9 | vaapiencoder_host.cpp \ 10 | 11 | LOCAL_SRC_FILES += \ 12 | vaapiencoder_h264.cpp \ 13 | vaapilayerid.cpp 14 | 15 | LOCAL_SRC_FILES += \ 16 | vaapiencoder_jpeg.cpp 17 | 18 | LOCAL_SRC_FILES += \ 19 | vaapiencoder_vp8.cpp 20 | 21 | LOCAL_SRC_FILES += \ 22 | vaapiencoder_vp9.cpp 23 | 24 | LOCAL_SRC_FILES += \ 25 | vaapiencoder_hevc.cpp 26 | 27 | LOCAL_C_INCLUDES:= \ 28 | $(LOCAL_PATH)/.. \ 29 | $(LOCAL_PATH)/../common \ 30 | $(LOCAL_PATH)/../interface \ 31 | $(LOCAL_PATH)/../vaapi \ 32 | $(LOCAL_PATH)/../codecparsers \ 33 | external/libcxx/include \ 34 | $(TARGET_OUT_HEADERS)/libva \ 35 | 36 | LOCAL_CFLAGS := \ 37 | -D__BUILD_H264_ENCODER__=1 \ 38 | -D__BUILD_H265_ENCODER__=1 \ 39 | -D__BUILD_VP8_ENCODER__=1 \ 40 | -D__BUILD_VP9_ENCODER__=1 \ 41 | -D__BUILD_JPEG_ENCODER__=1 \ 42 | 43 | LOCAL_SHARED_LIBRARIES := \ 44 | liblog \ 45 | libc++ \ 46 | libva \ 47 | 48 | LOCAL_PROPRIETARY_MODULE := true 49 | LOCAL_MODULE := libyami_encoder 50 | include $(BUILD_STATIC_LIBRARY) 51 | -------------------------------------------------------------------------------- /encoder/Makefile.unittest: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = unittest 2 | 3 | unittest_SOURCES = \ 4 | unittest_main.cpp \ 5 | $(NULL) 6 | 7 | if BUILD_H264_ENCODER 8 | unittest_SOURCES += vaapiencoder_h264_unittest.cpp 9 | endif 10 | 11 | if BUILD_H265_ENCODER 12 | unittest_SOURCES += vaapiencoder_hevc_unittest.cpp 13 | endif 14 | 15 | if BUILD_JPEG_ENCODER 16 | unittest_SOURCES += vaapiencoder_jpeg_unittest.cpp 17 | endif 18 | 19 | if BUILD_VP8_ENCODER 20 | unittest_SOURCES += vaapiencoder_vp8_unittest.cpp 21 | endif 22 | 23 | if BUILD_VP9_ENCODER 24 | unittest_SOURCES += vaapiencoder_vp9_unittest.cpp 25 | endif 26 | 27 | unittest_LDFLAGS = \ 28 | $(AM_LDFLAGS) \ 29 | -pthread \ 30 | $(NULL) 31 | 32 | unittest_LDADD = \ 33 | libyami_encoder.la \ 34 | $(top_builddir)/common/libyami_common.la \ 35 | $(top_builddir)/vaapi/libyami_vaapi.la \ 36 | $(top_builddir)/codecparsers/libyami_codecparser.la \ 37 | $(top_srcdir)/gtestsrc/libgtest.la \ 38 | $(NULL) 39 | 40 | unittest_CPPFLAGS = \ 41 | $(LIBVA_CFLAGS) \ 42 | $(AM_CPPFLAGS) \ 43 | -I$(top_srcdir)/interface \ 44 | -I$(top_srcdir)/gtestsrc/gtest/include \ 45 | $(NULL) 46 | 47 | unittest_CXXFLAGS = \ 48 | $(AM_CXXFLAGS) \ 49 | $(NULL) 50 | 51 | # Separate the vaapiencoder_host_unittest so that we can detect static 52 | # initialization bugs with the encoder factory. Separation is required 53 | # since any derived encoder that is explicitly constructed in another test 54 | # would hide such bugs. 55 | noinst_PROGRAMS += unittest_host 56 | unittest_host_SOURCES = \ 57 | unittest_main.cpp \ 58 | vaapiencoder_host_unittest.cpp \ 59 | $(NULL) 60 | 61 | unittest_host_LDFLAGS = \ 62 | $(AM_LDFLAGS) \ 63 | -pthread \ 64 | $(NULL) 65 | 66 | unittest_host_LDADD = \ 67 | libyami_encoder.la \ 68 | $(top_builddir)/common/libyami_common.la \ 69 | $(top_builddir)/vaapi/libyami_vaapi.la \ 70 | $(top_builddir)/codecparsers/libyami_codecparser.la \ 71 | $(top_srcdir)/gtestsrc/libgtest.la \ 72 | $(NULL) 73 | 74 | unittest_host_CPPFLAGS = \ 75 | $(LIBVA_CFLAGS) \ 76 | $(AM_CPPFLAGS) \ 77 | -I$(top_srcdir)/interface \ 78 | -I$(top_srcdir)/gtestsrc/gtest/include \ 79 | $(NULL) 80 | 81 | unittest_host_CXXFLAGS = \ 82 | $(AM_CXXFLAGS) \ 83 | $(NULL) 84 | 85 | check-local: unittest unittest_host 86 | $(builddir)/unittest 87 | $(builddir)/unittest_host 88 | -------------------------------------------------------------------------------- /encoder/unittest_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // library headers 18 | #include "common/unittest.h" 19 | 20 | int main(int argc, char **argv) { 21 | ::testing::InitGoogleTest(&argc, argv); 22 | return RUN_ALL_TESTS(); 23 | } 24 | -------------------------------------------------------------------------------- /encoder/vaapicodedbuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | #include "vaapicodedbuffer.h" 22 | 23 | #include "vaapi/vaapicontext.h" 24 | #include 25 | 26 | namespace YamiMediaCodec{ 27 | CodedBufferPtr VaapiCodedBuffer::create(const ContextPtr& context, uint32_t bufSize) 28 | { 29 | CodedBufferPtr coded; 30 | BufObjectPtr buf = VaapiBuffer::create(context, VAEncCodedBufferType, bufSize); 31 | if (buf) 32 | coded.reset(new VaapiCodedBuffer(buf)); 33 | return coded; 34 | } 35 | 36 | bool VaapiCodedBuffer::map() 37 | { 38 | if (!m_segments) 39 | m_segments = static_cast(m_buf->map()); 40 | return m_segments != NULL; 41 | } 42 | 43 | uint32_t VaapiCodedBuffer::size() 44 | { 45 | if (!map()) 46 | return 0; 47 | uint32_t size = 0; 48 | VACodedBufferSegment* segment = m_segments; 49 | while (segment != NULL) { 50 | size += segment->size; 51 | segment = static_cast(segment->next); 52 | } 53 | return size; 54 | } 55 | 56 | bool VaapiCodedBuffer::copyInto(void* data) 57 | { 58 | if (!data) 59 | return false; 60 | if (!map()) 61 | return false; 62 | uint8_t* dest = static_cast(data); 63 | VACodedBufferSegment* segment = m_segments; 64 | while (segment != NULL) { 65 | memcpy(dest, segment->buf, segment->size); 66 | dest += segment->size; 67 | segment = static_cast(segment->next); 68 | } 69 | return true; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /encoder/vaapicodedbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef vaapicodedbuffer_h 17 | #define vaapicodedbuffer_h 18 | 19 | #include "vaapi/VaapiBuffer.h" 20 | #include "vaapi/vaapiptrs.h" 21 | #include 22 | 23 | namespace YamiMediaCodec{ 24 | class VaapiCodedBuffer 25 | { 26 | public: 27 | static CodedBufferPtr create(const ContextPtr&, uint32_t bufSize); 28 | ~VaapiCodedBuffer() {} 29 | uint32_t size(); 30 | VABufferID getID() const { 31 | return m_buf->getID(); 32 | } 33 | bool copyInto(void* data); 34 | bool setFlag(uint32_t flag) { m_flags |= flag; return true; } 35 | bool clearFlag(uint32_t flag) { m_flags &= ~flag; return true; } 36 | uint32_t getFlags() { return m_flags; } 37 | 38 | private: 39 | VaapiCodedBuffer(const BufObjectPtr& buf):m_buf(buf), m_segments(NULL), m_flags(0) {} 40 | bool map(); 41 | BufObjectPtr m_buf; 42 | VACodedBufferSegment* m_segments; 43 | uint32_t m_flags; 44 | }; 45 | } 46 | #endif //vaapicodedbuffer_h 47 | -------------------------------------------------------------------------------- /encoder/vaapiencoder_factory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapiencoder_factory_h 18 | #define vaapiencoder_factory_h 19 | 20 | #include "common/factory.h" 21 | #include "VideoEncoderInterface.h" 22 | 23 | namespace YamiMediaCodec { 24 | 25 | typedef Factory VaapiEncoderFactory; 26 | 27 | } // namespace YamiMediaCodec 28 | #endif // vaapiencoder_factory_h 29 | -------------------------------------------------------------------------------- /encoder/vaapiencoder_h264_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "vaapiencoder_h264.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class VaapiEncoderH264Test 40 | : public FactoryTest 41 | { 42 | protected: 43 | /* invoked by gtest before the test */ 44 | virtual void SetUp() { 45 | return; 46 | } 47 | 48 | /* invoked by gtest after the test */ 49 | virtual void TearDown() { 50 | return; 51 | } 52 | }; 53 | 54 | #define VAAPIENCODER_H264_TEST(name) \ 55 | TEST_F(VaapiEncoderH264Test, name) 56 | 57 | VAAPIENCODER_H264_TEST(Factory) { 58 | FactoryKeys mimeTypes; 59 | mimeTypes.push_back(YAMI_MIME_AVC); 60 | mimeTypes.push_back(YAMI_MIME_H264); 61 | doFactoryTest(mimeTypes); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /encoder/vaapiencoder_hevc_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "vaapiencoder_hevc.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class VaapiEncoderHEVCTest 40 | : public FactoryTest 41 | { 42 | protected: 43 | /* invoked by gtest before the test */ 44 | virtual void SetUp() { 45 | return; 46 | } 47 | 48 | /* invoked by gtest after the test */ 49 | virtual void TearDown() { 50 | return; 51 | } 52 | }; 53 | 54 | #define VAAPIENCODER_HEVC_TEST(name) \ 55 | TEST_F(VaapiEncoderHEVCTest, name) 56 | 57 | VAAPIENCODER_HEVC_TEST(Factory) { 58 | FactoryKeys mimeTypes; 59 | mimeTypes.push_back(YAMI_MIME_HEVC); 60 | mimeTypes.push_back(YAMI_MIME_H265); 61 | doFactoryTest(mimeTypes); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /encoder/vaapiencoder_host.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | #include "common/log.h" 22 | #include "VideoEncoderHost.h" 23 | #include "vaapiencoder_factory.h" 24 | 25 | using namespace YamiMediaCodec; 26 | 27 | #if __BUILD_H264_ENCODER__ 28 | #include "vaapiencoder_h264.h" 29 | const bool VaapiEncoderH264::s_registered = 30 | VaapiEncoderFactory::register_(YAMI_MIME_AVC) 31 | && VaapiEncoderFactory::register_(YAMI_MIME_H264); 32 | #endif 33 | 34 | #if __BUILD_H265_ENCODER__ 35 | #include "vaapiencoder_hevc.h" 36 | const bool VaapiEncoderHEVC::s_registered = 37 | VaapiEncoderFactory::register_(YAMI_MIME_HEVC) 38 | && VaapiEncoderFactory::register_(YAMI_MIME_H265); 39 | #endif 40 | 41 | #if __BUILD_JPEG_ENCODER__ 42 | #include "vaapiencoder_jpeg.h" 43 | const bool VaapiEncoderJpeg::s_registered = 44 | VaapiEncoderFactory::register_(YAMI_MIME_JPEG); 45 | #endif 46 | 47 | #if __BUILD_VP8_ENCODER__ 48 | #include "vaapiencoder_vp8.h" 49 | const bool VaapiEncoderVP8::s_registered = 50 | VaapiEncoderFactory::register_(YAMI_MIME_VP8); 51 | #endif 52 | 53 | #if __BUILD_VP9_ENCODER__ 54 | #include "vaapiencoder_vp9.h" 55 | const bool VaapiEncoderVP9::s_registered 56 | = VaapiEncoderFactory::register_(YAMI_MIME_VP9); 57 | #endif 58 | 59 | IVideoEncoder* createVideoEncoder(const char* mimeType) { 60 | if (!mimeType) { 61 | ERROR("NULL mime type."); 62 | return NULL; 63 | } 64 | 65 | VaapiEncoderFactory::Type enc = VaapiEncoderFactory::create(mimeType); 66 | 67 | if (!enc) 68 | ERROR("Failed to create encoder for mimeType: '%s'", mimeType); 69 | else 70 | INFO("Created encoder for mimeType: '%s'", mimeType); 71 | 72 | return enc; 73 | } 74 | 75 | void releaseVideoEncoder(IVideoEncoder* p) { 76 | delete p; 77 | } 78 | 79 | std::vector getVideoEncoderMimeTypes() 80 | { 81 | return VaapiEncoderFactory::keys(); 82 | } 83 | -------------------------------------------------------------------------------- /encoder/vaapiencoder_jpeg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapiencoder_jpeg_h 18 | #define vaapiencoder_jpeg_h 19 | 20 | #include "vaapiencoder_base.h" 21 | #include "vaapi/vaapiptrs.h" 22 | #include 23 | 24 | namespace YamiMediaCodec { 25 | class VaapiEncPictureJPEG; 26 | 27 | class VaapiEncoderJpeg : public VaapiEncoderBase { 28 | public: 29 | typedef SharedPtr PicturePtr; 30 | 31 | VaapiEncoderJpeg(); 32 | virtual ~VaapiEncoderJpeg() { } 33 | virtual YamiStatus start(); 34 | virtual void flush(); 35 | virtual YamiStatus stop(); 36 | 37 | virtual YamiStatus getParameters(VideoParamConfigType type, Yami_PTR videoEncParams); 38 | virtual YamiStatus setParameters(VideoParamConfigType type, Yami_PTR videoEncParams); 39 | virtual YamiStatus getMaxOutSize(uint32_t* maxSize); 40 | 41 | protected: 42 | virtual YamiStatus doEncode(const SurfacePtr&, uint64_t timeStamp, bool forceKeyFrame); 43 | virtual bool isBusy() { return false;}; 44 | 45 | private: 46 | friend class FactoryTest; 47 | friend class VaapiEncoderJpegTest; 48 | 49 | YamiStatus encodePicture(const PicturePtr&); 50 | bool addSliceHeaders (const PicturePtr&) const; 51 | bool fill(VAEncPictureParameterBufferJPEG * picParam, const PicturePtr &, const SurfacePtr &) const; 52 | bool fill(VAQMatrixBufferJPEG * qMatrix) const; 53 | bool fill(VAEncSliceParameterBufferJPEG *sliceParam) const; 54 | bool fill(VAHuffmanTableBufferJPEGBaseline *huffTableParam) const; 55 | 56 | bool ensurePicture (const PicturePtr&, const SurfacePtr&); 57 | bool ensureQMatrix (const PicturePtr&); 58 | bool ensureSlice (const PicturePtr&); 59 | bool ensureHuffTable (const PicturePtr&); 60 | 61 | void resetParams(); 62 | 63 | /** 64 | * VaapiEncoderFactory registration result. This encoder is registered in 65 | * vaapiencoder_host.cpp 66 | */ 67 | static const bool s_registered; 68 | }; 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /encoder/vaapiencoder_vp8_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "vaapiencoder_vp8.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class VaapiEncoderVP8Test 40 | : public FactoryTest 41 | { 42 | protected: 43 | /* invoked by gtest before the test */ 44 | virtual void SetUp() { 45 | return; 46 | } 47 | 48 | /* invoked by gtest after the test */ 49 | virtual void TearDown() { 50 | return; 51 | } 52 | }; 53 | 54 | #define VAAPIENCODER_VP8_TEST(name) \ 55 | TEST_F(VaapiEncoderVP8Test, name) 56 | 57 | VAAPIENCODER_VP8_TEST(Factory) { 58 | FactoryKeys mimeTypes; 59 | mimeTypes.push_back(YAMI_MIME_VP8); 60 | doFactoryTest(mimeTypes); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /encoder/vaapiencoder_vp9_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "vaapiencoder_vp9.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class VaapiEncoderVP9Test 40 | : public FactoryTest 41 | { 42 | protected: 43 | /* invoked by gtest before the test */ 44 | virtual void SetUp() { 45 | return; 46 | } 47 | 48 | /* invoked by gtest after the test */ 49 | virtual void TearDown() { 50 | return; 51 | } 52 | }; 53 | 54 | #define VAAPIENCODER_VP9_TEST(name) \ 55 | TEST_F(VaapiEncoderVP9Test, name) 56 | 57 | VAAPIENCODER_VP9_TEST(Factory) { 58 | FactoryKeys mimeTypes; 59 | mimeTypes.push_back(YAMI_MIME_VP9); 60 | doFactoryTest(mimeTypes); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /gtestsrc/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = subdir-objects 2 | 3 | # libgtest 4 | noinst_LTLIBRARIES = libgtest.la 5 | 6 | libgtest_la_SOURCES = \ 7 | gtest/src/gtest-all.cc \ 8 | gtest/src/gtest_main.cc \ 9 | $(NULL) 10 | 11 | libgtest_la_CXXFLAGS = \ 12 | -I$(top_srcdir)/gtestsrc/gtest \ 13 | -I$(top_srcdir)/gtestsrc/gtest/include \ 14 | $(AM_CXXFLAGS) \ 15 | $(NULL) 16 | 17 | EXTRA_DIST = \ 18 | gtest/docs \ 19 | gtest/include \ 20 | gtest/src/*.cc \ 21 | gtest/src/*.h \ 22 | gtest/README.md \ 23 | gtest/LICENSE \ 24 | $(NULL) 25 | -------------------------------------------------------------------------------- /gtestsrc/gtest/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /gtestsrc/gtest/docs/Documentation.md: -------------------------------------------------------------------------------- 1 | This page lists all documentation wiki pages for Google Test **(the SVN trunk version)** 2 | -- **if you use a released version of Google Test, please read the 3 | documentation for that specific version instead.** 4 | 5 | * [Primer](Primer.md) -- start here if you are new to Google Test. 6 | * [Samples](Samples.md) -- learn from examples. 7 | * [AdvancedGuide](AdvancedGuide.md) -- learn more about Google Test. 8 | * [XcodeGuide](XcodeGuide.md) -- how to use Google Test in Xcode on Mac. 9 | * [Frequently-Asked Questions](FAQ.md) -- check here before asking a question on the mailing list. 10 | 11 | To contribute code to Google Test, read: 12 | 13 | * [DevGuide](DevGuide.md) -- read this _before_ writing your first patch. 14 | * [PumpManual](PumpManual.md) -- how we generate some of Google Test's source files. -------------------------------------------------------------------------------- /gtestsrc/gtest/docs/Samples.md: -------------------------------------------------------------------------------- 1 | If you're like us, you'd like to look at some Google Test sample code. The 2 | [samples folder](../samples) has a number of well-commented samples showing how to use a 3 | variety of Google Test features. 4 | 5 | * [Sample #1](../samples/sample1_unittest.cc) shows the basic steps of using Google Test to test C++ functions. 6 | * [Sample #2](../samples/sample2_unittest.cc) shows a more complex unit test for a class with multiple member functions. 7 | * [Sample #3](../samples/sample3_unittest.cc) uses a test fixture. 8 | * [Sample #4](../samples/sample4_unittest.cc) is another basic example of using Google Test. 9 | * [Sample #5](../samples/sample5_unittest.cc) teaches how to reuse a test fixture in multiple test cases by deriving sub-fixtures from it. 10 | * [Sample #6](../samples/sample6_unittest.cc) demonstrates type-parameterized tests. 11 | * [Sample #7](../samples/sample7_unittest.cc) teaches the basics of value-parameterized tests. 12 | * [Sample #8](../samples/sample8_unittest.cc) shows using `Combine()` in value-parameterized tests. 13 | * [Sample #9](../samples/sample9_unittest.cc) shows use of the listener API to modify Google Test's console output and the use of its reflection API to inspect test results. 14 | * [Sample #10](../samples/sample10_unittest.cc) shows use of the listener API to implement a primitive memory leak checker. 15 | -------------------------------------------------------------------------------- /gtestsrc/gtest/include/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Google C++ Testing Framework definitions useful in production code. 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 36 | 37 | // When you need to test the private or protected members of a class, 38 | // use the FRIEND_TEST macro to declare your tests as friends of the 39 | // class. For example: 40 | // 41 | // class MyClass { 42 | // private: 43 | // void MyMethod(); 44 | // FRIEND_TEST(MyClassTest, MyMethod); 45 | // }; 46 | // 47 | // class MyClassTest : public testing::Test { 48 | // // ... 49 | // }; 50 | // 51 | // TEST_F(MyClassTest, MyMethod) { 52 | // // Can call MyClass::MyMethod() here. 53 | // } 54 | 55 | #define FRIEND_TEST(test_case_name, test_name)\ 56 | friend class test_case_name##_##test_name##_Test 57 | 58 | #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 59 | -------------------------------------------------------------------------------- /gtestsrc/gtest/include/gtest/internal/custom/gtest-printers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This file provides an injection point for custom printers in a local 31 | // installation of gTest. 32 | // It will be included from gtest-printers.h and the overrides in this file 33 | // will be visible to everyone. 34 | // See documentation at gtest/gtest-printers.h for details on how to define a 35 | // custom printer. 36 | // 37 | // ** Custom implementation starts here ** 38 | 39 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 40 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 41 | 42 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 43 | -------------------------------------------------------------------------------- /gtestsrc/gtest/include/gtest/internal/custom/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. 31 | // The following macros can be defined: 32 | // 33 | // GTEST_OS_STACK_TRACE_GETTER_ - The name of an implementation of 34 | // OsStackTraceGetterInterface. 35 | // 36 | // ** Custom implementation starts here ** 37 | 38 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 39 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 40 | 41 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 42 | -------------------------------------------------------------------------------- /gtestsrc/gtest/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build Google Test by compiling a single file. 35 | // This file serves this purpose. 36 | 37 | // This line ensures that gtest.h can be compiled on its own, even 38 | // when it's fused. 39 | #include "gtest/gtest.h" 40 | 41 | // The following lines pull in the real gtest *.cc files. 42 | #include "src/gtest.cc" 43 | #include "src/gtest-death-test.cc" 44 | #include "src/gtest-filepath.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | -------------------------------------------------------------------------------- /gtestsrc/gtest/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) { 35 | printf("Running main() from gtest_main.cc\n"); 36 | testing::InitGoogleTest(&argc, argv); 37 | return RUN_ALL_TESTS(); 38 | } 39 | -------------------------------------------------------------------------------- /interface/VideoDecoderCapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __VIDEO_DECODER_CAPI_H__ 18 | #define __VIDEO_DECODER_CAPI_H__ 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef void* DecodeHandler; 28 | 29 | DecodeHandler createDecoder(const char *mimeType); 30 | 31 | void decodeSetNativeDisplay(DecodeHandler p, NativeDisplay* display); 32 | 33 | YamiStatus decodeStart(DecodeHandler p, VideoConfigBuffer* buffer); 34 | 35 | YamiStatus decodeReset(DecodeHandler p, VideoConfigBuffer* buffer); 36 | 37 | void decodeStop(DecodeHandler p); 38 | 39 | void decodeFlush(DecodeHandler p); 40 | 41 | YamiStatus decodeDecode(DecodeHandler p, VideoDecodeBuffer* buffer); 42 | 43 | VideoFrame* decodeGetOutput(DecodeHandler p); 44 | 45 | const VideoFormatInfo* decodeGetFormatInfo(DecodeHandler p); 46 | 47 | void releaseDecoder(DecodeHandler p); 48 | 49 | /*deprecated*/ 50 | void releaseLock(DecodeHandler p); 51 | 52 | #ifdef __cplusplus 53 | }; 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /interface/VideoDecoderHost.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef VIDEO_DECODER_HOST_H_ 19 | #define VIDEO_DECODER_HOST_H_ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | /** \file VideoDecoderHost.h 26 | */ 27 | 28 | /** \fn IVideoDecoder *createVideoDecoder(const char *mimeType) 29 | * \brief create a decoder basing on given mimetype 30 | */ 31 | YamiMediaCodec::IVideoDecoder *createVideoDecoder(const char *mimeType); 32 | /// \brief destroy the decoder 33 | void releaseVideoDecoder(YamiMediaCodec::IVideoDecoder * p); 34 | /** \fn void getVideoDecoderMimeTypes() 35 | * \brief return the MimeTypes enabled in the current build 36 | */ 37 | std::vector getVideoDecoderMimeTypes(); 38 | 39 | typedef YamiMediaCodec::IVideoDecoder *(*YamiCreateVideoDecoderFuncPtr) (const char *mimeType); 40 | typedef void (*YamiReleaseVideoDecoderFuncPtr)(YamiMediaCodec::IVideoDecoder * p); 41 | #endif /* VIDEO_DECODER_HOST_H_ */ 42 | -------------------------------------------------------------------------------- /interface/VideoEncoderCapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __VIDEO_ENCODER_CAPI_H__ 18 | #define __VIDEO_ENCODER_CAPI_H__ 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | typedef void* EncodeHandler; 27 | 28 | EncodeHandler createEncoder(const char *mimeType); 29 | 30 | void encodeSetNativeDisplay(EncodeHandler p, NativeDisplay * display); 31 | 32 | YamiStatus encodeStart(EncodeHandler p); 33 | 34 | void encodeStop(EncodeHandler p); 35 | 36 | /* encoder will can frame->free, no matter it return fail or not*/ 37 | YamiStatus encodeEncode(EncodeHandler p, VideoFrame* frame); 38 | 39 | YamiStatus encodeGetOutput(EncodeHandler p, VideoEncOutputBuffer* outBuffer, bool withWait); 40 | 41 | YamiStatus encodeGetParameters(EncodeHandler p, VideoParamConfigType type, Yami_PTR videoEncParams); 42 | 43 | YamiStatus encodeSetParameters(EncodeHandler p, VideoParamConfigType type, Yami_PTR videoEncParams); 44 | 45 | YamiStatus encodeGetMaxOutSize(EncodeHandler p, uint32_t* maxSize); 46 | 47 | void releaseEncoder(EncodeHandler p); 48 | 49 | /*deprecated*/ 50 | YamiStatus encodeEncodeRawData(EncodeHandler p, VideoFrameRawData* inBuffer); 51 | 52 | /*deprecated*/ 53 | YamiStatus getStatistics(EncodeHandler p, VideoStatistics* videoStat); 54 | 55 | /*deprecated*/ 56 | YamiStatus getConfig(EncodeHandler p, VideoParamConfigType type, Yami_PTR videoEncConfig); 57 | 58 | /*deprecated*/ 59 | YamiStatus setConfig(EncodeHandler p, VideoParamConfigType type, Yami_PTR videoEncConfig); 60 | 61 | #ifdef __cplusplus 62 | }; 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /interface/VideoEncoderHost.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef VIDEO_ENCODER_HOST_H_ 18 | #define VIDEO_ENCODER_HOST_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | /** \file VideoEncoderHost.h 25 | */ 26 | 27 | /** \fn IVideoEncoder *createVideoEncoder(const char *mimeType) 28 | * \brief create encoder basing on given mimetype 29 | */ 30 | YamiMediaCodec::IVideoEncoder *createVideoEncoder(const char *mimeType); 31 | ///brief destroy encoder 32 | void releaseVideoEncoder(YamiMediaCodec::IVideoEncoder * p); 33 | /** \fn void getVideoEncoderMimeTypes() 34 | * \brief return the MimeTypes enabled in the current build 35 | */ 36 | std::vector getVideoEncoderMimeTypes(); 37 | 38 | typedef YamiMediaCodec::IVideoEncoder *(*YamiCreateVideoEncoderFuncPtr) (const char *mimeType); 39 | typedef void (*YamiReleaseVideoEncoderFuncPtr)(YamiMediaCodec::IVideoEncoder * p); 40 | #endif /* VIDEO_ENCODER_HOST_H_ */ 41 | -------------------------------------------------------------------------------- /interface/VideoPostProcessHost.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef VIDEO_POST_PROCESS_HOST_H_ 18 | #define VIDEO_POST_PROCESS_HOST_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | /** \file VideoPostProcessHost.h 25 | */ 26 | 27 | /** \fn IVideoPostProcess *createVideoPostProcess(const char *mimeType) 28 | * \brief create encoder basing on given mimetype 29 | */ 30 | YamiMediaCodec::IVideoPostProcess *createVideoPostProcess(const char *mimeType); 31 | /** \fn void releaseVideoPostProcess(IVideoPostProcess *p) 32 | * \brief destroy encoder 33 | */ 34 | void releaseVideoPostProcess(YamiMediaCodec::IVideoPostProcess * p); 35 | /** \fn void getVideoPostProcessMimeTypes() 36 | * \brief return the MimeTypes enabled in the current build 37 | */ 38 | std::vector getVideoPostProcessMimeTypes(); 39 | 40 | typedef YamiMediaCodec::IVideoPostProcess *(*YamiCreateVideoPostProcessFuncPtr) (const char *mimeType); 41 | typedef void (*YamiReleaseVideoPostProcessFuncPtr)(YamiMediaCodec::IVideoPostProcess * p); 42 | #endif /* VIDEO_POST_PROCESS_HOST_H_ */ 43 | -------------------------------------------------------------------------------- /interface/VideoPostProcessInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef VIDEO_POST_PROCESS_INTERFACE_H_ 18 | #define VIDEO_POST_PROCESS_INTERFACE_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace YamiMediaCodec{ 24 | /** 25 | * \class IVideoPostProcess 26 | * \brief Abstract video post process interface of libyami 27 | * it is the interface with client. they are not thread safe. 28 | */ 29 | class IVideoPostProcess { 30 | public: 31 | // set native display 32 | virtual YamiStatus setNativeDisplay(const NativeDisplay& display) = 0; 33 | // it may return YAMI_MORE_DATA when output is not ready 34 | // it's no need fill every field of VideoFrame, we can get detailed information from lower level 35 | // VideoFrame.surface is enough for most of case 36 | // for some type of vpp such as deinterlace, we will hold a referece of src. 37 | virtual YamiStatus process(const SharedPtr& src, 38 | const SharedPtr& dest) = 0; 39 | virtual YamiStatus setParameters(VppParamType type, void* vppParam) = 0; 40 | virtual ~IVideoPostProcess() {} 41 | }; 42 | } 43 | #endif /* VIDEO_POST_PROCESS_INTERFACE_H_ */ 44 | -------------------------------------------------------------------------------- /interface/Yami.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef YAMI_H_ 18 | #define YAMI_H_ 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | 26 | #include 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /interface/YamiC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef YAMI_C_H_ 18 | #define YAMI_C_H_ 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /interface/YamiVersion.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef YAMI_VERSION_H 18 | #define YAMI_VERSION_H 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** 27 | * YAMI_API_MAJOR_VERSION 28 | * The major version of yami api 29 | */ 30 | #define YAMI_API_MAJOR_VERSION @YAMI_API_MAJOR_VERSION@ 31 | 32 | /** 33 | * YAMI_API_MINOR_VERSION 34 | * The minor version of yami api 35 | */ 36 | #define YAMI_API_MINOR_VERSION @YAMI_API_MINOR_VERSION@ 37 | 38 | /** 39 | * YAMI_API_MICRO_VERSION 40 | * The micro version of yami api 41 | */ 42 | #define YAMI_API_MICRO_VERSION @YAMI_API_MICRO_VERSION@ 43 | 44 | /** 45 | * YAMI_API_VERSION_STRING 46 | * The string version of yami api 47 | */ 48 | #define YAMI_API_VERSION_STRING "@YAMI_API_VERSION@" 49 | 50 | 51 | #define YAMI_API_VERSION_INT(major, minor, micro) ((major << 24) | (minor << 16) | (micro << 8)) 52 | 53 | /** 54 | * YAMI_API_VERSION 55 | * The int version of yami api 56 | */ 57 | #define YAMI_API_VERSION YAMI_API_VERSION_INT(YAMI_API_MAJOR_VERSION, YAMI_API_MINOR_VERSION, YAMI_API_MICRO_VERSION) 58 | 59 | /** 60 | * YAMI_CHECK_API_VERSION 61 | * Result is 1 if YAMI_API_VERSION is greater than 62 | * YAMI_API_VERSION_INT(major, minor, micro) 63 | */ 64 | #define YAMI_CHECK_API_VERSION(major, minor, micro) (YAMI_API_VERSION >= YAMI_API_VERSION_INT(major, minor, micro)) 65 | 66 | /** 67 | * yamiGetApiVersion 68 | * return YAMI_API_VERSION; 69 | */ 70 | void yamiGetApiVersion(uint32_t *apiVersion); 71 | 72 | #ifdef __cplusplus 73 | }; 74 | #endif 75 | 76 | #endif /* YAMI_VERSION_H */ 77 | -------------------------------------------------------------------------------- /interface/v4l2_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #if defined(__ENABLE_X11__) 20 | #include 21 | #endif 22 | #include "VideoCommonDefs.h" 23 | 24 | #ifndef v4l2_wrapper_h 25 | #define v4l2_wrapper_h 26 | #ifndef V4L2_EVENT_RESOLUTION_CHANGE 27 | #define V4L2_EVENT_RESOLUTION_CHANGE 5 28 | #endif 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | int32_t YamiV4L2_Open(const char* name, int32_t flags); 34 | int32_t YamiV4L2_Close(int32_t fd); 35 | int32_t YamiV4L2_FrameMemoryType(int32_t fd, VideoDataMemoryType memory_type); 36 | int32_t YamiV4L2_SvcT(int32_t fd, bool enable); 37 | int32_t YamiV4L2_Ioctl(int32_t fd, int request, void* arg); 38 | int32_t YamiV4L2_Poll(int32_t fd, bool poll_device, bool* event_pending); 39 | int32_t YamiV4L2_SetDevicePollInterrupt(int32_t fd); 40 | int32_t YamiV4L2_ClearDevicePollInterrupt(int32_t fd); 41 | void* YamiV4L2_Mmap(void* addr, size_t length, 42 | int prot, int flags, int fd, unsigned int offset); 43 | int32_t YamiV4L2_Munmap(void* addr, size_t length); 44 | 45 | #if defined(__ENABLE_WAYLAND__) 46 | int32_t YamiV4L2_SetWaylandDisplay(int32_t fd, struct wl_display* wlDisplay); 47 | #endif //__ENABLE_WAYLAND__ 48 | 49 | #if defined(__ENABLE_X11__) 50 | /// it should be called before driver initialization (immediate after _Open()). 51 | int32_t YamiV4L2_SetXDisplay(int32_t fd, Display* x11Display); 52 | #endif // defined(__ENABLE_X11__) 53 | 54 | #if defined(__ENABLE_EGL__) 55 | int32_t YamiV4L2_UseEglImage(int fd, /*EGLDisplay*/ void* eglDisplay, /*EGLContext*/ void* eglContext, unsigned int buffer_index, void* egl_image); 56 | #endif //__ENABLE_EGL__ 57 | 58 | int32_t YamiV4L2_SetDrmFd(int32_t fd, int drm_fd); 59 | 60 | #ifdef __cplusplus 61 | } // extern "C" 62 | #endif 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /ocl/kernels/wireframe.cl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | __kernel void wireframe(__write_only image2d_t img_y, 18 | __write_only image2d_t img_uv, 19 | uint crop_x, 20 | uint crop_y, 21 | uint crop_w, 22 | uint crop_h, 23 | uint border, 24 | uchar y, 25 | uchar u, 26 | uchar v) 27 | { 28 | sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; 29 | size_t g_id_x = get_global_id(0); 30 | size_t g_id_y = get_global_id(1); 31 | uint4 Y = (uint4)y; 32 | uint4 UV = (uint4)(u, v, 0, 0); 33 | 34 | if ((g_id_x < crop_w && g_id_y < border) 35 | || ((g_id_x < border || (g_id_x + border >= crop_w && g_id_x < crop_w)) 36 | && (g_id_y >= border && g_id_y + border < crop_h)) 37 | || (g_id_x < crop_w && (g_id_y + border >= crop_h && g_id_y < crop_h))) { 38 | write_imageui(img_y, (int2)(g_id_x + crop_x, 2 * (g_id_y + crop_y)), Y); 39 | write_imageui(img_y, (int2)(g_id_x + crop_x, 2 * (g_id_y + crop_y) + 1), Y); 40 | write_imageui(img_uv, (int2)(g_id_x + crop_x, g_id_y + crop_y), UV); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ocl/oclcontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef oclcontext_h 17 | #define oclcontext_h 18 | 19 | 20 | #include "VideoCommonDefs.h" 21 | #include "common/lock.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace YamiMediaCodec{ 28 | 29 | class OclDevice; 30 | 31 | typedef std::map OclKernelMap; 32 | 33 | class OclContext 34 | { 35 | public: 36 | static SharedPtr create(); 37 | bool createKernel(const char* name, OclKernelMap& kernelMap); 38 | bool releaseKernel(OclKernelMap& kernelMap); 39 | YamiStatus createImageFromFdIntel(const cl_import_image_info_intel* info, cl_mem* mem); 40 | YamiStatus createBufferFromFdIntel(const cl_import_buffer_info_intel* info, cl_mem* mem); 41 | ~OclContext(); 42 | 43 | cl_context m_context; 44 | cl_command_queue m_queue; 45 | private: 46 | OclContext(); 47 | bool init(); 48 | SharedPtr m_device; 49 | DISALLOW_COPY_AND_ASSIGN(OclContext) 50 | }; 51 | 52 | bool checkOclStatus(cl_int status, const char* err); 53 | 54 | } 55 | 56 | #endif //oclcontext_h 57 | -------------------------------------------------------------------------------- /pkgconfig/Makefile.am: -------------------------------------------------------------------------------- 1 | pkg_config_files = \ 2 | libyami.pc \ 3 | $(NULL) 4 | 5 | if ENABLE_V4L2 6 | pkg_config_files += \ 7 | libyami_v4l2.pc \ 8 | $(NULL) 9 | endif 10 | 11 | pkgconfigdir = @pkgconfigdir@ 12 | pkgconfig_DATA = $(pkg_config_files) 13 | 14 | DISTCLEANFILES = \ 15 | $(pkg_config_files) \ 16 | Makefile.in \ 17 | $(NULL) 18 | -------------------------------------------------------------------------------- /pkgconfig/libyami.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libyami 7 | Description: Intel open source media infrastructure base on libva. 8 | Version: @YAMI_API_VERSION@ 9 | Requires: @LIBVA_PKG_REQ@ \ 10 | @LIBVA_DRM_PKG_REQ@ \ 11 | @LIBVA_X11_PKG_REQ@ \ 12 | @X11_PKG_REQ@ 13 | Libs: -L${libdir} -lyami 14 | Libs.private: -Wl,--whole-archive -lyami -Wl,--no-whole-archive 15 | Cflags: -I${includedir}/libyami 16 | -------------------------------------------------------------------------------- /pkgconfig/libyami_v4l2.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libyami_v4l2 7 | Description: yami based v4l2 plugin 8 | Version: @YAMI_API_VERSION@ 9 | Requires: libyami 10 | Libs: -L${libdir} -lyami_v4l2 11 | Cflags: -I${includedir}/libyami 12 | -------------------------------------------------------------------------------- /pre-commit: -------------------------------------------------------------------------------- 1 | ## strip trailing whitespace 2 | for file in `git diff --check --cached | grep '^[^+-]' | grep -o '^.*[0-9]\+:'` ; do 3 | file_name=`echo ${file} | grep -o '^[^:]\+'` 4 | line_number=`echo ${file} | grep -oP '(?<=:)[0-9]+(?=:)'` 5 | # I think the reason there are two sed commands here 6 | # is that 'sed -i' is different on different systems. 7 | # shoot me. 8 | (sed -i "${line_number}s/\s*$//" "${file_name}" > /dev/null 2>&1 \ 9 | || sed -i '' -E "${line_number}s/\s*$//" "${file_name}") 10 | git add ${file_name} 11 | echo "Re-wrote ${file_name} to trim whitespace." 12 | done 13 | 14 | ## remove 'x' bit and apply kr style for source file 15 | for file in `git diff --cached --name-only`; do 16 | filename=$(basename "$file") 17 | extension="${filename##*.}" 18 | dir_name=$(dirname "$file") 19 | if test "$extension" = "h" || test "$extension" = "c" || test "$extension" = "cpp"; then 20 | # remove the 'x' bit for files 21 | echo "remove 'x' for ${file}" 22 | chmod -x ${file} 23 | fi 24 | done 25 | 26 | echo "****************************************************" 27 | echo "* applying coding style to the changed files, you can:" 28 | echo "* a) [check ] it by 'git diff'" 29 | echo "* b) [accept] it by 'git commit -a --amend'" 30 | echo "* c) [reject] it by 'git reset --hard'" 31 | echo "****************************************************" 32 | -------------------------------------------------------------------------------- /v4l2/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | include $(LOCAL_PATH)/../common.mk 4 | 5 | LOCAL_SRC_FILES := \ 6 | v4l2_codecbase.cpp \ 7 | v4l2_decode.cpp \ 8 | v4l2_encode.cpp \ 9 | v4l2_wrapper.cpp 10 | 11 | LOCAL_C_INCLUDES:= \ 12 | $(LOCAL_PATH)/.. \ 13 | $(LOCAL_PATH)/../interface \ 14 | external/libcxx/include \ 15 | $(TARGET_OUT_HEADERS)/libva \ 16 | 17 | LOCAL_SHARED_LIBRARIES := \ 18 | liblog \ 19 | libc++ \ 20 | libva \ 21 | libhardware \ 22 | libva-android 23 | 24 | LOCAL_WHOLE_STATIC_LIBRARIES := \ 25 | libyami_common \ 26 | libcodecparser \ 27 | libyami_vaapi \ 28 | libyami_vpp \ 29 | libyami_decoder \ 30 | libyami_encoder 31 | 32 | ifeq ($(ENABLE-V4L2-OPS),true) 33 | LOCAL_CFLAGS += -D__ENABLE_V4L2_OPS__ 34 | endif 35 | 36 | LOCAL_MODULE := libyami_v4l2 37 | include $(BUILD_SHARED_LIBRARY) 38 | -------------------------------------------------------------------------------- /v4l2/BufferPipe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef BufferPipe_h 17 | #define BufferPipe_h 18 | 19 | #include "common/lock.h" 20 | #include 21 | 22 | namespace YamiMediaCodec { 23 | 24 | template 25 | class BufferPipe { 26 | typedef T ValueType; 27 | 28 | public: 29 | //queue to incoming 30 | void queue(const ValueType& v) 31 | { 32 | queue(m_incoming, v); 33 | } 34 | 35 | //deque from outgoing 36 | bool deque(ValueType& v) 37 | { 38 | return peek(m_outgoing, v, true); 39 | } 40 | 41 | //queue to outgoing 42 | void put(const ValueType& v) 43 | { 44 | queue(m_outgoing, v); 45 | } 46 | 47 | //deque from incoming 48 | bool get(ValueType& v) 49 | { 50 | return peek(m_incoming, v, true); 51 | } 52 | 53 | //peek from incoming 54 | bool peek(ValueType& v) 55 | { 56 | return peek(m_incoming, v); 57 | } 58 | 59 | //clear incoming and outgoing 60 | void clearPipe() 61 | { 62 | clearQueue(m_incoming); 63 | clearQueue(m_outgoing); 64 | } 65 | 66 | private: 67 | struct BufferQue { 68 | std::deque m_queue; 69 | Lock m_lock; 70 | }; 71 | BufferQue m_incoming; 72 | BufferQue m_outgoing; 73 | static void queue(BufferQue& q, const ValueType& v) 74 | { 75 | AutoLock l(q.m_lock); 76 | q.m_queue.push_back(v); 77 | } 78 | static bool peek(BufferQue& q, ValueType& v, bool pop = false) 79 | { 80 | AutoLock l(q.m_lock); 81 | if (q.m_queue.empty()) 82 | return false; 83 | v = q.m_queue.front(); 84 | if (pop) 85 | q.m_queue.pop_front(); 86 | return true; 87 | } 88 | static void clearQueue(BufferQue& q) 89 | { 90 | AutoLock l(q.m_lock); 91 | q.m_queue.clear(); 92 | } 93 | }; 94 | } 95 | 96 | #endif //BufferPipe_h 97 | -------------------------------------------------------------------------------- /v4l2/Makefile.am: -------------------------------------------------------------------------------- 1 | libyamiv4l2_source_c = \ 2 | v4l2_codecbase.cpp \ 3 | v4l2_decode.cpp \ 4 | v4l2_encode.cpp \ 5 | v4l2_wrapper.cpp \ 6 | $(NULL) 7 | 8 | if ENABLE_EGL 9 | libyamiv4l2_source_c += ../egl/egl_util.c ../egl/egl_vaapi_image.cpp 10 | endif 11 | 12 | libyamiv4l2_source_h = \ 13 | ../interface/v4l2_wrapper.h \ 14 | ../interface/v4l2codec_device_ops.h \ 15 | $(NULL) 16 | 17 | libyamiv4l2_source_h_priv = \ 18 | v4l2_codecbase.h \ 19 | v4l2_encode.h \ 20 | v4l2_decode.h \ 21 | $(NULL) 22 | 23 | libyamiv4l2_ldflags = \ 24 | $(LIBYAMI_LT_LDFLAGS) \ 25 | -pthread \ 26 | $(NULL) 27 | 28 | if ENABLE_EGL 29 | libyamiv4l2_ldflags += $(LIBEGL_LIBS) 30 | endif 31 | 32 | #to compile within yocto 33 | extra_includes = \ 34 | -I$(top_srcdir) \ 35 | $(NULL) 36 | 37 | libyamiv4l2_cppflags = \ 38 | $(LIBVA_CFLAGS) \ 39 | $(LIBV4L2_CFLAGS) \ 40 | -I$(top_srcdir)/interface \ 41 | $(extra_includes) \ 42 | $(NULL) 43 | 44 | if ENABLE_EGL 45 | libyamiv4l2_cppflags += $(LIBEGL_CFLAGS) 46 | endif 47 | 48 | if ENABLE_DMABUF 49 | libyamiv4l2_cppflags += $(LIBDRM_CFLAGS) 50 | endif 51 | 52 | 53 | noinst_LTLIBRARIES = libyamiv4l2.la 54 | libyamiv4l2includedir = $(includedir)/libyami 55 | libyamiv4l2include_HEADERS = $(libyamiv4l2_source_h) 56 | noinst_HEADERS = $(libyamiv4l2_source_h_priv) 57 | libyamiv4l2_la_SOURCES = $(libyamiv4l2_source_c) 58 | libyamiv4l2_la_LDFLAGS = $(libyamiv4l2_ldflags) $(AM_LDFLAGS) 59 | libyamiv4l2_la_CPPFLAGS = $(libyamiv4l2_cppflags) $(AM_CPPFLAGS) 60 | 61 | if ENABLE_TESTS 62 | -include Makefile.unittest 63 | endif 64 | 65 | DISTCLEANFILES = \ 66 | Makefile.in 67 | 68 | 69 | -------------------------------------------------------------------------------- /v4l2/v4l2_encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef v4l2_encode_h 17 | #define v4l2_encode_h 18 | 19 | #include 20 | 21 | #include "v4l2_codecbase.h" 22 | #include "VideoEncoderInterface.h" 23 | 24 | using namespace YamiMediaCodec; 25 | typedef SharedPtr < IVideoEncoder > EncoderPtr; 26 | 27 | class V4l2Encoder : public V4l2CodecBase 28 | { 29 | public: 30 | V4l2Encoder(); 31 | ~V4l2Encoder() {}; 32 | 33 | virtual int32_t ioctl(int request, void* arg); 34 | virtual void* mmap(void* addr, size_t length, 35 | int prot, int flags, unsigned int offset); 36 | 37 | protected: 38 | virtual bool start(); 39 | virtual bool stop(); 40 | virtual bool acceptInputBuffer(struct v4l2_buffer *qbuf); 41 | virtual bool giveOutputBuffer(struct v4l2_buffer *dqbuf); 42 | virtual bool inputPulse(uint32_t index); 43 | virtual bool outputPulse(uint32_t &index); 44 | 45 | private: 46 | bool UpdateVideoParameters(bool isInputThread=false); 47 | EncoderPtr m_encoder; 48 | 49 | VideoParamsCommon m_videoParams; 50 | Lock m_videoParamsLock; 51 | bool m_videoParamsChanged; 52 | 53 | uint32_t m_maxOutputBufferSize; 54 | uint8_t *m_outputBufferSpace; 55 | 56 | std::vector m_inputFrames; 57 | std::vector m_outputFrames; 58 | 59 | bool m_separatedStreamHeader; 60 | bool m_requestStreamHeader; 61 | bool m_forceKeyFrame; 62 | }; 63 | #endif 64 | -------------------------------------------------------------------------------- /vaapi/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | include $(LOCAL_PATH)/../common.mk 4 | 5 | LOCAL_SRC_FILES := \ 6 | vaapipicture.cpp \ 7 | VaapiBuffer.cpp \ 8 | VaapiSurface.cpp\ 9 | VaapiUtils.cpp \ 10 | vaapidisplay.cpp \ 11 | vaapicontext.cpp \ 12 | vaapisurfaceallocator.cpp \ 13 | 14 | LOCAL_C_INCLUDES:= \ 15 | $(LOCAL_PATH)/.. \ 16 | $(LOCAL_PATH)/../interface \ 17 | external/libcxx/include \ 18 | $(TARGET_OUT_HEADERS)/libva 19 | 20 | LOCAL_SHARED_LIBRARIES := \ 21 | liblog \ 22 | libva \ 23 | libva-android \ 24 | libc++ \ 25 | 26 | LOCAL_CPPFLAGS += \ 27 | -frtti 28 | 29 | LOCAL_PROPRIETARY_MODULE := true 30 | LOCAL_MODULE := libyami_vaapi 31 | include $(BUILD_STATIC_LIBRARY) 32 | -------------------------------------------------------------------------------- /vaapi/Makefile.am: -------------------------------------------------------------------------------- 1 | libyami_vaapi_source_c = \ 2 | vaapipicture.cpp \ 3 | VaapiBuffer.cpp \ 4 | VaapiSurface.cpp\ 5 | VaapiUtils.cpp \ 6 | vaapidisplay.cpp \ 7 | vaapicontext.cpp \ 8 | vaapisurfaceallocator.cpp \ 9 | $(NULL) 10 | 11 | libyami_vaapi_source_h_priv = \ 12 | vaapipicture.h \ 13 | VaapiBuffer.h \ 14 | VaapiSurface.h \ 15 | VaapiUtils.h \ 16 | vaapidisplay.h \ 17 | vaapicontext.h \ 18 | vaapistreamable.h \ 19 | vaapisurfaceallocator.h \ 20 | $(NULL) 21 | 22 | libyami_vaapi_ldflags = \ 23 | $(LIBYAMI_LT_LDFLAGS) \ 24 | $(LIBVA_LIBS) \ 25 | $(LIBVA_DRM_LIBS) \ 26 | $(NULL) 27 | 28 | if ENABLE_X11 29 | libyami_vaapi_ldflags += $(LIBVA_X11_LIBS) $(X11_LIBS) 30 | endif 31 | 32 | #to compile within yocto 33 | extra_includes = \ 34 | -I$(top_srcdir) \ 35 | $(NULL) 36 | 37 | libyami_vaapi_cppflags = \ 38 | $(LIBVA_CFLAGS) \ 39 | -I$(top_srcdir)/interface \ 40 | $(extra_includes) \ 41 | $(NULL) 42 | 43 | noinst_LTLIBRARIES = libyami_vaapi.la 44 | libyami_vaapiincludedir = ${includedir}/libyami 45 | libyami_vaapiinclude_HEADERS = $(libyami_vaapi_source_h) 46 | libyami_vaapi_la_SOURCES = $(libyami_vaapi_source_c) 47 | libyami_vaapi_la_LDFLAGS = $(libyami_vaapi_ldflags) $(AM_LDFLAGS) 48 | libyami_vaapi_la_CPPFLAGS = $(libyami_vaapi_cppflags) $(AM_CPPFLAGS) 49 | 50 | if ENABLE_TESTS 51 | include Makefile.unittest 52 | endif 53 | 54 | DISTCLEANFILES = \ 55 | Makefile.in 56 | 57 | 58 | -------------------------------------------------------------------------------- /vaapi/Makefile.unittest: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = unittest 2 | 3 | unittest_SOURCES = \ 4 | unittest_main.cpp \ 5 | vaapidisplay_unittest.cpp \ 6 | $(NULL) 7 | 8 | unittest_LDFLAGS = \ 9 | $(AM_LDFLAGS) \ 10 | -pthread \ 11 | $(NULL) 12 | 13 | unittest_LDADD = \ 14 | libyami_vaapi.la \ 15 | $(top_builddir)/common/libyami_common.la \ 16 | $(top_srcdir)/gtestsrc/libgtest.la \ 17 | $(NULL) 18 | 19 | if ENABLE_X11 20 | unittest_LDADD += $(X11_LIBS) 21 | endif 22 | 23 | unittest_CPPFLAGS = \ 24 | $(LIBVA_CFLAGS) \ 25 | $(AM_CPPFLAGS) \ 26 | -I$(top_srcdir)/interface \ 27 | -I$(top_srcdir)/gtestsrc/gtest/include \ 28 | $(NULL) 29 | 30 | unittest_CXXFLAGS = \ 31 | $(AM_CXXFLAGS) \ 32 | $(NULL) 33 | 34 | check-local: unittest 35 | $(builddir)/unittest 36 | 37 | -------------------------------------------------------------------------------- /vaapi/VaapiBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef VaapiBuffer_h 18 | #define VaapiBuffer_h 19 | 20 | #include "common/NonCopyable.h" 21 | #include "vaapiptrs.h" 22 | 23 | #include 24 | #include 25 | 26 | namespace YamiMediaCodec { 27 | 28 | class VaapiBuffer { 29 | public: 30 | static BufObjectPtr create(const ContextPtr&, 31 | VABufferType, 32 | uint32_t size, 33 | const void* data = 0, 34 | void** mapped = 0); 35 | 36 | template 37 | static BufObjectPtr create(const ContextPtr&, 38 | VABufferType, T*& mapped); 39 | 40 | void* map(); 41 | void unmap(); 42 | uint32_t getSize(); 43 | VABufferID getID(); 44 | ~VaapiBuffer(); 45 | 46 | private: 47 | VaapiBuffer(const DisplayPtr&, VABufferID id, uint32_t size); 48 | DisplayPtr m_display; 49 | VABufferID m_id; 50 | void* m_data; 51 | uint32_t m_size; 52 | DISALLOW_COPY_AND_ASSIGN(VaapiBuffer); 53 | }; 54 | 55 | template 56 | BufObjectPtr VaapiBuffer::create(const ContextPtr& context, 57 | VABufferType type, T*& mapped) 58 | { 59 | BufObjectPtr p = create(context, type, sizeof(T), NULL, (void**)&mapped); 60 | if (p) { 61 | if (mapped) { 62 | memset(mapped, 0, sizeof(T)); 63 | } 64 | else { 65 | //bug 66 | p.reset(); 67 | } 68 | } 69 | return p; 70 | } 71 | } 72 | 73 | #endif //VaapiBuffer_h 74 | -------------------------------------------------------------------------------- /vaapi/VaapiSurface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | #include "VaapiSurface.h" 22 | 23 | #include 24 | 25 | namespace YamiMediaCodec { 26 | 27 | VaapiSurface::VaapiSurface(intptr_t id, uint32_t width, uint32_t height, uint32_t fourcc) 28 | { 29 | m_frame.reset(new VideoFrame); 30 | memset(m_frame.get(), 0, sizeof(VideoFrame)); 31 | m_frame->surface = id; 32 | m_frame->crop.x = m_frame->crop.y = 0; 33 | m_frame->crop.width = width; 34 | m_frame->crop.height = height; 35 | m_frame->fourcc = fourcc; 36 | m_width = width; 37 | m_height = height; 38 | } 39 | 40 | VaapiSurface::VaapiSurface(const SharedPtr& frame) 41 | { 42 | m_frame = frame; 43 | 44 | VideoRect& r = m_frame->crop; 45 | m_width = r.x + r.width; 46 | m_height = r.y + r.height; 47 | } 48 | 49 | VASurfaceID VaapiSurface::getID() 50 | { 51 | return (VASurfaceID)m_frame->surface; 52 | } 53 | 54 | bool VaapiSurface::setCrop(uint32_t x, uint32_t y, uint32_t width, uint32_t height) 55 | { 56 | VideoRect& r = m_frame->crop; 57 | 58 | if (x + width > m_width 59 | || y + height > m_height) 60 | return false; 61 | r.x = x; 62 | r.y = y; 63 | r.width = width; 64 | r.height = height; 65 | return true; 66 | } 67 | 68 | void VaapiSurface::getCrop(uint32_t& x, uint32_t& y, uint32_t& width, uint32_t& height) 69 | { 70 | const VideoRect& r = m_frame->crop; 71 | x = r.x; 72 | y = r.y; 73 | width = r.width; 74 | height = r.height; 75 | } 76 | 77 | uint32_t VaapiSurface::getFourcc() 78 | { 79 | return m_frame->fourcc; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /vaapi/VaapiSurface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef VaapiSurface_h 18 | #define VaapiSurface_h 19 | 20 | #include "common/NonCopyable.h" 21 | #include "VideoCommonDefs.h" 22 | #include 23 | #include 24 | 25 | namespace YamiMediaCodec { 26 | 27 | class VaapiSurface { 28 | friend class VaapiDecoderBase; 29 | 30 | public: 31 | VaapiSurface(intptr_t id, uint32_t width, uint32_t height, uint32_t fourcc); 32 | VaapiSurface(const SharedPtr&); 33 | 34 | VASurfaceID getID(); 35 | 36 | bool setCrop(uint32_t x, uint32_t y, uint32_t width, uint32_t height); 37 | void getCrop(uint32_t& x, uint32_t& y, uint32_t& width, uint32_t& height); 38 | uint32_t getFourcc(); 39 | 40 | private: 41 | SharedPtr m_frame; 42 | uint32_t m_width; 43 | uint32_t m_height; 44 | DISALLOW_COPY_AND_ASSIGN(VaapiSurface); 45 | }; 46 | 47 | } 48 | 49 | #endif //VaapiSurface_h 50 | -------------------------------------------------------------------------------- /vaapi/VaapiUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef VaapiUtils_h 18 | #define VaapiUtils_h 19 | 20 | #include "common/log.h" 21 | #include 22 | 23 | namespace YamiMediaCodec { 24 | 25 | uint8_t* mapSurfaceToImage(VADisplay display, intptr_t surface, VAImage& image); 26 | 27 | void unmapImage(VADisplay display, const VAImage& image); 28 | 29 | //return rt format, 0 for unsupported 30 | uint32_t getRtFormat(uint32_t fourcc); 31 | bool dumpSurface(VADisplay display, intptr_t surface); 32 | 33 | #define checkVaapiStatus(status, prompt) \ 34 | ( \ 35 | { \ 36 | bool ret; \ 37 | ret = (status == VA_STATUS_SUCCESS); \ 38 | if (!ret) \ 39 | ERROR("%s: %s", prompt, vaErrorStr(status)); \ 40 | ret; \ 41 | }) 42 | } 43 | 44 | #endif //VaapiUtils_h 45 | -------------------------------------------------------------------------------- /vaapi/unittest_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // library headers 18 | #include "common/unittest.h" 19 | 20 | int main(int argc, char **argv) { 21 | ::testing::InitGoogleTest(&argc, argv); 22 | return RUN_ALL_TESTS(); 23 | } 24 | -------------------------------------------------------------------------------- /vaapi/vaapicontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapicontext_h 18 | #define vaapicontext_h 19 | 20 | #include "common/NonCopyable.h" 21 | #include "VideoCommonDefs.h" 22 | #include "vaapi/vaapiptrs.h" 23 | #include 24 | 25 | namespace YamiMediaCodec{ 26 | class VaapiConfig 27 | { 28 | friend class VaapiContext; 29 | public: 30 | static YamiStatus create(const DisplayPtr&, VAProfile, VAEntrypoint, 31 | VAConfigAttrib* attribList, int numAttribs, ConfigPtr& confg); 32 | ~VaapiConfig(); 33 | private: 34 | VaapiConfig(const DisplayPtr&, VAConfigID); 35 | DisplayPtr m_display; 36 | VAConfigID m_config; 37 | DISALLOW_COPY_AND_ASSIGN(VaapiConfig); 38 | }; 39 | 40 | class VaapiContext 41 | { 42 | public: 43 | static ContextPtr create(const ConfigPtr&, 44 | int width,int height,int flag, 45 | VASurfaceID *render_targets, 46 | int num_render_targets); 47 | VAContextID getID() const { return m_context; } 48 | DisplayPtr getDisplay() const { return m_config->m_display; } 49 | 50 | ~VaapiContext(); 51 | private: 52 | VaapiContext(const ConfigPtr&, VAContextID); 53 | ConfigPtr m_config; 54 | VAContextID m_context; 55 | DISALLOW_COPY_AND_ASSIGN(VaapiContext); 56 | }; 57 | } 58 | #endif 59 | -------------------------------------------------------------------------------- /vaapi/vaapidisplay.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapidisplay_h 18 | #define vaapidisplay_h 19 | 20 | #include "vaapi/vaapiptrs.h" 21 | #include 22 | #ifdef HAVE_VA_X11 23 | #include 24 | #endif 25 | #ifndef ANDROID 26 | #include 27 | #endif 28 | #include 29 | #include "common/lock.h" 30 | #include "common/NonCopyable.h" 31 | 32 | ///abstract for all display, x11, wayland, ozone, android etc. 33 | namespace YamiMediaCodec{ 34 | #ifndef VA_FOURCC_I420 35 | #define VA_FOURCC_I420 VA_FOURCC('I','4','2','0') 36 | #endif 37 | class NativeDisplayBase; 38 | class VaapiDisplay 39 | { 40 | typedef SharedPtr NativeDisplayPtr; 41 | friend class DisplayCache; 42 | friend class VaapiDisplayTest; 43 | 44 | public: 45 | virtual ~VaapiDisplay(); 46 | //FIXME: add more create functions. 47 | static DisplayPtr create(const NativeDisplay& display); 48 | virtual bool setRotation(int degree); 49 | VADisplay getID() const { return m_vaDisplay; } 50 | const VAImageFormat* getVaFormat(uint32_t fourcc); 51 | 52 | protected: 53 | /// for display cache management. 54 | virtual bool isCompatible(const NativeDisplay& other); 55 | 56 | private: 57 | VaapiDisplay(const NativeDisplayPtr& nativeDisplay, VADisplay vaDisplay) 58 | :m_vaDisplay(vaDisplay), m_nativeDisplay(nativeDisplay) { }; 59 | 60 | Lock m_lock; 61 | VADisplay m_vaDisplay; 62 | NativeDisplayPtr m_nativeDisplay; 63 | std::vector m_vaImageFormats; 64 | 65 | DISALLOW_COPY_AND_ASSIGN(VaapiDisplay); 66 | }; 67 | } 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /vaapi/vaapiptrs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapiptrs_h 18 | #define vaapiptrs_h 19 | 20 | #include "VideoCommonDefs.h" 21 | 22 | namespace YamiMediaCodec{ 23 | class VaapiSurface; 24 | typedef SharedPtr < VaapiSurface > SurfacePtr; 25 | 26 | class VaapiCodedBuffer; 27 | typedef SharedPtr < VaapiCodedBuffer > CodedBufferPtr; 28 | 29 | class VaapiBuffer; 30 | typedef SharedPtr BufObjectPtr; 31 | 32 | class VaapiDisplay; 33 | typedef SharedPtr < VaapiDisplay > DisplayPtr; 34 | 35 | class VaapiConfig; 36 | typedef SharedPtr < VaapiConfig > ConfigPtr; 37 | 38 | class VaapiContext; 39 | typedef SharedPtr < VaapiContext > ContextPtr; 40 | 41 | class VaapiDecSurfacePool; 42 | typedef SharedPtr < VaapiDecSurfacePool > DecSurfacePoolPtr; 43 | 44 | } //namespace YamiMediaCodec 45 | 46 | #endif /* vaapiptr_h */ 47 | -------------------------------------------------------------------------------- /vaapi/vaapisurfaceallocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapisurfaceallocator_h 18 | #define vaapisurfaceallocator_h 19 | #include "common/basesurfaceallocator.h" 20 | #include "common/NonCopyable.h" 21 | #include 22 | 23 | namespace YamiMediaCodec{ 24 | 25 | class VaapiSurfaceAllocator : public BaseSurfaceAllocator 26 | { 27 | //extra buffer size for performance 28 | static const uint32_t EXTRA_BUFFER_SIZE = 5; 29 | public: 30 | //we do not use DisplayPtr here since we may give this to user someday. 31 | //@extraSize[in] extra size add to SurfaceAllocParams.size 32 | VaapiSurfaceAllocator(VADisplay display, uint32_t extraSize = EXTRA_BUFFER_SIZE); 33 | protected: 34 | virtual YamiStatus doAlloc(SurfaceAllocParams* params); 35 | virtual YamiStatus doFree(SurfaceAllocParams* params); 36 | virtual void doUnref(); 37 | private: 38 | VADisplay m_display; 39 | uint32_t m_extraSize; 40 | DISALLOW_COPY_AND_ASSIGN(VaapiSurfaceAllocator); 41 | }; 42 | 43 | } 44 | #endif //vaapisurfaceallocator_h 45 | -------------------------------------------------------------------------------- /vpp/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | include $(LOCAL_PATH)/../common.mk 4 | 5 | LOCAL_SRC_FILES := \ 6 | vaapipostprocess_base.cpp \ 7 | vaapipostprocess_host.cpp \ 8 | vaapipostprocess_scaler.cpp \ 9 | vaapivpppicture.cpp 10 | 11 | LOCAL_C_INCLUDES:= \ 12 | $(LOCAL_PATH)/.. \ 13 | $(LOCAL_PATH)/../interface \ 14 | external/libcxx/include \ 15 | $(TARGET_OUT_HEADERS)/libva 16 | 17 | LOCAL_SHARED_LIBRARIES := \ 18 | liblog \ 19 | libva \ 20 | libc++ 21 | 22 | LOCAL_CPPFLAGS += \ 23 | -frtti 24 | 25 | LOCAL_ALLOW_UNDEFINED_SYMBOLS := true 26 | 27 | LOCAL_PROPRIETARY_MODULE := true 28 | LOCAL_MODULE := libyami_vpp 29 | include $(BUILD_STATIC_LIBRARY) 30 | -------------------------------------------------------------------------------- /vpp/Makefile.unittest: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = unittest 2 | 3 | unittest_SOURCES = \ 4 | unittest_main.cpp \ 5 | $(NULL) 6 | 7 | unittest_SOURCES += vaapipostprocess_scaler_unittest.cpp 8 | 9 | if BUILD_OCL_FILTERS 10 | unittest_SOURCES += \ 11 | oclpostprocess_blender_unittest.cpp \ 12 | oclpostprocess_mosaic_unittest.cpp \ 13 | oclpostprocess_osd_unittest.cpp \ 14 | oclpostprocess_transform_unittest.cpp \ 15 | oclpostprocess_wireframe_unittest.cpp \ 16 | $(NULL) 17 | endif 18 | 19 | unittest_LDFLAGS = \ 20 | $(AM_LDFLAGS) \ 21 | -pthread \ 22 | $(NULL) 23 | 24 | unittest_LDADD = \ 25 | libyami_vpp.la \ 26 | $(top_builddir)/vaapi/libyami_vaapi.la \ 27 | $(top_builddir)/common/libyami_common.la \ 28 | $(top_srcdir)/gtestsrc/libgtest.la \ 29 | $(NULL) 30 | 31 | unittest_CPPFLAGS = \ 32 | $(LIBVA_CFLAGS) \ 33 | $(AM_CPPFLAGS) \ 34 | -I$(top_srcdir)/interface \ 35 | -I$(top_srcdir)/gtestsrc/gtest/include \ 36 | $(NULL) 37 | 38 | unittest_CXXFLAGS = \ 39 | $(AM_CXXFLAGS) \ 40 | $(NULL) 41 | 42 | # Separate the vaapipostprocess_host_unittest so that we can detect static 43 | # initialization bugs with the vpp factory. Separation is required 44 | # since any derived vpp that is explicitly constructed in another test 45 | # would hide such bugs. 46 | noinst_PROGRAMS += unittest_host 47 | unittest_host_SOURCES = \ 48 | unittest_main.cpp \ 49 | vaapipostprocess_host_unittest.cpp \ 50 | $(NULL) 51 | 52 | unittest_host_LDFLAGS = \ 53 | $(AM_LDFLAGS) \ 54 | -pthread \ 55 | $(NULL) 56 | 57 | unittest_host_LDADD = \ 58 | libyami_vpp.la \ 59 | $(top_builddir)/vaapi/libyami_vaapi.la \ 60 | $(top_builddir)/common/libyami_common.la \ 61 | $(top_srcdir)/gtestsrc/libgtest.la \ 62 | $(NULL) 63 | 64 | unittest_host_CPPFLAGS = \ 65 | $(LIBVA_CFLAGS) \ 66 | $(AM_CPPFLAGS) \ 67 | -I$(top_srcdir)/interface \ 68 | -I$(top_srcdir)/gtestsrc/gtest/include \ 69 | $(NULL) 70 | 71 | unittest_host_CXXFLAGS = \ 72 | $(AM_CXXFLAGS) \ 73 | $(NULL) 74 | 75 | check-local: unittest unittest_host 76 | $(builddir)/unittest 77 | $(builddir)/unittest_host 78 | 79 | -------------------------------------------------------------------------------- /vpp/oclpostprocess_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef oclpostprocess_base_h 18 | #define oclpostprocess_base_h 19 | 20 | #include "VideoPostProcessInterface.h" 21 | #include 22 | #include 23 | #include 24 | 25 | template 26 | class FactoryTest; 27 | 28 | namespace YamiMediaCodec{ 29 | class OclContext; 30 | /** 31 | * \class OclPostProcessBase 32 | * \brief Abstract video post process base on opencl 33 | * 34 | */ 35 | class OclPostProcessBase : public IVideoPostProcess { 36 | public: 37 | // set native display 38 | virtual YamiStatus setNativeDisplay(const NativeDisplay& display); 39 | 40 | YamiStatus ensureContext(const char* name); 41 | // 42 | virtual YamiStatus process(const SharedPtr& src, 43 | const SharedPtr& dest) = 0; 44 | virtual YamiStatus setParameters(VppParamType type, void* vppParam) 45 | { 46 | return YAMI_SUCCESS; 47 | } 48 | OclPostProcessBase(); 49 | virtual ~OclPostProcessBase(); 50 | 51 | protected: 52 | class VideoFrameDeleter { 53 | public: 54 | VideoFrameDeleter(VADisplay display) 55 | : m_display(display) 56 | { 57 | } 58 | void operator()(VideoFrame* frame) 59 | { 60 | VASurfaceID id = (VASurfaceID)frame->surface; 61 | vaDestroySurfaces(m_display, &id, 1); 62 | delete frame; 63 | } 64 | 65 | private: 66 | VADisplay m_display; 67 | }; 68 | 69 | uint32_t getPixelSize(const cl_image_format& fmt); 70 | cl_kernel prepareKernel(const char* name); 71 | 72 | VADisplay m_display; 73 | SharedPtr m_context; 74 | OclKernelMap m_kernels; 75 | 76 | private: 77 | virtual bool prepareKernels() = 0; 78 | }; 79 | } 80 | #endif /* vaapipostprocess_base_h */ 81 | 82 | -------------------------------------------------------------------------------- /vpp/oclpostprocess_blender.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef oclpostprocess_blender_h 17 | #define oclpostprocess_blender_h 18 | 19 | 20 | #include "VideoCommonDefs.h" 21 | #include "oclpostprocess_base.h" 22 | 23 | namespace YamiMediaCodec{ 24 | 25 | /** 26 | * \class OclPostProcessBlend 27 | * \brief alpha blending base on opencl 28 | */ 29 | class OclPostProcessBlender : public OclPostProcessBase { 30 | public: 31 | virtual YamiStatus process(const SharedPtr& src, 32 | const SharedPtr& dest); 33 | explicit OclPostProcessBlender() 34 | : m_kernelBlend(NULL) 35 | { 36 | ensureContext("blend"); 37 | } 38 | 39 | private: 40 | friend class FactoryTest; 41 | friend class OclPostProcessBlenderTest; 42 | 43 | virtual bool prepareKernels(); 44 | YamiStatus blend(const SharedPtr& src, 45 | const SharedPtr& dst); 46 | 47 | /** 48 | * VaapiPostProcessFactory registration result. This postprocess is 49 | * registered in vaapipostprocess_host.cpp 50 | */ 51 | static const bool s_registered; 52 | 53 | cl_kernel m_kernelBlend; 54 | }; 55 | 56 | } 57 | #endif //oclpostprocess_blend_h 58 | -------------------------------------------------------------------------------- /vpp/oclpostprocess_blender_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "oclpostprocess_blender.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class OclPostProcessBlenderTest 40 | : public FactoryTest 41 | { }; 42 | 43 | #define OCLPOSTPROCESS_BLENDER_TEST(name) \ 44 | TEST_F(OclPostProcessBlenderTest, name) 45 | 46 | OCLPOSTPROCESS_BLENDER_TEST(Factory) { 47 | FactoryKeys mimeTypes; 48 | mimeTypes.push_back(YAMI_VPP_OCL_BLENDER); 49 | doFactoryTest(mimeTypes); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /vpp/oclpostprocess_mosaic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef oclpostprocess_mosaic_h 17 | #define oclpostprocess_mosaic_h 18 | 19 | #include "VideoCommonDefs.h" 20 | #include "oclpostprocess_base.h" 21 | 22 | namespace YamiMediaCodec { 23 | 24 | /** 25 | * \class OclPostProcessMosaic 26 | * \brief OpenCL based mosaic filter 27 | */ 28 | class OclPostProcessMosaic : public OclPostProcessBase { 29 | public: 30 | virtual YamiStatus process(const SharedPtr& src, 31 | const SharedPtr& dst); 32 | 33 | virtual YamiStatus setParameters(VppParamType type, void* vppParam); 34 | 35 | explicit OclPostProcessMosaic() 36 | : m_blockSize(32) 37 | , m_kernelMosaic(NULL) 38 | { 39 | ensureContext("mosaic"); 40 | } 41 | 42 | private: 43 | friend class FactoryTest; 44 | friend class OclPostProcessMosaicTest; 45 | 46 | virtual bool prepareKernels(); 47 | 48 | /** 49 | * VaapiPostProcessFactory registration result. This postprocess is 50 | * registered in vaapipostprocess_host.cpp 51 | */ 52 | static const bool s_registered; 53 | 54 | int m_blockSize; 55 | cl_kernel m_kernelMosaic; 56 | }; 57 | } 58 | #endif //oclpostprocess_mosaic_h 59 | -------------------------------------------------------------------------------- /vpp/oclpostprocess_mosaic_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "oclpostprocess_mosaic.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class OclPostProcessMosaicTest 40 | : public FactoryTest 41 | { }; 42 | 43 | #define OCLPOSTPROCESS_MOSAIC_TEST(name) \ 44 | TEST_F(OclPostProcessMosaicTest, name) 45 | 46 | OCLPOSTPROCESS_MOSAIC_TEST(Factory) { 47 | FactoryKeys mimeTypes; 48 | mimeTypes.push_back(YAMI_VPP_OCL_MOSAIC); 49 | doFactoryTest(mimeTypes); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /vpp/oclpostprocess_osd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef oclpostprocess_osd_h 17 | #define oclpostprocess_osd_h 18 | 19 | #include 20 | #include "VideoCommonDefs.h" 21 | #include "oclpostprocess_base.h" 22 | 23 | using std::vector; 24 | 25 | namespace YamiMediaCodec { 26 | 27 | /** 28 | * \class OclPostProcessOsd 29 | * \brief OpenCL based OSD of contrastive font color 30 | */ 31 | class OclPostProcessOsd : public OclPostProcessBase { 32 | public: 33 | virtual YamiStatus process(const SharedPtr& src, 34 | const SharedPtr& dst); 35 | 36 | virtual YamiStatus setParameters(VppParamType type, void* vppParam); 37 | 38 | explicit OclPostProcessOsd() 39 | : m_blockCount(0) 40 | , m_threshold(128) 41 | , m_kernelOsd(NULL) 42 | , m_kernelReduceLuma(NULL) 43 | { 44 | ensureContext("osd"); 45 | } 46 | 47 | private: 48 | friend class FactoryTest; 49 | friend class OclPostProcessOsdTest; 50 | 51 | virtual bool prepareKernels(); 52 | YamiStatus computeBlockLuma(const SharedPtr frame); 53 | 54 | /** 55 | * VaapiPostProcessFactory registration result. This postprocess is 56 | * registered in vaapipostprocess_host.cpp 57 | */ 58 | static const bool s_registered; 59 | 60 | vector m_osdLuma; 61 | vector m_lineBuf; 62 | int m_blockCount; 63 | uint32_t m_threshold; 64 | cl_kernel m_kernelOsd; 65 | cl_kernel m_kernelReduceLuma; 66 | }; 67 | } 68 | #endif //oclpostprocess_osd_h 69 | -------------------------------------------------------------------------------- /vpp/oclpostprocess_osd_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "oclpostprocess_osd.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class OclPostProcessOsdTest 40 | : public FactoryTest 41 | { }; 42 | 43 | #define OCLPOSTPROCESS_OSD_TEST(name) \ 44 | TEST_F(OclPostProcessOsdTest, name) 45 | 46 | OCLPOSTPROCESS_OSD_TEST(Factory) { 47 | FactoryKeys mimeTypes; 48 | mimeTypes.push_back(YAMI_VPP_OCL_OSD); 49 | doFactoryTest(mimeTypes); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /vpp/oclpostprocess_transform_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "oclpostprocess_transform.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class OclPostProcessTransformTest 40 | : public FactoryTest 41 | { }; 42 | 43 | #define OCLPOSTPROCESS_TRANSFORM_TEST(name) \ 44 | TEST_F(OclPostProcessTransformTest, name) 45 | 46 | OCLPOSTPROCESS_TRANSFORM_TEST(Factory) { 47 | FactoryKeys mimeTypes; 48 | mimeTypes.push_back(YAMI_VPP_OCL_TRANSFORM); 49 | doFactoryTest(mimeTypes); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /vpp/oclpostprocess_wireframe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef oclpostprocess_wireframe_h 18 | #define oclpostprocess_wireframe_h 19 | 20 | #include "interface/VideoCommonDefs.h" 21 | #include "oclpostprocess_base.h" 22 | 23 | namespace YamiMediaCodec { 24 | 25 | /** 26 | * \class OclPostProcessWireframe 27 | * \brief OpenCL based wireframe filter 28 | */ 29 | class OclPostProcessWireframe : public OclPostProcessBase { 30 | public: 31 | virtual YamiStatus process(const SharedPtr& src, 32 | const SharedPtr& dst); 33 | 34 | virtual YamiStatus setParameters(VppParamType type, void* vppParam); 35 | 36 | explicit OclPostProcessWireframe() 37 | : m_borderWidth(4) 38 | , m_colorY(0xFF) 39 | , m_colorU(0) 40 | , m_colorV(0) 41 | , m_kernelWireframe(NULL) 42 | { 43 | ensureContext("wireframe"); 44 | } 45 | 46 | private: 47 | friend class FactoryTest; 48 | friend class OclPostProcessWireframeTest; 49 | 50 | virtual bool prepareKernels(); 51 | 52 | /** 53 | * VaapiPostProcessFactory registration result. This postprocess is 54 | * registered in vaapipostprocess_host.cpp 55 | */ 56 | static const bool s_registered; 57 | 58 | uint32_t m_borderWidth; 59 | uint8_t m_colorY; 60 | uint8_t m_colorU; 61 | uint8_t m_colorV; 62 | cl_kernel m_kernelWireframe; 63 | }; 64 | } 65 | #endif //oclpostprocess_wireframe_h 66 | -------------------------------------------------------------------------------- /vpp/oclpostprocess_wireframe_unittest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | // 22 | // The unittest header must be included before va_x11.h (which might be included 23 | // indirectly). The va_x11.h includes Xlib.h and X.h. And the X headers 24 | // define 'Bool' and 'None' preprocessor types. Gtest uses the same names 25 | // to define some struct placeholders. Thus, this creates a compile conflict 26 | // if X defines them before gtest. Hence, the include order requirement here 27 | // is the only fix for this right now. 28 | // 29 | // See bug filed on gtest at https://github.com/google/googletest/issues/371 30 | // for more details. 31 | // 32 | #include "common/factory_unittest.h" 33 | 34 | // primary header 35 | #include "oclpostprocess_wireframe.h" 36 | 37 | namespace YamiMediaCodec { 38 | 39 | class OclPostProcessWireframeTest 40 | : public FactoryTest 41 | { }; 42 | 43 | #define OCLPOSTPROCESS_WIREFRAME_TEST(name) \ 44 | TEST_F(OclPostProcessWireframeTest, name) 45 | 46 | OCLPOSTPROCESS_WIREFRAME_TEST(Factory) { 47 | FactoryKeys mimeTypes; 48 | mimeTypes.push_back(YAMI_VPP_OCL_WIREFRAME); 49 | doFactoryTest(mimeTypes); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /vpp/unittest_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // library headers 18 | #include "common/unittest.h" 19 | 20 | int main(int argc, char **argv) { 21 | ::testing::InitGoogleTest(&argc, argv); 22 | return RUN_ALL_TESTS(); 23 | } 24 | -------------------------------------------------------------------------------- /vpp/vaapipostprocess_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapipostprocess_base_h 18 | #define vaapipostprocess_base_h 19 | 20 | #include "VideoPostProcessInterface.h" 21 | #include "vaapi/vaapiptrs.h" 22 | #include 23 | #include 24 | 25 | template 26 | class FactoryTest; 27 | 28 | namespace YamiMediaCodec{ 29 | /** 30 | * \class IVideoPostProcess 31 | * \brief Abstract video post process interface of libyami 32 | * it is the interface with client. they are not thread safe. 33 | */ 34 | class VaapiPostProcessBase : public IVideoPostProcess { 35 | public: 36 | // set native display 37 | virtual YamiStatus setNativeDisplay(const NativeDisplay& display); 38 | // it may return YAMI_MORE_DATA when output is not ready 39 | // it's no need fill every field of VideoFrame, we can get detailed information from lower level 40 | // VideoFrame.surface is enough for most of case 41 | // for some type of vpp such as deinterlace, we will hold a referece of src. 42 | virtual YamiStatus process(const SharedPtr& src, 43 | const SharedPtr& dest) = 0; 44 | virtual YamiStatus setParameters(VppParamType type, void* vppParam) { return YAMI_INVALID_PARAM; } 45 | virtual ~VaapiPostProcessBase(); 46 | protected: 47 | //NativeDisplay m_externalDisplay; 48 | YamiStatus initVA(const NativeDisplay& display); 49 | void cleanupVA(); 50 | 51 | YamiStatus queryVideoProcFilterCaps(VAProcFilterType filterType, void* filterCaps, uint32_t* numFilterCaps = NULL); 52 | 53 | DisplayPtr m_display; 54 | ContextPtr m_context; 55 | }; 56 | } 57 | #endif /* vaapipostprocess_base_h */ 58 | -------------------------------------------------------------------------------- /vpp/vaapipostprocess_factory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapipostprocess_factory_h 18 | #define vaapipostprocess_factory_h 19 | 20 | #include "common/factory.h" 21 | #include "VideoPostProcessInterface.h" 22 | 23 | namespace YamiMediaCodec { 24 | 25 | typedef Factory VaapiPostProcessFactory; 26 | 27 | } // namespace YamiMediaCodec 28 | #endif // vaapipostprocess_factory_h 29 | -------------------------------------------------------------------------------- /vpp/vaapivpppicture.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifdef HAVE_CONFIG_H 17 | #include "config.h" 18 | #endif 19 | #include "vaapivpppicture.h" 20 | #include "common/log.h" 21 | 22 | namespace YamiMediaCodec{ 23 | VaapiVppPicture::VaapiVppPicture(const ContextPtr& context, 24 | const SurfacePtr & surface) 25 | :VaapiPicture(context, surface, 0) 26 | { 27 | } 28 | 29 | bool VaapiVppPicture::editVppParam(VAProcPipelineParameterBuffer*& vppParm) 30 | { 31 | return editObject(m_vppParam, VAProcPipelineParameterBufferType, vppParm); 32 | } 33 | 34 | bool VaapiVppPicture::process() 35 | { 36 | return render(); 37 | } 38 | 39 | bool VaapiVppPicture::doRender() 40 | { 41 | RENDER_OBJECT(m_vppParam); 42 | return true; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /vpp/vaapivpppicture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Intel Corporation. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef vaapivpppicture_h 18 | #define vaapivpppicture_h 19 | 20 | #include "vaapi/vaapipicture.h" 21 | #include 22 | 23 | namespace YamiMediaCodec{ 24 | 25 | class VaapiVppPicture:public VaapiPicture { 26 | public: 27 | VaapiVppPicture(const ContextPtr& context, 28 | const SurfacePtr & surface); 29 | virtual ~VaapiVppPicture() { } 30 | 31 | bool editVppParam(VAProcPipelineParameterBuffer*&); 32 | 33 | bool process(); 34 | 35 | protected: 36 | bool doRender(); 37 | private: 38 | BufObjectPtr m_vppParam; 39 | DISALLOW_COPY_AND_ASSIGN(VaapiVppPicture); 40 | }; 41 | 42 | } 43 | 44 | #endif /* vaapivpppicture_h */ 45 | --------------------------------------------------------------------------------