[MPlayer-cvslog] r38192 - in trunk: configure libmpdemux/video.c loader/win32.c sub/sub.c

reimar subversion at mplayerhq.hu
Sun Jun 14 20:55:21 EEST 2020


Author: reimar
Date: Sun Jun 14 20:55:21 2020
New Revision: 38192

Log:
Remove usage of memalign.

Switch to av_malloc instead.
Only vo_vesa remains using memalign as it requests 64-byte alignment,
which is more than av_malloc provides.
The fallback for memalign has been plain malloc, which meant crashes
on e.g. Win32 where malloc is not sufficiently aligned.

Modified:
   trunk/configure
   trunk/libmpdemux/video.c
   trunk/loader/win32.c
   trunk/sub/sub.c

Modified: trunk/configure
==============================================================================
--- trunk/configure	Sat Jun  6 18:13:32 2020	(r38191)
+++ trunk/configure	Sun Jun 14 20:55:21 2020	(r38192)
@@ -3988,8 +3988,6 @@ if test "$_memalign" = yes ; then
   def_memalign='#define HAVE_MEMALIGN 1'
 else
   def_memalign='#define HAVE_MEMALIGN 0'
-  def_map_memalign='#define memalign(a, b) malloc(b)'
-  darwin || def_memalign_hack='#define CONFIG_MEMALIGN_HACK 1'
 fi
 echores "$_memalign"
 
@@ -9008,7 +9006,6 @@ $def_glob
 $def_gmtime_r
 $def_langinfo
 $def_localtime_r
-$def_map_memalign
 $def_memalign
 $def_nanosleep
 $def_posix_select
@@ -9036,7 +9033,6 @@ $def_kstat
 $def_macosx_bundle
 $def_macosx_finder
 $def_maemo
-$def_memalign_hack
 $def_path_max_check
 $def_priority
 $def_quicktime

Modified: trunk/libmpdemux/video.c
==============================================================================
--- trunk/libmpdemux/video.c	Sat Jun  6 18:13:32 2020	(r38191)
+++ trunk/libmpdemux/video.c	Sun Jun 14 20:55:21 2020	(r38192)
@@ -134,7 +134,7 @@ switch(video_codec){
    }
    mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
    if(!videobuffer) {
-     videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+     videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
      if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
      else {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
@@ -229,7 +229,7 @@ switch(video_codec){
    }
    mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
    if(!videobuffer) {
-     videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+     videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
      if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
      else {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
@@ -275,7 +275,7 @@ switch(video_codec){
  case VIDEO_HEVC: {
    videobuf_len=0; videobuf_code_len=0;
    if(!videobuffer) {
-     videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+     videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
      if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
      else {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
@@ -306,7 +306,7 @@ mpeg_header_parser:
    mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
    // ========= Read & process sequence header & extension ============
    if(!videobuffer) {
-     videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+     videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
      if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
      else {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
@@ -374,7 +374,7 @@ mpeg_header_parser:
    }
    mp_msg(MSGT_DECVIDEO,MSGL_INFO,"found\n");
    if(!videobuffer) {
-     videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+     videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
      if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
      else {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);

Modified: trunk/loader/win32.c
==============================================================================
--- trunk/loader/win32.c	Sat Jun  6 18:13:32 2020	(r38191)
+++ trunk/loader/win32.c	Sun Jun 14 20:55:21 2020	(r38192)
@@ -351,7 +351,7 @@ void* mreq_private(int size, int to_zero
 void* mreq_private(int size, int to_zero, int type)
 {
     int nsize = size + sizeof(alloc_header);
-    alloc_header* header = memalign(16, nsize);
+    alloc_header* header = av_malloc(nsize);
     if (!header)
         return 0;
     if (to_zero)
@@ -436,7 +436,7 @@ static int my_release(void* memory)
 	return 0;
 #endif
     //memset(header + 1, 0xcc, header->size);
-    free(header);
+    av_free(header);
     return 0;
 }
 #endif

Modified: trunk/sub/sub.c
==============================================================================
--- trunk/sub/sub.c	Sat Jun  6 18:13:32 2020	(r38191)
+++ trunk/sub/sub.c	Sun Jun 14 20:55:21 2020	(r38192)
@@ -156,10 +156,10 @@ static void alloc_buf(mp_osd_obj_t* obj)
     len = obj->stride*(obj->bbox.y2-obj->bbox.y1);
     if (obj->allocated<len) {
 	obj->allocated = len;
-	free(obj->bitmap_buffer);
-	free(obj->alpha_buffer);
-	obj->bitmap_buffer = memalign(16, len);
-	obj->alpha_buffer  = memalign(16, len);
+	av_freep(&obj->bitmap_buffer);
+	av_freep(&obj->alpha_buffer);
+	obj->bitmap_buffer = av_malloc(len);
+	obj->alpha_buffer  = av_malloc(len);
     }
     memset(obj->bitmap_buffer, sub_bg_color, len);
     memset(obj->alpha_buffer, sub_bg_alpha, len);
@@ -1101,8 +1101,8 @@ void free_osd_list(void){
     mp_osd_obj_t* obj=vo_osd_list;
     while(obj){
 	mp_osd_obj_t* next=obj->next;
-	free(obj->alpha_buffer);
-	free(obj->bitmap_buffer);
+	av_freep(&obj->alpha_buffer);
+	av_freep(&obj->bitmap_buffer);
 	free(obj);
 	obj=next;
     }


More information about the MPlayer-cvslog mailing list