diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-09-09 12:12:29 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-09-09 12:12:29 +0200 |
commit | b63052839a6b247bd13daab74a869c8f837eda84 (patch) | |
tree | f4960ae9f6110190f83c7bf1533a97ae68ff09fc /libavcodec/dirac_parser.c | |
parent | f7bbe0f414f8cd495798522c61aec750ebdcf913 (diff) | |
parent | 9752d07d33d5370f7819865fbb5e582b982aad06 (diff) |
Merge commit '9752d07d33d5370f7819865fbb5e582b982aad06'
* commit '9752d07d33d5370f7819865fbb5e582b982aad06':
dirac: K&R formatting cosmetics
Conflicts:
libavcodec/dirac.c
libavcodec/dirac_parser.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/dirac_parser.c')
-rw-r--r-- | libavcodec/dirac_parser.c | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/libavcodec/dirac_parser.c b/libavcodec/dirac_parser.c index a2a22ee5b2..4119e3b660 100644 --- a/libavcodec/dirac_parser.c +++ b/libavcodec/dirac_parser.c @@ -31,6 +31,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/mem.h" + #include "parser.h" #define DIRAC_PARSE_INFO_PREFIX 0x42424344 @@ -75,23 +76,22 @@ static int find_frame_end(DiracParseContext *pc, pc->sync_offset = 0; for (; i < buf_size; i++) { if (state == DIRAC_PARSE_INFO_PREFIX) { - if ((buf_size-i) >= pc->header_bytes_needed) { + if ((buf_size - i) >= pc->header_bytes_needed) { pc->state = -1; return i + pc->header_bytes_needed; } else { - pc->header_bytes_needed = 9-(buf_size-i); + pc->header_bytes_needed = 9 - (buf_size - i); break; } } else - state = (state << 8) | buf[i]; + state = (state << 8) | buf[i]; } } pc->state = state; return -1; } -typedef struct DiracParseUnit -{ +typedef struct DiracParseUnit { int next_pu_offset; int prev_pu_offset; uint8_t pu_type; @@ -102,12 +102,12 @@ static int unpack_parse_unit(DiracParseUnit *pu, DiracParseContext *pc, { uint8_t *start = pc->buffer + offset; uint8_t *end = pc->buffer + pc->index; - if (start < pc->buffer || (start+13 > end)) + if (start < pc->buffer || (start + 13 > end)) return 0; pu->pu_type = start[4]; - pu->next_pu_offset = AV_RB32(start+5); - pu->prev_pu_offset = AV_RB32(start+9); + pu->next_pu_offset = AV_RB32(start + 5); + pu->prev_pu_offset = AV_RB32(start + 9); if (pu->pu_type == 0x10 && pu->next_pu_offset == 0) pu->next_pu_offset = 13; @@ -125,7 +125,7 @@ static int dirac_combine_frame(AVCodecParserContext *s, AVCodecContext *avctx, if (pc->overread_index) { memcpy(pc->buffer, pc->buffer + pc->overread_index, pc->index - pc->overread_index); - pc->index -= pc->overread_index; + pc->index -= pc->overread_index; pc->overread_index = 0; if (*buf_size == 0 && pc->buffer[4] == 0x10) { *buf = pc->buffer; @@ -134,13 +134,13 @@ static int dirac_combine_frame(AVCodecParserContext *s, AVCodecContext *avctx, } } - if ( next == -1) { + if (next == -1) { /* Found a possible frame start but not a frame end */ - void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, - pc->index + (*buf_size - - pc->sync_offset)); + void *new_buffer = + av_fast_realloc(pc->buffer, &pc->buffer_size, + pc->index + (*buf_size - pc->sync_offset)); pc->buffer = new_buffer; - memcpy(pc->buffer+pc->index, (*buf + pc->sync_offset), + memcpy(pc->buffer + pc->index, (*buf + pc->sync_offset), *buf_size - pc->sync_offset); pc->index += *buf_size - pc->sync_offset; return -1; @@ -164,8 +164,8 @@ static int dirac_combine_frame(AVCodecParserContext *s, AVCodecContext *avctx, pu.next_pu_offset != pu1.prev_pu_offset || pc->index < pc->dirac_unit_size + 13LL + pu1.prev_pu_offset ) { - pc->index -= 9; - *buf_size = next-9; + pc->index -= 9; + *buf_size = next - 9; pc->header_bytes_needed = 9; return -1; } @@ -179,9 +179,9 @@ static int dirac_combine_frame(AVCodecParserContext *s, AVCodecContext *avctx, pc->dirac_unit_size += pu.next_pu_offset; - if ((pu.pu_type&0x08) != 0x08) { + if ((pu.pu_type & 0x08) != 0x08) { pc->header_bytes_needed = 9; - *buf_size = next; + *buf_size = next; return -1; } @@ -189,24 +189,24 @@ static int dirac_combine_frame(AVCodecParserContext *s, AVCodecContext *avctx, if (parse_timing_info) { uint8_t *cur_pu = pc->buffer + pc->index - 13 - pu1.prev_pu_offset; - int pts = AV_RB32(cur_pu + 13); + int pts = AV_RB32(cur_pu + 13); if (s->last_pts == 0 && s->last_dts == 0) s->dts = pts - 1; else - s->dts = s->last_dts+1; + s->dts = s->last_dts + 1; s->pts = pts; if (!avctx->has_b_frames && (cur_pu[4] & 0x03)) avctx->has_b_frames = 1; } if (avctx->has_b_frames && s->pts == s->dts) - s->pict_type = AV_PICTURE_TYPE_B; + s->pict_type = AV_PICTURE_TYPE_B; /* Finally have a complete Dirac data unit */ *buf = pc->dirac_unit; *buf_size = pc->dirac_unit_size; pc->dirac_unit_size = 0; - pc->overread_index = pc->index-13; + pc->overread_index = pc->index - 13; pc->header_bytes_needed = 9; } return next; @@ -219,27 +219,25 @@ static int dirac_parse(AVCodecParserContext *s, AVCodecContext *avctx, DiracParseContext *pc = s->priv_data; int next; - *poutbuf = NULL; + *poutbuf = NULL; *poutbuf_size = 0; if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { - next = buf_size; - *poutbuf = buf; + next = buf_size; + *poutbuf = buf; *poutbuf_size = buf_size; /* Assume that data has been packetized into an encapsulation unit. */ } else { next = find_frame_end(pc, buf, buf_size); - if (!pc->is_synced && next == -1) { + if (!pc->is_synced && next == -1) /* No frame start found yet. So throw away the entire buffer. */ return buf_size; - } - if (dirac_combine_frame(s, avctx, next, &buf, &buf_size) < 0) { + if (dirac_combine_frame(s, avctx, next, &buf, &buf_size) < 0) return buf_size; - } } - *poutbuf = buf; + *poutbuf = buf; *poutbuf_size = buf_size; return next; } |