Mercurial > libavcodec.hg
annotate dca_parser.c @ 9472:05663d250d5b libavcodec
Remove unused variable from wma_decode_block() found by CSA.
author | michael |
---|---|
date | Fri, 17 Apr 2009 15:35:32 +0000 |
parents | e9d9d946f213 |
children | 7dd2a45249a9 |
rev | line source |
---|---|
4599 | 1 /* |
4899 | 2 * DCA parser |
4599 | 3 * Copyright (C) 2004 Gildas Bazin |
4 * Copyright (C) 2004 Benjamin Zores | |
5 * Copyright (C) 2006 Benjamin Larsson | |
6 * Copyright (C) 2007 Konstantin Shishkov | |
7 * | |
8 * This file is part of FFmpeg. | |
9 * | |
10 * FFmpeg is free software; you can redistribute it and/or | |
11 * modify it under the terms of the GNU Lesser General Public | |
12 * License as published by the Free Software Foundation; either | |
13 * version 2.1 of the License, or (at your option) any later version. | |
14 * | |
15 * FFmpeg is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 * Lesser General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU Lesser General Public | |
21 * License along with FFmpeg; if not, write to the Free Software | |
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
23 */ | |
24 | |
25 /** | |
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
8226
diff
changeset
|
26 * @file libavcodec/dca_parser.c |
4599 | 27 */ |
28 | |
29 #include "parser.h" | |
4899 | 30 #include "dca.h" |
4599 | 31 |
32 typedef struct DCAParseContext { | |
33 ParseContext pc; | |
34 uint32_t lastmarker; | |
6598 | 35 int size; |
36 int framesize; | |
8226
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
6598
diff
changeset
|
37 int hd_pos; |
4599 | 38 } DCAParseContext; |
39 | |
40 #define IS_MARKER(state, i, buf, buf_size) \ | |
41 ((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 && buf[i+2] == 0x07) \ | |
42 || (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && (buf[i+2] & 0xF0) == 0xF0) \ | |
43 || state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE) | |
44 | |
45 /** | |
46 * finds the end of the current frame in the bitstream. | |
47 * @return the position of the first byte of the next frame, or -1 | |
48 */ | |
49 static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf, | |
50 int buf_size) | |
51 { | |
52 int start_found, i; | |
53 uint32_t state; | |
54 ParseContext *pc = &pc1->pc; | |
55 | |
56 start_found = pc->frame_start_found; | |
57 state = pc->state; | |
58 | |
59 i = 0; | |
60 if (!start_found) { | |
61 for (i = 0; i < buf_size; i++) { | |
62 state = (state << 8) | buf[i]; | |
63 if (IS_MARKER(state, i, buf, buf_size)) { | |
64 if (pc1->lastmarker && state == pc1->lastmarker) { | |
65 start_found = 1; | |
66 break; | |
67 } else if (!pc1->lastmarker) { | |
68 start_found = 1; | |
69 pc1->lastmarker = state; | |
70 break; | |
71 } | |
72 } | |
73 } | |
74 } | |
75 if (start_found) { | |
76 for (; i < buf_size; i++) { | |
6598 | 77 pc1->size++; |
4599 | 78 state = (state << 8) | buf[i]; |
8226
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
6598
diff
changeset
|
79 if (state == DCA_HD_MARKER && !pc1->hd_pos) |
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
6598
diff
changeset
|
80 pc1->hd_pos = pc1->size; |
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
6598
diff
changeset
|
81 if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size)) { |
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
6598
diff
changeset
|
82 if(pc1->framesize > pc1->size) |
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
6598
diff
changeset
|
83 continue; |
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
6598
diff
changeset
|
84 if(!pc1->framesize){ |
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
6598
diff
changeset
|
85 pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size; |
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
6598
diff
changeset
|
86 } |
4599 | 87 pc->frame_start_found = 0; |
88 pc->state = -1; | |
6598 | 89 pc1->size = 0; |
4599 | 90 return i - 3; |
91 } | |
92 } | |
93 } | |
94 pc->frame_start_found = start_found; | |
95 pc->state = state; | |
96 return END_NOT_FOUND; | |
97 } | |
98 | |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
4931
diff
changeset
|
99 static av_cold int dca_parse_init(AVCodecParserContext * s) |
4599 | 100 { |
101 DCAParseContext *pc1 = s->priv_data; | |
102 | |
103 pc1->lastmarker = 0; | |
104 return 0; | |
105 } | |
106 | |
107 static int dca_parse(AVCodecParserContext * s, | |
108 AVCodecContext * avctx, | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4919
diff
changeset
|
109 const uint8_t ** poutbuf, int *poutbuf_size, |
4599 | 110 const uint8_t * buf, int buf_size) |
111 { | |
112 DCAParseContext *pc1 = s->priv_data; | |
113 ParseContext *pc = &pc1->pc; | |
114 int next; | |
115 | |
116 if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { | |
117 next = buf_size; | |
118 } else { | |
119 next = dca_find_frame_end(pc1, buf, buf_size); | |
120 | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4919
diff
changeset
|
121 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { |
4599 | 122 *poutbuf = NULL; |
123 *poutbuf_size = 0; | |
124 return buf_size; | |
125 } | |
126 } | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4919
diff
changeset
|
127 *poutbuf = buf; |
4599 | 128 *poutbuf_size = buf_size; |
129 return next; | |
130 } | |
131 | |
132 AVCodecParser dca_parser = { | |
133 {CODEC_ID_DTS}, | |
134 sizeof(DCAParseContext), | |
135 dca_parse_init, | |
136 dca_parse, | |
137 ff_parse_close, | |
138 }; |