Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 8 Jun 2011 01:56:36 +0000 (03:56 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 8 Jun 2011 03:25:28 +0000 (05:25 +0200)
* qatar/master: (28 commits)
  Remove some non-compiling debug messages.
  ffplay: Fix non-compiling debug printf and replace it by av_dlog.
  H264: x86 predict init cosmetics.
  ac3enc: Fix linking of AC-3 encoder without the E-AC-3 encoder.
  Move E-AC-3 encoder functions to a separate eac3enc.c file.
  ac3enc: remove convenience macro, #define DEBUG
  ac3enc: remove unused #define
  vc1: re-initialize tables after width/height change.
  APIchanges: fill-in git commit hash for av_get_bytes_per_sample() addition
  samplefmt: add av_get_bytes_per_sample()
  iirfilter: fix biquad filter coefficients.
  swscale: remove duplicate conversion routine in swScale().
  swscale: add yuv2planar/packed function typedefs.
  swscale: integrate yuv2nv12X_C into yuv2yuvX() function pointers.
  swscale: reindent x86 init code.
  swscale: extract SWS_FULL_CHR_H_INT conditional into init code.
  swscale: cosmetics.
  swscale: remove alp/chr/lumSrcOffset.
  swscale: un-special-case yuv2yuvX16_c().
  shorten: Remove stray DEBUG #define and corresponding av_dlog statement.
  ...

Conflicts:
doc/APIchanges
libavcodec/ac3enc.c
libavutil/avutil.h
libavutil/samplefmt.c
libswscale/swscale.c
libswscale/swscale_internal.h
libswscale/x86/swscale_template.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
41 files changed:
1  2 
configure
doc/APIchanges
ffplay.c
libavcodec/Makefile
libavcodec/aac_tablegen.h
libavcodec/ac3.h
libavcodec/ac3enc.c
libavcodec/ac3enc.h
libavcodec/bitstream.c
libavcodec/dnxhdenc.h
libavcodec/dv.c
libavcodec/dvbsub_parser.c
libavcodec/dvbsubdec.c
libavcodec/iirfilter.c
libavcodec/mlpdsp.c
libavcodec/pgssubdec.c
libavcodec/ppc/h264_template_altivec.c
libavcodec/shorten.c
libavcodec/v210enc.c
libavcodec/vc1dec.c
libavcodec/vorbisdec.c
libavcodec/x86/h264_intrapred_init.c
libavformat/avidec.c
libavformat/mmsh.c
libavformat/mov.c
libavformat/mpeg.c
libavformat/rtspdec.c
libavutil/audioconvert.c
libavutil/avutil.h
libavutil/eval.c
libavutil/imgutils.c
libavutil/imgutils.h
libavutil/inverse.c
libavutil/parseutils.c
libavutil/parseutils.h
libavutil/samplefmt.c
libavutil/samplefmt.h
libswscale/ppc/swscale_altivec.c
libswscale/swscale.c
libswscale/swscale_internal.h
libswscale/x86/swscale_template.c

diff --cc configure
Simple merge
diff --cc doc/APIchanges
@@@ -13,43 -13,10 +13,47 @@@ libavutil:   2011-04-1
  
  API changes, most recent first:
  
 +2011-06-06 - xxxxxx - lavfi 2.14.0 - AVFilterBufferRefAudioProps
 +  Remove AVFilterBufferRefAudioProps.size, and use nb_samples in
 +  avfilter_get_audio_buffer() and avfilter_default_get_audio_buffer() in
 +  place of size.
 +
 +2011-06-06 - xxxxxx - lavu 51.6.0 - av_samples_alloc()
 +  Switch nb_channels and nb_samples parameters order in
 +  av_samples_alloc().
 +
 +2011-06-06 - xxxxxx - lavu 51.5.0 - av_samples_*
 +  Change the data layout created by av_samples_fill_arrays() and
 +  av_samples_alloc().
 +
 +2011-06-06 - xxxxxx - lavfi 2.13.0 - vsrc_buffer.h
 +  Make av_vsrc_buffer_add_video_buffer_ref() accepts an additional
 +  flags parameter in input.
 +
 +2011-06-03 - xxxxxx - lavfi 2.12.0 - avfilter_link_free()
 +  Add avfilter_link_free() function.
 +
 +2011-05-28 - xxxxxx - lavu 51.3.0 - pixdesc.h
 +  Add av_get_pix_fmt_name() in libavutil/pixdesc.h, and deprecate
 +  avcodec_get_pix_fmt_name() in libavcodec/avcodec.h in its favor.
 +
 +2011-05-22 - xxxxxx - lavf 53.2.0 - avformat.h
 +  Introduce avformat_alloc_output_context2() and deprecate
 +  avformat_alloc_output_context().
 +
 +2011-05-22 - xxxxxx - lavfi 2.10.0 - vsrc_buffer.h
 +  Make libavfilter/vsrc_buffer.h public.
 +
 +2011-05-XX - XXXXXX - lavfi 2.8.0 - avcodec.h
 +  Add av_vsrc_buffer_add_frame() to libavfilter/avcodec.h.
 +
 +2011-05-XX - XXXXXX - lavfi 2.6.0 - avcodec.h
 +  Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h.
 +
+ 2011-06-07 - a6703fa - lavu 51.4.0 - av_get_bytes_per_sample()
+   Add av_get_bytes_per_sample() in libavutil/samplefmt.h.
+   Deprecate av_get_bits_per_sample_fmt().
  2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h
    Add av_opt_free convenience function.
  
diff --cc ffplay.c
Simple merge
Simple merge
Simple merge
@@@ -131,48 -129,8 +131,47 @@@ typedef enum 
      EAC3_FRAME_TYPE_RESERVED
  } EAC3FrameType;
  
 +/**
 + * Encoding Options used by AVOption.
 + */
 +typedef struct AC3EncOptions {
 +    /* AC-3 metadata options*/
 +    int dialogue_level;
 +    int bitstream_mode;
 +    float center_mix_level;
 +    float surround_mix_level;
 +    int dolby_surround_mode;
 +    int audio_production_info;
 +    int mixing_level;
 +    int room_type;
 +    int copyright;
 +    int original;
 +    int extended_bsi_1;
 +    int preferred_stereo_downmix;
 +    float ltrt_center_mix_level;
 +    float ltrt_surround_mix_level;
 +    float loro_center_mix_level;
 +    float loro_surround_mix_level;
 +    int extended_bsi_2;
 +    int dolby_surround_ex_mode;
 +    int dolby_headphone_mode;
 +    int ad_converter_type;
 +
 +    /* other encoding options */
 +    int allow_per_frame_metadata;
 +    int stereo_rematrixing;
 +    int channel_coupling;
 +    int cpl_start;    
 +} AC3EncOptions;
 +
  void ff_ac3_common_init(void);
  
 +extern const int64_t ff_ac3_channel_layouts[];
 +extern const AVOption ff_ac3_options[];
 +
 +extern AVCodec ff_ac3_float_encoder;
 +extern AVCodec ff_ac3_fixed_encoder;
 +
  /**
   * Calculate the log power-spectral density of the input signal.
   * This gives a rough estimate of signal power in the frequency domain by using
  #include "ac3.h"
  #include "audioconvert.h"
  #include "fft.h"
- #ifndef CONFIG_AC3ENC_FLOAT
- #define CONFIG_AC3ENC_FLOAT 0
- #endif
- /** Maximum number of exponent groups. +1 for separate DC exponent. */
- #define AC3_MAX_EXP_GROUPS 85
- #if CONFIG_AC3ENC_FLOAT
- #define MAC_COEF(d,a,b) ((d)+=(a)*(b))
- typedef float SampleType;
- typedef float CoefType;
- typedef float CoefSumType;
- #else
- #define MAC_COEF(d,a,b) MAC64(d,a,b)
- typedef int16_t SampleType;
- typedef int32_t CoefType;
- typedef int64_t CoefSumType;
- #endif
- typedef struct AC3MDCTContext {
-     const SampleType *window;           ///< MDCT window function
-     FFTContext fft;                     ///< FFT context for MDCT calculation
- } AC3MDCTContext;
- /**
-  * Data for a single audio block.
-  */
- typedef struct AC3Block {
-     CoefType **mdct_coef;                       ///< MDCT coefficients
-     int32_t  **fixed_coef;                      ///< fixed-point MDCT coefficients
-     uint8_t  **exp;                             ///< original exponents
-     uint8_t  **grouped_exp;                     ///< grouped exponents
-     int16_t  **psd;                             ///< psd per frequency bin
-     int16_t  **band_psd;                        ///< psd per critical band
-     int16_t  **mask;                            ///< masking curve
-     uint16_t **qmant;                           ///< quantized mantissas
-     uint8_t  **cpl_coord_exp;                   ///< coupling coord exponents           (cplcoexp)
-     uint8_t  **cpl_coord_mant;                  ///< coupling coord mantissas           (cplcomant)
-     uint8_t  coeff_shift[AC3_MAX_CHANNELS];     ///< fixed-point coefficient shift values
-     uint8_t  new_rematrixing_strategy;          ///< send new rematrixing flags in this block
-     int      num_rematrixing_bands;             ///< number of rematrixing bands
-     uint8_t  rematrixing_flags[4];              ///< rematrixing flags
-     int      new_cpl_strategy;                  ///< send new coupling strategy
-     int      cpl_in_use;                        ///< coupling in use for this block     (cplinu)
-     uint8_t  channel_in_cpl[AC3_MAX_CHANNELS];  ///< channel in coupling                (chincpl)
-     int      num_cpl_channels;                  ///< number of channels in coupling
-     uint8_t  new_cpl_coords;                    ///< send new coupling coordinates      (cplcoe)
-     uint8_t  cpl_master_exp[AC3_MAX_CHANNELS];  ///< coupling coord master exponents    (mstrcplco)
-     int      new_snr_offsets;                   ///< send new SNR offsets
-     int      new_cpl_leak;                      ///< send new coupling leak info
-     int      end_freq[AC3_MAX_CHANNELS];        ///< end frequency bin                  (endmant)
- } AC3Block;
- /**
-  * AC-3 encoder private context.
-  */
- typedef struct AC3EncodeContext {
-     AVClass *av_class;                      ///< AVClass used for AVOption
-     AC3EncOptions options;                  ///< encoding options
-     PutBitContext pb;                       ///< bitstream writer context
-     DSPContext dsp;
-     AC3DSPContext ac3dsp;                   ///< AC-3 optimized functions
-     AC3MDCTContext mdct;                    ///< MDCT context
-     AC3Block blocks[AC3_MAX_BLOCKS];        ///< per-block info
-     int eac3;                               ///< indicates if this is E-AC-3 vs. AC-3
-     int bitstream_id;                       ///< bitstream id                           (bsid)
-     int bitstream_mode;                     ///< bitstream mode                         (bsmod)
-     int bit_rate;                           ///< target bit rate, in bits-per-second
-     int sample_rate;                        ///< sampling frequency, in Hz
-     int frame_size_min;                     ///< minimum frame size in case rounding is necessary
-     int frame_size;                         ///< current frame size in bytes
-     int frame_size_code;                    ///< frame size code                        (frmsizecod)
-     uint16_t crc_inv[2];
-     int64_t bits_written;                   ///< bit count    (used to avg. bitrate)
-     int64_t samples_written;                ///< sample count (used to avg. bitrate)
-     int fbw_channels;                       ///< number of full-bandwidth channels      (nfchans)
-     int channels;                           ///< total number of channels               (nchans)
-     int lfe_on;                             ///< indicates if there is an LFE channel   (lfeon)
-     int lfe_channel;                        ///< channel index of the LFE channel
-     int has_center;                         ///< indicates if there is a center channel
-     int has_surround;                       ///< indicates if there are one or more surround channels
-     int channel_mode;                       ///< channel mode                           (acmod)
-     const uint8_t *channel_map;             ///< channel map used to reorder channels
-     int center_mix_level;                   ///< center mix level code
-     int surround_mix_level;                 ///< surround mix level code
-     int ltrt_center_mix_level;              ///< Lt/Rt center mix level code
-     int ltrt_surround_mix_level;            ///< Lt/Rt surround mix level code
-     int loro_center_mix_level;              ///< Lo/Ro center mix level code
-     int loro_surround_mix_level;            ///< Lo/Ro surround mix level code
-     int cutoff;                             ///< user-specified cutoff frequency, in Hz
-     int bandwidth_code;                     ///< bandwidth code (0 to 60)               (chbwcod)
-     int start_freq[AC3_MAX_CHANNELS];       ///< start frequency bin                    (strtmant)
-     int cpl_end_freq;                       ///< coupling channel end frequency bin
-     int cpl_on;                             ///< coupling turned on for this frame
-     int cpl_enabled;                        ///< coupling enabled for all frames
-     int num_cpl_subbands;                   ///< number of coupling subbands            (ncplsubnd)
-     int num_cpl_bands;                      ///< number of coupling bands               (ncplbnd)
-     uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS];  ///< number of coeffs in each coupling band
-     int rematrixing_enabled;                ///< stereo rematrixing enabled
-     /* bitrate allocation control */
-     int slow_gain_code;                     ///< slow gain code                         (sgaincod)
-     int slow_decay_code;                    ///< slow decay code                        (sdcycod)
-     int fast_decay_code;                    ///< fast decay code                        (fdcycod)
-     int db_per_bit_code;                    ///< dB/bit code                            (dbpbcod)
-     int floor_code;                         ///< floor code                             (floorcod)
-     AC3BitAllocParameters bit_alloc;        ///< bit allocation parameters
-     int coarse_snr_offset;                  ///< coarse SNR offsets                     (csnroffst)
-     int fast_gain_code[AC3_MAX_CHANNELS];   ///< fast gain codes (signal-to-mask ratio) (fgaincod)
-     int fine_snr_offset[AC3_MAX_CHANNELS];  ///< fine SNR offsets                       (fsnroffst)
-     int frame_bits_fixed;                   ///< number of non-coefficient bits for fixed parameters
-     int frame_bits;                         ///< all frame bits except exponents and mantissas
-     int exponent_bits;                      ///< number of bits used for exponents
-     SampleType **planar_samples;
-     uint8_t *bap_buffer;
-     uint8_t *bap1_buffer;
-     CoefType *mdct_coef_buffer;
-     int32_t *fixed_coef_buffer;
-     uint8_t *exp_buffer;
-     uint8_t *grouped_exp_buffer;
-     int16_t *psd_buffer;
-     int16_t *band_psd_buffer;
-     int16_t *mask_buffer;
-     uint16_t *qmant_buffer;
-     uint8_t *cpl_coord_exp_buffer;
-     uint8_t *cpl_coord_mant_buffer;
-     uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies
-     uint8_t exp_ref_block[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< reference blocks for EXP_REUSE
-     uint8_t *ref_bap     [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap)
-     int ref_bap_set;                                         ///< indicates if ref_bap pointers have been set
-     DECLARE_ALIGNED(32, SampleType, windowed_samples)[AC3_WINDOW_SIZE];
- } AC3EncodeContext;
 +
