Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 25 Mar 2012 21:10:30 +0000 (23:10 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 25 Mar 2012 21:10:30 +0000 (23:10 +0200)
* qatar/master:
  x86: dsputil: prettyprint gcc inline asm
  x86: K&R prettyprinting cosmetics for dsputil_mmx.c
  x86: conditionally compile H.264 QPEL optimizations
  dsputil_mmx: Surround QPEL macros by "do { } while (0);" blocks.
  Ignore generated files below doc/.
  dpcm: convert to bytestream2.
  interplayvideo: convert to bytestream2.
  movenc: Merge if statements
  h264: fix memleak in error path.
  pthread: Immediately release all frames in ff_thread_flush()
  h264: Add check for invalid chroma_format_idc
  utvideo: port header reading to bytestream2.

Conflicts:
.gitignore
configure
libavcodec/h264_ps.c
libavcodec/interplayvideo.c
libavcodec/pthread.c
libavcodec/x86/dsputil_mmx.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
.gitignore
configure
libavcodec/dpcm.c
libavcodec/h264_ps.c
libavcodec/interplayvideo.c
libavcodec/pthread.c
libavcodec/utvideo.c
libavcodec/x86/Makefile
libavcodec/x86/dsputil_mmx.c
libavformat/movenc.c

diff --cc .gitignore
@@@ -15,13 -10,14 +15,16 @@@ config.
  doc/*.1
  doc/*.html
  doc/*.pod
 +doc/fate.txt
  doxy
 +ffmpeg
 +ffplay
 +ffprobe
 +ffserver
  avconv
 -avplay
 -avprobe
 -avserver
+ doc/avoptions_codec.texi
+ doc/avoptions_format.texi
+ doc/print_options
  libavcodec/*_tablegen
  libavcodec/*_tables.c
  libavcodec/*_tables.h
diff --cc configure
+++ b/configure
@@@ -1423,8 -1312,7 +1424,8 @@@ h263_encoder_select="aandct
  h263_vaapi_hwaccel_select="vaapi h263_decoder"
  h263i_decoder_select="h263_decoder"
  h263p_encoder_select="h263_encoder"
- h264_decoder_select="golomb h264chroma h264dsp h264pred"
 +h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
+ h264_decoder_select="golomb h264chroma h264dsp h264pred h264qpel"
  h264_dxva2_hwaccel_deps="dxva2api_h"
  h264_dxva2_hwaccel_select="dxva2 h264_decoder"
  h264_vaapi_hwaccel_select="vaapi h264_decoder"
@@@ -1491,11 -1373,8 +1492,11 @@@ shorten_decoder_select="golomb
  sipr_decoder_select="lsp"
  snow_decoder_select="dwt"
  snow_encoder_select="aandct dwt"
 +sonic_decoder_select="golomb"
 +sonic_encoder_select="golomb"
 +sonic_ls_encoder_select="golomb"
  svq1_encoder_select="aandct"
- svq3_decoder_select="golomb h264chroma h264dsp h264pred"
+ svq3_decoder_select="golomb h264chroma h264dsp h264pred h264qpel"
  svq3_decoder_suggest="zlib"
  theora_decoder_select="vp3_decoder"
  tiff_decoder_suggest="zlib"
@@@ -1503,8 -1382,7 +1504,8 @@@ tiff_encoder_suggest="zlib
  truehd_decoder_select="mlp_decoder"
  tscc_decoder_select="zlib"
  twinvq_decoder_select="mdct lsp sinewin"
- vc1_decoder_select="h263_decoder h264chroma"
 +vc1_crystalhd_decoder_select="crystalhd"
+ vc1_decoder_select="h263_decoder h264chroma h264qpel"
  vc1_dxva2_hwaccel_deps="dxva2api_h"
  vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
  vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
@@@ -1544,11 -1420,9 +1545,11 @@@ vda_deps="VideoDecodeAcceleration_VDADe
  vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  
  # parsers
- h264_parser_select="golomb h264chroma h264dsp h264pred"
+ h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel"
  
  # external libraries
 +libaacplus_encoder_deps="libaacplus"
 +libcelt_decoder_deps="libcelt"
  libdirac_decoder_deps="libdirac !libschroedinger"
  libfaac_encoder_deps="libfaac"
  libgsm_decoder_deps="libgsm"
Simple merge
@@@ -349,19 -332,14 +349,19 @@@ int ff_h264_decode_seq_parameter_set(H2
  
      if(sps->profile_idc >= 100){ //high profile
          sps->chroma_format_idc= get_ue_golomb_31(&s->gb);
 -        if(sps->chroma_format_idc > 3) {
 -            av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc (%u) out of range\n", sps->chroma_format_idc);
 +        if (sps->chroma_format_idc > 3U) {
 +            av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc %d is illegal\n", sps->chroma_format_idc);
              goto fail;
-         }
-         if(sps->chroma_format_idc == 3)
+         } else if(sps->chroma_format_idc == 3) {
              sps->residual_color_transform_flag = get_bits1(&s->gb);
+         }
          sps->bit_depth_luma   = get_ue_golomb(&s->gb) + 8;
          sps->bit_depth_chroma = get_ue_golomb(&s->gb) + 8;
 +        if (sps->bit_depth_luma > 12U || sps->bit_depth_chroma > 12U) {
 +            av_log(h->s.avctx, AV_LOG_ERROR, "illegal bit depth value (%d, %d)\n",
 +                   sps->bit_depth_luma, sps->bit_depth_chroma);
 +            goto fail;
 +        }
          sps->transform_bypass = get_bits1(&s->gb);
          decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8);
      }else{
@@@ -194,12 -175,10 +175,10 @@@ static int ipvideo_decode_block_opcode_
  
      /* copy a block from the previous frame using an expanded range;
       * need 2 more bytes */
-     CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 2);
-     x = *s->stream_ptr++;
-     y = *s->stream_ptr++;
+     x = bytestream2_get_byte(&s->stream_ptr);
+     y = bytestream2_get_byte(&s->stream_ptr);
  
 -    av_dlog(NULL, "    motion bytes = %d, %d\n", x, y);
 +    av_dlog(s->avctx, "motion bytes = %d, %d\n", x, y);
      return copy_from(s, &s->last_frame, x, y);
  }
  
@@@ -575,12 -525,10 +525,10 @@@ static int ipvideo_decode_block_opcode_
      signed char x, y;
  
      /* copy a block from the second last frame using an expanded range */
-     CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 2);
-     x = *s->stream_ptr++;
-     y = *s->stream_ptr++;
+     x = bytestream2_get_byte(&s->stream_ptr);
+     y = bytestream2_get_byte(&s->stream_ptr);
  
 -    av_dlog(NULL, "    motion bytes = %d, %d\n", x, y);
 +    av_dlog(s->avctx, "motion bytes = %d, %d\n", x, y);
      return copy_from(s, &s->second_last_frame, x, y);
  }
  
@@@ -957,9 -884,10 +884,10 @@@ static void ipvideo_decode_opcodes(Ipvi
      static int frame = 0;
      GetBitContext gb;
  
 -    av_dlog(NULL, "------------------ frame %d\n", frame);
 +    av_dlog(s->avctx, "frame %d\n", frame);
      frame++;
  
+     bytestream2_skip(&s->stream_ptr, 14); /* data starts 14 bytes in */
      if (!s->is_16bpp) {
          /* this is PAL8, so make the palette available */
          memcpy(s->current_frame.data[1], s->pal, AVPALETTE_SIZE);
              }
          }
      }
-     if (s->stream_end - s->stream_ptr > 1) {
-         av_log(s->avctx, AV_LOG_ERROR, "decode finished with %td bytes left over\n",
-                s->stream_end - s->stream_ptr);
+     if (bytestream2_get_bytes_left(&s->stream_ptr) > 1) {
+         av_log(s->avctx, AV_LOG_ERROR,
 -               "Interplay video: decode finished with %d bytes left over\n",
++               "decode finished with %d bytes left over\n",
+                bytestream2_get_bytes_left(&s->stream_ptr));
      }
  }
  
