Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 19 May 2011 03:12:45 +0000 (05:12 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 19 May 2011 04:00:31 +0000 (06:00 +0200)
* qatar/master:
  APIchanges: fill in date and commit for request_sample_fmt
  Add floating-point sample format support to the ac3, eac3, dca, aac, and vorbis decoders.
  Add support for request_sample_format in ffmpeg and ffplay.
  Add APIchanges entry for request_sample_fmt.
  Add request_sample_fmt field to AVCodecContext.
  Add float_interleave() to FmtConvertContext with x86-optimized versions.
  Remove unused make variable SEEK_REFFILE
  fate: remove redundant aref and vref references
  fate: remove do_ffmpeg_nocheck function
  fate: do not collect -benchmark output
  mpegaudiodec: remove decode_end() function
  fate: run aref and vref as regular tests
  mpegaudio: sanitise compute_antialias_* names
  mpeg12: add slice-threading checks to slice-threading initializers.
  h264: copy pixel_shift between slice threading contexts.
  mdec: enable frame-level multithreading.
  mdec.c: fix overread.

Conflicts:
libavcodec/aacdec.c
libavcodec/ac3dec.c
libavcodec/avcodec.h
libavcodec/dca.c
libavcodec/h264.c
libavcodec/mdec.c
libavcodec/mpeg12.c
libavcodec/options.c
libavcodec/version.h
libavcodec/vorbisdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
21 files changed:
1  2 
Makefile
doc/APIchanges
libavcodec/aacdec.c
libavcodec/aacsbr.c
libavcodec/aacsbr.h
libavcodec/ac3dec.c
libavcodec/avcodec.h
libavcodec/dca.c
libavcodec/fmtconvert.c
libavcodec/fmtconvert.h
libavcodec/h264.c
libavcodec/mdec.c
libavcodec/mpeg12.c
libavcodec/mpegaudiodec.c
libavcodec/mpegaudiodec_float.c
libavcodec/options.c
libavcodec/vorbisdec.c
libavcodec/x86/fmtconvert.asm
libavcodec/x86/fmtconvert_mmx.c
tests/codec-regression.sh
tests/lavfi-regression.sh

diff --cc Makefile
Simple merge
diff --cc doc/APIchanges
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -193,14 -205,11 +202,6 @@@ static av_cold int ac3_decode_init(AVCo
      }
      s->downmixed = 1;
  
-     if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) {
-         avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
-         s->mul_bias = 1.0f;
-     } else {
-         avctx->sample_fmt = AV_SAMPLE_FMT_S16;
-         /* set scale value for float to int16 conversion */
-         s->mul_bias = 32767.0f;
-     }
 -    /* allocate context input buffer */
 -        s->input_buffer = av_mallocz(AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
 -        if (!s->input_buffer)
 -            return AVERROR(ENOMEM);
 -
      return 0;
  }
  
@@@ -1295,10 -1304,9 +1296,10 @@@ static int ac3_decode_frame(AVCodecCont
      const uint8_t *buf = avpkt->data;
      int buf_size = avpkt->size;
      AC3DecodeContext *s = avctx->priv_data;
-     float *out_samples_flt = (float *)data;
-     int16_t *out_samples = (int16_t *)data;
+     float   *out_samples_flt = data;
+     int16_t *out_samples_s16 = data;
      int blk, ch, err;
 +    int data_size_orig, data_size_tmp;
      const uint8_t *channel_map;
      const float *output[AC3_MAX_CHANNELS];
  
      channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];
      for (ch = 0; ch < s->out_channels; ch++)
          output[ch] = s->output[channel_map[ch]];
-     data_size_tmp *= avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? sizeof(*out_samples_flt) : sizeof(*out_samples);
 +    data_size_tmp = s->num_blocks * 256 * avctx->channels;
++    data_size_tmp *= avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? sizeof(*out_samples_flt) : sizeof(*out_samples_s16);
 +    if (data_size_orig < data_size_tmp)
 +        return -1;
 +    *data_size = data_size_tmp;
      for (blk = 0; blk < s->num_blocks; blk++) {
          if (!err && decode_audio_block(s, blk)) {
              av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
              err = 1;
          }
++
          if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
-             float_interleave_noscale(out_samples_flt, output, 256, s->out_channels);
+             s->fmt_conv.float_interleave(out_samples_flt, output, 256,
+                                          s->out_channels);
              out_samples_flt += 256 * s->out_channels;
          } else {
-             s->fmt_conv.float_to_int16_interleave(out_samples, output, 256, s->out_channels);
-             out_samples += 256 * s->out_channels;
+             s->fmt_conv.float_to_int16_interleave(out_samples_s16, output, 256,
+                                                   s->out_channels);
+             out_samples_s16 += 256 * s->out_channels;
          }
      }
+     *data_size = s->num_blocks * 256 * avctx->channels *
+                  (av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8);
      return FFMIN(buf_size, s->frame_size);
  }
  
@@@ -2881,23 -2838,11 +2881,24 @@@ typedef struct AVCodecContext 
      enum AVAudioServiceType audio_service_type;
  
      /**
 -     * Used to request a sample format from the decoder.
 -     * - encoding: unused.
++     * desired sample format
++     * - encoding: Not used.
+      * - decoding: Set by user.
++     * Decoder will decode to this format if it can.
+      */
+     enum AVSampleFormat request_sample_fmt;
++
++    /**
 +     * Current statistics for PTS correction.
 +     * - decoding: maintained and used by libavcodec, not intended to be used by user apps
 +     * - encoding: unused
 +     */
 +    int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
 +    int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
 +    int64_t pts_correction_last_pts;       /// PTS of the last frame
 +    int64_t pts_correction_last_dts;       /// DTS of the last frame
 +
