Miam-Player  0.8.0
A nice music player
AVCompat.h File Reference

Go to the source code of this file.

Macros

#define QTAV_USE_FFMPEG(MODULE)   (MODULE##_VERSION_MICRO >= 100)
 NOTE: include this at last. More...
 
#define QTAV_USE_LIBAV(MODULE)   !QTAV_USE_FFMPEG(MODULE)
 
#define FFMPEG_MODULE_CHECK(MODULE, MAJOR, MINOR, MICRO)   (QTAV_USE_FFMPEG(MODULE) && MODULE##_VERSION_INT >= AV_VERSION_INT(MAJOR, MINOR, MICRO))
 
#define LIBAV_MODULE_CHECK(MODULE, MAJOR, MINOR, MICRO)   (QTAV_USE_LIBAV(MODULE) && MODULE##_VERSION_INT >= AV_VERSION_INT(MAJOR, MINOR, MICRO))
 
#define AV_MODULE_CHECK(MODULE, MAJOR, MINOR, MICRO, MINOR2, MICRO2)   (LIBAV_MODULE_CHECK(MODULE, MAJOR, MINOR, MICRO) || FFMPEG_MODULE_CHECK(MODULE, MAJOR, MINOR2, MICRO2))
 
#define AV_ENSURE_OK(FUNC, ...)   AV_RUN_CHECK(FUNC, return, __VA_ARGS__)
 example: AV_ENSURE(avcodec_close(avctx), false) will print error and return false if failed. AV_WARN just prints error. More...
 
#define AV_ENSURE(FUNC, ...)   AV_RUN_CHECK(FUNC, return, __VA_ARGS__)
 
#define AV_WARN(FUNC)   AV_RUN_CHECK(FUNC, void)
 
#define AV_VERSION_INT(a, b, c)   (a<<16 | b<<8 | c)
 Guide to uniform the api for different FFmpeg version(or other libraries) We use the existing old api to simulater . More...
 
#define GCC_VERSION_AT_LEAST(major, minor, patch)   0
 
#define QTAV_HAVE_AVBUFREF   AV_MODULE_CHECK(LIBAVUTIL, 52, 8, 0, 19, 100)
 
#define AV_ERROR_MAX_STRING_SIZE   64
 
#define avcodec_decode_audio3(avctx, samples, frame_size_ptr, avpkt)   avcodec_decode_audio2(avctx, samples, frame_size_ptr, (*avpkt).data, (*avpkt).size);
 defined(av_err2str) || GCC_VERSION_AT_LEAST(4, 7, 2) More...
 
#define av_dump_format(...)   dump_format(__VA_ARGS__)
 
#define QTAV_PIX_FMT_C(X)   PIX_FMT_##X
 
#define PIX_FMT_PLANAR   16
 At least one pixel component is not in the first data plane. More...
 
#define PIX_FMT_RGB   32
 The pixel format contains RGB-like data (as opposed to YUV/grayscale) More...
 
#define PIX_FMT_PSEUDOPAL   64
 
#define PIX_FMT_ALPHA   128
 The pixel format has an alpha channel. More...
 
#define AV_PIX_FMT_FLAG_BE   PIX_FMT_BE
 
#define AV_PIX_FMT_FLAG_PAL   PIX_FMT_PAL
 
#define AV_PIX_FMT_FLAG_BITSTREAM   PIX_FMT_BITSTREAM
 
#define AV_PIX_FMT_FLAG_HWACCEL   PIX_FMT_HWACCEL
 
#define AV_PIX_FMT_FLAG_PLANAR   PIX_FMT_PLANAR
 
#define AV_PIX_FMT_FLAG_RGB   PIX_FMT_RGB
 
#define AV_PIX_FMT_FLAG_PSEUDOPAL   PIX_FMT_PSEUDOPAL
 
#define AV_PIX_FMT_FLAG_ALPHA   PIX_FMT_ALPHA
 
#define QTAV_CODEC_ID(X)   CODEC_ID_##X
 
#define av_frame_alloc()   avcodec_alloc_frame()
 
#define av_frame_free(f)   avcodec_free_frame(f)
 
#define av_packet_unref(pkt)   av_free_packet(pkt)
 
#define AV_CODEC_ID_HEVC   ((AVCodecID)0)
 
#define CODEC_ID_HEVC   ((AVCodecID)0)
 
#define FF_PROFILE_HEVC_MAIN   -1
 
#define FF_PROFILE_HEVC_MAIN_10   -1
 
#define AV_CODEC_ID_VP9   ((AVCodecID)0)
 
#define CODEC_ID_VP9   ((AVCodecID)0)
 
#define FF_PROFILE_VP9_0   0
 
#define FF_PROFILE_VP9_1   1
 
#define FF_PROFILE_VP9_2   2
 
#define FF_PROFILE_VP9_3   3
 
#define AV_RUN_CHECK(FUNC, RETURN, ...)
 

Typedefs

typedef enum PixelFormat AVPixelFormat
 
typedef enum CodecID AVCodecID
 

Functions

void ffmpeg_version_print ()
 
int avio_feof (AVIOContext *s)
 
int avformat_alloc_output_context2 (AVFormatContext **avctx, AVOutputFormat *oformat, const char *format, const char *filename)
 
av_always_inline char * av_err2str (int errnum)
 
int64_t av_get_default_channel_layout (int nb_channels)
 
const AVPixFmtDescriptorav_pix_fmt_desc_get (AVPixelFormat pix_fmt)
 
const AVPixFmtDescriptorav_pix_fmt_desc_next (const AVPixFmtDescriptor *prev)
 
AVPixelFormat av_pix_fmt_desc_get_id (const AVPixFmtDescriptor *desc)
 
enum AVColorSpace av_frame_get_colorspace (const AVFrame *frame)
 
enum AVColorRange av_frame_get_color_range (const AVFrame *frame)
 
int av_pix_fmt_count_planes (AVPixelFormat pix_fmt)
 
int av_samples_copy (uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
 
const char * avcodec_get_name (enum AVCodecID id)
 
void av_packet_rescale_ts (AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
 
int av_packet_copy_props (AVPacket *dst, const AVPacket *src)
 
void av_packet_free_side_data (AVPacket *pkt)
 
int av_packet_ref (AVPacket *dst, const AVPacket *src)
 
void avcodec_free_context (AVCodecContext **avctx)
 
const char * get_codec_long_name (AVCodecID id)
 

Macro Definition Documentation

#define AV_CODEC_ID_HEVC   ((AVCodecID)0)
#define AV_CODEC_ID_VP9   ((AVCodecID)0)
#define av_dump_format (   ...)    dump_format(__VA_ARGS__)
#define AV_ENSURE (   FUNC,
  ... 
)    AV_RUN_CHECK(FUNC, return, __VA_ARGS__)
#define AV_ENSURE_OK (   FUNC,
  ... 
)    AV_RUN_CHECK(FUNC, return, __VA_ARGS__)

example: AV_ENSURE(avcodec_close(avctx), false) will print error and return false if failed. AV_WARN just prints error.

#define AV_ERROR_MAX_STRING_SIZE   64
#define av_frame_alloc (   void)    avcodec_alloc_frame()
#define av_frame_free (   f)    avcodec_free_frame(f)
#define AV_MODULE_CHECK (   MODULE,
  MAJOR,
  MINOR,
  MICRO,
  MINOR2,
  MICRO2 
)    (LIBAV_MODULE_CHECK(MODULE, MAJOR, MINOR, MICRO) || FFMPEG_MODULE_CHECK(MODULE, MAJOR, MINOR2, MICRO2))
#define av_packet_unref (   pkt)    av_free_packet(pkt)
#define AV_PIX_FMT_FLAG_ALPHA   PIX_FMT_ALPHA
#define AV_PIX_FMT_FLAG_BE   PIX_FMT_BE
#define AV_PIX_FMT_FLAG_BITSTREAM   PIX_FMT_BITSTREAM
#define AV_PIX_FMT_FLAG_HWACCEL   PIX_FMT_HWACCEL
#define AV_PIX_FMT_FLAG_PAL   PIX_FMT_PAL
#define AV_PIX_FMT_FLAG_PLANAR   PIX_FMT_PLANAR
#define AV_PIX_FMT_FLAG_PSEUDOPAL   PIX_FMT_PSEUDOPAL
#define AV_PIX_FMT_FLAG_RGB   PIX_FMT_RGB
#define AV_RUN_CHECK (   FUNC,
  RETURN,
  ... 
)
Value:
do { \
int ret = FUNC; \
if (ret < 0) { \
memset(str, 0, sizeof(str)); \
av_strerror(ret, str, sizeof(str)); \
av_log(NULL, AV_LOG_WARNING, "Error " #FUNC " @%d " __FILE__ ": (%#x) %s\n", __LINE__, ret, str); \
RETURN __VA_ARGS__; \
} } while(0)
#define AV_LOG_WARNING
Definition: log.h:182
#define AV_ERROR_MAX_STRING_SIZE
Definition: AVCompat.h:169
#define AV_VERSION_INT (   a,
  b,
 
)    (a<<16 | b<<8 | c)

Guide to uniform the api for different FFmpeg version(or other libraries) We use the existing old api to simulater .

  1. The old version does not have this api: Just add it.
  2. The old version has similar api: Try using macro. e.g. the old is bool my_play(char* data, size_t size) the new is bool my_play2(const ByteArray& data) change: #define my_play2(data) my_play(data.data(), data.size());
  3. The old version api is conflicted with the latest's. We can redefine the api e.g. the old is bool my_play(char* data, size_t size) the new is bool my_play(const ByteArray& data) change: typedef bool (my_play_t)(const ByteArray&); static my_play_t my_play_ptr = my_play; //using the existing my_play(char, size_t) #define my_play my_play_compat inline bool my_play_compat(const ByteArray& data) { return my_play_ptr(data.data(), data.size()); }
  4. conflict macros see av_err2str
