diff -Nru libyami-utils-1.2.0/common/v4l2_wrapper.h libyami-utils-1.3.0/common/v4l2_wrapper.h --- libyami-utils-1.2.0/common/v4l2_wrapper.h 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/common/v4l2_wrapper.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2014 Intel Corporation. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#if ANDROID -#else - #if __ENABLE_X11__ - #include - #endif - #include -#endif -#include - -#ifndef v4l2_wrapper_h -#define v4l2_wrapper_h -#ifndef V4L2_EVENT_RESOLUTION_CHANGE - #define V4L2_EVENT_RESOLUTION_CHANGE 5 -#endif - -#ifdef __cplusplus -extern "C" { -#endif -int32_t YamiV4L2_Open(const char* name, int32_t flags); -int32_t YamiV4L2_Close(int32_t fd); -int32_t YamiV4L2_FrameMemoryType(int32_t fd, VideoDataMemoryType memory_type); -int32_t YamiV4L2_Ioctl(int32_t fd, int request, void* arg); -int32_t YamiV4L2_Poll(int32_t fd, bool poll_device, bool* event_pending); -int32_t YamiV4L2_SetDevicePollInterrupt(int32_t fd); -int32_t YamiV4L2_ClearDevicePollInterrupt(int32_t fd); -void* YamiV4L2_Mmap(void* addr, size_t length, - int prot, int flags, int fd, unsigned int offset); -int32_t YamiV4L2_Munmap(void* addr, size_t length); -#if ANDROID -#elif __ENABLE_WAYLAND__ - int32_t YamiV4L2_SetWaylandDisplay(int32_t fd, struct wl_display *wlDisplay); -#else - #if __ENABLE_X11__ - /// it should be called before driver initialization (immediate after _Open()). - int32_t YamiV4L2_SetXDisplay(int32_t fd, Display *x11Display); - #endif - int32_t YamiV4L2_UseEglImage(int fd, EGLDisplay eglDisplay, EGLContext eglContext, unsigned int buffer_index, void* egl_image); - int32_t YamiV4L2_SetDrmFd(int32_t fd, int drm_fd); -#endif -#ifdef __cplusplus -} // extern "C" -#endif - -#endif - diff -Nru libyami-utils-1.2.0/configure.ac libyami-utils-1.3.0/configure.ac --- libyami-utils-1.2.0/configure.ac 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/configure.ac 2017-10-11 04:01:39.000000000 +0000 @@ -256,7 +256,7 @@ []) fi -PKG_CHECK_MODULES([LIBYAMI], [libyami >= 0.4.2]) +PKG_CHECK_MODULES([LIBYAMI], [libyami >= 0.5.2]) AM_CONDITIONAL(ENABLE_MD5, test "x$enable_md5" = "xyes") diff -Nru libyami-utils-1.2.0/debian/changelog libyami-utils-1.3.0/debian/changelog --- libyami-utils-1.2.0/debian/changelog 2017-08-28 22:41:41.000000000 +0000 +++ libyami-utils-1.3.0/debian/changelog 2017-11-06 21:59:05.000000000 +0000 @@ -1,3 +1,13 @@ +libyami-utils (1.3.0-1) unstable; urgency=medium + + * New upstream release. + * debian/control: + - Bump Standard-Version. + - Bump libyami-dev B-D. + * debian/{control,rules}: Enable GLES support. (Closes: #878265) + + -- Sebastian Ramacher Mon, 06 Nov 2017 22:59:05 +0100 + libyami-utils (1.2.0-1) unstable; urgency=medium * New upstream release. diff -Nru libyami-utils-1.2.0/debian/control libyami-utils-1.3.0/debian/control --- libyami-utils-1.2.0/debian/control 2017-08-28 18:26:16.000000000 +0000 +++ libyami-utils-1.3.0/debian/control 2017-11-06 21:57:45.000000000 +0000 @@ -9,12 +9,14 @@ libavformat-dev, libavutil-dev, libbsd-dev, + libegl1-mesa-dev, + libgles2-mesa-dev, libva-dev, libwayland-dev, libx11-dev, - libyami-dev (>= 1.2.0), + libyami-dev (>= 1.3.0), pkg-config -Standards-Version: 4.1.0 +Standards-Version: 4.1.1 Homepage: https://github.com/01org/libyami-utils Vcs-Git: https://anonscm.debian.org/git/pkg-multimedia/libyami-utils.git Vcs-Browser: https://anonscm.debian.org/cgit/pkg-multimedia/libyami-utils.git diff -Nru libyami-utils-1.2.0/debian/rules libyami-utils-1.3.0/debian/rules --- libyami-utils-1.2.0/debian/rules 2017-01-30 21:05:07.000000000 +0000 +++ libyami-utils-1.3.0/debian/rules 2017-11-06 21:54:30.000000000 +0000 @@ -9,7 +9,7 @@ dh_auto_configure -- \ --enable-wayland \ --enable-avformat \ - --disable-tests-gles + --enable-tests-gles override_dh_install: dh_install diff -Nru libyami-utils-1.2.0/debian/watch libyami-utils-1.3.0/debian/watch --- libyami-utils-1.2.0/debian/watch 2016-11-25 16:52:06.000000000 +0000 +++ libyami-utils-1.3.0/debian/watch 2017-11-06 21:45:22.000000000 +0000 @@ -1,3 +1,2 @@ version=4 -opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%libyami-utils-$1.tar.gz%" \ -https://github.com/01org/libyami-utils/tags (?:.*?/)?(\d[\d.]*)\.tar\.gz +https://github.com/01org/libyami-utils/tags (?:.*?/)?libyami-(\d[\d.]*)\.tar\.gz diff -Nru libyami-utils-1.2.0/tests/decode.cpp libyami-utils-1.3.0/tests/decode.cpp --- libyami-utils-1.2.0/tests/decode.cpp 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/decode.cpp 2017-10-11 04:01:39.000000000 +0000 @@ -41,8 +41,12 @@ return input; }else{ SharedPtr inputDecode = DynamicPointerCast(input); - if (inputDecode && inputDecode->config(*display)) - return input; + if (inputDecode) { + inputDecode->setTargetLayer(para.temporalLayer); + inputDecode->setLowLatency(para.enableLowLatency); + if (inputDecode->config(*display)) + return input; + } } input.reset(); fprintf(stderr, "VppInputDecode config failed.\n"); @@ -85,6 +89,9 @@ break; } fps.log(); + + possibleWait(m_vppInput->getMimeType(), &m_params); + return true; } diff -Nru libyami-utils-1.2.0/tests/decodehelp.cpp libyami-utils-1.3.0/tests/decodehelp.cpp --- libyami-utils-1.2.0/tests/decodehelp.cpp 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/decodehelp.cpp 2017-10-11 04:01:39.000000000 +0000 @@ -52,6 +52,10 @@ printf(" 6: use external dma buf for decode and display, only v4l2decode support this\n"); printf(" [*] v4l2decode doesn't support the option\n"); printf(" --capi: use the codec capi to encode or decode, default(false)\n"); + printf(" --temporal-layer: decode SVC-T stream up to given layer, default 0, only vp8 support\n"); + printf(" 0: decode all layers\n"); + printf(" N>0: decode the first N layers\n"); + printf(" --lowlatency: if set this flag to true, AVC decoder will output the ready frames ASAP\n"); } bool processCmdLine(int argc, char** argv, DecodeParameter* parameters) @@ -64,11 +68,18 @@ parameters->renderMode = 1; parameters->inputFile = NULL; parameters->useCAPI = false; + parameters->temporalLayer = 0; + parameters->spacialLayer = 0; + parameters->qualityLayer = 0; + parameters->enableLowLatency = false; const struct option long_opts[] = { - {"help", no_argument, NULL, 'h'}, - {"capi", no_argument, NULL, 0}, - {NULL, no_argument, NULL, 0}}; + { "help", no_argument, NULL, 'h' }, + { "capi", no_argument, NULL, 0 }, + { "temporal-layer", required_argument, NULL, 0 }, + { "lowlatency", no_argument, 0, 0 }, + { NULL, no_argument, NULL, 0 } + }; char opt; while ((opt = getopt_long_only(argc, argv, "h:m:n:i:f:o:w:?", long_opts,&option_index)) != -1){ @@ -107,6 +118,12 @@ case 1: parameters->useCAPI = true; break; + case 2: + parameters->temporalLayer = atoi(optarg); + break; + case 3: + parameters->enableLowLatency = true; + break; default: printHelp(argv[0]); break; diff -Nru libyami-utils-1.2.0/tests/decodehelp.h libyami-utils-1.3.0/tests/decodehelp.h --- libyami-utils-1.2.0/tests/decodehelp.h 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/decodehelp.h 2017-10-11 04:01:39.000000000 +0000 @@ -29,7 +29,13 @@ uint32_t renderFourcc; std::string outputFile; bool useCAPI; -} DecodeParameter; + uint32_t temporalLayer; + uint32_t spacialLayer; + uint32_t qualityLayer; + + //if set this flag to true, AVC decoder will output the ready frames ASAP. + bool enableLowLatency; +} StreamParameter; bool processCmdLine(int argc, char** argv, DecodeParameter* parameters); diff -Nru libyami-utils-1.2.0/tests/decodeoutput.cpp libyami-utils-1.3.0/tests/decodeoutput.cpp --- libyami-utils-1.2.0/tests/decodeoutput.cpp 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/decodeoutput.cpp 2017-10-11 04:01:39.000000000 +0000 @@ -337,6 +337,7 @@ public: DecodeOutputMD5(const char* outputFile, const char* inputFile, uint32_t fourcc) : DecodeOutputFile(outputFile, inputFile, fourcc) + , m_file(NULL) { } virtual ~DecodeOutputMD5(); @@ -465,11 +466,20 @@ DefaultScreen(m_display); XSetWindowAttributes x11WindowAttrib; - x11WindowAttrib.event_mask = KeyPressMask; + x11WindowAttrib.event_mask = ExposureMask; m_window = XCreateWindow(m_display, DefaultRootWindow(m_display), 0, 0, width, height, 0, CopyFromParent, InputOutput, CopyFromParent, CWEventMask, &x11WindowAttrib); XMapWindow(m_display, m_window); + + // If we allow vaPutSurface to be called before the window is exposed + // then those frames will not get displayed on the window. Thus, wait + // for the Expose event from X before we return. + XEvent e; + while(true) { + XNextEvent(m_display, &e); + if (e.type == Expose) break; + } } XSync(m_display, false); { diff -Nru libyami-utils-1.2.0/tests/v4l2decode.cpp libyami-utils-1.3.0/tests/v4l2decode.cpp --- libyami-utils-1.2.0/tests/v4l2decode.cpp 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/v4l2decode.cpp 2017-10-11 04:01:39.000000000 +0000 @@ -120,8 +120,10 @@ } -bool handleResolutionChange(const SharedPtr& device) +bool handleResolutionChange(const SharedPtr& device, + const SharedPtr& renderer) { + DEBUG("+handle resolution change"); bool resolutionChanged = false; // check resolution change struct v4l2_event ev; @@ -133,24 +135,14 @@ break; } } - - if (!resolutionChanged) - return false; - - struct v4l2_format format; - memset(&format, 0, sizeof(format)); - format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; - if (device->ioctl(VIDIOC_G_FMT, &format) == -1) { + if (!resolutionChanged) { + WARNING("no resolution change"); return false; } - // resolution and pixelformat got here - outputPlaneCount = format.fmt.pix_mp.num_planes; - ASSERT(outputPlaneCount == 2); - videoWidth = format.fmt.pix_mp.width; - videoHeight = format.fmt.pix_mp.height; - - return true; + bool ret = renderer->onFormatChanged(); + ERROR("-handle resolution change"); + return ret; } extern uint32_t v4l2PixelFormatFromMime(const char* mime); @@ -329,16 +321,17 @@ type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; ioctlRet = device->ioctl(VIDIOC_STREAMON, &type); ASSERT(ioctlRet != -1); -//#define SEEK_POS 500 +//#define SEEK_POS 1300 #ifdef SEEK_POS uint32_t frames = 0; + uint32_t seekPos = rand() % SEEK_POS; #endif bool event_pending=true; // try to get video resolution. uint32_t dqCountAfterEOS = 0; do { if (event_pending) { - handleResolutionChange(device); + handleResolutionChange(device, renderer); } renderer->renderOneFrame(); @@ -352,7 +345,10 @@ #ifdef SEEK_POS frames++; - if (frames == SEEK_POS) { + if (frames == seekPos) { + ERROR("Seek from %d to pos 0", seekPos); + frames = 0; + seekPos = rand() % SEEK_POS; input.reset(DecodeInput::create(params.inputFile)); if (!input) { ERROR("fail to init input stream\n"); diff -Nru libyami-utils-1.2.0/tests/V4L2Device.cpp libyami-utils-1.3.0/tests/V4L2Device.cpp --- libyami-utils-1.2.0/tests/V4L2Device.cpp 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/V4L2Device.cpp 2017-10-11 04:01:39.000000000 +0000 @@ -210,7 +210,7 @@ #else -#include "common/v4l2_wrapper.h" +#include class V4L2DeviceYami : public V4L2Device { public: diff -Nru libyami-utils-1.2.0/tests/v4l2encode.cpp libyami-utils-1.3.0/tests/v4l2encode.cpp --- libyami-utils-1.2.0/tests/v4l2encode.cpp 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/v4l2encode.cpp 2017-10-11 04:01:39.000000000 +0000 @@ -24,10 +24,10 @@ #include #include #include +#include #include "common/log.h" #include "common/utils.h" -#include "common/v4l2_wrapper.h" #include "encodehelp.h" #include "encodeinput.h" diff -Nru libyami-utils-1.2.0/tests/V4L2Renderer.cpp libyami-utils-1.3.0/tests/V4L2Renderer.cpp --- libyami-utils-1.2.0/tests/V4L2Renderer.cpp 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/V4L2Renderer.cpp 2017-10-11 04:01:39.000000000 +0000 @@ -39,6 +39,9 @@ V4L2Renderer::V4L2Renderer(const SharedPtr& device, VideoDataMemoryType memoryType) : m_device(device) , m_memoryType(memoryType) + , m_dpbSize(0) + , m_width(0) + , m_height(0) { } @@ -118,11 +121,76 @@ reqbufs.count = count; int32_t ioctlRet = m_device->ioctl(VIDIOC_REQBUFS, &reqbufs); ASSERT(ioctlRet != -1); - ASSERT(reqbufs.count > 0); + ASSERT(reqbufs.count >= 0); count = reqbufs.count; return true; } +void V4L2Renderer::streamOff(bool off) +{ + uint32_t type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + int32_t cmd = off ? VIDIOC_STREAMOFF : VIDIOC_STREAMON; + int32_t ret = m_device->ioctl(cmd, &type); + ASSERT(ret != -1); +} + +bool V4L2Renderer::getSurfaceGeometry(uint32_t& width, uint32_t& height, uint32_t& dpbSize) +{ + struct v4l2_format format; + memset(&format, 0, sizeof(format)); + format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + if (m_device->ioctl(VIDIOC_G_FMT, &format) == -1) { + ERROR("get format failed"); + return false; + } + if (!getDpbSize(dpbSize)) { + ERROR("get DPB size failed"); + return false; + } + width = format.fmt.pix_mp.width; + height = format.fmt.pix_mp.height; + return true; +} + +bool V4L2Renderer::onFormatChanged() +{ + DEBUG("onFormatChanged"); + //drain output; + while (renderOneFrame()) { + //no thing + } + + uint32_t width, height, dpbSize; + + if (!getSurfaceGeometry(width, height, dpbSize)) { + ERROR("failed to get geometry"); + return false; + } + if (m_width == width + && m_height == height + && m_dpbSize == dpbSize) { + ERROR("report format change but actually no, %dx%d, dpbSize = %d", + m_width, m_height, dpbSize); + return true; + } + if (m_width != width + || m_height != height) { + ERROR("resize window from %dx%d to %dx%d", + m_width, m_height, width, height); + resizeWindow(width, height); + } + //real foramt changes + streamOff(true); + destroyOutputBuffers(); + uint32_t size = 0; + requestBuffers(size); + setupOutputBuffers(width, height, dpbSize); + m_width = width; + m_height = height; + streamOff(false); + return true; +} + #ifdef __ENABLE_X11__ #include class X11Renderer : public V4L2Renderer { @@ -161,6 +229,14 @@ if (m_x11Window <= 0) return false; XMapWindow(m_x11Display, m_x11Window); + m_width = width; + m_height = height; + return true; + } + bool resizeWindow(uint32_t width, uint32_t height) + { + XResizeWindow(m_x11Display, m_x11Window, width, height); + XSync(m_x11Display, false); return true; } Display* m_x11Display; @@ -195,17 +271,19 @@ return true; } - bool setupOutputBuffers(uint32_t width, uint32_t height) + bool setupOutputBuffers(uint32_t width, uint32_t height, uint32_t dpbSize) { if (!createWindow(width, height)) { ERROR("Create window failed"); return false; } - uint32_t dpbSize; - if (!getDpbSize(dpbSize)) { - ERROR("get dpb size failed"); - return false; + if (!dpbSize) { + if (!getDpbSize(dpbSize)) { + ERROR("get dpb size failed"); + return false; + } } + m_dpbSize = dpbSize; uint32_t count = dpbSize + kExtraOutputFrameCount + kFrontSize; if (!requestBuffers(count)) { ERROR("requestBuffers failed"); @@ -213,7 +291,7 @@ } m_width = width; m_height = height; - return setupOutputBuffers(width, height, count) && queueOutputBuffersAtStart(count); + return createOutputBuffers(width, height, count) && queueOutputBuffersAtStart(count); } bool queueOutputBuffersAtStart(uint32_t count) @@ -247,9 +325,7 @@ } virtual ~ExternalDmaBufRenderer() { - if (m_surfaces.size()) { - vaDestroySurfaces(m_display->getID(), &m_surfaces[0], m_surfaces.size()); - } + destroyOutputBuffers(); } private: @@ -293,7 +369,7 @@ checkVaapiStatus(vaDestroyImage(m_display->getID(), image.image_id), "vaDestroyImage"); return ioctlRet != -1; } - bool setupOutputBuffers(uint32_t width, uint32_t height, uint32_t count) + bool createOutputBuffers(uint32_t width, uint32_t height, uint32_t count) { m_surfaces.resize(count); @@ -317,6 +393,18 @@ } return true; } + + void destroyOutputBuffers() + { + if (m_surfaces.size()) { + vaDestroySurfaces(m_display->getID(), &m_surfaces[0], m_surfaces.size()); + } + m_surfaces.clear(); + m_dmabuf.clear(); + m_images.clear(); + m_front.clear(); + } + void addAndPopFront(uint32_t& index) { m_front.push_back(index); @@ -356,17 +444,19 @@ , m_eglContext(NULL) { } - bool setupOutputBuffers(uint32_t width, uint32_t height) + bool setupOutputBuffers(uint32_t width, uint32_t height, uint32_t dpbSize) { if (!createWindow(width, height)) { ERROR("Create window failed"); return false; } - uint32_t dpbSize; - if (!getDpbSize(dpbSize)) { - ERROR("get dpb size failed"); - return false; + if (!dpbSize) { + if (!getDpbSize(dpbSize)) { + ERROR("get dpb size failed"); + return false; + } } + m_dpbSize = dpbSize; uint32_t count = dpbSize + kExtraOutputFrameCount; if (!requestBuffers(count)) { ERROR("requestBuffers failed"); @@ -374,6 +464,18 @@ } return setupOutputBuffers(count) && queueOutputBuffersAtStart(count); } + + void destroyOutputBuffers() + { + if (m_textureIds.size()) + glDeleteTextures(m_textureIds.size(), &m_textureIds[0]); + m_textureIds.clear(); + ASSERT(glGetError() == GL_NO_ERROR); + for (size_t i = 0; i < m_eglImages.size(); i++) { + destroyImage(m_eglContext->eglContext.display, m_eglImages[i]); + } + m_eglImages.clear(); + } bool render(uint32_t& idx) { const uint32_t index = idx; @@ -389,12 +491,7 @@ } virtual ~EglRenderer() { - if (m_textureIds.size()) - glDeleteTextures(m_textureIds.size(), &m_textureIds[0]); - ASSERT(glGetError() == GL_NO_ERROR); - for (size_t i = 0; i < m_eglImages.size(); i++) { - destroyImage(m_eglContext->eglContext.display, m_eglImages[i]); - } + destroyOutputBuffers(); /* there is still randomly fail in mesa; no good idea for it. seems mesa bug 0 0x00007ffff079c343 in _mesa_symbol_table_dtor () from /usr/lib/x86_64-linux-gnu/libdricore9.2.1.so.1 diff -Nru libyami-utils-1.2.0/tests/V4L2Renderer.h libyami-utils-1.3.0/tests/V4L2Renderer.h --- libyami-utils-1.2.0/tests/V4L2Renderer.h 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/V4L2Renderer.h 2017-10-11 04:01:39.000000000 +0000 @@ -22,9 +22,10 @@ public: static SharedPtr create(const SharedPtr&, VideoDataMemoryType memoryType); virtual bool setDisplay() = 0; - virtual bool setupOutputBuffers(uint32_t wdith, uint32_t height) = 0; + virtual bool setupOutputBuffers(uint32_t wdith, uint32_t height, uint32_t dpbSize = 0) = 0; bool renderOneFrame(); virtual bool queueOutputBuffers() = 0; + bool onFormatChanged(); protected: V4L2Renderer(const SharedPtr&, VideoDataMemoryType memoryType); @@ -35,7 +36,16 @@ bool dequeBuffer(uint32_t& index); virtual bool render(uint32_t& index) = 0; virtual bool queueOutputBuffersAtStart(uint32_t count) = 0; + virtual bool resizeWindow(uint32_t width, uint32_t height) = 0; + virtual void destroyOutputBuffers() = 0; SharedPtr m_device; VideoDataMemoryType m_memoryType; + uint32_t m_dpbSize; + uint32_t m_width; + uint32_t m_height; + +private: + void streamOff(bool off); + bool getSurfaceGeometry(uint32_t& width, uint32_t& height, uint32_t& dpbSize); }; diff -Nru libyami-utils-1.2.0/tests/vppinputasync.h libyami-utils-1.3.0/tests/vppinputasync.h --- libyami-utils-1.2.0/tests/vppinputasync.h 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/vppinputasync.h 2017-10-11 04:01:39.000000000 +0000 @@ -37,6 +37,8 @@ virtual int getHeight() { return m_input->getHeight(); } virtual uint32_t getFourcc() { return m_input->getFourcc(); } + const char *getMimeType() const { return m_input->getMimeType(); } + //do not use this bool init(const char* inputFileName, uint32_t fourcc, int width, int height); private: diff -Nru libyami-utils-1.2.0/tests/vppinputdecodecapi.h libyami-utils-1.3.0/tests/vppinputdecodecapi.h --- libyami-utils-1.2.0/tests/vppinputdecodecapi.h 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/vppinputdecodecapi.h 2017-10-11 04:01:39.000000000 +0000 @@ -32,6 +32,7 @@ bool init(const char* inputFileName, uint32_t fourcc = 0, int width = 0, int height = 0); bool read(SharedPtr& frame); + const char *getMimeType() const { return m_input->getMimeType(); } bool config(NativeDisplay& nativeDisplay); private: diff -Nru libyami-utils-1.2.0/tests/vppinputdecode.cpp libyami-utils-1.3.0/tests/vppinputdecode.cpp --- libyami-utils-1.2.0/tests/vppinputdecode.cpp 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/vppinputdecode.cpp 2017-10-11 04:01:39.000000000 +0000 @@ -42,6 +42,8 @@ } configBuffer.width = m_input->getWidth(); configBuffer.height = m_input->getHeight(); + configBuffer.temporalLayer = m_temporalLayer; + configBuffer.enableLowLatency = m_enableLowLatency; Decode_Status status = m_decoder->start(&configBuffer); if (status == DECODE_SUCCESS) { //read first frame to update width height diff -Nru libyami-utils-1.2.0/tests/vppinputdecode.h libyami-utils-1.3.0/tests/vppinputdecode.h --- libyami-utils-1.2.0/tests/vppinputdecode.h 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/vppinputdecode.h 2017-10-11 04:01:39.000000000 +0000 @@ -30,8 +30,19 @@ } bool init(const char* inputFileName, uint32_t fourcc = 0, int width = 0, int height = 0); bool read(SharedPtr& frame); + const char *getMimeType() const { return m_input->getMimeType(); } bool config(NativeDisplay& nativeDisplay); + void setTargetLayer(uint32_t temporal = 0, uint32_t spacial = 0, uint32_t quality = 0) + { + m_temporalLayer = temporal; + m_spacialLayer = spacial; + m_qualityLayer = quality; + } + void setLowLatency(bool lowLatency = false) + { + m_enableLowLatency = lowLatency; + } virtual ~VppInputDecode() {} private: bool m_eos; @@ -39,6 +50,13 @@ SharedPtr m_decoder; SharedPtr m_input; SharedPtr m_first; + //m_xxxLayer layer number, 0: decode all layers, >0: decode up to target layer. + uint32_t m_temporalLayer; + uint32_t m_spacialLayer; + uint32_t m_qualityLayer; + + //if set this flag to true, AVC decoder will output the ready frames ASAP. + bool m_enableLowLatency; }; #endif //vppinputdecode_h diff -Nru libyami-utils-1.2.0/tests/vppinputoutput.h libyami-utils-1.3.0/tests/vppinputoutput.h --- libyami-utils-1.2.0/tests/vppinputoutput.h 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/vppinputoutput.h 2017-10-11 04:01:39.000000000 +0000 @@ -179,6 +179,7 @@ create(const char* inputFileName, uint32_t fourcc = 0, int width = 0, int height = 0, bool useCAPI = false); virtual bool init(const char* inputFileName = 0, uint32_t fourcc = 0, int width = 0, int height = 0) = 0; virtual bool read(SharedPtr& frame) = 0; + virtual const char * getMimeType() const = 0; virtual int getWidth() { return m_width; } virtual int getHeight() { return m_height; } virtual uint32_t getFourcc() { return m_fourcc; } @@ -195,7 +196,7 @@ //inherit VppInput bool init(const char* inputFileName, uint32_t fourcc, int width, int height); virtual bool read(SharedPtr& frame); - + const char *getMimeType() const { return "unknown"; } bool config(const SharedPtr& allocator, const SharedPtr& reader); VppInputFile(); ~VppInputFile(); diff -Nru libyami-utils-1.2.0/tests/vppoutputencode.cpp libyami-utils-1.3.0/tests/vppoutputencode.cpp --- libyami-utils-1.2.0/tests/vppoutputencode.cpp 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/vppoutputencode.cpp 2017-10-11 04:01:39.000000000 +0000 @@ -120,8 +120,17 @@ else encVideoParams.bitDepth = 8; - memcpy(encVideoParams.rcParams.layerBitRate, encParam->layerBitRate, - sizeof(encParam->layerBitRate)); + if (VA_RC_CQP == encVideoParams.rcMode) //for CQP mode + encVideoParams.temporalLayers.numLayersMinus1 = encParam->temporalLayerNum - 1; + else { //for CBR or VBR mode + uint32_t i = 0; + for (i = 0; i < TEMPORAL_LAYER_LENGTH_MAX; i++) { + if (!encParam->layerBitRate[i]) + break; + encVideoParams.temporalLayers.bitRate[i] = encParam->layerBitRate[i]; + } + encVideoParams.temporalLayers.numLayersMinus1 = i; + } encVideoParams.size = sizeof(VideoParamsCommon); encoder->setParameters(VideoParamsTypeCommon, &encVideoParams); @@ -165,7 +174,6 @@ "0.2.1", "or enableCabac, enableDct8x8 and enableDeblockFilter " "will use the default value"); #endif - encVideoParamsAVC.temporalLayerNum = encParam->temporalLayerNum; encVideoParamsAVC.priorityId = encParam->priorityId; encoder->setParameters(VideoParamsTypeAVC, &encVideoParamsAVC); diff -Nru libyami-utils-1.2.0/tests/vppoutputencode.h libyami-utils-1.3.0/tests/vppoutputencode.h --- libyami-utils-1.2.0/tests/vppoutputencode.h 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/vppoutputencode.h 2017-10-11 04:01:39.000000000 +0000 @@ -51,7 +51,7 @@ uint32_t temporalLayerNum; // svc-t temporal layer number uint32_t priorityId; // h264 priority_id in prefix nal unit EncodeParamsVP9 m_encParamsVP9; - uint32_t layerBitRate[4]; // specify each scalable layer bitrate + uint32_t layerBitRate[TEMPORAL_LAYER_LENGTH_MAX]; // specify each scalable layer bitrate bool enableLowPower; uint32_t targetPercentage; uint32_t windowSize; // use for HRD CPB length in ms diff -Nru libyami-utils-1.2.0/tests/yamitranscode.cpp libyami-utils-1.3.0/tests/yamitranscode.cpp --- libyami-utils-1.2.0/tests/yamitranscode.cpp 2017-04-06 08:26:43.000000000 +0000 +++ libyami-utils-1.3.0/tests/yamitranscode.cpp 2017-10-11 04:01:39.000000000 +0000 @@ -41,7 +41,8 @@ printf(" -c \n"); printf(" -s \n"); printf(" -N \n"); - printf(" -t optional\n"); + printf(" -t optional\n"); printf(" --qp optional\n"); printf(" --rcmode optional\n"); printf(" --target-percnetage optional\n"); @@ -62,10 +63,6 @@ printf(" --priorityid optional\n"); printf(" --ow optional\n"); printf(" --oh optional\n"); - printf(" --btl0 optional\n"); - printf(" --btl1 optional\n"); - printf(" --btl2 optional\n"); - printf(" --btl3 optional\n"); printf(" --lowpower optional\n"); printf(" --quality-level optional\n", VIDEO_PARAMS_QUALITYLEVEL_NONE, VIDEO_PARAMS_QUALITYLEVEL_MAX); @@ -73,6 +70,12 @@ printf(" --refmode optional\n"); + printf(" VP8/AVC SVC-T bitrate settings, the highest layer bitrate is set via \"-b\"; the other lower \n"); + printf(" layer bitrates are set via the following parameters:\n"); + printf(" --btl0 optional\n"); + printf(" --btl1 optional\n"); + printf(" --btl2 optional\n"); + printf(" --btl3 optional\n"); } static VideoRateControl string_to_rc_mode(char *str) @@ -285,6 +288,10 @@ return false; } + if ((para.m_encParams.rcMode == RATE_CONTROL_CQP) && (para.m_encParams.bitRate > 0)) { + para.m_encParams.rcMode = RATE_CONTROL_CBR; + } + if (!strncmp(para.inputFileName.c_str(), "/dev/video", strlen("/dev/video")) && !para.frameCount) para.frameCount = 50;