Browse code

jvdec: K&R formatting cosmetics

Signed-off-by: Diego Biurrun <diego@biurrun.de>

Vittorio Giovara authored on 2013/12/13 22:30:22
Showing 2 changed files
... ...
@@ -25,11 +25,12 @@
25 25
  * @author Peter Ross <pross@xvid.org>
26 26
  */
27 27
 
28
+#include "libavutil/intreadwrite.h"
29
+
28 30
 #include "avcodec.h"
29 31
 #include "dsputil.h"
30 32
 #include "get_bits.h"
31 33
 #include "internal.h"
32
-#include "libavutil/intreadwrite.h"
33 34
 
34 35
 typedef struct JvContext {
35 36
     DSPContext dsp;
... ...
@@ -62,19 +63,19 @@ static inline void decode2x2(GetBitContext *gb, uint8_t *dst, int linesize)
62 62
     case 1:
63 63
         v[0] = get_bits(gb, 8);
64 64
         for (j = 0; j < 2; j++)
65
-            memset(dst + j*linesize, v[0], 2);
65
+            memset(dst + j * linesize, v[0], 2);
66 66
         break;
67 67
     case 2:
68 68
         v[0] = get_bits(gb, 8);
69 69
         v[1] = get_bits(gb, 8);
70 70
         for (j = 0; j < 2; j++)
71 71
             for (i = 0; i < 2; i++)
72
-                dst[j*linesize + i] = v[get_bits1(gb)];
72
+                dst[j * linesize + i] = v[get_bits1(gb)];
73 73
         break;
74 74
     case 3:
75 75
         for (j = 0; j < 2; j++)
76 76
             for (i = 0; i < 2; i++)
77
-                dst[j*linesize + i] = get_bits(gb, 8);
77
+                dst[j * linesize + i] = get_bits(gb, 8);
78 78
     }
79 79
 }
80 80
 
... ...
@@ -89,29 +90,30 @@ static inline void decode4x4(GetBitContext *gb, uint8_t *dst, int linesize)
89 89
     case 1:
90 90
         v[0] = get_bits(gb, 8);
91 91
         for (j = 0; j < 4; j++)
92
-            memset(dst + j*linesize, v[0], 4);
92
+            memset(dst + j * linesize, v[0], 4);
93 93
         break;
94 94
     case 2:
95 95
         v[0] = get_bits(gb, 8);
96 96
         v[1] = get_bits(gb, 8);
97 97
         for (j = 2; j >= 0; j -= 2) {
98 98
             for (i = 0; i < 4; i++)
99
-                dst[j*linesize + i]     = v[get_bits1(gb)];
99
+                dst[j * linesize + i] = v[get_bits1(gb)];
100 100
             for (i = 0; i < 4; i++)
101
-                dst[(j+1)*linesize + i] = v[get_bits1(gb)];
101
+                dst[(j + 1) * linesize + i] = v[get_bits1(gb)];
102 102
         }
103 103
         break;
104 104
     case 3:
105 105
         for (j = 0; j < 4; j += 2)
106 106
             for (i = 0; i < 4; i += 2)
107
-                decode2x2(gb, dst + j*linesize + i, linesize);
107
+                decode2x2(gb, dst + j * linesize + i, linesize);
108 108
     }
109 109
 }
110 110
 
111 111
 /**
112 112
  * Decode 8x8 block
113 113
  */
114
-static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize, DSPContext *dsp)
114
+static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize,
115
+                             DSPContext *dsp)
115 116
 {
116 117
     int i, j, v[2];
117 118
 
... ...
@@ -124,23 +126,22 @@ static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize, DSPC
124 124
         v[0] = get_bits(gb, 8);
125 125
         v[1] = get_bits(gb, 8);
126 126
         for (j = 7; j >= 0; j--)
127
-            for (i = 0; i <  8; i++)
128
-                dst[j*linesize + i] = v[get_bits1(gb)];
127
+            for (i = 0; i < 8; i++)
128
+                dst[j * linesize + i] = v[get_bits1(gb)];
129 129
         break;
130 130
     case 3:
131 131
         for (j = 0; j < 8; j += 4)
132 132
             for (i = 0; i < 8; i += 4)
133
-                decode4x4(gb, dst + j*linesize + i, linesize);
133
+                decode4x4(gb, dst + j * linesize + i, linesize);
134 134
     }
