ffmpeg.patch 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. diff -ru freerdp-1.0.2.orig/channels/drdynvc/tsmf/ffmpeg/tsmf_ffmpeg.c freerdp-1.0.2/channels/drdynvc/tsmf/ffmpeg/tsmf_ffmpeg.c
  2. --- freerdp-1.0.2.orig/channels/drdynvc/tsmf/ffmpeg/tsmf_ffmpeg.c 2013-01-03 06:46:59.000000000 +0900
  3. +++ freerdp-1.0.2/channels/drdynvc/tsmf/ffmpeg/tsmf_ffmpeg.c 2017-05-02 14:47:47.897325525 +0900
  4. @@ -34,12 +34,39 @@
  5. #define AVMEDIA_TYPE_AUDIO 1
  6. #endif
  7. +#if LIBAVCODEC_VERSION_MAJOR < 54
  8. +#define MAX_AUDIO_FRAME_SIZE AVCODEC_MAX_AUDIO_FRAME_SIZE
  9. +#else
  10. +#define MAX_AUDIO_FRAME_SIZE 192000
  11. +#endif
  12. +
  13. +#if LIBAVCODEC_VERSION_MAJOR < 55
  14. +#define AV_CODEC_ID_VC1 CODEC_ID_VC1
  15. +#define AV_CODEC_ID_WMAV2 CODEC_ID_WMAV2
  16. +#define AV_CODEC_ID_WMAPRO CODEC_ID_WMAPRO
  17. +#define AV_CODEC_ID_MP3 CODEC_ID_MP3
  18. +#define AV_CODEC_ID_MP2 CODEC_ID_MP2
  19. +#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO
  20. +#define AV_CODEC_ID_WMV3 CODEC_ID_WMV3
  21. +#define AV_CODEC_ID_AAC CODEC_ID_AAC
  22. +#define AV_CODEC_ID_H264 CODEC_ID_H264
  23. +#define AV_CODEC_ID_AC3 CODEC_ID_AC3
  24. +#endif
  25. +
  26. +#if LIBAVUTIL_VERSION_MAJOR < 52
  27. +#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
  28. +#endif
  29. +
  30. typedef struct _TSMFFFmpegDecoder
  31. {
  32. ITSMFDecoder iface;
  33. int media_type;
  34. +#if LIBAVCODEC_VERSION_MAJOR < 55
  35. enum CodecID codec_id;
  36. +#else
  37. + enum AVCodecID codec_id;
  38. +#endif
  39. AVCodecContext* codec_context;
  40. AVCodec* codec;
  41. AVFrame* frame;
  42. @@ -54,7 +81,7 @@
  43. {
  44. TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
  45. - mdecoder->codec_context = avcodec_alloc_context();
  46. + mdecoder->codec_context = avcodec_alloc_context3(NULL);
  47. if (!mdecoder->codec_context)
  48. {
  49. DEBUG_WARN("avcodec_alloc_context failed.");
  50. @@ -73,8 +100,11 @@
  51. mdecoder->codec_context->bit_rate = media_type->BitRate;
  52. mdecoder->codec_context->time_base.den = media_type->SamplesPerSecond.Numerator;
  53. mdecoder->codec_context->time_base.num = media_type->SamplesPerSecond.Denominator;
  54. -
  55. +#if LIBAVCODEC_VERSION_MAJOR < 55
  56. mdecoder->frame = avcodec_alloc_frame();
  57. +#else
  58. + mdecoder->frame = av_frame_alloc();
  59. +#endif
  60. return true;
  61. }
  62. @@ -88,6 +118,7 @@
  63. mdecoder->codec_context->channels = media_type->Channels;
  64. mdecoder->codec_context->block_align = media_type->BlockAlign;
  65. +#if LIBAVCODEC_VERSION_MAJOR < 55
  66. #ifdef AV_CPU_FLAG_SSE2
  67. mdecoder->codec_context->dsp_mask = AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_MMX2;
  68. #else
  69. @@ -97,6 +128,13 @@
  70. mdecoder->codec_context->dsp_mask = FF_MM_SSE2 | FF_MM_MMX2;
  71. #endif
  72. #endif
  73. +#else /* LIBAVCODEC_VERSION_MAJOR < 55 */
  74. +#ifdef AV_CPU_FLAG_SSE2
  75. + av_set_cpu_flags_mask(AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_MMXEXT);
  76. +#else
  77. + av_set_cpu_flags_mask(FF_MM_SSE2 | FF_MM_MMX2);
  78. +#endif
  79. +#endif /* LIBAVCODEC_VERSION_MAJOR < 55 */
  80. return true;
  81. }
  82. @@ -203,28 +241,28 @@
  83. switch (media_type->SubType)
  84. {
  85. case TSMF_SUB_TYPE_WVC1:
  86. - mdecoder->codec_id = CODEC_ID_VC1;
  87. + mdecoder->codec_id = AV_CODEC_ID_VC1;
  88. break;
  89. case TSMF_SUB_TYPE_WMA2:
  90. - mdecoder->codec_id = CODEC_ID_WMAV2;
  91. + mdecoder->codec_id = AV_CODEC_ID_WMAV2;
  92. break;
  93. case TSMF_SUB_TYPE_WMA9:
  94. - mdecoder->codec_id = CODEC_ID_WMAPRO;
  95. + mdecoder->codec_id = AV_CODEC_ID_WMAPRO;
  96. break;
  97. case TSMF_SUB_TYPE_MP3:
  98. - mdecoder->codec_id = CODEC_ID_MP3;
  99. + mdecoder->codec_id = AV_CODEC_ID_MP3;
  100. break;
  101. case TSMF_SUB_TYPE_MP2A:
  102. - mdecoder->codec_id = CODEC_ID_MP2;
  103. + mdecoder->codec_id = AV_CODEC_ID_MP2;
  104. break;
  105. case TSMF_SUB_TYPE_MP2V:
  106. - mdecoder->codec_id = CODEC_ID_MPEG2VIDEO;
  107. + mdecoder->codec_id = AV_CODEC_ID_MPEG2VIDEO;
  108. break;
  109. case TSMF_SUB_TYPE_WMV3:
  110. - mdecoder->codec_id = CODEC_ID_WMV3;
  111. + mdecoder->codec_id = AV_CODEC_ID_WMV3;
  112. break;
  113. case TSMF_SUB_TYPE_AAC:
  114. - mdecoder->codec_id = CODEC_ID_AAC;
  115. + mdecoder->codec_id = AV_CODEC_ID_AAC;
  116. /* For AAC the pFormat is a HEAACWAVEINFO struct, and the codec data
  117. is at the end of it. See
  118. http://msdn.microsoft.com/en-us/library/dd757806.aspx */
  119. @@ -236,10 +274,10 @@
  120. break;
  121. case TSMF_SUB_TYPE_H264:
  122. case TSMF_SUB_TYPE_AVC1:
  123. - mdecoder->codec_id = CODEC_ID_H264;
  124. + mdecoder->codec_id = AV_CODEC_ID_H264;
  125. break;
  126. case TSMF_SUB_TYPE_AC3:
  127. - mdecoder->codec_id = CODEC_ID_AC3;
  128. + mdecoder->codec_id = AV_CODEC_ID_AC3;
  129. break;
  130. default:
  131. return false;
  132. @@ -299,7 +337,12 @@
  133. mdecoder->decoded_size = avpicture_get_size(mdecoder->codec_context->pix_fmt,
  134. mdecoder->codec_context->width, mdecoder->codec_context->height);
  135. mdecoder->decoded_data = xzalloc(mdecoder->decoded_size);
  136. +
  137. +#if LIBAVCODEC_VERSION_MAJOR < 55
  138. frame = avcodec_alloc_frame();
  139. +#else
  140. + frame = av_frame_alloc();
  141. +#endif
  142. avpicture_fill((AVPicture *) frame, mdecoder->decoded_data,
  143. mdecoder->codec_context->pix_fmt,
  144. mdecoder->codec_context->width, mdecoder->codec_context->height);
  145. @@ -337,7 +380,7 @@
  146. #endif
  147. if (mdecoder->decoded_size_max == 0)
  148. - mdecoder->decoded_size_max = AVCODEC_MAX_AUDIO_FRAME_SIZE + 16;
  149. + mdecoder->decoded_size_max = MAX_AUDIO_FRAME_SIZE + 16;
  150. mdecoder->decoded_data = xzalloc(mdecoder->decoded_size_max);
  151. /* align the memory for SSE2 needs */
  152. dst = (uint8*) (((uintptr_t)mdecoder->decoded_data + 15) & ~ 0x0F);
  153. @@ -348,7 +391,7 @@
  154. while (src_size > 0)
  155. {
  156. /* Ensure enough space for decoding */
  157. - if (mdecoder->decoded_size_max - mdecoder->decoded_size < AVCODEC_MAX_AUDIO_FRAME_SIZE)
  158. + if (mdecoder->decoded_size_max - mdecoder->decoded_size < MAX_AUDIO_FRAME_SIZE)
  159. {
  160. mdecoder->decoded_size_max = mdecoder->decoded_size_max * 2 + 16;
  161. mdecoder->decoded_data = xrealloc(mdecoder->decoded_data, mdecoder->decoded_size_max);
  162. @@ -445,7 +488,7 @@
  163. switch (mdecoder->codec_context->pix_fmt)
  164. {
  165. - case PIX_FMT_YUV420P:
  166. + case AV_PIX_FMT_YUV420P:
  167. return RDP_PIXFMT_I420;
  168. default: