OSDN Git Service

Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 26 Feb 2012 03:47:56 +0000 (04:47 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 26 Feb 2012 04:11:21 +0000 (05:11 +0100)
* qatar/master: (34 commits)
  mlp_parser: fix the channel mask value used for the top surround channel
  vorbisenc: check all allocations for failure
  roqaudioenc: return AVERROR codes instead of -1
  roqaudioenc: set correct bit rate
  roqaudioenc: use AVCodecContext.frame_size correctly.
  roqaudioenc: remove unneeded sample_fmt check
  ra144enc: use int16_t* for input samples rather than void*
  ra144enc: set AVCodecContext.coded_frame
  ra144enc: remove unneeded sample_fmt check
  nellymoserenc: set AVCodecContext.coded_frame
  nellymoserenc: improve error checking in encode_init()
  nellymoserenc: return AVERROR codes instead of -1
  libvorbis: improve error checking in oggvorbis_encode_init()
  mpegaudioenc: return AVERROR codes instead of -1
  libfaac: improve error checking and handling in Faac_encode_init()
  avutil: add AVERROR_UNKNOWN
  check for coded_frame allocation failure in several audio encoders
  audio encoders: do not set coded_frame->key_frame.
  g722enc: check for trellis data allocation error
  libspeexenc: export encoder delay through AVCodecContext.delay
  ...

Conflicts:
doc/APIchanges
libavcodec/avcodec.h
libavcodec/fraps.c
libavcodec/kgv1dec.c
libavcodec/libfaac.c
libavcodec/libgsm.c
libavcodec/libvorbis.c
libavcodec/mlp_parser.c
libavcodec/roqaudioenc.c
libavcodec/vorbisenc.c
libavutil/avutil.h
libavutil/error.c
libavutil/error.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
23 files changed:
1  2 
doc/APIchanges
libavcodec/avcodec.h
libavcodec/cdxl.c
libavcodec/fraps.c
libavcodec/kgv1dec.c
libavcodec/libfaac.c
libavcodec/libspeexenc.c
libavcodec/libvo-aacenc.c
libavcodec/libvo-amrwbenc.c
libavcodec/libvorbis.c
libavcodec/mpegaudioenc.c
libavcodec/nellymoserenc.c
libavcodec/ra144enc.c
libavcodec/roqaudioenc.c
libavcodec/utils.c
libavcodec/vorbisdec.c
libavcodec/vorbisenc.c
libavformat/matroskadec.c
libavutil/avutil.h
libavutil/error.c
libavutil/error.h
tests/Makefile
tests/ref/lavf/xwd

diff --cc doc/APIchanges
@@@ -13,28 -12,9 +13,31 @@@ libavutil:   2011-04-1
  
  API changes, most recent first:
  
 +2012-02-21 - xxxxxxx - lavc 54.4.100
 +  Add av_get_pcm_codec() function.
 +
 +2012-02-16 - xxxxxxx - libswr 0.7.100
 +  Add swr_set_matrix() function.
 +
 +2012-02-09 - xxxxxxx - lavu 51.39.100
 +  Add a new installed header libavutil/timestamp.h with timestamp
 +  utilities.
 +
 +2012-02-06 - xxxxxxx - lavu 51.38.100
 +  Add av_parse_ratio() function to parseutils.h.
 +
 +2012-02-06 - xxxxxxx - lavu 51.38.100
 +  Add AV_LOG_MAX_OFFSET macro to log.h.
 +
 +2012-02-02 - xxxxxxx - lavu 51.37.100
 +  Add public timecode helpers.
 +
 +2012-01-24 - xxxxxxx - lavfi 2.60.100
 +  Add avfilter_graph_dump.
 +
+ 2012-xx-xx - xxxxxxx - lavu 51.24.0 - error.h
+   Add AVERROR_UNKNOWN
  2012-xx-xx - xxxxxxx - lavc 54.x.x
    Add duration field to AVCodecParserContext
  
@@@ -1368,12 -1315,22 +1368,25 @@@ typedef struct AVCodecContext 
      int frame_number;   ///< audio or video frame number
  
      /**
 -     * Encoder delay.
 +     * Encoding: Number of frames delay there will be from the encoder input to
 +     *           the decoder output. (we assume the decoder matches the spec)
 +     * Decoding: Number of frames delay in addition to what a standard decoder
 +     *           as specified in the spec would produce.
+      *
+      * Video:
+      *   Number of frames the decoded output will be delayed relative to the
+      *   encoded input.
+      *
+      * Audio:
+      *   Number of "priming" samples added to the beginning of the stream
+      *   during encoding. The decoded output will be delayed by this many
+      *   samples relative to the input to the encoder. Note that this field is
+      *   purely informational and does not directly affect the pts output by
+      *   the encoder, which should always be based on the actual presentation
+      *   time, including any delay.
+      *
       * - encoding: Set by libavcodec.
 -     * - decoding: unused
 +     * - decoding: Set by libavcodec.
       */
      int delay;
  
Simple merge
@@@ -139,10 -138,8 +139,10 @@@ static int decode_frame(AVCodecContext 
      const uint32_t *buf32;
      uint32_t *luma1,*luma2,*cb,*cr;
      uint32_t offs[4];
 -    int i, j, is_chroma, planes;
 +    int i, j, is_chroma;
 +    const int planes = 3;
 +    uint8_t *out;
+     enum PixelFormat pix_fmt;
  
      header = AV_RL32(buf);
      version = header & 0xff;
          return -1;
      }
  
 -    buf+=4;
 -    if (header_size == 8)
 -        buf+=4;
 +    buf += header_size;
 +
-     avctx->pix_fmt = version & 1 ? PIX_FMT_BGR24 : PIX_FMT_YUVJ420P;
 +    if (version < 2) {
 +        unsigned needed_size = avctx->width*avctx->height*3;
 +        if (version == 0) needed_size /= 2;
 +        needed_size += header_size;
 +        if (buf_size != needed_size && buf_size != header_size) {
 +            av_log(avctx, AV_LOG_ERROR,
 +                   "Invalid frame length %d (should be %d)\n",
 +                   buf_size, needed_size);
 +            return -1;
 +        }
 +        /* bit 31 means same as previous pic */
 +        if (header & (1U<<31)) {
 +            *data_size = 0;
 +            return buf_size;
 +        }
 +    } else {
 +        /* skip frame */
 +        if (buf_size == 8) {
 +            *data_size = 0;
 +            return buf_size;
 +        }
 +        if (AV_RL32(buf) != FPS_TAG || buf_size < planes*1024 + 24) {
 +            av_log(avctx, AV_LOG_ERROR, "Fraps: error in data stream\n");
 +            return -1;
 +        }
 +        for(i = 0; i < planes; i++) {
 +            offs[i] = AV_RL32(buf + 4 + i * 4);
 +            if(offs[i] >= buf_size - header_size || (i && offs[i] <= offs[i - 1] + 1024)) {
 +                av_log(avctx, AV_LOG_ERROR, "Fraps: plane %i offset is out of bounds\n", i);
 +                return -1;
 +            }
 +        }
 +        offs[planes] = buf_size - header_size;
 +        for(i = 0; i < planes; i++) {
 +            av_fast_padded_malloc(&s->tmpbuf, &s->tmpbuf_size, offs[i + 1] - offs[i] - 1024);
 +            if (!s->tmpbuf)
 +                return AVERROR(ENOMEM);
 +        }
 +    }
 +
 +    if (f->data[0])
 +        ff_thread_release_buffer(avctx, f);
 +    f->pict_type = AV_PICTURE_TYPE_I;
 +    f->key_frame = 1;
 +    f->reference = 0;
 +    f->buffer_hints = FF_BUFFER_HINTS_VALID;
+     pix_fmt = version & 1 ? PIX_FMT_BGR24 : PIX_FMT_YUVJ420P;
+     if (avctx->pix_fmt != pix_fmt && f->data[0]) {
+         avctx->release_buffer(avctx, f);
+     }
+     avctx->pix_fmt = pix_fmt;
 +    if (ff_thread_get_buffer(avctx, f)) {
 +        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 +        return -1;
 +    }
 +
      switch(version) {
      case 0:
      default:
Simple merge
@@@ -31,13 -31,19 +31,25 @@@ typedef struct FaacAudioContext 
      faacEncHandle faac_handle;
  } FaacAudioContext;
  
 +static const int channel_maps[][6] = {
 +    { 2, 0, 1 },          //< C L R
 +    { 2, 0, 1, 3 },       //< C L R Cs
 +    { 2, 0, 1, 3, 4 },    //< C L R Ls Rs
 +    { 2, 0, 1, 4, 5, 3 }, //< C L R Ls Rs LFE
 +};
  
+ static av_cold int Faac_encode_close(AVCodecContext *avctx)
+ {
+     FaacAudioContext *s = avctx->priv_data;
+     av_freep(&avctx->coded_frame);
+     av_freep(&avctx->extradata);
+     if (s->faac_handle)
+         faacEncClose(s->faac_handle);
+     return 0;
+ }
  static av_cold int Faac_encode_init(AVCodecContext *avctx)
  {
      FaacAudioContext *s = avctx->priv_data;
Simple merge
Simple merge
Simple merge
@@@ -105,51 -96,28 +96,57 @@@ static av_cold int oggvorbis_init_encod
  
          /* variable bitrate by estimate, disable slow rate management */
          if (minrate == -1 && maxrate == -1)
-             if (vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE2_SET, NULL))
-                 return AVERROR(EINVAL); /* should not happen */
+             if ((ret = vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE2_SET, NULL)))
 -                goto error;
