OSDN Git Service

Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 8 Feb 2012 23:44:20 +0000 (00:44 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 9 Feb 2012 00:27:12 +0000 (01:27 +0100)
* qatar/master:
  pixdesc: mark pseudopaletted formats with a special flag.
  avconv: switch to avcodec_encode_video2().
  libx264: implement encode2().
  libx264: split extradata writing out of encode_nals().
  lavc: add avcodec_encode_video2() that encodes from an AVFrame -> AVPacket
  cmdutils: update copyright year to 2012.
  swscale: sign-extend integer function argument to qword on x86-64.
  x86inc: support yasm -f win64 flag also.
  h264: manually save/restore XMM registers for functions using INIT_MMX.
  x86inc: allow manual use of WIN64_SPILL_XMM.
  aacdec: Use correct speaker order for 7.1.
  aacdec: Remove incorrect comment.
  aacdec: Simplify output configuration.
  Remove Sun medialib glue code.
  dsputil: set STRIDE_ALIGN to 16 for x86 also.
  pngdsp: swap argument inversion.

Conflicts:
cmdutils.c
configure
doc/APIchanges
ffmpeg.c
libavcodec/aacdec.c
libavcodec/dsputil.h
libavcodec/libx264.c
libavcodec/mlib/dsputil_mlib.c
libavcodec/utils.c
libavfilter/vf_scale.c
libavutil/avutil.h
libswscale/mlib/yuv2rgb_mlib.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
32 files changed:
1  2 
configure
doc/APIchanges
ffmpeg.c
libavcodec/Makefile
libavcodec/aacdec.c
libavcodec/aacdectab.h
libavcodec/avcodec.h
libavcodec/dsputil.c
libavcodec/dsputil.h
libavcodec/imgconvert.c
libavcodec/libx264.c
libavcodec/mpegvideo.c
libavcodec/mpegvideo.h
libavcodec/options.c
libavcodec/rawdec.c
libavcodec/utils.c
libavcodec/version.h
libavcodec/x86/h264_idct.asm
libavcodec/x86/h264_intrapred.asm
libavfilter/vf_crop.c
libavfilter/vf_pixdesctest.c
libavfilter/vf_scale.c
libavutil/audioconvert.h
libavutil/avutil.h
libavutil/imgutils.c
libavutil/pixdesc.c
libavutil/pixdesc.h
libavutil/x86/x86inc.asm
libswscale/Makefile
libswscale/swscale_internal.h
libswscale/x86/output.asm
libswscale/yuv2rgb.c

diff --cc configure
+++ b/configure
@@@ -204,8 -194,6 +204,7 @@@ External library support
    --enable-libxavs         enable AVS encoding via xavs [no]
    --enable-libxvid         enable Xvid encoding via xvidcore,
                             native MPEG-4/Xvid encoder exists [no]
-   --enable-mlib            enable Sun medialib [no]
 +  --enable-openal          enable OpenAL 1.1 capture support [no]
    --enable-openssl         enable openssl [no]
    --enable-zlib            enable zlib [autodetect]
  
@@@ -3174,12 -2965,6 +3172,11 @@@ enabled libx264    && require  libx264 
                          die "ERROR: libx264 version must be >= 0.118."; }
  enabled libxavs    && require  libxavs xavs.h xavs_encoder_encode -lxavs
  enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
- enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
 +enabled openal     && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
 +                        check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } ||
 +                        die "ERROR: openal not found"; } &&
 +                      { check_cpp_condition "AL/al.h" "defined(AL_VERSION_1_1)" ||
 +                        die "ERROR: openal version must be 1.1 or compatible"; }
  enabled openssl    && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
                          check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
                          check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
diff --cc doc/APIchanges
@@@ -13,18 -13,12 +13,24 @@@ libavutil:   2011-04-1
  
  API changes, most recent first:
  
 +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-02-xx - xxxxxxx - lavu 51.22.1 - pixdesc.h