@@@ -907,9 -880,13 +907,13 @@@ void ff_thread_flush(AVCodecContext *av
      fctx->next_decoding = fctx->next_finished = 0;
      fctx->delaying = 1;
      fctx->prev_thread = NULL;
-     // Make sure decode flush calls with size=0 won't return old frames
-     for (i = 0; i < avctx->thread_count; i++)
-         fctx->threads[i].got_frame = 0;
 -    for (int i = 0; i < avctx->thread_count; i++) {
++    for (i = 0; i < avctx->thread_count; i++) {
+         PerThreadContext *p = &fctx->threads[i];
+         // Make sure decode flush calls with size=0 won't return old frames
+         p->got_frame = 0;
+         release_delayed_buffers(p);
+     }
  }
  
  static int *allocate_progress(PerThreadContext *p)
@@@ -376,11 -375,13 +375,11 @@@ static int decode_frame(AVCodecContext 
          return ret;
      }
  
 -    ff_thread_finish_setup(avctx);
 -
      /* parse plane structure to retrieve frame flags and validate slice offsets */
-     ptr = buf;
+     bytestream2_init(&gb, buf, buf_size);
      for (i = 0; i < c->planes; i++) {
-         plane_start[i] = ptr;
-         if (buf_end - ptr < 256 + 4 * c->slices) {
+         plane_start[i] = gb.buffer;
+         if (bytestream2_get_bytes_left(&gb) < 256 + 4 * c->slices) {
              av_log(avctx, AV_LOG_ERROR, "Insufficient data for a plane\n");
              return AVERROR_INVALIDDATA;
          }
Simple merge
@@@ -1865,105 -2108,34 +2109,112 @@@ void ff_avg_vc1_mspel_mc00_mmx2(uint8_
      avg_pixels8_mmx2(dst, src, stride, 8);
  }
  
- /* XXX: those functions should be suppressed ASAP when all IDCTs are
-    converted */
 +/* only used in VP3/5/6 */
 +static void put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h)
 +{
 +//    START_TIMER
 +    MOVQ_BFE(mm6);
 +    __asm__ volatile(
 +        "1:                             \n\t"
 +        "movq   (%1), %%mm0             \n\t"
 +        "movq   (%2), %%mm1             \n\t"
 +        "movq   (%1,%4), %%mm2          \n\t"
 +        "movq   (%2,%4), %%mm3          \n\t"
 +        PAVGBP_MMX_NO_RND(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
 +        "movq   %%mm4, (%3)             \n\t"
 +        "movq   %%mm5, (%3,%4)          \n\t"
 +
 +        "movq   (%1,%4,2), %%mm0        \n\t"
 +        "movq   (%2,%4,2), %%mm1        \n\t"
 +        "movq   (%1,%5), %%mm2          \n\t"
 +        "movq   (%2,%5), %%mm3          \n\t"
 +        "lea    (%1,%4,4), %1           \n\t"
 +        "lea    (%2,%4,4), %2           \n\t"
 +        PAVGBP_MMX_NO_RND(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
 +        "movq   %%mm4, (%3,%4,2)        \n\t"
 +        "movq   %%mm5, (%3,%5)          \n\t"
 +        "lea    (%3,%4,4), %3           \n\t"
 +        "subl   $4, %0                  \n\t"
 +        "jnz    1b                      \n\t"
 +        :"+r"(h), "+r"(a), "+r"(b), "+r"(dst)
 +        :"r"((x86_reg)stride), "r"((x86_reg)3L*stride)
 +        :"memory");
 +//    STOP_TIMER("put_vp_no_rnd_pixels8_l2_mmx")
 +}
 +static void put_vp_no_rnd_pixels16_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h)
 +{
 +    put_vp_no_rnd_pixels8_l2_mmx(dst, a, b, stride, h);
 +    put_vp_no_rnd_pixels8_l2_mmx(dst+8, a+8, b+8, stride, h);
 +}
 +
 +#if CONFIG_DIRAC_DECODER
 +#define DIRAC_PIXOP(OPNAME, EXT)\
 +void ff_ ## OPNAME ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
 +{\
 +    OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\
 +}\
 +void ff_ ## OPNAME ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
 +{\
 +    OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
 +}\
 +void ff_ ## OPNAME ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
 +{\
 +    OPNAME ## _pixels16_ ## EXT(dst   , src[0]   , stride, h);\
 +    OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
 +}
 +
 +DIRAC_PIXOP(put, mmx)
 +DIRAC_PIXOP(avg, mmx)
 +DIRAC_PIXOP(avg, mmx2)
 +
 +void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
 +{
 +    put_pixels16_sse2(dst, src[0], stride, h);
 +}
 +void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
 +{
 +    avg_pixels16_sse2(dst, src[0], stride, h);
 +}
 +void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
 +{
 +    put_pixels16_sse2(dst   , src[0]   , stride, h);
 +    put_pixels16_sse2(dst+16, src[0]+16, stride, h);
 +}
 +void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
 +{
 +    avg_pixels16_sse2(dst   , src[0]   , stride, h);
 +    avg_pixels16_sse2(dst+16, src[0]+16, stride, h);
 +}
 +#endif
 +
+ /* XXX: Those functions should be suppressed ASAP when all IDCTs are
+  * converted. */
  #if CONFIG_GPL
- static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
+ static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size,
+                                     DCTELEM *block)
  {
-     ff_mmx_idct (block);
+     ff_mmx_idct(block);
      ff_put_pixels_clamped_mmx(block, dest, line_size);
  }
- static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
+ static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size,
+                                     DCTELEM *block)
  {
-     ff_mmx_idct (block);
+     ff_mmx_idct(block);
      ff_add_pixels_clamped_mmx(block, dest, line_size);
  }
- static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
+ static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size,
+                                      DCTELEM *block)
  {
-     ff_mmxext_idct (block);
+     ff_mmxext_idct(block);
      ff_put_pixels_clamped_mmx(block, dest, line_size);
  }
- static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
+ static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size,
+                                      DCTELEM *block)
  {
-     ff_mmxext_idct (block);
+     ff_mmxext_idct(block);
      ff_add_pixels_clamped_mmx(block, dest, line_size);
  }
  #endif
Simple merge