2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
16 #include <libavutil/pixfmt.h>
22 friend class CFFmpegImage
;
27 int GetPitch() const { return m_pitch
; }
29 unsigned char* m_pImage
= nullptr;
30 unsigned int m_delay
= 0;
33 Frame(const Frame
& src
);
36 unsigned int m_imageSize
= 0;
37 unsigned int m_height
= 0;
38 unsigned int m_width
= 0;
44 uint8_t* data
= nullptr;
51 struct AVFormatContext
;
52 struct AVCodecContext
;
55 class CFFmpegImage
: public IImage
58 explicit CFFmpegImage(const std::string
& strMimeType
);
59 ~CFFmpegImage() override
;
61 bool LoadImageFromMemory(unsigned char* buffer
, unsigned int bufSize
,
62 unsigned int width
, unsigned int height
) override
;
63 bool Decode(unsigned char * const pixels
, unsigned int width
, unsigned int height
,
64 unsigned int pitch
, unsigned int format
) override
;
65 bool CreateThumbnailFromSurface(unsigned char* bufferin
, unsigned int width
,
66 unsigned int height
, unsigned int format
,
67 unsigned int pitch
, const std::string
& destFile
,
68 unsigned char* &bufferout
,
69 unsigned int &bufferoutSize
) override
;
70 void ReleaseThumbnailBuffer() override
;
72 bool Initialize(unsigned char* buffer
, size_t bufSize
);
74 std::shared_ptr
<Frame
> ReadFrame();
77 static void FreeIOCtx(AVIOContext
** ioctx
);
78 AVFrame
* ExtractFrame();
79 bool DecodeFrame(AVFrame
* m_pFrame
, unsigned int width
, unsigned int height
, unsigned int pitch
, unsigned char * const pixels
);
80 static int EncodeFFmpegFrame(AVCodecContext
*avctx
, AVPacket
*pkt
, int *got_packet
, AVFrame
*frame
);
81 static int DecodeFFmpegFrame(AVCodecContext
*avctx
, AVFrame
*frame
, int *got_frame
, AVPacket
*pkt
);
82 static AVPixelFormat
ConvertFormats(AVFrame
* frame
);
83 std::string m_strMimeType
;
84 void CleanupLocalOutputBuffer();
89 AVIOContext
* m_ioctx
= nullptr;
90 AVFormatContext
* m_fctx
= nullptr;
91 AVCodecContext
* m_codec_ctx
= nullptr;
94 uint8_t* m_outputBuffer
;