1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
diff --git a/apps/plugins/mpegplayer/alloc.c b/apps/plugins/mpegplayer/alloc.c
index da92f87..aa842af 100644
--- a/apps/plugins/mpegplayer/alloc.c
+++ b/apps/plugins/mpegplayer/alloc.c
@@ -112,13 +112,13 @@ static void * mpeg_malloc_internal (unsigned char *mallocbuf,
     (void)reason;
 }

-void *mpeg_malloc(size_t size, mpeg2_alloc_t reason)
+void *mpeg_malloc(size_t size, int reason)
 {
     return mpeg_malloc_internal(mallocbuf, &mem_ptr, bufsize, size,
                                 reason);
 }

-void *mpeg_malloc_all(size_t *size_out, mpeg2_alloc_t reason)
+void *mpeg_malloc_all(size_t *size_out, int reason)
 {
     /* Can steal all but MIN_MEMMARGIN */
     if (bufsize - mem_ptr < MIN_MEMMARGIN)
@@ -154,7 +154,7 @@ bool mpeg_alloc_init(unsigned char *buf, size_t mallocsize)
 }

 /* allocate non-dedicated buffer space which mpeg2_mem_reset will free */
-void * mpeg2_malloc(unsigned size, mpeg2_alloc_t reason)
+void * mpeg2_malloc(unsigned size, int reason)
 {
     void *ptr = mpeg_malloc_internal(mpeg2_mallocbuf, &mpeg2_mem_ptr,
                                      mpeg2_bufsize, size, reason);
@@ -167,7 +167,7 @@ void * mpeg2_malloc(unsigned size, mpeg2_alloc_t reason)

 /* allocate dedicated buffer - memory behind buffer pointer becomes dedicated
    so order is important */
-void * mpeg2_bufalloc(unsigned size, mpeg2_alloc_t reason)
+void * mpeg2_bufalloc(unsigned size, int reason)
 {
     void *buf = mpeg2_malloc(size, reason);

diff --git a/apps/plugins/mpegplayer/mpeg2.h b/apps/plugins/mpegplayer/mpeg2.h
index 2a63f39..b183d86 100644
--- a/apps/plugins/mpegplayer/mpeg2.h
+++ b/apps/plugins/mpegplayer/mpeg2.h
@@ -130,6 +130,7 @@ typedef struct mpeg2_decoder_s mpeg2_decoder_t;

 typedef enum
 {
+    STATE_INTERNAL_NORETURN = -1,
     STATE_BUFFER            = 0,
     STATE_SEQUENCE          = 1,
     STATE_SEQUENCE_REPEATED = 2,
@@ -199,15 +200,16 @@ typedef enum
     MPEG2_ALLOC_CHUNK      = 1,
     MPEG2_ALLOC_YUV        = 2,
     MPEG2_ALLOC_CONVERT_ID = 3,
-    MPEG2_ALLOC_CONVERTED  = 4
+    MPEG2_ALLOC_CONVERTED  = 4,
+    MPEG2_ALLOC_T_MAX
 } mpeg2_alloc_t;

-void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason);
+void * mpeg2_malloc (unsigned size, int reason);
 #if 0
 void mpeg2_free (void * buf);
 #endif
 /* allocates a dedicated buffer and locks all previous allocation in place */
-void * mpeg2_bufalloc(unsigned size, mpeg2_alloc_t reason);
+void * mpeg2_bufalloc(unsigned size, int reason);
 /* clears all non-dedicated buffer space */
 void mpeg2_mem_reset(void);
 void mpeg2_alloc_init(unsigned char* buf, int mallocsize);
diff --git a/apps/plugins/mpegplayer/mpeg2_internal.h b/apps/plugins/mpegplayer/mpeg2_internal.h
index cbc3e24..f8c9891 100644
--- a/apps/plugins/mpegplayer/mpeg2_internal.h
+++ b/apps/plugins/mpegplayer/mpeg2_internal.h
@@ -29,8 +29,6 @@

 #include "config.h" /* for Rockbox CPU_ #defines */

-#define STATE_INTERNAL_NORETURN ((mpeg2_state_t)-1)
-
 /* macroblock modes */
 #define MACROBLOCK_INTRA            1
 #define MACROBLOCK_PATTERN          2
diff --git a/apps/plugins/mpegplayer/mpeg_alloc.h b/apps/plugins/mpegplayer/mpeg_alloc.h
index 9acfbc5..9a23721 100644
--- a/apps/plugins/mpegplayer/mpeg_alloc.h
+++ b/apps/plugins/mpegplayer/mpeg_alloc.h
@@ -23,9 +23,9 @@

 /* returns the remaining mpeg2 buffer and it's size */
 void * mpeg2_get_buf(size_t *size);
-void *mpeg_malloc(size_t size, mpeg2_alloc_t reason);
+void *mpeg_malloc(size_t size, int reason);
 /* Grabs all the buffer available sans margin */
-void *mpeg_malloc_all(size_t *size_out, mpeg2_alloc_t reason);
+void *mpeg_malloc_all(size_t *size_out, int reason);
 /* Initializes the malloc buffer with the given base buffer */
 bool mpeg_alloc_init(unsigned char *buf, size_t mallocsize);

diff --git a/apps/plugins/mpegplayer/mpegplayer.h b/apps/plugins/mpegplayer/mpegplayer.h
index 6247a6d..7b11730 100644
--- a/apps/plugins/mpegplayer/mpegplayer.h
+++ b/apps/plugins/mpegplayer/mpegplayer.h
@@ -32,17 +32,6 @@
 /* Memory allotments for various subsystems */
 #define MIN_MEMMARGIN (4*1024)

-enum mpeg_malloc_reason_t
-{
-    __MPEG_ALLOC_FIRST = -256,
-    MPEG_ALLOC_CODEC_MALLOC,
-    MPEG_ALLOC_CODEC_CALLOC,
-    MPEG_ALLOC_MPEG2_BUFFER,
-    MPEG_ALLOC_AUDIOBUF,
-    MPEG_ALLOC_PCMOUT,
-    MPEG_ALLOC_DISKBUF,
-};
-
 /** Video thread **/
 #define LIBMPEG2_ALLOC_SIZE (2*1024*1024)

@@ -103,6 +92,17 @@ enum mpeg_malloc_reason_t
 #include "disk_buf.h"
 #include "stream_mgr.h"

+enum mpeg_malloc_reason_t
+{
+    __MPEG_ALLOC_FIRST = -256,
+    MPEG_ALLOC_CODEC_MALLOC = MPEG2_ALLOC_T_MAX,
+    MPEG_ALLOC_CODEC_CALLOC,
+    MPEG_ALLOC_MPEG2_BUFFER,
+    MPEG_ALLOC_AUDIOBUF,
+    MPEG_ALLOC_PCMOUT,
+    MPEG_ALLOC_DISKBUF,
+};
+
 #define LCD_ENABLE_EVENT_0 MAKE_SYS_EVENT(SYS_EVENT_CLS_PRIVATE, 0)
 #define LCD_ENABLE_EVENT_1 MAKE_SYS_EVENT(SYS_EVENT_CLS_PRIVATE, 1)