#define AV_WARN (   FUNC)    AV_RUN_CHECK(FUNC, void)
#define avcodec_decode_audio3 (   avctx,
  samples,
  frame_size_ptr,
  avpkt 
)    avcodec_decode_audio2(avctx, samples, frame_size_ptr, (*avpkt).data, (*avpkt).size);

defined(av_err2str) || GCC_VERSION_AT_LEAST(4, 7, 2)

#define CODEC_ID_HEVC   ((AVCodecID)0)
#define CODEC_ID_VP9   ((AVCodecID)0)
#define FF_PROFILE_HEVC_MAIN   -1
#define FF_PROFILE_HEVC_MAIN_10   -1
#define FF_PROFILE_VP9_0   0
#define FF_PROFILE_VP9_1   1
#define FF_PROFILE_VP9_2   2
#define FF_PROFILE_VP9_3   3
#define FFMPEG_MODULE_CHECK (   MODULE,
  MAJOR,
  MINOR,
  MICRO 
)    (QTAV_USE_FFMPEG(MODULE) && MODULE##_VERSION_INT >= AV_VERSION_INT(MAJOR, MINOR, MICRO))
#define GCC_VERSION_AT_LEAST (   major,
  minor,
  patch 
)    0
#define LIBAV_MODULE_CHECK (   MODULE,
  MAJOR,
  MINOR,
  MICRO 
)    (QTAV_USE_LIBAV(MODULE) && MODULE##_VERSION_INT >= AV_VERSION_INT(MAJOR, MINOR, MICRO))
#define PIX_FMT_ALPHA   128

The pixel format has an alpha channel.

#define PIX_FMT_PLANAR   16

At least one pixel component is not in the first data plane.

#define PIX_FMT_PSEUDOPAL   64
#define PIX_FMT_RGB   32

The pixel format contains RGB-like data (as opposed to YUV/grayscale)

#define QTAV_CODEC_ID (   X)    CODEC_ID_##X
#define QTAV_HAVE_AVBUFREF   AV_MODULE_CHECK(LIBAVUTIL, 52, 8, 0, 19, 100)
#define QTAV_PIX_FMT_C (   X)    PIX_FMT_##X
#define QTAV_USE_FFMPEG (   MODULE)    (MODULE##_VERSION_MICRO >= 100)

NOTE: include this at last.

#define QTAV_USE_LIBAV (   MODULE)    !QTAV_USE_FFMPEG(MODULE)

Typedef Documentation

typedef enum CodecID AVCodecID
typedef enum PixelFormat AVPixelFormat

Function Documentation

av_always_inline char* av_err2str ( int  errnum)
enum AVColorRange av_frame_get_color_range ( const AVFrame frame)
enum AVColorSpace av_frame_get_colorspace ( const AVFrame frame)
int64_t av_get_default_channel_layout ( int  nb_channels)
int av_packet_copy_props ( AVPacket dst,
const AVPacket src 
)
void av_packet_free_side_data ( AVPacket pkt)
int av_packet_ref ( AVPacket dst,
const AVPacket src 
)
void av_packet_rescale_ts ( AVPacket pkt,
AVRational  src_tb,
AVRational  dst_tb 
)
int av_pix_fmt_count_planes ( AVPixelFormat  pix_fmt)
const AVPixFmtDescriptor* av_pix_fmt_desc_get ( AVPixelFormat  pix_fmt)
AVPixelFormat av_pix_fmt_desc_get_id ( const AVPixFmtDescriptor desc)
const AVPixFmtDescriptor* av_pix_fmt_desc_next ( const AVPixFmtDescriptor prev)
int av_samples_copy ( uint8_t **  dst,
uint8_t *const *  src,
int  dst_offset,
int  src_offset,
int  nb_samples,
int  nb_channels,
enum AVSampleFormat  sample_fmt 
)

Copy samples from src to dst.

Parameters
dstdestination array of pointers to data planes
srcsource array of pointers to data planes
dst_offsetoffset in samples at which the data will be written to dst
src_offsetoffset in samples at which the data will be read from src
nb_samplesnumber of samples to be copied
nb_channelsnumber of audio channels
sample_fmtaudio sample format
void avcodec_free_context ( AVCodecContext **  avctx)
const char* avcodec_get_name ( enum AVCodecID  id)
int avformat_alloc_output_context2 ( AVFormatContext **  avctx,
AVOutputFormat oformat,
const char *  format,
const char *  filename 
)
int avio_feof ( AVIOContext s)
void ffmpeg_version_print ( )
const char* get_codec_long_name ( AVCodecID  id)