+ #include "ac3enc.h"
+ #include "eac3enc.h"
  
  typedef struct AC3Mant {
      uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; ///< mantissa pointers for bap=1,2,4
index 0000000,0541683..d1f5548
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,214 +1,214 @@@
 -
+ /*
+  * AC-3 encoder & E-AC-3 encoder common header
+  * Copyright (c) 2000 Fabrice Bellard
+  * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
+  *
+  * This file is part of Libav.
+  *
+  * Libav is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Lesser General Public
+  * License as published by the Free Software Foundation; either
+  * version 2.1 of the License, or (at your option) any later version.
+  *
+  * Libav is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with Libav; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
+ /**
+  * @file
+  * AC-3 encoder & E-AC-3 encoder common header
+  */
+ #ifndef AVCODEC_AC3ENC_H
+ #define AVCODEC_AC3ENC_H
+ #include <stdint.h>
+ #include "ac3.h"
+ #include "ac3dsp.h"
+ #include "avcodec.h"
+ #include "dsputil.h"
+ #include "put_bits.h"
+ #include "fft.h"
+ #ifndef CONFIG_AC3ENC_FLOAT
+ #define CONFIG_AC3ENC_FLOAT 0
+ #endif
+ #if CONFIG_AC3ENC_FLOAT
+ #define MAC_COEF(d,a,b) ((d)+=(a)*(b))
+ typedef float SampleType;
+ typedef float CoefType;
+ typedef float CoefSumType;
+ #else
+ #define MAC_COEF(d,a,b) MAC64(d,a,b)
+ typedef int16_t SampleType;
+ typedef int32_t CoefType;
+ typedef int64_t CoefSumType;
+ #endif
+ typedef struct AC3MDCTContext {
+     const SampleType *window;           ///< MDCT window function
+     FFTContext fft;                     ///< FFT context for MDCT calculation
+ } AC3MDCTContext;
 -
++#if 0
+ /**
+  * Encoding Options used by AVOption.
+  */
+ typedef struct AC3EncOptions {
+     /* AC-3 metadata options*/
+     int dialogue_level;
+     int bitstream_mode;
+     float center_mix_level;
+     float surround_mix_level;
+     int dolby_surround_mode;
+     int audio_production_info;
+     int mixing_level;
+     int room_type;
+     int copyright;
+     int original;
+     int extended_bsi_1;
+     int preferred_stereo_downmix;
+     float ltrt_center_mix_level;
+     float ltrt_surround_mix_level;
+     float loro_center_mix_level;
+     float loro_surround_mix_level;
+     int extended_bsi_2;
+     int dolby_surround_ex_mode;
+     int dolby_headphone_mode;
+     int ad_converter_type;
+     /* other encoding options */
+     int allow_per_frame_metadata;
+     int stereo_rematrixing;
+     int channel_coupling;
+     int cpl_start;
+ } AC3EncOptions;
++#endif
+ /**
+  * Data for a single audio block.
+  */
+ typedef struct AC3Block {
+     CoefType **mdct_coef;                       ///< MDCT coefficients
+     int32_t  **fixed_coef;                      ///< fixed-point MDCT coefficients
+     uint8_t  **exp;                             ///< original exponents
+     uint8_t  **grouped_exp;                     ///< grouped exponents
+     int16_t  **psd;                             ///< psd per frequency bin
+     int16_t  **band_psd;                        ///< psd per critical band
+     int16_t  **mask;                            ///< masking curve
+     uint16_t **qmant;                           ///< quantized mantissas
+     uint8_t  **cpl_coord_exp;                   ///< coupling coord exponents           (cplcoexp)
+     uint8_t  **cpl_coord_mant;                  ///< coupling coord mantissas           (cplcomant)
+     uint8_t  coeff_shift[AC3_MAX_CHANNELS];     ///< fixed-point coefficient shift values
+     uint8_t  new_rematrixing_strategy;          ///< send new rematrixing flags in this block
+     int      num_rematrixing_bands;             ///< number of rematrixing bands
+     uint8_t  rematrixing_flags[4];              ///< rematrixing flags
+     int      new_cpl_strategy;                  ///< send new coupling strategy
+     int      cpl_in_use;                        ///< coupling in use for this block     (cplinu)
+     uint8_t  channel_in_cpl[AC3_MAX_CHANNELS];  ///< channel in coupling                (chincpl)
+     int      num_cpl_channels;                  ///< number of channels in coupling
+     uint8_t  new_cpl_coords;                    ///< send new coupling coordinates      (cplcoe)
+     uint8_t  cpl_master_exp[AC3_MAX_CHANNELS];  ///< coupling coord master exponents    (mstrcplco)
+     int      new_snr_offsets;                   ///< send new SNR offsets
+     int      new_cpl_leak;                      ///< send new coupling leak info
+     int      end_freq[AC3_MAX_CHANNELS];        ///< end frequency bin                  (endmant)
+ } AC3Block;
+ /**
+  * AC-3 encoder private context.
+  */
+ typedef struct AC3EncodeContext {
+     AVClass *av_class;                      ///< AVClass used for AVOption
+     AC3EncOptions options;                  ///< encoding options
+     PutBitContext pb;                       ///< bitstream writer context
+     DSPContext dsp;
+     AC3DSPContext ac3dsp;                   ///< AC-3 optimized functions
+     AC3MDCTContext mdct;                    ///< MDCT context
+     AC3Block blocks[AC3_MAX_BLOCKS];        ///< per-block info
+     int eac3;                               ///< indicates if this is E-AC-3 vs. AC-3
+     int bitstream_id;                       ///< bitstream id                           (bsid)
+     int bitstream_mode;                     ///< bitstream mode                         (bsmod)
+     int bit_rate;                           ///< target bit rate, in bits-per-second
+     int sample_rate;                        ///< sampling frequency, in Hz
+     int frame_size_min;                     ///< minimum frame size in case rounding is necessary
+     int frame_size;                         ///< current frame size in bytes
+     int frame_size_code;                    ///< frame size code                        (frmsizecod)
+     uint16_t crc_inv[2];
+     int64_t bits_written;                   ///< bit count    (used to avg. bitrate)
+     int64_t samples_written;                ///< sample count (used to avg. bitrate)
+     int fbw_channels;                       ///< number of full-bandwidth channels      (nfchans)
+     int channels;                           ///< total number of channels               (nchans)
+     int lfe_on;                             ///< indicates if there is an LFE channel   (lfeon)
+     int lfe_channel;                        ///< channel index of the LFE channel
+     int has_center;                         ///< indicates if there is a center channel
+     int has_surround;                       ///< indicates if there are one or more surround channels
+     int channel_mode;                       ///< channel mode                           (acmod)
+     const uint8_t *channel_map;             ///< channel map used to reorder channels
+     int center_mix_level;                   ///< center mix level code
+     int surround_mix_level;                 ///< surround mix level code
+     int ltrt_center_mix_level;              ///< Lt/Rt center mix level code
+     int ltrt_surround_mix_level;            ///< Lt/Rt surround mix level code
+     int loro_center_mix_level;              ///< Lo/Ro center mix level code
+     int loro_surround_mix_level;            ///< Lo/Ro surround mix level code
+     int cutoff;                             ///< user-specified cutoff frequency, in Hz
+     int bandwidth_code;                     ///< bandwidth code (0 to 60)               (chbwcod)
+     int start_freq[AC3_MAX_CHANNELS];       ///< start frequency bin                    (strtmant)
+     int cpl_end_freq;                       ///< coupling channel end frequency bin
+     int cpl_on;                             ///< coupling turned on for this frame
+     int cpl_enabled;                        ///< coupling enabled for all frames
+     int num_cpl_subbands;                   ///< number of coupling subbands            (ncplsubnd)
+     int num_cpl_bands;                      ///< number of coupling bands               (ncplbnd)
+     uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS];  ///< number of coeffs in each coupling band
+     int rematrixing_enabled;                ///< stereo rematrixing enabled
+     /* bitrate allocation control */
+     int slow_gain_code;                     ///< slow gain code                         (sgaincod)
+     int slow_decay_code;                    ///< slow decay code                        (sdcycod)
+     int fast_decay_code;                    ///< fast decay code                        (fdcycod)
+     int db_per_bit_code;                    ///< dB/bit code                            (dbpbcod)
+     int floor_code;                         ///< floor code                             (floorcod)
+     AC3BitAllocParameters bit_alloc;        ///< bit allocation parameters
+     int coarse_snr_offset;                  ///< coarse SNR offsets                     (csnroffst)
+     int fast_gain_code[AC3_MAX_CHANNELS];   ///< fast gain codes (signal-to-mask ratio) (fgaincod)
+     int fine_snr_offset[AC3_MAX_CHANNELS];  ///< fine SNR offsets                       (fsnroffst)
+     int frame_bits_fixed;                   ///< number of non-coefficient bits for fixed parameters
+     int frame_bits;                         ///< all frame bits except exponents and mantissas
+     int exponent_bits;                      ///< number of bits used for exponents
+     SampleType **planar_samples;
+     uint8_t *bap_buffer;
+     uint8_t *bap1_buffer;
+     CoefType *mdct_coef_buffer;
+     int32_t *fixed_coef_buffer;
+     uint8_t *exp_buffer;
+     uint8_t *grouped_exp_buffer;
+     int16_t *psd_buffer;
+     int16_t *band_psd_buffer;
+     int16_t *mask_buffer;
+     uint16_t *qmant_buffer;
+     uint8_t *cpl_coord_exp_buffer;
+     uint8_t *cpl_coord_mant_buffer;
+     uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies
+     uint8_t exp_ref_block[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< reference blocks for EXP_REUSE
+     uint8_t *ref_bap     [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap)
+     int ref_bap_set;                                         ///< indicates if ref_bap pointers have been set
+     DECLARE_ALIGNED(32, SampleType, windowed_samples)[AC3_WINDOW_SIZE];
+ } AC3EncodeContext;
+ #endif /* AVCODEC_AC3ENC_H */
Simple merge
Simple merge
diff --cc libavcodec/dv.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1254,10 -1206,10 +1254,10 @@@ static int avi_load_index(AVFormatConte
      if (avio_seek(pb, avi->movi_end, SEEK_SET) < 0)
          goto the_end; // maybe truncated file
  #ifdef DEBUG_SEEK
-     printf("movi_end=0x%"PRIx64"\n", avi->movi_end);
+     av_log(s, AV_LOG_DEBUG, "movi_end=0x%"PRIx64"\n", avi->movi_end);
  #endif
      for(;;) {
 -        if (pb->eof_reached)
 +        if (url_feof(pb))
              break;
          tag = avio_rl32(pb);
          size = avio_rl32(pb);
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -40,8 -40,8 +40,8 @@@
  #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
  
  #define LIBAVUTIL_VERSION_MAJOR 51
- #define LIBAVUTIL_VERSION_MINOR  6
- #define LIBAVUTIL_VERSION_MICRO  1
 -#define LIBAVUTIL_VERSION_MINOR  4
++#define LIBAVUTIL_VERSION_MINOR  7
+ #define LIBAVUTIL_VERSION_MICRO  0
  
  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                 LIBAVUTIL_VERSION_MINOR, \
   * Those FF_API_* defines are not part of public API.
   * They may change, break or disappear at any time.
   */
 +#ifndef FF_API_OLD_EVAL_NAMES
 +#define FF_API_OLD_EVAL_NAMES (LIBAVUTIL_VERSION_MAJOR < 52)
 +#endif
+ #ifndef FF_API_GET_BITS_PER_SAMPLE_FMT
+ #define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 52)
+ #endif
  
  /**
   * Return the LIBAVUTIL_VERSION_INT constant.
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -71,52 -78,4 +78,53 @@@ int av_get_bits_per_sample_fmt(enum AVS
      return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ?
          0 : sample_fmt_info[sample_fmt].bits;
  }
+ #endif
 +
 +int av_samples_fill_arrays(uint8_t *pointers[8], int linesizes[8],
 +                           uint8_t *buf, int nb_channels, int nb_samples,
 +                           enum AVSampleFormat sample_fmt, int planar, int align)
 +{
 +    int i, linesize;
 +    int sample_size = av_get_bits_per_sample_fmt(sample_fmt) >> 3;
 +
 +    if (nb_channels * (uint64_t)nb_samples * sample_size >= INT_MAX - align*(uint64_t)nb_channels)
 +        return AVERROR(EINVAL);
 +    linesize = planar ? FFALIGN(nb_samples*sample_size,             align) :
 +                        FFALIGN(nb_samples*sample_size*nb_channels, align);
 +
 +    if (pointers) {
 +        pointers[0] = buf;
 +        for (i = 1; planar && i < nb_channels; i++) {
 +            pointers[i] = pointers[i-1] + linesize;
 +        }
 +        memset(&pointers[i], 0, (8-i) * sizeof(pointers[0]));
 +    }
 +
 +    if (linesizes) {
 +        linesizes[0] = linesize;
 +        for (i = 1; planar && i < nb_channels; i++)
 +            linesizes[i] = linesizes[0];
 +        memset(&linesizes[i], 0, (8-i) * sizeof(linesizes[0]));
 +    }
 +
 +    return planar ? linesize * nb_channels : linesize;
 +}
 +
 +int av_samples_alloc(uint8_t *pointers[8], int linesizes[8],
 +                     int nb_channels, int nb_samples,
 +                     enum AVSampleFormat sample_fmt, int planar,
 +                     int align)
 +{
 +    uint8_t *buf;
 +    int size = av_samples_fill_arrays(NULL, NULL,
 +                                      NULL, nb_channels, nb_samples,
 +                                      sample_fmt, planar, align);
 +
 +    buf = av_mallocz(size);
 +    if (!buf)
 +        return AVERROR(ENOMEM);
 +
 +    return av_samples_fill_arrays(pointers, linesizes,
 +                                  buf, nb_channels, nb_samples,
 +                                  sample_fmt, planar, align);
 +}
@@@ -60,58 -60,21 +60,66 @@@ enum AVSampleFormat av_get_sample_fmt(c
   */
  char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
  
+ #if FF_API_GET_BITS_PER_SAMPLE_FMT
  /**
-  * Return sample format bits per sample.
+  * @deprecated Use av_get_bytes_per_sample() instead.
+  */
+ attribute_deprecated
+ int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
+ #endif
+ /**
+  * Return number of bytes per sample.
   *
   * @param sample_fmt the sample format
-  * @return number of bits per sample or zero if unknown for the given
+  * @return number of bytes per sample or zero if unknown for the given
   * sample format
   */
- int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
+ int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt);
  
 -#endif /* AVUTIL_SAMPLEFMT_H */
 +/**
 + * Fill channel data pointers and linesizes for samples with sample
 + * format sample_fmt.
 + *
 + * The pointers array is filled with the pointers to the samples data:
 + * for planar, set the start point of each plane's data within the buffer,
 + * for packed, set the start point of the entire buffer only.
 + *
 + * The linesize array is filled with the aligned size of each samples
 + * plane, that is linesize[i] will contain the linesize of the plane i,
 + * and will be zero for all the unused planes. All linesize values are
 + * equal.
 + *
 + * @param pointers array to be filled with the pointer for each plane, may be NULL
 + * @param linesizes array to be filled with the linesize, may be NULL
 + * @param buf the pointer to a buffer containing the samples
 + * @param nb_samples the number of samples in a single channel
 + * @param planar 1 if the samples layout is planar, 0 if it is packed
 + * @param nb_channels the number of channels
 + * @return the total size of the buffer, a negative
 + * error code in case of failure
 + */
 +int av_samples_fill_arrays(uint8_t *pointers[8], int linesizes[8],
 +                           uint8_t *buf, int nb_channels, int nb_samples,
 +                           enum AVSampleFormat sample_fmt, int planar, int align);
 +
 +/**
 + * Allocate a samples buffer for nb_samples samples, and
 + * fill pointers and linesizes accordingly.
 + * The allocated samples buffer has to be freed by using
 + * av_freep(&pointers[0]).
 + *
 + * @param nb_channels number of audio channels
 + * @param nb_samples number of samples per channel
 + * @param planar 1 if the samples layout is planar, 0 if packed,
 + * @param align the value to use for buffer size alignment
 + * @return the size in bytes required for the samples buffer, a negative
 + * error code in case of failure
 + * @see av_samples_fill_arrays()
 + */
 +int av_samples_alloc(uint8_t *pointers[8], int linesizes[8],
 +                     int nb_channels, int nb_samples,
 +                     enum AVSampleFormat sample_fmt, int planar,
 +                     int align);
 +
 +#endif /* AVCORE_SAMPLEFMT_H */
Simple merge
@@@ -377,40 -285,42 +380,40 @@@ yuv2NBPS(10, LE, 0)
  yuv2NBPS(16, BE, 1);
  yuv2NBPS(16, LE, 0);
  
- static inline void yuv2yuvX16_c(const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
+ static inline void yuv2yuvX16_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
                                  const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize,
 -                                const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW,
 +                                const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW,
                                  enum PixelFormat dstFormat)
  {
 -#define conv16(bits) \
 -    if (isBE(dstFormat)) { \
 -        yuv2yuvX ## bits ## BE_c(c, lumFilter, lumSrc, lumFilterSize, \
 -                                 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
 -                                 alpSrc, \
 -                                 dest, uDest, vDest, aDest, \
 -                                 dstW, chrDstW); \
 -    } else { \
 -        yuv2yuvX ## bits ## LE_c(c, lumFilter, lumSrc, lumFilterSize, \
 -                                 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
 -                                 alpSrc, \
 -                                 dest, uDest, vDest, aDest, \
 -                                 dstW, chrDstW); \
 -    }
 -    if (is16BPS(dstFormat)) {
 -        conv16(16);
 -    } else if (av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1 == 8) {
 -        conv16(9);
 +    if (isNBPS(dstFormat)) {
 +        const int depth = av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1+1;
 +        yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize,
 +                              chrFilter, chrUSrc, chrVSrc, chrFilterSize,
 +                              alpSrc,
 +                              dest, uDest, vDest, aDest,
 +                              dstW, chrDstW, isBE(dstFormat), depth);
      } else {
 -        conv16(10);
 +        if (isBE(dstFormat)) {
 +            yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize,
 +                                   chrFilter, chrUSrc, chrVSrc, chrFilterSize,
 +                                   alpSrc,
 +                                   dest, uDest, vDest, aDest,
 +                                   dstW, chrDstW, 1, 16);
 +        } else {
 +            yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize,
 +                                   chrFilter, chrUSrc, chrVSrc, chrFilterSize,
 +                                   alpSrc,
 +                                   dest, uDest, vDest, aDest,
 +                                   dstW, chrDstW, 0, 16);
 +        }
      }
 -#undef conv16
  }
  
 -static inline void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter,
 -                              const int16_t **lumSrc, int lumFilterSize,
 -                              const int16_t *chrFilter, const int16_t **chrUSrc,
 -                              const int16_t **chrVSrc,
 -                              int chrFilterSize, const int16_t **alpSrc,
 -                              uint8_t *dest, uint8_t *uDest, uint8_t *vDest,
 -                              uint8_t *aDest, int dstW, int chrDstW)
 +static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
 +                               const int16_t *chrFilter, const int16_t **chrUSrc,
 +                               const int16_t **chrVSrc, int chrFilterSize,
 +                               const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW,
 +                               const uint8_t *lumDither, const uint8_t *chrDither)
  {
      //FIXME Optimize (just quickly written not optimized..)
      int i;
  
  }
  
 -static inline void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter,
 -                               const int16_t **lumSrc, int lumFilterSize,
 +static inline void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
                                 const int16_t *chrFilter, const int16_t **chrUSrc,
                                 const int16_t **chrVSrc, int chrFilterSize,
-                                uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, int dstFormat,
+                                const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest,
+                                uint8_t *vDest, uint8_t *aDest,
 -                               int dstW, int chrDstW)
++                               int dstW, int chrDstW,
 +                               const uint8_t *lumDither, const uint8_t *chrDither)
  {
+     enum PixelFormat dstFormat = c->dstFormat;
      //FIXME Optimize (just quickly written not optimized..)
      int i;
      for (i=0; i<dstW; i++) {
@@@ -1148,8 -1066,18 +1155,16 @@@ static void abgrToA_c(int16_t *dst, con
      }
  }
  
 -static void rgbaToA_c(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused)
++static void rgbaToA_c(int16_t *dst, const uint8_t *src, int width, uint32_t *unused)
+ {
+     int i;
+     for (i=0; i<width; i++) {
 -        dst[i]= src[4*i+3];
++        dst[i]= src[4*i+3]<<6;
+     }
+ }
  #define BGR2UV(type, name, shr, shg, shb, shp, maskr, maskg, maskb, RU, GU, BU, RV, GV, BV, S) \
 -static void name ## _c(uint8_t *dstU, uint8_t *dstV, \
 -                       const uint8_t *src, const uint8_t *dummy, \
 -                       int width, uint32_t *unused)\
 +static  void name ## _c(int16_t *dstU, int16_t *dstV, const uint8_t *src, const uint8_t *dummy, int width, uint32_t *unused)\
  {\
      int i;\
      for (i=0; i<width; i++) {\
@@@ -1614,10 -1506,8 +1629,8 @@@ static inline void hyscale(SwsContext *
                             uint32_t *pal, int isAlpha)
  {
      void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
 -    void (*convertRange)(uint16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
 +    void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
  
-     src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset;
      if (toYV12) {
          toYV12(formatConvBuffer, src, srcW, pal);
          src= formatConvBuffer;
@@@ -1661,12 -1544,8 +1674,8 @@@ static inline void hcscale(SwsContext *
                             const int16_t *hChrFilterPos, int hChrFilterSize,
                             uint8_t *formatConvBuffer, uint32_t *pal)
  {
-     src1 += c->chrSrcOffset;
-     src2 += c->chrSrcOffset;
      if (c->chrToYV12) {
 -        uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW, 16);
 +        uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16);
          c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal);
          src1= formatConvBuffer;
          src2= buf2;
@@@ -1730,7 -1636,11 +1770,12 @@@ static int swScale(SwsContext *c, cons
      const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
      int lastDstY;
      uint32_t *pal=c->pal_yuv;
 +    int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat);
+     yuv2planar1_fn yuv2yuv1 = c->yuv2yuv1;
+     yuv2planarX_fn yuv2yuvX = c->yuv2yuvX;
+     yuv2packed1_fn yuv2packed1 = c->yuv2packed1;
+     yuv2packed2_fn yuv2packed2 = c->yuv2packed2;
+     yuv2packedX_fn yuv2packedX = c->yuv2packedX;
  
      /* vars which will change and which we need to store back in the context */
      int dstY= c->dstY;
              const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
              const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
              const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
-             if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) {
-                 const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
-                 if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
-                 c->yuv2nv12X(c,
-                              vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
-                              vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
-                              dest, uDest, dstW, chrDstW, dstFormat, lumDither, chrDither);
-             } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like
++
+             if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like
                  const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
                  if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
-                 if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
-                     yuv2yuvX16_c(vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
-                                  vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr,
-                                  chrVSrcPtr, vChrFilterSize,
-                                  alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest,
-                                  (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW,
-                                  dstFormat);
-                 } else if (vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12
+                 if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12
                      const int16_t *lumBuf = lumSrcPtr[0];
                      const int16_t *chrUBuf= chrUSrcPtr[0];
                      const int16_t *chrVBuf= chrVSrcPtr[0];
                      const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL;
-                     c->yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest,
+                     yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest,
 -                                uDest, vDest, aDest, dstW, chrDstW);
 +                                uDest, vDest, aDest, dstW, chrDstW, lumDither, chrDither);
                  } else { //General YV12
-                     c->yuv2yuvX(c,
+                     yuv2yuvX(c,
                                  vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
                                  vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr,
                                  chrVSrcPtr, vChrFilterSize,
@@@ -2133,28 -1970,14 +2102,18 @@@ static void sws_init_swScale_c(SwsConte
      }
      if (c->alpPixBuf) {
          switch (srcFormat) {
-         case PIX_FMT_RGB32  :
-         case PIX_FMT_RGB32_1:
-         case PIX_FMT_BGR32  :
-         case PIX_FMT_BGR32_1: c->alpToYV12 = abgrToA_c; break;
-         case PIX_FMT_GRAY8A : c->alpToYV12 = yuy2ToY_c; break;
-         case PIX_FMT_PAL8   : c->alpToYV12 = palToA_c; break;
+         case PIX_FMT_BGRA:
+         case PIX_FMT_RGBA:  c->alpToYV12 = rgbaToA_c; break;
+         case PIX_FMT_ABGR:
+         case PIX_FMT_ARGB:  c->alpToYV12 = abgrToA_c; break;
+         case PIX_FMT_Y400A: c->alpToYV12 = uyvyToY_c; break;
++        case PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; break;
          }
      }
  
-     switch (srcFormat) {
-     case PIX_FMT_GRAY8A :
-         c->alpSrcOffset = 1;
-         break;
-     case PIX_FMT_RGB32  :
-     case PIX_FMT_BGR32  :
-         c->alpSrcOffset = 3;
-         break;
-     }
 +    if(isAnyRGB(c->srcFormat) || c->srcFormat == PIX_FMT_PAL8)
 +        c->hScale16= hScale16_c;
 +
      if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {
          if (c->srcRange) {
              c->lumConvertRange = lumRangeFromJpeg_c;
@@@ -59,6 -57,41 +59,41 @@@ typedef int (*SwsFunc)(struct SwsContex
                         int srcStride[], int srcSliceY, int srcSliceH,
                         uint8_t* dst[], int dstStride[]);
  
 -                                int dstW, int chrDstW);
+ typedef void (*yuv2planar1_fn) (struct SwsContext *c,
+                                 const int16_t *lumSrc, const int16_t *chrUSrc,
+                                 const int16_t *chrVSrc, const int16_t *alpSrc,
+                                 uint8_t *dest,
+                                 uint8_t *uDest, uint8_t *vDest, uint8_t *aDest,
 -                                int dstW, int chrDstW);
++                                int dstW, int chrDstW, const uint8_t *lumDither, const uint8_t *chrDither);
+ typedef void (*yuv2planarX_fn) (struct SwsContext *c,
+                                 const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
+                                 const int16_t *chrFilter, const int16_t **chrUSrc,
+                                 const int16_t **chrVSrc, int chrFilterSize,
+                                 const int16_t **alpSrc,
+                                 uint8_t *dest,
+                                 uint8_t *uDest, uint8_t *vDest, uint8_t *aDest,
++                                int dstW, int chrDstW, const uint8_t *lumDither, const uint8_t *chrDither);
+ typedef void (*yuv2packed1_fn) (struct SwsContext *c,
+                                 const uint16_t *buf0,
+                                 const uint16_t *ubuf0, const uint16_t *ubuf1,
+                                 const uint16_t *vbuf0, const uint16_t *vbuf1,
+                                 const uint16_t *abuf0,
+                                 uint8_t *dest,
+                                 int dstW, int uvalpha, int dstFormat, int flags, int y);
+ typedef void (*yuv2packed2_fn) (struct SwsContext *c,
+                                 const uint16_t *buf0, const uint16_t *buf1,
+                                 const uint16_t *ubuf0, const uint16_t *ubuf1,
+                                 const uint16_t *vbuf0, const uint16_t *vbuf1,
+                                 const uint16_t *abuf0, const uint16_t *abuf1,
+                                 uint8_t *dest,
+                                 int dstW, int yalpha, int uvalpha, int y);
+ typedef void (*yuv2packedX_fn) (struct SwsContext *c,
+                                 const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
+                                 const int16_t *chrFilter, const int16_t **chrUSrc,
+                                 const int16_t **chrVSrc, int chrFilterSize,
+                                 const int16_t **alpSrc, uint8_t *dest,
+                                 int dstW, int dstY);
  /* This struct should be aligned on at least a 32-byte boundary. */
  typedef struct SwsContext {
      /**
                     int xInc, const int16_t *filter, const int16_t *filterPos,
                     int filterSize);
  
 -    void (*lumConvertRange)(uint16_t *dst, int width); ///< Color range conversion function for luma plane if needed.
 -    void (*chrConvertRange)(uint16_t *dst1, uint16_t *dst2, int width); ///< Color range conversion function for chroma planes if needed.
 +    void (*hScale16)(int16_t *dst, int dstW, const uint16_t *src, int srcW,
 +                   int xInc, const int16_t *filter, const int16_t *filterPos,
 +                   long filterSize, int shift);
 +
 +    void (*lumConvertRange)(int16_t *dst, int width); ///< Color range conversion function for luma plane if needed.
 +    void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width); ///< Color range conversion function for chroma planes if needed.
  
-     int lumSrcOffset; ///< Offset given to luma src pointers passed to horizontal input functions.
-     int chrSrcOffset; ///< Offset given to chroma src pointers passed to horizontal input functions.
-     int alpSrcOffset; ///< Offset given to alpha src pointers passed to horizontal input functions.
      int needs_hcscale; ///< Set if there are chroma planes to be converted.
  
  } SwsContext;
@@@ -2351,35 -2185,42 +2351,42 @@@ static inline void RENAME(hcscale_fast)
  
  static void RENAME(sws_init_swScale)(SwsContext *c)
  {
-     enum PixelFormat srcFormat = c->srcFormat;
-     if (!(c->flags & SWS_BITEXACT)) {
-         if (c->flags & SWS_ACCURATE_RND) {
-             c->yuv2yuv1     = RENAME(yuv2yuv1_ar    );
-             c->yuv2yuvX     = RENAME(yuv2yuvX_ar    );
-             switch (c->dstFormat) {
-             case PIX_FMT_RGB32:   c->yuv2packedX = RENAME(yuv2rgb32_X_ar);   break;
-             case PIX_FMT_BGR24:   c->yuv2packedX = RENAME(yuv2bgr24_X_ar);   break;
-             case PIX_FMT_RGB555:  c->yuv2packedX = RENAME(yuv2rgb555_X_ar);  break;
-             case PIX_FMT_RGB565:  c->yuv2packedX = RENAME(yuv2rgb565_X_ar);  break;
-             case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break;
-             default: break;
+     enum PixelFormat srcFormat = c->srcFormat,
+                      dstFormat = c->dstFormat;
 -    if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat)) {
 -        if (!(c->flags & SWS_BITEXACT)) {
++    if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && dstFormat != PIX_FMT_NV12
++        && dstFormat != PIX_FMT_NV21 && !(c->flags & SWS_BITEXACT)) {
+             if (c->flags & SWS_ACCURATE_RND) {
+                 c->yuv2yuv1 = RENAME(yuv2yuv1_ar    );
+                 c->yuv2yuvX = RENAME(yuv2yuvX_ar    );
+                 if (!(c->flags & SWS_FULL_CHR_H_INT)) {
+                     switch (c->dstFormat) {
+                     case PIX_FMT_RGB32:   c->yuv2packedX = RENAME(yuv2rgb32_X_ar);   break;
+                     case PIX_FMT_BGR24:   c->yuv2packedX = RENAME(yuv2bgr24_X_ar);   break;
+                     case PIX_FMT_RGB555:  c->yuv2packedX = RENAME(yuv2rgb555_X_ar);  break;
+                     case PIX_FMT_RGB565:  c->yuv2packedX = RENAME(yuv2rgb565_X_ar);  break;
+                     case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break;
+                     default: break;
+                     }
+                 }
+             } else {
 -                c->yuv2yuv1 = RENAME(yuv2yuv1    );
++                int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat);
++                c->yuv2yuv1 = should_dither ? RENAME(yuv2yuv1_ar    ) : RENAME(yuv2yuv1    );
+                 c->yuv2yuvX = RENAME(yuv2yuvX    );
+                 if (!(c->flags & SWS_FULL_CHR_H_INT)) {
+                     switch (c->dstFormat) {
+                     case PIX_FMT_RGB32:   c->yuv2packedX = RENAME(yuv2rgb32_X);   break;
+                     case PIX_FMT_BGR24:   c->yuv2packedX = RENAME(yuv2bgr24_X);   break;
+                     case PIX_FMT_RGB555:  c->yuv2packedX = RENAME(yuv2rgb555_X);  break;
+                     case PIX_FMT_RGB565:  c->yuv2packedX = RENAME(yuv2rgb565_X);  break;
+                     case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break;
+                     default: break;
+                     }
+                 }
              }
-         } else {
-             int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat);
-             c->yuv2yuv1     = should_dither ? RENAME(yuv2yuv1_ar    ) : RENAME(yuv2yuv1    );
-             c->yuv2yuvX     = RENAME(yuv2yuvX    );
 -        }
+         if (!(c->flags & SWS_FULL_CHR_H_INT)) {
              switch (c->dstFormat) {
-             case PIX_FMT_RGB32:   c->yuv2packedX = RENAME(yuv2rgb32_X);   break;
-             case PIX_FMT_BGR24:   c->yuv2packedX = RENAME(yuv2bgr24_X);   break;
-             case PIX_FMT_RGB555:  c->yuv2packedX = RENAME(yuv2rgb555_X);  break;
-             case PIX_FMT_RGB565:  c->yuv2packedX = RENAME(yuv2rgb565_X);  break;
-             case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break;
-             default: break;
-             }
-         }
-         switch (c->dstFormat) {
-         case PIX_FMT_RGB32:
+             case PIX_FMT_RGB32:
                  c->yuv2packed1 = RENAME(yuv2rgb32_1);
                  c->yuv2packed2 = RENAME(yuv2rgb32_2);
                  break;