++                goto error; /* should not happen */
      }
  
      /* cutoff frequency */
      if (avccontext->cutoff > 0) {
          cfreq = avccontext->cutoff / 1000.0;
-         if (vorbis_encode_ctl(vi, OV_ECTL_LOWPASS_SET, &cfreq))
-             return AVERROR(EINVAL); /* should not happen */
+         if ((ret = vorbis_encode_ctl(vi, OV_ECTL_LOWPASS_SET, &cfreq)))
 -            goto error;
++            goto error; /* should not happen */
      }
  
      if (context->iblock) {
-         vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock);
+         if ((ret = vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock)))
+             goto error;
      }
  
-     return vorbis_encode_setup_init(vi);
 +    if (avccontext->channels == 3 &&
 +            avccontext->channel_layout != (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) ||
 +        avccontext->channels == 4 &&
 +            avccontext->channel_layout != AV_CH_LAYOUT_2_2 &&
 +            avccontext->channel_layout != AV_CH_LAYOUT_QUAD ||
 +        avccontext->channels == 5 &&
 +            avccontext->channel_layout != AV_CH_LAYOUT_5POINT0 &&
 +            avccontext->channel_layout != AV_CH_LAYOUT_5POINT0_BACK ||
 +        avccontext->channels == 6 &&
 +            avccontext->channel_layout != AV_CH_LAYOUT_5POINT1 &&
 +            avccontext->channel_layout != AV_CH_LAYOUT_5POINT1_BACK ||
 +        avccontext->channels == 7 &&
 +            avccontext->channel_layout != (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) ||
 +        avccontext->channels == 8 &&
 +            avccontext->channel_layout != AV_CH_LAYOUT_7POINT1) {
 +        if (avccontext->channel_layout) {
 +            char name[32];
 +            av_get_channel_layout_string(name, sizeof(name), avccontext->channels,
 +                                         avccontext->channel_layout);
 +            av_log(avccontext, AV_LOG_ERROR, "%s not supported by Vorbis: "
 +                                             "output stream will have incorrect "
 +                                             "channel layout.\n", name);
 +        } else {
 +            av_log(avccontext, AV_LOG_WARNING, "No channel layout specified. The encoder "
 +                                               "will use Vorbis channel layout for "
 +                                               "%d channels.\n", avccontext->channels);
 +        }
 +    }
 +
