Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 27 Dec 2011 23:48:53 +0000 (00:48 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 28 Dec 2011 01:38:33 +0000 (02:38 +0100)
* qatar/master:
  mpegvideo_enc: K&R cosmetics
  doxygen: remove unreplaced variables from custom header and footer
  threads: test for sys/param.h and include it for sysctl on OpenBSD
  v4l2: remove unneded linux specific asm/types.h include
  x86: Fix constraints for decode_significance*_x86

Conflicts:
libavcodec/mpegvideo_enc.c
libavdevice/v4l2.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
configure
libavcodec/h264_cabac.c
libavcodec/mpegvideo_enc.c
libavcodec/pthread.c
libavcodec/x86/h264_i386.h

diff --cc configure
+++ b/configure
@@@ -3020,9 -2872,9 +3021,10 @@@ check_header libcrystalhd/libcrystalhd_
  check_header malloc.h
  check_header poll.h
  check_header sys/mman.h
+ check_header sys/param.h
  check_header sys/resource.h
  check_header sys/select.h
 +check_header termios.h
  check_header vdpau/vdpau.h
  check_header vdpau/vdpau_x11.h
  check_header X11/extensions/XvMClib.h
Simple merge
@@@ -92,30 -94,39 +95,38 @@@ void ff_convert_matrix(DSPContext *dsp
                     || dsp->fdct == ff_faandct
  #endif
                     ) {
-             for(i=0;i<64;i++) {
-                 const int j= dsp->idct_permutation[i];
-                 /* 16 <= qscale * quant_matrix[i] <= 7905 */
-                 /* 19952             <= ff_aanscales[i] * qscale * quant_matrix[i]               <= 249205026 */
-                 /* (1 << 36) / 19952 >= (1 << 36) / (ff_aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */
-                 /* 3444240           >= (1 << 36) / (ff_aanscales[i] * qscale * quant_matrix[i]) >= 275 */
+             for (i = 0; i < 64; i++) {
+                 const int j = dsp->idct_permutation[i];
+                 /* 16 <= qscale * quant_matrix[i] <= 7905
+                  * Assume x = ff_aanscales[i] * qscale * quant_matrix[i]
+                  *             19952 <=              x  <= 249205026
+                  * (1 << 36) / 19952 >= (1 << 36) / (x) >= (1 << 36) / 249205026
+                  *           3444240 >= (1 << 36) / (x) >= 275 */
  
                  qmat[qscale][i] = (int)((UINT64_C(1) << (QMAT_SHIFT + 14)) /
-                                 (ff_aanscales[i] * qscale * quant_matrix[j]));
 -                                        (ff_aanscales[i] * qscale *
 -                                         quant_matrix[j]));
++                                        (ff_aanscales[i] * qscale * quant_matrix[j]));
              }
          } else {
-             for(i=0;i<64;i++) {
-                 const int j= dsp->idct_permutation[i];
+             for (i = 0; i < 64; i++) {
+                 const int j = dsp->idct_permutation[i];
                  /* We can safely suppose that 16 <= quant_matrix[i] <= 255
-                    So 16           <= qscale * quant_matrix[i]             <= 7905
-                    so (1<<19) / 16 >= (1<<19) / (qscale * quant_matrix[i]) >= (1<<19) / 7905
-                    so 32768        >= (1<<19) / (qscale * quant_matrix[i]) >= 67
-                 */
-                 qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j]));
- //                qmat  [qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]);
-                 qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]);
-                 if(qmat16[qscale][0][i]==0 || qmat16[qscale][0][i]==128*256) qmat16[qscale][0][i]=128*256-1;
-                 qmat16[qscale][1][i]= ROUNDED_DIV(bias<<(16-QUANT_BIAS_SHIFT), qmat16[qscale][0][i]);
+                  * Assume x = qscale * quant_matrix[i]
+                  * So             16 <=              x  <= 7905
+                  * so (1 << 19) / 16 >= (1 << 19) / (x) >= (1 << 19) / 7905
+                  * so          32768 >= (1 << 19) / (x) >= 67 */
+                 qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) /
+                                         (qscale * quant_matrix[j]));
+                 //qmat  [qscale][i] = (1 << QMAT_SHIFT_MMX) /
+                 //                    (qscale * quant_matrix[i]);
+                 qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) /
+                                        (qscale * quant_matrix[j]);
+                 if (qmat16[qscale][0][i] == 0 ||
+                     qmat16[qscale][0][i] == 128 * 256)
+                     qmat16[qscale][0][i] = 128 * 256 - 1;
+                 qmat16[qscale][1][i] =
+                     ROUNDED_DIV(bias << (16 - QUANT_BIAS_SHIFT),
+                                 qmat16[qscale][0][i]);
              }
          }
  
@@@ -266,9 -305,11 +305,12 @@@ av_cold int MPV_encode_init(AVCodecCont
          }
          break;
      case CODEC_ID_MJPEG:
-         if(avctx->pix_fmt != PIX_FMT_YUVJ420P && avctx->pix_fmt != PIX_FMT_YUVJ422P &&
-            ((avctx->pix_fmt != PIX_FMT_YUV420P && avctx->pix_fmt != PIX_FMT_YUV422P) || avctx->strict_std_compliance>FF_COMPLIANCE_UNOFFICIAL)){
 +    case CODEC_ID_AMV:
+         if (avctx->pix_fmt != PIX_FMT_YUVJ420P &&
+             avctx->pix_fmt != PIX_FMT_YUVJ422P &&
+             ((avctx->pix_fmt != PIX_FMT_YUV420P &&
+               avctx->pix_fmt != PIX_FMT_YUV422P) ||
+              avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)) {
              av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n");
              return -1;
          }
          return -1;
      }
  
-     if(avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate){
+     if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) {
 -        av_log(avctx, AV_LOG_INFO, "bitrate above max bitrate\n");
 +        av_log(avctx, AV_LOG_ERROR, "bitrate above max bitrate\n");
          return -1;
      }
  
          return -1;
      }
  
-     if ((s->codec_id == CODEC_ID_MPEG4 || s->codec_id == CODEC_ID_H263 ||
+     if ((s->codec_id == CODEC_ID_MPEG4 ||
+          s->codec_id == CODEC_ID_H263  ||
           s->codec_id == CODEC_ID_H263P) &&
-         (avctx->sample_aspect_ratio.num > 255 || avctx->sample_aspect_ratio.den > 255)) {
-         av_log(avctx, AV_LOG_WARNING, "Invalid pixel aspect ratio %i/%i, limit is 255/255 reducing\n",
+         (avctx->sample_aspect_ratio.num > 255 ||
+          avctx->sample_aspect_ratio.den > 255)) {
 -        av_log(avctx, AV_LOG_ERROR,
 -               "Invalid pixel aspect ratio %i/%i, limit is 255/255\n",
++        av_log(avctx, AV_LOG_WARNING,
++               "Invalid pixel aspect ratio %i/%i, limit is 255/255 reducing\n",
                 avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);
 -        return -1;
 +        av_reduce(&avctx->sample_aspect_ratio.num, &avctx->sample_aspect_ratio.den,
 +                   avctx->sample_aspect_ratio.num,  avctx->sample_aspect_ratio.den, 255);
      }
  
-     if((s->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME|CODEC_FLAG_ALT_SCAN))
-        && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG2VIDEO){
+     if ((s->flags & (CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME |
+                      CODEC_FLAG_ALT_SCAN)) &&
+         s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG2VIDEO) {
          av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n");
          return -1;
      }
          return -1;
      }
  
-     if(s->avctx->thread_count < 1){
-         av_log(avctx, AV_LOG_ERROR, "automatic thread number detection not supported by codec, patch welcome\n");
+     if (s->avctx->thread_count < 1) {
+         av_log(avctx, AV_LOG_ERROR,
 -               "automatic thread number detection not supported by codec,"
++               "automatic thread number detection not supported by codec, "
+                "patch welcome\n");
          return -1;
      }
  
          av_log(avctx, AV_LOG_INFO, "removing common factors from framerate\n");
          avctx->time_base.den /= i;
          avctx->time_base.num /= i;
//        return -1;
        //return -1;
      }
  
-     if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO || s->codec_id==CODEC_ID_MJPEG || s->codec_id==CODEC_ID_AMV){
-         s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x
-         s->inter_quant_bias= 0;
-     }else{
-         s->intra_quant_bias=0;
-         s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x
 -    if (s->mpeg_quant || s->codec_id == CODEC_ID_MPEG1VIDEO ||
 -        s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG) {
++    if (s->mpeg_quant || s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id==CODEC_ID_AMV) {
+         // (a + x * 3 / 8) / x
+         s->intra_quant_bias = 3 << (QUANT_BIAS_SHIFT - 3);
+         s->inter_quant_bias = 0;
+     } else {
+         s->intra_quant_bias = 0;
+         // (a - x / 4) / x
+         s->inter_quant_bias = -(1 << (QUANT_BIAS_SHIFT - 2));
      }
  
-     if(avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)
-         s->intra_quant_bias= avctx->intra_quant_bias;
-     if(avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
-         s->inter_quant_bias= avctx->inter_quant_bias;
+     if (avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)
+         s->intra_quant_bias = avctx->intra_quant_bias;
+     if (avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
+         s->inter_quant_bias = avctx->inter_quant_bias;
  
-     avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
 +    av_log(avctx, AV_LOG_DEBUG, "intra_quant_bias = %d inter_quant_bias = %d\n",s->intra_quant_bias,s->inter_quant_bias);
 +
+     avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
+                                   &chroma_v_shift);
  
-     if(avctx->codec_id == CODEC_ID_MPEG4 && s->avctx->time_base.den > (1<<16)-1){
-         av_log(avctx, AV_LOG_ERROR, "timebase %d/%d not supported by MPEG 4 standard, "
-                "the maximum admitted value for the timebase denominator is %d\n",
-                s->avctx->time_base.num, s->avctx->time_base.den, (1<<16)-1);
+     if (avctx->codec_id == CODEC_ID_MPEG4 &&
+         s->avctx->time_base.den > (1 << 16) - 1) {
+         av_log(avctx, AV_LOG_ERROR,
+                "timebase %d/%d not supported by MPEG 4 standard, "
+                "the maximum admitted value for the timebase denominator "
+                "is %d\n", s->avctx->time_base.num, s->avctx->time_base.den,
+                (1 << 16) - 1);
          return -1;
      }
      s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
          break;
      case CODEC_ID_LJPEG:
      case CODEC_ID_MJPEG:
 +    case CODEC_ID_AMV:
          s->out_format = FMT_MJPEG;
          s->intra_only = 1; /* force intra only for jpeg */
-         if(avctx->codec->id == CODEC_ID_LJPEG && avctx->pix_fmt == PIX_FMT_BGRA){
 -        if (avctx->codec->id == CODEC_ID_LJPEG &&
 -            avctx->pix_fmt   == PIX_FMT_BGRA) {
++        if (avctx->codec->id == CODEC_ID_LJPEG && avctx->pix_fmt   == PIX_FMT_BGRA) {
              s->mjpeg_vsample[0] = s->mjpeg_hsample[0] =
              s->mjpeg_vsample[1] = s->mjpeg_hsample[1] =
              s->mjpeg_vsample[2] = s->mjpeg_hsample[2] = 1;
              return -1;
          }
          s->out_format = FMT_H261;
-         avctx->delay=0;
-         s->low_delay=1;
+         avctx->delay  = 0;
+         s->low_delay  = 1;
          break;
      case CODEC_ID_H263:
-         if (!CONFIG_H263_ENCODER)  return -1;
-         if (ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format), s->width, s->height) == 8) {
-             av_log(avctx, AV_LOG_ERROR, "The specified picture size of %dx%d is not valid for the H.263 codec.\nValid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152. Try H.263+.\n", s->width, s->height);
+         if (!CONFIG_H263_ENCODER)
 -        return -1;
++            return -1;
+         if (ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format),
+                              s->width, s->height) == 8) {
 -            av_log(avctx, AV_LOG_INFO,
++            av_log(avctx, AV_LOG_ERROR,
+                    "The specified picture size of %dx%d is not valid for "
+                    "the H.263 codec.\nValid sizes are 128x96, 176x144, "
 -                   "352x288, 704x576, and 1408x1152."
++                   "352x288, 704x576, and 1408x1152. "
+                    "Try H.263+.\n", s->width, s->height);
              return -1;
          }
          s->out_format = FMT_H263;
@@@ -889,35 -1013,32 +1016,36 @@@ static int load_input_picture(MpegEncCo
              return -1;
          }
  
-         if(   pic->data[0] + INPLACE_OFFSET == pic_arg->data[0]
-            && pic->data[1] + INPLACE_OFFSET == pic_arg->data[1]
-            && pic->data[2] + INPLACE_OFFSET == pic_arg->data[2]){
-        // empty
-         }else{
+         if (pic->data[0] + INPLACE_OFFSET == pic_arg->data[0] &&
+             pic->data[1] + INPLACE_OFFSET == pic_arg->data[1] &&
+             pic->data[2] + INPLACE_OFFSET == pic_arg->data[2]) {
+             // empty
+         } else {
              int h_chroma_shift, v_chroma_shift;
-             avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift);
-             for(i=0; i<3; i++){
-                 int src_stride= pic_arg->linesize[i];
-                 int dst_stride= i ? s->uvlinesize : s->linesize;
-                 int h_shift= i ? h_chroma_shift : 0;
-                 int v_shift= i ? v_chroma_shift : 0;
-                 int w= s->width >>h_shift;
-                 int h= s->height>>v_shift;
-                 uint8_t *src= pic_arg->data[i];
-                 uint8_t *dst= pic->data[i];
+             avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift,
+                                           &v_chroma_shift);
+             for (i = 0; i < 3; i++) {
+                 int src_stride = pic_arg->linesize[i];
+                 int dst_stride = i ? s->uvlinesize : s->linesize;
+                 int h_shift = i ? h_chroma_shift : 0;
+                 int v_shift = i ? v_chroma_shift : 0;
+                 int w = s->width  >> h_shift;
+                 int h = s->height >> v_shift;
+                 uint8_t *src = pic_arg->data[i];
+                 uint8_t *dst = pic->data[i];
  
-                 if(!s->avctx->rc_buffer_size)
-                     dst +=INPLACE_OFFSET;
 +                if(s->codec_id == CODEC_ID_AMV && !(s->avctx->flags & CODEC_FLAG_EMU_EDGE)){
 +                    h= ((s->height+15)/16*16)>>v_shift;
 +                }
 +
+                 if (!s->avctx->rc_buffer_size)
+                     dst += INPLACE_OFFSET;
  
-                 if(src_stride==dst_stride)
-                     memcpy(dst, src, src_stride*h);
-                 else{
-                     while(h--){
+                 if (src_stride == dst_stride)
+                     memcpy(dst, src, src_stride * h);
+                 else {
+                     while (h--) {
                          memcpy(dst, src, w);
                          dst += dst_stride;
                          src += src_stride;
  #elif HAVE_GETSYSTEMINFO
  #include <windows.h>
  #elif HAVE_SYSCTL
+ #if HAVE_SYS_PARAM_H
+ #include <sys/param.h>
+ #endif
  #include <sys/types.h>
 +#include <sys/param.h>
  #include <sys/sysctl.h>
  #endif
  
Simple merge