comparison ac3dec.c @ 2979:bfabfdf9ce55 libavcodec

COSMETICS: tabs --> spaces, some prettyprinting
author diego
date Thu, 22 Dec 2005 01:10:11 +0000
parents ef2149182f1c
children 0b546eab515d
comparison
equal deleted inserted replaced
2978:403183bbb505 2979:bfabfdf9ce55
52 52
53 /**** the following two functions comes from ac3dec */ 53 /**** the following two functions comes from ac3dec */
54 static inline int blah (int32_t i) 54 static inline int blah (int32_t i)
55 { 55 {
56 if (i > 0x43c07fff) 56 if (i > 0x43c07fff)
57 return 32767; 57 return 32767;
58 else if (i < 0x43bf8000) 58 else if (i < 0x43bf8000)
59 return -32768; 59 return -32768;
60 else 60 else
61 return i - 0x43c00000; 61 return i - 0x43c00000;
62 } 62 }
63 63
64 static inline void float_to_int (float * _f, int16_t * s16, int nchannels) 64 static inline void float_to_int (float * _f, int16_t * s16, int nchannels)
65 { 65 {
66 int i, j, c; 66 int i, j, c;
67 int32_t * f = (int32_t *) _f; // XXX assumes IEEE float format 67 int32_t * f = (int32_t *) _f; // XXX assumes IEEE float format
68 68
69 j = 0; 69 j = 0;
70 nchannels *= 256; 70 nchannels *= 256;
71 for (i = 0; i < 256; i++) { 71 for (i = 0; i < 256; i++) {
72 for (c = 0; c < nchannels; c += 256) 72 for (c = 0; c < nchannels; c += 256)
73 s16[j++] = blah (f[i + c]); 73 s16[j++] = blah (f[i + c]);
74 } 74 }
75 } 75 }
76 76
77 /**** end */ 77 /**** end */
78 78
87 int flags, i, len; 87 int flags, i, len;
88 int sample_rate, bit_rate; 88 int sample_rate, bit_rate;
89 short *out_samples = data; 89 short *out_samples = data;
90 float level; 90 float level;
91 static const int ac3_channels[8] = { 91 static const int ac3_channels[8] = {
92 2, 1, 2, 3, 3, 4, 4, 5 92 2, 1, 2, 3, 3, 4, 4, 5
93 }; 93 };
94 94
95 buf_ptr = buf; 95 buf_ptr = buf;
96 while (buf_size > 0) { 96 while (buf_size > 0) {
97 len = s->inbuf_ptr - s->inbuf; 97 len = s->inbuf_ptr - s->inbuf;
109 if (len == 0) { 109 if (len == 0) {
110 /* no sync found : move by one byte (inefficient, but simple!) */ 110 /* no sync found : move by one byte (inefficient, but simple!) */
111 memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1); 111 memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1);
112 s->inbuf_ptr--; 112 s->inbuf_ptr--;
113 } else { 113 } else {
114 s->frame_size = len; 114 s->frame_size = len;
115 /* update codec info */ 115 /* update codec info */
116 avctx->sample_rate = sample_rate; 116 avctx->sample_rate = sample_rate;
117 s->channels = ac3_channels[s->flags & 7]; 117 s->channels = ac3_channels[s->flags & 7];
118 if (s->flags & AC3_LFE) 118 if (s->flags & AC3_LFE)
119 s->channels++; 119 s->channels++;
120 if (avctx->channels == 0) 120 if (avctx->channels == 0)
121 /* No specific number of channel requested */ 121 /* No specific number of channel requested */
122 avctx->channels = s->channels; 122 avctx->channels = s->channels;
123 else if (s->channels < avctx->channels) { 123 else if (s->channels < avctx->channels) {
124 av_log( avctx, AV_LOG_INFO, "ac3dec: AC3 Source channels are less than specified: output to %d channels.. (frmsize: %d)\n", s->channels, len); 124 av_log( avctx, AV_LOG_INFO, "ac3dec: AC3 Source channels are less than specified: output to %d channels.. (frmsize: %d)\n", s->channels, len);
125 avctx->channels = s->channels; 125 avctx->channels = s->channels;
126 } 126 }
127 avctx->bit_rate = bit_rate; 127 avctx->bit_rate = bit_rate;
128 } 128 }
129 } 129 }
130 } else if (len < s->frame_size) { 130 } else if (len < s->frame_size) {
131 len = s->frame_size - len; 131 len = s->frame_size - len;
132 if (len > buf_size) 132 if (len > buf_size)