+   Add PIX_FMT_PSEUDOPAL flag.
+ 2012-02-01 - xxxxxxx - lavc 54.01.0
+   Add avcodec_encode_video2() and deprecate avcodec_encode_video().
  2012-02-01 - 316fc74 - lavc 54.01.0
    Add av_fast_padded_malloc() as alternative for av_realloc() when aligned
    memory is required. The buffer will always have FF_INPUT_BUFFER_PADDING_SIZE
diff --cc ffmpeg.c
+++ b/ffmpeg.c
@@@ -1385,9 -1292,7 +1385,6 @@@ static void do_subtitle_out(AVFormatCon
      }
  }
  
- static int bit_buffer_size = 1024 * 256;
- static uint8_t *bit_buffer = NULL;
 -#if !CONFIG_AVFILTER
  static void do_video_resample(OutputStream *ost,
                                InputStream *ist,
                                AVFrame *in_picture,
@@@ -1513,7 -1409,12 +1510,9 @@@ static void do_video_out(AVFormatContex
      for (i = 0; i < nb_frames; i++) {
          AVPacket pkt;
          av_init_packet(&pkt);
+         pkt.data = NULL;
+         pkt.size = 0;
  
 -        if (!check_recording_time(ost))
 -            return;
 -
          if (s->oformat->flags & AVFMT_RAWPICTURE &&
              enc->codec->id == CODEC_ID_RAWVIDEO) {
              /* raw pictures are written as AVPicture structure to
                  exit_program(1);
              }
  
-             if (ret > 0) {
-                 pkt.data = bit_buffer;
-                 pkt.size = ret;
-                 if (!(enc->codec->capabilities & CODEC_CAP_DELAY))
-                     pkt.pts = av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
-                 if (enc->coded_frame->pts != AV_NOPTS_VALUE)
-                     pkt.pts = av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
+             if (got_packet) {
++                if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY))
++                    pkt.pts = ost->sync_opts;
++
+                 if (pkt.pts != AV_NOPTS_VALUE)
+                     pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
+                 if (pkt.dts != AV_NOPTS_VALUE)
+                     pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
  
-                 if (enc->coded_frame->key_frame)
-                     pkt.flags |= AV_PKT_FLAG_KEY;
 +                if (format_video_sync == VSYNC_DROP)
 +                    pkt.pts = pkt.dts = AV_NOPTS_VALUE;
++
                  write_frame(s, &pkt, ost);
--                *frame_size = ret;
--                video_size += ret;
++                *frame_size = pkt.size;
++                video_size += pkt.size;
  
                  /* if two pass, output log */
                  if (ost->logfile && enc->stats_out) {
@@@ -1827,9 -1709,7 +1825,7 @@@ static void flush_encoders(OutputStrea
                      av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
                      exit_program(1);
                  }
--                video_size += ret;
-                 if (enc->coded_frame && enc->coded_frame->key_frame)
-                     pkt.flags |= AV_PKT_FLAG_KEY;
++                video_size += pkt.size;
                  if (ost->logfile && enc->stats_out) {
                      fprintf(ost->logfile, "%s", enc->stats_out);
                  }
@@@ -2657,30 -2489,8 +2653,17 @@@ static int transcode_init(OutputFile *o
                      }
                      codec->stats_in = logbuffer;
                  }
 +                if (codec->flags & CODEC_FLAG_PASS1) {
 +                    f = fopen(logfilename, "wb");
 +                    if (!f) {
 +                        av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n",
 +                               logfilename, strerror(errno));
 +                        exit_program(1);
 +                    }
 +                    ost->logfile = f;
 +                }
              }
          }
-         if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
-             /* maximum video buffer size is 8-bytes per pixel, plus DPX header size (1664)*/
-             int size        = codec->width * codec->height;
-             bit_buffer_size = FFMAX(bit_buffer_size, 9*size + 10000);
-         }
-     }
-     if (!bit_buffer)
-         bit_buffer = av_malloc(bit_buffer_size);
-     if (!bit_buffer) {
-         av_log(NULL, AV_LOG_ERROR, "Cannot allocate %d bytes output buffer\n",
-                bit_buffer_size);
-         return AVERROR(ENOMEM);
      }
  
      /* open each encoder */
