Skip to content
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

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions channels/drdynvc/tsmf/ffmpeg/tsmf_ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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?

Copy link
Contributor Author

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

#endif

typedef struct _TSMFFFmpegDecoder
{
ITSMFDecoder iface;

int media_type;
enum CodecID codec_id;
#if LIBAVCODEC_VERSION_MAJOR < 55
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer not to pollute the code with inline ifdefs
we should use the latest API and backport it using our own defines (at the head of this file or smthg).

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;
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same applies here.
lets make a wrapper for av_set_cpu_flags_mask and backport its code for older api.
(maybe even copy their implementation)

#ifdef AV_CPU_FLAG_SSE2
mdecoder->codec_context->dsp_mask = AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_MMX2;
#else
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAX_AUDIO_FRAME_SIZE shouldnt be defined by us
we should find another way to backport this code

mdecoder->decoded_data = xzalloc(mdecoder->decoded_size_max);
/* align the memory for SSE2 needs */
dst = (uint8*) (((uintptr_t)mdecoder->decoded_data + 15) & ~ 0x0F);
Expand All @@ -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);
Expand Down
35 changes: 22 additions & 13 deletions channels/xrdpvr/xrdpvr_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove tab after &&

#warning unsupported distro
#endif

Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know its already there but I don't like those DISTRO_xxx backport style. its very specific.
we should backport the code so it builds everywhere with this ffmpeg libs

there's not really an dependency/change on a specific distro

Copy link
Member

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions libfreerdp-codec/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The 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)
either split it to another PR or remove them for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes makes sense.
Will try to make an own PR for these changes.

{
*red = *green = *blue = 0;
*alpha = (clrconv->alpha) ? 0xFF : 0x00;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions libfreerdp-core/fastpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ uint16 fastpath_read_header(rdpFastPath* fastpath, STREAM* s)
return length;
}

INLINE void fastpath_read_update_header(STREAM* s, uint8* updateCode, uint8* fragmentation, uint8* compression)
static INLINE void fastpath_read_update_header(STREAM* s, uint8* updateCode, uint8* fragmentation, uint8* compression)
{
uint8 updateHeader;

Expand All @@ -101,7 +101,7 @@ INLINE void fastpath_read_update_header(STREAM* s, uint8* updateCode, uint8* fra
*compression = (updateHeader >> 6) & 0x03;
}

INLINE void fastpath_write_update_header(STREAM* s, uint8 updateCode, uint8 fragmentation, uint8 compression)
static INLINE void fastpath_write_update_header(STREAM* s, uint8 updateCode, uint8 fragmentation, uint8 compression)
{
uint8 updateHeader = 0;

Expand Down
26 changes: 13 additions & 13 deletions libfreerdp-core/orders.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static const uint8 BMF_BPP[] =
0, 1, 0, 8, 16, 24, 32
};

INLINE void update_read_coord(STREAM* s, sint32* coord, tbool delta)
static INLINE void update_read_coord(STREAM* s, sint32* coord, tbool delta)
{
sint8 lsi8;
sint16 lsi16;
Expand All @@ -161,7 +161,7 @@ INLINE void update_read_coord(STREAM* s, sint32* coord, tbool delta)
}
}

INLINE void update_read_color(STREAM* s, uint32* color)
static INLINE void update_read_color(STREAM* s, uint32* color)
{
uint8 byte;

Expand All @@ -173,7 +173,7 @@ INLINE void update_read_color(STREAM* s, uint32* color)
*color |= (byte << 16);
}

INLINE void update_read_colorref(STREAM* s, uint32* color)
static INLINE void update_read_colorref(STREAM* s, uint32* color)
{
uint8 byte;

Expand All @@ -186,7 +186,7 @@ INLINE void update_read_colorref(STREAM* s, uint32* color)
stream_seek_uint8(s);
}

INLINE void update_read_color_quad(STREAM* s, uint32* color)
static INLINE void update_read_color_quad(STREAM* s, uint32* color)
{
uint8 byte;

Expand All @@ -199,7 +199,7 @@ INLINE void update_read_color_quad(STREAM* s, uint32* color)
stream_seek_uint8(s);
}

INLINE void update_read_2byte_unsigned(STREAM* s, uint32* value)
static INLINE void update_read_2byte_unsigned(STREAM* s, uint32* value)
{
uint8 byte;

Expand All @@ -217,7 +217,7 @@ INLINE void update_read_2byte_unsigned(STREAM* s, uint32* value)
}
}

INLINE void update_read_2byte_signed(STREAM* s, sint32* value)
static INLINE void update_read_2byte_signed(STREAM* s, sint32* value)
{
uint8 byte;
tbool negative;
Expand All @@ -238,7 +238,7 @@ INLINE void update_read_2byte_signed(STREAM* s, sint32* value)
*value *= -1;
}

INLINE void update_read_4byte_unsigned(STREAM* s, uint32* value)
static INLINE void update_read_4byte_unsigned(STREAM* s, uint32* value)
{
uint8 byte;
uint8 count;
Expand Down Expand Up @@ -282,7 +282,7 @@ INLINE void update_read_4byte_unsigned(STREAM* s, uint32* value)
}
}

INLINE void update_read_delta(STREAM* s, sint32* value)
static INLINE void update_read_delta(STREAM* s, sint32* value)
{
uint8 byte;

Expand All @@ -300,7 +300,7 @@ INLINE void update_read_delta(STREAM* s, sint32* value)
}
}

INLINE void update_read_glyph_delta(STREAM* s, uint16* value)
static INLINE void update_read_glyph_delta(STREAM* s, uint16* value)
{
uint8 byte;

Expand All @@ -312,7 +312,7 @@ INLINE void update_read_glyph_delta(STREAM* s, uint16* value)
*value = (byte & 0x3F);
}

INLINE void update_seek_glyph_delta(STREAM* s)
static INLINE void update_seek_glyph_delta(STREAM* s)
{
uint8 byte;

Expand All @@ -322,7 +322,7 @@ INLINE void update_seek_glyph_delta(STREAM* s)
stream_seek_uint8(s);
}

INLINE void update_read_brush(STREAM* s, rdpBrush* brush, uint8 fieldFlags)
static INLINE void update_read_brush(STREAM* s, rdpBrush* brush, uint8 fieldFlags)
{
if (fieldFlags & ORDER_FIELD_01)
stream_read_uint8(s, brush->x);
Expand Down Expand Up @@ -360,7 +360,7 @@ INLINE void update_read_brush(STREAM* s, rdpBrush* brush, uint8 fieldFlags)
}
}

INLINE void update_read_delta_rects(STREAM* s, DELTA_RECT* rectangles, int number)
static INLINE void update_read_delta_rects(STREAM* s, DELTA_RECT* rectangles, int number)
{
int i;
uint8 flags = 0;
Expand Down Expand Up @@ -405,7 +405,7 @@ INLINE void update_read_delta_rects(STREAM* s, DELTA_RECT* rectangles, int numbe
}
}

INLINE void update_read_delta_points(STREAM* s, DELTA_POINT* points, int number, sint16 x, sint16 y)
static INLINE void update_read_delta_points(STREAM* s, DELTA_POINT* points, int number, sint16 x, sint16 y)
{
int i;
uint8 flags = 0;
Expand Down
Loading