History

dca: K&R formatting cosmetics

Gabriel Dume committed 12 years ago

Commit 45ff7c91 parent 9030c586 files · +7953 −7981Browse files

Showing the changes to libavcodec/dca_parser.c (1 of 6 files). Show all

Unified · Split

libavcodec/dca_parser.c+19−20
@@ -22,9 +22,9 @@ · 21 unmodified lines
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */23 */
24 24
25#include "parser.h"
26#include "dca.h"25#include "dca.h"
27#include "get_bits.h"26#include "get_bits.h"
27#include "parser.h"
28 28
29typedef struct DCAParseContext {29typedef struct DCAParseContext {
30 ParseContext pc;30 ParseContext pc;
@@ -35,15 +35,15 @@ typedef struct DCAParseContext { · 4 unmodified lines
35} DCAParseContext;35} DCAParseContext;
36 36
37#define IS_MARKER(state, i, buf, buf_size) \37#define IS_MARKER(state, i, buf, buf_size) \
38 ((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 && buf[i+2] == 0x07) \38 ((state == DCA_MARKER_14B_LE && (i < buf_size - 2) && (buf[i + 1] & 0xF0) == 0xF0 && buf[i + 2] == 0x07) || \
39 || (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && (buf[i+2] & 0xF0) == 0xF0) \39 (state == DCA_MARKER_14B_BE && (i < buf_size - 2) && buf[i + 1] == 0x07 && (buf[i + 2] & 0xF0) == 0xF0) || \
40 || state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE)40 state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE)
41 41
42/**42/**
43 * Find the end of the current frame in the bitstream.43 * Find the end of the current frame in the bitstream.
44 * @return the position of the first byte of the next frame, or -144 * @return the position of the first byte of the next frame, or -1
45 */45 */
46static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,46static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf,
47 int buf_size)47 int buf_size)
48{48{
49 int start_found, i;49 int start_found, i;
@@ -51,7 +51,7 @@ static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf, · 1 unmodified line
51 ParseContext *pc = &pc1->pc;51 ParseContext *pc = &pc1->pc;
52 52
53 start_found = pc->frame_start_found;53 start_found = pc->frame_start_found;
54 state = pc->state;54 state = pc->state;
55 55
56 i = 0;56 i = 0;
57 if (!start_found) {57 if (!start_found) {
@@ -63,7 +63,7 @@ static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf, · 5 unmodified lines
63 i++;63 i++;
64 break;64 break;
65 } else if (!pc1->lastmarker) {65 } else if (!pc1->lastmarker) {
66 start_found = 1;66 start_found = 1;
67 pc1->lastmarker = state;67 pc1->lastmarker = state;
68 i++;68 i++;
69 break;69 break;
@@ -78,21 +78,21 @@ static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf, · 8 unmodified lines
78 if (state == DCA_HD_MARKER && !pc1->hd_pos)78 if (state == DCA_HD_MARKER && !pc1->hd_pos)
79 pc1->hd_pos = pc1->size;79 pc1->hd_pos = pc1->size;
80 if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size)) {80 if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size)) {
81 if(pc1->framesize > pc1->size)81 if (pc1->framesize > pc1->size)
82 continue;82 continue;
83 pc->frame_start_found = 0;83 pc->frame_start_found = 0;
84 pc->state = -1;84 pc->state = -1;
85 pc1->size = 0;85 pc1->size = 0;
86 return i - 3;86 return i - 3;
87 }87 }
88 }88 }
89 }89 }
90 pc->frame_start_found = start_found;90 pc->frame_start_found = start_found;
91 pc->state = state;91 pc->state = state;
92 return END_NOT_FOUND;92 return END_NOT_FOUND;
93}93}
94 94
95static av_cold int dca_parse_init(AVCodecParserContext * s)95static av_cold int dca_parse_init(AVCodecParserContext *s)
96{96{
97 DCAParseContext *pc1 = s->priv_data;97 DCAParseContext *pc1 = s->priv_data;
98 98
@@ -126,7 +126,7 @@ static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration, · 27 unmodified lines
126 return AVERROR_INVALIDDATA;126 return AVERROR_INVALIDDATA;
127 127
128 skip_bits(&gb, 6);128 skip_bits(&gb, 6);
129 sr_code = get_bits(&gb, 4);129 sr_code = get_bits(&gb, 4);
130 *sample_rate = avpriv_dca_sample_rates[sr_code];130 *sample_rate = avpriv_dca_sample_rates[sr_code];
131 if (*sample_rate == 0)131 if (*sample_rate == 0)
132 return AVERROR_INVALIDDATA;132 return AVERROR_INVALIDDATA;
@@ -134,10 +134,9 @@ static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration, · 1 unmodified line
134 return 0;134 return 0;
135}135}
136 136
137static int dca_parse(AVCodecParserContext * s,137static int dca_parse(AVCodecParserContext *s, AVCodecContext *avctx,
138 AVCodecContext * avctx,138 const uint8_t **poutbuf, int *poutbuf_size,
139 const uint8_t ** poutbuf, int *poutbuf_size,139 const uint8_t *buf, int buf_size)
140 const uint8_t * buf, int buf_size)
141{140{
142 DCAParseContext *pc1 = s->priv_data;141 DCAParseContext *pc1 = s->priv_data;
143 ParseContext *pc = &pc1->pc;142 ParseContext *pc = &pc1->pc;
@@ -149,7 +148,7 @@ static int dca_parse(AVCodecParserContext * s, · 5 unmodified lines
149 next = dca_find_frame_end(pc1, buf, buf_size);148 next = dca_find_frame_end(pc1, buf, buf_size);
150 149
151 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {150 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
152 *poutbuf = NULL;151 *poutbuf = NULL;
153 *poutbuf_size = 0;152 *poutbuf_size = 0;
154 return buf_size;153 return buf_size;
155 }154 }
@@ -157,12 +156,12 @@ static int dca_parse(AVCodecParserContext * s, · 1 unmodified line
157 156
158 /* read the duration and sample rate from the frame header */157 /* read the duration and sample rate from the frame header */
159 if (!dca_parse_params(buf, buf_size, &duration, &sample_rate, &pc1->framesize)) {158 if (!dca_parse_params(buf, buf_size, &duration, &sample_rate, &pc1->framesize)) {
160 s->duration = duration;159 s->duration = duration;
161 avctx->sample_rate = sample_rate;160 avctx->sample_rate = sample_rate;
162 } else161 } else
163 s->duration = 0;162 s->duration = 0;
164 163
165 *poutbuf = buf;164 *poutbuf = buf;
166 *poutbuf_size = buf_size;165 *poutbuf_size = buf_size;
167 return next;166 return next;
168}167}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t