Merge commit '2db953f84671997e936f91140ffb5143c1537844'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 17 Jul 2014 12:00:01 +0000 (14:00 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 17 Jul 2014 12:00:01 +0000 (14:00 +0200)
* commit '2db953f84671997e936f91140ffb5143c1537844':
  h264: K&R formatting cosmetics

Conflicts:
libavcodec/h264.c
libavcodec/h264_direct.c
libavcodec/h264_slice.c

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

@@@ -614,11 -589,11 +617,11 @@@ int ff_h264_decode_extradata(H264Contex
              }
              p += nalsize;
          }
-         // Now store right nal length size, that will be used to parse all other nals
+         // Store right nal length size that will be used to parse all other nals
 -        h->nal_length_size = (avctx->extradata[4] & 0x03) + 1;
 +        h->nal_length_size = (buf[4] & 0x03) + 1;
      } else {
          h->is_avc = 0;
 -        ret = decode_nal_units(h, avctx->extradata, avctx->extradata_size, 1);
 +        ret = decode_nal_units(h, buf, size, 1);
          if (ret < 0)
              return ret;
      }
@@@ -1047,14 -1039,11 +1050,14 @@@ int ff_pred_weight_table(H264Context *h
   */
  static void idr(H264Context *h)
  {
 +    int i;
      ff_h264_remove_all_refs(h);
-     h->prev_frame_num        = 0;
+     h->prev_frame_num        =
 -    h->prev_frame_num_offset =
 -    h->prev_poc_msb          =
 +    h->prev_frame_num_offset = 0;
 +    h->prev_poc_msb          = 1<<16;
      h->prev_poc_lsb          = 0;
 +    for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
 +        h->last_pocs[i] = INT_MIN;
  }
  
  /* forget old pics after a seek */
@@@ -47,10 -47,9 +47,11 @@@ static int get_scale_factor(H264Contex
      }
  }
  
- void ff_h264_direct_dist_scale_factor(H264Context * const h){
-     const int poc = h->picture_structure == PICT_FRAME ?
+ void ff_h264_direct_dist_scale_factor(H264Context *const h)
+ {
 -    const int poc  = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
++    const int poc  = h->picture_structure == PICT_FRAME ?
 +        h->cur_pic_ptr->poc :
 +        h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
      const int poc1 = h->ref_list[1][0].poc;
      int i, field;
  
@@@ -175,47 -187,52 +189,53 @@@ static void pred_spatial_direct_motion(
  
      assert(h->ref_list[1][0].reference & 3);
  
-     await_reference_mb_row(h, &h->ref_list[1][0], h->mb_y + !!IS_INTERLACED(*mb_type));
- #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)
+     await_reference_mb_row(h, &h->ref_list[1][0],
+                            h->mb_y + !!IS_INTERLACED(*mb_type));
  
+ #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
+                                 MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
  
      /* ref = min(neighbors) */
-     for(list=0; list<2; list++){
-         int left_ref = h->ref_cache[list][scan8[0] - 1];
-         int top_ref  = h->ref_cache[list][scan8[0] - 8];
-         int refc = h->ref_cache[list][scan8[0] - 8 + 4];
-         const int16_t *C= h->mv_cache[list][ scan8[0] - 8 + 4];
-         if(refc == PART_NOT_AVAILABLE){
+     for (list = 0; list < 2; list++) {
+         int left_ref     = h->ref_cache[list][scan8[0] - 1];
+         int top_ref      = h->ref_cache[list][scan8[0] - 8];
+         int refc         = h->ref_cache[list][scan8[0] - 8 + 4];
+         const int16_t *C = h->mv_cache[list][scan8[0]  - 8 + 4];
+         if (refc == PART_NOT_AVAILABLE) {
              refc = h->ref_cache[list][scan8[0] - 8 - 1];
-             C    = h-> mv_cache[list][scan8[0] - 8 - 1];
+             C    = h->mv_cache[list][scan8[0]  - 8 - 1];
          }
-         ref[list] = FFMIN3((unsigned)left_ref, (unsigned)top_ref, (unsigned)refc);
-         if(ref[list] >= 0){
-             //this is just pred_motion() but with the cases removed that cannot happen for direct blocks
-             const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ];
-             const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ];
-             int match_count= (left_ref==ref[list]) + (top_ref==ref[list]) + (refc==ref[list]);
-             if(match_count > 1){ //most common
-                 mv[list]= pack16to32(mid_pred(A[0], B[0], C[0]),
-                                      mid_pred(A[1], B[1], C[1]) );
-             }else {
-                 assert(match_count==1);
-                 if(left_ref==ref[list]){
-                     mv[list]= AV_RN32A(A);
-                 }else if(top_ref==ref[list]){
-                     mv[list]= AV_RN32A(B);
-                 }else{
-                     mv[list]= AV_RN32A(C);
-                 }
+         ref[list] = FFMIN3((unsigned)left_ref,
+                            (unsigned)top_ref,
+                            (unsigned)refc);
+         if (ref[list] >= 0) {
+             /* This is just pred_motion() but with the cases removed that
+              * cannot happen for direct blocks. */
+             const int16_t *const A = h->mv_cache[list][scan8[0] - 1];
+             const int16_t *const B = h->mv_cache[list][scan8[0] - 8];
+             int match_count = (left_ref == ref[list]) +
+                               (top_ref  == ref[list]) +
+                               (refc     == ref[list]);
+             if (match_count > 1) { // most common
+                 mv[list] = pack16to32(mid_pred(A[0], B[0], C[0]),
+                                       mid_pred(A[1], B[1], C[1]));
+             } else {
+                 assert(match_count == 1);
+                 if (left_ref == ref[list])
+                     mv[list] = AV_RN32A(A);
+                 else if (top_ref == ref[list])
+                     mv[list] = AV_RN32A(B);
+                 else
+                     mv[list] = AV_RN32A(C);
              }
-         }else{
-             int mask= ~(MB_TYPE_L0 << (2*list));
-             mv[list] = 0;
 +            av_assert2(ref[list] < (h->ref_count[list] << !!FRAME_MBAFF(h)));
+         } else {
+             int mask = ~(MB_TYPE_L0 << (2 * list));
+             mv[list]  = 0;
              ref[list] = -1;
-             if(!is_b8x8)
+             if (!is_b8x8)
                  *mb_type &= mask;
              sub_mb_type &= mask;
          }
@@@ -290,16 -313,16 +316,16 @@@ single_col
  
      await_reference_mb_row(h, &h->ref_list[1][0], mb_y);
  
-     l1mv0  = (void*)&h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]];
-     l1mv1  = (void*)&h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]];
-     l1ref0 = &h->ref_list[1][0].ref_index [0][4 * mb_xy];
-     l1ref1 = &h->ref_list[1][0].ref_index [1][4 * mb_xy];
-     if(!b8_stride){
-         if(h->mb_y&1){
 -    l1mv0  = &h->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]];
 -    l1mv1  = &h->ref_list[1][0].motion_val[1][h->mb2b_xy[mb_xy]];
++    l1mv0  = (void*)&h->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]];
++    l1mv1  = (void*)&h->ref_list[1][0].motion_val[1][h->mb2b_xy[mb_xy]];
+     l1ref0 = &h->ref_list[1][0].ref_index[0][4 * mb_xy];
+     l1ref1 = &h->ref_list[1][0].ref_index[1][4 * mb_xy];
+     if (!b8_stride) {
+         if (h->mb_y & 1) {
              l1ref0 += 2;
              l1ref1 += 2;
-             l1mv0  +=  2*b4_stride;
-             l1mv1  +=  2*b4_stride;
+             l1mv0  += 2 * b4_stride;
+             l1mv1  += 2 * b4_stride;
          }
      }
  