+     if ((ret = vorbis_encode_setup_init(vi)))
+         goto error;
+     return 0;
+ error:
+     return vorbis_error_to_averror(ret);
  }
  
  /* How many bytes are needed for a buffer of length 'l' */
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -603,8 -553,13 +603,10 @@@ int avcodec_default_reget_buffer(AVCode
          return s->get_buffer(s, pic);
      }
  
+     assert(s->pix_fmt == pic->pix_fmt);
      /* If internal buffer type return the same buffer */
      if(pic->type == FF_BUFFER_TYPE_INTERNAL) {
 -        if(s->pkt) pic->pkt_pts= s->pkt->pts;
 -        else       pic->pkt_pts= AV_NOPTS_VALUE;
 -        pic->reordered_opaque= s->reordered_opaque;
          return 0;
      }
  
Simple merge
@@@ -952,33 -998,7 +998,6 @@@ static int apply_window_and_mdct(vorbis
      return 1;
  }
  
- static av_cold int vorbis_encode_init(AVCodecContext *avccontext)
- {
-     vorbis_enc_context *venc = avccontext->priv_data;
-     if (avccontext->channels != 2) {
-         av_log(avccontext, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n");
-         return -1;
-     }
-     create_vorbis_context(venc, avccontext);
-     if (avccontext->flags & CODEC_FLAG_QSCALE)
-         venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.;
-     else
-         venc->quality = 0.03;
-     venc->quality *= venc->quality;
-     avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);
-     avccontext->frame_size     = 1 << (venc->log2_blocksize[0] - 1);
-     avccontext->coded_frame            = avcodec_alloc_frame();
-     avccontext->coded_frame->key_frame = 1;
-     return 0;
- }
--
  static int vorbis_encode_frame(AVCodecContext *avccontext,
                                 unsigned char *packets,
                                 int buf_size, void *data)
@@@ -1102,6 -1122,43 +1121,43 @@@ static av_cold int vorbis_encode_close(
      return 0 ;
  }
  
 -        av_log(avccontext, AV_LOG_ERROR, "Current Libav Vorbis encoder only supports 2 channels.\n");
+ static av_cold int vorbis_encode_init(AVCodecContext *avccontext)
+ {
+     vorbis_enc_context *venc = avccontext->priv_data;
+     int ret;
+     if (avccontext->channels != 2) {
++        av_log(avccontext, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n");
+         return -1;
+     }
+     if ((ret = create_vorbis_context(venc, avccontext)) < 0)
+         goto error;
+     if (avccontext->flags & CODEC_FLAG_QSCALE)
+         venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.;
+     else
+         venc->quality = 0.03;
+     venc->quality *= venc->quality;
+     if ((ret = put_main_header(venc, (uint8_t**)&avccontext->extradata)) < 0)
+         goto error;
+     avccontext->extradata_size = ret;
+     avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1);
+     avccontext->coded_frame = avcodec_alloc_frame();
+     if (!avccontext->coded_frame) {
+         ret = AVERROR(ENOMEM);
+         goto error;
+     }
+     return 0;
+ error:
+     vorbis_encode_close(avccontext);
+     return ret;
+ }
  AVCodec ff_vorbis_encoder = {
      .name           = "vorbis",
      .type           = AVMEDIA_TYPE_AUDIO,
Simple merge
   */
  
  #define LIBAVUTIL_VERSION_MAJOR 51
- #define LIBAVUTIL_VERSION_MINOR 40
 -#define LIBAVUTIL_VERSION_MINOR 24
 -#define LIBAVUTIL_VERSION_MICRO  0
++#define LIBAVUTIL_VERSION_MINOR 41
 +#define LIBAVUTIL_VERSION_MICRO 100
  
  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                 LIBAVUTIL_VERSION_MINOR, \
@@@ -38,9 -35,11 +38,10 @@@ int av_strerror(int errnum, char *errbu
      case AVERROR_INVALIDDATA:       errstr = "Invalid data found when processing input"     ; break;
      case AVERROR_MUXER_NOT_FOUND:   errstr = "Muxer not found"                              ; break;
      case AVERROR_OPTION_NOT_FOUND:  errstr = "Option not found"                             ; break;
 -    case AVERROR_PATCHWELCOME:      errstr = "Not yet implemented in Libav, patches welcome"; break;
 +    case AVERROR_PATCHWELCOME:      errstr = "Not yet implemented in FFmpeg, patches welcome"; break;
      case AVERROR_PROTOCOL_NOT_FOUND:errstr = "Protocol not found"                           ; break;
      case AVERROR_STREAM_NOT_FOUND:  errstr = "Stream not found"                             ; break;
 -    case AVERROR_BUG:               errstr = "Bug detected, please report the issue"        ; break;
+     case AVERROR_UNKNOWN:           errstr = "Unknown error occurred"                       ; break;
      }
  
      if (errstr) {
  #define AVERROR_INVALIDDATA        (-MKTAG( 'I','N','D','A')) ///< Invalid data found when processing input
  #define AVERROR_MUXER_NOT_FOUND    (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found
  #define AVERROR_OPTION_NOT_FOUND   (-MKTAG(0xF8,'O','P','T')) ///< Option not found
 -#define AVERROR_PATCHWELCOME       (-MKTAG( 'P','A','W','E')) ///< Not yet implemented in Libav, patches welcome
 +#define AVERROR_PATCHWELCOME       (-MKTAG( 'P','A','W','E')) ///< Not yet implemented in FFmpeg, patches welcome
  #define AVERROR_PROTOCOL_NOT_FOUND (-MKTAG(0xF8,'P','R','O')) ///< Protocol not found
  #define AVERROR_STREAM_NOT_FOUND   (-MKTAG(0xF8,'S','T','R')) ///< Stream not found
 -#define AVERROR_BUG                (-MKTAG( 'B','U','G',' ')) ///< Bug detected, please report the issue
 +
 +/**
 + * This is semantically identical to AVERROR_BUG
 + * it has been introduced in Libav after our AVERROR_BUG and with a modified value.
 + */
 +#define AVERROR_BUG2               (-MKTAG( 'B','U','G',' '))
+ #define AVERROR_UNKNOWN            (-MKTAG( 'U','N','K','N')) ///< Unknown error, typically from an external library
  
  /**
   * Put a description of the AVERROR code errnum in errbuf.
diff --cc tests/Makefile
Simple merge
@@@ -1,3 -1,3 +1,3 @@@
- 0ab6cd4fe5fe85a3f3e87508c2eadfa0 *./tests/data/images/xwd/02.xwd
 -b838561f7df803ea14dd6307a9d3c5ec *./tests/data/images/xwd/02.xwd
 -./tests/data/images/xwd/%02d.xwd CRC=0x69b329cd
 -405615 ./tests/data/images/xwd/02.xwd
++50baa5560b7d1aa3188b19c1162bf7dc *./tests/data/images/xwd/02.xwd
 +./tests/data/images/xwd/%02d.xwd CRC=0x6da01946
 +304239 ./tests/data/images/xwd/02.xwd