@@@ -716,10 -662,7 +716,8 @@@ OBJS-$(CONFIG_TEXT2MOVSUB_BSF
  # thread libraries
  OBJS-$(HAVE_PTHREADS)                  += pthread.o
  OBJS-$(HAVE_W32THREADS)                += pthread.o
 +OBJS-$(HAVE_OS2THREADS)                += pthread.o
  
- OBJS-$(CONFIG_MLIB)                    += mlib/dsputil_mlib.o           \
  # inverse.o contains the ff_inverse table definition, which is used by
  # the FASTDIV macro (from libavutil); since referencing the external
  # table has a negative effect on performance, copy it in libavcodec as
@@@ -2170,15 -2147,6 +2167,15 @@@ static int aac_decode_frame_int(AVCodec
          elem_id = get_bits(gb, 4);
  
          if (elem_type < TYPE_DSE) {
-                 if (output_configure(ac, ac->che_pos, new_che_pos, 2, OC_TRIAL_FRAME)<0)
 +            if (!ac->tags_mapped && elem_type == TYPE_CPE && ac->m4ac.chan_config==1) {
 +                enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]= {0};
 +                ac->m4ac.chan_config=2;
 +
 +                if (set_default_channel_config(ac->avctx, new_che_pos, 2)<0)
 +                    return -1;
++                if (output_configure(ac, new_che_pos, 2, OC_TRIAL_FRAME)<0)
 +                    return -1;
 +            }
              if (!(che=get_che(ac, elem_type, elem_id))) {
                  av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",
                         elem_type, elem_id);
              if ((err = decode_pce(avctx, &ac->m4ac, new_che_pos, gb)))
                  break;
              if (ac->output_configured > OC_TRIAL_PCE)
 -                av_log(avctx, AV_LOG_ERROR,
 -                       "Not evaluating a further program_config_element as this construct is dubious at best.\n");
 -            else
 -                err = output_configure(ac, new_che_pos, 0, OC_TRIAL_PCE);
 +                av_log(avctx, AV_LOG_INFO,
 +                       "Evaluating a further program_config_element.\n");
-             err = output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_PCE);
++            err = output_configure(ac, new_che_pos, 0, OC_TRIAL_PCE);
 +            if (!err)
 +                ac->m4ac.chan_config = 0;
              break;
          }
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -124,37 -114,16 +123,35 @@@ static int encode_nals(AVCodecContext *
          p += nals[i].i_payload;
      }
  
-     return p - buf;
+     return 1;
  }
  
- static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
-                       int orig_bufsize, void *data)
 +static int avfmt2_num_planes(int avfmt)
 +{
 +    switch (avfmt) {
 +    case PIX_FMT_YUV420P:
 +    case PIX_FMT_YUVJ420P:
 +    case PIX_FMT_YUV420P9:
 +    case PIX_FMT_YUV420P10:
 +    case PIX_FMT_YUV444P:
 +        return 3;
 +
 +    case PIX_FMT_BGR24:
 +    case PIX_FMT_RGB24:
 +        return 1;
 +
 +    default:
 +        return 3;
 +    }
 +}
 +
+ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
+                       int *got_packet)
  {
      X264Context *x4 = ctx->priv_data;
-     AVFrame *frame = data;
      x264_nal_t *nal;
-     int nnal, i;
+     int nnal, i, ret;
      x264_picture_t pic_out;
-     int bufsize;
  
      x264_picture_init( &x4->pic );
      x4->pic.img.i_csp   = x4->params.i_csp;
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1132,16 -1045,96 +1124,96 @@@ int attribute_align_arg avcodec_encode_
          av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
          return -1;
      }
-     if(av_image_check_size(avctx->width, avctx->height, 0, avctx))
-         return -1;
-     if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
-         int ret = avctx->codec->encode(avctx, buf, buf_size, pict);
-         avctx->frame_number++;
-         emms_c(); //needed to avoid an emms_c() call before every return;
  
-         return ret;
-     }else
+     av_init_packet(&pkt);
+     pkt.data = buf;
+     pkt.size = buf_size;
+     ret = avcodec_encode_video2(avctx, &pkt, pict, &got_packet);
+     if (!ret && got_packet && avctx->coded_frame) {
+         avctx->coded_frame->pts       = pkt.pts;
+         avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
+     }
+     /* free any side data since we cannot return it */
+     if (pkt.side_data_elems > 0) {
+         int i;
+         for (i = 0; i < pkt.side_data_elems; i++)
+             av_free(pkt.side_data[i].data);
+         av_freep(&pkt.side_data);
+         pkt.side_data_elems = 0;
+     }
+     return ret ? ret : pkt.size;
+ }
+ #endif
+ #define MAX_CODED_FRAME_SIZE(width, height)\
 -    (8*(width)*(height) + FF_MIN_BUFFER_SIZE)
++    (9*(width)*(height) + FF_MIN_BUFFER_SIZE)
+ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
+                                               AVPacket *avpkt,
+                                               const AVFrame *frame,
+                                               int *got_packet_ptr)
+ {
+     int ret;
+     int user_packet = !!avpkt->data;
+     if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) {
+         av_init_packet(avpkt);
+         avpkt->size     = 0;
+         *got_packet_ptr = 0;
          return 0;
 -                avpkt->flags |= AV_PKT_FLAG_KEY*avctx->coded_frame->key_frame;
+     }
+     if (av_image_check_size(avctx->width, avctx->height, 0, avctx))
+         return AVERROR(EINVAL);
+     if (avctx->codec->encode2) {
+         *got_packet_ptr = 0;
+         ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
+         if (!ret) {
+             if (!*got_packet_ptr)
+                 avpkt->size = 0;
+             else if (!(avctx->codec->capabilities & CODEC_CAP_DELAY))
+                 avpkt->pts = avpkt->dts = frame->pts;
+         }
+     } else {
+         /* for compatibility with encoders not supporting encode2(), we need to
+            allocate a packet buffer if the user has not provided one or check
+            the size otherwise */
+         int buf_size = avpkt->size;
+         if (!user_packet)
+             buf_size = MAX_CODED_FRAME_SIZE(avctx->width, avctx->height);
+         if ((ret = ff_alloc_packet(avpkt, buf_size)))
+             return ret;
+         /* encode the frame */
+         ret = avctx->codec->encode(avctx, avpkt->data, avpkt->size, frame);
+         if (ret >= 0) {
+             if (!ret) {
+                 /* no output. if the packet data was allocated by libavcodec,
+                    free it */
+                 if (!user_packet)
+                     av_freep(&avpkt->data);
+             } else if (avctx->coded_frame) {
+                 avpkt->pts    = avctx->coded_frame->pts;
++                avpkt->flags |= AV_PKT_FLAG_KEY*!!avctx->coded_frame->key_frame;
+             }
+             avpkt->size     = ret;
+             *got_packet_ptr = (ret > 0);
+             ret             = 0;
+         }
+     }
+     if (!ret)
+         avctx->frame_number++;
+     emms_c();
+     return ret;
  }
  
  int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -212,8 -208,8 +212,9 @@@ static int config_props(AVFilterLink *o
             outlink->w, outlink->h, av_pix_fmt_descriptors[outlink->format].name,
             scale->flags);
  
-     scale->input_is_pal = av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL;
+     scale->input_is_pal = av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL ||
+                           av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PSEUDOPAL;
 +    if (outfmt == PIX_FMT_PAL8) outfmt = PIX_FMT_BGR8;
  
      if (scale->sws)
          sws_freeContext(scale->sws);
Simple merge
   */
  
  #define LIBAVUTIL_VERSION_MAJOR 51
 -#define LIBAVUTIL_VERSION_MINOR 22
 -#define LIBAVUTIL_VERSION_MICRO  1
 +#define LIBAVUTIL_VERSION_MINOR 38
- #define LIBAVUTIL_VERSION_MICRO 100
++#define LIBAVUTIL_VERSION_MICRO 101
  
  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                 LIBAVUTIL_VERSION_MINOR, \
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge