Merge commit 'd9ebb00dcbaac3812b8b1fbc3d6e027506c11cbc'
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 16 Feb 2013 13:30:21 +0000 (14:30 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 16 Feb 2013 13:30:21 +0000 (14:30 +0100)
* commit 'd9ebb00dcbaac3812b8b1fbc3d6e027506c11cbc':
  svq3: remove a pointless if()
  h264: remove a pointless if()

Conflicts:
libavcodec/h264.c
libavcodec/svq3.c

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

@@@ -1822,77 -1796,75 +1822,75 @@@ static av_always_inline void hl_decode_
      int qscale = p == 0 ? s->qscale : h->chroma_qp[p - 1];
      block_offset += 16 * p;
      if (IS_INTRA4x4(mb_type)) {
-         if (simple || !s->encoding) {
-             if (IS_8x8DCT(mb_type)) {
-                 if (transform_bypass) {
-                     idct_dc_add  =
-                     idct_add     = h->h264dsp.h264_add_pixels8;
+         if (IS_8x8DCT(mb_type)) {
+             if (transform_bypass) {
+                 idct_dc_add  =
 -                idct_add     = s->dsp.add_pixels8;
++                idct_add     = h->h264dsp.h264_add_pixels8;
+             } else {
+                 idct_dc_add = h->h264dsp.h264_idct8_dc_add;
+                 idct_add    = h->h264dsp.h264_idct8_add;
+             }
+             for (i = 0; i < 16; i += 4) {
+                 uint8_t *const ptr = dest_y + block_offset[i];
+                 const int dir      = h->intra4x4_pred_mode_cache[scan8[i]];
+                 if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
+                     h->hpc.pred8x8l_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
                  } else {
-                     idct_dc_add = h->h264dsp.h264_idct8_dc_add;
-                     idct_add    = h->h264dsp.h264_idct8_add;
-                 }
-                 for (i = 0; i < 16; i += 4) {
-                     uint8_t *const ptr = dest_y + block_offset[i];
-                     const int dir      = h->intra4x4_pred_mode_cache[scan8[i]];
-                     if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
-                         h->hpc.pred8x8l_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
-                     } else {
-                         const int nnz = h->non_zero_count_cache[scan8[i + p * 16]];
-                         h->hpc.pred8x8l[dir](ptr, (h->topleft_samples_available << i) & 0x8000,
-                                              (h->topright_samples_available << i) & 0x4000, linesize);
-                         if (nnz) {
-                             if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
-                                 idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
-                             else
-                                 idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
-                         }
+                     const int nnz = h->non_zero_count_cache[scan8[i + p * 16]];
+                     h->hpc.pred8x8l[dir](ptr, (h->topleft_samples_available << i) & 0x8000,
+                                          (h->topright_samples_available << i) & 0x4000, linesize);
+                     if (nnz) {
+                         if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
+                             idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
+                         else
+                             idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
                      }
                  }
 -                    idct_add = s->dsp.add_pixels4;
+             }
+         } else {
+             if (transform_bypass) {
+                 idct_dc_add  =
++                    idct_add = h->h264dsp.h264_add_pixels4;
              } else {
-                 if (transform_bypass) {
-                     idct_dc_add  =
-                         idct_add = h->h264dsp.h264_add_pixels4;
-                 } else {
-                     idct_dc_add = h->h264dsp.h264_idct_dc_add;
-                     idct_add    = h->h264dsp.h264_idct_add;
-                 }
-                 for (i = 0; i < 16; i++) {
-                     uint8_t *const ptr = dest_y + block_offset[i];
-                     const int dir      = h->intra4x4_pred_mode_cache[scan8[i]];
+                 idct_dc_add = h->h264dsp.h264_idct_dc_add;
+                 idct_add    = h->h264dsp.h264_idct_add;
+             }
+             for (i = 0; i < 16; i++) {
+                 uint8_t *const ptr = dest_y + block_offset[i];
+                 const int dir      = h->intra4x4_pred_mode_cache[scan8[i]];
  
-                     if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
-                         h->hpc.pred4x4_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
-                     } else {
-                         uint8_t *topright;
-                         int nnz, tr;
-                         uint64_t tr_high;
-                         if (dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED) {
-                             const int topright_avail = (h->topright_samples_available << i) & 0x8000;
-                             av_assert2(s->mb_y || linesize <= block_offset[i]);
-                             if (!topright_avail) {
-                                 if (pixel_shift) {
-                                     tr_high  = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
-                                     topright = (uint8_t *)&tr_high;
-                                 } else {
-                                     tr       = ptr[3 - linesize] * 0x01010101u;
-                                     topright = (uint8_t *)&tr;
-                                 }
-                             } else
-                                 topright = ptr + (4 << pixel_shift) - linesize;
+                 if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
+                     h->hpc.pred4x4_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
+                 } else {
+                     uint8_t *topright;
+                     int nnz, tr;
+                     uint64_t tr_high;
+                     if (dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED) {
+                         const int topright_avail = (h->topright_samples_available << i) & 0x8000;
 -                        assert(s->mb_y || linesize <= block_offset[i]);
++                        av_assert2(s->mb_y || linesize <= block_offset[i]);
+                         if (!topright_avail) {
+                             if (pixel_shift) {
+                                 tr_high  = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
+                                 topright = (uint8_t *)&tr_high;
+                             } else {
+                                 tr       = ptr[3 - linesize] * 0x01010101u;
+                                 topright = (uint8_t *)&tr;
+                             }
                          } else
-                             topright = NULL;
-                         h->hpc.pred4x4[dir](ptr, topright, linesize);
-                         nnz = h->non_zero_count_cache[scan8[i + p * 16]];
-                         if (nnz) {
-                             if (is_h264) {
-                                 if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
-                                     idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
-                                 else
-                                     idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
-                             } else if (CONFIG_SVQ3_DECODER)
-                                 ff_svq3_add_idct_c(ptr, h->mb + i * 16 + p * 256, linesize, qscale, 0);
-                         }
+                             topright = ptr + (4 << pixel_shift) - linesize;
+                     } else
+                         topright = NULL;
+                     h->hpc.pred4x4[dir](ptr, topright, linesize);
+                     nnz = h->non_zero_count_cache[scan8[i + p * 16]];
+                     if (nnz) {
+                         if (is_h264) {
+                             if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
+                                 idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
+                             else
+                                 idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
+                         } else if (CONFIG_SVQ3_DECODER)
+                             ff_svq3_add_idct_c(ptr, h->mb + i * 16 + p * 256, linesize, qscale, 0);
                      }
                  }
              }
@@@ -860,151 -854,147 +860,148 @@@ static av_cold int svq3_decode_init(AVC
      s->flags2          = avctx->flags2;
      s->unrestricted_mv = 1;
      h->is_complex      = 1;
 +    h->sps.chroma_format_idc = 1;
      avctx->pix_fmt     = avctx->codec->pix_fmts[0];
  
-     if (!s->context_initialized) {
-         h->chroma_qp[0] = h->chroma_qp[1] = 4;
-         svq3->halfpel_flag  = 1;
-         svq3->thirdpel_flag = 1;
-         svq3->unknown_flag  = 0;
-         /* prowl for the "SEQH" marker in the extradata */
-         extradata     = (unsigned char *)avctx->extradata;
-         extradata_end = avctx->extradata + avctx->extradata_size;
-         if (extradata) {
-             for (m = 0; m + 8 < avctx->extradata_size; m++) {
-                 if (!memcmp(extradata, "SEQH", 4)) {
-                     marker_found = 1;
-                     break;
-                 }
-                 extradata++;
+     h->chroma_qp[0] = h->chroma_qp[1] = 4;
+     svq3->halfpel_flag  = 1;
+     svq3->thirdpel_flag = 1;
+     svq3->unknown_flag  = 0;
+     /* prowl for the "SEQH" marker in the extradata */
+     extradata     = (unsigned char *)avctx->extradata;
+     extradata_end = avctx->extradata + avctx->extradata_size;
+     if (extradata) {
+         for (m = 0; m + 8 < avctx->extradata_size; m++) {
+             if (!memcmp(extradata, "SEQH", 4)) {
+                 marker_found = 1;
+                 break;
              }
+             extradata++;
          }
+     }
  
-         /* if a match was found, parse the extra data */
-         if (marker_found) {
-             GetBitContext gb;
-             int frame_size_code;
-             size = AV_RB32(&extradata[4]);
-             if (size > extradata_end - extradata - 8)
-                 return AVERROR_INVALIDDATA;
-             init_get_bits(&gb, extradata + 8, size * 8);
-             /* 'frame size code' and optional 'width, height' */
-             frame_size_code = get_bits(&gb, 3);
-             switch (frame_size_code) {
-             case 0:
-                 avctx->width  = 160;
-                 avctx->height = 120;
-                 break;
-             case 1:
-                 avctx->width  = 128;
-                 avctx->height =  96;
-                 break;
-             case 2:
-                 avctx->width  = 176;
-                 avctx->height = 144;
-                 break;
-             case 3:
-                 avctx->width  = 352;
-                 avctx->height = 288;
-                 break;
-             case 4:
-                 avctx->width  = 704;
-                 avctx->height = 576;
-                 break;
-             case 5:
-                 avctx->width  = 240;
-                 avctx->height = 180;
-                 break;
-             case 6:
-                 avctx->width  = 320;
-                 avctx->height = 240;
-                 break;
-             case 7:
-                 avctx->width  = get_bits(&gb, 12);
-                 avctx->height = get_bits(&gb, 12);
-                 break;
-             }
+     /* if a match was found, parse the extra data */
+     if (marker_found) {
+         GetBitContext gb;
+         int frame_size_code;
+         size = AV_RB32(&extradata[4]);
+         if (size > extradata_end - extradata - 8)
+             return AVERROR_INVALIDDATA;
+         init_get_bits(&gb, extradata + 8, size * 8);
+         /* 'frame size code' and optional 'width, height' */
+         frame_size_code = get_bits(&gb, 3);
+         switch (frame_size_code) {
+         case 0:
+             avctx->width  = 160;
+             avctx->height = 120;
+             break;
+         case 1:
+             avctx->width  = 128;
+             avctx->height =  96;
+             break;
+         case 2:
+             avctx->width  = 176;
+             avctx->height = 144;
+             break;
+         case 3:
+             avctx->width  = 352;
+             avctx->height = 288;
+             break;
+         case 4:
+             avctx->width  = 704;
+             avctx->height = 576;
+             break;
+         case 5:
+             avctx->width  = 240;
+             avctx->height = 180;
+             break;
+         case 6:
+             avctx->width  = 320;
+             avctx->height = 240;
+             break;
+         case 7:
+             avctx->width  = get_bits(&gb, 12);
+             avctx->height = get_bits(&gb, 12);
+             break;
+         }
  
-             svq3->halfpel_flag  = get_bits1(&gb);
-             svq3->thirdpel_flag = get_bits1(&gb);
+         svq3->halfpel_flag  = get_bits1(&gb);
+         svq3->thirdpel_flag = get_bits1(&gb);
  
-             /* unknown fields */
-             skip_bits1(&gb);
-             skip_bits1(&gb);
-             skip_bits1(&gb);
-             skip_bits1(&gb);
+         /* unknown fields */
+         skip_bits1(&gb);
+         skip_bits1(&gb);
+         skip_bits1(&gb);
+         skip_bits1(&gb);
  
-             s->low_delay = get_bits1(&gb);
+         s->low_delay = get_bits1(&gb);
  
-             /* unknown field */
-             skip_bits1(&gb);
+         /* unknown field */
+         skip_bits1(&gb);
  
-             while (get_bits1(&gb))
-                 skip_bits(&gb, 8);
+         while (get_bits1(&gb))
+             skip_bits(&gb, 8);
  
-             svq3->unknown_flag  = get_bits1(&gb);
-             avctx->has_b_frames = !s->low_delay;
-             if (svq3->unknown_flag) {
+         svq3->unknown_flag  = get_bits1(&gb);
+         avctx->has_b_frames = !s->low_delay;
+         if (svq3->unknown_flag) {
  #if CONFIG_ZLIB
-                 unsigned watermark_width  = svq3_get_ue_golomb(&gb);
-                 unsigned watermark_height = svq3_get_ue_golomb(&gb);
-                 int u1                    = svq3_get_ue_golomb(&gb);
-                 int u2                    = get_bits(&gb, 8);
-                 int u3                    = get_bits(&gb, 2);
-                 int u4                    = svq3_get_ue_golomb(&gb);
-                 unsigned long buf_len     = watermark_width *
-                                             watermark_height * 4;
-                 int offset                = get_bits_count(&gb) + 7 >> 3;
-                 uint8_t *buf;
-                 if (watermark_height <= 0 || (uint64_t)watermark_width*4 > UINT_MAX/watermark_height)
-                     return -1;
+             unsigned watermark_width  = svq3_get_ue_golomb(&gb);
+             unsigned watermark_height = svq3_get_ue_golomb(&gb);
+             int u1                    = svq3_get_ue_golomb(&gb);
+             int u2                    = get_bits(&gb, 8);
+             int u3                    = get_bits(&gb, 2);
+             int u4                    = svq3_get_ue_golomb(&gb);
+             unsigned long buf_len     = watermark_width *
+                                         watermark_height * 4;
+             int offset                = get_bits_count(&gb) + 7 >> 3;
+             uint8_t *buf;
 -            if ((uint64_t)watermark_width * 4 > UINT_MAX / watermark_height)
++            if (watermark_height <= 0 || (uint64_t)watermark_width*4 > UINT_MAX/watermark_height)
+                 return -1;
  
-                 buf = av_malloc(buf_len);
-                 av_log(avctx, AV_LOG_DEBUG, "watermark size: %dx%d\n",
-                        watermark_width, watermark_height);
-                 av_log(avctx, AV_LOG_DEBUG,
-                        "u1: %x u2: %x u3: %x compressed data size: %d offset: %d\n",
-                        u1, u2, u3, u4, offset);
-                 if (uncompress(buf, &buf_len, extradata + 8 + offset,
-                                size - offset) != Z_OK) {
-                     av_log(avctx, AV_LOG_ERROR,
-                            "could not uncompress watermark logo\n");
-                     av_free(buf);
-                     return -1;
-                 }
-                 svq3->watermark_key = ff_svq1_packet_checksum(buf, buf_len, 0);
-                 svq3->watermark_key = svq3->watermark_key << 16 |
-                                       svq3->watermark_key;
-                 av_log(avctx, AV_LOG_DEBUG,
-                        "watermark key %#x\n", svq3->watermark_key);
-                 av_free(buf);
- #else
+             buf = av_malloc(buf_len);
+             av_log(avctx, AV_LOG_DEBUG, "watermark size: %dx%d\n",
+                    watermark_width, watermark_height);
+             av_log(avctx, AV_LOG_DEBUG,
+                    "u1: %x u2: %x u3: %x compressed data size: %d offset: %d\n",
+                    u1, u2, u3, u4, offset);
+             if (uncompress(buf, &buf_len, extradata + 8 + offset,
+                            size - offset) != Z_OK) {
                  av_log(avctx, AV_LOG_ERROR,
-                        "this svq3 file contains watermark which need zlib support compiled in\n");
+                        "could not uncompress watermark logo\n");
+                 av_free(buf);
                  return -1;
- #endif
              }
+             svq3->watermark_key = ff_svq1_packet_checksum(buf, buf_len, 0);
+             svq3->watermark_key = svq3->watermark_key << 16 |
+                                   svq3->watermark_key;
+             av_log(avctx, AV_LOG_DEBUG,
+                    "watermark key %#x\n", svq3->watermark_key);
+             av_free(buf);
+ #else
+             av_log(avctx, AV_LOG_ERROR,
+                    "this svq3 file contains watermark which need zlib support compiled in\n");
+             return -1;
+ #endif
          }
+     }
  
-         s->width  = avctx->width;
-         s->height = avctx->height;
+     s->width  = avctx->width;
+     s->height = avctx->height;
  
-         if (ff_MPV_common_init(s) < 0)
-             return -1;
+     if (ff_MPV_common_init(s) < 0)
+         return -1;
  
-         h->b_stride = 4 * s->mb_width;
+     h->b_stride = 4 * s->mb_width;
  
-         if (ff_h264_alloc_tables(h) < 0) {
-             av_log(avctx, AV_LOG_ERROR, "svq3 memory allocation failed\n");
-             return AVERROR(ENOMEM);
-         }
+     if (ff_h264_alloc_tables(h) < 0) {
+         av_log(avctx, AV_LOG_ERROR, "svq3 memory allocation failed\n");
+         return AVERROR(ENOMEM);
      }
  
      return 0;