Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 1 Apr 2014 22:25:21 +0000 (00:25 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 1 Apr 2014 22:25:21 +0000 (00:25 +0200)
* qatar/master:
  VP3: K&R formatting cosmetics

Conflicts:
libavcodec/vp3.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/vp3.c
libavcodec/vp3_parser.c
libavcodec/vp3data.h
libavcodec/vp3dsp.c

@@@ -76,49 -77,43 +77,47 @@@ typedef struct Vp3Fragment 
  /* special internal mode */
  #define MODE_COPY             8
  
 +static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb);
 +static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb);
 +
 +
  /* There are 6 preset schemes, plus a free-form scheme */
- static const int ModeAlphabet[6][CODING_MODE_COUNT] =
- {
+ static const int ModeAlphabet[6][CODING_MODE_COUNT] = {
      /* scheme 1: Last motion vector dominates */
-     {    MODE_INTER_LAST_MV,    MODE_INTER_PRIOR_LAST,
-          MODE_INTER_PLUS_MV,    MODE_INTER_NO_MV,
-          MODE_INTRA,            MODE_USING_GOLDEN,
-          MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
+     { MODE_INTER_LAST_MV,    MODE_INTER_PRIOR_LAST,
+       MODE_INTER_PLUS_MV,    MODE_INTER_NO_MV,
+       MODE_INTRA,            MODE_USING_GOLDEN,
+       MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
  
      /* scheme 2 */
-     {    MODE_INTER_LAST_MV,    MODE_INTER_PRIOR_LAST,
-          MODE_INTER_NO_MV,      MODE_INTER_PLUS_MV,
-          MODE_INTRA,            MODE_USING_GOLDEN,
-          MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
+     { MODE_INTER_LAST_MV,    MODE_INTER_PRIOR_LAST,
+       MODE_INTER_NO_MV,      MODE_INTER_PLUS_MV,
+       MODE_INTRA,            MODE_USING_GOLDEN,
+       MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
  
      /* scheme 3 */
-     {    MODE_INTER_LAST_MV,    MODE_INTER_PLUS_MV,
-          MODE_INTER_PRIOR_LAST, MODE_INTER_NO_MV,
-          MODE_INTRA,            MODE_USING_GOLDEN,
-          MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
+     { MODE_INTER_LAST_MV,    MODE_INTER_PLUS_MV,
+       MODE_INTER_PRIOR_LAST, MODE_INTER_NO_MV,
+       MODE_INTRA,            MODE_USING_GOLDEN,
+       MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
  
      /* scheme 4 */
-     {    MODE_INTER_LAST_MV,    MODE_INTER_PLUS_MV,
-          MODE_INTER_NO_MV,      MODE_INTER_PRIOR_LAST,
-          MODE_INTRA,            MODE_USING_GOLDEN,
-          MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
+     { MODE_INTER_LAST_MV,    MODE_INTER_PLUS_MV,
+       MODE_INTER_NO_MV,      MODE_INTER_PRIOR_LAST,
+       MODE_INTRA,            MODE_USING_GOLDEN,
+       MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
  
      /* scheme 5: No motion vector dominates */
-     {    MODE_INTER_NO_MV,      MODE_INTER_LAST_MV,
-          MODE_INTER_PRIOR_LAST, MODE_INTER_PLUS_MV,
-          MODE_INTRA,            MODE_USING_GOLDEN,
-          MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
+     { MODE_INTER_NO_MV,      MODE_INTER_LAST_MV,
+       MODE_INTER_PRIOR_LAST, MODE_INTER_PLUS_MV,
+       MODE_INTRA,            MODE_USING_GOLDEN,
+       MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
  
      /* scheme 6 */
-     {    MODE_INTER_NO_MV,      MODE_USING_GOLDEN,
-          MODE_INTER_LAST_MV,    MODE_INTER_PRIOR_LAST,
-          MODE_INTER_PLUS_MV,    MODE_INTRA,
-          MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
+     { MODE_INTER_NO_MV,      MODE_USING_GOLDEN,
+       MODE_INTER_LAST_MV,    MODE_INTER_PRIOR_LAST,
+       MODE_INTER_PLUS_MV,    MODE_INTRA,
+       MODE_GOLDEN_MV,        MODE_INTER_FOURMV },
  };
  
  static const uint8_t hilbert_offset[16][2] = {
@@@ -1512,101 -1521,112 +1527,106 @@@ static void render_slice(Vp3DecodeConte
                      if (x >= fragment_width || y >= fragment_height)
                          continue;
  
-                 first_pixel = 8*y*stride + 8*x;
-                 if (do_await && s->all_fragments[i].coding_method != MODE_INTRA)
-                     await_reference_row(s, &s->all_fragments[i], motion_val[fragment][1], (16*y) >> s->chroma_y_shift);
-                 /* transform if this block was coded */
-                 if (s->all_fragments[i].coding_method != MODE_COPY) {
-                     if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) ||
-                         (s->all_fragments[i].coding_method == MODE_GOLDEN_MV))
-                         motion_source= golden_plane;
-                     else
-                         motion_source= last_plane;
-                     motion_source += first_pixel;
-                     motion_halfpel_index = 0;
-                     /* sort out the motion vector if this fragment is coded
-                      * using a motion vector method */
-                     if ((s->all_fragments[i].coding_method > MODE_INTRA) &&
-                         (s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) {
-                         int src_x, src_y;
-                         motion_x = motion_val[fragment][0];
-                         motion_y = motion_val[fragment][1];
-                         src_x= (motion_x>>1) + 8*x;
-                         src_y= (motion_y>>1) + 8*y;
-                         motion_halfpel_index = motion_x & 0x01;
-                         motion_source += (motion_x >> 1);
-                         motion_halfpel_index |= (motion_y & 0x01) << 1;
-                         motion_source += ((motion_y >> 1) * stride);
-                         if(src_x<0 || src_y<0 || src_x + 9 >= plane_width || src_y + 9 >= plane_height){
-                             uint8_t *temp= s->edge_emu_buffer;
-                             if(stride<0) temp -= 8*stride;
-                             s->vdsp.emulated_edge_mc(temp, motion_source,
-                                                      stride, stride,
-                                                      9, 9, src_x, src_y,
-                                                      plane_width,
-                                                      plane_height);
-                             motion_source= temp;
+                     first_pixel = 8 * y * stride + 8 * x;
+                     if (do_await &&
+                         s->all_fragments[i].coding_method != MODE_INTRA)
+                         await_reference_row(s, &s->all_fragments[i],
+                                             motion_val[fragment][1],
+                                             (16 * y) >> s->chroma_y_shift);
+                     /* transform if this block was coded */
+                     if (s->all_fragments[i].coding_method != MODE_COPY) {
+                         if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) ||
+                             (s->all_fragments[i].coding_method == MODE_GOLDEN_MV))
+                             motion_source = golden_plane;
+                         else
+                             motion_source = last_plane;
+                         motion_source       += first_pixel;
+                         motion_halfpel_index = 0;
+                         /* sort out the motion vector if this fragment is coded
+                          * using a motion vector method */
+                         if ((s->all_fragments[i].coding_method > MODE_INTRA) &&
+                             (s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) {
+                             int src_x, src_y;
+                             motion_x = motion_val[fragment][0];
+                             motion_y = motion_val[fragment][1];
+                             src_x = (motion_x >> 1) + 8 * x;
+                             src_y = (motion_y >> 1) + 8 * y;
+                             motion_halfpel_index = motion_x & 0x01;
+                             motion_source       += (motion_x >> 1);
+                             motion_halfpel_index |= (motion_y & 0x01) << 1;
+                             motion_source        += ((motion_y >> 1) * stride);
+                             if (src_x < 0 || src_y < 0 ||
+                                 src_x + 9 >= plane_width ||
+                                 src_y + 9 >= plane_height) {
+                                 uint8_t *temp = s->edge_emu_buffer;
+                                 if (stride < 0)
+                                     temp -= 8 * stride;
+                                 s->vdsp.emulated_edge_mc(temp, motion_source,
+                                                          stride, stride,
+                                                          9, 9, src_x, src_y,
+                                                          plane_width,
+                                                          plane_height);
+                                 motion_source = temp;
+                             }
                          }
-                     }
  
-                     /* first, take care of copying a block from either the
-                      * previous or the golden frame */
-                     if (s->all_fragments[i].coding_method != MODE_INTRA) {
-                         /* Note, it is possible to implement all MC cases with
-                            put_no_rnd_pixels_l2 which would look more like the
-                            VP3 source but this would be slower as
-                            put_no_rnd_pixels_tab is better optimzed */
-                         if(motion_halfpel_index != 3){
-                             s->hdsp.put_no_rnd_pixels_tab[1][motion_halfpel_index](
-                                 output_plane + first_pixel,
-                                 motion_source, stride, 8);
-                         }else{
-                             int d= (motion_x ^ motion_y)>>31; // d is 0 if motion_x and _y have the same sign, else -1
-                             s->vp3dsp.put_no_rnd_pixels_l2(
-                                 output_plane + first_pixel,
-                                 motion_source - d,
-                                 motion_source + stride + 1 + d,
-                                 stride, 8);
+                         /* first, take care of copying a block from either the
+                          * previous or the golden frame */
+                         if (s->all_fragments[i].coding_method != MODE_INTRA) {
+                             /* Note, it is possible to implement all MC cases
+                              * with put_no_rnd_pixels_l2 which would look more
+                              * like the VP3 source but this would be slower as
+                              * put_no_rnd_pixels_tab is better optimzed */
+                             if (motion_halfpel_index != 3) {
+                                 s->hdsp.put_no_rnd_pixels_tab[1][motion_halfpel_index](
+                                     output_plane + first_pixel,
+                                     motion_source, stride, 8);
+                             } else {
+                                 /* d is 0 if motion_x and _y have the same sign,
+                                  * else -1 */
+                                 int d = (motion_x ^ motion_y) >> 31;
+                                 s->vp3dsp.put_no_rnd_pixels_l2(output_plane + first_pixel,
+                                                                motion_source - d,
+                                                                motion_source + stride + 1 + d,
+                                                                stride, 8);
+                             }
                          }
-                     }
  
-                     /* invert DCT and place (or add) in final output */
+                         /* invert DCT and place (or add) in final output */
  
-                     if (s->all_fragments[i].coding_method == MODE_INTRA) {
-                         vp3_dequant(s, s->all_fragments + i, plane, 0, block);
-                         s->vp3dsp.idct_put(
-                             output_plane + first_pixel,
-                             stride,
-                             block);
-                     } else {
-                         if (vp3_dequant(s, s->all_fragments + i, plane, 1, block)) {
-                         s->vp3dsp.idct_add(
-                             output_plane + first_pixel,
-                             stride,
-                             block);
+                         if (s->all_fragments[i].coding_method == MODE_INTRA) {
 -                            int index;
 -                            index = vp3_dequant(s, s->all_fragments + i,
 -                                                plane, 0, block);
 -                            if (index > 63)
 -                                continue;
++                            vp3_dequant(s, s->all_fragments + i,
++                                        plane, 0, block);
+                             s->vp3dsp.idct_put(output_plane + first_pixel,
+                                                stride,
+                                                block);
                          } else {
-                             s->vp3dsp.idct_dc_add(output_plane + first_pixel, stride, block);
 -                            int index = vp3_dequant(s, s->all_fragments + i,
 -                                                    plane, 1, block);
 -                            if (index > 63)
 -                                continue;
 -                            if (index > 0) {
++                            if (vp3_dequant(s, s->all_fragments + i,
++                                            plane, 1, block)) {
+                                 s->vp3dsp.idct_add(output_plane + first_pixel,
+                                                    stride,
+                                                    block);
+                             } else {
+                                 s->vp3dsp.idct_dc_add(output_plane + first_pixel,
+                                                       stride, block);
+                             }
                          }
+                     } else {
+                         /* copy directly from the previous frame */
+                         s->hdsp.put_pixels_tab[1][0](
+                             output_plane + first_pixel,
+                             last_plane + first_pixel,
+                             stride, 8);
                      }
-                 } else {
-                     /* copy directly from the previous frame */
-                     s->hdsp.put_pixels_tab[1][0](
-                         output_plane + first_pixel,
-                         last_plane + first_pixel,
-                         stride, 8);
-                 }
                  }
              }
  
@@@ -1636,20 -1658,24 +1658,24 @@@ static av_cold int allocate_tables(AVCo
      y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
      c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
  
 -    s->superblock_coding = av_malloc(s->superblock_count);
 -    s->all_fragments     = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
 +    s->superblock_coding = av_mallocz(s->superblock_count);
-     s->all_fragments = av_mallocz(s->fragment_count * sizeof(Vp3Fragment));
++    s->all_fragments     = av_mallocz(s->fragment_count * sizeof(Vp3Fragment));
 -    s->coded_fragment_list[0] = av_malloc(s->fragment_count * sizeof(int));
 +    s->coded_fragment_list[0] = av_mallocz(s->fragment_count * sizeof(int));
-     s->dct_tokens_base = av_mallocz(64*s->fragment_count * sizeof(*s->dct_tokens_base));
 -    s->dct_tokens_base = av_malloc(64 * s->fragment_count *
 -                                   sizeof(*s->dct_tokens_base));
 -    s->motion_val[0] = av_malloc(y_fragment_count * sizeof(*s->motion_val[0]));
 -    s->motion_val[1] = av_malloc(c_fragment_count * sizeof(*s->motion_val[1]));
++    s->dct_tokens_base = av_mallocz(64 * s->fragment_count *
++                                    sizeof(*s->dct_tokens_base));
 +    s->motion_val[0] = av_mallocz(y_fragment_count * sizeof(*s->motion_val[0]));
 +    s->motion_val[1] = av_mallocz(c_fragment_count * sizeof(*s->motion_val[1]));
  
      /* work out the block mapping tables */
 -    s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
 -    s->macroblock_coding    = av_malloc(s->macroblock_count + 1);
 +    s->superblock_fragments = av_mallocz(s->superblock_count * 16 * sizeof(int));
-     s->macroblock_coding = av_mallocz(s->macroblock_count + 1);
++    s->macroblock_coding    = av_mallocz(s->macroblock_count + 1);
  
-     if (!s->superblock_coding || !s->all_fragments || !s->dct_tokens_base ||
-         !s->coded_fragment_list[0] || !s->superblock_fragments || !s->macroblock_coding ||
-         !s->motion_val[0] || !s->motion_val[1]) {
+     if (!s->superblock_coding    || !s->all_fragments          ||
+         !s->dct_tokens_base      || !s->coded_fragment_list[0] ||
+         !s->superblock_fragments || !s->macroblock_coding      ||
+         !s->motion_val[0]        || !s->motion_val[1]) {
          vp3_decode_end(avctx);
          return -1;
      }
@@@ -1694,10 -1720,10 +1720,10 @@@ static av_cold int vp3_decode_init(AVCo
      else
          s->version = 1;
  
-     s->avctx = avctx;
-     s->width = FFALIGN(avctx->width, 16);
+     s->avctx  = avctx;
+     s->width  = FFALIGN(avctx->width, 16);
      s->height = FFALIGN(avctx->height, 16);
 -    if (avctx->pix_fmt == AV_PIX_FMT_NONE)
 +    if (avctx->codec_id != AV_CODEC_ID_THEORA)
          avctx->pix_fmt = AV_PIX_FMT_YUV420P;
      avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
      ff_hpeldsp_init(&s->hdsp, avctx->flags | CODEC_FLAG_BITEXACT);
      for (i = 0; i < 3; i++)
          s->qps[i] = -1;
  
 -    av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift,
 -                                     &s->chroma_y_shift);
 +    avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
  
-     s->y_superblock_width = (s->width + 31) / 32;
+     s->y_superblock_width  = (s->width  + 31) / 32;
      s->y_superblock_height = (s->height + 31) / 32;
-     s->y_superblock_count = s->y_superblock_width * s->y_superblock_height;
+     s->y_superblock_count  = s->y_superblock_width * s->y_superblock_height;
  
      /* work out the dimensions for the C planes */
-     c_width = s->width >> s->chroma_x_shift;
-     c_height = s->height >> s->chroma_y_shift;
-     s->c_superblock_width = (c_width + 31) / 32;
+     c_width                = s->width >> s->chroma_x_shift;
+     c_height               = s->height >> s->chroma_y_shift;
+     s->c_superblock_width  = (c_width  + 31) / 32;
      s->c_superblock_height = (c_height + 31) / 32;
-     s->c_superblock_count = s->c_superblock_width * s->c_superblock_height;
+     s->c_superblock_count  = s->c_superblock_width * s->c_superblock_height;
  
-     s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);
+     s->superblock_count   = s->y_superblock_count + (s->c_superblock_count * 2);
      s->u_superblock_start = s->y_superblock_count;
      s->v_superblock_start = s->u_superblock_start + s->c_superblock_count;
  
@@@ -1962,44 -1989,13 +1988,44 @@@ static int vp3_decode_frame(AVCodecCont
  
      init_get_bits(&gb, buf, buf_size * 8);
  
-     if (s->theora && get_bits1(&gb))
-     {
 +#if CONFIG_THEORA_DECODER
-         av_log(avctx, AV_LOG_ERROR, "Header packet passed to frame decoder, skipping\n");
+     if (s->theora && get_bits1(&gb)) {
 +        int type = get_bits(&gb, 7);
 +        skip_bits_long(&gb, 6*8); /* "theora" */
 +
 +        if (s->avctx->active_thread_type&FF_THREAD_FRAME) {
 +            av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n");
 +            return AVERROR_PATCHWELCOME;
 +        }
 +        if (type == 0) {
 +            vp3_decode_end(avctx);
 +            ret = theora_decode_header(avctx, &gb);
 +
 +            if (ret < 0) {
 +                vp3_decode_end(avctx);
 +            } else
 +                ret = vp3_decode_init(avctx);
 +            return ret;
 +        } else if (type == 2) {
 +            ret = theora_decode_tables(avctx, &gb);
 +            if (ret < 0) {
 +                vp3_decode_end(avctx);
 +            } else
 +                ret = vp3_decode_init(avctx);
 +            return ret;
 +        }
 +
+         av_log(avctx, AV_LOG_ERROR,
+                "Header packet passed to frame decoder, skipping\n");
          return -1;
      }
 +#endif
  
      s->keyframe = !get_bits1(&gb);
 +    if (!s->all_fragments) {
 +        av_log(avctx, AV_LOG_ERROR, "Data packet without prior valid headers\n");
 +        return -1;
 +    }
      if (!s->theora)
          skip_bits(&gb, 1);
      for (i = 0; i < 3; i++)
      if (avctx->skip_frame >= AVDISCARD_NONKEY && !s->keyframe)
          return buf_size;
  
-     s->current_frame.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
+     s->current_frame.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I
+                                                 : AV_PICTURE_TYPE_P;
 -    if (ff_thread_get_buffer(avctx, &s->current_frame, AV_GET_BUFFER_FLAG_REF) < 0) {
 -        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 +    s->current_frame.f->key_frame = s->keyframe;
 +    if (ff_thread_get_buffer(avctx, &s->current_frame, AV_GET_BUFFER_FLAG_REF) < 0)
          goto error;
 -    }
  
      if (!s->edge_emu_buffer)
-         s->edge_emu_buffer = av_malloc(9*FFABS(s->current_frame.f->linesize[0]));
+         s->edge_emu_buffer = av_malloc(9 * FFABS(s->current_frame.f->linesize[0]));
  
      if (s->keyframe) {
-         if (!s->theora)
-         {
+         if (!s->theora) {
              skip_bits(&gb, 4); /* width code */
              skip_bits(&gb, 4); /* height code */
-             if (s->version)
-             {
+             if (s->version) {
                  s->version = get_bits(&gb, 5);
                  if (avctx->frame_number == 0)
-                     av_log(s->avctx, AV_LOG_DEBUG, "VP version: %d\n", s->version);
+                     av_log(s->avctx, AV_LOG_DEBUG,
+                            "VP version: %d\n", s->version);
              }
          }
-         if (s->version || s->theora)
-         {
-                 if (get_bits1(&gb))
-                     av_log(s->avctx, AV_LOG_ERROR, "Warning, unsupported keyframe coding type?!\n");
+         if (s->version || s->theora) {
+             if (get_bits1(&gb))
+                 av_log(s->avctx, AV_LOG_ERROR,
+                        "Warning, unsupported keyframe coding type?!\n");
              skip_bits(&gb, 2); /* reserved? */
          }
      } else {
          if (!s->golden_frame.f->data[0]) {
-             av_log(s->avctx, AV_LOG_WARNING, "vp3: first frame not a keyframe\n");
+             av_log(s->avctx, AV_LOG_WARNING,
+                    "vp3: first frame not a keyframe\n");
  
              s->golden_frame.f->pict_type = AV_PICTURE_TYPE_I;
-             if (ff_thread_get_buffer(avctx, &s->golden_frame, AV_GET_BUFFER_FLAG_REF) < 0)
+             if (ff_thread_get_buffer(avctx, &s->golden_frame,
 -                                     AV_GET_BUFFER_FLAG_REF) < 0) {
 -                av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
++                                     AV_GET_BUFFER_FLAG_REF) < 0)
                  goto error;
 -            }
              ff_thread_release_buffer(avctx, &s->last_frame);
-             if ((ret = ff_thread_ref_frame(&s->last_frame, &s->golden_frame)) < 0)
+             if ((ret = ff_thread_ref_frame(&s->last_frame,
+                                            &s->golden_frame)) < 0)
                  goto error;
              ff_thread_report_progress(&s->last_frame, INT_MAX, 0);
          }
@@@ -2248,14 -2252,9 +2279,13 @@@ static int theora_decode_header(AVCodec
  
      skip_bits(gb, 6); /* quality hint */
  
-     if (s->theora >= 0x030200)
-     {
+     if (s->theora >= 0x030200) {
          skip_bits(gb, 5); /* keyframe frequency force */
          avctx->pix_fmt = theora_pix_fmts[get_bits(gb, 2)];
 +        if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
 +            av_log(avctx, AV_LOG_ERROR, "Invalid pixel format\n");
 +            return AVERROR_INVALIDDATA;
 +        }
          skip_bits(gb, 3); /* reserved */
      }
  
@@@ -2399,12 -2400,9 +2431,11 @@@ static av_cold int theora_decode_init(A
      int header_len[3];
      int i;
  
 +    avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 +
      s->theora = 1;
  
-     if (!avctx->extradata_size)
-     {
+     if (!avctx->extradata_size) {
          av_log(avctx, AV_LOG_ERROR, "Missing extradata!\n");
          return -1;
      }
          return -1;
      }
  
-   for(i=0;i<3;i++) {
-     if (header_len[i] <= 0)
-         continue;
-     init_get_bits(&gb, header_start[i], header_len[i] * 8);
+     for (i = 0; i < 3; i++) {
+         if (header_len[i] <= 0)
+             continue;
+         init_get_bits(&gb, header_start[i], header_len[i] * 8);
  
-     ptype = get_bits(&gb, 8);
+         ptype = get_bits(&gb, 8);
  
-      if (!(ptype & 0x80))
-      {
-         av_log(avctx, AV_LOG_ERROR, "Invalid extradata!\n");
- //        return -1;
-      }
+         if (!(ptype & 0x80)) {
+             av_log(avctx, AV_LOG_ERROR, "Invalid extradata!\n");
+ //          return -1;
+         }
  
-     // FIXME: Check for this as well.
-     skip_bits_long(&gb, 6*8); /* "theora" */
+         // FIXME: Check for this as well.
+         skip_bits_long(&gb, 6 * 8); /* "theora" */
  
-     switch(ptype)
-     {
+         switch (ptype) {
          case 0x80:
 -            theora_decode_header(avctx, &gb);
 +            if (theora_decode_header(avctx, &gb) < 0)
 +                return -1;
-                 break;
+             break;
          case 0x81:
  // FIXME: is this needed? it breaks sometimes
  //            theora_decode_comments(avctx, gb);
Simple merge
Simple merge
Simple merge