OSDN Git Service

Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 21 Feb 2012 01:49:41 +0000 (02:49 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 21 Feb 2012 04:10:12 +0000 (05:10 +0100)
* qatar/master: (36 commits)
  adpcmenc: Use correct frame_size for Yamaha ADPCM.
  avcodec: add ff_samples_to_time_base() convenience function to internal.h
  adx parser: set duration
  mlp parser: set duration instead of frame_size
  gsm parser: set duration
  mpegaudio parser: set duration instead of frame_size
  (e)ac3 parser: set duration instead of frame_size
  flac parser: set duration instead of frame_size
  avcodec: add duration field to AVCodecParserContext
  avutil: add av_rescale_q_rnd() to allow different rounding
  pnmdec: remove useless .pix_fmts
  libmp3lame: support float and s32 sample formats
  libmp3lame: renaming, rearrangement, alignment, and comments
  libmp3lame: use the LAME default bit rate
  libmp3lame: use avpriv_mpegaudio_decode_header() for output frame parsing
  libmp3lame: cosmetics: remove some pointless comments
  libmp3lame: convert some debugging code to av_dlog()
  libmp3lame: remove outdated comment.
  libmp3lame: do not set coded_frame->key_frame.
  libmp3lame: improve error handling in MP3lame_encode_init()
  ...

Conflicts:
doc/APIchanges
libavcodec/libmp3lame.c
libavcodec/pcxenc.c
libavcodec/pnmdec.c
libavcodec/pnmenc.c
libavcodec/sgienc.c
libavcodec/utils.c
libavformat/hls.c
libavutil/avutil.h
libswscale/x86/swscale_mmx.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
31 files changed:
1  2 
doc/APIchanges
libavcodec/Makefile
libavcodec/aac_ac3_parser.c
libavcodec/adpcmenc.c
libavcodec/avcodec.h
libavcodec/flac_parser.c
libavcodec/huffyuv.c
libavcodec/internal.h
libavcodec/libmp3lame.c
libavcodec/libspeexenc.c
libavcodec/libvorbis.c
libavcodec/mlp_parser.c
libavcodec/mpegaudio_parser.c
libavcodec/pcxenc.c
libavcodec/pnmdec.c
libavcodec/pnmenc.c
libavcodec/roqvideo.h
libavcodec/roqvideoenc.c
libavcodec/sgienc.c
libavcodec/targaenc.c
libavcodec/utils.c
libavcodec/v410enc.c
libavcodec/x86/h264_deblock.asm
libavcodec/zmbvenc.c
libavformat/hls.c
libavformat/utils.c
libavutil/avutil.h
libavutil/mathematics.c
libavutil/mathematics.h
libswscale/swscale_internal.h
libswscale/x86/swscale_template.c

diff --cc doc/APIchanges
@@@ -13,25 -13,12 +13,31 @@@ libavutil:   2011-04-1
  
  API changes, most recent first:
  
 +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 - lavc 54.x.x
+   Add duration field to AVCodecParserContext
+ 2012-02-xx - xxxxxxx - lavu 51.23.1 - mathematics.h
+   Add av_rescale_q_rnd()
  2012-02-xx - xxxxxxx - lavu 51.22.1 - pixdesc.h
    Add PIX_FMT_PSEUDOPAL flag.
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1531,9 -1482,9 +1542,9 @@@ AVCodec ff_huffyuv_encoder = 
      .id             = CODEC_ID_HUFFYUV,
      .priv_data_size = sizeof(HYuvContext),
      .init           = encode_init,
-     .encode         = encode_frame,
+     .encode2        = encode_frame,
      .close          = encode_end,
 -    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_RGB32, PIX_FMT_NONE},
 +    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_NONE},
      .long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
  };
  #endif
@@@ -1545,9 -1496,9 +1556,9 @@@ AVCodec ff_ffvhuff_encoder = 
      .id             = CODEC_ID_FFVHUFF,
      .priv_data_size = sizeof(HYuvContext),
      .init           = encode_init,
