2 Copyright 2021 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
24 The OMX image_decode "hardware" is buggy when given an image with height not divisible
25 by 16. Extensive testing shows there is no way to use tunneled communication between
26 image_decode and egl_render when the image height is not divisible by 16 and guarantee
27 correct image display.
29 ImageOMX1 mitigated this by cropping the image height to a value divisible by 16
30 but this introduced a new race condition bug which corrupted some images.
31 ImageOMX1 works most of the time because it happens to pull down the tunnel before
32 it has finished. If a 0.1s delay is inserted after the
33 if (!video->ChangeComponentState(omx_egl_render,OMX_StateExecuting)) {
34 if block, it will break every image with height not divisible by 16.
36 The solution is to not use tunneled communication between image_decode and
37 egl_render. If the input image height is not divisible by 16, set the slice height
38 to 16. Then feed egl_render separately.
40 This ImageOMX2 is a rework of my clean-implementation test programs used to debug
41 the problem. Future work: Fix ImageOMX1 or swap over to ImageOMX2 if it works
42 well enough? (Is it even possible to run image_decode/egl_render without integration
50 #include "osdvectortypes.h"
53 class OMX_Image_Decode;
56 class ImageOMX2 : public PictureDecoder
58 // PictureDecoder Interface
60 ImageOMX2(/*EGLDisplay egl_display*/);
61 virtual ~ImageOMX2() {};
66 unsigned char* decodePicture(LoadingIndex index, unsigned char* buffer, unsigned int length, bool freemem) noexcept;
67 bool getDecodedPicture(struct PictureInfo& pict_inf);
68 void freeReference(void*) {};
74 //EGLDisplay egl_display;
75 OMX_Image_Decode* omx_imagedecode{};
76 OMX_EGL_Render* omx_eglrender{};
78 // State data for the decode
79 struct PictureInfo currentDecode{}; // There's only one user so no locking required
80 bool currentDecodeValid{};
85 void decode(char* inputData, int inputDataSize, char** outRawData, int* outRawDataSize, int* outWidth, int* outHeight, int* outStride); // throws
86 void render(char* inputData, int inputDataSize, int imageWidth, int imageHeight, int imageStride); // throws