YARP
Yet Another Robot Platform
ffmpeg_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef FFMPEG_API_YARP
11 #define FFMPEG_API_YARP
12 
13 // ffmpeg changes all the time.
14 // time to start factoring out some of the things that change.
15 
16 #ifndef __STDC_CONSTANT_MACROS
17 #define __STDC_CONSTANT_MACROS
18 #endif
19 
20 extern "C" {
21 #include <libavcodec/avcodec.h>
22 #include <libavformat/avformat.h>
23 #include <libavdevice/avdevice.h>
24 #include <libswscale/swscale.h>
25 #include <libavutil/mathematics.h>
26 }
27 
28 
29 #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 0, 0)
30 # error "ffmpeg version is too old, sorry - please download and compile newer version"
31 #endif
32 
33 #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 0, 0)
34 # define USE_AVFORMAT_OPEN_INPUT
35 #endif
36 
37 #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 0, 0)
38 # define USE_AV_FRAME_ALLOC
39 # define USE_AUDIO4
40 #endif
41 
42 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 0, 0)
43 # define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
44 # define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
45 # define AVPixelFormat PixelFormat
46 #endif
47 
48 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(54, 4, 100)
49 # define av_dict_set_int(x, k, v, f) { char buf[256]; sprintf(buf,"%d",v); av_dict_set(x, k ,buf, 0); }
50 #endif
51 
52 
53 
54 
55 int stable_img_convert (AVPicture *dst, int dst_pix_fmt,
56  const AVPicture *src, int src_pix_fmt,
57  int src_width, int src_height);
58 
59 #ifndef CODEC_TYPE_AUDIO
60 # define CodecType AVMediaType
61 # define CODEC_TYPE_UNKNOWN AVMEDIA_TYPE_UNKNOWN
62 # define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
63 # define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO
64 # define CODEC_TYPE_DATA AVMEDIA_TYPE_DATA
65 # define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE
66 # define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT
67 # define CODEC_TYPE_NB AVMEDIA_TYPE_NB
68 # define PKT_FLAG_KEY AV_PKT_FLAG_KEY
69 # define guess_format av_guess_format
70 # define av_alloc_format_context avformat_alloc_context
71 # define FFEPOCH3
72 #endif
73 
74 
75 
76 #ifdef USE_AV_FRAME_ALLOC
77 # define YARP_avcodec_alloc_frame av_frame_alloc
78 #else
79 # define YARP_avcodec_alloc_frame avcodec_alloc_frame
80 #endif
81 
82 #ifdef USE_AVFORMAT_OPEN_INPUT
83 # define YARP_av_find_stream_info(a) avformat_find_stream_info(a,NULL)
84 # define YARP_dump_format av_dump_format
85 # define YARP_av_close_input_file(x) avformat_close_input(&(x))
86 # define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
87 # define CodecID AVCodecID
88 # define CODEC_ID_NONE AV_CODEC_ID_NONE
89 # define CODEC_ID_PCM_S16LE AV_CODEC_ID_PCM_S16LE
90 # define CODEC_ID_PCM_S16BE AV_CODEC_ID_PCM_S16BE
91 # define CODEC_ID_PCM_U16LE AV_CODEC_ID_PCM_U16LE
92 # define CODEC_ID_PCM_U16BE AV_CODEC_ID_PCM_U16BE
93 # define CODEC_ID_MPEG1VIDEO AV_CODEC_ID_MPEG1VIDEO
94 # define CODEC_ID_MPEG2VIDEO AV_CODEC_ID_MPEG2VIDEO
95 # define url_fopen avio_open
96 # define url_fclose avio_close
97 # define URL_WRONLY AVIO_FLAG_WRITE
98 # define AV_NO_SET_PARAMETERS
99 # define av_write_header(x) avformat_write_header(x,NULL)
100 # define av_new_stream(x,v) avformat_new_stream(x,NULL)
101 #else
102 # define YARP_av_find_stream_info av_find_stream_info
103 # define YARP_dump_format dump_format
104 # define YARP_av_close_input_file av_close_input_file
105 #endif
106 
107 #endif
int stable_img_convert(AVPicture *dst, int dst_pix_fmt, const AVPicture *src, int src_pix_fmt, int src_width, int src_height)
Definition: ffmpeg_api.cpp:13