-     .encode         = encode_frame,
+     .encode2        = encode_frame,
      .close          = encode_end,
 -    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_RGB32, PIX_FMT_NONE},
 +    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_NONE},
      .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"),
  };
  #endif
Simple merge
  #include "libavutil/log.h"
  #include "libavutil/opt.h"
  #include "avcodec.h"
+ #include "internal.h"
  #include "mpegaudio.h"
- #include <lame/lame.h>
+ #include "mpegaudiodecheader.h"
  
 -#define BUFFER_SIZE (7200 + 2 * MPA_FRAME_SIZE + MPA_FRAME_SIZE / 4)
 +#define BUFFER_SIZE (7200 + 2 * MPA_FRAME_SIZE + MPA_FRAME_SIZE / 4+1000) // FIXME: Buffer size to small? Adding 1000 to make up for it.
- typedef struct Mp3AudioContext {
+ typedef struct LAMEContext {
      AVClass *class;
+     AVCodecContext *avctx;
      lame_global_flags *gfp;
-     int stereo;
      uint8_t buffer[BUFFER_SIZE];
      int buffer_index;
-     struct {
-         int *left;
-         int *right;
-     } s32_data;
      int reservoir;
- } Mp3AudioContext;
+     void *planar_samples[2];
+ } LAMEContext;
  
