Merge commit '23e85be58fc64b2e804e68b0034a08a6d257e523'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 21 Mar 2013 12:06:14 +0000 (13:06 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 21 Mar 2013 12:06:14 +0000 (13:06 +0100)
* commit '23e85be58fc64b2e804e68b0034a08a6d257e523':
  h264: add a parameter to the CHROMA444 macro.
  h264: add a parameter to the CHROMA422 macro.

Conflicts:
libavcodec/h264.c
libavcodec/h264.h
libavcodec/h264_cavlc.c
libavcodec/h264_loopfilter.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/h264.c
libavcodec/h264.h
libavcodec/h264_cabac.c
libavcodec/h264_cavlc.c
libavcodec/h264_loopfilter.c
libavcodec/h264_mb_template.c
libavcodec/h264_mvpred.h

@@@ -3009,39 -2947,14 +3009,39 @@@ static enum AVPixelFormat get_pixel_for
          else
              return AV_PIX_FMT_YUV420P10;
          break;
 -    case 8:
 +    case 12:
-         if (CHROMA444) {
+         if (CHROMA444(h)) {
              if (h->avctx->colorspace == AVCOL_SPC_RGB) {
 -                return AV_PIX_FMT_GBRP;
 +                return AV_PIX_FMT_GBRP12;
              } else
 -                return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ444P
 -                                                                 : AV_PIX_FMT_YUV444P;
 +                return AV_PIX_FMT_YUV444P12;
-         } else if (CHROMA422)
++        } else if (CHROMA422(h))
 +            return AV_PIX_FMT_YUV422P12;
 +        else
 +            return AV_PIX_FMT_YUV420P12;
 +        break;
 +    case 14:
-         if (CHROMA444) {
++        if (CHROMA444(h)) {
 +            if (h->avctx->colorspace == AVCOL_SPC_RGB) {
 +                return AV_PIX_FMT_GBRP14;
 +            } else
 +                return AV_PIX_FMT_YUV444P14;
-         } else if (CHROMA422)
++        } else if (CHROMA422(h))
 +            return AV_PIX_FMT_YUV422P14;
 +        else
 +            return AV_PIX_FMT_YUV420P14;
 +        break;
 +    case 8:
-         if (CHROMA444) {
++        if (CHROMA444(h)) {
 +            if (h->avctx->colorspace == AVCOL_SPC_RGB) {
 +                av_log(h->avctx, AV_LOG_DEBUG, "Detected GBR colorspace.\n");
 +                return AV_PIX_FMT_GBR24P;
 +            } else if (h->avctx->colorspace == AVCOL_SPC_YCGCO) {
 +                av_log(h->avctx, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n");
 +            }
 +            return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ444P
 +                                                                : AV_PIX_FMT_YUV444P;
-         } else if (CHROMA422) {
+         } else if (CHROMA422(h)) {
              return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ422P
                                                               : AV_PIX_FMT_YUV422P;
          } else {
@@@ -3072,20 -2979,7 +3072,20 @@@ static int h264_slice_header_init(H264C
                      h->avctx->thread_count : 1;
      int i;
  
 -    avcodec_set_dimensions(h->avctx, h->width, h->height);
 +    if(    FFALIGN(h->avctx->width , 16                                 ) == h->width
 +        && FFALIGN(h->avctx->height, 16*(2 - h->sps.frame_mbs_only_flag)) == h->height
 +        && !h->sps.crop_right && !h->sps.crop_bottom
 +        && (h->avctx->width != h->width || h->avctx->height && h->height)
 +    ) {
 +        av_log(h->avctx, AV_LOG_DEBUG, "Using externally provided dimensions\n");
 +        h->avctx->coded_width  = h->width;
 +        h->avctx->coded_height = h->height;
 +    } else{
 +        avcodec_set_dimensions(h->avctx, h->width, h->height);
-         h->avctx->width  -= (2>>CHROMA444)*FFMIN(h->sps.crop_right, (8<<CHROMA444)-1);
++        h->avctx->width  -= (2>>CHROMA444(h))*FFMIN(h->sps.crop_right, (8<<CHROMA444(h))-1);
 +        h->avctx->height -= (1<<h->chroma_y_shift)*FFMIN(h->sps.crop_bottom, (16>>h->chroma_y_shift)-1) * (2 - h->sps.frame_mbs_only_flag);
 +    }
 +
      h->avctx->sample_aspect_ratio = h->sps.sar;
      av_assert0(h->avctx->sample_aspect_ratio.den);
      av_pix_fmt_get_chroma_sub_sample(h->avctx->pix_fmt,
@@@ -87,9 -85,8 +87,9 @@@
  #define CABAC(h) h->pps.cabac
  #endif
  
- #define CHROMA422 (h->sps.chroma_format_idc == 2)
- #define CHROMA444 (h->sps.chroma_format_idc == 3)
 +#define CHROMA    (h->sps.chroma_format_idc)
+ #define CHROMA422(h) (h->sps.chroma_format_idc == 2)
+ #define CHROMA444(h) (h->sps.chroma_format_idc == 3)
  
  #define EXTENDED_SAR       255
  
Simple merge
@@@ -1125,9 -1117,8 +1125,9 @@@ decode_intra_mb
              if(cbp&0x30){
                  for(chroma_idx=0; chroma_idx<2; chroma_idx++)
                      if (decode_residual(h, gb, h->mb + ((256 + 16*16*chroma_idx) << pixel_shift),
 -                                        CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma422_dc_scan,
 -                                        NULL, 8) < 0) {
 +                                        CHROMA_DC_BLOCK_INDEX+chroma_idx,
-                                         CHROMA422 ? chroma422_dc_scan : chroma_dc_scan,
++                                        CHROMA422(h) ? chroma422_dc_scan : chroma_dc_scan,
 +                                        NULL, 4*num_c8x8) < 0) {
                          return -1;
                      }
              }
@@@ -241,9 -244,9 +241,9 @@@ static av_always_inline void h264_filte
                                                            unsigned int uvlinesize,
                                                            int pixel_shift)
  {
 -    int chroma = !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
 +    int chroma = CHROMA && !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
-     int chroma444 = CHROMA444;
-     int chroma422 = CHROMA422;
+     int chroma444 = CHROMA444(h);
+     int chroma422 = CHROMA422(h);
  
      int mb_xy = h->mb_xy;
      int left_type= h->left_type[LTOP];
Simple merge
Simple merge