-     /**
-      * desired sample format
-      * - encoding: Not used.
-      * - decoding: Set by user.
-      * Decoder will decode to this format if it can.
-      */
-     enum AVSampleFormat request_sample_fmt;
 +
  } AVCodecContext;
  
  /**
Simple merge
Simple merge
Simple merge
@@@ -1939,30 -1957,22 +1939,31 @@@ static int decode_slice_header(H264Cont
          init_scan_tables(h);
          ff_h264_alloc_tables(h);
  
 -        for(i = 1; i < s->avctx->thread_count; i++) {
 -            H264Context *c;
 -            c = h->thread_context[i] = av_malloc(sizeof(H264Context));
 -            memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext));
 -            memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext));
 -            c->h264dsp = h->h264dsp;
 -            c->sps = h->sps;
 -            c->pps = h->pps;
 -            c->pixel_shift = h->pixel_shift;
 -            init_scan_tables(c);
 -            clone_tables(c, h, i);
 -        }
 -
 -        for(i = 0; i < s->avctx->thread_count; i++)
 -            if(context_init(h->thread_context[i]) < 0)
 +        if (!HAVE_THREADS || !(s->avctx->active_thread_type&FF_THREAD_SLICE)) {
 +            if (context_init(h) < 0){
 +                av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed\n");
                  return -1;
 +            }
 +        } else {
 +            for(i = 1; i < s->avctx->thread_count; i++) {
 +                H264Context *c;
 +                c = h->thread_context[i] = av_malloc(sizeof(H264Context));
 +                memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext));
 +                memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext));
 +                c->h264dsp = h->h264dsp;
 +                c->sps = h->sps;
 +                c->pps = h->pps;
++                c->pixel_shift = h->pixel_shift;
 +                init_scan_tables(c);
 +                clone_tables(c, h, i);
 +            }
 +
 +            for(i = 0; i < s->avctx->thread_count; i++)
 +                if(context_init(h->thread_context[i]) < 0){
 +                    av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed\n");
 +                    return -1;
 +                }
 +        }
      }
  
      h->frame_num= get_bits(&s->gb, h->sps.log2_max_frame_num);
@@@ -252,6 -252,6 +253,7 @@@ static av_cold int decode_init_thread_c
      return 0;
  }
  
++
  static av_cold int decode_end(AVCodecContext *avctx){
      MDECContext * const a = avctx->priv_data;
  
@@@ -2340,8 -2262,8 +2340,9 @@@ static int decode_chunks(AVCodecContex
          buf_ptr = ff_find_start_code(buf_ptr,buf_end, &start_code);
          if (start_code > 0x1ff){
              if(s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT){
 -                if((avctx->active_thread_type & FF_THREAD_SLICE) && avctx->thread_count > 1){
 +                if(HAVE_THREADS && avctx->active_thread_type&FF_THREAD_SLICE){
                      int i;
++                    assert(avctx->thread_count > 1);
  
                      avctx->execute(avctx, slice_decode_thread,  &s2->thread_context[0], NULL, s->slice_count, sizeof(void*));
                      for(i=0; i<s->slice_count; i++)
                      break;
                  }
  
 -                if((avctx->active_thread_type & FF_THREAD_SLICE) && avctx->thread_count > 1){
 +                if(HAVE_THREADS && avctx->active_thread_type&FF_THREAD_SLICE){
                      int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count;
++                    assert(avctx->thread_count > 1);
                      if(threshold <= mb_y){
                          MpegEncContext *thread_context= s2->thread_context[s->slice_count];
  
Simple merge
Simple merge
@@@ -441,7 -441,12 +441,12 @@@ static const AVOption options[]=
  {"em", "Emergency",          0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_EMERGENCY },         INT_MIN, INT_MAX, A|E, "audio_service_type"},
  {"vo", "Voice Over",         0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_VOICE_OVER },        INT_MIN, INT_MAX, A|E, "audio_service_type"},
  {"ka", "Karaoke",            0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_KARAOKE },           INT_MIN, INT_MAX, A|E, "audio_service_type"},
- {"request_sample_fmt", "sample format audio decoders should prefer", OFFSET(request_sample_fmt), FF_OPT_TYPE_INT, {.dbl = AV_SAMPLE_FMT_NONE }, AV_SAMPLE_FMT_NONE, AV_SAMPLE_FMT_NB-1, A|D},
 -{"request_sample_fmt", NULL, OFFSET(request_sample_fmt), FF_OPT_TYPE_INT, {.dbl = AV_SAMPLE_FMT_NONE }, AV_SAMPLE_FMT_NONE, AV_SAMPLE_FMT_NB-1, A|D, "request_sample_fmt"},
++{"request_sample_fmt", "sample format audio decoders should prefer", OFFSET(request_sample_fmt), FF_OPT_TYPE_INT, {.dbl = AV_SAMPLE_FMT_NONE }, AV_SAMPLE_FMT_NONE, AV_SAMPLE_FMT_NB-1, A|D, "request_sample_fmt"},
+ {"u8" , "8-bit unsigned integer", 0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_U8  }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
+ {"s16", "16-bit signed integer",  0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S16 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
+ {"s32", "32-bit signed integer",  0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S32 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
+ {"flt", "32-bit float",           0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_FLT }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
+ {"dbl", "64-bit double",          0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_DBL }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
  {NULL},
  };
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge