-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build fixes for Ubuntu 16.04.2 #11
base: devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,12 +35,22 @@ | |
#define AVMEDIA_TYPE_AUDIO 1 | ||
#endif | ||
|
||
#if LIBAVCODEC_VERSION_MAJOR < 54 | ||
#define MAX_AUDIO_FRAME_SIZE AVCODEC_MAX_AUDIO_FRAME_SIZE | ||
#else | ||
#define MAX_AUDIO_FRAME_SIZE 192000 | ||
#endif | ||
|
||
typedef struct _TSMFFFmpegDecoder | ||
{ | ||
ITSMFDecoder iface; | ||
|
||
int media_type; | ||
enum CodecID codec_id; | ||
#if LIBAVCODEC_VERSION_MAJOR < 55 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer not to pollute the code with inline For example #if LIBAVCODEC_VERSION_MAJOR < 55
#define AVCodecID CodecID
#endif |
||
enum CodecID codec_id; | ||
#else | ||
enum AVCodecID codec_id; | ||
#endif | ||
AVCodecContext* codec_context; | ||
AVCodec* codec; | ||
AVFrame* frame; | ||
|
@@ -89,6 +99,7 @@ static tbool tsmf_ffmpeg_init_audio_stream(ITSMFDecoder* decoder, const TS_AM_ME | |
mdecoder->codec_context->channels = media_type->Channels; | ||
mdecoder->codec_context->block_align = media_type->BlockAlign; | ||
|
||
#if LIBAVCODEC_VERSION_MAJOR < 55 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same applies here. |
||
#ifdef AV_CPU_FLAG_SSE2 | ||
mdecoder->codec_context->dsp_mask = AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_MMX2; | ||
#else | ||
|
@@ -99,6 +110,14 @@ static tbool tsmf_ffmpeg_init_audio_stream(ITSMFDecoder* decoder, const TS_AM_ME | |
#endif | ||
#endif | ||
|
||
#else /* LIBAVCODEC_VERSION_MAJOR < 55 */ | ||
#ifdef AV_CPU_FLAG_SSE2 | ||
av_set_cpu_flags_mask(AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_MMX2); | ||
#else | ||
av_set_cpu_flags_mask(FF_MM_SSE2 | FF_MM_MMX2); | ||
#endif | ||
#endif /* LIBAVCODEC_VERSION_MAJOR < 55 */ | ||
|
||
return true; | ||
} | ||
|
||
|
@@ -387,7 +406,7 @@ static tbool tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const uint8* data, | |
#endif | ||
|
||
if (mdecoder->decoded_size_max == 0) | ||
mdecoder->decoded_size_max = AVCODEC_MAX_AUDIO_FRAME_SIZE + 16; | ||
mdecoder->decoded_size_max = MAX_AUDIO_FRAME_SIZE + 16; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
mdecoder->decoded_data = xzalloc(mdecoder->decoded_size_max); | ||
/* align the memory for SSE2 needs */ | ||
dst = (uint8*) (((uintptr_t)mdecoder->decoded_data + 15) & ~ 0x0F); | ||
|
@@ -398,7 +417,7 @@ static tbool tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const uint8* data, | |
while (src_size > 0) | ||
{ | ||
/* Ensure enough space for decoding */ | ||
if (mdecoder->decoded_size_max - mdecoder->decoded_size < AVCODEC_MAX_AUDIO_FRAME_SIZE) | ||
if (mdecoder->decoded_size_max - mdecoder->decoded_size < MAX_AUDIO_FRAME_SIZE) | ||
{ | ||
mdecoder->decoded_size_max = mdecoder->decoded_size_max * 2 + 16; | ||
mdecoder->decoded_data = xrealloc(mdecoder->decoded_data, mdecoder->decoded_size_max); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,11 @@ ubuntu 14.04 | |
#define LIBAVCODEC_VERSION_MINOR 35 | ||
#define LIBAVCODEC_VERSION_MICRO 0 | ||
|
||
ubuntu 16.04 | ||
#define LIBAVCODEC_VERSION_MAJOR 56 | ||
#define LIBAVCODEC_VERSION_MINOR 60 | ||
#define LIBAVCODEC_VERSION_MICRO 100 | ||
|
||
debian 7 | ||
#define LIBAVCODEC_VERSION_MAJOR 54 | ||
#define LIBAVCODEC_VERSION_MINOR 59 | ||
|
@@ -107,6 +112,10 @@ debian 8 | |
#define DISTRO_UBUNTU1404 | ||
#endif | ||
|
||
#if LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR == 60 | ||
#define DISTRO_UBUNTU1604 | ||
#endif | ||
|
||
#if LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR == 26 | ||
#define DISTRO_DEBIAN8 | ||
#endif | ||
|
@@ -115,7 +124,7 @@ debian 8 | |
#if !defined(DISTRO_DEBIAN6) && !defined(DISTRO_UBUNTU1104) && \ | ||
!defined(DISTRO_UBUNTU1111) && !defined(DISTRO_UBUNTU1204) && \ | ||
!defined(DISTRO_DEBIAN7) && !defined(DISTRO_UBUNTU1404) && \ | ||
!defined(DISTRO_DEBIAN8) | ||
!defined(DISTRO_UBUNTU1604) && !defined(DISTRO_DEBIAN8) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove tab after |
||
#warning unsupported distro | ||
#endif | ||
|
||
|
@@ -141,7 +150,7 @@ typedef struct player_state_info | |
AVCodec *video_codec; | ||
AVFrame *audio_frame; | ||
AVFrame *video_frame; | ||
#if defined(DISTRO_DEBIAN8) | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know its already there but I don't like those there's not really an dependency/change on a specific distro There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can keep it like this for now. meh. |
||
AVDictionary *audio_codec_options; | ||
AVDictionary *video_codec_options; | ||
#endif | ||
|
@@ -183,11 +192,11 @@ static int display_picture(PLAYER_STATE_INFO *psi); | |
#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO | ||
#endif | ||
|
||
#if defined(DISTRO_DEBIAN7) || defined(DISTRO_UBUNTU1404) || defined(DISTRO_DEBIAN8) | ||
#if defined(DISTRO_DEBIAN7) || defined(DISTRO_UBUNTU1404) || defined(DISTRO_UBUNTU1604) || defined(DISTRO_DEBIAN8) | ||
#define SAMPLE_FMT_U8 AV_SAMPLE_FMT_U8 | ||
#endif | ||
|
||
#if defined(DISTRO_DEBIAN8) | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 | ||
#endif | ||
|
||
|
@@ -218,20 +227,20 @@ void* init_player(void* plugin, char* filename) | |
|
||
psi->audio_codec = avcodec_find_decoder(CODEC_ID_AAC); | ||
|
||
#ifdef DISTRO_DEBIAN8 | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
psi->audio_codec_ctx = avcodec_alloc_context3(psi->audio_codec); | ||
#else | ||
psi->audio_codec_ctx = avcodec_alloc_context(); | ||
#endif | ||
|
||
psi->video_codec = avcodec_find_decoder(CODEC_ID_H264); | ||
#ifdef DISTRO_DEBIAN8 | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
psi->video_codec_ctx = avcodec_alloc_context3(psi->video_codec); | ||
#else | ||
psi->video_codec_ctx = avcodec_alloc_context(); | ||
#endif | ||
|
||
#ifdef DISTRO_DEBIAN8 | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
psi->audio_frame = av_frame_alloc(); | ||
psi->video_frame = av_frame_alloc(); | ||
#else | ||
|
@@ -404,7 +413,7 @@ set_audio_config(void* vp, char* extradata, int extradata_size, | |
psi->audio_codec_ctx->block_align = block_align; | ||
#if defined(AV_CPU_FLAG_SSE2) | ||
|
||
#if defined(DISTRO_DEBIAN8) | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
av_force_cpu_flags(AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_MMX2); | ||
#else | ||
psi->audio_codec_ctx->dsp_mask = AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_MMX2; | ||
|
@@ -414,15 +423,15 @@ set_audio_config(void* vp, char* extradata, int extradata_size, | |
|
||
#if LIBAVCODEC_VERSION_MAJOR < 53 | ||
|
||
#if defined(DISTRO_DEBIAN8) | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
av_force_cpu_flags(FF_MM_SSE2 | FF_MM_MMXEXT); | ||
#else | ||
psi->audio_codec_ctx->dsp_mask = FF_MM_SSE2 | FF_MM_MMXEXT; | ||
#endif | ||
|
||
#else | ||
|
||
#if defined(DISTRO_DEBIAN8) | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
av_force_cpu_flags(FF_MM_SSE2 | FF_MM_MMX2); | ||
#else | ||
psi->audio_codec_ctx->dsp_mask = FF_MM_SSE2 | FF_MM_MMX2; | ||
|
@@ -436,7 +445,7 @@ set_audio_config(void* vp, char* extradata, int extradata_size, | |
psi->audio_codec_ctx->flags |= CODEC_FLAG_TRUNCATED; | ||
} | ||
|
||
#ifdef DISTRO_DEBIAN8 | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
if (avcodec_open2(psi->audio_codec_ctx, psi->audio_codec, &psi->audio_codec_options) < 0) | ||
|
||
#else | ||
|
@@ -459,7 +468,7 @@ set_video_config(void *vp) | |
PLAYER_STATE_INFO *psi = (PLAYER_STATE_INFO *) vp; | ||
|
||
printf("set_video_config:\n"); | ||
#ifdef DISTRO_DEBIAN8 | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
if (avcodec_open2(psi->video_codec_ctx, psi->video_codec, &psi->video_codec_options) < 0) | ||
|
||
#else | ||
|
@@ -596,7 +605,7 @@ play_video(PLAYER_STATE_INFO *psi, struct AVPacket *av_pkt) | |
|
||
/* TODO where is this memory released? */ | ||
psi->video_decoded_data = xzalloc(psi->video_decoded_size); | ||
#if defined(DISTRO_DEBIAN8) | ||
#if defined(DISTRO_DEBIAN8) || defined(DISTRO_UBUNTU1604) | ||
frame = av_frame_alloc(); | ||
#else | ||
frame = avcodec_alloc_frame(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ void freerdp_set_pixel(uint8* data, int x, int y, int width, int height, int bpp | |
} | ||
} | ||
|
||
INLINE void freerdp_color_split_rgb(uint32* color, int bpp, uint8* red, uint8* green, uint8* blue, uint8* alpha, HCLRCONV clrconv) | ||
static INLINE void freerdp_color_split_rgb(uint32* color, int bpp, uint8* red, uint8* green, uint8* blue, uint8* alpha, HCLRCONV clrconv) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like those changes are irrelevant to this PR (not an ffmpeg api fixes) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes makes sense. |
||
{ | ||
*red = *green = *blue = 0; | ||
*alpha = (clrconv->alpha) ? 0xFF : 0x00; | ||
|
@@ -137,7 +137,7 @@ INLINE void freerdp_color_split_rgb(uint32* color, int bpp, uint8* red, uint8* g | |
} | ||
} | ||
|
||
INLINE void freerdp_color_split_bgr(uint32* color, int bpp, uint8* red, uint8* green, uint8* blue, uint8* alpha, HCLRCONV clrconv) | ||
static INLINE void freerdp_color_split_bgr(uint32* color, int bpp, uint8* red, uint8* green, uint8* blue, uint8* alpha, HCLRCONV clrconv) | ||
{ | ||
*red = *green = *blue = 0; | ||
*alpha = (clrconv->alpha) ? 0xFF : 0x00; | ||
|
@@ -188,7 +188,7 @@ INLINE void freerdp_color_split_bgr(uint32* color, int bpp, uint8* red, uint8* g | |
} | ||
} | ||
|
||
INLINE void freerdp_color_make_rgb(uint32* color, int bpp, uint8* red, uint8* green, uint8* blue, uint8* alpha, HCLRCONV clrconv) | ||
static INLINE void freerdp_color_make_rgb(uint32* color, int bpp, uint8* red, uint8* green, uint8* blue, uint8* alpha, HCLRCONV clrconv) | ||
{ | ||
switch (bpp) | ||
{ | ||
|
@@ -229,7 +229,7 @@ INLINE void freerdp_color_make_rgb(uint32* color, int bpp, uint8* red, uint8* gr | |
} | ||
} | ||
|
||
INLINE void freerdp_color_make_bgr(uint32* color, int bpp, uint8* red, uint8* green, uint8* blue, uint8* alpha, HCLRCONV clrconv) | ||
static INLINE void freerdp_color_make_bgr(uint32* color, int bpp, uint8* red, uint8* green, uint8* blue, uint8* alpha, HCLRCONV clrconv) | ||
{ | ||
switch (bpp) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where this sample rate come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is defined in the linked PR, nothing I added.
But it seems to be a generic hard coded limit for whatever reason and represents "1 second of 48khz 32-bit audio"
https://www.ffmpeg.org/doxygen/3.2/libavformat_2dvenc_8c_source.html#l00045
https://lists.ffmpeg.org/pipermail/ffmpeg-cvslog/2012-August/053785.html