Merge commit '5d21ca45591bb1c1d2265f8ed972d18c563f145e'
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 16 Jun 2013 20:40:43 +0000 (22:40 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 16 Jun 2013 20:40:43 +0000 (22:40 +0200)
* commit '5d21ca45591bb1c1d2265f8ed972d18c563f145e':
  h264_mp4toannexb_bsf: K&R formatting cosmetics

Conflicts:
libavcodec/h264_mp4toannexb_bsf.c

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

@@@ -58,16 -60,15 +60,17 @@@ static int alloc_and_copy(uint8_t **pou
  
  static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
                                     AVCodecContext *avctx, const char *args,
-                                    uint8_t  **poutbuf, int *poutbuf_size,
-                                    const uint8_t *buf, int      buf_size,
-                                    int keyframe) {
+                                    uint8_t **poutbuf, int *poutbuf_size,
+                                    const uint8_t *buf, int buf_size,
+                                    int keyframe)
+ {
      H264BSFContext *ctx = bsfc->priv_data;
 +    int i;
      uint8_t unit_type;
      int32_t nal_size;
-     uint32_t cumul_size = 0;
+     uint32_t cumul_size    = 0;
      const uint8_t *buf_end = buf + buf_size;
 +    int ret = AVERROR(EINVAL);
  
      /* nothing to filter */
      if (!avctx->extradata || avctx->extradata_size < 6) {
                  return AVERROR(ENOMEM);
              }
              out = tmp;
-             memcpy(out+total_size-unit_size-4, nalu_header, 4);
-             memcpy(out+total_size-unit_size,   extradata+2, unit_size);
-             extradata += 2+unit_size;
+             memcpy(out + total_size - unit_size - 4, nalu_header, 4);
+             memcpy(out + total_size - unit_size, extradata + 2, unit_size);
+             extradata += 2 + unit_size;
 -
 +pps:
              if (!unit_nb && !sps_done++) {
                  unit_nb = *extradata++; /* number of pps unit(s) */
                  if (unit_nb)
      }
  
      *poutbuf_size = 0;
-     *poutbuf = NULL;
+     *poutbuf      = NULL;
      do {
 +        ret= AVERROR(EINVAL);
          if (buf + ctx->length_size > buf_end)
              goto fail;
  
 -        if (ctx->length_size == 1) {
 -            nal_size = buf[0];
 -        } else if (ctx->length_size == 2) {
 -            nal_size = AV_RB16(buf);
 -        } else
 -            nal_size = AV_RB32(buf);
 +        for (nal_size = 0, i = 0; i<ctx->length_size; i++)
 +            nal_size = (nal_size << 8) | buf[i];
  
-         buf += ctx->length_size;
+         buf      += ctx->length_size;
          unit_type = *buf & 0x1f;
  
          if (buf + nal_size > buf_end || nal_size < 0)
                  goto fail;
              ctx->first_idr = 0;
          } else {
 -            if (alloc_and_copy(poutbuf, poutbuf_size,
 -                               NULL, 0, buf, nal_size) < 0)
 +            if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
-                                NULL, 0,
-                                buf, nal_size)) < 0)
++                               NULL, 0, buf, nal_size)) < 0)
                  goto fail;
              if (!ctx->first_idr && unit_type == 1)
                  ctx->first_idr = 1;