Remove OMX
The API has been abandoned for some time now and there are no more users. FFmpeg only supports encoding, but it never worked with Mesa. GStreamer completely removed OMX support in 1.24 release. Acked-by: Leo Liu <leo.liu@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30865>
This commit is contained in:
91
meson.build
91
meson.build
@@ -642,85 +642,6 @@ if prog_glslang.found()
|
||||
endif
|
||||
endif
|
||||
|
||||
dep_xv = null_dep
|
||||
_omx = get_option('gallium-omx')
|
||||
if not system_has_kms_drm
|
||||
if ['auto', 'disabled'].contains(_omx)
|
||||
_omx = 'disabled'
|
||||
else
|
||||
error('OMX state tracker can only be built on unix-like OSes.')
|
||||
endif
|
||||
elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
|
||||
if ['auto', 'disabled'].contains(_omx)
|
||||
_omx = 'disabled'
|
||||
else
|
||||
error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
|
||||
endif
|
||||
endif
|
||||
with_gallium_omx = _omx
|
||||
dep_omx = null_dep
|
||||
dep_omx_other = []
|
||||
if ['auto', 'bellagio'].contains(_omx)
|
||||
dep_omx = dependency(
|
||||
'libomxil-bellagio', required : _omx == 'bellagio'
|
||||
)
|
||||
if dep_omx.found()
|
||||
with_gallium_omx = 'bellagio'
|
||||
endif
|
||||
endif
|
||||
if ['auto', 'tizonia'].contains(_omx)
|
||||
if with_dri and with_egl
|
||||
dep_omx = dependency(
|
||||
'libtizonia', version : '>= 0.10.0',
|
||||
required : _omx == 'tizonia',
|
||||
)
|
||||
dep_omx_other = [
|
||||
dependency('libtizplatform', required : _omx == 'tizonia'),
|
||||
dependency('tizilheaders', required : _omx == 'tizonia'),
|
||||
]
|
||||
if dep_omx.found() and dep_omx_other[0].found() and dep_omx_other[1].found()
|
||||
with_gallium_omx = 'tizonia'
|
||||
endif
|
||||
elif _omx == 'tizonia'
|
||||
error('OMX-Tizonia state tracker requires dri and egl')
|
||||
endif
|
||||
endif
|
||||
if _omx == 'auto'
|
||||
with_gallium_omx = 'disabled'
|
||||
else
|
||||
with_gallium_omx = _omx
|
||||
endif
|
||||
|
||||
pre_args += '-DENABLE_ST_OMX_BELLAGIO=@0@'.format((with_gallium_omx == 'bellagio').to_int())
|
||||
pre_args += '-DENABLE_ST_OMX_TIZONIA=@0@'.format((with_gallium_omx == 'tizonia').to_int())
|
||||
|
||||
|
||||
omx_drivers_path = get_option('omx-libs-path')
|
||||
|
||||
if with_gallium_omx != 'disabled'
|
||||
# Figure out where to put the omx driver.
|
||||
# FIXME: this could all be vastly simplified by adding a 'defined_variable'
|
||||
# argument to meson's get_variable method.
|
||||
if omx_drivers_path == ''
|
||||
_omx_libdir = dep_omx.get_variable(pkgconfig : 'libdir')
|
||||
_omx_drivers_dir = dep_omx.get_variable(pkgconfig : 'pluginsdir')
|
||||
if _omx_libdir == get_option('libdir')
|
||||
omx_drivers_path = _omx_drivers_dir
|
||||
else
|
||||
_omx_base_dir = []
|
||||
# This will fail on windows. Does OMX run on windows?
|
||||
_omx_libdir = _omx_libdir.split('/')
|
||||
_omx_drivers_dir = _omx_drivers_dir.split('/')
|
||||
foreach o : _omx_drivers_dir
|
||||
if not _omx_libdir.contains(o)
|
||||
_omx_base_dir += o
|
||||
endif
|
||||
endforeach
|
||||
omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
_va_drivers = [
|
||||
with_gallium_d3d12_video,
|
||||
with_gallium_nouveau,
|
||||
@@ -2164,8 +2085,7 @@ if with_platform_x11
|
||||
dep_x11 = dependency('x11')
|
||||
endif
|
||||
if (with_any_vk or with_glx == 'dri' or with_egl or
|
||||
(with_gallium_vdpau or with_gallium_va or
|
||||
with_gallium_omx != 'disabled'))
|
||||
(with_gallium_vdpau or with_gallium_va))
|
||||
dep_xcb = dependency('xcb')
|
||||
dep_xcb_keysyms = dependency('xcb-keysyms', required : false)
|
||||
with_xcb_keysyms = dep_xcb_keysyms.found()
|
||||
@@ -2205,8 +2125,7 @@ if with_platform_x11
|
||||
endif
|
||||
if (with_egl or
|
||||
with_any_vk or
|
||||
with_gallium_vdpau or with_gallium_xa or
|
||||
with_gallium_omx != 'disabled')
|
||||
with_gallium_vdpau or with_gallium_xa)
|
||||
dep_xcb_xfixes = dependency('xcb-xfixes')
|
||||
endif
|
||||
if with_xlib_lease or with_any_vk
|
||||
@@ -2437,9 +2356,6 @@ endif
|
||||
if with_gallium_xa
|
||||
video_apis += 'xa'
|
||||
endif
|
||||
if with_gallium_omx != 'disabled'
|
||||
video_apis += 'omx'
|
||||
endif
|
||||
video_summary += {'APIs': video_apis.length() != 0 ? video_apis : false}
|
||||
summary(video_summary, section: 'Video', bool_yn: true, list_sep: ' ')
|
||||
|
||||
@@ -2461,9 +2377,6 @@ if with_gallium
|
||||
if with_gallium_vdpau
|
||||
gallium_frontends += 'vdpau'
|
||||
endif
|
||||
if with_gallium_omx != 'disabled'
|
||||
gallium_frontends += 'omx' + with_gallium_omx
|
||||
endif
|
||||
if with_gallium_va
|
||||
gallium_frontends += 'va'
|
||||
endif
|
||||
|
||||
@@ -118,22 +118,6 @@ option(
|
||||
description : 'path to put vdpau libraries. defaults to $libdir/vdpau.'
|
||||
)
|
||||
|
||||
option(
|
||||
'gallium-omx',
|
||||
type : 'combo',
|
||||
value : 'auto',
|
||||
choices : ['auto', 'disabled', 'bellagio', 'tizonia'],
|
||||
description : 'enable gallium omx frontend.',
|
||||
)
|
||||
|
||||
option(
|
||||
'omx-libs-path',
|
||||
type : 'string',
|
||||
value : '',
|
||||
description : 'path to put omx libraries. defaults to omx-bellagio ' +
|
||||
'pkg-config pluginsdir.'
|
||||
)
|
||||
|
||||
option(
|
||||
'gallium-va',
|
||||
type : 'feature',
|
||||
|
||||
@@ -562,8 +562,7 @@ libgalliumvl = static_library(
|
||||
|
||||
# some drivers export their screen creation function globally, so all frontends have to contain the
|
||||
# full libgalliumvl. So we'll handle this here globally for everybody.
|
||||
if (with_gallium_va or with_gallium_vdpau or with_gallium_omx != 'disabled' or
|
||||
with_dri or with_gallium_radeonsi)
|
||||
if (with_gallium_va or with_gallium_vdpau or with_dri or with_gallium_radeonsi)
|
||||
libgalliumvl_stub = libgalliumvl
|
||||
else
|
||||
libgalliumvl_stub = _libgalliumvl_stub
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Christian König <christian.koenig@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "entrypoint.h"
|
||||
#include "vid_dec.h"
|
||||
#include "vid_enc.h"
|
||||
|
||||
int omx_component_library_Setup(stLoaderComponentType **stComponents)
|
||||
{
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
if (stComponents == NULL)
|
||||
return 2;
|
||||
|
||||
/* component 0 - video decoder */
|
||||
r = vid_dec_LoaderComponent(stComponents[0]);
|
||||
if (r != OMX_ErrorNone)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
/* component 1 - video encoder */
|
||||
r = vid_enc_LoaderComponent(stComponents[1]);
|
||||
if (r != OMX_ErrorNone)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
OMX_ERRORTYPE omx_workaround_Destructor(OMX_COMPONENTTYPE *comp)
|
||||
{
|
||||
omx_base_component_PrivateType* priv = (omx_base_component_PrivateType*)comp->pComponentPrivate;
|
||||
|
||||
priv->state = OMX_StateInvalid;
|
||||
tsem_up(priv->messageSem);
|
||||
|
||||
/* wait for thread to exit */
|
||||
pthread_join(priv->messageHandlerThread, NULL);
|
||||
|
||||
return omx_base_component_Destructor(comp);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Christian König <christian.koenig@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef OMX_ENTRYPOINT_H
|
||||
#define OMX_ENTRYPOINT_H
|
||||
|
||||
#include <bellagio/st_static_component_loader.h>
|
||||
|
||||
#include "vl/vl_winsys.h"
|
||||
|
||||
PUBLIC extern int omx_component_library_Setup(stLoaderComponentType **stComponents);
|
||||
|
||||
OMX_ERRORTYPE omx_workaround_Destructor(OMX_COMPONENTTYPE *comp);
|
||||
|
||||
#endif
|
||||
@@ -1,550 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Christian König <christian.koenig@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <OMX_Video.h>
|
||||
|
||||
#include <bellagio/omxcore.h>
|
||||
|
||||
#include "pipe/p_screen.h"
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_surface.h"
|
||||
#include "vl/vl_video_buffer.h"
|
||||
#include "util/vl_vlc.h"
|
||||
|
||||
#include "vl/vl_codec.h"
|
||||
|
||||
#include "entrypoint.h"
|
||||
#include "vid_dec.h"
|
||||
#include "vid_omx_common.h"
|
||||
#include "vid_dec_h264_common.h"
|
||||
|
||||
static OMX_ERRORTYPE vid_dec_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING name);
|
||||
static OMX_ERRORTYPE vid_dec_Destructor(OMX_COMPONENTTYPE *comp);
|
||||
static OMX_ERRORTYPE vid_dec_SetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param);
|
||||
static OMX_ERRORTYPE vid_dec_GetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param);
|
||||
static OMX_ERRORTYPE vid_dec_MessageHandler(OMX_COMPONENTTYPE *comp, internalRequestMessageType *msg);
|
||||
static OMX_ERRORTYPE vid_dec_DecodeBuffer(omx_base_PortType *port, OMX_BUFFERHEADERTYPE *buf);
|
||||
static OMX_ERRORTYPE vid_dec_FreeDecBuffer(omx_base_PortType *port, OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf);
|
||||
static void vid_dec_FrameDecoded(OMX_COMPONENTTYPE *comp, OMX_BUFFERHEADERTYPE* input, OMX_BUFFERHEADERTYPE* output);
|
||||
|
||||
OMX_ERRORTYPE vid_dec_LoaderComponent(stLoaderComponentType *comp)
|
||||
{
|
||||
comp->componentVersion.s.nVersionMajor = 0;
|
||||
comp->componentVersion.s.nVersionMinor = 0;
|
||||
comp->componentVersion.s.nRevision = 0;
|
||||
comp->componentVersion.s.nStep = 1;
|
||||
comp->name_specific_length = 4;
|
||||
|
||||
comp->name = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->name == NULL)
|
||||
goto error;
|
||||
|
||||
comp->name_specific = CALLOC(comp->name_specific_length, sizeof(char *));
|
||||
if (comp->name_specific == NULL)
|
||||
goto error;
|
||||
|
||||
comp->role_specific = CALLOC(comp->name_specific_length, sizeof(char *));
|
||||
if (comp->role_specific == NULL)
|
||||
goto error;
|
||||
|
||||
comp->name_specific[0] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->name_specific[0] == NULL)
|
||||
goto error_specific;
|
||||
|
||||
comp->name_specific[1] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->name_specific[1] == NULL)
|
||||
goto error_specific;
|
||||
|
||||
comp->name_specific[2] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->name_specific[2] == NULL)
|
||||
goto error_specific;
|
||||
|
||||
comp->name_specific[3] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->name_specific[3] == NULL)
|
||||
goto error_specific;
|
||||
|
||||
comp->role_specific[0] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->role_specific[0] == NULL)
|
||||
goto error_specific;
|
||||
|
||||
comp->role_specific[1] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->role_specific[1] == NULL)
|
||||
goto error_specific;
|
||||
|
||||
comp->role_specific[2] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->role_specific[2] == NULL)
|
||||
goto error_specific;
|
||||
|
||||
comp->role_specific[3] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->role_specific[3] == NULL)
|
||||
goto error_specific;
|
||||
|
||||
strcpy(comp->name, OMX_VID_DEC_BASE_NAME);
|
||||
strcpy(comp->name_specific[0], OMX_VID_DEC_MPEG2_NAME);
|
||||
strcpy(comp->name_specific[1], OMX_VID_DEC_AVC_NAME);
|
||||
strcpy(comp->name_specific[2], OMX_VID_DEC_HEVC_NAME);
|
||||
strcpy(comp->name_specific[3], OMX_VID_DEC_AV1_NAME);
|
||||
|
||||
strcpy(comp->role_specific[0], OMX_VID_DEC_MPEG2_ROLE);
|
||||
strcpy(comp->role_specific[1], OMX_VID_DEC_AVC_ROLE);
|
||||
strcpy(comp->role_specific[2], OMX_VID_DEC_HEVC_ROLE);
|
||||
strcpy(comp->role_specific[3], OMX_VID_DEC_AV1_ROLE);
|
||||
|
||||
comp->constructor = vid_dec_Constructor;
|
||||
|
||||
return OMX_ErrorNone;
|
||||
|
||||
error_specific:
|
||||
FREE(comp->role_specific[3]);
|
||||
FREE(comp->role_specific[2]);
|
||||
FREE(comp->role_specific[1]);
|
||||
FREE(comp->role_specific[0]);
|
||||
FREE(comp->name_specific[3]);
|
||||
FREE(comp->name_specific[2]);
|
||||
FREE(comp->name_specific[1]);
|
||||
FREE(comp->name_specific[0]);
|
||||
|
||||
error:
|
||||
FREE(comp->role_specific);
|
||||
FREE(comp->name_specific);
|
||||
|
||||
FREE(comp->name);
|
||||
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_dec_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING name)
|
||||
{
|
||||
vid_dec_PrivateType *priv;
|
||||
omx_base_video_PortType *port;
|
||||
struct pipe_screen *screen;
|
||||
OMX_ERRORTYPE r;
|
||||
int i;
|
||||
|
||||
assert(!comp->pComponentPrivate);
|
||||
|
||||
priv = comp->pComponentPrivate = CALLOC(1, sizeof(vid_dec_PrivateType));
|
||||
if (!priv)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
r = omx_base_filter_Constructor(comp, name);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
priv->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
|
||||
|
||||
if (!strcmp(name, OMX_VID_DEC_MPEG2_NAME))
|
||||
priv->profile = PIPE_VIDEO_PROFILE_MPEG2_MAIN;
|
||||
|
||||
if (!strcmp(name, OMX_VID_DEC_AVC_NAME))
|
||||
priv->profile = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
|
||||
|
||||
if (!strcmp(name, OMX_VID_DEC_HEVC_NAME))
|
||||
priv->profile = PIPE_VIDEO_PROFILE_HEVC_MAIN;
|
||||
|
||||
if (!strcmp(name, OMX_VID_DEC_AV1_NAME))
|
||||
priv->profile = PIPE_VIDEO_PROFILE_AV1_MAIN;
|
||||
|
||||
if (priv->profile == PIPE_VIDEO_PROFILE_AV1_MAIN)
|
||||
priv->BufferMgmtCallback = vid_dec_av1_FrameDecoded;
|
||||
else
|
||||
priv->BufferMgmtCallback = vid_dec_FrameDecoded;
|
||||
priv->messageHandler = vid_dec_MessageHandler;
|
||||
priv->destructor = vid_dec_Destructor;
|
||||
|
||||
comp->SetParameter = vid_dec_SetParameter;
|
||||
comp->GetParameter = vid_dec_GetParameter;
|
||||
|
||||
priv->screen = omx_get_screen();
|
||||
if (!priv->screen)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
screen = priv->screen->pscreen;
|
||||
|
||||
if (!vl_codec_supported(screen, priv->profile, false))
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
priv->pipe = pipe_create_multimedia_context(screen);
|
||||
if (!priv->pipe)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
if (!vl_compositor_init(&priv->compositor, priv->pipe)) {
|
||||
priv->pipe->destroy(priv->pipe);
|
||||
priv->pipe = NULL;
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
if (!vl_compositor_init_state(&priv->cstate, priv->pipe)) {
|
||||
vl_compositor_cleanup(&priv->compositor);
|
||||
priv->pipe->destroy(priv->pipe);
|
||||
priv->pipe = NULL;
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
priv->sPortTypesParam[OMX_PortDomainVideo].nStartPortNumber = 0;
|
||||
priv->sPortTypesParam[OMX_PortDomainVideo].nPorts = 2;
|
||||
priv->ports = CALLOC(2, sizeof(omx_base_PortType *));
|
||||
if (!priv->ports)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
for (i = 0; i < 2; ++i) {
|
||||
priv->ports[i] = CALLOC(1, sizeof(omx_base_video_PortType));
|
||||
if (!priv->ports[i])
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
base_video_port_Constructor(comp, &priv->ports[i], i, i == 0);
|
||||
}
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_INPUTPORT_INDEX];
|
||||
strcpy(port->sPortParam.format.video.cMIMEType,"video/MPEG2");
|
||||
port->sPortParam.nBufferCountMin = 8;
|
||||
port->sPortParam.nBufferCountActual = 8;
|
||||
port->sPortParam.nBufferSize = DEFAULT_OUT_BUFFER_SIZE;
|
||||
port->sPortParam.format.video.nFrameWidth = 176;
|
||||
port->sPortParam.format.video.nFrameHeight = 144;
|
||||
port->sPortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG2;
|
||||
port->sVideoParam.eCompressionFormat = OMX_VIDEO_CodingMPEG2;
|
||||
port->Port_SendBufferFunction = vid_dec_DecodeBuffer;
|
||||
if (priv->profile == PIPE_VIDEO_PROFILE_AV1_MAIN) {
|
||||
port->Port_AllocateBuffer = vid_dec_av1_AllocateInBuffer;
|
||||
port->Port_UseBuffer = vid_dec_av1_UseInBuffer;
|
||||
}
|
||||
|
||||
port->Port_FreeBuffer = vid_dec_FreeDecBuffer;
|
||||
port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_OUTPUTPORT_INDEX];
|
||||
port->sPortParam.nBufferCountActual = 8;
|
||||
port->sPortParam.nBufferCountMin = 4;
|
||||
port->sPortParam.format.video.nFrameWidth = 176;
|
||||
port->sPortParam.format.video.nFrameHeight = 144;
|
||||
port->sPortParam.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
|
||||
port->sVideoParam.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_dec_Destructor(OMX_COMPONENTTYPE *comp)
|
||||
{
|
||||
vid_dec_PrivateType* priv = comp->pComponentPrivate;
|
||||
int i;
|
||||
|
||||
if (priv->profile == PIPE_VIDEO_PROFILE_AV1_MAIN)
|
||||
vid_dec_av1_ReleaseTasks(priv);
|
||||
|
||||
if (priv->ports) {
|
||||
for (i = 0; i < priv->sPortTypesParam[OMX_PortDomainVideo].nPorts; ++i) {
|
||||
if(priv->ports[i])
|
||||
priv->ports[i]->PortDestructor(priv->ports[i]);
|
||||
}
|
||||
FREE(priv->ports);
|
||||
priv->ports=NULL;
|
||||
}
|
||||
|
||||
if (priv->pipe) {
|
||||
vl_compositor_cleanup_state(&priv->cstate);
|
||||
vl_compositor_cleanup(&priv->compositor);
|
||||
priv->pipe->destroy(priv->pipe);
|
||||
}
|
||||
|
||||
if (priv->screen)
|
||||
omx_put_screen();
|
||||
|
||||
return omx_workaround_Destructor(comp);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_dec_SetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param)
|
||||
{
|
||||
OMX_COMPONENTTYPE *comp = handle;
|
||||
vid_dec_PrivateType *priv = comp->pComponentPrivate;
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
if (!param)
|
||||
return OMX_ErrorBadParameter;
|
||||
|
||||
switch(idx) {
|
||||
case OMX_IndexParamPortDefinition: {
|
||||
OMX_PARAM_PORTDEFINITIONTYPE *def = param;
|
||||
|
||||
r = omx_base_component_SetParameter(handle, idx, param);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (def->nPortIndex == OMX_BASE_FILTER_INPUTPORT_INDEX) {
|
||||
omx_base_video_PortType *port;
|
||||
unsigned framesize = def->format.video.nFrameWidth * def->format.video.nFrameHeight;
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_INPUTPORT_INDEX];
|
||||
port->sPortParam.nBufferSize = framesize * 512 / (16*16);
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_OUTPUTPORT_INDEX];
|
||||
port->sPortParam.format.video.nFrameWidth = def->format.video.nFrameWidth;
|
||||
port->sPortParam.format.video.nFrameHeight = def->format.video.nFrameHeight;
|
||||
port->sPortParam.format.video.nStride = def->format.video.nFrameWidth;
|
||||
port->sPortParam.format.video.nSliceHeight = def->format.video.nFrameHeight;
|
||||
port->sPortParam.nBufferSize = framesize*3/2;
|
||||
|
||||
priv->callbacks->EventHandler(comp, priv->callbackData, OMX_EventPortSettingsChanged,
|
||||
OMX_BASE_FILTER_OUTPUTPORT_INDEX, 0, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OMX_IndexParamStandardComponentRole: {
|
||||
OMX_PARAM_COMPONENTROLETYPE *role = param;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_PARAM_COMPONENTROLETYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (!strcmp((char *)role->cRole, OMX_VID_DEC_MPEG2_ROLE)) {
|
||||
priv->profile = PIPE_VIDEO_PROFILE_MPEG2_MAIN;
|
||||
} else if (!strcmp((char *)role->cRole, OMX_VID_DEC_AVC_ROLE)) {
|
||||
priv->profile = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
|
||||
} else if (!strcmp((char *)role->cRole, OMX_VID_DEC_HEVC_ROLE)) {
|
||||
priv->profile = PIPE_VIDEO_PROFILE_HEVC_MAIN;
|
||||
} else if (!strcmp((char *)role->cRole, OMX_VID_DEC_AV1_ROLE)) {
|
||||
priv->profile = PIPE_VIDEO_PROFILE_AV1_MAIN;
|
||||
} else {
|
||||
return OMX_ErrorBadParameter;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case OMX_IndexParamVideoPortFormat: {
|
||||
OMX_VIDEO_PARAM_PORTFORMATTYPE *format = param;
|
||||
omx_base_video_PortType *port;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (format->nPortIndex > 1)
|
||||
return OMX_ErrorBadPortIndex;
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[format->nPortIndex];
|
||||
memcpy(&port->sVideoParam, format, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return omx_base_component_SetParameter(handle, idx, param);
|
||||
}
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_dec_GetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param)
|
||||
{
|
||||
OMX_COMPONENTTYPE *comp = handle;
|
||||
vid_dec_PrivateType *priv = comp->pComponentPrivate;
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
if (!param)
|
||||
return OMX_ErrorBadParameter;
|
||||
|
||||
switch(idx) {
|
||||
case OMX_IndexParamStandardComponentRole: {
|
||||
OMX_PARAM_COMPONENTROLETYPE *role = param;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_PARAM_COMPONENTROLETYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (priv->profile == PIPE_VIDEO_PROFILE_MPEG2_MAIN)
|
||||
strcpy((char *)role->cRole, OMX_VID_DEC_MPEG2_ROLE);
|
||||
else if (priv->profile == PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH)
|
||||
strcpy((char *)role->cRole, OMX_VID_DEC_AVC_ROLE);
|
||||
else if (priv->profile == PIPE_VIDEO_PROFILE_HEVC_MAIN)
|
||||
strcpy((char *)role->cRole, OMX_VID_DEC_HEVC_ROLE);
|
||||
else if (priv->profile == PIPE_VIDEO_PROFILE_AV1_MAIN)
|
||||
strcpy((char *)role->cRole, OMX_VID_DEC_AV1_ROLE);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case OMX_IndexParamVideoInit:
|
||||
r = checkHeader(param, sizeof(OMX_PORT_PARAM_TYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
memcpy(param, &priv->sPortTypesParam[OMX_PortDomainVideo], sizeof(OMX_PORT_PARAM_TYPE));
|
||||
break;
|
||||
|
||||
case OMX_IndexParamVideoPortFormat: {
|
||||
OMX_VIDEO_PARAM_PORTFORMATTYPE *format = param;
|
||||
omx_base_video_PortType *port;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (format->nPortIndex > 1)
|
||||
return OMX_ErrorBadPortIndex;
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[format->nPortIndex];
|
||||
memcpy(format, &port->sVideoParam, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return omx_base_component_GetParameter(handle, idx, param);
|
||||
|
||||
}
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_dec_MessageHandler(OMX_COMPONENTTYPE* comp, internalRequestMessageType *msg)
|
||||
{
|
||||
vid_dec_PrivateType* priv = comp->pComponentPrivate;
|
||||
|
||||
if (msg->messageType == OMX_CommandStateSet) {
|
||||
if ((msg->messageParam == OMX_StateIdle ) && (priv->state == OMX_StateLoaded)) {
|
||||
if (priv->profile == PIPE_VIDEO_PROFILE_MPEG2_MAIN)
|
||||
vid_dec_mpeg12_Init(priv);
|
||||
else if (priv->profile == PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH)
|
||||
vid_dec_h264_Init(priv);
|
||||
else if (priv->profile == PIPE_VIDEO_PROFILE_HEVC_MAIN)
|
||||
vid_dec_h265_Init(priv);
|
||||
else if (priv->profile == PIPE_VIDEO_PROFILE_AV1_MAIN) {
|
||||
vid_dec_av1_Init(priv);
|
||||
}
|
||||
|
||||
} else if ((msg->messageParam == OMX_StateLoaded) && (priv->state == OMX_StateIdle)) {
|
||||
if (priv->shadow) {
|
||||
priv->shadow->destroy(priv->shadow);
|
||||
priv->shadow = NULL;
|
||||
}
|
||||
if (priv->codec) {
|
||||
priv->codec->destroy(priv->codec);
|
||||
priv->codec = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return omx_base_component_MessageHandler(comp, msg);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_dec_DecodeBuffer(omx_base_PortType *port, OMX_BUFFERHEADERTYPE *buf)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_dec_PrivateType *priv = comp->pComponentPrivate;
|
||||
unsigned i = priv->num_in_buffers++;
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
priv->in_buffers[i] = buf;
|
||||
priv->sizes[i] = buf->nFilledLen;
|
||||
priv->inputs[i] = buf->pBuffer;
|
||||
priv->timestamps[i] = buf->nTimeStamp;
|
||||
|
||||
while (priv->num_in_buffers > (!!(buf->nFlags & OMX_BUFFERFLAG_EOS) ? 0 : 1)) {
|
||||
bool eos = !!(priv->in_buffers[0]->nFlags & OMX_BUFFERFLAG_EOS);
|
||||
unsigned min_bits_left = eos ? 32 : MAX2(buf->nFilledLen * 8, 32);
|
||||
struct vl_vlc vlc;
|
||||
|
||||
vl_vlc_init(&vlc, priv->num_in_buffers, priv->inputs, priv->sizes);
|
||||
|
||||
if (priv->slice)
|
||||
priv->bytes_left = vl_vlc_bits_left(&vlc) / 8;
|
||||
|
||||
while (vl_vlc_bits_left(&vlc) > min_bits_left) {
|
||||
priv->Decode(priv, &vlc, min_bits_left);
|
||||
vl_vlc_fillbits(&vlc);
|
||||
}
|
||||
|
||||
if (priv->slice) {
|
||||
unsigned bytes = priv->bytes_left - vl_vlc_bits_left(&vlc) / 8;
|
||||
|
||||
priv->codec->decode_bitstream(priv->codec, priv->target, &priv->picture.base,
|
||||
1, &priv->slice, &bytes);
|
||||
|
||||
if (priv->num_in_buffers)
|
||||
priv->slice = priv->inputs[1];
|
||||
else
|
||||
priv->slice = NULL;
|
||||
}
|
||||
|
||||
if (eos && priv->frame_started)
|
||||
priv->EndFrame(priv);
|
||||
|
||||
if (priv->frame_finished) {
|
||||
priv->frame_finished = false;
|
||||
priv->in_buffers[0]->nFilledLen = priv->in_buffers[0]->nAllocLen;
|
||||
r = base_port_SendBufferFunction(port, priv->in_buffers[0]);
|
||||
} else if (eos) {
|
||||
if (priv->profile == PIPE_VIDEO_PROFILE_AV1_MAIN)
|
||||
vid_dec_av1_FreeInputPortPrivate(priv, priv->in_buffers[0]);
|
||||
else
|
||||
vid_dec_FreeInputPortPrivate(priv->in_buffers[0]);
|
||||
priv->in_buffers[0]->nFilledLen = priv->in_buffers[0]->nAllocLen;
|
||||
r = base_port_SendBufferFunction(port, priv->in_buffers[0]);
|
||||
} else {
|
||||
priv->in_buffers[0]->nFilledLen = 0;
|
||||
r = port->ReturnBufferFunction(port, priv->in_buffers[0]);
|
||||
}
|
||||
|
||||
if (--priv->num_in_buffers) {
|
||||
unsigned delta = MIN2((min_bits_left - vl_vlc_bits_left(&vlc)) / 8, priv->sizes[1]);
|
||||
|
||||
priv->in_buffers[0] = priv->in_buffers[1];
|
||||
priv->sizes[0] = priv->sizes[1] - delta;
|
||||
priv->inputs[0] = priv->inputs[1] + delta;
|
||||
priv->timestamps[0] = priv->timestamps[1];
|
||||
}
|
||||
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_dec_FreeDecBuffer(omx_base_PortType *port, OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_dec_PrivateType *priv = comp->pComponentPrivate;
|
||||
|
||||
if (priv->profile == PIPE_VIDEO_PROFILE_AV1_MAIN)
|
||||
vid_dec_av1_FreeInputPortPrivate(priv, buf);
|
||||
else
|
||||
vid_dec_FreeInputPortPrivate(buf);
|
||||
|
||||
return base_port_FreeBuffer(port, idx, buf);
|
||||
}
|
||||
|
||||
static void vid_dec_FrameDecoded(OMX_COMPONENTTYPE *comp, OMX_BUFFERHEADERTYPE* input,
|
||||
OMX_BUFFERHEADERTYPE* output)
|
||||
{
|
||||
vid_dec_PrivateType *priv = comp->pComponentPrivate;
|
||||
|
||||
vid_dec_FrameDecoded_common(priv, input, output);
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Christian König <christian.koenig@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef OMX_VID_DEC_H
|
||||
#define OMX_VID_DEC_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <OMX_Types.h>
|
||||
#include <OMX_Component.h>
|
||||
|
||||
#include "util/u_thread.h"
|
||||
|
||||
#include "vid_dec_common.h"
|
||||
|
||||
#define OMX_VID_DEC_BASE_NAME "OMX.mesa.video_decoder"
|
||||
|
||||
#define OMX_VID_DEC_MPEG2_NAME "OMX.mesa.video_decoder.mpeg2"
|
||||
#define OMX_VID_DEC_MPEG2_ROLE "video_decoder.mpeg2"
|
||||
|
||||
#define OMX_VID_DEC_AVC_NAME "OMX.mesa.video_decoder.avc"
|
||||
#define OMX_VID_DEC_AVC_ROLE "video_decoder.avc"
|
||||
|
||||
#define OMX_VID_DEC_HEVC_NAME "OMX.mesa.video_decoder.hevc"
|
||||
#define OMX_VID_DEC_HEVC_ROLE "video_decoder.hevc"
|
||||
|
||||
#define OMX_VID_DEC_AV1_NAME "OMX.mesa.video_decoder.av1"
|
||||
#define OMX_VID_DEC_AV1_ROLE "video_decoder.av1"
|
||||
|
||||
#define OMX_VID_DEC_TIMESTAMP_INVALID ((OMX_TICKS) -1)
|
||||
|
||||
OMX_ERRORTYPE vid_dec_LoaderComponent(stLoaderComponentType *comp);
|
||||
|
||||
/* vid_dec_mpeg12.c */
|
||||
void vid_dec_mpeg12_Init(vid_dec_PrivateType *priv);
|
||||
|
||||
/* vid_dec_h264.c */
|
||||
void vid_dec_h264_Init(vid_dec_PrivateType *priv);
|
||||
|
||||
/* vid_dec_h265.c */
|
||||
void vid_dec_h265_Init(vid_dec_PrivateType *priv);
|
||||
|
||||
/* vid_dec_av1.c */
|
||||
void vid_dec_av1_Init(vid_dec_PrivateType *priv);
|
||||
|
||||
OMX_ERRORTYPE vid_dec_av1_AllocateInBuffer(omx_base_PortType *port,
|
||||
OMX_INOUT OMX_BUFFERHEADERTYPE **buf,
|
||||
OMX_IN OMX_U32 idx, OMX_IN OMX_PTR private,
|
||||
OMX_IN OMX_U32 size);
|
||||
|
||||
OMX_ERRORTYPE vid_dec_av1_UseInBuffer(omx_base_PortType *port, OMX_BUFFERHEADERTYPE **buf,
|
||||
OMX_U32 idx, OMX_PTR private, OMX_U32 size, OMX_U8 *mem);
|
||||
|
||||
void vid_dec_av1_FrameDecoded(OMX_COMPONENTTYPE *comp, OMX_BUFFERHEADERTYPE* input,
|
||||
OMX_BUFFERHEADERTYPE* output);
|
||||
|
||||
void vid_dec_av1_ReleaseTasks(vid_dec_PrivateType *priv);
|
||||
|
||||
void vid_dec_av1_FreeInputPortPrivate(vid_dec_PrivateType *priv, OMX_BUFFERHEADERTYPE *buf);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,459 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2020 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef VID_DEC_AV1_H
|
||||
#define VID_DEC_AV1_H
|
||||
|
||||
#include "util/u_thread.h"
|
||||
|
||||
enum av1_obu_type {
|
||||
AV1_OBU_SEQUENCE_HEADER = 1,
|
||||
AV1_OBU_TEMPORAL_DELIMITER,
|
||||
AV1_OBU_FRAME_HEADER,
|
||||
AV1_OBU_TILE_GROUP,
|
||||
AV1_OBU_METADATA,
|
||||
AV1_OBU_FRAME,
|
||||
AV1_OBU_REDUNDANT_FRAME_HEADER,
|
||||
AV1_OBU_TILE_LIST,
|
||||
AV1_OBU_PADDING = 15
|
||||
};
|
||||
|
||||
enum av1_obu_frame_type {
|
||||
AV1_KEY_FRAME = 0,
|
||||
AV1_INTER_FRAME,
|
||||
AV1_INTRA_ONLY_FRAME,
|
||||
AV1_SWITCH_FRAME
|
||||
};
|
||||
|
||||
enum av1_obu_color_primary {
|
||||
AV1_CP_BT_709 = 1,
|
||||
AV1_CP_UNSPECIFIED,
|
||||
AV1_CP_BT_470_M = 4,
|
||||
AV1_CP_BT_470_B_G,
|
||||
AV1_CP_BT_601,
|
||||
AV1_CP_SMPTE_240,
|
||||
AV1_CP_GENERIC_FILM,
|
||||
AV1_CP_BT_2020,
|
||||
AV1_CP_XYZ,
|
||||
AV1_CP_SMPTE_431,
|
||||
AV1_CP_SMPTE_432,
|
||||
AV1_CP_EBU_3213 = 22
|
||||
};
|
||||
|
||||
enum av1_obu_transfer_characteristic {
|
||||
AV1_TC_RESERVED_0 = 0,
|
||||
AV1_TC_BT_709,
|
||||
AV1_TC_UNSPECIFIED,
|
||||
AV1_TC_RESERVED_3,
|
||||
AV1_TC_BT_470_M,
|
||||
AV1_TC_BT_470_B_G,
|
||||
AV1_TC_BT_601,
|
||||
AV1_TC_SMPTE_240,
|
||||
AV1_TC_LINEAR,
|
||||
AV1_TC_LOG_100,
|
||||
AV1_TC_LOG_100_SQRT10,
|
||||
AV1_TC_IEC_61966,
|
||||
AV1_TC_BT_1361,
|
||||
AV1_TC_SRGB,
|
||||
AV1_TC_BT_2020_10_BIT,
|
||||
AV1_TC_BT_2020_12_BIT,
|
||||
AV1_TC_SMPTE_2084,
|
||||
AV1_TC_SMPTE_428,
|
||||
AV1_TC_HLG
|
||||
};
|
||||
|
||||
enum av1_obu_matrix_coefficient {
|
||||
AV1_MC_IDENTITY = 0,
|
||||
AV1_MC_BT_709,
|
||||
AV1_MC_UNSPECIFIED,
|
||||
AV1_MC_RESERVED_3,
|
||||
AV1_MC_FCC,
|
||||
AV1_MC_BT_470_B_G,
|
||||
AV1_MC_BT_601,
|
||||
AV1_MC_SMPTE_240,
|
||||
AV1_MC_SMPTE_YCGCO,
|
||||
AV1_MC_BT_2020_NCL,
|
||||
AV1_MC_BT_2020_CL,
|
||||
AV1_MC_SMPTE_2085,
|
||||
AV1_MC_CHROMAT_NCL,
|
||||
AV1_MC_CHROMAT_CL,
|
||||
AV1_MC_ICTCP
|
||||
};
|
||||
|
||||
enum av1_obu_seg_lvl {
|
||||
AV1_SEG_LVL_ALT_Q = 0,
|
||||
AV1_SEG_LVL_ALT_LF_Y_V,
|
||||
AV1_SEG_LVL_REF_FRAME = 5,
|
||||
AV1_SEG_LVL_SKIP,
|
||||
AV1_SEG_LVL_GLOBALMV,
|
||||
AV1_SEG_LVL_MAX
|
||||
};
|
||||
|
||||
enum av1_obu_lrtype {
|
||||
AV1_RESTORE_NONE = 0,
|
||||
AV1_RESTORE_WIENER,
|
||||
AV1_RESTORE_SGRPROJ,
|
||||
AV1_RESTORE_SWITCHABLE
|
||||
};
|
||||
|
||||
enum av1_obu_txmode {
|
||||
AV1_ONLY_4X4 = 0,
|
||||
AV1_TX_MODE_LARGEST,
|
||||
AV1_TX_MODE_SELECT
|
||||
};
|
||||
|
||||
enum av1_obu_gmtype {
|
||||
AV1_IDENTITY = 0,
|
||||
AV1_TRANSLATION,
|
||||
AV1_ROTZOOM,
|
||||
AV1_AFFINE
|
||||
};
|
||||
|
||||
enum av1_frame_refs {
|
||||
AV1_NONE = -1,
|
||||
AV1_INTRA_FRAME = 0,
|
||||
AV1_LAST_FRAME,
|
||||
AV1_LAST2_FRAME,
|
||||
AV1_LAST3_FRAME,
|
||||
AV1_GOLDEN_FRAME,
|
||||
AV1_BWDREF_FRAME,
|
||||
AV1_ALTREF2_FRAME,
|
||||
AV1_ALTREF_FRAME
|
||||
};
|
||||
|
||||
#define AV1_SELECT_SCREEN_CONTENT_TOOLS 2
|
||||
#define AV1_SELECT_INTEGER_MV 2
|
||||
|
||||
#define AV1_PRIMARY_REF_NONE 7
|
||||
#define AV1_REFS_PER_FRAME 7
|
||||
#define AV1_NUM_REF_FRAMES 8
|
||||
|
||||
#define AV1_MAX_TILE_WIDTH 4096
|
||||
#define AV1_MAX_TILE_AREA (4096 * 2304)
|
||||
#define AV1_MAX_TILE_ROWS 64
|
||||
#define AV1_MAX_TILE_COLS 64
|
||||
#define AV1_MAX_NUM_TILES AV1_MAX_TILE_ROWS * AV1_MAX_TILE_COLS
|
||||
|
||||
#define AV1_MAX_SEGMENTS 8
|
||||
#define AV1_MAX_CDEF_BITS_ARRAY 8
|
||||
#define AV1_RESTORATION_TILESIZE 256
|
||||
#define AV1_WARPEDMODEL_PREC_BITS 16
|
||||
#define AV1_FG_MAX_NUM_Y_POINTS 14
|
||||
#define AV1_FG_MAX_NUM_CBR_POINTS 10
|
||||
#define AV1_FG_MAX_NUM_POS_LUMA 24
|
||||
#define AV1_FG_MAX_NUM_POS_CHROMA 25
|
||||
|
||||
struct av1_obu_extension_header_obu
|
||||
{
|
||||
unsigned temporal_id;
|
||||
unsigned spatial_id;
|
||||
};
|
||||
|
||||
struct av1_sequence_header_obu {
|
||||
uint8_t seq_profile;
|
||||
bool reduced_still_picture_header;
|
||||
|
||||
struct {
|
||||
bool equal_picture_interval;
|
||||
} timing_info;
|
||||
|
||||
bool decoder_model_info_present_flag;
|
||||
struct {
|
||||
unsigned num_units_in_decoding_tick;
|
||||
uint8_t buffer_removal_time_length_minus_1;
|
||||
uint8_t frame_presentation_time_length_minus_1;
|
||||
} decoder_model_info;
|
||||
|
||||
uint8_t operating_points_cnt_minus_1;
|
||||
uint16_t operating_point_idc[32];
|
||||
bool decoder_model_present_for_this_op[32];
|
||||
|
||||
uint8_t frame_width_bits_minus_1;
|
||||
uint8_t frame_height_bits_minus_1;
|
||||
unsigned max_frame_width_minus_1;
|
||||
unsigned max_frame_height_minus_1;
|
||||
bool frame_id_numbers_present_flag;
|
||||
uint8_t delta_frame_id_length_minus_2;
|
||||
uint8_t additional_frame_id_length_minus_1;
|
||||
|
||||
bool use_128x128_superblock;
|
||||
bool enable_filter_intra;
|
||||
bool enable_intra_edge_filter;
|
||||
bool enable_interintra_compound;
|
||||
bool enable_masked_compound;
|
||||
bool enable_warped_motion;
|
||||
bool enable_dual_filter;
|
||||
bool enable_order_hint;
|
||||
bool enable_jnt_comp;
|
||||
bool enable_ref_frame_mvs;
|
||||
uint8_t seq_force_screen_content_tools;
|
||||
uint8_t seq_force_integer_mv;
|
||||
|
||||
uint8_t order_hint_bits_minus_1;
|
||||
uint8_t OrderHintBits;
|
||||
bool enable_superres;
|
||||
bool enable_cdef;
|
||||
bool enable_restoration;
|
||||
struct {
|
||||
uint8_t BitDepth;
|
||||
bool mono_chrome;
|
||||
uint8_t NumPlanes;
|
||||
bool subsampling_x;
|
||||
bool subsampling_y;
|
||||
bool separate_uv_delta_q;
|
||||
} color_config;
|
||||
bool film_grain_params_present;
|
||||
};
|
||||
|
||||
struct ref_frame {
|
||||
uint8_t RefFrameType;
|
||||
unsigned RefFrameId;
|
||||
unsigned RefUpscaledWidth;
|
||||
unsigned RefFrameWidth;
|
||||
unsigned RefFrameHeight;
|
||||
unsigned RefRenderWidth;
|
||||
unsigned RefRenderHeight;
|
||||
};
|
||||
|
||||
struct tile_info {
|
||||
unsigned TileColsLog2;
|
||||
unsigned TileRowsLog2;
|
||||
int tile_col_start_sb[AV1_MAX_TILE_COLS + 1];
|
||||
int tile_row_start_sb[AV1_MAX_TILE_ROWS + 1];
|
||||
unsigned TileCols;
|
||||
unsigned TileRows;
|
||||
unsigned context_update_tile_id;
|
||||
uint8_t TileSizeBytes;
|
||||
};
|
||||
|
||||
struct quantization_params {
|
||||
uint8_t base_q_idx;
|
||||
int DeltaQYDc;
|
||||
int DeltaQUDc;
|
||||
int DeltaQUAc;
|
||||
int DeltaQVDc;
|
||||
int DeltaQVAc;
|
||||
uint8_t qm_y;
|
||||
uint8_t qm_u;
|
||||
uint8_t qm_v;
|
||||
};
|
||||
|
||||
struct segmentation_params {
|
||||
bool segmentation_enabled;
|
||||
bool segmentation_update_map;
|
||||
bool segmentation_temporal_update;
|
||||
bool FeatureEnabled[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
int FeatureData[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
int FeatureMask[AV1_MAX_SEGMENTS];
|
||||
};
|
||||
|
||||
struct delta_q_params {
|
||||
bool delta_q_present;
|
||||
uint8_t delta_q_res;
|
||||
};
|
||||
|
||||
struct delta_lf_params {
|
||||
bool delta_lf_present;
|
||||
uint8_t delta_lf_res;
|
||||
bool delta_lf_multi;
|
||||
};
|
||||
|
||||
struct loop_filter_params {
|
||||
uint8_t loop_filter_level[4];
|
||||
uint8_t loop_filter_sharpness;
|
||||
bool loop_filter_delta_enabled;
|
||||
bool loop_filter_delta_update;
|
||||
int8_t loop_filter_ref_deltas[AV1_NUM_REF_FRAMES];
|
||||
int8_t loop_filter_mode_deltas[2];
|
||||
};
|
||||
|
||||
struct cdef_params {
|
||||
uint8_t cdef_damping_minus_3;
|
||||
uint8_t cdef_bits;
|
||||
uint16_t cdef_y_strengths[AV1_MAX_CDEF_BITS_ARRAY];
|
||||
uint16_t cdef_uv_strengths[AV1_MAX_CDEF_BITS_ARRAY];
|
||||
};
|
||||
|
||||
struct loop_restoration_params {
|
||||
uint8_t FrameRestorationType[3];
|
||||
uint16_t LoopRestorationSize[3];
|
||||
};
|
||||
|
||||
struct tx_mode_params {
|
||||
uint8_t TxMode;
|
||||
};
|
||||
|
||||
enum reference_mode {
|
||||
SINGLE_REFERENCE = 0,
|
||||
COMPOUND_REFERENCE = 1,
|
||||
REFERENCE_MODE_SELECT = 2,
|
||||
REFERENCE_MODES = 3,
|
||||
};
|
||||
|
||||
struct skip_mode_params {
|
||||
bool skip_mode_present;
|
||||
};
|
||||
|
||||
struct global_motion_params {
|
||||
uint8_t GmType[AV1_NUM_REF_FRAMES];
|
||||
int gm_params[AV1_NUM_REF_FRAMES][6];
|
||||
};
|
||||
|
||||
struct film_grain_params {
|
||||
bool apply_grain;
|
||||
uint16_t grain_seed;
|
||||
uint8_t num_y_points;
|
||||
uint8_t point_y_value[AV1_FG_MAX_NUM_Y_POINTS];
|
||||
uint8_t point_y_scaling[AV1_FG_MAX_NUM_Y_POINTS];
|
||||
bool chroma_scaling_from_luma;
|
||||
uint8_t num_cb_points;
|
||||
uint8_t num_cr_points;
|
||||
uint8_t point_cb_value[AV1_FG_MAX_NUM_CBR_POINTS];
|
||||
uint8_t point_cb_scaling[AV1_FG_MAX_NUM_CBR_POINTS];
|
||||
uint8_t point_cr_value[AV1_FG_MAX_NUM_CBR_POINTS];
|
||||
uint8_t point_cr_scaling[AV1_FG_MAX_NUM_CBR_POINTS];
|
||||
uint8_t grain_scaling_minus_8;
|
||||
uint8_t ar_coeff_lag;
|
||||
int ar_coeffs_y[AV1_FG_MAX_NUM_POS_LUMA];
|
||||
int ar_coeffs_cb[AV1_FG_MAX_NUM_POS_CHROMA];
|
||||
int ar_coeffs_cr[AV1_FG_MAX_NUM_POS_CHROMA];
|
||||
uint8_t ar_coeff_shift_minus_6;
|
||||
int ar_coeff_shift;
|
||||
uint8_t grain_scale_shift;
|
||||
uint8_t cb_mult;
|
||||
uint8_t cb_luma_mult;
|
||||
uint16_t cb_offset;
|
||||
uint8_t cr_mult;
|
||||
uint8_t cr_luma_mult;
|
||||
uint16_t cr_offset;
|
||||
bool overlap_flag;
|
||||
bool clip_to_restricted_range;
|
||||
};
|
||||
|
||||
struct av1_uncompressed_header_obu
|
||||
{
|
||||
uint8_t frame_type;
|
||||
bool FrameIsIntra;
|
||||
bool show_frame;
|
||||
bool showable_frame;
|
||||
bool show_existing_frame;
|
||||
uint8_t frame_to_show_map_idx;
|
||||
|
||||
unsigned RefOrderHint[AV1_NUM_REF_FRAMES];
|
||||
bool error_resilient_mode;
|
||||
bool disable_cdf_update;
|
||||
bool allow_screen_content_tools;
|
||||
bool force_integer_mv;
|
||||
|
||||
unsigned current_frame_id;
|
||||
bool frame_size_override_flag;
|
||||
unsigned OrderHint;
|
||||
uint8_t primary_ref_frame;
|
||||
|
||||
uint8_t refresh_frame_flags;
|
||||
unsigned FrameWidth;
|
||||
unsigned FrameHeight;
|
||||
bool use_superres;
|
||||
unsigned SuperresDenom;
|
||||
unsigned UpscaledWidth;
|
||||
unsigned MiCols;
|
||||
unsigned MiRows;
|
||||
|
||||
unsigned RenderWidth;
|
||||
unsigned RenderHeight;
|
||||
|
||||
uint8_t last_frame_idx;
|
||||
uint8_t gold_frame_idx;
|
||||
uint8_t ref_frame_idx[AV1_REFS_PER_FRAME];
|
||||
uint8_t usedFrame[AV1_NUM_REF_FRAMES];
|
||||
unsigned curFrameHint;
|
||||
unsigned shiftedOrderHints[AV1_NUM_REF_FRAMES];
|
||||
|
||||
bool allow_high_precision_mv;
|
||||
bool use_ref_frame_mvs;
|
||||
bool allow_intrabc;
|
||||
uint8_t interpolation_filter;
|
||||
bool is_motion_mode_switchable;
|
||||
|
||||
bool disable_frame_end_update_cdf;
|
||||
struct tile_info ti;
|
||||
struct quantization_params qp;
|
||||
struct segmentation_params sp;
|
||||
struct delta_q_params dqp;
|
||||
struct delta_lf_params dlfp;
|
||||
|
||||
bool CodedLossless;
|
||||
bool AllLossless;
|
||||
struct loop_filter_params lfp;
|
||||
struct cdef_params cdefp;
|
||||
struct loop_restoration_params lrp;
|
||||
struct tx_mode_params tm;
|
||||
enum reference_mode reference_select;
|
||||
struct skip_mode_params smp;
|
||||
bool allow_warped_motion;
|
||||
bool reduced_tx_set;
|
||||
struct global_motion_params gmp;
|
||||
struct film_grain_params fgp;
|
||||
};
|
||||
|
||||
struct dec_av1_task {
|
||||
struct list_head list;
|
||||
|
||||
struct pipe_video_buffer *buf;
|
||||
bool no_show_frame;
|
||||
unsigned buf_ref_count;
|
||||
struct pipe_video_buffer **buf_ref;
|
||||
bool is_sef_task;
|
||||
};
|
||||
|
||||
struct input_buf_private {
|
||||
struct list_head tasks;
|
||||
struct list_head inps;
|
||||
};
|
||||
|
||||
struct dec_av1 {
|
||||
struct av1_obu_extension_header_obu ext;
|
||||
struct av1_sequence_header_obu seq;
|
||||
struct av1_uncompressed_header_obu uncompressed_header;
|
||||
struct av1_uncompressed_header_obu refs[AV1_NUM_REF_FRAMES];
|
||||
struct ref_frame RefFrames[AV1_NUM_REF_FRAMES];
|
||||
|
||||
uint8_t bs_obu_td_buf[8];
|
||||
unsigned bs_obu_td_sz;
|
||||
uint8_t bs_obu_seq_buf[128];
|
||||
unsigned bs_obu_seq_sz;
|
||||
struct pipe_video_buffer *frame_refs[AV1_NUM_REF_FRAMES];
|
||||
struct list_head free_tasks;
|
||||
struct list_head started_tasks;
|
||||
struct list_head finished_tasks;
|
||||
struct list_head decode_tasks;
|
||||
unsigned que_num;
|
||||
bool stacked_frame;
|
||||
mtx_t mutex;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,55 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Christian König <christian.koenig@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_video.h"
|
||||
#include "util/vl_rbsp.h"
|
||||
#include "vl/vl_zscan.h"
|
||||
|
||||
#include "entrypoint.h"
|
||||
#include "vid_dec.h"
|
||||
#include "vid_dec_h264_common.h"
|
||||
|
||||
void vid_dec_h264_Init(vid_dec_PrivateType *priv)
|
||||
{
|
||||
priv->picture.base.profile = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
|
||||
|
||||
priv->Decode = vid_dec_h264_Decode;
|
||||
priv->EndFrame = vid_dec_h264_EndFrame;
|
||||
priv->Flush = vid_dec_h264_Flush;
|
||||
|
||||
list_inithead(&priv->codec_data.h264.dpb_list);
|
||||
priv->picture.h264.field_order_cnt[0] = priv->picture.h264.field_order_cnt[1] = INT_MAX;
|
||||
priv->first_buf_in_frame = true;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,383 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Christian König <christian.koenig@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "util/vl_vlc.h"
|
||||
#include "vl/vl_zscan.h"
|
||||
|
||||
#include "vid_dec.h"
|
||||
|
||||
static uint8_t default_intra_matrix[64] = {
|
||||
8, 16, 19, 22, 26, 27, 29, 34,
|
||||
16, 16, 22, 24, 27, 29, 34, 37,
|
||||
19, 22, 26, 27, 29, 34, 34, 38,
|
||||
22, 22, 26, 27, 29, 34, 37, 40,
|
||||
22, 26, 27, 29, 32, 35, 40, 48,
|
||||
26, 27, 29, 32, 35, 40, 48, 58,
|
||||
26, 27, 29, 34, 38, 46, 56, 69,
|
||||
27, 29, 35, 38, 46, 56, 69, 83
|
||||
};
|
||||
|
||||
static uint8_t default_non_intra_matrix[64] = {
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 16
|
||||
};
|
||||
|
||||
static void vid_dec_mpeg12_Decode(vid_dec_PrivateType *priv, struct vl_vlc *vlc, unsigned min_bits_left);
|
||||
static void vid_dec_mpeg12_EndFrame(vid_dec_PrivateType *priv);
|
||||
static struct pipe_video_buffer *vid_dec_mpeg12_Flush(vid_dec_PrivateType *priv, OMX_TICKS *timestamp);
|
||||
|
||||
void vid_dec_mpeg12_Init(vid_dec_PrivateType *priv)
|
||||
{
|
||||
struct pipe_video_codec templat = {};
|
||||
omx_base_video_PortType *port;
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_INPUTPORT_INDEX];
|
||||
templat.profile = priv->profile;
|
||||
templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
|
||||
templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
|
||||
templat.max_references = 2;
|
||||
templat.expect_chunked_decode = true;
|
||||
templat.width = port->sPortParam.format.video.nFrameWidth;
|
||||
templat.height = port->sPortParam.format.video.nFrameHeight;
|
||||
|
||||
priv->codec = priv->pipe->create_video_codec(priv->pipe, &templat);
|
||||
|
||||
priv->picture.base.profile = PIPE_VIDEO_PROFILE_MPEG2_MAIN;
|
||||
priv->picture.mpeg12.intra_matrix = default_intra_matrix;
|
||||
priv->picture.mpeg12.non_intra_matrix = default_non_intra_matrix;
|
||||
|
||||
priv->Decode = vid_dec_mpeg12_Decode;
|
||||
priv->EndFrame = vid_dec_mpeg12_EndFrame;
|
||||
priv->Flush = vid_dec_mpeg12_Flush;
|
||||
}
|
||||
|
||||
static void BeginFrame(vid_dec_PrivateType *priv)
|
||||
{
|
||||
if (priv->picture.mpeg12.picture_coding_type != PIPE_MPEG12_PICTURE_CODING_TYPE_B) {
|
||||
priv->picture.mpeg12.ref[0] = priv->picture.mpeg12.ref[1];
|
||||
priv->picture.mpeg12.ref[1] = NULL;
|
||||
}
|
||||
|
||||
if (priv->target == priv->picture.mpeg12.ref[0]) {
|
||||
struct pipe_video_buffer *tmp = priv->target;
|
||||
priv->target = priv->shadow;
|
||||
priv->shadow = tmp;
|
||||
}
|
||||
|
||||
vid_dec_NeedTarget(priv);
|
||||
|
||||
priv->codec->begin_frame(priv->codec, priv->target, &priv->picture.base);
|
||||
priv->frame_started = true;
|
||||
}
|
||||
|
||||
static void vid_dec_mpeg12_EndFrame(vid_dec_PrivateType *priv)
|
||||
{
|
||||
struct pipe_video_buffer *done;
|
||||
|
||||
priv->codec->end_frame(priv->codec, priv->target, &priv->picture.base);
|
||||
priv->frame_started = false;
|
||||
|
||||
if (priv->picture.mpeg12.picture_coding_type != PIPE_MPEG12_PICTURE_CODING_TYPE_B) {
|
||||
|
||||
priv->picture.mpeg12.ref[1] = priv->target;
|
||||
done = priv->picture.mpeg12.ref[0];
|
||||
if (!done) {
|
||||
priv->target = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
} else
|
||||
done = priv->target;
|
||||
|
||||
priv->frame_finished = true;
|
||||
priv->target = priv->in_buffers[0]->pInputPortPrivate;
|
||||
priv->in_buffers[0]->pInputPortPrivate = done;
|
||||
}
|
||||
|
||||
static struct pipe_video_buffer *vid_dec_mpeg12_Flush(vid_dec_PrivateType *priv, OMX_TICKS *timestamp)
|
||||
{
|
||||
struct pipe_video_buffer *result = priv->picture.mpeg12.ref[1];
|
||||
priv->picture.mpeg12.ref[1] = NULL;
|
||||
if (timestamp)
|
||||
*timestamp = OMX_VID_DEC_TIMESTAMP_INVALID;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void vid_dec_mpeg12_Decode(vid_dec_PrivateType *priv, struct vl_vlc *vlc, unsigned min_bits_left)
|
||||
{
|
||||
uint8_t code;
|
||||
unsigned i;
|
||||
|
||||
if (!vl_vlc_search_byte(vlc, vl_vlc_bits_left(vlc) - min_bits_left, 0x00))
|
||||
return;
|
||||
|
||||
if (vl_vlc_peekbits(vlc, 24) != 0x000001) {
|
||||
vl_vlc_eatbits(vlc, 8);
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->slice) {
|
||||
unsigned bytes = priv->bytes_left - (vl_vlc_bits_left(vlc) / 8);
|
||||
priv->codec->decode_bitstream(priv->codec, priv->target, &priv->picture.base,
|
||||
1, &priv->slice, &bytes);
|
||||
priv->slice = NULL;
|
||||
}
|
||||
|
||||
vl_vlc_eatbits(vlc, 24);
|
||||
code = vl_vlc_get_uimsbf(vlc, 8);
|
||||
|
||||
if (priv->frame_started && (code == 0x00 || code > 0xAF))
|
||||
vid_dec_mpeg12_EndFrame(priv);
|
||||
|
||||
if (code == 0xB3) {
|
||||
/* sequence header code */
|
||||
vl_vlc_fillbits(vlc);
|
||||
|
||||
/* horizontal_size_value */
|
||||
vl_vlc_get_uimsbf(vlc, 12);
|
||||
|
||||
/* vertical_size_value */
|
||||
vl_vlc_get_uimsbf(vlc, 12);
|
||||
|
||||
/* aspect_ratio_information */
|
||||
vl_vlc_get_uimsbf(vlc, 4);
|
||||
|
||||
/* frame_rate_code */
|
||||
vl_vlc_get_uimsbf(vlc, 4);
|
||||
|
||||
vl_vlc_fillbits(vlc);
|
||||
|
||||
/* bit_rate_value */
|
||||
vl_vlc_get_uimsbf(vlc, 18);
|
||||
|
||||
/* marker_bit */
|
||||
vl_vlc_get_uimsbf(vlc, 1);
|
||||
|
||||
/* vbv_buffer_size_value */
|
||||
vl_vlc_get_uimsbf(vlc, 10);
|
||||
|
||||
/* constrained_parameters_flag */
|
||||
vl_vlc_get_uimsbf(vlc, 1);
|
||||
|
||||
vl_vlc_fillbits(vlc);
|
||||
|
||||
/* load_intra_quantiser_matrix */
|
||||
if (vl_vlc_get_uimsbf(vlc, 1)) {
|
||||
/* intra_quantiser_matrix */
|
||||
priv->picture.mpeg12.intra_matrix = priv->codec_data.mpeg12.intra_matrix;
|
||||
for (i = 0; i < 64; ++i) {
|
||||
priv->codec_data.mpeg12.intra_matrix[vl_zscan_normal[i]] = vl_vlc_get_uimsbf(vlc, 8);
|
||||
vl_vlc_fillbits(vlc);
|
||||
}
|
||||
} else
|
||||
priv->picture.mpeg12.intra_matrix = default_intra_matrix;
|
||||
|
||||
/* load_non_intra_quantiser_matrix */
|
||||
if (vl_vlc_get_uimsbf(vlc, 1)) {
|
||||
/* non_intra_quantiser_matrix */
|
||||
priv->picture.mpeg12.non_intra_matrix = priv->codec_data.mpeg12.non_intra_matrix;
|
||||
for (i = 0; i < 64; ++i) {
|
||||
priv->codec_data.mpeg12.non_intra_matrix[i] = vl_vlc_get_uimsbf(vlc, 8);
|
||||
vl_vlc_fillbits(vlc);
|
||||
}
|
||||
} else
|
||||
priv->picture.mpeg12.non_intra_matrix = default_non_intra_matrix;
|
||||
|
||||
} else if (code == 0x00) {
|
||||
/* picture start code */
|
||||
vl_vlc_fillbits(vlc);
|
||||
|
||||
/* temporal_reference */
|
||||
vl_vlc_get_uimsbf(vlc, 10);
|
||||
|
||||
priv->picture.mpeg12.picture_coding_type = vl_vlc_get_uimsbf(vlc, 3);
|
||||
|
||||
/* vbv_delay */
|
||||
vl_vlc_get_uimsbf(vlc, 16);
|
||||
|
||||
vl_vlc_fillbits(vlc);
|
||||
if (priv->picture.mpeg12.picture_coding_type == 2 ||
|
||||
priv->picture.mpeg12.picture_coding_type == 3) {
|
||||
priv->picture.mpeg12.full_pel_forward_vector = vl_vlc_get_uimsbf(vlc, 1);
|
||||
/* forward_f_code */
|
||||
priv->picture.mpeg12.f_code[0][0] = vl_vlc_get_uimsbf(vlc, 3) - 1;
|
||||
priv->picture.mpeg12.f_code[0][1] = priv->picture.mpeg12.f_code[0][0];
|
||||
} else {
|
||||
priv->picture.mpeg12.full_pel_forward_vector = 0;
|
||||
priv->picture.mpeg12.f_code[0][1] = priv->picture.mpeg12.f_code[0][0] = 14;
|
||||
}
|
||||
|
||||
if (priv->picture.mpeg12.picture_coding_type == 3) {
|
||||
priv->picture.mpeg12.full_pel_backward_vector = vl_vlc_get_uimsbf(vlc, 1);
|
||||
/* backward_f_code */
|
||||
priv->picture.mpeg12.f_code[1][0] = vl_vlc_get_uimsbf(vlc, 3) - 1;
|
||||
priv->picture.mpeg12.f_code[1][1] = priv->picture.mpeg12.f_code[1][0];
|
||||
} else {
|
||||
priv->picture.mpeg12.full_pel_backward_vector = 0;
|
||||
priv->picture.mpeg12.f_code[0][1] = priv->picture.mpeg12.f_code[0][0] = 14;
|
||||
}
|
||||
|
||||
/* extra_bit_picture */
|
||||
while (vl_vlc_get_uimsbf(vlc, 1)) {
|
||||
/* extra_information_picture */
|
||||
vl_vlc_get_uimsbf(vlc, 8);
|
||||
vl_vlc_fillbits(vlc);
|
||||
}
|
||||
|
||||
} else if (code == 0xB5) {
|
||||
/* extension start code */
|
||||
vl_vlc_fillbits(vlc);
|
||||
|
||||
/* extension_start_code_identifier */
|
||||
switch (vl_vlc_get_uimsbf(vlc, 4)) {
|
||||
case 0x3: /* quant matrix extension */
|
||||
|
||||
/* load_intra_quantiser_matrix */
|
||||
if (vl_vlc_get_uimsbf(vlc, 1)) {
|
||||
/* intra_quantiser_matrix */
|
||||
priv->picture.mpeg12.intra_matrix = priv->codec_data.mpeg12.intra_matrix;
|
||||
for (i = 0; i < 64; ++i) {
|
||||
priv->codec_data.mpeg12.intra_matrix[vl_zscan_normal[i]] = vl_vlc_get_uimsbf(vlc, 8);
|
||||
vl_vlc_fillbits(vlc);
|
||||
}
|
||||
} else
|
||||
priv->picture.mpeg12.intra_matrix = default_intra_matrix;
|
||||
|
||||
/* load_non_intra_quantiser_matrix */
|
||||
if (vl_vlc_get_uimsbf(vlc, 1)) {
|
||||
/* non_intra_quantiser_matrix */
|
||||
priv->picture.mpeg12.non_intra_matrix = priv->codec_data.mpeg12.non_intra_matrix;
|
||||
for (i = 0; i < 64; ++i) {
|
||||
priv->codec_data.mpeg12.non_intra_matrix[i] = vl_vlc_get_uimsbf(vlc, 8);
|
||||
vl_vlc_fillbits(vlc);
|
||||
}
|
||||
} else
|
||||
priv->picture.mpeg12.intra_matrix = default_non_intra_matrix;
|
||||
|
||||
break;
|
||||
|
||||
case 0x8: /* picture coding extension */
|
||||
|
||||
priv->picture.mpeg12.f_code[0][0] = vl_vlc_get_uimsbf(vlc, 4) - 1;
|
||||
priv->picture.mpeg12.f_code[0][1] = vl_vlc_get_uimsbf(vlc, 4) - 1;
|
||||
priv->picture.mpeg12.f_code[1][0] = vl_vlc_get_uimsbf(vlc, 4) - 1;
|
||||
priv->picture.mpeg12.f_code[1][1] = vl_vlc_get_uimsbf(vlc, 4) - 1;
|
||||
priv->picture.mpeg12.intra_dc_precision = vl_vlc_get_uimsbf(vlc, 2);
|
||||
priv->picture.mpeg12.picture_structure = vl_vlc_get_uimsbf(vlc, 2);
|
||||
priv->picture.mpeg12.top_field_first = vl_vlc_get_uimsbf(vlc, 1);
|
||||
priv->picture.mpeg12.frame_pred_frame_dct = vl_vlc_get_uimsbf(vlc, 1);
|
||||
priv->picture.mpeg12.concealment_motion_vectors = vl_vlc_get_uimsbf(vlc, 1);
|
||||
priv->picture.mpeg12.q_scale_type = vl_vlc_get_uimsbf(vlc, 1);
|
||||
priv->picture.mpeg12.intra_vlc_format = vl_vlc_get_uimsbf(vlc, 1);
|
||||
priv->picture.mpeg12.alternate_scan = vl_vlc_get_uimsbf(vlc, 1);
|
||||
|
||||
/* repeat_first_field */
|
||||
vl_vlc_get_uimsbf(vlc, 1);
|
||||
|
||||
/* chroma_420_type */
|
||||
vl_vlc_get_uimsbf(vlc, 1);
|
||||
|
||||
vl_vlc_fillbits(vlc);
|
||||
|
||||
/* progressive_frame */
|
||||
vl_vlc_get_uimsbf(vlc, 1);
|
||||
|
||||
/* composite_display_flag */
|
||||
if (vl_vlc_get_uimsbf(vlc, 1)) {
|
||||
|
||||
/* v_axis */
|
||||
vl_vlc_get_uimsbf(vlc, 1);
|
||||
|
||||
/* field_sequence */
|
||||
vl_vlc_get_uimsbf(vlc, 3);
|
||||
|
||||
/* sub_carrier */
|
||||
vl_vlc_get_uimsbf(vlc, 1);
|
||||
|
||||
/* burst_amplitude */
|
||||
vl_vlc_get_uimsbf(vlc, 7);
|
||||
|
||||
/* sub_carrier_phase */
|
||||
vl_vlc_get_uimsbf(vlc, 8);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (code <= 0xAF) {
|
||||
/* slice start */
|
||||
unsigned bytes = (vl_vlc_valid_bits(vlc) / 8) + 4;
|
||||
uint8_t buf[12];
|
||||
const void *ptr = buf;
|
||||
unsigned i;
|
||||
|
||||
if (!priv->frame_started)
|
||||
BeginFrame(priv);
|
||||
|
||||
buf[0] = 0x00;
|
||||
buf[1] = 0x00;
|
||||
buf[2] = 0x01;
|
||||
buf[3] = code;
|
||||
for (i = 4; i < bytes; ++i)
|
||||
buf[i] = vl_vlc_get_uimsbf(vlc, 8);
|
||||
|
||||
priv->codec->decode_bitstream(priv->codec, priv->target, &priv->picture.base,
|
||||
1, &ptr, &bytes);
|
||||
|
||||
priv->bytes_left = vl_vlc_bits_left(vlc) / 8;
|
||||
priv->slice = vlc->data;
|
||||
|
||||
} else if (code == 0xB2) {
|
||||
/* user data start */
|
||||
|
||||
} else if (code == 0xB4) {
|
||||
/* sequence error */
|
||||
} else if (code == 0xB7) {
|
||||
/* sequence end */
|
||||
} else if (code == 0xB8) {
|
||||
/* group start */
|
||||
} else if (code >= 0xB9) {
|
||||
/* system start */
|
||||
} else {
|
||||
/* reserved */
|
||||
}
|
||||
|
||||
/* resync to byte boundary */
|
||||
vl_vlc_eatbits(vlc, vl_vlc_valid_bits(vlc) % 8);
|
||||
}
|
||||
@@ -1,935 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Christian König <christian.koenig@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <OMX_Video.h>
|
||||
|
||||
#include <bellagio/omxcore.h>
|
||||
#include <bellagio/omx_base_video_port.h>
|
||||
|
||||
#include "pipe/p_screen.h"
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
#include "vl/vl_codec.h"
|
||||
|
||||
#include "entrypoint.h"
|
||||
#include "vid_enc.h"
|
||||
#include "vid_omx_common.h"
|
||||
#include "vid_enc_common.h"
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING name);
|
||||
static OMX_ERRORTYPE vid_enc_Destructor(OMX_COMPONENTTYPE *comp);
|
||||
static OMX_ERRORTYPE vid_enc_SetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param);
|
||||
static OMX_ERRORTYPE vid_enc_GetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param);
|
||||
static OMX_ERRORTYPE vid_enc_SetConfig(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR config);
|
||||
static OMX_ERRORTYPE vid_enc_GetConfig(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR config);
|
||||
static OMX_ERRORTYPE vid_enc_MessageHandler(OMX_COMPONENTTYPE *comp, internalRequestMessageType *msg);
|
||||
static OMX_ERRORTYPE vid_enc_AllocateInBuffer(omx_base_PortType *port, OMX_INOUT OMX_BUFFERHEADERTYPE **buf,
|
||||
OMX_IN OMX_U32 idx, OMX_IN OMX_PTR private, OMX_IN OMX_U32 size);
|
||||
static OMX_ERRORTYPE vid_enc_UseInBuffer(omx_base_PortType *port, OMX_BUFFERHEADERTYPE **buf, OMX_U32 idx,
|
||||
OMX_PTR private, OMX_U32 size, OMX_U8 *mem);
|
||||
static OMX_ERRORTYPE vid_enc_FreeInBuffer(omx_base_PortType *port, OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf);
|
||||
static OMX_ERRORTYPE vid_enc_EncodeFrame(omx_base_PortType *port, OMX_BUFFERHEADERTYPE *buf);
|
||||
static OMX_ERRORTYPE vid_enc_AllocateOutBuffer(omx_base_PortType *comp, OMX_INOUT OMX_BUFFERHEADERTYPE **buf,
|
||||
OMX_IN OMX_U32 idx, OMX_IN OMX_PTR private, OMX_IN OMX_U32 size);
|
||||
static OMX_ERRORTYPE vid_enc_FreeOutBuffer(omx_base_PortType *port, OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf);
|
||||
static void vid_enc_BufferEncoded(OMX_COMPONENTTYPE *comp, OMX_BUFFERHEADERTYPE* input, OMX_BUFFERHEADERTYPE* output);
|
||||
|
||||
OMX_ERRORTYPE vid_enc_LoaderComponent(stLoaderComponentType *comp)
|
||||
{
|
||||
comp->componentVersion.s.nVersionMajor = 0;
|
||||
comp->componentVersion.s.nVersionMinor = 0;
|
||||
comp->componentVersion.s.nRevision = 0;
|
||||
comp->componentVersion.s.nStep = 1;
|
||||
comp->name_specific_length = 1;
|
||||
comp->constructor = vid_enc_Constructor;
|
||||
|
||||
comp->name = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (!comp->name)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
comp->name_specific = CALLOC(1, sizeof(char *));
|
||||
if (!comp->name_specific)
|
||||
goto error_arrays;
|
||||
|
||||
comp->role_specific = CALLOC(1, sizeof(char *));
|
||||
if (!comp->role_specific)
|
||||
goto error_arrays;
|
||||
|
||||
comp->name_specific[0] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->name_specific[0] == NULL)
|
||||
goto error_specific;
|
||||
|
||||
comp->role_specific[0] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
|
||||
if (comp->role_specific[0] == NULL)
|
||||
goto error_specific;
|
||||
|
||||
strcpy(comp->name, OMX_VID_ENC_BASE_NAME);
|
||||
strcpy(comp->name_specific[0], OMX_VID_ENC_AVC_NAME);
|
||||
strcpy(comp->role_specific[0], OMX_VID_ENC_AVC_ROLE);
|
||||
|
||||
return OMX_ErrorNone;
|
||||
|
||||
error_specific:
|
||||
FREE(comp->role_specific[0]);
|
||||
FREE(comp->name_specific[0]);
|
||||
|
||||
error_arrays:
|
||||
FREE(comp->role_specific);
|
||||
FREE(comp->name_specific);
|
||||
|
||||
FREE(comp->name);
|
||||
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING name)
|
||||
{
|
||||
vid_enc_PrivateType *priv;
|
||||
omx_base_video_PortType *port;
|
||||
struct pipe_screen *screen;
|
||||
OMX_ERRORTYPE r;
|
||||
int i;
|
||||
|
||||
assert(!comp->pComponentPrivate);
|
||||
|
||||
priv = comp->pComponentPrivate = CALLOC(1, sizeof(vid_enc_PrivateType));
|
||||
if (!priv)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
r = omx_base_filter_Constructor(comp, name);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
priv->BufferMgmtCallback = vid_enc_BufferEncoded;
|
||||
priv->messageHandler = vid_enc_MessageHandler;
|
||||
priv->destructor = vid_enc_Destructor;
|
||||
|
||||
comp->SetParameter = vid_enc_SetParameter;
|
||||
comp->GetParameter = vid_enc_GetParameter;
|
||||
comp->GetConfig = vid_enc_GetConfig;
|
||||
comp->SetConfig = vid_enc_SetConfig;
|
||||
|
||||
priv->screen = omx_get_screen();
|
||||
if (!priv->screen)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
screen = priv->screen->pscreen;
|
||||
if (!vl_codec_supported(screen, PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH, true))
|
||||
return OMX_ErrorBadParameter;
|
||||
|
||||
priv->s_pipe = pipe_create_multimedia_context(screen);
|
||||
if (!priv->s_pipe)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
enc_InitCompute_common(priv);
|
||||
|
||||
if (!vl_compositor_init(&priv->compositor, priv->s_pipe)) {
|
||||
priv->s_pipe->destroy(priv->s_pipe);
|
||||
priv->s_pipe = NULL;
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
if (!vl_compositor_init_state(&priv->cstate, priv->s_pipe)) {
|
||||
vl_compositor_cleanup(&priv->compositor);
|
||||
priv->s_pipe->destroy(priv->s_pipe);
|
||||
priv->s_pipe = NULL;
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
priv->t_pipe = pipe_create_multimedia_context(screen);
|
||||
if (!priv->t_pipe)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
priv->sPortTypesParam[OMX_PortDomainVideo].nStartPortNumber = 0;
|
||||
priv->sPortTypesParam[OMX_PortDomainVideo].nPorts = 2;
|
||||
priv->ports = CALLOC(2, sizeof(omx_base_PortType *));
|
||||
if (!priv->ports)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
for (i = 0; i < 2; ++i) {
|
||||
priv->ports[i] = CALLOC(1, sizeof(omx_base_video_PortType));
|
||||
if (!priv->ports[i])
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
base_video_port_Constructor(comp, &priv->ports[i], i, i == 0);
|
||||
}
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_INPUTPORT_INDEX];
|
||||
port->sPortParam.format.video.nFrameWidth = 176;
|
||||
port->sPortParam.format.video.nFrameHeight = 144;
|
||||
port->sPortParam.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
|
||||
port->sVideoParam.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
|
||||
port->sPortParam.nBufferCountActual = 8;
|
||||
port->sPortParam.nBufferCountMin = 4;
|
||||
|
||||
port->Port_SendBufferFunction = vid_enc_EncodeFrame;
|
||||
port->Port_AllocateBuffer = vid_enc_AllocateInBuffer;
|
||||
port->Port_UseBuffer = vid_enc_UseInBuffer;
|
||||
port->Port_FreeBuffer = vid_enc_FreeInBuffer;
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_OUTPUTPORT_INDEX];
|
||||
strcpy(port->sPortParam.format.video.cMIMEType,"video/H264");
|
||||
port->sPortParam.format.video.nFrameWidth = 176;
|
||||
port->sPortParam.format.video.nFrameHeight = 144;
|
||||
port->sPortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
|
||||
port->sVideoParam.eCompressionFormat = OMX_VIDEO_CodingAVC;
|
||||
|
||||
port->Port_AllocateBuffer = vid_enc_AllocateOutBuffer;
|
||||
port->Port_FreeBuffer = vid_enc_FreeOutBuffer;
|
||||
|
||||
priv->bitrate.eControlRate = OMX_Video_ControlRateDisable;
|
||||
priv->bitrate.nTargetBitrate = 0;
|
||||
|
||||
priv->quant.nQpI = OMX_VID_ENC_QUANT_I_FRAMES_DEFAULT;
|
||||
priv->quant.nQpP = OMX_VID_ENC_QUANT_P_FRAMES_DEFAULT;
|
||||
priv->quant.nQpB = OMX_VID_ENC_QUANT_B_FRAMES_DEFAULT;
|
||||
|
||||
priv->profile_level.eProfile = OMX_VIDEO_AVCProfileBaseline;
|
||||
priv->profile_level.eLevel = OMX_VIDEO_AVCLevel51;
|
||||
|
||||
priv->force_pic_type.IntraRefreshVOP = OMX_FALSE;
|
||||
priv->frame_num = 0;
|
||||
priv->pic_order_cnt = 0;
|
||||
priv->restricted_b_frames = debug_get_bool_option("OMX_USE_RESTRICTED_B_FRAMES", false);
|
||||
|
||||
priv->scale.xWidth = OMX_VID_ENC_SCALING_WIDTH_DEFAULT;
|
||||
priv->scale.xHeight = OMX_VID_ENC_SCALING_WIDTH_DEFAULT;
|
||||
|
||||
list_inithead(&priv->free_tasks);
|
||||
list_inithead(&priv->used_tasks);
|
||||
list_inithead(&priv->b_frames);
|
||||
list_inithead(&priv->stacked_tasks);
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_Destructor(OMX_COMPONENTTYPE *comp)
|
||||
{
|
||||
vid_enc_PrivateType* priv = comp->pComponentPrivate;
|
||||
int i;
|
||||
|
||||
enc_ReleaseTasks(&priv->free_tasks);
|
||||
enc_ReleaseTasks(&priv->used_tasks);
|
||||
enc_ReleaseTasks(&priv->b_frames);
|
||||
enc_ReleaseTasks(&priv->stacked_tasks);
|
||||
|
||||
if (priv->ports) {
|
||||
for (i = 0; i < priv->sPortTypesParam[OMX_PortDomainVideo].nPorts; ++i) {
|
||||
if(priv->ports[i])
|
||||
priv->ports[i]->PortDestructor(priv->ports[i]);
|
||||
}
|
||||
FREE(priv->ports);
|
||||
priv->ports=NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < OMX_VID_ENC_NUM_SCALING_BUFFERS; ++i)
|
||||
if (priv->scale_buffer[i])
|
||||
priv->scale_buffer[i]->destroy(priv->scale_buffer[i]);
|
||||
|
||||
if (priv->s_pipe) {
|
||||
vl_compositor_cleanup_state(&priv->cstate);
|
||||
vl_compositor_cleanup(&priv->compositor);
|
||||
enc_ReleaseCompute_common(priv);
|
||||
priv->s_pipe->destroy(priv->s_pipe);
|
||||
}
|
||||
|
||||
if (priv->t_pipe)
|
||||
priv->t_pipe->destroy(priv->t_pipe);
|
||||
|
||||
if (priv->screen)
|
||||
omx_put_screen();
|
||||
|
||||
return omx_workaround_Destructor(comp);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE enc_AllocateBackTexture(omx_base_PortType *port,
|
||||
struct pipe_resource **resource,
|
||||
struct pipe_transfer **transfer,
|
||||
OMX_U8 **map)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
struct pipe_resource buf_templ;
|
||||
struct pipe_box box = {};
|
||||
OMX_U8 *ptr;
|
||||
|
||||
memset(&buf_templ, 0, sizeof buf_templ);
|
||||
buf_templ.target = PIPE_TEXTURE_2D;
|
||||
buf_templ.format = PIPE_FORMAT_I8_UNORM;
|
||||
buf_templ.bind = PIPE_BIND_LINEAR;
|
||||
buf_templ.usage = PIPE_USAGE_STAGING;
|
||||
buf_templ.flags = 0;
|
||||
buf_templ.width0 = port->sPortParam.format.video.nFrameWidth;
|
||||
buf_templ.height0 = port->sPortParam.format.video.nFrameHeight * 3 / 2;
|
||||
buf_templ.depth0 = 1;
|
||||
buf_templ.array_size = 1;
|
||||
|
||||
*resource = priv->s_pipe->screen->resource_create(priv->s_pipe->screen, &buf_templ);
|
||||
if (!*resource)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
box.width = (*resource)->width0;
|
||||
box.height = (*resource)->height0;
|
||||
box.depth = (*resource)->depth0;
|
||||
ptr = priv->s_pipe->texture_map(priv->s_pipe, *resource, 0, PIPE_MAP_WRITE, &box, transfer);
|
||||
if (map)
|
||||
*map = ptr;
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_SetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param)
|
||||
{
|
||||
OMX_COMPONENTTYPE *comp = handle;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
if (!param)
|
||||
return OMX_ErrorBadParameter;
|
||||
|
||||
switch(idx) {
|
||||
case OMX_IndexParamPortDefinition: {
|
||||
OMX_PARAM_PORTDEFINITIONTYPE *def = param;
|
||||
|
||||
r = omx_base_component_SetParameter(handle, idx, param);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (def->nPortIndex == OMX_BASE_FILTER_INPUTPORT_INDEX) {
|
||||
omx_base_video_PortType *port;
|
||||
unsigned framesize;
|
||||
struct pipe_resource *resource;
|
||||
struct pipe_transfer *transfer;
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_INPUTPORT_INDEX];
|
||||
enc_AllocateBackTexture(priv->ports[OMX_BASE_FILTER_INPUTPORT_INDEX],
|
||||
&resource, &transfer, NULL);
|
||||
port->sPortParam.format.video.nStride = transfer->stride;
|
||||
pipe_texture_unmap(priv->s_pipe, transfer);
|
||||
pipe_resource_reference(&resource, NULL);
|
||||
|
||||
framesize = port->sPortParam.format.video.nStride *
|
||||
port->sPortParam.format.video.nFrameHeight;
|
||||
port->sPortParam.format.video.nSliceHeight = port->sPortParam.format.video.nFrameHeight;
|
||||
port->sPortParam.nBufferSize = framesize * 3 / 2;
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_OUTPUTPORT_INDEX];
|
||||
port->sPortParam.nBufferSize = framesize * 512 / (16*16);
|
||||
|
||||
priv->frame_rate = def->format.video.xFramerate;
|
||||
|
||||
priv->callbacks->EventHandler(comp, priv->callbackData, OMX_EventPortSettingsChanged,
|
||||
OMX_BASE_FILTER_OUTPUTPORT_INDEX, 0, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OMX_IndexParamStandardComponentRole: {
|
||||
OMX_PARAM_COMPONENTROLETYPE *role = param;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_PARAM_COMPONENTROLETYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (strcmp((char *)role->cRole, OMX_VID_ENC_AVC_ROLE)) {
|
||||
return OMX_ErrorBadParameter;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case OMX_IndexParamVideoBitrate: {
|
||||
OMX_VIDEO_PARAM_BITRATETYPE *bitrate = param;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_VIDEO_PARAM_BITRATETYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
priv->bitrate = *bitrate;
|
||||
|
||||
break;
|
||||
}
|
||||
case OMX_IndexParamVideoQuantization: {
|
||||
OMX_VIDEO_PARAM_QUANTIZATIONTYPE *quant = param;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
priv->quant = *quant;
|
||||
|
||||
break;
|
||||
}
|
||||
case OMX_IndexParamVideoProfileLevelCurrent: {
|
||||
OMX_VIDEO_PARAM_PROFILELEVELTYPE *profile_level = param;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
priv->profile_level = *profile_level;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return omx_base_component_SetParameter(handle, idx, param);
|
||||
}
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_GetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param)
|
||||
{
|
||||
OMX_COMPONENTTYPE *comp = handle;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
if (!param)
|
||||
return OMX_ErrorBadParameter;
|
||||
|
||||
switch(idx) {
|
||||
case OMX_IndexParamStandardComponentRole: {
|
||||
OMX_PARAM_COMPONENTROLETYPE *role = param;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_PARAM_COMPONENTROLETYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
strcpy((char *)role->cRole, OMX_VID_ENC_AVC_ROLE);
|
||||
break;
|
||||
}
|
||||
case OMX_IndexParamVideoInit:
|
||||
r = checkHeader(param, sizeof(OMX_PORT_PARAM_TYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
memcpy(param, &priv->sPortTypesParam[OMX_PortDomainVideo], sizeof(OMX_PORT_PARAM_TYPE));
|
||||
break;
|
||||
|
||||
case OMX_IndexParamVideoPortFormat: {
|
||||
OMX_VIDEO_PARAM_PORTFORMATTYPE *format = param;
|
||||
omx_base_video_PortType *port;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (format->nPortIndex > 1)
|
||||
return OMX_ErrorBadPortIndex;
|
||||
if (format->nIndex >= 1)
|
||||
return OMX_ErrorNoMore;
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[format->nPortIndex];
|
||||
memcpy(format, &port->sVideoParam, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
|
||||
break;
|
||||
}
|
||||
case OMX_IndexParamVideoBitrate: {
|
||||
OMX_VIDEO_PARAM_BITRATETYPE *bitrate = param;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_VIDEO_PARAM_BITRATETYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
bitrate->eControlRate = priv->bitrate.eControlRate;
|
||||
bitrate->nTargetBitrate = priv->bitrate.nTargetBitrate;
|
||||
|
||||
break;
|
||||
}
|
||||
case OMX_IndexParamVideoQuantization: {
|
||||
OMX_VIDEO_PARAM_QUANTIZATIONTYPE *quant = param;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
quant->nQpI = priv->quant.nQpI;
|
||||
quant->nQpP = priv->quant.nQpP;
|
||||
quant->nQpB = priv->quant.nQpB;
|
||||
|
||||
break;
|
||||
}
|
||||
case OMX_IndexParamVideoProfileLevelCurrent: {
|
||||
OMX_VIDEO_PARAM_PROFILELEVELTYPE *profile_level = param;
|
||||
|
||||
r = checkHeader(param, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
profile_level->eProfile = priv->profile_level.eProfile;
|
||||
profile_level->eLevel = priv->profile_level.eLevel;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return omx_base_component_GetParameter(handle, idx, param);
|
||||
}
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_SetConfig(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR config)
|
||||
{
|
||||
OMX_COMPONENTTYPE *comp = handle;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
OMX_ERRORTYPE r;
|
||||
int i;
|
||||
|
||||
if (!config)
|
||||
return OMX_ErrorBadParameter;
|
||||
|
||||
switch(idx) {
|
||||
case OMX_IndexConfigVideoIntraVOPRefresh: {
|
||||
OMX_CONFIG_INTRAREFRESHVOPTYPE *type = config;
|
||||
|
||||
r = checkHeader(config, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
priv->force_pic_type = *type;
|
||||
|
||||
break;
|
||||
}
|
||||
case OMX_IndexConfigCommonScale: {
|
||||
OMX_CONFIG_SCALEFACTORTYPE *scale = config;
|
||||
|
||||
r = checkHeader(config, sizeof(OMX_CONFIG_SCALEFACTORTYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (scale->xWidth < 176 || scale->xHeight < 144)
|
||||
return OMX_ErrorBadParameter;
|
||||
|
||||
for (i = 0; i < OMX_VID_ENC_NUM_SCALING_BUFFERS; ++i) {
|
||||
if (priv->scale_buffer[i]) {
|
||||
priv->scale_buffer[i]->destroy(priv->scale_buffer[i]);
|
||||
priv->scale_buffer[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
priv->scale = *scale;
|
||||
if (priv->scale.xWidth != 0xffffffff && priv->scale.xHeight != 0xffffffff) {
|
||||
struct pipe_video_buffer templat = {};
|
||||
|
||||
templat.buffer_format = PIPE_FORMAT_NV12;
|
||||
templat.width = priv->scale.xWidth;
|
||||
templat.height = priv->scale.xHeight;
|
||||
templat.interlaced = false;
|
||||
for (i = 0; i < OMX_VID_ENC_NUM_SCALING_BUFFERS; ++i) {
|
||||
priv->scale_buffer[i] = priv->s_pipe->create_video_buffer(priv->s_pipe, &templat);
|
||||
if (!priv->scale_buffer[i])
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return omx_base_component_SetConfig(handle, idx, config);
|
||||
}
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_GetConfig(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR config)
|
||||
{
|
||||
OMX_COMPONENTTYPE *comp = handle;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
if (!config)
|
||||
return OMX_ErrorBadParameter;
|
||||
|
||||
switch(idx) {
|
||||
case OMX_IndexConfigCommonScale: {
|
||||
OMX_CONFIG_SCALEFACTORTYPE *scale = config;
|
||||
|
||||
r = checkHeader(config, sizeof(OMX_CONFIG_SCALEFACTORTYPE));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
scale->xWidth = priv->scale.xWidth;
|
||||
scale->xHeight = priv->scale.xHeight;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return omx_base_component_GetConfig(handle, idx, config);
|
||||
}
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_MessageHandler(OMX_COMPONENTTYPE* comp, internalRequestMessageType *msg)
|
||||
{
|
||||
vid_enc_PrivateType* priv = comp->pComponentPrivate;
|
||||
|
||||
if (msg->messageType == OMX_CommandStateSet) {
|
||||
if ((msg->messageParam == OMX_StateIdle ) && (priv->state == OMX_StateLoaded)) {
|
||||
|
||||
struct pipe_video_codec templat = {};
|
||||
omx_base_video_PortType *port;
|
||||
|
||||
port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_INPUTPORT_INDEX];
|
||||
|
||||
templat.profile = enc_TranslateOMXProfileToPipe(priv->profile_level.eProfile);
|
||||
templat.level = enc_TranslateOMXLevelToPipe(priv->profile_level.eLevel);
|
||||
templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
|
||||
templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
|
||||
templat.width = priv->scale_buffer[priv->current_scale_buffer] ?
|
||||
priv->scale.xWidth : port->sPortParam.format.video.nFrameWidth;
|
||||
templat.height = priv->scale_buffer[priv->current_scale_buffer] ?
|
||||
priv->scale.xHeight : port->sPortParam.format.video.nFrameHeight;
|
||||
|
||||
if (templat.profile == PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE) {
|
||||
struct pipe_screen *screen = priv->screen->pscreen;
|
||||
templat.max_references = 1;
|
||||
priv->stacked_frames_num =
|
||||
screen->get_video_param(screen,
|
||||
PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH,
|
||||
PIPE_VIDEO_ENTRYPOINT_ENCODE,
|
||||
PIPE_VIDEO_CAP_STACKED_FRAMES);
|
||||
} else {
|
||||
templat.max_references = OMX_VID_ENC_P_PERIOD_DEFAULT;
|
||||
priv->stacked_frames_num = 1;
|
||||
}
|
||||
priv->codec = priv->s_pipe->create_video_codec(priv->s_pipe, &templat);
|
||||
|
||||
} else if ((msg->messageParam == OMX_StateLoaded) && (priv->state == OMX_StateIdle)) {
|
||||
if (priv->codec) {
|
||||
priv->codec->destroy(priv->codec);
|
||||
priv->codec = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return omx_base_component_MessageHandler(comp, msg);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_AllocateInBuffer(omx_base_PortType *port, OMX_INOUT OMX_BUFFERHEADERTYPE **buf,
|
||||
OMX_IN OMX_U32 idx, OMX_IN OMX_PTR private, OMX_IN OMX_U32 size)
|
||||
{
|
||||
struct input_buf_private *inp;
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
r = base_port_AllocateBuffer(port, buf, idx, private, size);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
inp = (*buf)->pInputPortPrivate = CALLOC_STRUCT(input_buf_private);
|
||||
if (!inp) {
|
||||
base_port_FreeBuffer(port, idx, *buf);
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
list_inithead(&inp->tasks);
|
||||
|
||||
FREE((*buf)->pBuffer);
|
||||
r = enc_AllocateBackTexture(port, &inp->resource, &inp->transfer, &(*buf)->pBuffer);
|
||||
if (r) {
|
||||
FREE(inp);
|
||||
base_port_FreeBuffer(port, idx, *buf);
|
||||
return r;
|
||||
}
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_UseInBuffer(omx_base_PortType *port, OMX_BUFFERHEADERTYPE **buf, OMX_U32 idx,
|
||||
OMX_PTR private, OMX_U32 size, OMX_U8 *mem)
|
||||
{
|
||||
struct input_buf_private *inp;
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
r = base_port_UseBuffer(port, buf, idx, private, size, mem);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
inp = (*buf)->pInputPortPrivate = CALLOC_STRUCT(input_buf_private);
|
||||
if (!inp) {
|
||||
base_port_FreeBuffer(port, idx, *buf);
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
list_inithead(&inp->tasks);
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_FreeInBuffer(omx_base_PortType *port, OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
struct input_buf_private *inp = buf->pInputPortPrivate;
|
||||
|
||||
if (inp) {
|
||||
enc_ReleaseTasks(&inp->tasks);
|
||||
if (inp->transfer)
|
||||
pipe_texture_unmap(priv->s_pipe, inp->transfer);
|
||||
pipe_resource_reference(&inp->resource, NULL);
|
||||
FREE(inp);
|
||||
}
|
||||
buf->pBuffer = NULL;
|
||||
|
||||
return base_port_FreeBuffer(port, idx, buf);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_AllocateOutBuffer(omx_base_PortType *port, OMX_INOUT OMX_BUFFERHEADERTYPE **buf,
|
||||
OMX_IN OMX_U32 idx, OMX_IN OMX_PTR private, OMX_IN OMX_U32 size)
|
||||
{
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
r = base_port_AllocateBuffer(port, buf, idx, private, size);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
FREE((*buf)->pBuffer);
|
||||
(*buf)->pBuffer = NULL;
|
||||
(*buf)->pOutputPortPrivate = CALLOC(1, sizeof(struct output_buf_private));
|
||||
if (!(*buf)->pOutputPortPrivate) {
|
||||
base_port_FreeBuffer(port, idx, *buf);
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_FreeOutBuffer(omx_base_PortType *port, OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
|
||||
if (buf->pOutputPortPrivate) {
|
||||
struct output_buf_private *outp = buf->pOutputPortPrivate;
|
||||
if (outp->transfer)
|
||||
pipe_buffer_unmap(priv->t_pipe, outp->transfer);
|
||||
pipe_resource_reference(&outp->bitstream, NULL);
|
||||
FREE(outp);
|
||||
buf->pOutputPortPrivate = NULL;
|
||||
}
|
||||
buf->pBuffer = NULL;
|
||||
|
||||
return base_port_FreeBuffer(port, idx, buf);
|
||||
}
|
||||
|
||||
static struct encode_task *enc_NeedTask(omx_base_PortType *port)
|
||||
{
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE *def = &port->sPortParam.format.video;
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
|
||||
return enc_NeedTask_common(priv, def);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE enc_LoadImage(omx_base_PortType *port, OMX_BUFFERHEADERTYPE *buf,
|
||||
struct pipe_video_buffer *vbuf)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE *def = &port->sPortParam.format.video;
|
||||
return enc_LoadImage_common(priv, def, buf, vbuf);
|
||||
}
|
||||
|
||||
static void enc_ScaleInput(omx_base_PortType *port, struct pipe_video_buffer **vbuf, unsigned *size)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE *def = &port->sPortParam.format.video;
|
||||
enc_ScaleInput_common(priv, def, vbuf, size);
|
||||
}
|
||||
|
||||
static void enc_ControlPicture(omx_base_PortType *port, struct pipe_h264_enc_picture_desc *picture)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
enc_ControlPicture_common(priv, picture);
|
||||
}
|
||||
|
||||
static void enc_HandleTask(omx_base_PortType *port, struct encode_task *task,
|
||||
enum pipe_h2645_enc_picture_type picture_type)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
unsigned size = priv->ports[OMX_BASE_FILTER_OUTPUTPORT_INDEX]->sPortParam.nBufferSize;
|
||||
struct pipe_video_buffer *vbuf = task->buf;
|
||||
struct pipe_h264_enc_picture_desc picture = {};
|
||||
|
||||
/* -------------- scale input image --------- */
|
||||
enc_ScaleInput(port, &vbuf, &size);
|
||||
priv->s_pipe->flush(priv->s_pipe, NULL, 0);
|
||||
|
||||
/* -------------- allocate output buffer --------- */
|
||||
task->bitstream = pipe_buffer_create(priv->s_pipe->screen,
|
||||
PIPE_BIND_VERTEX_BUFFER,
|
||||
PIPE_USAGE_STAGING, /* map for read */
|
||||
size);
|
||||
|
||||
picture.picture_type = picture_type;
|
||||
picture.pic_order_cnt = task->pic_order_cnt;
|
||||
picture.base.profile = enc_TranslateOMXProfileToPipe(priv->profile_level.eProfile);
|
||||
picture.base.entry_point = PIPE_VIDEO_ENTRYPOINT_ENCODE;
|
||||
if (priv->restricted_b_frames && picture_type == PIPE_H2645_ENC_PICTURE_TYPE_B)
|
||||
picture.not_referenced = true;
|
||||
enc_ControlPicture(port, &picture);
|
||||
|
||||
/* -------------- encode frame --------- */
|
||||
priv->codec->begin_frame(priv->codec, vbuf, &picture.base);
|
||||
priv->codec->encode_bitstream(priv->codec, vbuf, task->bitstream, &task->feedback);
|
||||
priv->codec->end_frame(priv->codec, vbuf, &picture.base);
|
||||
}
|
||||
|
||||
static void enc_ClearBframes(omx_base_PortType *port, struct input_buf_private *inp)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
struct encode_task *task;
|
||||
|
||||
if (list_is_empty(&priv->b_frames))
|
||||
return;
|
||||
|
||||
task = list_entry(priv->b_frames.prev, struct encode_task, list);
|
||||
list_del(&task->list);
|
||||
|
||||
/* promote last from to P frame */
|
||||
priv->ref_idx_l0 = priv->ref_idx_l1;
|
||||
enc_HandleTask(port, task, PIPE_H2645_ENC_PICTURE_TYPE_P);
|
||||
list_addtail(&task->list, &inp->tasks);
|
||||
priv->ref_idx_l1 = priv->frame_num++;
|
||||
|
||||
/* handle B frames */
|
||||
LIST_FOR_EACH_ENTRY(task, &priv->b_frames, list) {
|
||||
enc_HandleTask(port, task, PIPE_H2645_ENC_PICTURE_TYPE_B);
|
||||
if (!priv->restricted_b_frames)
|
||||
priv->ref_idx_l0 = priv->frame_num;
|
||||
priv->frame_num++;
|
||||
}
|
||||
|
||||
enc_MoveTasks(&priv->b_frames, &inp->tasks);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE vid_enc_EncodeFrame(omx_base_PortType *port, OMX_BUFFERHEADERTYPE *buf)
|
||||
{
|
||||
OMX_COMPONENTTYPE* comp = port->standCompContainer;
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
struct input_buf_private *inp = buf->pInputPortPrivate;
|
||||
enum pipe_h2645_enc_picture_type picture_type;
|
||||
struct encode_task *task;
|
||||
unsigned stacked_num = 0;
|
||||
OMX_ERRORTYPE err;
|
||||
|
||||
enc_MoveTasks(&inp->tasks, &priv->free_tasks);
|
||||
task = enc_NeedTask(port);
|
||||
if (!task)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
if (buf->nFilledLen == 0) {
|
||||
if (buf->nFlags & OMX_BUFFERFLAG_EOS) {
|
||||
buf->nFilledLen = buf->nAllocLen;
|
||||
enc_ClearBframes(port, inp);
|
||||
enc_MoveTasks(&priv->stacked_tasks, &inp->tasks);
|
||||
priv->codec->flush(priv->codec);
|
||||
}
|
||||
return base_port_SendBufferFunction(port, buf);
|
||||
}
|
||||
|
||||
if (buf->pOutputPortPrivate) {
|
||||
struct pipe_video_buffer *vbuf = buf->pOutputPortPrivate;
|
||||
buf->pOutputPortPrivate = task->buf;
|
||||
task->buf = vbuf;
|
||||
} else {
|
||||
/* ------- load input image into video buffer ---- */
|
||||
err = enc_LoadImage(port, buf, task->buf);
|
||||
if (err != OMX_ErrorNone) {
|
||||
FREE(task);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------- determine picture type --------- */
|
||||
if (!(priv->pic_order_cnt % OMX_VID_ENC_IDR_PERIOD_DEFAULT) ||
|
||||
priv->force_pic_type.IntraRefreshVOP) {
|
||||
enc_ClearBframes(port, inp);
|
||||
picture_type = PIPE_H2645_ENC_PICTURE_TYPE_IDR;
|
||||
priv->force_pic_type.IntraRefreshVOP = OMX_FALSE;
|
||||
priv->frame_num = 0;
|
||||
priv->pic_order_cnt = 0;
|
||||
} else if (priv->codec->profile == PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE ||
|
||||
!(priv->pic_order_cnt % OMX_VID_ENC_P_PERIOD_DEFAULT) ||
|
||||
(buf->nFlags & OMX_BUFFERFLAG_EOS)) {
|
||||
picture_type = PIPE_H2645_ENC_PICTURE_TYPE_P;
|
||||
} else {
|
||||
picture_type = PIPE_H2645_ENC_PICTURE_TYPE_B;
|
||||
}
|
||||
|
||||
task->pic_order_cnt = priv->pic_order_cnt++;
|
||||
|
||||
if (picture_type == PIPE_H2645_ENC_PICTURE_TYPE_B) {
|
||||
/* put frame at the tail of the queue */
|
||||
list_addtail(&task->list, &priv->b_frames);
|
||||
} else {
|
||||
/* handle I or P frame */
|
||||
priv->ref_idx_l0 = priv->ref_idx_l1;
|
||||
enc_HandleTask(port, task, picture_type);
|
||||
list_addtail(&task->list, &priv->stacked_tasks);
|
||||
LIST_FOR_EACH_ENTRY(task, &priv->stacked_tasks, list) {
|
||||
++stacked_num;
|
||||
}
|
||||
if (stacked_num == priv->stacked_frames_num) {
|
||||
struct encode_task *t;
|
||||
t = list_entry(priv->stacked_tasks.next, struct encode_task, list);
|
||||
list_del(&t->list);
|
||||
list_addtail(&t->list, &inp->tasks);
|
||||
}
|
||||
priv->ref_idx_l1 = priv->frame_num++;
|
||||
|
||||
/* handle B frames */
|
||||
LIST_FOR_EACH_ENTRY(task, &priv->b_frames, list) {
|
||||
enc_HandleTask(port, task, PIPE_H2645_ENC_PICTURE_TYPE_B);
|
||||
if (!priv->restricted_b_frames)
|
||||
priv->ref_idx_l0 = priv->frame_num;
|
||||
priv->frame_num++;
|
||||
}
|
||||
|
||||
enc_MoveTasks(&priv->b_frames, &inp->tasks);
|
||||
}
|
||||
|
||||
if (list_is_empty(&inp->tasks))
|
||||
return port->ReturnBufferFunction(port, buf);
|
||||
else
|
||||
return base_port_SendBufferFunction(port, buf);
|
||||
}
|
||||
|
||||
static void vid_enc_BufferEncoded(OMX_COMPONENTTYPE *comp, OMX_BUFFERHEADERTYPE* input, OMX_BUFFERHEADERTYPE* output)
|
||||
{
|
||||
vid_enc_PrivateType *priv = comp->pComponentPrivate;
|
||||
vid_enc_BufferEncoded_common(priv, input, output);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Christian König <christian.koenig@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef OMX_VID_ENC_H
|
||||
#define OMX_VID_ENC_H
|
||||
|
||||
#include <OMX_Types.h>
|
||||
#include <OMX_Component.h>
|
||||
|
||||
#include <bellagio/st_static_component_loader.h>
|
||||
|
||||
#define OMX_VID_ENC_BASE_NAME "OMX.mesa.video_encoder"
|
||||
#define OMX_VID_ENC_AVC_NAME "OMX.mesa.video_encoder.avc"
|
||||
#define OMX_VID_ENC_AVC_ROLE "video_encoder.avc"
|
||||
|
||||
OMX_ERRORTYPE vid_enc_LoaderComponent(stLoaderComponentType *comp);
|
||||
|
||||
#endif
|
||||
@@ -1,55 +0,0 @@
|
||||
# Copyright © 2017, 2019 Intel Corporation
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
inc_st_omx = [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux]
|
||||
dep_st_omx = [
|
||||
dep_omx, dep_x11_xcb, dep_xcb, dep_xcb_dri2, dep_xcb_dri3, dep_libdrm,
|
||||
]
|
||||
|
||||
files_omx = files(
|
||||
'vid_dec_common.c',
|
||||
'vid_dec_h264_common.c',
|
||||
'vid_enc_common.c',
|
||||
'vid_omx_common.c'
|
||||
)
|
||||
|
||||
if with_gallium_omx == 'bellagio'
|
||||
files_omx += files(
|
||||
'bellagio/entrypoint.c',
|
||||
'bellagio/vid_dec.c',
|
||||
'bellagio/vid_dec_mpeg12.c',
|
||||
'bellagio/vid_dec_h264.c',
|
||||
'bellagio/vid_dec_h265.c',
|
||||
'bellagio/vid_dec_av1.c',
|
||||
'bellagio/vid_enc.c'
|
||||
)
|
||||
elif with_gallium_omx == 'tizonia'
|
||||
files_omx += files(
|
||||
'tizonia/entrypoint.c',
|
||||
'tizonia/h264d.c',
|
||||
'tizonia/h264dprc.c',
|
||||
'tizonia/h264dinport.c',
|
||||
'tizonia/h264e.c',
|
||||
'tizonia/h264eprc.c',
|
||||
'tizonia/h264einport.c',
|
||||
'tizonia/h264eoutport.c'
|
||||
)
|
||||
inc_st_omx = [
|
||||
inc_st_omx,
|
||||
inc_loader,
|
||||
inc_gbm,
|
||||
inc_st_dri,
|
||||
inc_egl,
|
||||
inc_egl_dri2,
|
||||
]
|
||||
dep_st_omx = [dep_st_omx, dep_omx_other]
|
||||
endif
|
||||
|
||||
libomx_st = static_library(
|
||||
'omx_st',
|
||||
files_omx,
|
||||
c_args : ['-fcommon'],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
include_directories : inc_st_omx,
|
||||
dependencies : [dep_st_omx, idep_mesautil],
|
||||
)
|
||||
@@ -1,158 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <tizplatform.h>
|
||||
#include <tizkernel.h>
|
||||
#include <tizscheduler.h>
|
||||
#include <tizport.h>
|
||||
#include <tizport_decls.h>
|
||||
#include <tizvideoport.h>
|
||||
#include <tizvideoport_decls.h>
|
||||
|
||||
#include "vid_dec_h264_common.h"
|
||||
#include "entrypoint.h"
|
||||
#include "h264d.h"
|
||||
#include "h264dprc.h"
|
||||
#include "h264dinport.h"
|
||||
#include "h264e.h"
|
||||
#include "h264eprc.h"
|
||||
#include "h264einport.h"
|
||||
#include "h264eoutport.h"
|
||||
#include "names.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
|
||||
DEBUG_GET_ONCE_BOOL_OPTION(mesa_enable_omx_eglimage,
|
||||
"MESA_ENABLE_OMX_EGLIMAGE",
|
||||
false)
|
||||
|
||||
static OMX_BOOL egl_image_validation_hook(const OMX_HANDLETYPE ap_hdl,
|
||||
OMX_U32 pid, OMX_PTR ap_eglimage,
|
||||
void *ap_args)
|
||||
{
|
||||
const void * p_krn = NULL;
|
||||
const tiz_port_t * p_port = NULL;
|
||||
|
||||
assert(ap_hdl);
|
||||
assert(ap_eglimage);
|
||||
assert(!ap_args);
|
||||
|
||||
if (!debug_get_option_mesa_enable_omx_eglimage()) {
|
||||
return OMX_FALSE;
|
||||
}
|
||||
|
||||
p_krn = tiz_get_krn(ap_hdl);
|
||||
p_port = tiz_krn_get_port(p_krn, pid);
|
||||
|
||||
const OMX_VIDEO_PORTDEFINITIONTYPE * p_video_portdef
|
||||
= &(p_port->portdef_.format.video);
|
||||
|
||||
if (!p_video_portdef->pNativeWindow) {
|
||||
return OMX_FALSE;
|
||||
}
|
||||
|
||||
return OMX_TRUE;
|
||||
}
|
||||
|
||||
OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE ap_hdl)
|
||||
{
|
||||
tiz_role_factory_t h264d_role;
|
||||
tiz_role_factory_t h264e_role;
|
||||
const tiz_role_factory_t * rf_list[] = {&h264d_role, &h264e_role};
|
||||
tiz_type_factory_t h264dprc_type;
|
||||
tiz_type_factory_t h264d_inport_type;
|
||||
tiz_type_factory_t h264eprc_type;
|
||||
tiz_type_factory_t h264e_inport_type;
|
||||
tiz_type_factory_t h264e_outport_type;
|
||||
const tiz_type_factory_t * tf_list[] = {&h264dprc_type,
|
||||
&h264d_inport_type,
|
||||
&h264eprc_type,
|
||||
&h264e_inport_type,
|
||||
&h264e_outport_type};
|
||||
const tiz_eglimage_hook_t egl_validation_hook = {
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX,
|
||||
egl_image_validation_hook,
|
||||
NULL
|
||||
};
|
||||
|
||||
/* Settings for roles */
|
||||
strcpy ((OMX_STRING) h264d_role.role, OMX_VID_DEC_AVC_ROLE);
|
||||
h264d_role.pf_cport = instantiate_h264d_config_port;
|
||||
h264d_role.pf_port[0] = instantiate_h264d_input_port;
|
||||
h264d_role.pf_port[1] = instantiate_h264d_output_port;
|
||||
h264d_role.nports = 2;
|
||||
h264d_role.pf_proc = instantiate_h264d_processor;
|
||||
|
||||
strcpy ((OMX_STRING) h264e_role.role, OMX_VID_ENC_AVC_ROLE);
|
||||
h264e_role.pf_cport = instantiate_h264e_config_port;
|
||||
h264e_role.pf_port[0] = instantiate_h264e_input_port;
|
||||
h264e_role.pf_port[1] = instantiate_h264e_output_port;
|
||||
h264e_role.nports = 2;
|
||||
h264e_role.pf_proc = instantiate_h264e_processor;
|
||||
|
||||
/* Settings for classes */
|
||||
strcpy ((OMX_STRING) h264dprc_type.class_name, "h264dprc_class");
|
||||
h264dprc_type.pf_class_init = h264d_prc_class_init;
|
||||
strcpy ((OMX_STRING) h264dprc_type.object_name, "h264dprc");
|
||||
h264dprc_type.pf_object_init = h264d_prc_init;
|
||||
|
||||
strcpy ((OMX_STRING) h264d_inport_type.class_name, "h264dinport_class");
|
||||
h264d_inport_type.pf_class_init = h264d_inport_class_init;
|
||||
strcpy ((OMX_STRING) h264d_inport_type.object_name, "h264dinport");
|
||||
h264d_inport_type.pf_object_init = h264d_inport_init;
|
||||
|
||||
strcpy ((OMX_STRING) h264eprc_type.class_name, "h264eprc_class");
|
||||
h264eprc_type.pf_class_init = h264e_prc_class_init;
|
||||
strcpy ((OMX_STRING) h264eprc_type.object_name, "h264eprc");
|
||||
h264eprc_type.pf_object_init = h264e_prc_init;
|
||||
|
||||
strcpy ((OMX_STRING) h264e_inport_type.class_name, "h264einport_class");
|
||||
h264e_inport_type.pf_class_init = h264e_inport_class_init;
|
||||
strcpy ((OMX_STRING) h264e_inport_type.object_name, "h264einport");
|
||||
h264e_inport_type.pf_object_init = h264e_inport_init;
|
||||
|
||||
strcpy ((OMX_STRING) h264e_outport_type.class_name, "h264eoutport_class");
|
||||
h264e_outport_type.pf_class_init = h264e_outport_class_init;
|
||||
strcpy ((OMX_STRING) h264e_outport_type.object_name, "h264eoutport");
|
||||
h264e_outport_type.pf_object_init = h264e_outport_init;
|
||||
|
||||
/* Initialize the component infrastructure */
|
||||
tiz_comp_init (ap_hdl, OMX_VID_COMP_NAME);
|
||||
|
||||
/* Classes need to be registered first */
|
||||
tiz_comp_register_types (ap_hdl, tf_list, 5);
|
||||
|
||||
/* Register the component roles */
|
||||
tiz_comp_register_roles (ap_hdl, rf_list, 2);
|
||||
|
||||
/* Register egl image validation hook for the decoder */
|
||||
tiz_check_omx (tiz_comp_register_role_eglimage_hook
|
||||
(ap_hdl, (const OMX_U8 *) OMX_VID_DEC_AVC_ROLE,
|
||||
&egl_validation_hook));
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef OMX_TIZ_ENTRYPOINT_H
|
||||
#define OMX_TIZ_ENTRYPOINT_H
|
||||
|
||||
#include "vl/vl_winsys.h"
|
||||
|
||||
PUBLIC OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE ap_hdl);
|
||||
|
||||
#endif
|
||||
@@ -1,176 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <tizport_decls.h>
|
||||
|
||||
#include "vid_dec_h264_common.h"
|
||||
|
||||
#include "h264dprc.h"
|
||||
#include "h264d.h"
|
||||
#include "names.h"
|
||||
|
||||
static OMX_VERSIONTYPE h264_decoder_version = {{0, 0, 0, 1}};
|
||||
|
||||
OMX_PTR instantiate_h264d_input_port(OMX_HANDLETYPE ap_hdl)
|
||||
{
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE portdef;
|
||||
OMX_VIDEO_PARAM_AVCTYPE avctype;
|
||||
OMX_VIDEO_CODINGTYPE encodings[] = {
|
||||
OMX_VIDEO_CodingAVC,
|
||||
OMX_VIDEO_CodingMax
|
||||
};
|
||||
OMX_COLOR_FORMATTYPE formats[] = {
|
||||
OMX_COLOR_FormatUnused,
|
||||
OMX_COLOR_FormatMax
|
||||
};
|
||||
tiz_port_options_t avc_port_opts = {
|
||||
OMX_PortDomainVideo,
|
||||
OMX_DirInput,
|
||||
OMX_VID_DEC_AVC_INPUT_PORT_MIN_BUF_COUNT,
|
||||
OMX_VID_DEC_AVC_PORT_MIN_INPUT_BUF_SIZE,
|
||||
OMX_VID_DEC_AVC_PORT_NONCONTIGUOUS,
|
||||
OMX_VID_DEC_AVC_PORT_ALIGNMENT,
|
||||
OMX_VID_DEC_AVC_PORT_SUPPLIERPREF,
|
||||
{OMX_VID_DEC_AVC_INPUT_PORT_INDEX, NULL, NULL, NULL},
|
||||
1 /* slave port */
|
||||
};
|
||||
OMX_VIDEO_AVCLEVELTYPE levels[] = {
|
||||
OMX_VIDEO_AVCLevel1,
|
||||
OMX_VIDEO_AVCLevel1b,
|
||||
OMX_VIDEO_AVCLevel11,
|
||||
OMX_VIDEO_AVCLevel12,
|
||||
OMX_VIDEO_AVCLevel13,
|
||||
OMX_VIDEO_AVCLevel2,
|
||||
OMX_VIDEO_AVCLevel21,
|
||||
OMX_VIDEO_AVCLevel22,
|
||||
OMX_VIDEO_AVCLevel3,
|
||||
OMX_VIDEO_AVCLevel31,
|
||||
OMX_VIDEO_AVCLevel32,
|
||||
OMX_VIDEO_AVCLevel4,
|
||||
OMX_VIDEO_AVCLevel41,
|
||||
OMX_VIDEO_AVCLevel42,
|
||||
OMX_VIDEO_AVCLevel5,
|
||||
OMX_VIDEO_AVCLevel51,
|
||||
OMX_VIDEO_AVCLevelMax
|
||||
};
|
||||
|
||||
portdef.pNativeRender = NULL;
|
||||
portdef.nFrameWidth = OMX_VID_DEC_AVC_DEFAULT_FRAME_WIDTH;
|
||||
portdef.nFrameHeight = OMX_VID_DEC_AVC_DEFAULT_FRAME_HEIGHT;
|
||||
portdef.nStride = 0;
|
||||
portdef.nSliceHeight = 0;
|
||||
portdef.nBitrate = 64000;
|
||||
portdef.xFramerate = OMX_VID_DEC_AVC_DEFAULT_FRAME_RATE;
|
||||
portdef.bFlagErrorConcealment = OMX_FALSE;
|
||||
portdef.eCompressionFormat = OMX_VIDEO_CodingAVC;
|
||||
portdef.eColorFormat = OMX_COLOR_FormatUnused;
|
||||
portdef.pNativeWindow = NULL;
|
||||
|
||||
avctype.nSize = sizeof (OMX_VIDEO_PARAM_AVCTYPE);
|
||||
avctype.nVersion.nVersion = OMX_VERSION;
|
||||
avctype.nPortIndex = OMX_VID_DEC_AVC_INPUT_PORT_INDEX;
|
||||
avctype.eProfile = OMX_VIDEO_AVCProfileHigh;
|
||||
/* Encoder related, decide if need to initialise these */
|
||||
avctype.nSliceHeaderSpacing = 0;
|
||||
avctype.nPFrames = 0;
|
||||
avctype.nBFrames = 0;
|
||||
avctype.bUseHadamard = OMX_FALSE;
|
||||
avctype.nRefFrames = 1;
|
||||
avctype.nRefIdx10ActiveMinus1 = 1;
|
||||
avctype.nRefIdx11ActiveMinus1 = 0;
|
||||
avctype.bEnableUEP = OMX_FALSE;
|
||||
avctype.bEnableFMO = OMX_FALSE;
|
||||
avctype.bEnableASO = OMX_FALSE;
|
||||
avctype.bEnableRS = OMX_FALSE;
|
||||
avctype.eLevel = OMX_VIDEO_AVCLevel51;
|
||||
avctype.nAllowedPictureTypes = 2;
|
||||
avctype.bFrameMBsOnly = OMX_FALSE;
|
||||
avctype.bMBAFF = OMX_FALSE;
|
||||
avctype.bEntropyCodingCABAC = OMX_FALSE;
|
||||
avctype.bWeightedPPrediction = OMX_FALSE;
|
||||
avctype.nWeightedBipredicitonMode = 0;
|
||||
avctype.bconstIpred = OMX_FALSE;
|
||||
avctype.bDirect8x8Inference = OMX_FALSE;
|
||||
avctype.bDirectSpatialTemporal = OMX_FALSE;
|
||||
avctype.nCabacInitIdc = 0;
|
||||
avctype.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable;
|
||||
|
||||
return factory_new (tiz_get_type(ap_hdl, "h264dinport"),
|
||||
&avc_port_opts, &portdef,
|
||||
&encodings, &formats, &avctype, &levels,
|
||||
NULL /* OMX_VIDEO_PARAM_BITRATETYPE */,
|
||||
NULL /* OMX_VIDEO_PARAM_QUANTIZATIONTYPE */);
|
||||
}
|
||||
|
||||
OMX_PTR instantiate_h264d_output_port(OMX_HANDLETYPE ap_hdl)
|
||||
{
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE portdef;
|
||||
OMX_VIDEO_CODINGTYPE encodings[] = {
|
||||
OMX_VIDEO_CodingUnused,
|
||||
OMX_VIDEO_CodingMax
|
||||
};
|
||||
OMX_COLOR_FORMATTYPE formats[] = {
|
||||
OMX_COLOR_FormatYUV420SemiPlanar,
|
||||
OMX_COLOR_FormatMax
|
||||
};
|
||||
tiz_port_options_t rawvideo_port_opts = {
|
||||
OMX_PortDomainVideo,
|
||||
OMX_DirOutput,
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_MIN_BUF_COUNT,
|
||||
OMX_VID_DEC_AVC_PORT_MIN_OUTPUT_BUF_SIZE,
|
||||
OMX_VID_DEC_AVC_PORT_NONCONTIGUOUS,
|
||||
OMX_VID_DEC_AVC_PORT_ALIGNMENT,
|
||||
OMX_VID_DEC_AVC_PORT_SUPPLIERPREF,
|
||||
{OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX, NULL, NULL, NULL},
|
||||
0 /* Master port */
|
||||
};
|
||||
|
||||
portdef.pNativeRender = NULL;
|
||||
portdef.nFrameWidth = OMX_VID_DEC_AVC_DEFAULT_FRAME_WIDTH;
|
||||
portdef.nFrameHeight = OMX_VID_DEC_AVC_DEFAULT_FRAME_HEIGHT;
|
||||
portdef.nStride = 0;
|
||||
portdef.nSliceHeight = 0;
|
||||
portdef.nBitrate = 64000;
|
||||
portdef.xFramerate = OMX_VID_DEC_AVC_DEFAULT_FRAME_RATE;
|
||||
portdef.bFlagErrorConcealment = OMX_FALSE;
|
||||
portdef.eCompressionFormat = OMX_VIDEO_CodingUnused;
|
||||
portdef.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
|
||||
portdef.pNativeWindow = NULL;
|
||||
|
||||
return factory_new(tiz_get_type(ap_hdl, "tizvideoport"),
|
||||
&rawvideo_port_opts, &portdef,
|
||||
&encodings, &formats);
|
||||
}
|
||||
|
||||
OMX_PTR instantiate_h264d_config_port(OMX_HANDLETYPE ap_hdl)
|
||||
{
|
||||
return factory_new(tiz_get_type(ap_hdl, "tizconfigport"),
|
||||
NULL, /* this port does not take options */
|
||||
OMX_VID_COMP_NAME, h264_decoder_version);
|
||||
}
|
||||
|
||||
OMX_PTR instantiate_h264d_processor(OMX_HANDLETYPE ap_hdl)
|
||||
{
|
||||
return factory_new(tiz_get_type(ap_hdl, "h264dprc"));
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef H264D_H
|
||||
#define H264D_H
|
||||
|
||||
#include <OMX_Core.h>
|
||||
#include <OMX_Types.h>
|
||||
#include <OMX_Video.h>
|
||||
|
||||
OMX_PTR instantiate_h264d_config_port(OMX_HANDLETYPE ap_hdl);
|
||||
OMX_PTR instantiate_h264d_input_port(OMX_HANDLETYPE ap_hdl);
|
||||
OMX_PTR instantiate_h264d_output_port(OMX_HANDLETYPE ap_hdl);
|
||||
OMX_PTR instantiate_h264d_processor(OMX_HANDLETYPE ap_hdl);
|
||||
|
||||
#endif /* H264D_H */
|
||||
@@ -1,147 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <tizplatform.h>
|
||||
#include <tizkernel.h>
|
||||
|
||||
#include "vl/vl_winsys.h"
|
||||
|
||||
#include "h264d.h"
|
||||
#include "h264dinport.h"
|
||||
#include "h264dinport_decls.h"
|
||||
#include "vid_dec_common.h"
|
||||
|
||||
/*
|
||||
* h264dinport class
|
||||
*/
|
||||
|
||||
static void * h264d_inport_ctor(void * ap_obj, va_list * app)
|
||||
{
|
||||
return super_ctor(typeOf(ap_obj, "h264dinport"), ap_obj, app);
|
||||
}
|
||||
|
||||
static void * h264d_inport_dtor(void * ap_obj)
|
||||
{
|
||||
return super_dtor(typeOf(ap_obj, "h264dinport"), ap_obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* from tiz_api
|
||||
*/
|
||||
|
||||
static OMX_ERRORTYPE h264d_inport_SetParameter(const void * ap_obj, OMX_HANDLETYPE ap_hdl,
|
||||
OMX_INDEXTYPE a_index, OMX_PTR ap_struct)
|
||||
{
|
||||
OMX_ERRORTYPE err = OMX_ErrorNone;
|
||||
|
||||
assert(ap_obj);
|
||||
assert(ap_hdl);
|
||||
assert(ap_struct);
|
||||
|
||||
if (a_index == OMX_IndexParamPortDefinition) {
|
||||
vid_dec_PrivateType * p_prc = tiz_get_prc(ap_hdl);
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE * p_def = &(p_prc->out_port_def_.format.video);
|
||||
OMX_PARAM_PORTDEFINITIONTYPE * i_def = (OMX_PARAM_PORTDEFINITIONTYPE *) ap_struct;
|
||||
|
||||
/* Make changes only if there is a resolution change */
|
||||
if ((p_def->nFrameWidth == i_def->format.video.nFrameWidth) &&
|
||||
(p_def->nFrameHeight == i_def->format.video.nFrameHeight) &&
|
||||
(p_def->eCompressionFormat == i_def->format.video.eCompressionFormat))
|
||||
return err;
|
||||
|
||||
/* Set some default values if not set */
|
||||
if (i_def->format.video.nStride == 0)
|
||||
i_def->format.video.nStride = i_def->format.video.nFrameWidth;
|
||||
if (i_def->format.video.nSliceHeight == 0)
|
||||
i_def->format.video.nSliceHeight = i_def->format.video.nFrameHeight;
|
||||
|
||||
err = super_SetParameter(typeOf (ap_obj, "h264dinport"), ap_obj,
|
||||
ap_hdl, a_index, ap_struct);
|
||||
if (err == OMX_ErrorNone) {
|
||||
tiz_port_t * p_obj = (tiz_port_t *) ap_obj;
|
||||
|
||||
/* Set desired buffer size that will be used when allocating input buffers */
|
||||
p_obj->portdef_.nBufferSize = i_def->format.video.nFrameWidth * i_def->format.video.nFrameHeight * 512 / (16*16);
|
||||
|
||||
/* Get a locally copy of port def. Useful for the early return above */
|
||||
tiz_check_omx(tiz_api_GetParameter(tiz_get_krn(handleOf(p_prc)), handleOf(p_prc),
|
||||
OMX_IndexParamPortDefinition, &(p_prc->out_port_def_)));
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* h264dinport_class
|
||||
*/
|
||||
|
||||
static void * h264d_inport_class_ctor(void * ap_obj, va_list * app)
|
||||
{
|
||||
/* NOTE: Class methods might be added in the future. None for now. */
|
||||
return super_ctor (typeOf (ap_obj, "h264dinport_class"), ap_obj, app);
|
||||
}
|
||||
|
||||
/*
|
||||
* initialization
|
||||
*/
|
||||
|
||||
void * h264d_inport_class_init(void * ap_tos, void * ap_hdl)
|
||||
{
|
||||
void * tizavcport = tiz_get_type(ap_hdl, "tizavcport");
|
||||
void * h264dinport_class
|
||||
= factory_new(classOf(tizavcport), "h264dinport_class",
|
||||
classOf(tizavcport), sizeof(h264d_inport_class_t),
|
||||
ap_tos, ap_hdl, ctor, h264d_inport_class_ctor, 0);
|
||||
return h264dinport_class;
|
||||
}
|
||||
|
||||
void * h264d_inport_init(void * ap_tos, void * ap_hdl)
|
||||
{
|
||||
void * tizavcport = tiz_get_type (ap_hdl, "tizavcport");
|
||||
void * h264dinport_class = tiz_get_type (ap_hdl, "h264dinport_class");
|
||||
void * h264dinport = factory_new
|
||||
/* TIZ_CLASS_COMMENT: class type, class name, parent, size */
|
||||
(h264dinport_class, "h264dinport", tizavcport,
|
||||
sizeof (h264d_inport_t),
|
||||
/* TIZ_CLASS_COMMENT: class constructor */
|
||||
ap_tos, ap_hdl,
|
||||
/* TIZ_CLASS_COMMENT: class constructor */
|
||||
ctor, h264d_inport_ctor,
|
||||
/* TIZ_CLASS_COMMENT: class destructor */
|
||||
dtor, h264d_inport_dtor,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_api_SetParameter, h264d_inport_SetParameter,
|
||||
/* TIZ_CLASS_COMMENT: stop value*/
|
||||
0);
|
||||
|
||||
return h264dinport;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef H264DINPORT_H
|
||||
#define H264DINPORT_H
|
||||
|
||||
void * h264d_inport_class_init(void * ap_tos, void * ap_hdl);
|
||||
void * h264d_inport_init(void * ap_tos, void * ap_hdl);
|
||||
|
||||
#endif /* H264DINPORT_H */
|
||||
@@ -1,48 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef H264DINPORT_DECLS_H
|
||||
#define H264DINPORT_DECLS_H
|
||||
|
||||
#include <OMX_TizoniaExt.h>
|
||||
#include <OMX_Types.h>
|
||||
|
||||
#include <tizavcport_decls.h>
|
||||
|
||||
typedef struct h264d_inport h264d_inport_t;
|
||||
struct h264d_inport
|
||||
{
|
||||
/* Object */
|
||||
const tiz_avcport_t _;
|
||||
};
|
||||
|
||||
typedef struct h264d_inport_class h264d_inport_class_t;
|
||||
struct h264d_inport_class
|
||||
{
|
||||
/* Class */
|
||||
const tiz_avcport_class_t _;
|
||||
/* NOTE: Class methods might be added in the future */
|
||||
};
|
||||
|
||||
#endif /* H264DINPORT_DECLS_H */
|
||||
@@ -1,616 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <tizplatform.h>
|
||||
#include <tizkernel.h>
|
||||
#include <tizutils.h>
|
||||
|
||||
#include "entrypoint.h"
|
||||
#include "h264d.h"
|
||||
#include "h264dprc.h"
|
||||
#include "vid_omx_common.h"
|
||||
#include "vid_dec_common.h"
|
||||
#include "vid_dec_h264_common.h"
|
||||
|
||||
#include "vl/vl_video_buffer.h"
|
||||
#include "vl/vl_compositor.h"
|
||||
#include "util/u_hash_table.h"
|
||||
#include "util/u_surface.h"
|
||||
|
||||
#include "dri_screen.h"
|
||||
#include "egl_dri2.h"
|
||||
|
||||
unsigned dec_frame_delta;
|
||||
|
||||
static enum pipe_error hash_table_clear_item_callback(void *key, void *value, void *data)
|
||||
{
|
||||
struct pipe_video_buffer *video_buffer = (struct pipe_video_buffer *)value;
|
||||
video_buffer->destroy(video_buffer);
|
||||
return PIPE_OK;
|
||||
}
|
||||
|
||||
static void release_input_headers(vid_dec_PrivateType* priv) {
|
||||
int i;
|
||||
for (i = 0; i < priv->num_in_buffers; i++) {
|
||||
assert(!priv->in_port_disabled_);
|
||||
if (priv->in_buffers[i]->pInputPortPrivate) {
|
||||
vid_dec_FreeInputPortPrivate(priv->in_buffers[i]);
|
||||
}
|
||||
(void) tiz_krn_release_buffer (tiz_get_krn (handleOf (priv)),
|
||||
OMX_VID_DEC_AVC_INPUT_PORT_INDEX,
|
||||
priv->in_buffers[i]);
|
||||
priv->in_buffers[i] = NULL;
|
||||
}
|
||||
priv->p_inhdr_ = NULL;
|
||||
priv->num_in_buffers = 0;
|
||||
}
|
||||
|
||||
static void release_output_header(vid_dec_PrivateType* priv) {
|
||||
if (priv->p_outhdr_) {
|
||||
assert(!priv->out_port_disabled_);
|
||||
(void) tiz_krn_release_buffer (tiz_get_krn (handleOf (priv)),
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX,
|
||||
priv->p_outhdr_);
|
||||
priv->p_outhdr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264d_release_all_headers(vid_dec_PrivateType* priv)
|
||||
{
|
||||
assert(priv);
|
||||
release_input_headers(priv);
|
||||
release_output_header(priv);
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static void h264d_buffer_emptied(vid_dec_PrivateType* priv, OMX_BUFFERHEADERTYPE * p_hdr)
|
||||
{
|
||||
assert(priv);
|
||||
assert(priv->in_buffers[0] == p_hdr);
|
||||
|
||||
if (!priv->out_port_disabled_) {
|
||||
assert (p_hdr->nFilledLen == 0);
|
||||
p_hdr->nOffset = 0;
|
||||
|
||||
if ((p_hdr->nFlags & OMX_BUFFERFLAG_EOS) != 0) {
|
||||
priv->eos_ = true;
|
||||
}
|
||||
|
||||
(void) tiz_krn_release_buffer (tiz_get_krn (handleOf (priv)), 0, p_hdr);
|
||||
priv->p_inhdr_ = NULL;
|
||||
priv->in_buffers[0] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void h264d_buffer_filled(vid_dec_PrivateType* priv, OMX_BUFFERHEADERTYPE * p_hdr)
|
||||
{
|
||||
assert(priv);
|
||||
assert(p_hdr);
|
||||
assert(priv->p_outhdr_ == p_hdr);
|
||||
|
||||
if (!priv->in_port_disabled_) {
|
||||
p_hdr->nOffset = 0;
|
||||
|
||||
if (priv->eos_) {
|
||||
/* EOS has been received and all the input data has been consumed
|
||||
* already, so its time to propagate the EOS flag */
|
||||
priv->p_outhdr_->nFlags |= OMX_BUFFERFLAG_EOS;
|
||||
priv->eos_ = false;
|
||||
}
|
||||
|
||||
(void) tiz_krn_release_buffer(tiz_get_krn (handleOf (priv)),
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX,
|
||||
p_hdr);
|
||||
priv->p_outhdr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static bool h264d_shift_buffers_left(vid_dec_PrivateType* priv) {
|
||||
if (--priv->num_in_buffers) {
|
||||
priv->in_buffers[0] = priv->in_buffers[1];
|
||||
priv->sizes[0] = priv->sizes[1] - dec_frame_delta;
|
||||
priv->inputs[0] = priv->inputs[1] + dec_frame_delta;
|
||||
priv->timestamps[0] = priv->timestamps[1];
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static OMX_BUFFERHEADERTYPE * get_input_buffer(vid_dec_PrivateType* priv) {
|
||||
assert(priv);
|
||||
|
||||
if (priv->in_port_disabled_) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (priv->num_in_buffers > 1) {
|
||||
/* The input buffer wasn't cleared last time. */
|
||||
h264d_buffer_emptied(priv, priv->in_buffers[0]);
|
||||
if (priv->in_buffers[0]) {
|
||||
/* Failed to release buffer */
|
||||
return NULL;
|
||||
}
|
||||
h264d_shift_buffers_left(priv);
|
||||
}
|
||||
|
||||
/* Decode_frame expects new buffers each time */
|
||||
assert(priv->p_inhdr_ || priv->first_buf_in_frame);
|
||||
tiz_krn_claim_buffer(tiz_get_krn (handleOf (priv)),
|
||||
OMX_VID_DEC_AVC_INPUT_PORT_INDEX, 0,
|
||||
&priv->p_inhdr_);
|
||||
return priv->p_inhdr_;
|
||||
}
|
||||
|
||||
static struct pipe_resource * st_omx_pipe_texture_from_eglimage(EGLDisplay egldisplay,
|
||||
EGLImage eglimage)
|
||||
{
|
||||
_EGLDisplay *disp = egldisplay;
|
||||
struct dri2_egl_display *dri2_egl_dpy = disp->DriverData;
|
||||
__DRIscreen *_dri_screen = dri2_egl_dpy->dri_screen;
|
||||
struct dri_screen *st_dri_screen = dri_screen(_dri_screen);
|
||||
if (!st_dri_screen->validate_egl_image(st_dri_screen, eglimage))
|
||||
return NULL;
|
||||
__DRIimage *_dri_image = st_dri_screen->lookup_egl_image_validated(st_dri_screen, eglimage);
|
||||
|
||||
return _dri_image->texture;
|
||||
}
|
||||
|
||||
static void get_eglimage(vid_dec_PrivateType* priv) {
|
||||
OMX_PTR p_eglimage = NULL;
|
||||
OMX_NATIVE_WINDOWTYPE * p_egldisplay = NULL;
|
||||
const tiz_port_t * p_port = NULL;
|
||||
struct pipe_video_buffer templat = {};
|
||||
struct pipe_video_buffer *video_buffer = NULL;
|
||||
struct pipe_resource * p_res = NULL;
|
||||
struct pipe_resource *resources[VL_NUM_COMPONENTS];
|
||||
|
||||
if (OMX_ErrorNone ==
|
||||
tiz_krn_claim_eglimage(tiz_get_krn (handleOf (priv)),
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX,
|
||||
priv->p_outhdr_, &p_eglimage)) {
|
||||
priv->use_eglimage = true;
|
||||
p_port = tiz_krn_get_port(tiz_get_krn (handleOf (priv)),
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX);
|
||||
p_egldisplay = p_port->portdef_.format.video.pNativeWindow;
|
||||
|
||||
if (!util_hash_table_get(priv->video_buffer_map, priv->p_outhdr_)) {
|
||||
p_res = st_omx_pipe_texture_from_eglimage(p_egldisplay, p_eglimage);
|
||||
|
||||
assert(p_res);
|
||||
|
||||
memset(&templat, 0, sizeof(templat));
|
||||
templat.buffer_format = p_res->format;
|
||||
templat.width = p_res->width0;
|
||||
templat.height = p_res->height0;
|
||||
templat.interlaced = 0;
|
||||
|
||||
memset(resources, 0, sizeof(resources));
|
||||
pipe_resource_reference(&resources[0], p_res);
|
||||
|
||||
video_buffer = vl_video_buffer_create_ex2(priv->pipe, &templat, resources);
|
||||
|
||||
assert(video_buffer);
|
||||
assert(video_buffer->buffer_format == p_res->format);
|
||||
|
||||
_mesa_hash_table_insert(priv->video_buffer_map, priv->p_outhdr_, video_buffer);
|
||||
}
|
||||
} else {
|
||||
(void) tiz_krn_release_buffer(tiz_get_krn (handleOf (priv)),
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX,
|
||||
priv->p_outhdr_);
|
||||
priv->p_outhdr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static OMX_BUFFERHEADERTYPE * get_output_buffer(vid_dec_PrivateType* priv) {
|
||||
assert (priv);
|
||||
|
||||
if (priv->out_port_disabled_) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!priv->p_outhdr_) {
|
||||
if (OMX_ErrorNone
|
||||
== tiz_krn_claim_buffer(tiz_get_krn (handleOf (priv)),
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX, 0,
|
||||
&priv->p_outhdr_)) {
|
||||
if (priv->p_outhdr_) {
|
||||
/* Check pBuffer nullity to know if an eglimage has been registered. */
|
||||
if (!priv->p_outhdr_->pBuffer) {
|
||||
get_eglimage(priv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return priv->p_outhdr_;
|
||||
}
|
||||
|
||||
static void reset_stream_parameters(vid_dec_PrivateType* apriv)
|
||||
{
|
||||
assert(apriv);
|
||||
TIZ_INIT_OMX_PORT_STRUCT(apriv->out_port_def_,
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX);
|
||||
|
||||
tiz_api_GetParameter (tiz_get_krn (handleOf (apriv)), handleOf (apriv),
|
||||
OMX_IndexParamPortDefinition, &(apriv->out_port_def_));
|
||||
|
||||
apriv->p_inhdr_ = 0;
|
||||
apriv->num_in_buffers = 0;
|
||||
apriv->first_buf_in_frame = true;
|
||||
apriv->eos_ = false;
|
||||
apriv->frame_finished = false;
|
||||
apriv->frame_started = false;
|
||||
apriv->picture.h264.field_order_cnt[0] = apriv->picture.h264.field_order_cnt[1] = INT_MAX;
|
||||
apriv->slice = NULL;
|
||||
}
|
||||
|
||||
/* Replacement for bellagio's omx_base_filter_BufferMgmtFunction */
|
||||
static void h264d_manage_buffers(vid_dec_PrivateType* priv) {
|
||||
bool next_is_eos = priv->num_in_buffers == 2 ? !!(priv->in_buffers[1]->nFlags & OMX_BUFFERFLAG_EOS) : false;
|
||||
vid_dec_FrameDecoded_common(priv, priv->in_buffers[0], priv->p_outhdr_);
|
||||
|
||||
priv->p_outhdr_->nTimeStamp = priv->in_buffers[0]->nTimeStamp;
|
||||
|
||||
/* Realase output buffer if filled or eos
|
||||
Keep if two input buffers are being decoded */
|
||||
if ((!next_is_eos) && ((priv->p_outhdr_->nFilledLen > 0) || priv->use_eglimage || priv->eos_)) {
|
||||
h264d_buffer_filled(priv, priv->p_outhdr_);
|
||||
}
|
||||
|
||||
/* Release input buffer if possible */
|
||||
if (priv->in_buffers[0]->nFilledLen == 0) {
|
||||
h264d_buffer_emptied(priv, priv->in_buffers[0]);
|
||||
}
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE decode_frame(vid_dec_PrivateType*priv,
|
||||
OMX_BUFFERHEADERTYPE *in_buf)
|
||||
{
|
||||
unsigned i = priv->num_in_buffers++;
|
||||
priv->in_buffers[i] = in_buf;
|
||||
priv->sizes[i] = in_buf->nFilledLen;
|
||||
priv->inputs[i] = in_buf->pBuffer;
|
||||
priv->timestamps[i] = in_buf->nTimeStamp;
|
||||
|
||||
while (priv->num_in_buffers > (!!(in_buf->nFlags & OMX_BUFFERFLAG_EOS) ? 0 : 1)) {
|
||||
priv->eos_ = !!(priv->in_buffers[0]->nFlags & OMX_BUFFERFLAG_EOS);
|
||||
unsigned min_bits_left = priv->eos_ ? 32 : MAX2(in_buf->nFilledLen * 8, 32);
|
||||
struct vl_vlc vlc;
|
||||
|
||||
vl_vlc_init(&vlc, priv->num_in_buffers, priv->inputs, priv->sizes);
|
||||
|
||||
if (priv->slice)
|
||||
priv->bytes_left = vl_vlc_bits_left(&vlc) / 8;
|
||||
|
||||
while (vl_vlc_bits_left (&vlc) > min_bits_left) {
|
||||
vid_dec_h264_Decode(priv, &vlc, min_bits_left);
|
||||
vl_vlc_fillbits(&vlc);
|
||||
}
|
||||
|
||||
if (priv->slice) {
|
||||
unsigned bytes = priv->bytes_left - vl_vlc_bits_left(&vlc) / 8;
|
||||
|
||||
priv->codec->decode_bitstream(priv->codec, priv->target, &priv->picture.base,
|
||||
1, &priv->slice, &bytes);
|
||||
|
||||
if (priv->num_in_buffers)
|
||||
priv->slice = priv->inputs[1];
|
||||
else
|
||||
priv->slice = NULL;
|
||||
}
|
||||
|
||||
if (priv->eos_ && priv->frame_started)
|
||||
vid_dec_h264_EndFrame(priv);
|
||||
|
||||
if (priv->frame_finished) {
|
||||
priv->frame_finished = false;
|
||||
h264d_manage_buffers(priv);
|
||||
} else if (priv->eos_) {
|
||||
vid_dec_FreeInputPortPrivate(priv->in_buffers[0]);
|
||||
h264d_manage_buffers(priv);
|
||||
} else {
|
||||
priv->in_buffers[0]->nFilledLen = 0;
|
||||
h264d_buffer_emptied(priv, priv->in_buffers[0]);
|
||||
}
|
||||
|
||||
if (priv->out_port_disabled_) {
|
||||
/* In case out port is disabled, h264d_buffer_emptied will fail to release input port.
|
||||
* We need to wait before shifting the buffers in that case and check in
|
||||
* get_input_buffer when out port is enabled to release and shift the buffers.
|
||||
* Infinite looping occurs if buffer is not released */
|
||||
if (priv->num_in_buffers == 2) {
|
||||
/* Set the delta value for use in get_input_buffer before exiting */
|
||||
dec_frame_delta = MIN2((min_bits_left - vl_vlc_bits_left(&vlc)) / 8, priv->sizes[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
h264d_shift_buffers_left(priv);
|
||||
}
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
/*
|
||||
* h264dprc
|
||||
*/
|
||||
|
||||
static void * h264d_prc_ctor(void *ap_obj, va_list * app)
|
||||
{
|
||||
vid_dec_PrivateType*priv = super_ctor(typeOf (ap_obj, "h264dprc"), ap_obj, app);
|
||||
assert(priv);
|
||||
priv->p_inhdr_ = 0;
|
||||
priv->p_outhdr_ = 0;
|
||||
priv->first_buf_in_frame = true;
|
||||
priv->eos_ = false;
|
||||
priv->in_port_disabled_ = false;
|
||||
priv->out_port_disabled_ = false;
|
||||
priv->picture.base.profile = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
|
||||
priv->profile = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
|
||||
reset_stream_parameters(priv);
|
||||
|
||||
return priv;
|
||||
}
|
||||
|
||||
static void * h264d_prc_dtor(void *ap_obj)
|
||||
{
|
||||
return super_dtor(typeOf(ap_obj, "h264dprc"), ap_obj);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264d_prc_allocate_resources(void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
vid_dec_PrivateType*priv = ap_obj;
|
||||
struct pipe_screen *screen;
|
||||
vl_csc_matrix csc;
|
||||
|
||||
assert (priv);
|
||||
|
||||
priv->screen = omx_get_screen();
|
||||
if (!priv->screen)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
screen = priv->screen->pscreen;
|
||||
priv->pipe = pipe_create_multimedia_context(screen);
|
||||
if (!priv->pipe)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
if (!vl_compositor_init(&priv->compositor, priv->pipe)) {
|
||||
priv->pipe->destroy(priv->pipe);
|
||||
priv->pipe = NULL;
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
if (!vl_compositor_init_state(&priv->cstate, priv->pipe)) {
|
||||
vl_compositor_cleanup(&priv->compositor);
|
||||
priv->pipe->destroy(priv->pipe);
|
||||
priv->pipe = NULL;
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &csc);
|
||||
if (!vl_compositor_set_csc_matrix(&priv->cstate, (const vl_csc_matrix *)&csc, 1.0f, 0.0f)) {
|
||||
vl_compositor_cleanup(&priv->compositor);
|
||||
priv->pipe->destroy(priv->pipe);
|
||||
priv->pipe = NULL;
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
list_inithead(&priv->codec_data.h264.dpb_list);
|
||||
|
||||
priv->video_buffer_map = util_hash_table_create_ptr_keys();
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264d_prc_deallocate_resources(void *ap_obj)
|
||||
{
|
||||
vid_dec_PrivateType*priv = ap_obj;
|
||||
assert(priv);
|
||||
|
||||
/* Clear hash table */
|
||||
util_hash_table_foreach(priv->video_buffer_map,
|
||||
&hash_table_clear_item_callback,
|
||||
NULL);
|
||||
_mesa_hash_table_destroy(priv->video_buffer_map, NULL);
|
||||
|
||||
if (priv->pipe) {
|
||||
vl_compositor_cleanup_state(&priv->cstate);
|
||||
vl_compositor_cleanup(&priv->compositor);
|
||||
priv->pipe->destroy(priv->pipe);
|
||||
}
|
||||
|
||||
if (priv->screen)
|
||||
omx_put_screen();
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264d_prc_prepare_to_transfer(void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
vid_dec_PrivateType*priv = ap_obj;
|
||||
assert(priv);
|
||||
|
||||
TIZ_INIT_OMX_PORT_STRUCT(priv->out_port_def_,
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX);
|
||||
tiz_check_omx(
|
||||
tiz_api_GetParameter(tiz_get_krn(handleOf(priv)), handleOf(priv),
|
||||
OMX_IndexParamPortDefinition, &(priv->out_port_def_)));
|
||||
|
||||
priv->first_buf_in_frame = true;
|
||||
priv->eos_ = false;
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264d_prc_transfer_and_process(void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264d_prc_stop_and_return(void *ap_obj)
|
||||
{
|
||||
vid_dec_PrivateType*priv = (vid_dec_PrivateType*) ap_obj;
|
||||
return h264d_release_all_headers (priv);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264d_prc_buffers_ready(const void *ap_obj)
|
||||
{
|
||||
vid_dec_PrivateType*priv = (vid_dec_PrivateType*) ap_obj;
|
||||
OMX_BUFFERHEADERTYPE *in_buf = NULL;
|
||||
OMX_BUFFERHEADERTYPE *out_buf = NULL;
|
||||
|
||||
assert(priv);
|
||||
|
||||
/* Set parameters if start of stream */
|
||||
if (!priv->eos_ && priv->first_buf_in_frame && (in_buf = get_input_buffer(priv))) {
|
||||
decode_frame(priv, in_buf);
|
||||
}
|
||||
|
||||
/* Don't get input buffer if output buffer not found */
|
||||
while (!priv->eos_ && (out_buf = get_output_buffer(priv)) && (in_buf = get_input_buffer(priv))) {
|
||||
if (!priv->out_port_disabled_) {
|
||||
decode_frame(priv, in_buf);
|
||||
}
|
||||
}
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264d_prc_port_flush(const void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
vid_dec_PrivateType*priv = (vid_dec_PrivateType*) ap_obj;
|
||||
if (OMX_ALL == a_pid || OMX_VID_DEC_AVC_INPUT_PORT_INDEX == a_pid) {
|
||||
release_input_headers(priv);
|
||||
reset_stream_parameters(priv);
|
||||
}
|
||||
if (OMX_ALL == a_pid || OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX == a_pid) {
|
||||
release_output_header(priv);
|
||||
}
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264d_prc_port_disable(const void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
vid_dec_PrivateType*priv = (vid_dec_PrivateType*) ap_obj;
|
||||
assert(priv);
|
||||
if (OMX_ALL == a_pid || OMX_VID_DEC_AVC_INPUT_PORT_INDEX == a_pid) {
|
||||
/* Release all buffers */
|
||||
h264d_release_all_headers(priv);
|
||||
reset_stream_parameters(priv);
|
||||
priv->in_port_disabled_ = true;
|
||||
}
|
||||
if (OMX_ALL == a_pid || OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX == a_pid) {
|
||||
release_output_header(priv);
|
||||
priv->out_port_disabled_ = true;
|
||||
}
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264d_prc_port_enable(const void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
vid_dec_PrivateType* priv = (vid_dec_PrivateType*) ap_obj;
|
||||
assert(priv);
|
||||
if (OMX_ALL == a_pid || OMX_VID_DEC_AVC_INPUT_PORT_INDEX == a_pid) {
|
||||
if (priv->in_port_disabled_) {
|
||||
reset_stream_parameters(priv);
|
||||
priv->in_port_disabled_ = false;
|
||||
}
|
||||
}
|
||||
if (OMX_ALL == a_pid || OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX == a_pid) {
|
||||
priv->out_port_disabled_ = false;
|
||||
}
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
/*
|
||||
* h264d_prc_class
|
||||
*/
|
||||
|
||||
static void * h264d_prc_class_ctor(void *ap_obj, va_list * app)
|
||||
{
|
||||
/* NOTE: Class methods might be added in the future. None for now. */
|
||||
return super_ctor(typeOf(ap_obj, "h264dprc_class"), ap_obj, app);
|
||||
}
|
||||
|
||||
/*
|
||||
* initialization
|
||||
*/
|
||||
|
||||
void * h264d_prc_class_init(void * ap_tos, void * ap_hdl)
|
||||
{
|
||||
void * tizprc = tiz_get_type(ap_hdl, "tizprc");
|
||||
void * h264dprc_class = factory_new
|
||||
/* TIZ_CLASS_COMMENT: class type, class name, parent, size */
|
||||
(classOf(tizprc), "h264dprc_class", classOf(tizprc),
|
||||
sizeof(h264d_prc_class_t),
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
ap_tos, ap_hdl,
|
||||
/* TIZ_CLASS_COMMENT: class constructor */
|
||||
ctor, h264d_prc_class_ctor,
|
||||
/* TIZ_CLASS_COMMENT: stop value*/
|
||||
0);
|
||||
return h264dprc_class;
|
||||
}
|
||||
|
||||
void * h264d_prc_init(void * ap_tos, void * ap_hdl)
|
||||
{
|
||||
void * tizprc = tiz_get_type(ap_hdl, "tizprc");
|
||||
void * h264dprc_class = tiz_get_type(ap_hdl, "h264dprc_class");
|
||||
TIZ_LOG_CLASS (h264dprc_class);
|
||||
void * h264dprc = factory_new
|
||||
/* TIZ_CLASS_COMMENT: class type, class name, parent, size */
|
||||
(h264dprc_class, "h264dprc", tizprc, sizeof(vid_dec_PrivateType),
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
ap_tos, ap_hdl,
|
||||
/* TIZ_CLASS_COMMENT: class constructor */
|
||||
ctor, h264d_prc_ctor,
|
||||
/* TIZ_CLASS_COMMENT: class destructor */
|
||||
dtor, h264d_prc_dtor,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_srv_allocate_resources, h264d_prc_allocate_resources,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_srv_deallocate_resources, h264d_prc_deallocate_resources,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_srv_prepare_to_transfer, h264d_prc_prepare_to_transfer,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_srv_transfer_and_process, h264d_prc_transfer_and_process,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_srv_stop_and_return, h264d_prc_stop_and_return,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_prc_buffers_ready, h264d_prc_buffers_ready,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_prc_port_flush, h264d_prc_port_flush,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_prc_port_disable, h264d_prc_port_disable,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_prc_port_enable, h264d_prc_port_enable,
|
||||
/* TIZ_CLASS_COMMENT: stop value*/
|
||||
0);
|
||||
|
||||
return h264dprc;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef H264DPRC_H
|
||||
#define H264DPRC_H
|
||||
|
||||
void * h264d_prc_class_init(void * ap_tos, void * ap_hdl);
|
||||
void * h264d_prc_init(void * ap_tos, void * ap_hdl);
|
||||
|
||||
#endif /* H264DPRC_H */
|
||||
@@ -1,184 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <tizport_decls.h>
|
||||
|
||||
#include "h264eprc.h"
|
||||
#include "h264e.h"
|
||||
#include "names.h"
|
||||
#include "vid_enc_common.h"
|
||||
|
||||
static OMX_VERSIONTYPE h264e_encoder_version = {{0, 0, 0, 1}};
|
||||
|
||||
OMX_PTR instantiate_h264e_input_port(OMX_HANDLETYPE ap_hdl)
|
||||
{
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE portdef;
|
||||
OMX_VIDEO_CODINGTYPE encodings[] = {
|
||||
OMX_VIDEO_CodingUnused,
|
||||
OMX_VIDEO_CodingMax
|
||||
};
|
||||
OMX_COLOR_FORMATTYPE formats[] = {
|
||||
OMX_COLOR_FormatYUV420SemiPlanar,
|
||||
OMX_COLOR_FormatMax
|
||||
};
|
||||
tiz_port_options_t rawvideo_port_opts = {
|
||||
OMX_PortDomainVideo,
|
||||
OMX_DirInput,
|
||||
OMX_VID_ENC_AVC_INPUT_PORT_MIN_BUF_COUNT,
|
||||
OMX_VID_ENC_AVC_PORT_MIN_INPUT_BUF_SIZE,
|
||||
OMX_VID_ENC_AVC_PORT_NONCONTIGUOUS,
|
||||
OMX_VID_ENC_AVC_PORT_ALIGNMENT,
|
||||
OMX_VID_ENC_AVC_PORT_SUPPLIERPREF,
|
||||
{OMX_VID_ENC_AVC_INPUT_PORT_INDEX, NULL, NULL, NULL},
|
||||
1 /* Slave port */
|
||||
};
|
||||
|
||||
portdef.pNativeRender = NULL;
|
||||
portdef.nFrameWidth = OMX_VID_ENC_AVC_DEFAULT_FRAME_WIDTH;
|
||||
portdef.nFrameHeight = OMX_VID_ENC_AVC_DEFAULT_FRAME_HEIGHT;
|
||||
portdef.nStride = 0;
|
||||
portdef.nSliceHeight = 0;
|
||||
portdef.nBitrate = 64000;
|
||||
portdef.xFramerate = 15;
|
||||
portdef.bFlagErrorConcealment = OMX_FALSE;
|
||||
portdef.eCompressionFormat = OMX_VIDEO_CodingUnused;
|
||||
portdef.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
|
||||
portdef.pNativeWindow = NULL;
|
||||
|
||||
return factory_new(tiz_get_type(ap_hdl, "h264einport"),
|
||||
&rawvideo_port_opts, &portdef,
|
||||
&encodings, &formats);
|
||||
}
|
||||
|
||||
OMX_PTR instantiate_h264e_output_port(OMX_HANDLETYPE ap_hdl)
|
||||
{
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE portdef;
|
||||
OMX_VIDEO_PARAM_AVCTYPE avctype;
|
||||
OMX_VIDEO_PARAM_BITRATETYPE bitrate;
|
||||
OMX_VIDEO_PARAM_QUANTIZATIONTYPE quant;
|
||||
|
||||
OMX_VIDEO_CODINGTYPE encodings[] = {
|
||||
OMX_VIDEO_CodingAVC,
|
||||
OMX_VIDEO_CodingMax
|
||||
};
|
||||
OMX_COLOR_FORMATTYPE formats[] = {
|
||||
OMX_COLOR_FormatUnused,
|
||||
OMX_COLOR_FormatMax
|
||||
};
|
||||
tiz_port_options_t avc_port_opts = {
|
||||
OMX_PortDomainVideo,
|
||||
OMX_DirOutput,
|
||||
OMX_VID_ENC_AVC_OUTPUT_PORT_MIN_BUF_COUNT,
|
||||
OMX_VID_ENC_AVC_PORT_MIN_OUTPUT_BUF_SIZE,
|
||||
OMX_VID_ENC_AVC_PORT_NONCONTIGUOUS,
|
||||
OMX_VID_ENC_AVC_PORT_ALIGNMENT,
|
||||
OMX_VID_ENC_AVC_PORT_SUPPLIERPREF,
|
||||
{OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX, NULL, NULL, NULL},
|
||||
0 /* Master port */
|
||||
};
|
||||
OMX_VIDEO_AVCLEVELTYPE levels[] = {
|
||||
OMX_VIDEO_AVCLevel51,
|
||||
OMX_VIDEO_AVCLevel1,
|
||||
OMX_VIDEO_AVCLevel1b,
|
||||
OMX_VIDEO_AVCLevel11,
|
||||
OMX_VIDEO_AVCLevel12,
|
||||
OMX_VIDEO_AVCLevel13,
|
||||
OMX_VIDEO_AVCLevel2,
|
||||
OMX_VIDEO_AVCLevel21,
|
||||
OMX_VIDEO_AVCLevel22,
|
||||
OMX_VIDEO_AVCLevel3,
|
||||
OMX_VIDEO_AVCLevel31,
|
||||
OMX_VIDEO_AVCLevel32,
|
||||
OMX_VIDEO_AVCLevel4,
|
||||
OMX_VIDEO_AVCLevel41,
|
||||
OMX_VIDEO_AVCLevel42,
|
||||
OMX_VIDEO_AVCLevel5,
|
||||
OMX_VIDEO_AVCLevelMax
|
||||
};
|
||||
|
||||
/* Values set from as given in specification */
|
||||
portdef.pNativeRender = NULL;
|
||||
portdef.nFrameWidth = OMX_VID_ENC_AVC_DEFAULT_FRAME_WIDTH;
|
||||
portdef.nFrameHeight = OMX_VID_ENC_AVC_DEFAULT_FRAME_HEIGHT;
|
||||
portdef.nStride = 0;
|
||||
portdef.nSliceHeight = 0;
|
||||
portdef.nBitrate = 64000;
|
||||
portdef.xFramerate = 15;
|
||||
portdef.bFlagErrorConcealment = OMX_FALSE;
|
||||
portdef.eCompressionFormat = OMX_VIDEO_CodingAVC;
|
||||
portdef.eColorFormat = OMX_COLOR_FormatUnused;
|
||||
portdef.pNativeWindow = NULL;
|
||||
|
||||
bitrate.eControlRate = OMX_Video_ControlRateDisable;
|
||||
bitrate.nTargetBitrate = 0;
|
||||
|
||||
quant.nQpI = OMX_VID_ENC_QUANT_I_FRAMES_DEFAULT;
|
||||
quant.nQpP = OMX_VID_ENC_QUANT_P_FRAMES_DEFAULT;
|
||||
quant.nQpB = OMX_VID_ENC_QUANT_B_FRAMES_DEFAULT;
|
||||
|
||||
avctype.nSize = sizeof (OMX_VIDEO_PARAM_AVCTYPE);
|
||||
avctype.nVersion.nVersion = OMX_VERSION;
|
||||
avctype.nPortIndex = OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX;
|
||||
avctype.eProfile = OMX_VIDEO_AVCProfileBaseline;
|
||||
avctype.nSliceHeaderSpacing = 0;
|
||||
avctype.nPFrames = 0;
|
||||
avctype.nBFrames = 0;
|
||||
avctype.bUseHadamard = OMX_TRUE;
|
||||
avctype.nRefFrames = 1;
|
||||
avctype.nRefIdx10ActiveMinus1 = 1;
|
||||
avctype.nRefIdx11ActiveMinus1 = 0;
|
||||
avctype.bEnableUEP = OMX_FALSE;
|
||||
avctype.bEnableFMO = OMX_FALSE;
|
||||
avctype.bEnableASO = OMX_FALSE;
|
||||
avctype.bEnableRS = OMX_FALSE;
|
||||
avctype.eLevel = OMX_VIDEO_AVCLevel51;
|
||||
avctype.nAllowedPictureTypes = 2;
|
||||
avctype.bFrameMBsOnly = OMX_FALSE;
|
||||
avctype.bMBAFF = OMX_FALSE;
|
||||
avctype.bEntropyCodingCABAC = OMX_FALSE;
|
||||
avctype.bWeightedPPrediction = OMX_FALSE;
|
||||
avctype.nWeightedBipredicitonMode = 0;
|
||||
avctype.bconstIpred = OMX_FALSE;
|
||||
avctype.bDirect8x8Inference = OMX_FALSE;
|
||||
avctype.bDirectSpatialTemporal = OMX_FALSE;
|
||||
avctype.nCabacInitIdc = 0;
|
||||
avctype.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable;
|
||||
|
||||
return factory_new(tiz_get_type(ap_hdl, "h264eoutport"),
|
||||
&avc_port_opts, &portdef,
|
||||
&encodings, &formats, &avctype, &levels,
|
||||
&bitrate, &quant);
|
||||
}
|
||||
|
||||
OMX_PTR instantiate_h264e_config_port(OMX_HANDLETYPE ap_hdl)
|
||||
{
|
||||
return factory_new(tiz_get_type(ap_hdl, "tizconfigport"),
|
||||
NULL, /* this port does not take options */
|
||||
OMX_VID_COMP_NAME, h264e_encoder_version);
|
||||
}
|
||||
|
||||
OMX_PTR instantiate_h264e_processor(OMX_HANDLETYPE ap_hdl)
|
||||
{
|
||||
return factory_new(tiz_get_type(ap_hdl, "h264eprc"));
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef H264E_H
|
||||
#define H264E_H
|
||||
|
||||
#include <OMX_Core.h>
|
||||
#include <OMX_Types.h>
|
||||
#include <OMX_Video.h>
|
||||
|
||||
#define OMX_VID_ENC_AVC_ROLE "video_encoder.avc"
|
||||
|
||||
/* With libtizonia, port indexes must start at index 0 */
|
||||
#define OMX_VID_ENC_AVC_INPUT_PORT_INDEX 0
|
||||
#define OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX 1
|
||||
#define OMX_VID_ENC_AVC_DEFAULT_FRAME_WIDTH 176
|
||||
#define OMX_VID_ENC_AVC_DEFAULT_FRAME_HEIGHT 144
|
||||
#define OMX_VID_ENC_AVC_INPUT_PORT_MIN_BUF_COUNT 8
|
||||
#define OMX_VID_ENC_AVC_OUTPUT_PORT_MIN_BUF_COUNT 2
|
||||
#define OMX_VID_ENC_AVC_PORT_MIN_INPUT_BUF_SIZE 4 * 1024
|
||||
#define OMX_VID_ENC_AVC_PORT_MIN_OUTPUT_BUF_SIZE 345600
|
||||
#define OMX_VID_ENC_AVC_PORT_NONCONTIGUOUS OMX_FALSE
|
||||
#define OMX_VID_ENC_AVC_PORT_ALIGNMENT 0
|
||||
#define OMX_VID_ENC_AVC_PORT_SUPPLIERPREF OMX_BufferSupplyInput
|
||||
|
||||
OMX_PTR instantiate_h264e_config_port(OMX_HANDLETYPE ap_hdl);
|
||||
OMX_PTR instantiate_h264e_input_port(OMX_HANDLETYPE ap_hdl);
|
||||
OMX_PTR instantiate_h264e_output_port(OMX_HANDLETYPE ap_hdl);
|
||||
OMX_PTR instantiate_h264e_processor(OMX_HANDLETYPE ap_hdl);
|
||||
|
||||
#endif /* H264E_H */
|
||||
@@ -1,216 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <tizplatform.h>
|
||||
#include <tizkernel.h>
|
||||
|
||||
#include "vl/vl_winsys.h"
|
||||
|
||||
#include "h264e.h"
|
||||
#include "h264einport.h"
|
||||
#include "h264einport_decls.h"
|
||||
#include "vid_enc_common.h"
|
||||
|
||||
static OMX_ERRORTYPE enc_AllocateBackTexture(OMX_HANDLETYPE ap_hdl,
|
||||
OMX_U32 idx,
|
||||
struct pipe_resource **resource,
|
||||
struct pipe_transfer **transfer,
|
||||
OMX_U8 **map)
|
||||
{
|
||||
vid_enc_PrivateType * priv = tiz_get_prc(ap_hdl);
|
||||
tiz_port_t * port = tiz_krn_get_port(tiz_get_krn(ap_hdl), idx);
|
||||
struct pipe_resource buf_templ;
|
||||
struct pipe_box box = {};
|
||||
OMX_U8 *ptr;
|
||||
|
||||
memset(&buf_templ, 0, sizeof buf_templ);
|
||||
buf_templ.target = PIPE_TEXTURE_2D;
|
||||
buf_templ.format = PIPE_FORMAT_I8_UNORM;
|
||||
buf_templ.bind = PIPE_BIND_LINEAR;
|
||||
buf_templ.usage = PIPE_USAGE_STAGING;
|
||||
buf_templ.flags = 0;
|
||||
buf_templ.width0 = port->portdef_.format.video.nFrameWidth;
|
||||
buf_templ.height0 = port->portdef_.format.video.nFrameHeight * 3 / 2;
|
||||
buf_templ.depth0 = 1;
|
||||
buf_templ.array_size = 1;
|
||||
|
||||
*resource = priv->s_pipe->screen->resource_create(priv->s_pipe->screen, &buf_templ);
|
||||
if (!*resource)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
box.width = (*resource)->width0;
|
||||
box.height = (*resource)->height0;
|
||||
box.depth = (*resource)->depth0;
|
||||
ptr = priv->s_pipe->texture_map(priv->s_pipe, *resource, 0, PIPE_MAP_WRITE, &box, transfer);
|
||||
if (map)
|
||||
*map = ptr;
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
/*
|
||||
* h264einport class
|
||||
*/
|
||||
|
||||
static void * h264e_inport_ctor(void * ap_obj, va_list * app)
|
||||
{
|
||||
return super_ctor(typeOf(ap_obj, "h264einport"), ap_obj, app);
|
||||
}
|
||||
|
||||
static void * h264e_inport_dtor(void * ap_obj)
|
||||
{
|
||||
return super_dtor(typeOf(ap_obj, "h264einport"), ap_obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* from tiz_api
|
||||
*/
|
||||
|
||||
static OMX_ERRORTYPE h264e_inport_AllocateBuffer(const void * ap_obj, OMX_HANDLETYPE ap_hdl,
|
||||
OMX_BUFFERHEADERTYPE ** buf, OMX_U32 idx,
|
||||
OMX_PTR private, OMX_U32 size)
|
||||
{
|
||||
struct input_buf_private *inp;
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
r = super_UseBuffer(typeOf(ap_obj, "h264einport"), ap_obj, ap_hdl,
|
||||
buf, idx, private, size, NULL);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
inp = (*buf)->pInputPortPrivate = CALLOC_STRUCT(input_buf_private);
|
||||
if (!inp) {
|
||||
super_FreeBuffer(typeOf(ap_obj, "h264einport"), ap_obj, ap_hdl, idx, *buf);
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
list_inithead(&inp->tasks);
|
||||
|
||||
r = enc_AllocateBackTexture(ap_hdl, idx, &inp->resource, &inp->transfer, &(*buf)->pBuffer);
|
||||
|
||||
if (r) {
|
||||
FREE(inp);
|
||||
super_FreeBuffer(typeOf(ap_obj, "h264einport"), ap_obj, ap_hdl, idx, *buf);
|
||||
return r;
|
||||
}
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_inport_UseBuffer(const void * ap_obj, OMX_HANDLETYPE ap_hdl,
|
||||
OMX_BUFFERHEADERTYPE **buf, OMX_U32 idx,
|
||||
OMX_PTR private, OMX_U32 size, OMX_U8 *mem)
|
||||
{
|
||||
struct input_buf_private *inp;
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
r = super_UseBuffer(typeOf(ap_obj, "h264einport"), ap_obj, ap_hdl,
|
||||
buf, idx, private, size, mem);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
inp = (*buf)->pInputPortPrivate = CALLOC_STRUCT(input_buf_private);
|
||||
if (!inp) {
|
||||
super_FreeBuffer(typeOf(ap_obj, "h264einport"), ap_obj, ap_hdl, idx, *buf);
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
list_inithead(&inp->tasks);
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_inport_FreeBuffer(const void * ap_obj, OMX_HANDLETYPE ap_hdl,
|
||||
OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf)
|
||||
{
|
||||
vid_enc_PrivateType *priv = tiz_get_prc(ap_hdl);
|
||||
struct input_buf_private *inp = buf->pInputPortPrivate;
|
||||
|
||||
if (inp) {
|
||||
enc_ReleaseTasks(&inp->tasks);
|
||||
if (inp->transfer)
|
||||
pipe_texture_unmap(priv->s_pipe, inp->transfer);
|
||||
pipe_resource_reference(&inp->resource, NULL);
|
||||
FREE(inp);
|
||||
}
|
||||
|
||||
return super_FreeBuffer(typeOf(ap_obj, "h264einport"), ap_obj, ap_hdl, idx, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* h264einport_class
|
||||
*/
|
||||
|
||||
static void * h264e_inport_class_ctor(void * ap_obj, va_list * app)
|
||||
{
|
||||
/* NOTE: Class methods might be added in the future. None for now. */
|
||||
return super_ctor (typeOf (ap_obj, "h264einport_class"), ap_obj, app);
|
||||
}
|
||||
|
||||
/*
|
||||
* initialization
|
||||
*/
|
||||
|
||||
void * h264e_inport_class_init(void * ap_tos, void * ap_hdl)
|
||||
{
|
||||
void * tizvideoport = tiz_get_type(ap_hdl, "tizvideoport");
|
||||
void * h264einport_class
|
||||
= factory_new(classOf(tizvideoport), "h264einport_class",
|
||||
classOf(tizvideoport), sizeof(h264e_inport_class_t),
|
||||
ap_tos, ap_hdl, ctor, h264e_inport_class_ctor, 0);
|
||||
return h264einport_class;
|
||||
}
|
||||
|
||||
void * h264e_inport_init(void * ap_tos, void * ap_hdl)
|
||||
{
|
||||
void * tizvideoport = tiz_get_type (ap_hdl, "tizvideoport");
|
||||
void * h264einport_class = tiz_get_type (ap_hdl, "h264einport_class");
|
||||
void * h264einport = factory_new
|
||||
/* TIZ_CLASS_COMMENT: class type, class name, parent, size */
|
||||
(h264einport_class, "h264einport", tizvideoport,
|
||||
sizeof (h264e_inport_t),
|
||||
/* TIZ_CLASS_COMMENT: class constructor */
|
||||
ap_tos, ap_hdl,
|
||||
/* TIZ_CLASS_COMMENT: class constructor */
|
||||
ctor, h264e_inport_ctor,
|
||||
/* TIZ_CLASS_COMMENT: class destructor */
|
||||
dtor, h264e_inport_dtor,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_api_AllocateBuffer, h264e_inport_AllocateBuffer,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_api_UseBuffer, h264e_inport_UseBuffer,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_api_FreeBuffer, h264e_inport_FreeBuffer,
|
||||
/* TIZ_CLASS_COMMENT: stop value*/
|
||||
0);
|
||||
|
||||
return h264einport;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef H264EINPORT_H
|
||||
#define H264EINPORT_H
|
||||
|
||||
void * h264e_inport_class_init(void * ap_tos, void * ap_hdl);
|
||||
void * h264e_inport_init(void * ap_tos, void * ap_hdl);
|
||||
|
||||
#endif /* H264EINPORT_H */
|
||||
@@ -1,48 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef H264EINPORT_DECLS_H
|
||||
#define H264EINPORT_DECLS_H
|
||||
|
||||
#include <OMX_TizoniaExt.h>
|
||||
#include <OMX_Types.h>
|
||||
|
||||
#include <tizvideoport_decls.h>
|
||||
|
||||
typedef struct h264e_inport h264e_inport_t;
|
||||
struct h264e_inport
|
||||
{
|
||||
/* Object */
|
||||
const tiz_videoport_t _;
|
||||
};
|
||||
|
||||
typedef struct h264e_inport_class h264e_inport_class_t;
|
||||
struct h264e_inport_class
|
||||
{
|
||||
/* Class */
|
||||
const tiz_videoport_class_t _;
|
||||
/* NOTE: Class methods might be added in the future */
|
||||
};
|
||||
|
||||
#endif /* H264EINPORT_DECLS_H */
|
||||
@@ -1,143 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <tizplatform.h>
|
||||
|
||||
#include "vl/vl_winsys.h"
|
||||
|
||||
#include "h264eoutport.h"
|
||||
#include "h264eoutport_decls.h"
|
||||
#include "vid_enc_common.h"
|
||||
|
||||
/*
|
||||
* h264eoutport class
|
||||
*/
|
||||
|
||||
static void * h264e_outport_ctor(void * ap_obj, va_list * app)
|
||||
{
|
||||
return super_ctor(typeOf(ap_obj, "h264eoutport"), ap_obj, app);
|
||||
}
|
||||
|
||||
static void * h264e_outport_dtor(void * ap_obj)
|
||||
{
|
||||
return super_dtor(typeOf(ap_obj, "h264eoutport"), ap_obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* from tiz_api
|
||||
*/
|
||||
|
||||
static OMX_ERRORTYPE h264e_outport_AllocateBuffer(const void * ap_obj, OMX_HANDLETYPE ap_hdl,
|
||||
OMX_BUFFERHEADERTYPE ** buf, OMX_U32 idx,
|
||||
OMX_PTR private, OMX_U32 size)
|
||||
{
|
||||
OMX_ERRORTYPE r;
|
||||
|
||||
r = super_UseBuffer(typeOf(ap_obj, "h264eoutport"), ap_obj, ap_hdl,
|
||||
buf, idx, private, size, NULL);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
(*buf)->pBuffer = NULL;
|
||||
(*buf)->pOutputPortPrivate = CALLOC(1, sizeof(struct output_buf_private));
|
||||
if (!(*buf)->pOutputPortPrivate) {
|
||||
super_FreeBuffer(typeOf(ap_obj, "h264eoutport"), ap_obj, ap_hdl, idx, *buf);
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_outport_FreeBuffer(const void * ap_obj, OMX_HANDLETYPE ap_hdl,
|
||||
OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf)
|
||||
{
|
||||
vid_enc_PrivateType *priv = tiz_get_prc(ap_hdl);
|
||||
struct output_buf_private *outp = buf->pOutputPortPrivate;
|
||||
|
||||
if (outp) {
|
||||
if (outp->transfer)
|
||||
pipe_buffer_unmap(priv->t_pipe, outp->transfer);
|
||||
pipe_resource_reference(&outp->bitstream, NULL);
|
||||
FREE(outp);
|
||||
buf->pOutputPortPrivate = NULL;
|
||||
}
|
||||
buf->pBuffer = NULL;
|
||||
|
||||
return super_FreeBuffer(typeOf(ap_obj, "h264eoutport"), ap_obj, ap_hdl, idx, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* h264e_outport_class
|
||||
*/
|
||||
|
||||
static void * h264e_outport_class_ctor(void * ap_obj, va_list * app)
|
||||
{
|
||||
/* NOTE: Class methods might be added in the future. None for now. */
|
||||
return super_ctor(typeOf(ap_obj, "h264eoutport_class"), ap_obj, app);
|
||||
}
|
||||
|
||||
/*
|
||||
* initialization
|
||||
*/
|
||||
|
||||
void * h264e_outport_class_init(void * ap_tos, void * ap_hdl)
|
||||
{
|
||||
void * tizavcport = tiz_get_type(ap_hdl, "tizavcport");
|
||||
void * h264eoutport_class
|
||||
= factory_new (classOf(tizavcport), "h264eoutport_class",
|
||||
classOf(tizavcport), sizeof(h264e_outport_class_t),
|
||||
ap_tos, ap_hdl, ctor, h264e_outport_class_ctor, 0);
|
||||
return h264eoutport_class;
|
||||
}
|
||||
|
||||
void * h264e_outport_init(void * ap_tos, void * ap_hdl)
|
||||
{
|
||||
void * tizavcport = tiz_get_type(ap_hdl, "tizavcport");
|
||||
void * h264eoutport_class = tiz_get_type(ap_hdl, "h264eoutport_class");
|
||||
void * h264eoutport = factory_new
|
||||
/* TIZ_CLASS_COMMENT: class type, class name, parent, size */
|
||||
(h264eoutport_class, "h264eoutport", tizavcport,
|
||||
sizeof(h264e_outport_t),
|
||||
/* TIZ_CLASS_COMMENT: class constructor */
|
||||
ap_tos, ap_hdl,
|
||||
/* TIZ_CLASS_COMMENT: class constructor */
|
||||
ctor, h264e_outport_ctor,
|
||||
/* TIZ_CLASS_COMMENT: class destructor */
|
||||
dtor, h264e_outport_dtor,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_api_AllocateBuffer, h264e_outport_AllocateBuffer,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_api_FreeBuffer, h264e_outport_FreeBuffer,
|
||||
/* TIZ_CLASS_COMMENT: stop value*/
|
||||
0);
|
||||
|
||||
return h264eoutport;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef H264EOUTPORT_H
|
||||
#define H264EOUTPORT_H
|
||||
|
||||
void * h264e_outport_class_init(void * ap_tos, void * ap_hdl);
|
||||
void * h264e_outport_init(void * ap_tos, void * ap_hdl);
|
||||
|
||||
#endif /* H264EOUTPORT_H */
|
||||
@@ -1,48 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef H264EOUTPORT_DECLS_H
|
||||
#define H264EOUTPORT_DECLS_H
|
||||
|
||||
#include <OMX_TizoniaExt.h>
|
||||
#include <OMX_Types.h>
|
||||
|
||||
#include <tizavcport_decls.h>
|
||||
|
||||
typedef struct h264e_outport h264e_outport_t;
|
||||
struct h264e_outport
|
||||
{
|
||||
/* Object */
|
||||
const tiz_avcport_t _;
|
||||
};
|
||||
|
||||
typedef struct h264e_outport_class h264e_outport_class_t;
|
||||
struct h264e_outport_class
|
||||
{
|
||||
/* Class */
|
||||
const tiz_avcport_class_t _;
|
||||
/* NOTE: Class methods might be added in the future */
|
||||
};
|
||||
|
||||
#endif /* H264EOUTPORT_DECLS_H */
|
||||
@@ -1,699 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <tizplatform.h>
|
||||
#include <tizkernel.h>
|
||||
#include <tizutils.h>
|
||||
|
||||
#include "pipe/p_screen.h"
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
#include "vl/vl_codec.h"
|
||||
|
||||
#include "entrypoint.h"
|
||||
#include "h264e.h"
|
||||
#include "h264eprc.h"
|
||||
#include "vid_omx_common.h"
|
||||
#include "vid_enc_common.h"
|
||||
|
||||
static OMX_ERRORTYPE init_port_structs(vid_enc_PrivateType * priv) {
|
||||
const void * p_krn = NULL;
|
||||
|
||||
assert(priv);
|
||||
|
||||
/* Initialisation */
|
||||
TIZ_INIT_OMX_PORT_STRUCT(priv->in_port_def_,
|
||||
OMX_VID_ENC_AVC_INPUT_PORT_INDEX);
|
||||
TIZ_INIT_OMX_PORT_STRUCT(priv->out_port_def_,
|
||||
OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX);
|
||||
TIZ_INIT_OMX_PORT_STRUCT(priv->bitrate,
|
||||
OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX);
|
||||
TIZ_INIT_OMX_PORT_STRUCT(priv->quant,
|
||||
OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX);
|
||||
TIZ_INIT_OMX_PORT_STRUCT(priv->profile_level,
|
||||
OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX);
|
||||
|
||||
/* Get values */
|
||||
p_krn = tiz_get_krn(handleOf(priv));
|
||||
|
||||
tiz_check_omx(
|
||||
tiz_api_GetParameter(p_krn, handleOf(priv),
|
||||
OMX_IndexParamPortDefinition, &(priv->in_port_def_)));
|
||||
tiz_check_omx(
|
||||
tiz_api_GetParameter(p_krn, handleOf(priv),
|
||||
OMX_IndexParamPortDefinition, &(priv->out_port_def_)));
|
||||
tiz_check_omx(
|
||||
tiz_api_GetParameter(p_krn, handleOf(priv),
|
||||
OMX_IndexParamVideoBitrate, &(priv->bitrate)));
|
||||
tiz_check_omx(
|
||||
tiz_api_GetParameter(p_krn, handleOf(priv),
|
||||
OMX_IndexParamVideoQuantization, &(priv->quant)));
|
||||
tiz_check_omx(
|
||||
tiz_api_GetParameter(p_krn, handleOf(priv),
|
||||
OMX_IndexParamVideoProfileLevelCurrent, &(priv->profile_level)));
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_BUFFERHEADERTYPE * get_input_buffer(vid_enc_PrivateType * priv) {
|
||||
assert(priv);
|
||||
|
||||
if (priv->in_port_disabled_) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
assert(!priv->p_inhdr_); /* encode_frame expects new buffers every time */
|
||||
|
||||
tiz_krn_claim_buffer(tiz_get_krn(handleOf(priv)),
|
||||
OMX_VID_ENC_AVC_INPUT_PORT_INDEX, 0,
|
||||
&priv->p_inhdr_);
|
||||
return priv->p_inhdr_;
|
||||
}
|
||||
|
||||
static OMX_BUFFERHEADERTYPE * get_output_buffer(vid_enc_PrivateType * priv) {
|
||||
assert(priv);
|
||||
|
||||
if (priv->out_port_disabled_) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!priv->p_outhdr_) {
|
||||
tiz_krn_claim_buffer(tiz_get_krn(handleOf(priv)),
|
||||
OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX, 0,
|
||||
&priv->p_outhdr_);
|
||||
}
|
||||
return priv->p_outhdr_;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_buffer_emptied(vid_enc_PrivateType * priv, OMX_BUFFERHEADERTYPE * p_hdr)
|
||||
{
|
||||
OMX_ERRORTYPE r = OMX_ErrorNone;
|
||||
|
||||
assert(priv);
|
||||
assert(priv->p_inhdr_ == p_hdr);
|
||||
|
||||
if (!priv->out_port_disabled_) {
|
||||
p_hdr->nOffset = 0;
|
||||
|
||||
if ((p_hdr->nFlags & OMX_BUFFERFLAG_EOS) != 0) {
|
||||
priv->eos_ = true;
|
||||
}
|
||||
|
||||
r = tiz_krn_release_buffer(tiz_get_krn(handleOf(priv)), 0, p_hdr);
|
||||
priv->p_inhdr_ = NULL;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_buffer_filled(vid_enc_PrivateType * priv, OMX_BUFFERHEADERTYPE * p_hdr)
|
||||
{
|
||||
OMX_ERRORTYPE r = OMX_ErrorNone;
|
||||
|
||||
assert(priv);
|
||||
assert(priv->p_outhdr_ == p_hdr);
|
||||
assert(p_hdr);
|
||||
|
||||
if (!priv->in_port_disabled_) {
|
||||
p_hdr->nOffset = 0;
|
||||
|
||||
if (priv->eos_) {
|
||||
/* EOS has been received and all the input data has been consumed
|
||||
* already, so its time to propagate the EOS flag */
|
||||
priv->p_outhdr_->nFlags |= OMX_BUFFERFLAG_EOS;
|
||||
}
|
||||
|
||||
r = tiz_krn_release_buffer(tiz_get_krn(handleOf(priv)),
|
||||
OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX,
|
||||
p_hdr);
|
||||
priv->p_outhdr_ = NULL;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
static void release_input_header(vid_enc_PrivateType * priv) {
|
||||
assert(!priv->in_port_disabled_);
|
||||
if (priv->p_inhdr_) {
|
||||
(void) tiz_krn_release_buffer(tiz_get_krn(handleOf(priv)),
|
||||
OMX_VID_ENC_AVC_INPUT_PORT_INDEX,
|
||||
priv->p_inhdr_);
|
||||
}
|
||||
priv->p_inhdr_ = NULL;
|
||||
}
|
||||
|
||||
static void release_output_header(vid_enc_PrivateType * priv) {
|
||||
if (priv->p_outhdr_) {
|
||||
assert(!priv->out_port_disabled_);
|
||||
(void) tiz_krn_release_buffer(tiz_get_krn(handleOf(priv)),
|
||||
OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX,
|
||||
priv->p_outhdr_);
|
||||
priv->p_outhdr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_release_all_headers(vid_enc_PrivateType * priv)
|
||||
{
|
||||
assert(priv);
|
||||
|
||||
release_input_header(priv);
|
||||
release_output_header(priv);
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static void reset_stream_parameters(vid_enc_PrivateType * priv)
|
||||
{
|
||||
assert(priv);
|
||||
init_port_structs(priv);
|
||||
priv->p_inhdr_ = 0;
|
||||
priv->p_outhdr_ = 0;
|
||||
priv->eos_ = false;
|
||||
}
|
||||
|
||||
/* Replacement for bellagio's omx_base_filter_BufferMgmtFunction */
|
||||
static OMX_ERRORTYPE h264e_manage_buffers(vid_enc_PrivateType* priv) {
|
||||
OMX_BUFFERHEADERTYPE * in_buf = priv->p_inhdr_;
|
||||
OMX_BUFFERHEADERTYPE * out_buf = priv->p_outhdr_;
|
||||
OMX_ERRORTYPE r = OMX_ErrorNone;
|
||||
|
||||
if (in_buf->nFilledLen > 0) {
|
||||
vid_enc_BufferEncoded_common(priv, in_buf, out_buf);
|
||||
} else {
|
||||
in_buf->nFilledLen = 0;
|
||||
}
|
||||
|
||||
out_buf->nTimeStamp = in_buf->nTimeStamp;
|
||||
|
||||
/* Release input buffer if possible */
|
||||
if (in_buf->nFilledLen == 0) {
|
||||
r = h264e_buffer_emptied(priv, in_buf);
|
||||
}
|
||||
|
||||
/* Realase output buffer if filled or eos */
|
||||
if ((out_buf->nFilledLen != 0) || priv->eos_) {
|
||||
r = h264e_buffer_filled(priv, out_buf);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static struct encode_task *enc_NeedTask(vid_enc_PrivateType * priv)
|
||||
{
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE *def = &priv->in_port_def_.format.video;
|
||||
|
||||
return enc_NeedTask_common(priv, def);
|
||||
}
|
||||
|
||||
static void enc_ScaleInput(vid_enc_PrivateType * priv, struct pipe_video_buffer **vbuf, unsigned *size)
|
||||
{
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE *def = &priv->in_port_def_.format.video;
|
||||
enc_ScaleInput_common(priv, def, vbuf, size);
|
||||
}
|
||||
|
||||
static void enc_HandleTask(vid_enc_PrivateType * priv, struct encode_task *task,
|
||||
enum pipe_h2645_enc_picture_type picture_type)
|
||||
{
|
||||
unsigned size = priv->out_port_def_.nBufferSize;
|
||||
struct pipe_video_buffer *vbuf = task->buf;
|
||||
struct pipe_h264_enc_picture_desc picture = {};
|
||||
|
||||
/* -------------- scale input image --------- */
|
||||
enc_ScaleInput(priv, &vbuf, &size);
|
||||
priv->s_pipe->flush(priv->s_pipe, NULL, 0);
|
||||
|
||||
/* -------------- allocate output buffer --------- */
|
||||
task->bitstream = pipe_buffer_create(priv->s_pipe->screen,
|
||||
PIPE_BIND_VERTEX_BUFFER,
|
||||
PIPE_USAGE_STAGING, /* map for read */
|
||||
size);
|
||||
|
||||
picture.picture_type = picture_type;
|
||||
picture.pic_order_cnt = task->pic_order_cnt;
|
||||
if (priv->restricted_b_frames && picture_type == PIPE_H2645_ENC_PICTURE_TYPE_B)
|
||||
picture.not_referenced = true;
|
||||
enc_ControlPicture_common(priv, &picture);
|
||||
|
||||
/* -------------- encode frame --------- */
|
||||
priv->codec->begin_frame(priv->codec, vbuf, &picture.base);
|
||||
priv->codec->encode_bitstream(priv->codec, vbuf, task->bitstream, &task->feedback);
|
||||
priv->codec->end_frame(priv->codec, vbuf, &picture.base);
|
||||
}
|
||||
|
||||
static void enc_ClearBframes(vid_enc_PrivateType * priv, struct input_buf_private *inp)
|
||||
{
|
||||
struct encode_task *task;
|
||||
|
||||
if (list_is_empty(&priv->b_frames))
|
||||
return;
|
||||
|
||||
task = list_entry(priv->b_frames.prev, struct encode_task, list);
|
||||
list_del(&task->list);
|
||||
|
||||
/* promote last from to P frame */
|
||||
priv->ref_idx_l0 = priv->ref_idx_l1;
|
||||
enc_HandleTask(priv, task, PIPE_H2645_ENC_PICTURE_TYPE_P);
|
||||
list_addtail(&task->list, &inp->tasks);
|
||||
priv->ref_idx_l1 = priv->frame_num++;
|
||||
|
||||
/* handle B frames */
|
||||
LIST_FOR_EACH_ENTRY(task, &priv->b_frames, list) {
|
||||
enc_HandleTask(priv, task, PIPE_H2645_ENC_PICTURE_TYPE_B);
|
||||
if (!priv->restricted_b_frames)
|
||||
priv->ref_idx_l0 = priv->frame_num;
|
||||
priv->frame_num++;
|
||||
}
|
||||
|
||||
enc_MoveTasks(&priv->b_frames, &inp->tasks);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE enc_LoadImage(vid_enc_PrivateType * priv, OMX_BUFFERHEADERTYPE *buf,
|
||||
struct pipe_video_buffer *vbuf)
|
||||
{
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE *def = &priv->in_port_def_.format.video;
|
||||
return enc_LoadImage_common(priv, def, buf, vbuf);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE encode_frame(vid_enc_PrivateType * priv, OMX_BUFFERHEADERTYPE * in_buf)
|
||||
{
|
||||
struct input_buf_private *inp = in_buf->pInputPortPrivate;
|
||||
enum pipe_h2645_enc_picture_type picture_type;
|
||||
struct encode_task *task;
|
||||
unsigned stacked_num = 0;
|
||||
OMX_ERRORTYPE err;
|
||||
|
||||
enc_MoveTasks(&inp->tasks, &priv->free_tasks);
|
||||
task = enc_NeedTask(priv);
|
||||
if (!task)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
/* EOS */
|
||||
if (in_buf->nFilledLen == 0) {
|
||||
if (in_buf->nFlags & OMX_BUFFERFLAG_EOS) {
|
||||
in_buf->nFilledLen = in_buf->nAllocLen;
|
||||
enc_ClearBframes(priv, inp);
|
||||
enc_MoveTasks(&priv->stacked_tasks, &inp->tasks);
|
||||
priv->codec->flush(priv->codec);
|
||||
}
|
||||
return h264e_manage_buffers(priv);
|
||||
}
|
||||
|
||||
if (in_buf->pOutputPortPrivate) {
|
||||
struct pipe_video_buffer *vbuf = in_buf->pOutputPortPrivate;
|
||||
in_buf->pOutputPortPrivate = task->buf;
|
||||
task->buf = vbuf;
|
||||
} else {
|
||||
/* ------- load input image into video buffer ---- */
|
||||
err = enc_LoadImage(priv, in_buf, task->buf);
|
||||
if (err != OMX_ErrorNone) {
|
||||
FREE(task);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------- determine picture type --------- */
|
||||
if (!(priv->pic_order_cnt % OMX_VID_ENC_IDR_PERIOD_DEFAULT) ||
|
||||
priv->force_pic_type.IntraRefreshVOP) {
|
||||
enc_ClearBframes(priv, inp);
|
||||
picture_type = PIPE_H2645_ENC_PICTURE_TYPE_IDR;
|
||||
priv->force_pic_type.IntraRefreshVOP = OMX_FALSE;
|
||||
priv->frame_num = 0;
|
||||
} else if (priv->codec->profile == PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE ||
|
||||
!(priv->pic_order_cnt % OMX_VID_ENC_P_PERIOD_DEFAULT) ||
|
||||
(in_buf->nFlags & OMX_BUFFERFLAG_EOS)) {
|
||||
picture_type = PIPE_H2645_ENC_PICTURE_TYPE_P;
|
||||
} else {
|
||||
picture_type = PIPE_H2645_ENC_PICTURE_TYPE_B;
|
||||
}
|
||||
|
||||
task->pic_order_cnt = priv->pic_order_cnt++;
|
||||
|
||||
if (picture_type == PIPE_H2645_ENC_PICTURE_TYPE_B) {
|
||||
/* put frame at the tail of the queue */
|
||||
list_addtail(&task->list, &priv->b_frames);
|
||||
} else {
|
||||
/* handle I or P frame */
|
||||
priv->ref_idx_l0 = priv->ref_idx_l1;
|
||||
enc_HandleTask(priv, task, picture_type);
|
||||
list_addtail(&task->list, &priv->stacked_tasks);
|
||||
LIST_FOR_EACH_ENTRY(task, &priv->stacked_tasks, list) {
|
||||
++stacked_num;
|
||||
}
|
||||
if (stacked_num == priv->stacked_frames_num) {
|
||||
struct encode_task *t;
|
||||
t = list_entry(priv->stacked_tasks.next, struct encode_task, list);
|
||||
list_del(&t->list);
|
||||
list_addtail(&t->list, &inp->tasks);
|
||||
}
|
||||
priv->ref_idx_l1 = priv->frame_num++;
|
||||
|
||||
/* handle B frames */
|
||||
LIST_FOR_EACH_ENTRY(task, &priv->b_frames, list) {
|
||||
enc_HandleTask(priv, task, PIPE_H2645_ENC_PICTURE_TYPE_B);
|
||||
if (!priv->restricted_b_frames)
|
||||
priv->ref_idx_l0 = priv->frame_num;
|
||||
priv->frame_num++;
|
||||
}
|
||||
|
||||
enc_MoveTasks(&priv->b_frames, &inp->tasks);
|
||||
}
|
||||
|
||||
if (list_is_empty(&inp->tasks)) {
|
||||
return h264e_buffer_emptied(priv, in_buf);
|
||||
} else {
|
||||
return h264e_manage_buffers(priv);
|
||||
}
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_prc_create_encoder(void *ap_obj)
|
||||
{
|
||||
vid_enc_PrivateType *priv = ap_obj;
|
||||
struct pipe_screen *screen;
|
||||
|
||||
priv->screen = omx_get_screen();
|
||||
if (!priv->screen)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
screen = priv->screen->pscreen;
|
||||
if (!vl_codec_supported(screen, PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH, true))
|
||||
return OMX_ErrorBadParameter;
|
||||
|
||||
priv->s_pipe = pipe_create_multimedia_context(screen);
|
||||
if (!priv->s_pipe)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
enc_InitCompute_common(priv);
|
||||
|
||||
if (!vl_compositor_init(&priv->compositor, priv->s_pipe)) {
|
||||
priv->s_pipe->destroy(priv->s_pipe);
|
||||
priv->s_pipe = NULL;
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
if (!vl_compositor_init_state(&priv->cstate, priv->s_pipe)) {
|
||||
vl_compositor_cleanup(&priv->compositor);
|
||||
priv->s_pipe->destroy(priv->s_pipe);
|
||||
priv->s_pipe = NULL;
|
||||
return OMX_ErrorInsufficientResources;
|
||||
}
|
||||
|
||||
priv->t_pipe = pipe_create_multimedia_context(screen);
|
||||
if (!priv->t_pipe)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
list_inithead(&priv->free_tasks);
|
||||
list_inithead(&priv->used_tasks);
|
||||
list_inithead(&priv->b_frames);
|
||||
list_inithead(&priv->stacked_tasks);
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static void h264e_prc_destroy_encoder(void *ap_obj)
|
||||
{
|
||||
vid_enc_PrivateType *priv = ap_obj;
|
||||
int i;
|
||||
|
||||
assert (priv);
|
||||
|
||||
enc_ReleaseTasks(&priv->free_tasks);
|
||||
enc_ReleaseTasks(&priv->used_tasks);
|
||||
enc_ReleaseTasks(&priv->b_frames);
|
||||
enc_ReleaseTasks(&priv->stacked_tasks);
|
||||
|
||||
for (i = 0; i < OMX_VID_ENC_NUM_SCALING_BUFFERS; ++i)
|
||||
if (priv->scale_buffer[i])
|
||||
priv->scale_buffer[i]->destroy(priv->scale_buffer[i]);
|
||||
|
||||
if (priv->s_pipe) {
|
||||
vl_compositor_cleanup_state(&priv->cstate);
|
||||
vl_compositor_cleanup(&priv->compositor);
|
||||
enc_ReleaseCompute_common(priv);
|
||||
priv->s_pipe->destroy(priv->s_pipe);
|
||||
}
|
||||
|
||||
if (priv->t_pipe)
|
||||
priv->t_pipe->destroy(priv->t_pipe);
|
||||
|
||||
if (priv->screen)
|
||||
omx_put_screen();
|
||||
}
|
||||
|
||||
/*
|
||||
* h264eprc
|
||||
*/
|
||||
|
||||
static void * h264e_prc_ctor(void *ap_obj, va_list * app)
|
||||
{
|
||||
vid_enc_PrivateType *priv = super_ctor(typeOf(ap_obj, "h264eprc"), ap_obj, app);
|
||||
assert (priv);
|
||||
|
||||
if (h264e_prc_create_encoder(ap_obj) != OMX_ErrorNone)
|
||||
return priv;
|
||||
|
||||
priv->p_inhdr_ = 0;
|
||||
priv->p_outhdr_ = 0;
|
||||
priv->profile_level.eProfile = OMX_VIDEO_AVCProfileBaseline;
|
||||
priv->profile_level.eLevel = OMX_VIDEO_AVCLevel51;
|
||||
priv->force_pic_type.IntraRefreshVOP = OMX_FALSE;
|
||||
priv->frame_num = 0;
|
||||
priv->pic_order_cnt = 0;
|
||||
priv->restricted_b_frames = debug_get_bool_option("OMX_USE_RESTRICTED_B_FRAMES", false);
|
||||
priv->scale.xWidth = OMX_VID_ENC_SCALING_WIDTH_DEFAULT;
|
||||
priv->scale.xHeight = OMX_VID_ENC_SCALING_WIDTH_DEFAULT;
|
||||
priv->in_port_disabled_ = false;
|
||||
priv->out_port_disabled_ = false;
|
||||
reset_stream_parameters(priv);
|
||||
|
||||
return priv;
|
||||
}
|
||||
|
||||
static void * h264e_prc_dtor(void *ap_obj)
|
||||
{
|
||||
h264e_prc_destroy_encoder(ap_obj);
|
||||
return super_dtor(typeOf(ap_obj, "h264eprc"), ap_obj);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_prc_allocate_resources(void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
vid_enc_PrivateType *priv = ap_obj;
|
||||
|
||||
assert(priv);
|
||||
if (!priv->screen)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_prc_deallocate_resources(void *ap_obj)
|
||||
{
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_prc_prepare_to_transfer(void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
vid_enc_PrivateType *priv = ap_obj;
|
||||
|
||||
assert(priv);
|
||||
|
||||
init_port_structs(priv);
|
||||
|
||||
priv->eos_ = false;
|
||||
|
||||
struct pipe_video_codec templat = {};
|
||||
|
||||
templat.profile = enc_TranslateOMXProfileToPipe(priv->profile_level.eProfile);
|
||||
templat.level = enc_TranslateOMXLevelToPipe(priv->profile_level.eLevel);
|
||||
templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
|
||||
templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
|
||||
templat.width = priv->scale_buffer[priv->current_scale_buffer] ?
|
||||
priv->scale.xWidth : priv->in_port_def_.format.video.nFrameWidth;
|
||||
templat.height = priv->scale_buffer[priv->current_scale_buffer] ?
|
||||
priv->scale.xHeight : priv->in_port_def_.format.video.nFrameHeight;
|
||||
|
||||
if (templat.profile == PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE) {
|
||||
struct pipe_screen *screen = priv->screen->pscreen;
|
||||
templat.max_references = 1;
|
||||
priv->stacked_frames_num =
|
||||
screen->get_video_param(screen,
|
||||
PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH,
|
||||
PIPE_VIDEO_ENTRYPOINT_ENCODE,
|
||||
PIPE_VIDEO_CAP_STACKED_FRAMES);
|
||||
} else {
|
||||
templat.max_references = OMX_VID_ENC_P_PERIOD_DEFAULT;
|
||||
priv->stacked_frames_num = 1;
|
||||
}
|
||||
priv->codec = priv->s_pipe->create_video_codec(priv->s_pipe, &templat);
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_prc_transfer_and_process(void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_prc_stop_and_return(void *ap_obj)
|
||||
{
|
||||
vid_enc_PrivateType *priv = (vid_enc_PrivateType *) ap_obj;
|
||||
return h264e_release_all_headers(priv);
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_prc_buffers_ready(const void *ap_obj)
|
||||
{
|
||||
vid_enc_PrivateType *priv = (vid_enc_PrivateType *) ap_obj;
|
||||
OMX_BUFFERHEADERTYPE *in_buf = NULL;
|
||||
OMX_BUFFERHEADERTYPE *out_buf = NULL;
|
||||
OMX_ERRORTYPE r = OMX_ErrorNone;
|
||||
|
||||
assert(priv);
|
||||
|
||||
/* Don't get input buffer if output buffer not found */
|
||||
while (!priv->eos_ && (out_buf = get_output_buffer(priv)) && (in_buf = get_input_buffer(priv))) {
|
||||
if (!priv->out_port_disabled_) {
|
||||
r = encode_frame(priv, in_buf);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_prc_port_flush(const void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
vid_enc_PrivateType *priv = (vid_enc_PrivateType *) ap_obj;
|
||||
if (OMX_ALL == a_pid || OMX_VID_ENC_AVC_INPUT_PORT_INDEX == a_pid) {
|
||||
release_input_header(priv);
|
||||
reset_stream_parameters(priv);
|
||||
}
|
||||
if (OMX_ALL == a_pid || OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX == a_pid) {
|
||||
release_output_header(priv);
|
||||
}
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_prc_port_disable(const void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
vid_enc_PrivateType *priv = (vid_enc_PrivateType *) ap_obj;
|
||||
assert(priv);
|
||||
if (OMX_ALL == a_pid || OMX_VID_ENC_AVC_INPUT_PORT_INDEX == a_pid) {
|
||||
/* Release all buffers */
|
||||
h264e_release_all_headers(priv);
|
||||
reset_stream_parameters(priv);
|
||||
priv->in_port_disabled_ = true;
|
||||
}
|
||||
if (OMX_ALL == a_pid || OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX == a_pid) {
|
||||
release_output_header(priv);
|
||||
priv->out_port_disabled_ = true;
|
||||
}
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE h264e_prc_port_enable(const void *ap_obj, OMX_U32 a_pid)
|
||||
{
|
||||
vid_enc_PrivateType * priv = (vid_enc_PrivateType *) ap_obj;
|
||||
assert(priv);
|
||||
if (OMX_ALL == a_pid || OMX_VID_ENC_AVC_INPUT_PORT_INDEX == a_pid) {
|
||||
if (priv->in_port_disabled_) {
|
||||
reset_stream_parameters(priv);
|
||||
priv->in_port_disabled_ = false;
|
||||
}
|
||||
}
|
||||
if (OMX_ALL == a_pid || OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX == a_pid) {
|
||||
priv->out_port_disabled_ = false;
|
||||
}
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
/*
|
||||
* h264e_prc_class
|
||||
*/
|
||||
|
||||
static void * h264e_prc_class_ctor(void *ap_obj, va_list * app)
|
||||
{
|
||||
/* NOTE: Class methods might be added in the future. None for now. */
|
||||
return super_ctor(typeOf(ap_obj, "h264eprc_class"), ap_obj, app);
|
||||
}
|
||||
|
||||
/*
|
||||
* initialization
|
||||
*/
|
||||
|
||||
void * h264e_prc_class_init(void * ap_tos, void * ap_hdl)
|
||||
{
|
||||
void * tizprc = tiz_get_type(ap_hdl, "tizprc");
|
||||
void * h264eprc_class = factory_new
|
||||
/* TIZ_CLASS_COMMENT: class type, class name, parent, size */
|
||||
(classOf(tizprc), "h264eprc_class", classOf(tizprc),
|
||||
sizeof(h264e_prc_class_t),
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
ap_tos, ap_hdl,
|
||||
/* TIZ_CLASS_COMMENT: class constructor */
|
||||
ctor, h264e_prc_class_ctor,
|
||||
/* TIZ_CLASS_COMMENT: stop value*/
|
||||
0);
|
||||
return h264eprc_class;
|
||||
}
|
||||
|
||||
void * h264e_prc_init(void * ap_tos, void * ap_hdl)
|
||||
{
|
||||
void * tizprc = tiz_get_type(ap_hdl, "tizprc");
|
||||
void * h264eprc_class = tiz_get_type(ap_hdl, "h264eprc_class");
|
||||
TIZ_LOG_CLASS (h264eprc_class);
|
||||
void * h264eprc = factory_new
|
||||
/* TIZ_CLASS_COMMENT: class type, class name, parent, size */
|
||||
(h264eprc_class, "h264eprc", tizprc, sizeof(vid_enc_PrivateType),
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
ap_tos, ap_hdl,
|
||||
/* TIZ_CLASS_COMMENT: class constructor */
|
||||
ctor, h264e_prc_ctor,
|
||||
/* TIZ_CLASS_COMMENT: class destructor */
|
||||
dtor, h264e_prc_dtor,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_srv_allocate_resources, h264e_prc_allocate_resources,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_srv_deallocate_resources, h264e_prc_deallocate_resources,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_srv_prepare_to_transfer, h264e_prc_prepare_to_transfer,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_srv_transfer_and_process, h264e_prc_transfer_and_process,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_srv_stop_and_return, h264e_prc_stop_and_return,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_prc_buffers_ready, h264e_prc_buffers_ready,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_prc_port_flush, h264e_prc_port_flush,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_prc_port_disable, h264e_prc_port_disable,
|
||||
/* TIZ_CLASS_COMMENT: */
|
||||
tiz_prc_port_enable, h264e_prc_port_enable,
|
||||
/* TIZ_CLASS_COMMENT: stop value*/
|
||||
0);
|
||||
|
||||
return h264eprc;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef H264EPRC_H
|
||||
#define H264EPRC_H
|
||||
|
||||
void * h264e_prc_class_init(void * ap_tos, void * ap_hdl);
|
||||
void * h264e_prc_init(void * ap_tos, void * ap_hdl);
|
||||
|
||||
#endif /* H264EPRC_H */
|
||||
@@ -1,30 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef OMX_TIZ_NAMES_H
|
||||
#define OMX_TIZ_NAMES_H
|
||||
|
||||
#define OMX_VID_COMP_NAME "OMX.mesa.video.all"
|
||||
|
||||
#endif
|
||||
@@ -1,157 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#if ENABLE_ST_OMX_TIZONIA
|
||||
#include <tizkernel.h>
|
||||
#endif
|
||||
|
||||
#include "util/u_memory.h"
|
||||
#include "vl/vl_winsys.h"
|
||||
#include "vl/vl_video_buffer.h"
|
||||
#include "util/u_surface.h"
|
||||
|
||||
#include "vid_dec_common.h"
|
||||
#include "vid_dec_h264_common.h"
|
||||
|
||||
void vid_dec_NeedTarget(vid_dec_PrivateType *priv)
|
||||
{
|
||||
struct pipe_video_buffer templat = {};
|
||||
struct vl_screen *omx_screen;
|
||||
struct pipe_screen *pscreen;
|
||||
|
||||
omx_screen = priv->screen;
|
||||
assert(omx_screen);
|
||||
|
||||
pscreen = omx_screen->pscreen;
|
||||
assert(pscreen);
|
||||
|
||||
if (!priv->target) {
|
||||
memset(&templat, 0, sizeof(templat));
|
||||
|
||||
templat.width = priv->codec->width;
|
||||
templat.height = priv->codec->height;
|
||||
templat.buffer_format = pscreen->get_video_param(
|
||||
pscreen,
|
||||
priv->profile,
|
||||
PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
||||
PIPE_VIDEO_CAP_PREFERED_FORMAT
|
||||
);
|
||||
templat.interlaced = pscreen->get_video_param(
|
||||
pscreen,
|
||||
priv->profile,
|
||||
PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
||||
PIPE_VIDEO_CAP_PREFERS_INTERLACED
|
||||
);
|
||||
|
||||
priv->target = priv->pipe->create_video_buffer(priv->pipe, &templat);
|
||||
}
|
||||
}
|
||||
|
||||
void vid_dec_FillOutput(vid_dec_PrivateType *priv, struct pipe_video_buffer *buf,
|
||||
OMX_BUFFERHEADERTYPE* output)
|
||||
{
|
||||
#if ENABLE_ST_OMX_TIZONIA
|
||||
tiz_port_t *out_port = tiz_krn_get_port(tiz_get_krn(handleOf(priv)),
|
||||
OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX);
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE *def = &out_port->portdef_.format.video;
|
||||
#else
|
||||
omx_base_PortType *port = priv->ports[OMX_BASE_FILTER_OUTPUTPORT_INDEX];
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE *def = &port->sPortParam.format.video;
|
||||
#endif
|
||||
|
||||
struct pipe_sampler_view **views;
|
||||
unsigned i, j;
|
||||
unsigned width, height;
|
||||
|
||||
views = buf->get_sampler_view_planes(buf);
|
||||
|
||||
#if ENABLE_ST_OMX_TIZONIA
|
||||
if (!output->pBuffer) {
|
||||
struct pipe_video_buffer *dst_buf = NULL;
|
||||
struct pipe_surface **dst_surface = NULL;
|
||||
struct u_rect src_rect;
|
||||
struct u_rect dst_rect;
|
||||
struct vl_compositor *compositor = &priv->compositor;
|
||||
struct vl_compositor_state *s = &priv->cstate;
|
||||
enum vl_compositor_deinterlace deinterlace = VL_COMPOSITOR_WEAVE;
|
||||
|
||||
dst_buf = util_hash_table_get(priv->video_buffer_map, output);
|
||||
assert(dst_buf);
|
||||
|
||||
dst_surface = dst_buf->get_surfaces(dst_buf);
|
||||
assert(views);
|
||||
|
||||
src_rect.x0 = 0;
|
||||
src_rect.y0 = 0;
|
||||
src_rect.x1 = def->nFrameWidth;
|
||||
src_rect.y1 = def->nFrameHeight;
|
||||
|
||||
dst_rect.x0 = 0;
|
||||
dst_rect.y0 = 0;
|
||||
dst_rect.x1 = def->nFrameWidth;
|
||||
dst_rect.y1 = def->nFrameHeight;
|
||||
|
||||
vl_compositor_clear_layers(s);
|
||||
vl_compositor_set_buffer_layer(s, compositor, 0, buf,
|
||||
&src_rect, NULL, deinterlace);
|
||||
vl_compositor_set_layer_dst_area(s, 0, &dst_rect);
|
||||
vl_compositor_render(s, compositor, dst_surface[0], NULL, false);
|
||||
|
||||
priv->pipe->flush(priv->pipe, NULL, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 2 /* NV12 */; i++) {
|
||||
if (!views[i]) continue;
|
||||
width = def->nFrameWidth;
|
||||
height = def->nFrameHeight;
|
||||
vl_video_buffer_adjust_size(&width, &height, i,
|
||||
pipe_format_to_chroma_format(buf->buffer_format),
|
||||
buf->interlaced);
|
||||
for (j = 0; j < views[i]->texture->array_size; ++j) {
|
||||
struct pipe_box box;
|
||||
u_box_3d(0, 0, j, width, height, 1, &box);
|
||||
struct pipe_transfer *transfer;
|
||||
uint8_t *map, *dst;
|
||||
map = priv->pipe->texture_map(priv->pipe, views[i]->texture, 0,
|
||||
PIPE_MAP_READ, &box, &transfer);
|
||||
if (!map)
|
||||
return;
|
||||
|
||||
dst = ((uint8_t*)output->pBuffer + output->nOffset) + j * def->nStride +
|
||||
i * def->nFrameWidth * def->nFrameHeight;
|
||||
util_copy_rect(dst,
|
||||
views[i]->texture->format,
|
||||
def->nStride * views[i]->texture->array_size, 0, 0,
|
||||
box.width, box.height, map, transfer->stride, 0, 0);
|
||||
|
||||
pipe_texture_unmap(priv->pipe, transfer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef VID_DEC_COMMON_H
|
||||
#define VID_DEC_COMMON_H
|
||||
|
||||
#include "util/list.h"
|
||||
#include "util/vl_rbsp.h"
|
||||
|
||||
#include "vl/vl_compositor.h"
|
||||
#include "vl/vl_zscan.h"
|
||||
|
||||
#include "bellagio/vid_dec_av1.h"
|
||||
|
||||
#include <OMX_Core.h>
|
||||
#include <OMX_Types.h>
|
||||
|
||||
#if ENABLE_ST_OMX_BELLAGIO
|
||||
|
||||
#include <bellagio/st_static_component_loader.h>
|
||||
#include <bellagio/omx_base_filter.h>
|
||||
#include <bellagio/omx_base_video_port.h>
|
||||
|
||||
DERIVEDCLASS(vid_dec_PrivateType, omx_base_filter_PrivateType)
|
||||
#define vid_dec_PrivateType_FIELDS omx_base_filter_PrivateType_FIELDS \
|
||||
enum pipe_video_profile profile; \
|
||||
struct vl_screen *screen; \
|
||||
struct pipe_context *pipe; \
|
||||
struct pipe_video_codec *codec; \
|
||||
void (*Decode)(vid_dec_PrivateType *priv, struct vl_vlc *vlc, unsigned min_bits_left); \
|
||||
void (*EndFrame)(vid_dec_PrivateType *priv); \
|
||||
struct pipe_video_buffer *(*Flush)(vid_dec_PrivateType *priv, OMX_TICKS *timestamp); \
|
||||
struct pipe_video_buffer *target, *shadow; \
|
||||
union { \
|
||||
struct { \
|
||||
uint8_t intra_matrix[64]; \
|
||||
uint8_t non_intra_matrix[64]; \
|
||||
} mpeg12; \
|
||||
struct { \
|
||||
unsigned nal_ref_idc; \
|
||||
bool IdrPicFlag; \
|
||||
unsigned idr_pic_id; \
|
||||
unsigned pic_order_cnt_lsb; \
|
||||
unsigned pic_order_cnt_msb; \
|
||||
unsigned delta_pic_order_cnt_bottom; \
|
||||
unsigned delta_pic_order_cnt[2]; \
|
||||
unsigned prevFrameNumOffset; \
|
||||
struct pipe_h264_sps sps[32]; \
|
||||
struct pipe_h264_pps pps[256]; \
|
||||
struct list_head dpb_list; \
|
||||
unsigned dpb_num; \
|
||||
} h264; \
|
||||
struct { \
|
||||
unsigned temporal_id; \
|
||||
unsigned level_idc; \
|
||||
unsigned pic_width_in_luma_samples; \
|
||||
unsigned pic_height_in_luma_samples; \
|
||||
bool IdrPicFlag; \
|
||||
int slice_prev_poc; \
|
||||
void *ref_pic_set_list; \
|
||||
void *rps; \
|
||||
struct pipe_h265_sps sps[16]; \
|
||||
struct pipe_h265_pps pps[64]; \
|
||||
struct list_head dpb_list; \
|
||||
unsigned dpb_num; \
|
||||
} h265; \
|
||||
struct dec_av1 av1; \
|
||||
} codec_data; \
|
||||
union { \
|
||||
struct pipe_picture_desc base; \
|
||||
struct pipe_mpeg12_picture_desc mpeg12; \
|
||||
struct pipe_h264_picture_desc h264; \
|
||||
struct pipe_h265_picture_desc h265; \
|
||||
struct pipe_av1_picture_desc av1; \
|
||||
} picture; \
|
||||
unsigned num_in_buffers; \
|
||||
OMX_BUFFERHEADERTYPE *in_buffers[2]; \
|
||||
const void *inputs[2]; \
|
||||
unsigned sizes[2]; \
|
||||
OMX_TICKS timestamps[2]; \
|
||||
OMX_TICKS timestamp; \
|
||||
bool first_buf_in_frame; \
|
||||
bool frame_finished; \
|
||||
bool frame_started; \
|
||||
unsigned bytes_left; \
|
||||
const void *slice; \
|
||||
bool disable_tunnel; \
|
||||
struct vl_compositor compositor; \
|
||||
struct vl_compositor_state cstate;
|
||||
ENDCLASS(vid_dec_PrivateType)
|
||||
|
||||
#else
|
||||
|
||||
#include <tizprc_decls.h>
|
||||
#include <tizport_decls.h>
|
||||
|
||||
#include "util/list.h"
|
||||
#include "util/u_hash_table.h"
|
||||
|
||||
#include "pipe/p_video_state.h"
|
||||
|
||||
typedef struct h264d_prc_class h264d_prc_class_t;
|
||||
struct h264d_prc_class
|
||||
{
|
||||
/* Class */
|
||||
const tiz_prc_class_t _;
|
||||
/* NOTE: Class methods might be added in the future */
|
||||
};
|
||||
|
||||
typedef struct h264d_stream_info h264d_stream_info_t;
|
||||
struct h264d_stream_info
|
||||
{
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
};
|
||||
|
||||
typedef struct h264d_prc vid_dec_PrivateType;
|
||||
struct h264d_prc
|
||||
{
|
||||
/* Object */
|
||||
const tiz_prc_t _;
|
||||
OMX_BUFFERHEADERTYPE *in_buffers[2];
|
||||
OMX_BUFFERHEADERTYPE *p_inhdr_;
|
||||
OMX_BUFFERHEADERTYPE *p_outhdr_;
|
||||
OMX_PARAM_PORTDEFINITIONTYPE out_port_def_;
|
||||
const void *inputs[2];
|
||||
unsigned sizes[2];
|
||||
OMX_TICKS timestamps[2];
|
||||
OMX_TICKS timestamp;
|
||||
bool eos_;
|
||||
bool in_port_disabled_;
|
||||
bool out_port_disabled_;
|
||||
struct vl_screen *screen;
|
||||
struct pipe_context *pipe;
|
||||
struct pipe_video_codec *codec;
|
||||
struct pipe_video_buffer *target;
|
||||
enum pipe_video_profile profile;
|
||||
struct hash_table *video_buffer_map;
|
||||
union {
|
||||
struct {
|
||||
unsigned nal_ref_idc;
|
||||
bool IdrPicFlag;
|
||||
unsigned idr_pic_id;
|
||||
unsigned pic_order_cnt_lsb;
|
||||
unsigned pic_order_cnt_msb;
|
||||
unsigned delta_pic_order_cnt_bottom;
|
||||
unsigned delta_pic_order_cnt[2];
|
||||
unsigned prevFrameNumOffset;
|
||||
struct pipe_h264_sps sps[32];
|
||||
struct pipe_h264_pps pps[256];
|
||||
struct list_head dpb_list;
|
||||
unsigned dpb_num;
|
||||
} h264;
|
||||
} codec_data;
|
||||
union {
|
||||
struct pipe_picture_desc base;
|
||||
struct pipe_h264_picture_desc h264;
|
||||
} picture;
|
||||
h264d_stream_info_t stream_info;
|
||||
unsigned num_in_buffers;
|
||||
bool first_buf_in_frame;
|
||||
bool frame_finished;
|
||||
bool frame_started;
|
||||
unsigned bytes_left;
|
||||
const void *slice;
|
||||
bool disable_tunnel;
|
||||
struct vl_compositor compositor;
|
||||
struct vl_compositor_state cstate;
|
||||
bool use_eglimage;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
void vid_dec_NeedTarget(vid_dec_PrivateType* priv);
|
||||
void vid_dec_FillOutput(vid_dec_PrivateType* priv, struct pipe_video_buffer* buf,
|
||||
OMX_BUFFERHEADERTYPE* output);
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,99 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef VID_DEC_H264_COMMON_H
|
||||
#define VID_DEC_H264_COMMON_H
|
||||
|
||||
#include "vid_dec_common.h"
|
||||
|
||||
#define OMX_VID_DEC_AVC_DEFAULT_FRAME_WIDTH 176
|
||||
#define OMX_VID_DEC_AVC_DEFAULT_FRAME_HEIGHT 144
|
||||
#define OMX_VID_DEC_AVC_DEFAULT_FRAME_RATE 15<<16
|
||||
#define OMX_VID_DEC_AVC_ROLE "video_decoder.avc"
|
||||
/* With libtizonia, port indexes must start at index 0 */
|
||||
#define OMX_VID_DEC_AVC_INPUT_PORT_INDEX 0
|
||||
#define OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX 1
|
||||
#define OMX_VID_DEC_AVC_INPUT_PORT_MIN_BUF_COUNT 8
|
||||
#define OMX_VID_DEC_AVC_OUTPUT_PORT_MIN_BUF_COUNT 4
|
||||
/* 38016 = (width * height) + ((width * height)/2) */
|
||||
#define OMX_VID_DEC_AVC_PORT_MIN_INPUT_BUF_SIZE 38016
|
||||
#define OMX_VID_DEC_AVC_PORT_MIN_OUTPUT_BUF_SIZE 345600
|
||||
#define OMX_VID_DEC_AVC_PORT_NONCONTIGUOUS OMX_FALSE
|
||||
#define OMX_VID_DEC_AVC_PORT_ALIGNMENT 0
|
||||
#define OMX_VID_DEC_AVC_PORT_SUPPLIERPREF OMX_BufferSupplyInput
|
||||
#define OMX_VID_DEC_AVC_TIMESTAMP_INVALID ((OMX_TICKS) -1)
|
||||
|
||||
#define DPB_MAX_SIZE 5
|
||||
|
||||
struct dpb_list {
|
||||
struct list_head list;
|
||||
struct pipe_video_buffer *buffer;
|
||||
OMX_TICKS timestamp;
|
||||
int poc;
|
||||
};
|
||||
|
||||
static const uint8_t Default_4x4_Intra[16] = {
|
||||
6, 13, 20, 28, 13, 20, 28, 32,
|
||||
20, 28, 32, 37, 28, 32, 37, 42
|
||||
};
|
||||
|
||||
static const uint8_t Default_4x4_Inter[16] = {
|
||||
10, 14, 20, 24, 14, 20, 24, 27,
|
||||
20, 24, 27, 30, 24, 27, 30, 34
|
||||
};
|
||||
|
||||
static const uint8_t Default_8x8_Intra[64] = {
|
||||
6, 10, 13, 16, 18, 23, 25, 27,
|
||||
10, 11, 16, 18, 23, 25, 27, 29,
|
||||
13, 16, 18, 23, 25, 27, 29, 31,
|
||||
16, 18, 23, 25, 27, 29, 31, 33,
|
||||
18, 23, 25, 27, 29, 31, 33, 36,
|
||||
23, 25, 27, 29, 31, 33, 36, 38,
|
||||
25, 27, 29, 31, 33, 36, 38, 40,
|
||||
27, 29, 31, 33, 36, 38, 40, 42
|
||||
};
|
||||
|
||||
static const uint8_t Default_8x8_Inter[64] = {
|
||||
9, 13, 15, 17, 19, 21, 22, 24,
|
||||
13, 13, 17, 19, 21, 22, 24, 25,
|
||||
15, 17, 19, 21, 22, 24, 25, 27,
|
||||
17, 19, 21, 22, 24, 25, 27, 28,
|
||||
19, 21, 22, 24, 25, 27, 28, 30,
|
||||
21, 22, 24, 25, 27, 28, 30, 32,
|
||||
22, 24, 25, 27, 28, 30, 32, 33,
|
||||
24, 25, 27, 28, 30, 32, 33, 35
|
||||
};
|
||||
|
||||
struct pipe_video_buffer *vid_dec_h264_Flush(vid_dec_PrivateType *priv,
|
||||
OMX_TICKS *timestamp);
|
||||
void vid_dec_h264_EndFrame(vid_dec_PrivateType *priv);
|
||||
void vid_dec_h264_Decode(vid_dec_PrivateType *priv, struct vl_vlc *vlc, unsigned min_bits_left);
|
||||
void vid_dec_FreeInputPortPrivate(OMX_BUFFERHEADERTYPE *buf);
|
||||
void vid_dec_FrameDecoded_common(vid_dec_PrivateType*priv, OMX_BUFFERHEADERTYPE* input,
|
||||
OMX_BUFFERHEADERTYPE* output);
|
||||
|
||||
#endif
|
||||
@@ -1,573 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "vid_enc_common.h"
|
||||
|
||||
#include "vl/vl_video_buffer.h"
|
||||
#include "tgsi/tgsi_text.h"
|
||||
|
||||
void enc_ReleaseTasks(struct list_head *head)
|
||||
{
|
||||
struct encode_task *i, *next;
|
||||
|
||||
if (!head || !list_is_linked(head))
|
||||
return;
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(i, next, head, list) {
|
||||
pipe_resource_reference(&i->bitstream, NULL);
|
||||
i->buf->destroy(i->buf);
|
||||
FREE(i);
|
||||
}
|
||||
}
|
||||
|
||||
void enc_MoveTasks(struct list_head *from, struct list_head *to)
|
||||
{
|
||||
to->prev->next = from->next;
|
||||
from->next->prev = to->prev;
|
||||
from->prev->next = to;
|
||||
to->prev = from->prev;
|
||||
list_inithead(from);
|
||||
}
|
||||
|
||||
static void enc_GetPictureParamPreset(struct pipe_h264_enc_picture_desc *picture)
|
||||
{
|
||||
picture->motion_est.enc_disable_sub_mode = 0x000000fe;
|
||||
picture->motion_est.enc_ime2_search_range_x = 0x00000001;
|
||||
picture->motion_est.enc_ime2_search_range_y = 0x00000001;
|
||||
picture->seq.enc_constraint_set_flags = 0x00000040;
|
||||
}
|
||||
|
||||
enum pipe_video_profile enc_TranslateOMXProfileToPipe(unsigned omx_profile)
|
||||
{
|
||||
switch (omx_profile) {
|
||||
case OMX_VIDEO_AVCProfileBaseline:
|
||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
|
||||
case OMX_VIDEO_AVCProfileMain:
|
||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
|
||||
case OMX_VIDEO_AVCProfileExtended:
|
||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED;
|
||||
case OMX_VIDEO_AVCProfileHigh:
|
||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
|
||||
case OMX_VIDEO_AVCProfileHigh10:
|
||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH10;
|
||||
case OMX_VIDEO_AVCProfileHigh422:
|
||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH422;
|
||||
case OMX_VIDEO_AVCProfileHigh444:
|
||||
return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH444;
|
||||
default:
|
||||
return PIPE_VIDEO_PROFILE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned enc_TranslateOMXLevelToPipe(unsigned omx_level)
|
||||
{
|
||||
switch (omx_level) {
|
||||
case OMX_VIDEO_AVCLevel1:
|
||||
case OMX_VIDEO_AVCLevel1b:
|
||||
return 10;
|
||||
case OMX_VIDEO_AVCLevel11:
|
||||
return 11;
|
||||
case OMX_VIDEO_AVCLevel12:
|
||||
return 12;
|
||||
case OMX_VIDEO_AVCLevel13:
|
||||
return 13;
|
||||
case OMX_VIDEO_AVCLevel2:
|
||||
return 20;
|
||||
case OMX_VIDEO_AVCLevel21:
|
||||
return 21;
|
||||
case OMX_VIDEO_AVCLevel22:
|
||||
return 22;
|
||||
case OMX_VIDEO_AVCLevel3:
|
||||
return 30;
|
||||
case OMX_VIDEO_AVCLevel31:
|
||||
return 31;
|
||||
case OMX_VIDEO_AVCLevel32:
|
||||
return 32;
|
||||
case OMX_VIDEO_AVCLevel4:
|
||||
return 40;
|
||||
case OMX_VIDEO_AVCLevel41:
|
||||
return 41;
|
||||
default:
|
||||
case OMX_VIDEO_AVCLevel42:
|
||||
return 42;
|
||||
case OMX_VIDEO_AVCLevel5:
|
||||
return 50;
|
||||
case OMX_VIDEO_AVCLevel51:
|
||||
return 51;
|
||||
}
|
||||
}
|
||||
|
||||
void vid_enc_BufferEncoded_common(vid_enc_PrivateType * priv, OMX_BUFFERHEADERTYPE* input, OMX_BUFFERHEADERTYPE* output)
|
||||
{
|
||||
struct output_buf_private *outp = output->pOutputPortPrivate;
|
||||
struct input_buf_private *inp = input->pInputPortPrivate;
|
||||
struct encode_task *task;
|
||||
struct pipe_box box = {};
|
||||
unsigned size;
|
||||
|
||||
#if ENABLE_ST_OMX_BELLAGIO
|
||||
if (!inp || list_is_empty(&inp->tasks)) {
|
||||
input->nFilledLen = 0; /* mark buffer as empty */
|
||||
enc_MoveTasks(&priv->used_tasks, &inp->tasks);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
task = list_entry(inp->tasks.next, struct encode_task, list);
|
||||
list_del(&task->list);
|
||||
list_addtail(&task->list, &priv->used_tasks);
|
||||
|
||||
if (!task->bitstream)
|
||||
return;
|
||||
|
||||
/* ------------- map result buffer ----------------- */
|
||||
|
||||
if (outp->transfer)
|
||||
pipe_buffer_unmap(priv->t_pipe, outp->transfer);
|
||||
|
||||
pipe_resource_reference(&outp->bitstream, task->bitstream);
|
||||
pipe_resource_reference(&task->bitstream, NULL);
|
||||
|
||||
box.width = outp->bitstream->width0;
|
||||
box.height = outp->bitstream->height0;
|
||||
box.depth = outp->bitstream->depth0;
|
||||
|
||||
output->pBuffer = priv->t_pipe->buffer_map(priv->t_pipe, outp->bitstream, 0,
|
||||
PIPE_MAP_READ_WRITE,
|
||||
&box, &outp->transfer);
|
||||
|
||||
/* ------------- get size of result ----------------- */
|
||||
|
||||
priv->codec->get_feedback(priv->codec, task->feedback, &size, NULL);
|
||||
|
||||
output->nOffset = 0;
|
||||
output->nFilledLen = size; /* mark buffer as full */
|
||||
|
||||
/* all output buffers contain exactly one frame */
|
||||
output->nFlags = OMX_BUFFERFLAG_ENDOFFRAME;
|
||||
|
||||
#if ENABLE_ST_OMX_TIZONIA
|
||||
input->nFilledLen = 0; /* mark buffer as empty */
|
||||
enc_MoveTasks(&priv->used_tasks, &inp->tasks);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
struct encode_task *enc_NeedTask_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEFINITIONTYPE *def)
|
||||
{
|
||||
struct pipe_video_buffer templat = {};
|
||||
struct encode_task *task;
|
||||
|
||||
if (!list_is_empty(&priv->free_tasks)) {
|
||||
task = list_entry(priv->free_tasks.next, struct encode_task, list);
|
||||
list_del(&task->list);
|
||||
return task;
|
||||
}
|
||||
|
||||
/* allocate a new one */
|
||||
task = CALLOC_STRUCT(encode_task);
|
||||
if (!task)
|
||||
return NULL;
|
||||
|
||||
templat.buffer_format = PIPE_FORMAT_NV12;
|
||||
templat.width = def->nFrameWidth;
|
||||
templat.height = def->nFrameHeight;
|
||||
templat.interlaced = false;
|
||||
|
||||
task->buf = priv->s_pipe->create_video_buffer(priv->s_pipe, &templat);
|
||||
if (!task->buf) {
|
||||
FREE(task);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
void enc_ScaleInput_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEFINITIONTYPE *def,
|
||||
struct pipe_video_buffer **vbuf, unsigned *size)
|
||||
{
|
||||
struct pipe_video_buffer *src_buf = *vbuf;
|
||||
struct vl_compositor *compositor = &priv->compositor;
|
||||
struct vl_compositor_state *s = &priv->cstate;
|
||||
struct pipe_sampler_view **views;
|
||||
struct pipe_surface **dst_surface;
|
||||
unsigned i;
|
||||
|
||||
if (!priv->scale_buffer[priv->current_scale_buffer])
|
||||
return;
|
||||
|
||||
views = src_buf->get_sampler_view_planes(src_buf);
|
||||
dst_surface = priv->scale_buffer[priv->current_scale_buffer]->get_surfaces
|
||||
(priv->scale_buffer[priv->current_scale_buffer]);
|
||||
vl_compositor_clear_layers(s);
|
||||
|
||||
for (i = 0; i < VL_MAX_SURFACES; ++i) {
|
||||
struct u_rect src_rect;
|
||||
if (!views[i] || !dst_surface[i])
|
||||
continue;
|
||||
src_rect.x0 = 0;
|
||||
src_rect.y0 = 0;
|
||||
src_rect.x1 = def->nFrameWidth;
|
||||
src_rect.y1 = def->nFrameHeight;
|
||||
if (i > 0) {
|
||||
src_rect.x1 /= 2;
|
||||
src_rect.y1 /= 2;
|
||||
}
|
||||
vl_compositor_set_rgba_layer(s, compositor, 0, views[i], &src_rect, NULL, NULL);
|
||||
vl_compositor_render(s, compositor, dst_surface[i], NULL, false);
|
||||
}
|
||||
*size = priv->scale.xWidth * priv->scale.xHeight * 2;
|
||||
*vbuf = priv->scale_buffer[priv->current_scale_buffer++];
|
||||
priv->current_scale_buffer %= OMX_VID_ENC_NUM_SCALING_BUFFERS;
|
||||
}
|
||||
|
||||
void enc_ControlPicture_common(vid_enc_PrivateType * priv, struct pipe_h264_enc_picture_desc *picture)
|
||||
{
|
||||
struct pipe_h264_enc_rate_control *rate_ctrl = &picture->rate_ctrl[0];
|
||||
|
||||
/* Get bitrate from port */
|
||||
switch (priv->bitrate.eControlRate) {
|
||||
case OMX_Video_ControlRateVariable:
|
||||
rate_ctrl->rate_ctrl_method = PIPE_H2645_ENC_RATE_CONTROL_METHOD_VARIABLE;
|
||||
break;
|
||||
case OMX_Video_ControlRateConstant:
|
||||
rate_ctrl->rate_ctrl_method = PIPE_H2645_ENC_RATE_CONTROL_METHOD_CONSTANT;
|
||||
break;
|
||||
case OMX_Video_ControlRateVariableSkipFrames:
|
||||
rate_ctrl->rate_ctrl_method = PIPE_H2645_ENC_RATE_CONTROL_METHOD_VARIABLE_SKIP;
|
||||
break;
|
||||
case OMX_Video_ControlRateConstantSkipFrames:
|
||||
rate_ctrl->rate_ctrl_method = PIPE_H2645_ENC_RATE_CONTROL_METHOD_CONSTANT_SKIP;
|
||||
break;
|
||||
default:
|
||||
rate_ctrl->rate_ctrl_method = PIPE_H2645_ENC_RATE_CONTROL_METHOD_DISABLE;
|
||||
break;
|
||||
}
|
||||
|
||||
rate_ctrl->frame_rate_den = OMX_VID_ENC_CONTROL_FRAME_RATE_DEN_DEFAULT;
|
||||
rate_ctrl->frame_rate_num = ((priv->frame_rate) >> 16) * rate_ctrl->frame_rate_den;
|
||||
|
||||
if (rate_ctrl->rate_ctrl_method != PIPE_H2645_ENC_RATE_CONTROL_METHOD_DISABLE) {
|
||||
if (priv->bitrate.nTargetBitrate < OMX_VID_ENC_BITRATE_MIN)
|
||||
rate_ctrl->target_bitrate = OMX_VID_ENC_BITRATE_MIN;
|
||||
else if (priv->bitrate.nTargetBitrate < OMX_VID_ENC_BITRATE_MAX)
|
||||
rate_ctrl->target_bitrate = priv->bitrate.nTargetBitrate;
|
||||
else
|
||||
rate_ctrl->target_bitrate = OMX_VID_ENC_BITRATE_MAX;
|
||||
rate_ctrl->peak_bitrate = rate_ctrl->target_bitrate;
|
||||
if (rate_ctrl->target_bitrate < OMX_VID_ENC_BITRATE_MEDIAN)
|
||||
rate_ctrl->vbv_buffer_size = MIN2((rate_ctrl->target_bitrate * 2.75), OMX_VID_ENC_BITRATE_MEDIAN);
|
||||
else
|
||||
rate_ctrl->vbv_buffer_size = rate_ctrl->target_bitrate;
|
||||
|
||||
if (rate_ctrl->frame_rate_num) {
|
||||
unsigned long long t = rate_ctrl->target_bitrate;
|
||||
t *= rate_ctrl->frame_rate_den;
|
||||
rate_ctrl->target_bits_picture = t / rate_ctrl->frame_rate_num;
|
||||
} else {
|
||||
rate_ctrl->target_bits_picture = rate_ctrl->target_bitrate;
|
||||
}
|
||||
rate_ctrl->peak_bits_picture_integer = rate_ctrl->target_bits_picture;
|
||||
rate_ctrl->peak_bits_picture_fraction = 0;
|
||||
}
|
||||
|
||||
picture->quant_i_frames = priv->quant.nQpI;
|
||||
picture->quant_p_frames = priv->quant.nQpP;
|
||||
picture->quant_b_frames = priv->quant.nQpB;
|
||||
|
||||
picture->frame_num = priv->frame_num;
|
||||
picture->num_ref_idx_l0_active_minus1 = 0;
|
||||
picture->ref_idx_l0_list[0] = priv->ref_idx_l0;
|
||||
picture->num_ref_idx_l1_active_minus1 = 0;
|
||||
picture->ref_idx_l1_list[0] = priv->ref_idx_l1;
|
||||
picture->enable_vui = (picture->rate_ctrl[0].frame_rate_num != 0);
|
||||
enc_GetPictureParamPreset(picture);
|
||||
|
||||
uint8_t ref_idx = (priv->frame_num + 1) % 2;
|
||||
picture->header_flags.value = 0;
|
||||
if (picture->picture_type == PIPE_H2645_ENC_PICTURE_TYPE_IDR) {
|
||||
picture->header_flags.sps = 1;
|
||||
picture->header_flags.pps = 1;
|
||||
picture->ref_list0[0] = PIPE_H2645_LIST_REF_INVALID_ENTRY;
|
||||
} else {
|
||||
picture->ref_list0[0] = ref_idx;
|
||||
}
|
||||
picture->header_flags.aud = 1;
|
||||
picture->slice.frame_num = priv->frame_num;
|
||||
picture->slice.pic_order_cnt_lsb = priv->pic_order_cnt % 16;
|
||||
picture->dpb_size = 2;
|
||||
picture->dpb_curr_pic = priv->frame_num % 2;
|
||||
picture->dpb[picture->dpb_curr_pic].frame_idx = priv->frame_num;
|
||||
picture->dpb[ref_idx].frame_idx = priv->ref_idx_l0;
|
||||
}
|
||||
|
||||
static void *create_compute_state(struct pipe_context *pipe,
|
||||
const char *source)
|
||||
{
|
||||
struct tgsi_token tokens[1024];
|
||||
struct pipe_compute_state state = {0};
|
||||
|
||||
if (!tgsi_text_translate(source, tokens, ARRAY_SIZE(tokens))) {
|
||||
assert(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
state.ir_type = PIPE_SHADER_IR_TGSI;
|
||||
state.prog = tokens;
|
||||
|
||||
return pipe->create_compute_state(pipe, &state);
|
||||
}
|
||||
|
||||
void enc_InitCompute_common(vid_enc_PrivateType *priv)
|
||||
{
|
||||
struct pipe_context *pipe = priv->s_pipe;
|
||||
struct pipe_screen *screen = pipe->screen;
|
||||
|
||||
/* We need the partial last block support. */
|
||||
if (!screen->get_param(screen, PIPE_CAP_COMPUTE_GRID_INFO_LAST_BLOCK))
|
||||
return;
|
||||
|
||||
static const char *copy_y =
|
||||
"COMP\n"
|
||||
"PROPERTY CS_FIXED_BLOCK_WIDTH 64\n"
|
||||
"PROPERTY CS_FIXED_BLOCK_HEIGHT 1\n"
|
||||
"PROPERTY CS_FIXED_BLOCK_DEPTH 1\n"
|
||||
"DCL SV[0], THREAD_ID\n"
|
||||
"DCL SV[1], BLOCK_ID\n"
|
||||
"DCL IMAGE[0], 2D, PIPE_FORMAT_R8_UINT\n"
|
||||
"DCL IMAGE[1], 2D, PIPE_FORMAT_R8_UINT, WR\n"
|
||||
"DCL TEMP[0..1]\n"
|
||||
"IMM[0] UINT32 {64, 0, 0, 0}\n"
|
||||
|
||||
"UMAD TEMP[0].x, SV[1], IMM[0], SV[0]\n"
|
||||
"MOV TEMP[0].y, SV[1]\n"
|
||||
"LOAD TEMP[1].x, IMAGE[0], TEMP[0], 2D, PIPE_FORMAT_R8_UINT\n"
|
||||
"STORE IMAGE[1].x, TEMP[0], TEMP[1], 2D, PIPE_FORMAT_R8_UINT\n"
|
||||
"END\n";
|
||||
|
||||
static const char *copy_uv =
|
||||
"COMP\n"
|
||||
"PROPERTY CS_FIXED_BLOCK_WIDTH 64\n"
|
||||
"PROPERTY CS_FIXED_BLOCK_HEIGHT 1\n"
|
||||
"PROPERTY CS_FIXED_BLOCK_DEPTH 1\n"
|
||||
"DCL SV[0], THREAD_ID\n"
|
||||
"DCL SV[1], BLOCK_ID\n"
|
||||
"DCL IMAGE[0], 2D, PIPE_FORMAT_R8_UINT\n"
|
||||
"DCL IMAGE[2], 2D, PIPE_FORMAT_R8G8_UINT, WR\n"
|
||||
"DCL CONST[0][0]\n" /* .x = offset of the UV portion in the y direction */
|
||||
"DCL TEMP[0..4]\n"
|
||||
"IMM[0] UINT32 {64, 0, 2, 1}\n"
|
||||
/* Destination R8G8 coordinates */
|
||||
"UMAD TEMP[0].x, SV[1], IMM[0], SV[0]\n"
|
||||
"MOV TEMP[0].y, SV[1]\n"
|
||||
/* Source R8 coordinates of U */
|
||||
"UMUL TEMP[1].x, TEMP[0], IMM[0].zzzz\n"
|
||||
"UADD TEMP[1].y, TEMP[0], CONST[0].xxxx\n"
|
||||
/* Source R8 coordinates of V */
|
||||
"UADD TEMP[2].x, TEMP[1], IMM[0].wwww\n"
|
||||
"MOV TEMP[2].y, TEMP[1]\n"
|
||||
|
||||
"LOAD TEMP[3].x, IMAGE[0], TEMP[1], 2D, PIPE_FORMAT_R8_UINT\n"
|
||||
"LOAD TEMP[4].x, IMAGE[0], TEMP[2], 2D, PIPE_FORMAT_R8_UINT\n"
|
||||
"MOV TEMP[3].y, TEMP[4].xxxx\n"
|
||||
"STORE IMAGE[2], TEMP[0], TEMP[3], 2D, PIPE_FORMAT_R8G8_UINT\n"
|
||||
"END\n";
|
||||
|
||||
priv->copy_y_shader = create_compute_state(pipe, copy_y);
|
||||
priv->copy_uv_shader = create_compute_state(pipe, copy_uv);
|
||||
}
|
||||
|
||||
void enc_ReleaseCompute_common(vid_enc_PrivateType *priv)
|
||||
{
|
||||
struct pipe_context *pipe = priv->s_pipe;
|
||||
|
||||
if (priv->copy_y_shader)
|
||||
pipe->delete_compute_state(pipe, priv->copy_y_shader);
|
||||
if (priv->copy_uv_shader)
|
||||
pipe->delete_compute_state(pipe, priv->copy_uv_shader);
|
||||
}
|
||||
|
||||
OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEFINITIONTYPE *def,
|
||||
OMX_BUFFERHEADERTYPE *buf,
|
||||
struct pipe_video_buffer *vbuf)
|
||||
{
|
||||
struct pipe_context *pipe = priv->s_pipe;
|
||||
struct pipe_box box = {};
|
||||
struct input_buf_private *inp = buf->pInputPortPrivate;
|
||||
|
||||
if (!inp->resource) {
|
||||
struct pipe_sampler_view **views;
|
||||
void *ptr;
|
||||
|
||||
views = vbuf->get_sampler_view_planes(vbuf);
|
||||
if (!views)
|
||||
return OMX_ErrorInsufficientResources;
|
||||
|
||||
ptr = buf->pBuffer;
|
||||
box.width = def->nFrameWidth;
|
||||
box.height = def->nFrameHeight;
|
||||
box.depth = 1;
|
||||
pipe->texture_subdata(pipe, views[0]->texture, 0,
|
||||
PIPE_MAP_WRITE, &box,
|
||||
ptr, def->nStride, 0);
|
||||
ptr = ((uint8_t*)buf->pBuffer) + (def->nStride * box.height);
|
||||
box.width = def->nFrameWidth / 2;
|
||||
box.height = def->nFrameHeight / 2;
|
||||
box.depth = 1;
|
||||
pipe->texture_subdata(pipe, views[1]->texture, 0,
|
||||
PIPE_MAP_WRITE, &box,
|
||||
ptr, def->nStride, 0);
|
||||
} else {
|
||||
struct vl_video_buffer *dst_buf = (struct vl_video_buffer *)vbuf;
|
||||
|
||||
pipe_texture_unmap(pipe, inp->transfer);
|
||||
|
||||
/* inp->resource uses PIPE_FORMAT_I8 and the layout looks like this:
|
||||
*
|
||||
* def->nFrameWidth = 4, def->nFrameHeight = 4:
|
||||
* |----|
|
||||
* |YYYY|
|
||||
* |YYYY|
|
||||
* |YYYY|
|
||||
* |YYYY|
|
||||
* |UVUV|
|
||||
* |UVUV|
|
||||
* |----|
|
||||
*
|
||||
* The copy has 2 steps:
|
||||
* - Copy Y to dst_buf->resources[0] as R8.
|
||||
* - Copy UV to dst_buf->resources[1] as R8G8.
|
||||
*/
|
||||
if (priv->copy_y_shader && priv->copy_uv_shader) {
|
||||
/* Compute path */
|
||||
/* Set shader images for both copies. */
|
||||
struct pipe_image_view image[3] = {0};
|
||||
image[0].resource = inp->resource;
|
||||
image[0].shader_access = image[0].access = PIPE_IMAGE_ACCESS_READ;
|
||||
image[0].format = PIPE_FORMAT_R8_UINT;
|
||||
|
||||
image[1].resource = dst_buf->resources[0];
|
||||
image[1].shader_access = image[1].access = PIPE_IMAGE_ACCESS_WRITE;
|
||||
image[1].format = PIPE_FORMAT_R8_UINT;
|
||||
|
||||
image[2].resource = dst_buf->resources[1];
|
||||
image[2].shader_access = image[1].access = PIPE_IMAGE_ACCESS_WRITE;
|
||||
image[2].format = PIPE_FORMAT_R8G8_UINT;
|
||||
|
||||
pipe->set_shader_images(pipe, PIPE_SHADER_COMPUTE, 0, 3, 0, image);
|
||||
|
||||
/* Set the constant buffer. */
|
||||
uint32_t constants[4] = {def->nFrameHeight};
|
||||
struct pipe_constant_buffer cb = {};
|
||||
|
||||
cb.buffer_size = sizeof(constants);
|
||||
cb.user_buffer = constants;
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, false, &cb);
|
||||
|
||||
/* Use the optimal block size for the linear image layout. */
|
||||
struct pipe_grid_info info = {};
|
||||
info.block[0] = 64;
|
||||
info.block[1] = 1;
|
||||
info.block[2] = 1;
|
||||
info.grid[2] = 1;
|
||||
|
||||
/* Copy Y */
|
||||
pipe->bind_compute_state(pipe, priv->copy_y_shader);
|
||||
|
||||
info.grid[0] = DIV_ROUND_UP(def->nFrameWidth, 64);
|
||||
info.grid[1] = def->nFrameHeight;
|
||||
info.last_block[0] = def->nFrameWidth % 64;
|
||||
pipe->launch_grid(pipe, &info);
|
||||
|
||||
/* Copy UV */
|
||||
pipe->bind_compute_state(pipe, priv->copy_uv_shader);
|
||||
|
||||
info.grid[0] = DIV_ROUND_UP(def->nFrameWidth / 2, 64);
|
||||
info.grid[1] = def->nFrameHeight / 2;
|
||||
info.last_block[0] = (def->nFrameWidth / 2) % 64;
|
||||
pipe->launch_grid(pipe, &info);
|
||||
|
||||
/* Make the result visible to all clients. */
|
||||
pipe->memory_barrier(pipe, PIPE_BARRIER_ALL);
|
||||
|
||||
/* Unbind. */
|
||||
pipe->set_shader_images(pipe, PIPE_SHADER_COMPUTE, 0, 0, 3, NULL);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, false, NULL);
|
||||
pipe->bind_compute_state(pipe, NULL);
|
||||
} else {
|
||||
/* Graphics path */
|
||||
struct pipe_blit_info blit;
|
||||
|
||||
box.width = def->nFrameWidth;
|
||||
box.height = def->nFrameHeight;
|
||||
box.depth = 1;
|
||||
|
||||
/* Copy Y */
|
||||
pipe->resource_copy_region(pipe,
|
||||
dst_buf->resources[0],
|
||||
0, 0, 0, 0, inp->resource, 0, &box);
|
||||
|
||||
/* Copy U */
|
||||
memset(&blit, 0, sizeof(blit));
|
||||
blit.src.resource = inp->resource;
|
||||
blit.src.format = inp->resource->format;
|
||||
|
||||
blit.src.box.x = -1;
|
||||
blit.src.box.y = def->nFrameHeight;
|
||||
blit.src.box.width = def->nFrameWidth;
|
||||
blit.src.box.height = def->nFrameHeight / 2 ;
|
||||
blit.src.box.depth = 1;
|
||||
|
||||
blit.dst.resource = dst_buf->resources[1];
|
||||
blit.dst.format = blit.dst.resource->format;
|
||||
|
||||
blit.dst.box.width = def->nFrameWidth / 2;
|
||||
blit.dst.box.height = def->nFrameHeight / 2;
|
||||
blit.dst.box.depth = 1;
|
||||
blit.filter = PIPE_TEX_FILTER_NEAREST;
|
||||
|
||||
blit.mask = PIPE_MASK_R;
|
||||
pipe->blit(pipe, &blit);
|
||||
|
||||
/* Copy V */
|
||||
blit.src.box.x = 0;
|
||||
blit.mask = PIPE_MASK_G;
|
||||
pipe->blit(pipe, &blit);
|
||||
}
|
||||
|
||||
pipe->flush(pipe, NULL, 0);
|
||||
|
||||
box.width = inp->resource->width0;
|
||||
box.height = inp->resource->height0;
|
||||
box.depth = inp->resource->depth0;
|
||||
buf->pBuffer = pipe->texture_map(pipe, inp->resource, 0,
|
||||
PIPE_MAP_WRITE, &box,
|
||||
&inp->transfer);
|
||||
}
|
||||
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef VID_ENC_COMMON_H
|
||||
#define VID_ENC_COMMON_H
|
||||
|
||||
#include "util/list.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
#include "vl/vl_defines.h"
|
||||
#include "vl/vl_compositor.h"
|
||||
#include "vl/vl_winsys.h"
|
||||
|
||||
#include <OMX_Core.h>
|
||||
|
||||
#define OMX_VID_ENC_BITRATE_MIN 64000
|
||||
#define OMX_VID_ENC_BITRATE_MEDIAN 2000000
|
||||
#define OMX_VID_ENC_BITRATE_MAX 240000000
|
||||
#define OMX_VID_ENC_CONTROL_FRAME_RATE_DEN_DEFAULT 1001
|
||||
#define OMX_VID_ENC_QUANT_I_FRAMES_DEFAULT 0x1c
|
||||
#define OMX_VID_ENC_QUANT_P_FRAMES_DEFAULT 0x1c
|
||||
#define OMX_VID_ENC_QUANT_B_FRAMES_DEFAULT 0x1c
|
||||
#define OMX_VID_ENC_SCALING_WIDTH_DEFAULT 0xffffffff
|
||||
#define OMX_VID_ENC_SCALING_HEIGHT_DEFAULT 0xffffffff
|
||||
#define OMX_VID_ENC_IDR_PERIOD_DEFAULT 1000
|
||||
#define OMX_VID_ENC_P_PERIOD_DEFAULT 3
|
||||
|
||||
#define OMX_VID_ENC_NUM_SCALING_BUFFERS 4
|
||||
|
||||
struct encode_task {
|
||||
struct list_head list;
|
||||
|
||||
struct pipe_video_buffer *buf;
|
||||
unsigned pic_order_cnt;
|
||||
struct pipe_resource *bitstream;
|
||||
void *feedback;
|
||||
};
|
||||
|
||||
struct input_buf_private {
|
||||
struct list_head tasks;
|
||||
|
||||
struct pipe_resource *resource;
|
||||
struct pipe_transfer *transfer;
|
||||
};
|
||||
|
||||
struct output_buf_private {
|
||||
struct pipe_resource *bitstream;
|
||||
struct pipe_transfer *transfer;
|
||||
};
|
||||
|
||||
#if ENABLE_ST_OMX_BELLAGIO
|
||||
|
||||
#include <bellagio/omx_base_filter.h>
|
||||
|
||||
DERIVEDCLASS(vid_enc_PrivateType, omx_base_filter_PrivateType)
|
||||
#define vid_enc_PrivateType_FIELDS omx_base_filter_PrivateType_FIELDS \
|
||||
struct vl_screen *screen; \
|
||||
struct pipe_context *s_pipe; \
|
||||
struct pipe_context *t_pipe; \
|
||||
struct pipe_video_codec *codec; \
|
||||
struct list_head free_tasks; \
|
||||
struct list_head used_tasks; \
|
||||
struct list_head b_frames; \
|
||||
struct list_head stacked_tasks; \
|
||||
OMX_U32 frame_rate; \
|
||||
OMX_U32 frame_num; \
|
||||
OMX_U32 pic_order_cnt; \
|
||||
OMX_U32 ref_idx_l0, ref_idx_l1; \
|
||||
OMX_BOOL restricted_b_frames; \
|
||||
OMX_VIDEO_PARAM_BITRATETYPE bitrate; \
|
||||
OMX_VIDEO_PARAM_QUANTIZATIONTYPE quant; \
|
||||
OMX_VIDEO_PARAM_PROFILELEVELTYPE profile_level; \
|
||||
OMX_CONFIG_INTRAREFRESHVOPTYPE force_pic_type; \
|
||||
struct vl_compositor compositor; \
|
||||
struct vl_compositor_state cstate; \
|
||||
struct pipe_video_buffer *scale_buffer[OMX_VID_ENC_NUM_SCALING_BUFFERS]; \
|
||||
OMX_CONFIG_SCALEFACTORTYPE scale; \
|
||||
OMX_U32 current_scale_buffer; \
|
||||
OMX_U32 stacked_frames_num; \
|
||||
void *copy_y_shader; \
|
||||
void *copy_uv_shader;
|
||||
ENDCLASS(vid_enc_PrivateType)
|
||||
|
||||
#else
|
||||
|
||||
#include <tizprc_decls.h>
|
||||
#include <tizport_decls.h>
|
||||
|
||||
typedef struct h264e_prc_class h264e_prc_class_t;
|
||||
struct h264e_prc_class
|
||||
{
|
||||
/* Class */
|
||||
const tiz_prc_class_t _;
|
||||
/* NOTE: Class methods might be added in the future */
|
||||
};
|
||||
|
||||
typedef struct h264e_prc vid_enc_PrivateType;
|
||||
struct h264e_prc
|
||||
{
|
||||
/* Object */
|
||||
const tiz_prc_t _;
|
||||
OMX_BUFFERHEADERTYPE *p_inhdr_;
|
||||
OMX_BUFFERHEADERTYPE *p_outhdr_;
|
||||
OMX_PARAM_PORTDEFINITIONTYPE in_port_def_;
|
||||
OMX_PARAM_PORTDEFINITIONTYPE out_port_def_;
|
||||
struct vl_screen *screen;
|
||||
struct pipe_context *s_pipe;
|
||||
struct pipe_context *t_pipe;
|
||||
struct pipe_video_codec *codec;
|
||||
struct list_head free_tasks;
|
||||
struct list_head used_tasks;
|
||||
struct list_head b_frames;
|
||||
struct list_head stacked_tasks;
|
||||
OMX_U32 frame_rate;
|
||||
OMX_U32 frame_num;
|
||||
OMX_U32 pic_order_cnt;
|
||||
OMX_U32 ref_idx_l0, ref_idx_l1;
|
||||
OMX_BOOL restricted_b_frames;
|
||||
OMX_VIDEO_PARAM_BITRATETYPE bitrate;
|
||||
OMX_VIDEO_PARAM_QUANTIZATIONTYPE quant;
|
||||
OMX_VIDEO_PARAM_PROFILELEVELTYPE profile_level;
|
||||
OMX_CONFIG_INTRAREFRESHVOPTYPE force_pic_type;
|
||||
struct vl_compositor compositor;
|
||||
struct vl_compositor_state cstate;
|
||||
struct pipe_video_buffer *scale_buffer[OMX_VID_ENC_NUM_SCALING_BUFFERS];
|
||||
OMX_CONFIG_SCALEFACTORTYPE scale;
|
||||
OMX_U32 current_scale_buffer;
|
||||
OMX_U32 stacked_frames_num;
|
||||
bool eos_;
|
||||
bool in_port_disabled_;
|
||||
bool out_port_disabled_;
|
||||
void *copy_y_shader;
|
||||
void *copy_uv_shader;
|
||||
};
|
||||
#endif
|
||||
|
||||
void enc_ReleaseTasks(struct list_head *head);
|
||||
void enc_MoveTasks(struct list_head *from, struct list_head *to);
|
||||
enum pipe_video_profile enc_TranslateOMXProfileToPipe(unsigned omx_profile);
|
||||
unsigned enc_TranslateOMXLevelToPipe(unsigned omx_level);
|
||||
void vid_enc_BufferEncoded_common(vid_enc_PrivateType * priv, OMX_BUFFERHEADERTYPE* input,
|
||||
OMX_BUFFERHEADERTYPE* output);
|
||||
struct encode_task *enc_NeedTask_common(vid_enc_PrivateType * priv,
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE *def);
|
||||
void enc_ScaleInput_common(vid_enc_PrivateType * priv,
|
||||
OMX_VIDEO_PORTDEFINITIONTYPE *def,
|
||||
struct pipe_video_buffer **vbuf, unsigned *size);
|
||||
void enc_ControlPicture_common(vid_enc_PrivateType * priv,
|
||||
struct pipe_h264_enc_picture_desc *picture);
|
||||
void enc_InitCompute_common(vid_enc_PrivateType *priv);
|
||||
void enc_ReleaseCompute_common(vid_enc_PrivateType *priv);
|
||||
OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEFINITIONTYPE *def,
|
||||
OMX_BUFFERHEADERTYPE *buf,
|
||||
struct pipe_video_buffer *vbuf);
|
||||
#endif
|
||||
@@ -1,114 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if defined(HAVE_X11_PLATFORM)
|
||||
#include <X11/Xlib.h>
|
||||
#else
|
||||
#define XOpenDisplay(x) NULL
|
||||
#define XCloseDisplay(x)
|
||||
#define Display void
|
||||
#endif
|
||||
|
||||
#include "util/simple_mtx.h"
|
||||
#include "util/u_thread.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "loader/loader.h"
|
||||
|
||||
#include "vid_omx_common.h"
|
||||
|
||||
static simple_mtx_t omx_lock = SIMPLE_MTX_INITIALIZER;
|
||||
static Display *omx_display = NULL;
|
||||
static struct vl_screen *omx_screen = NULL;
|
||||
static unsigned omx_usecount = 0;
|
||||
static const char *omx_render_node = NULL;
|
||||
static int drm_fd;
|
||||
|
||||
struct vl_screen *omx_get_screen(void)
|
||||
{
|
||||
static bool first_time = true;
|
||||
simple_mtx_lock(&omx_lock);
|
||||
|
||||
if (!omx_screen) {
|
||||
if (first_time) {
|
||||
omx_render_node = debug_get_option("OMX_RENDER_NODE", NULL);
|
||||
first_time = false;
|
||||
}
|
||||
if (omx_render_node) {
|
||||
drm_fd = loader_open_device(omx_render_node);
|
||||
if (drm_fd < 0)
|
||||
goto error;
|
||||
|
||||
omx_screen = vl_drm_screen_create(drm_fd);
|
||||
if (!omx_screen) {
|
||||
close(drm_fd);
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
omx_display = XOpenDisplay(NULL);
|
||||
if (!omx_display)
|
||||
goto error;
|
||||
|
||||
omx_screen = vl_dri3_screen_create(omx_display, 0);
|
||||
#ifdef HAVE_X11_DRI2
|
||||
if (!omx_screen)
|
||||
omx_screen = vl_dri2_screen_create(omx_display, 0);
|
||||
#endif
|
||||
if (!omx_screen) {
|
||||
XCloseDisplay(omx_display);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++omx_usecount;
|
||||
|
||||
simple_mtx_unlock(&omx_lock);
|
||||
return omx_screen;
|
||||
|
||||
error:
|
||||
simple_mtx_unlock(&omx_lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void omx_put_screen(void)
|
||||
{
|
||||
simple_mtx_lock(&omx_lock);
|
||||
if ((--omx_usecount) == 0) {
|
||||
omx_screen->destroy(omx_screen);
|
||||
omx_screen = NULL;
|
||||
|
||||
if (omx_render_node)
|
||||
close(drm_fd);
|
||||
else
|
||||
XCloseDisplay(omx_display);
|
||||
}
|
||||
simple_mtx_unlock(&omx_lock);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef VID_OMX_COMMON_H
|
||||
#define VID_OMX_COMMON_H
|
||||
|
||||
#include "vl/vl_winsys.h"
|
||||
|
||||
struct vl_screen *omx_get_screen(void);
|
||||
void omx_put_screen(void);
|
||||
|
||||
#endif
|
||||
@@ -218,10 +218,6 @@ if with_gallium_vdpau
|
||||
subdir('frontends/vdpau')
|
||||
subdir('targets/vdpau')
|
||||
endif
|
||||
if with_gallium_omx != 'disabled'
|
||||
subdir('frontends/omx')
|
||||
subdir('targets/omx')
|
||||
endif
|
||||
if with_gallium_va
|
||||
subdir('frontends/va')
|
||||
subdir('targets/va')
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
# Copyright © 2017-2018 Intel Corporation
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# TODO: support non-static targets
|
||||
# Static targets are always enabled in autotools (unless you modify
|
||||
# configure.ac)
|
||||
|
||||
omx_link_args = []
|
||||
omx_link_depends = []
|
||||
|
||||
omx_sym = configure_file(input : 'omx.sym.in', output : 'omx.sym', configuration : sym_config)
|
||||
|
||||
if with_ld_version_script
|
||||
omx_link_args += ['-Wl,--version-script', join_paths(meson.current_build_dir(), 'omx.sym')]
|
||||
omx_link_depends += omx_sym
|
||||
endif
|
||||
|
||||
libomx_gallium = shared_library(
|
||||
'omx_mesa',
|
||||
'omx_target.c',
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
link_args : [omx_link_args, ld_args_gc_sections],
|
||||
include_directories : [
|
||||
inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_util, inc_gallium_winsys, inc_gallium_drivers,
|
||||
],
|
||||
link_whole : [libomx_st],
|
||||
link_with : [
|
||||
libgalliumvlwinsys, libgalliumvl, libgallium,
|
||||
libpipe_loader_static, libws_null, libwsw, libswdri, libswkmsdri,
|
||||
],
|
||||
link_depends : omx_link_depends,
|
||||
dependencies : [idep_mesautil, driver_r600, driver_radeonsi, driver_nouveau],
|
||||
install : true,
|
||||
install_dir : omx_drivers_path,
|
||||
)
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
global:
|
||||
OMX_ComponentInit;
|
||||
omx_component_library_Setup;
|
||||
|
||||
# Workaround for an LLVM warning with -simplifycfg-sink-common
|
||||
# due to LLVM being initialized multiple times.
|
||||
@radeon_drm_winsys_create@
|
||||
@amdgpu_winsys_create@
|
||||
@ac_init_shared_llvm_once@
|
||||
local:
|
||||
*;
|
||||
};
|
||||
@@ -1,2 +0,0 @@
|
||||
#include "target-helpers/drm_helper.h"
|
||||
#include "target-helpers/sw_helper.h"
|
||||
@@ -10,7 +10,7 @@ pipe_loader_incs = [
|
||||
inc_gallium_winsys, inc_gallium_aux,
|
||||
]
|
||||
|
||||
if (with_gallium_va or with_gallium_vdpau or with_gallium_omx != 'disabled')
|
||||
if (with_gallium_va or with_gallium_vdpau)
|
||||
pipe_loader_link_with += libgalliumvlwinsys
|
||||
endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user