Merge commit 'a1c699659d56b76c0bf399307f642c6fd6d28281'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 25 Feb 2014 18:12:30 +0000 (19:12 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 25 Feb 2014 18:12:30 +0000 (19:12 +0100)
* commit 'a1c699659d56b76c0bf399307f642c6fd6d28281':
  parser: K&R formatting cosmetics

Conflicts:
libavcodec/parser.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/parser.c

  #include <stdint.h>
  #include <string.h>
  
- #include "parser.h"
 +#include "libavutil/atomic.h"
  #include "libavutil/mem.h"
  
+ #include "parser.h"
  static AVCodecParser *av_first_parser = NULL;
  
- AVCodecParser* av_parser_next(AVCodecParser *p){
-     if(p) return p->next;
-     else  return av_first_parser;
+ AVCodecParser *av_parser_next(AVCodecParser *p)
+ {
+     if (p)
+         return p->next;
+     else
+         return av_first_parser;
  }
  
  void av_register_codec_parser(AVCodecParser *parser)
@@@ -59,53 -61,57 +63,56 @@@ AVCodecParserContext *av_parser_init(in
              goto found;
      }
      return NULL;
-  found:
+ found:
      s = av_mallocz(sizeof(AVCodecParserContext));
      if (!s)
 -        return NULL;
 +        goto err_out;
      s->parser = parser;
 -    if (parser->priv_data_size) {
 -        s->priv_data = av_mallocz(parser->priv_data_size);
 -        if (!s->priv_data) {
 -            av_free(s);
 -            return NULL;
 -        }
 -    }
 +    s->priv_data = av_mallocz(parser->priv_data_size);
 +    if (!s->priv_data)
 +        goto err_out;
 +    s->fetch_timestamp=1;
 +    s->pict_type = AV_PICTURE_TYPE_I;
      if (parser->parser_init) {
          ret = parser->parser_init(s);
 -        if (ret != 0) {
 -            av_free(s->priv_data);
 -            av_free(s);
 -            return NULL;
 -        }
 +        if (ret != 0)
 +            goto err_out;
      }
-     s->key_frame = -1;
 -    s->fetch_timestamp      = 1;
 -    s->pict_type            = AV_PICTURE_TYPE_I;
+     s->key_frame            = -1;
      s->convergence_duration = 0;
      s->dts_sync_point       = INT_MIN;
      s->dts_ref_dts_delta    = INT_MIN;
      s->pts_dts_delta        = INT_MIN;
      return s;
 +
 +err_out:
 +    if (s)
 +        av_freep(&s->priv_data);
 +    av_free(s);
 +    return NULL;
  }
  
- void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){
+ void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove)
+ {
      int i;
  
-     s->dts= s->pts= AV_NOPTS_VALUE;
-     s->pos= -1;
-     s->offset= 0;
-     for(i = 0; i < AV_PARSER_PTS_NB; i++) {
-         if (   s->cur_offset + off >= s->cur_frame_offset[i]
-             && (s->frame_offset < s->cur_frame_offset[i] ||
-               (!s->frame_offset && !s->next_frame_offset)) // first field/frame
-             && s->cur_frame_end[i]) {
-             s->dts= s->cur_frame_dts[i];
-             s->pts= s->cur_frame_pts[i];
-             s->pos= s->cur_frame_pos[i];
+     s->dts    =
+     s->pts    = AV_NOPTS_VALUE;
+     s->pos    = -1;
+     s->offset = 0;
+     for (i = 0; i < AV_PARSER_PTS_NB; i++) {
+         if (s->cur_offset + off >= s->cur_frame_offset[i] &&
+             (s->frame_offset < s->cur_frame_offset[i] ||
+              (!s->frame_offset && !s->next_frame_offset)) &&
+             s->cur_frame_end[i]) {
+             s->dts    = s->cur_frame_dts[i];
+             s->pts    = s->cur_frame_pts[i];
+             s->pos    = s->cur_frame_pos[i];
              s->offset = s->next_frame_offset - s->cur_frame_offset[i];
-             if(remove)
-                 s->cur_frame_offset[i]= INT64_MAX;
-             if(s->cur_offset + off < s->cur_frame_end[i])
+             if (remove)
+                 s->cur_frame_offset[i] = INT64_MAX;
+             if (s->cur_offset + off < s->cur_frame_end[i])
                  break;
          }
      }
@@@ -218,42 -225,40 +226,44 @@@ int ff_combine_frame(ParseContext *pc, 
      }
  
      /* Copy overread bytes from last frame into buffer. */
-     for(; pc->overread>0; pc->overread--){
-         pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
-     }
+     for (; pc->overread > 0; pc->overread--)
+         pc->buffer[pc->index++] = pc->buffer[pc->overread_index++];
  
      /* flush remaining if EOF */
-     if(!*buf_size && next == END_NOT_FOUND){
-         next= 0;
-     }
+     if (!*buf_size && next == END_NOT_FOUND)
+         next = 0;
  
-     pc->last_index= pc->index;
+     pc->last_index = pc->index;
  
      /* copy into buffer end return */
-     if(next == END_NOT_FOUND){
-         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
+     if (next == END_NOT_FOUND) {
+         void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
+                                            (*buf_size) + pc->index +
+                                            FF_INPUT_BUFFER_PADDING_SIZE);
  
-         if(!new_buffer) {
 -        if (!new_buffer)
++        if (!new_buffer) {
 +            pc->index = 0;
              return AVERROR(ENOMEM);
 +        }
          pc->buffer = new_buffer;
          memcpy(&pc->buffer[pc->index], *buf, *buf_size);
          pc->index += *buf_size;
          return -1;
      }
  
-     *buf_size=
-     pc->overread_index= pc->index + next;
+     *buf_size          =
+     pc->overread_index = pc->index + next;
  
      /* append to buffer */
-     if(pc->index){
-         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
-         if(!new_buffer) {
+     if (pc->index) {
+         void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
+                                            next + pc->index +
+                                            FF_INPUT_BUFFER_PADDING_SIZE);
 -
 -        if (!new_buffer)
++        if (!new_buffer) {
 +            pc->overread_index =
 +            pc->index = 0;
              return AVERROR(ENOMEM);
 +        }
          pc->buffer = new_buffer;
          if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
              memcpy(&pc->buffer[pc->index], *buf,