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