- static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
+ static av_cold int mp3lame_encode_close(AVCodecContext *avctx)
  {
-     Mp3AudioContext *s = avctx->priv_data;
+     LAMEContext *s = avctx->priv_data;
  
+     av_freep(&avctx->coded_frame);
+     av_freep(&s->planar_samples[0]);
+     av_freep(&s->planar_samples[1]);
+     lame_close(s->gfp);
+     return 0;
+ }
+ static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
+ {
+     LAMEContext *s = avctx->priv_data;
+     int ret;
+     s->avctx = avctx;
+     /* initialize LAME and get defaults */
+     if ((s->gfp = lame_init()) == NULL)
+         return AVERROR(ENOMEM);
+     /* channels */
      if (avctx->channels > 2) {
-         return AVERROR(EINVAL);
 +        av_log(avctx, AV_LOG_ERROR,
 +               "Invalid number of channels %d, must be <= 2\n", avctx->channels);
+         ret =  AVERROR(EINVAL);
+         goto error;
      }
+     lame_set_num_channels(s->gfp, avctx->channels);
+     lame_set_mode(s->gfp, avctx->channels > 1 ? JOINT_STEREO : MONO);
  
-     s->stereo = avctx->channels > 1 ? 1 : 0;
-     if ((s->gfp = lame_init()) == NULL)
-         goto err;
-     lame_set_in_samplerate(s->gfp, avctx->sample_rate);
+     /* sample rate */
+     lame_set_in_samplerate (s->gfp, avctx->sample_rate);
      lame_set_out_samplerate(s->gfp, avctx->sample_rate);
-     lame_set_num_channels(s->gfp, avctx->channels);
-     if (avctx->compression_level == FF_COMPRESSION_DEFAULT) {
+     /* algorithmic quality */
+     if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
          lame_set_quality(s->gfp, 5);
-     } else {
+     else
          lame_set_quality(s->gfp, avctx->compression_level);
-     }
-     lame_set_mode(s->gfp, s->stereo ? JOINT_STEREO : MONO);
-     lame_set_brate(s->gfp, avctx->bit_rate / 1000);
+     /* rate control */
      if (avctx->flags & CODEC_FLAG_QSCALE) {
-         lame_set_brate(s->gfp, 0);
          lame_set_VBR(s->gfp, vbr_default);
          lame_set_VBR_quality(s->gfp, avctx->global_quality / (float)FF_QP2LAMBDA);
+     } else {
+         if (avctx->bit_rate)
+             lame_set_brate(s->gfp, avctx->bit_rate / 1000);
      }
-     lame_set_bWriteVbrTag(s->gfp,0);
-     lame_set_disable_reservoir(s->gfp, !s->reservoir);
-     if (lame_init_params(s->gfp) < 0)
-         goto err_close;
  
-     avctx->frame_size             = lame_get_framesize(s->gfp);
+     /* do not get a Xing VBR header frame from LAME */
+     lame_set_bWriteVbrTag(s->gfp,0);
  
-     if(!(avctx->coded_frame= avcodec_alloc_frame())) {
-         lame_close(s->gfp);
+     /* bit reservoir usage */
+     lame_set_disable_reservoir(s->gfp, !s->reservoir);
  
-         return AVERROR(ENOMEM);
+     /* set specified parameters */
+     if (lame_init_params(s->gfp) < 0) {
+         ret = -1;
+         goto error;
      }
  
-     if(AV_SAMPLE_FMT_S32 == avctx->sample_fmt && s->stereo) {
-         int nelem = 2 * avctx->frame_size;
-         if(! (s->s32_data.left = av_malloc(nelem * sizeof(int)))) {
-             av_freep(&avctx->coded_frame);
-             lame_close(s->gfp);
+     avctx->frame_size  = lame_get_framesize(s->gfp);
+     avctx->coded_frame = avcodec_alloc_frame();
+     if (!avctx->coded_frame) {
+         ret = AVERROR(ENOMEM);
+         goto error;
+     }
  
-             return AVERROR(ENOMEM);
+     /* sample format */
+     if (avctx->sample_fmt == AV_SAMPLE_FMT_S32 ||
+         avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
+         int ch;
+         for (ch = 0; ch < avctx->channels; ch++) {
+             s->planar_samples[ch] = av_malloc(avctx->frame_size *
+                                               av_get_bytes_per_sample(avctx->sample_fmt));
+             if (!s->planar_samples[ch]) {
+                 ret = AVERROR(ENOMEM);
+                 goto error;
+             }
          }
-         s->s32_data.right = s->s32_data.left + avctx->frame_size;
      }
  
      return 0;
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -28,7 -28,7 +28,8 @@@
  
  #include "avcodec.h"
  #include "bytestream.h"
 +#include "libavutil/imgutils.h"
+ #include "internal.h"
  
  typedef struct PCXContext {
      AVFrame picture;
@@@ -101,15 -101,14 +102,15 @@@ static int pcx_encode_frame(AVCodecCont
  {
      PCXContext *s = avctx->priv_data;
      AVFrame *const pict = &s->picture;
-     const uint8_t *buf_start = buf;
-     const uint8_t *buf_end   = buf + buf_size;
+     const uint8_t *buf_end;
+     uint8_t *buf;
  
-     int bpp, nplanes, i, y, line_bytes, written;
+     int bpp, nplanes, i, y, line_bytes, written, ret, max_pkt_size;
      const uint32_t *pal = NULL;
 +    uint32_t palette256[256];
      const uint8_t *src;
  
-     *pict = *(AVFrame *)data;
+     *pict = *frame;
      pict->pict_type = AV_PICTURE_TYPE_I;
      pict->key_frame = 1;
  
Simple merge
@@@ -20,6 -20,8 +20,7 @@@
   */
  
  #include "avcodec.h"
 -#include "bytestream.h"
+ #include "internal.h"
  #include "pnm.h"
  
  
Simple merge
Simple merge
@@@ -46,12 -47,12 +47,12 @@@ static int encode_frame(AVCodecContext 
  {
      SgiContext *s = avctx->priv_data;
      AVFrame * const p = &s->picture;
-     uint8_t *offsettab, *lengthtab, *in_buf, *encode_buf;
-     int x, y, z, length, tablesize;
+     uint8_t *offsettab, *lengthtab, *in_buf, *encode_buf, *buf;
+     int x, y, z, length, tablesize, ret;
 -    unsigned int width, height, depth, dimension;
 +    unsigned int width, height, depth, dimension, bytes_per_channel, pixmax, put_be;
-     unsigned char *orig_buf = buf, *end_buf = buf + buf_size;
+     unsigned char *end_buf;
  
-     *p = *(AVFrame*)data;
+     *p = *frame;
      p->pict_type = AV_PICTURE_TYPE_I;
      p->key_frame = 1;
  
@@@ -202,11 -176,7 +213,11 @@@ AVCodec ff_sgi_encoder = 
      .id             = CODEC_ID_SGI,
      .priv_data_size = sizeof(SgiContext),
      .init           = encode_init,
-     .encode         = encode_frame,
+     .encode2        = encode_frame,
 -    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA, PIX_FMT_GRAY8, PIX_FMT_NONE},
 +    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA,
 +                                          PIX_FMT_RGB48LE, PIX_FMT_RGB48BE,
 +                                          PIX_FMT_RGBA64LE, PIX_FMT_RGBA64BE,
 +                                          PIX_FMT_GRAY16LE, PIX_FMT_GRAY16BE,
 +                                          PIX_FMT_GRAY8, PIX_FMT_NONE},
      .long_name= NULL_IF_CONFIG_SMALL("SGI image"),
  };
Simple merge
@@@ -1127,12 -1016,8 +1125,11 @@@ int attribute_align_arg avcodec_encode_
          /* fabricate frame pts from sample count.
             this is needed because the avcodec_encode_audio() API does not have
             a way for the user to provide pts */
 -        frame->pts = ff_samples_to_time_base(avctx,
 -                                             avctx->internal->sample_count);
 +        if(avctx->sample_rate && avctx->time_base.num)
-             frame->pts = av_rescale_q(avctx->internal->sample_count,
-                                   (AVRational){ 1, avctx->sample_rate },
-                                   avctx->time_base);
++            frame->pts = ff_samples_to_time_base(avctx,
++                                                avctx->internal->sample_count);
 +        else
 +            frame->pts = AV_NOPTS_VALUE;
          avctx->internal->sample_count += frame->nb_samples;
      } else {
          frame = NULL;
Simple merge
Simple merge
Simple merge
@@@ -609,16 -609,13 +609,13 @@@ start
          if (var->needed && !var->pkt.data) {
              while (1) {
                  int64_t ts_diff;
+                 AVStream *st;
                  ret = av_read_frame(var->ctx, &var->pkt);
                  if (ret < 0) {
-                     if (!url_feof(&var->pb)) {
 -                    if (!var->pb.eof_reached)
++                    if (!url_feof(&var->pb))
                          return ret;
-                     } else {
-                         if ((var->cur_seq_no - var->start_seq_no) == (var->n_segments)) {
-                             return AVERROR_EOF;
-                         }
-                     }
                      reset_packet(&var->pkt);
+                     break;
                  } else {
                      if (c->first_timestamp == AV_NOPTS_VALUE)
                          c->first_timestamp = var->pkt.dts;
@@@ -942,11 -885,11 +942,10 @@@ static void compute_pkt_fields(AVFormat
          compute_frame_duration(&num, &den, st, pc, pkt);
          if (den && num) {
              pkt->duration = av_rescale_rnd(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num, AV_ROUND_DOWN);
--
--            if(pkt->duration != 0 && s->packet_buffer)
--                update_initial_durations(s, st, pkt);
          }
      }
++    if(pkt->duration != 0 && s->packet_buffer)
++        update_initial_durations(s, st, pkt);
  
      /* correct timestamps with byte offset if demuxers only have timestamps
         on packet boundaries */
   */
  
  #define LIBAVUTIL_VERSION_MAJOR 51
- #define LIBAVUTIL_VERSION_MINOR 39
 -#define LIBAVUTIL_VERSION_MINOR 23
 -#define LIBAVUTIL_VERSION_MICRO  1
++#define LIBAVUTIL_VERSION_MINOR 40
 +#define LIBAVUTIL_VERSION_MICRO 100
  
  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                 LIBAVUTIL_VERSION_MINOR, \
Simple merge
Simple merge
@@@ -421,8 -417,6 +423,7 @@@ typedef struct SwsContext 
  #if HAVE_VIS
      DECLARE_ALIGNED(8, uint64_t, sparc_coeffs)[10];
  #endif
-     int32_t alpMmxFilter[4 * MAX_FILTER_SIZE];
 +    int use_mmx_vfilter;
  
      /* function pointers for swScale() */
      yuv2planar1_fn yuv2plane1;
Simple merge