135 135
 }
136 136
 
137
-static int decode_frame(AVCodecContext *avctx,
138
-                        void *data, int *got_frame,
137
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
139 138
                         AVPacket *avpkt)
140 139
 {
141
-    JvContext *s           = avctx->priv_data;
142
-    int buf_size           = avpkt->size;
143
-    const uint8_t *buf     = avpkt->data;
140
+    JvContext *s = avctx->priv_data;
141
+    int buf_size = avpkt->size;
142
+    const uint8_t *buf = avpkt->data;
144 143
     const uint8_t *buf_end = buf + buf_size;
145 144
     int video_size, video_type, i, j, ret;
146 145
 
... ...
@@ -160,7 +161,8 @@ static int decode_frame(AVCodecContext *avctx,
160 160
 
161 161
             for (j = 0; j < avctx->height; j += 8)
162 162
                 for (i = 0; i < avctx->width; i += 8)
163
-                    decode8x8(&gb, s->frame->data[0] + j*s->frame->linesize[0] + i,
163
+                    decode8x8(&gb,
164
+                              s->frame->data[0] + j * s->frame->linesize[0] + i,
164 165
                               s->frame->linesize[0], &s->dsp);
165 166
 
166 167
             buf += video_size;
... ...
@@ -168,10 +170,12 @@ static int decode_frame(AVCodecContext *avctx,
168 168
             if (buf + 1 <= buf_end) {
169 169
                 int v = *buf++;
170 170
                 for (j = 0; j < avctx->height; j++)
171
-                    memset(s->frame->data[0] + j*s->frame->linesize[0], v, avctx->width);
171
+                    memset(s->frame->data[0] + j * s->frame->linesize[0],
172
+                           v, avctx->width);
172 173
             }
173 174
         } else {
174
-            av_log(avctx, AV_LOG_WARNING, "unsupported frame type %i\n", video_type);
175
+            av_log(avctx, AV_LOG_WARNING,
176
+                   "unsupported frame type %i\n", video_type);
175 177
             return AVERROR_INVALIDDATA;
176 178
         }
177 179
     }
... ...
@@ -188,7 +192,7 @@ static int decode_frame(AVCodecContext *avctx,
188 188
         s->frame->key_frame           = 1;
189 189
         s->frame->pict_type           = AV_PICTURE_TYPE_I;
190 190
         s->frame->palette_has_changed = s->palette_has_changed;
191
-        s->palette_has_changed       = 0;
191
+        s->palette_has_changed        = 0;
192 192
         memcpy(s->frame->data[1], s->palette, AVPALETTE_SIZE);
193 193
 
194 194
         if ((ret = av_frame_ref(data, s->frame)) < 0)
... ...
@@ -27,6 +27,7 @@
27 27
 
28 28
 #include "libavutil/channel_layout.h"
29 29
 #include "libavutil/intreadwrite.h"
30
+
30 31
 #include "avformat.h"
31 32
 #include "internal.h"
32 33
 
... ...
@@ -96,17 +97,18 @@ static int read_header(AVFormatContext *s)
96 96
 
97 97
     avio_skip(pb, 4);
98 98
 
99
-    ast->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
100
-    ast->codec->codec_id    = AV_CODEC_ID_PCM_U8;
101
-    ast->codec->codec_tag   = 0; /* no fourcc */
102
-    ast->codec->sample_rate = avio_rl16(pb);
103
-    ast->codec->channels    = 1;
99
+    ast->codec->codec_type     = AVMEDIA_TYPE_AUDIO;
100
+    ast->codec->codec_id       = AV_CODEC_ID_PCM_U8;
101
+    ast->codec->codec_tag      = 0; /* no fourcc */
102
+    ast->codec->sample_rate    = avio_rl16(pb);
103
+    ast->codec->channels       = 1;
104 104
     ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
105 105
     avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
106 106
 
107 107
     avio_skip(pb, 10);
108 108
 
109
-    ast->index_entries = av_malloc(ast->nb_index_entries * sizeof(*ast->index_entries));
109
+    ast->index_entries = av_malloc(ast->nb_index_entries *
110
+                                   sizeof(*ast->index_entries));
110 111
     if (!ast->index_entries)
111 112
         return AVERROR(ENOMEM);
112 113
 
... ...
@@ -115,18 +117,18 @@ static int read_header(AVFormatContext *s)
115 115
         return AVERROR(ENOMEM);
116 116
 
117 117
     offset = 0x68 + ast->nb_index_entries * 16;
118
-    for(i = 0; i < ast->nb_index_entries; i++) {
118
+    for (i = 0; i < ast->nb_index_entries; i++) {
119 119
         AVIndexEntry *e   = ast->index_entries + i;
120 120
         JVFrame      *jvf = jv->frames + i;
121 121
 
122 122
         /* total frame size including audio, video, palette data and padding */
123
-        e->size         = avio_rl32(pb);
124
-        e->timestamp    = i;
125
-        e->pos          = offset;
126
-        offset         += e->size;
123
+        e->size      = avio_rl32(pb);
124
+        e->timestamp = i;
125
+        e->pos       = offset;
126
+        offset      += e->size;
127 127
 
128
-        jvf->audio_size = avio_rl32(pb);
129
-        jvf->video_size = avio_rl32(pb);
128
+        jvf->audio_size   = avio_rl32(pb);
129
+        jvf->video_size   = avio_rl32(pb);
130 130
         jvf->palette_size = avio_r8(pb) ? 768 : 0;
131 131
 
132 132
         if ((jvf->video_size | jvf->audio_size) & ~0xFFFFFF ||
... ...
@@ -137,19 +139,19 @@ static int read_header(AVFormatContext *s)
137 137
                 read_close(s);
138 138
                 return AVERROR_INVALIDDATA;
139 139
             }
140
-            jvf->audio_size =
141
-            jvf->video_size =
140
+            jvf->audio_size   =
141
+            jvf->video_size   =
142 142
             jvf->palette_size = 0;
143 143
         }
144 144
 
145 145
         if (avio_r8(pb))
146
-             av_log(s, AV_LOG_WARNING, "unsupported audio codec\n");
146
+            av_log(s, AV_LOG_WARNING, "unsupported audio codec\n");
147 147
 
148 148
         jvf->video_type = avio_r8(pb);
149 149
         avio_skip(pb, 1);
150 150
 
151 151
         e->timestamp = jvf->audio_size ? audio_pts : AV_NOPTS_VALUE;
152
-        audio_pts += jvf->audio_size;
152
+        audio_pts   += jvf->audio_size;
153 153
 
154 154
         e->flags = jvf->video_type != 1 ? AVINDEX_KEYFRAME : 0;
155 155
     }
... ...
@@ -168,10 +170,10 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
168 168
         const AVIndexEntry *e   = ast->index_entries + jv->pts;
169 169
         const JVFrame      *jvf = jv->frames + jv->pts;
170 170
 
171
-        switch(jv->state) {
171
+        switch (jv->state) {
172 172
         case JV_AUDIO:
173 173
             jv->state++;
174
-            if (jvf->audio_size ) {
174
+            if (jvf->audio_size) {
175 175
                 if (av_get_packet(s->pb, pkt, jvf->audio_size) < 0)
176 176
                     return AVERROR(ENOMEM);
177 177
                 pkt->stream_index = 0;
... ...
@@ -187,7 +189,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
187 187
                     return AVERROR(ENOMEM);
188 188
 
189 189
                 AV_WL32(pkt->data, jvf->video_size);
190
-                pkt->data[4]      = jvf->video_type;
190
+                pkt->data[4] = jvf->video_type;
191 191
                 if (avio_read(pb, pkt->data + JV_PREAMBLE_SIZE, size) < 0)
192 192
                     return AVERROR(EIO);
193 193
 
... ...
@@ -219,10 +221,10 @@ static int read_seek(AVFormatContext *s, int stream_index,
219 219
     AVStream *ast = s->streams[0];
220 220
     int i;
221 221
 
222
-    if (flags & (AVSEEK_FLAG_BYTE|AVSEEK_FLAG_FRAME))
222
+    if (flags & (AVSEEK_FLAG_BYTE | AVSEEK_FLAG_FRAME))
223 223
         return AVERROR(ENOSYS);
224 224
 
225
-    switch(stream_index) {
225
+    switch (stream_index) {
226 226
     case 0:
227 227
         i = av_index_search_timestamp(ast, ts, flags);
228 228
         break;