@@@ -480,16 -536,16 +539,16 @@@ single_col
  
      await_reference_mb_row(h, &h->ref_list[1][0], mb_y);
  
-     l1mv0  = (void*)&h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]];
-     l1mv1  = (void*)&h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]];
-     l1ref0 = &h->ref_list[1][0].ref_index [0][4 * mb_xy];
-     l1ref1 = &h->ref_list[1][0].ref_index [1][4 * mb_xy];
-     if(!b8_stride){
-         if(h->mb_y&1){
 -    l1mv0  = &h->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]];
 -    l1mv1  = &h->ref_list[1][0].motion_val[1][h->mb2b_xy[mb_xy]];
++    l1mv0  = (void*)&h->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]];
++    l1mv1  = (void*)&h->ref_list[1][0].motion_val[1][h->mb2b_xy[mb_xy]];
+     l1ref0 = &h->ref_list[1][0].ref_index[0][4 * mb_xy];
+     l1ref1 = &h->ref_list[1][0].ref_index[1][4 * mb_xy];
+     if (!b8_stride) {
+         if (h->mb_y & 1) {
              l1ref0 += 2;
              l1ref1 += 2;
-             l1mv0  +=  2*b4_stride;
-             l1mv1  +=  2*b4_stride;
+             l1mv0  += 2 * b4_stride;
+             l1mv1  += 2 * b4_stride;
          }
      }
  
@@@ -2488,17 -2296,14 +2491,15 @@@ static int decode_slice(struct AVCodecC
                      tprintf(h->avctx, "slice end %d %d\n",
                              get_bits_count(&h->gb), h->gb.size_in_bits);
  
 -                    if (get_bits_left(&h->gb) == 0) {
 +                    if (   get_bits_left(&h->gb) == 0
 +                        || get_bits_left(&h->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
                          er_add_slice(h, h->resync_mb_x, h->resync_mb_y,
-                                      h->mb_x - 1, h->mb_y,
-                                      ER_MB_END);
+                                      h->mb_x - 1, h->mb_y, ER_MB_END);
  
                          return 0;
                      } else {
                          er_add_slice(h, h->resync_mb_x, h->resync_mb_y,
-                                      h->mb_x, h->mb_y,
-                                      ER_MB_END);
 -                                     h->mb_x - 1, h->mb_y, ER_MB_END);
++                                     h->mb_x, h->mb_y, ER_MB_END);
  
                          return AVERROR_INVALIDDATA;
                      }