Ignition Common

API Reference

4.4.0
ffmpeg_inc.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_COMMON_FFMPEG_INC_HH_
18 #define IGNITION_COMMON_FFMPEG_INC_HH_
19 
20 #include <string>
21 
22 #include <ignition/common/config.hh>
23 
24 #ifndef _WIN32
25 #pragma GCC system_header
26 #endif
27 
28 #ifndef INT64_C
29 #define INT64_C(c) (c ## LL)
30 #define UINT64_C(c) (c ## ULL)
31 #endif
32 
33 #ifndef AV_ERROR_MAX_STRING_SIZE
34 #define AV_ERROR_MAX_STRING_SIZE 64
35 #endif
36 
37 extern "C" {
38 #include <libavcodec/avcodec.h>
39 #include <libavformat/avformat.h>
40 #include <libswscale/swscale.h>
41 #include <libavutil/mathematics.h>
42 #include <libavutil/opt.h>
43 #include <libavutil/error.h>
44 #include <libavutil/imgutils.h>
45 #include <libavutil/hwcontext.h>
46 
47 #if defined(__linux__) && defined(HAVE_AVDEVICE)
48 #include <libavdevice/avdevice.h>
49 #endif
50 }
51 
52 #include <ignition/common/av/Export.hh>
53 
54 namespace ignition
55 {
56  namespace common
57  {
59  IGNITION_COMMON_AV_VISIBLE
60  AVFrame *AVFrameAlloc(void);
61 
63  IGNITION_COMMON_AV_VISIBLE
64  void AVFrameUnref(AVFrame *_frame);
65 
68  IGNITION_COMMON_AV_VISIBLE
69  void AVPacketUnref(AVPacket *_packet);
70 
82  IGNITION_COMMON_AV_VISIBLE
83  int AVCodecDecode(AVCodecContext *_codecCtx,
84  AVFrame *_frame, int *_gotFrame, AVPacket *_packet);
85 
86  // av_err2str only works in C99, this is a version that works in C++;
87  // https://github.com/joncampbell123/composite-video-simulator/issues/5#issuecomment-611885908
88  inline std::string av_err2str_cpp(int errnum)
89  {
90  thread_local char buf[AV_ERROR_MAX_STRING_SIZE];
91  memset(buf, 0, sizeof(buf));
92  // lavu 51.58.100
93  return av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, errnum);
94  }
95  }
96 }
97 
98 #endif
IGNITION_COMMON_AV_VISIBLE void AVPacketUnref(AVPacket *_packet)
Helper function to avoid deprecation warnings.
#define AV_ERROR_MAX_STRING_SIZE
Definition: ffmpeg_inc.hh:34
STL class.
IGNITION_COMMON_AV_VISIBLE AVFrame * AVFrameAlloc(void)
Helper function to avoid deprecation warnings.
IGNITION_COMMON_AV_VISIBLE int AVCodecDecode(AVCodecContext *_codecCtx, AVFrame *_frame, int *_gotFrame, AVPacket *_packet)
Helper function to avoid deprecation warnings from av_codec_decode_video2.
IGNITION_COMMON_AV_VISIBLE void AVFrameUnref(AVFrame *_frame)
Helper function to avoid deprecation warnings.
std::string av_err2str_cpp(int errnum)
Definition: ffmpeg_inc.hh:88
Forward declarations for the common classes.