* 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>tags/n0.8
| @@ -107,7 +107,7 @@ Configuration options: | |||
| --disable-mdct disable MDCT code | |||
| --disable-rdft disable RDFT code | |||
| --enable-vaapi enable VAAPI code | |||
| --disable-vdpau disable VDPAU code | |||
| --enable-vdpau enable VDPAU code | |||
| --disable-dxva2 disable DXVA2 code | |||
| --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary) | |||
| --enable-hardcoded-tables use hardcoded tables instead of runtime generation | |||
| @@ -50,6 +50,10 @@ API changes, most recent first: | |||
| 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. | |||
| @@ -54,9 +54,6 @@ | |||
| const char program_name[] = "ffplay"; | |||
| const int program_birth_year = 2003; | |||
| //#define DEBUG | |||
| //#define DEBUG_SYNC | |||
| #define MAX_QUEUE_SIZE (15 * 1024 * 1024) | |||
| #define MIN_AUDIOQ_SIZE (20 * 16 * 1024) | |||
| #define MIN_FRAMES 5 | |||
| @@ -1052,10 +1049,9 @@ static double compute_target_time(double frame_current_pts, VideoState *is) | |||
| } | |||
| } | |||
| is->frame_timer += delay; | |||
| #if defined(DEBUG_SYNC) | |||
| printf("video: delay=%0.3f actual_delay=%0.3f pts=%0.3f A-V=%f\n", | |||
| delay, actual_delay, frame_current_pts, -diff); | |||
| #endif | |||
| av_dlog(NULL, "video: delay=%0.3f pts=%0.3f A-V=%f\n", | |||
| delay, frame_current_pts, -diff); | |||
| return is->frame_timer; | |||
| } | |||
| @@ -2033,7 +2029,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) | |||
| n = 2 * dec->channels; | |||
| is->audio_clock += (double)data_size / | |||
| (double)(n * dec->sample_rate); | |||
| #if defined(DEBUG_SYNC) | |||
| #ifdef DEBUG | |||
| { | |||
| static double last_clock; | |||
| printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n", | |||
| @@ -127,7 +127,8 @@ OBJS-$(CONFIG_DVVIDEO_DECODER) += dv.o dvdata.o | |||
| OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o dvdata.o | |||
| OBJS-$(CONFIG_DXA_DECODER) += dxa.o | |||
| OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3dec_data.o | |||
| OBJS-$(CONFIG_EAC3_ENCODER) += ac3enc_float.o ac3tab.o ac3.o kbdwin.o | |||
| OBJS-$(CONFIG_EAC3_ENCODER) += eac3enc.o ac3enc_float.o ac3tab.o \ | |||
| ac3.o kbdwin.o | |||
| OBJS-$(CONFIG_EACMV_DECODER) += eacmv.o | |||
| OBJS-$(CONFIG_EAMAD_DECODER) += eamad.o eaidct.o mpeg12.o \ | |||
| mpeg12data.o mpegvideo.o \ | |||
| @@ -29,7 +29,7 @@ | |||
| #include "libavcodec/aac_tables.h" | |||
| #else | |||
| #include "libavutil/mathematics.h" | |||
| #include "libavcodec/aac.h" | |||
| #include "aac.h" | |||
| float ff_aac_pow2sf_tab[428]; | |||
| void ff_aac_tableinit(void) | |||
| @@ -164,7 +164,6 @@ typedef struct AC3EncOptions { | |||
| int cpl_start; | |||
| } AC3EncOptions; | |||
| void ff_ac3_common_init(void); | |||
| extern const int64_t ff_ac3_channel_layouts[]; | |||
| @@ -26,7 +26,6 @@ | |||
| * The simplest AC-3 encoder. | |||
| */ | |||
| //#define DEBUG | |||
| //#define ASSERT_LEVEL 2 | |||
| #include <stdint.h> | |||
| @@ -44,153 +43,8 @@ | |||
| #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 | |||
| @@ -715,34 +569,8 @@ static void apply_channel_coupling(AC3EncodeContext *s) | |||
| } | |||
| } | |||
| if (s->eac3) { | |||
| /* set first cpl coords */ | |||
| int first_cpl_coords[AC3_MAX_CHANNELS]; | |||
| for (ch = 1; ch <= s->fbw_channels; ch++) | |||
| first_cpl_coords[ch] = 1; | |||
| for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | |||
| AC3Block *block = &s->blocks[blk]; | |||
| for (ch = 1; ch <= s->fbw_channels; ch++) { | |||
| if (block->channel_in_cpl[ch]) { | |||
| if (first_cpl_coords[ch]) { | |||
| block->new_cpl_coords = 2; | |||
| first_cpl_coords[ch] = 0; | |||
| } | |||
| } else { | |||
| first_cpl_coords[ch] = 1; | |||
| } | |||
| } | |||
| } | |||
| /* set first cpl leak */ | |||
| for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | |||
| AC3Block *block = &s->blocks[blk]; | |||
| if (block->cpl_in_use) { | |||
| block->new_cpl_leak = 2; | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| if (CONFIG_EAC3_ENCODER && s->eac3) | |||
| ff_eac3_set_cpl_states(s); | |||
| #endif /* CONFIG_AC3ENC_FLOAT */ | |||
| } | |||
| @@ -1879,79 +1707,6 @@ static void ac3_output_frame_header(AC3EncodeContext *s) | |||
| } | |||
| /** | |||
| * Write the E-AC-3 frame header to the output bitstream. | |||
| */ | |||
| static void eac3_output_frame_header(AC3EncodeContext *s) | |||
| { | |||
| int blk, ch; | |||
| AC3EncOptions *opt = &s->options; | |||
| put_bits(&s->pb, 16, 0x0b77); /* sync word */ | |||
| /* BSI header */ | |||
| put_bits(&s->pb, 2, 0); /* stream type = independent */ | |||
| put_bits(&s->pb, 3, 0); /* substream id = 0 */ | |||
| put_bits(&s->pb, 11, (s->frame_size / 2) - 1); /* frame size */ | |||
| if (s->bit_alloc.sr_shift) { | |||
| put_bits(&s->pb, 2, 0x3); /* fscod2 */ | |||
| put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ | |||
| } else { | |||
| put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ | |||
| put_bits(&s->pb, 2, 0x3); /* number of blocks = 6 */ | |||
| } | |||
| put_bits(&s->pb, 3, s->channel_mode); /* audio coding mode */ | |||
| put_bits(&s->pb, 1, s->lfe_on); /* LFE channel indicator */ | |||
| put_bits(&s->pb, 5, s->bitstream_id); /* bitstream id (EAC3=16) */ | |||
| put_bits(&s->pb, 5, -opt->dialogue_level); /* dialogue normalization level */ | |||
| put_bits(&s->pb, 1, 0); /* no compression gain */ | |||
| put_bits(&s->pb, 1, 0); /* no mixing metadata */ | |||
| /* TODO: mixing metadata */ | |||
| put_bits(&s->pb, 1, 0); /* no info metadata */ | |||
| /* TODO: info metadata */ | |||
| put_bits(&s->pb, 1, 0); /* no additional bit stream info */ | |||
| /* frame header */ | |||
| put_bits(&s->pb, 1, 1); /* exponent strategy syntax = each block */ | |||
| put_bits(&s->pb, 1, 0); /* aht enabled = no */ | |||
| put_bits(&s->pb, 2, 0); /* snr offset strategy = 1 */ | |||
| put_bits(&s->pb, 1, 0); /* transient pre-noise processing enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* block switch syntax enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* dither flag syntax enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* bit allocation model syntax enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* fast gain codes enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* dba syntax enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* skip field syntax enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* spx enabled = no */ | |||
| /* coupling strategy use flags */ | |||
| if (s->channel_mode > AC3_CHMODE_MONO) { | |||
| put_bits(&s->pb, 1, s->blocks[0].cpl_in_use); | |||
| for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) { | |||
| AC3Block *block = &s->blocks[blk]; | |||
| put_bits(&s->pb, 1, block->new_cpl_strategy); | |||
| if (block->new_cpl_strategy) | |||
| put_bits(&s->pb, 1, block->cpl_in_use); | |||
| } | |||
| } | |||
| /* exponent strategy */ | |||
| for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | |||
| for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) | |||
| put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); | |||
| if (s->lfe_on) { | |||
| for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | |||
| put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]); | |||
| } | |||
| /* E-AC-3 to AC-3 converter exponent strategy (unfortunately not optional...) */ | |||
| for (ch = 1; ch <= s->fbw_channels; ch++) | |||
| put_bits(&s->pb, 5, 0); | |||
| /* snr offsets */ | |||
| put_bits(&s->pb, 6, s->coarse_snr_offset); | |||
| put_bits(&s->pb, 4, s->fine_snr_offset[1]); | |||
| /* block start info */ | |||
| put_bits(&s->pb, 1, 0); | |||
| } | |||
| /** | |||
| * Write one audio block to the output bitstream. | |||
| */ | |||
| @@ -2235,8 +1990,8 @@ static void output_frame(AC3EncodeContext *s, unsigned char *frame) | |||
| init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE); | |||
| if (s->eac3) | |||
| eac3_output_frame_header(s); | |||
| if (CONFIG_EAC3_ENCODER && s->eac3) | |||
| ff_eac3_output_frame_header(s); | |||
| else | |||
| ac3_output_frame_header(s); | |||
| @@ -0,0 +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 */ | |||
| @@ -83,8 +83,6 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) | |||
| /* VLC decoding */ | |||
| //#define DEBUG_VLC | |||
| #define GET_DATA(v, table, i, wrap, size) \ | |||
| {\ | |||
| const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ | |||
| @@ -164,10 +162,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, | |||
| table_size = 1 << table_nb_bits; | |||
| table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); | |||
| #ifdef DEBUG_VLC | |||
| av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n", | |||
| table_index, table_size); | |||
| #endif | |||
| av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); | |||
| if (table_index < 0) | |||
| return -1; | |||
| table = &vlc->table[table_index]; | |||
| @@ -182,9 +177,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, | |||
| n = codes[i].bits; | |||
| code = codes[i].code; | |||
| symbol = codes[i].symbol; | |||
| #if defined(DEBUG_VLC) && 0 | |||
| av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code); | |||
| #endif | |||
| av_dlog(NULL, "i=%d n=%d code=0x%x\n", i, n, code); | |||
| if (n <= table_nb_bits) { | |||
| /* no need to add another table */ | |||
| j = code >> (32 - table_nb_bits); | |||
| @@ -195,10 +188,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, | |||
| inc = 1 << n; | |||
| } | |||
| for (k = 0; k < nb; k++) { | |||
| #ifdef DEBUG_VLC | |||
| av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", | |||
| j, i, n); | |||
| #endif | |||
| av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); | |||
| if (table[j][1] /*bits*/ != 0) { | |||
| av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); | |||
| return -1; | |||
| @@ -228,10 +218,8 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, | |||
| subtable_bits = FFMIN(subtable_bits, table_nb_bits); | |||
| j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; | |||
| table[j][1] = -subtable_bits; | |||
| #ifdef DEBUG_VLC | |||
| av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n", | |||
| j, codes[i].bits + table_nb_bits); | |||
| #endif | |||
| av_dlog(NULL, "%4x: n=%d (subtable)\n", | |||
| j, codes[i].bits + table_nb_bits); | |||
| index = build_table(vlc, subtable_bits, k-i, codes+i, flags); | |||
| if (index < 0) | |||
| return -1; | |||
| @@ -293,9 +281,7 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, | |||
| vlc->table_size = 0; | |||
| } | |||
| #ifdef DEBUG_VLC | |||
| av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); | |||
| #endif | |||
| av_dlog(NULL, "build table nb_codes=%d\n", nb_codes); | |||
| buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); | |||
| @@ -25,8 +25,9 @@ | |||
| #define AVCODEC_DNXHDENC_H | |||
| #include <stdint.h> | |||
| #include "libavcodec/mpegvideo.h" | |||
| #include "libavcodec/dnxhddata.h" | |||
| #include "mpegvideo.h" | |||
| #include "dnxhddata.h" | |||
| typedef struct { | |||
| uint16_t mb; | |||
| @@ -358,9 +358,6 @@ static av_cold int dvvideo_init_encoder(AVCodecContext *avctx) | |||
| return dvvideo_init(avctx); | |||
| } | |||
| // #define VLC_DEBUG | |||
| // #define printf(...) av_log(NULL, AV_LOG_ERROR, __VA_ARGS__) | |||
| typedef struct BlockInfo { | |||
| const uint32_t *factor_table; | |||
| const uint8_t *scan_table; | |||
| @@ -404,9 +401,8 @@ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) | |||
| /* get the AC coefficients until last_index is reached */ | |||
| for (;;) { | |||
| #ifdef VLC_DEBUG | |||
| printf("%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, gb, 16), re_index); | |||
| #endif | |||
| av_dlog(NULL, "%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, gb, 16), | |||
| re_index); | |||
| /* our own optimized GET_RL_VLC */ | |||
| index = NEG_USR32(re_cache, TEX_VLC_BITS); | |||
| vlc_len = dv_rl_vlc[index].len; | |||
| @@ -427,9 +423,7 @@ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) | |||
| } | |||
| re_index += vlc_len; | |||
| #ifdef VLC_DEBUG | |||
| printf("run=%d level=%d\n", run, level); | |||
| #endif | |||
| av_dlog(NULL, "run=%d level=%d\n", run, level); | |||
| pos += run; | |||
| if (pos >= 64) | |||
| break; | |||
| @@ -533,9 +527,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) | |||
| mb->pos = 0; | |||
| mb->partial_bit_count = 0; | |||
| #ifdef VLC_DEBUG | |||
| printf("MB block: %d, %d ", mb_index, j); | |||
| #endif | |||
| av_dlog(avctx, "MB block: %d, %d ", mb_index, j); | |||
| dv_decode_ac(&gb, mb, block); | |||
| /* write the remaining bits in a new buffer only if the | |||
| @@ -548,9 +540,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) | |||
| } | |||
| /* pass 2 : we can do it just after */ | |||
| #ifdef VLC_DEBUG | |||
| printf("***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); | |||
| #endif | |||
| av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); | |||
| block = block1; | |||
| mb = mb1; | |||
| init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb)); | |||
| @@ -570,9 +560,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) | |||
| } | |||
| /* we need a pass other the whole video segment */ | |||
| #ifdef VLC_DEBUG | |||
| printf("***pass 3 size=%d\n", put_bits_count(&vs_pb)); | |||
| #endif | |||
| av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb)); | |||
| block = &sblock[0][0]; | |||
| mb = mb_data; | |||
| init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb)); | |||
| @@ -580,9 +568,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) | |||
| for (mb_index = 0; mb_index < 5; mb_index++) { | |||
| for (j = 0; j < s->sys->bpm; j++) { | |||
| if (mb->pos < 64) { | |||
| #ifdef VLC_DEBUG | |||
| printf("start %d:%d\n", mb_index, j); | |||
| #endif | |||
| av_dlog(avctx, "start %d:%d\n", mb_index, j); | |||
| dv_decode_ac(&gb, mb, block); | |||
| } | |||
| if (mb->pos >= 64 && mb->pos < 127) | |||
| @@ -22,9 +22,6 @@ | |||
| #include "dsputil.h" | |||
| #include "get_bits.h" | |||
| //#define DEBUG | |||
| //#define DEBUG_PACKET_CONTENTS | |||
| /* Parser (mostly) copied from dvdsub.c */ | |||
| #define PARSE_BUF_SIZE (65536) | |||
| @@ -53,25 +50,20 @@ static int dvbsub_parse(AVCodecParserContext *s, | |||
| { | |||
| DVBSubParseContext *pc = s->priv_data; | |||
| uint8_t *p, *p_end; | |||
| int len, buf_pos = 0; | |||
| int i, len, buf_pos = 0; | |||
| av_dlog(avctx, "DVB parse packet pts=%"PRIx64", lpts=%"PRIx64", cpts=%"PRIx64":\n", | |||
| s->pts, s->last_pts, s->cur_frame_pts[s->cur_frame_start_index]); | |||
| #ifdef DEBUG_PACKET_CONTENTS | |||
| int i; | |||
| for (i=0; i < buf_size; i++) | |||
| { | |||
| av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); | |||
| av_dlog(avctx, "%02x ", buf[i]); | |||
| if (i % 16 == 15) | |||
| av_log(avctx, AV_LOG_INFO, "\n"); | |||
| av_dlog(avctx, "\n"); | |||
| } | |||
| if (i % 16 != 0) | |||
| av_log(avctx, AV_LOG_INFO, "\n"); | |||
| #endif | |||
| av_dlog(avctx, "\n"); | |||
| *poutbuf = NULL; | |||
| *poutbuf_size = 0; | |||
| @@ -24,10 +24,6 @@ | |||
| #include "bytestream.h" | |||
| #include "libavutil/colorspace.h" | |||
| //#define DEBUG | |||
| //#define DEBUG_PACKET_CONTENTS | |||
| //#define DEBUG_SAVE_IMAGES | |||
| #define DVBSUB_PAGE_SEGMENT 0x10 | |||
| #define DVBSUB_REGION_SEGMENT 0x11 | |||
| #define DVBSUB_CLUT_SEGMENT 0x12 | |||
| @@ -37,7 +33,7 @@ | |||
| #define cm (ff_cropTbl + MAX_NEG_CROP) | |||
| #ifdef DEBUG_SAVE_IMAGES | |||
| #ifdef DEBUG | |||
| #undef fprintf | |||
| #if 0 | |||
| static void png_save(const char *filename, uint8_t *bitmap, int w, int h, | |||
| @@ -768,20 +764,17 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDis | |||
| av_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size, | |||
| top_bottom ? "bottom" : "top"); | |||
| #ifdef DEBUG_PACKET_CONTENTS | |||
| for (i = 0; i < buf_size; i++) { | |||
| if (i % 16 == 0) | |||
| av_log(avctx, AV_LOG_INFO, "0x%08p: ", buf+i); | |||
| av_dlog(avctx, "0x%8p: ", buf+i); | |||
| av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); | |||
| av_dlog(avctx, "%02x ", buf[i]); | |||
| if (i % 16 == 15) | |||
| av_log(avctx, AV_LOG_INFO, "\n"); | |||
| av_dlog(avctx, "\n"); | |||
| } | |||
| if (i % 16) | |||
| av_log(avctx, AV_LOG_INFO, "\n"); | |||
| #endif | |||
| av_dlog(avctx, "\n"); | |||
| if (region == 0) | |||
| return; | |||
| @@ -930,27 +923,22 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx, | |||
| DVBSubContext *ctx = avctx->priv_data; | |||
| const uint8_t *buf_end = buf + buf_size; | |||
| int clut_id; | |||
| int i, clut_id; | |||
| DVBSubCLUT *clut; | |||
| int entry_id, depth , full_range; | |||
| int y, cr, cb, alpha; | |||
| int r, g, b, r_add, g_add, b_add; | |||
| #ifdef DEBUG_PACKET_CONTENTS | |||
| int i; | |||
| av_log(avctx, AV_LOG_INFO, "DVB clut packet:\n"); | |||
| av_dlog(avctx, "DVB clut packet:\n"); | |||
| for (i=0; i < buf_size; i++) { | |||
| av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); | |||
| av_dlog(avctx, "%02x ", buf[i]); | |||
| if (i % 16 == 15) | |||
| av_log(avctx, AV_LOG_INFO, "\n"); | |||
| av_dlog(avctx, "\n"); | |||
| } | |||
| if (i % 16) | |||
| av_log(avctx, AV_LOG_INFO, "\n"); | |||
| #endif | |||
| av_dlog(avctx, "\n"); | |||
| clut_id = *buf++; | |||
| buf += 1; | |||
| @@ -1194,7 +1182,7 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx, | |||
| } | |||
| #ifdef DEBUG_SAVE_IMAGES | |||
| #ifdef DEBUG | |||
| static void save_display_set(DVBSubContext *ctx) | |||
| { | |||
| DVBSubRegion *region; | |||
| @@ -1404,7 +1392,7 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, | |||
| sub->num_rects = i; | |||
| #ifdef DEBUG_SAVE_IMAGES | |||
| #ifdef DEBUG | |||
| save_display_set(ctx); | |||
| #endif | |||
| @@ -1423,22 +1411,18 @@ static int dvbsub_decode(AVCodecContext *avctx, | |||
| int segment_type; | |||
| int page_id; | |||
| int segment_length; | |||
| #ifdef DEBUG_PACKET_CONTENTS | |||
| int i; | |||
| av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n"); | |||
| av_dlog(avctx, "DVB sub packet:\n"); | |||
| for (i=0; i < buf_size; i++) { | |||
| av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); | |||
| av_dlog(avctx, "%02x ", buf[i]); | |||
| if (i % 16 == 15) | |||
| av_log(avctx, AV_LOG_INFO, "\n"); | |||
| av_dlog(avctx, "\n"); | |||
| } | |||
| if (i % 16) | |||
| av_log(avctx, AV_LOG_INFO, "\n"); | |||
| #endif | |||
| av_dlog(avctx, "\n"); | |||
| if (buf_size <= 6 || *buf != 0x0f) { | |||
| av_dlog(avctx, "incomplete or broken packet"); | |||
| @@ -0,0 +1,131 @@ | |||
| /* | |||
| * E-AC-3 encoder | |||
| * Copyright (c) 2011 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 | |||
| * E-AC-3 encoder | |||
| */ | |||
| #define CONFIG_AC3ENC_FLOAT 1 | |||
| #include "ac3enc.h" | |||
| #include "eac3enc.h" | |||
| void ff_eac3_set_cpl_states(AC3EncodeContext *s) | |||
| { | |||
| int ch, blk; | |||
| int first_cpl_coords[AC3_MAX_CHANNELS]; | |||
| /* set first cpl coords */ | |||
| for (ch = 1; ch <= s->fbw_channels; ch++) | |||
| first_cpl_coords[ch] = 1; | |||
| for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | |||
| AC3Block *block = &s->blocks[blk]; | |||
| for (ch = 1; ch <= s->fbw_channels; ch++) { | |||
| if (block->channel_in_cpl[ch]) { | |||
| if (first_cpl_coords[ch]) { | |||
| block->new_cpl_coords = 2; | |||
| first_cpl_coords[ch] = 0; | |||
| } | |||
| } else { | |||
| first_cpl_coords[ch] = 1; | |||
| } | |||
| } | |||
| } | |||
| /* set first cpl leak */ | |||
| for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | |||
| AC3Block *block = &s->blocks[blk]; | |||
| if (block->cpl_in_use) { | |||
| block->new_cpl_leak = 2; | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| void ff_eac3_output_frame_header(AC3EncodeContext *s) | |||
| { | |||
| int blk, ch; | |||
| AC3EncOptions *opt = &s->options; | |||
| put_bits(&s->pb, 16, 0x0b77); /* sync word */ | |||
| /* BSI header */ | |||
| put_bits(&s->pb, 2, 0); /* stream type = independent */ | |||
| put_bits(&s->pb, 3, 0); /* substream id = 0 */ | |||
| put_bits(&s->pb, 11, (s->frame_size / 2) - 1); /* frame size */ | |||
| if (s->bit_alloc.sr_shift) { | |||
| put_bits(&s->pb, 2, 0x3); /* fscod2 */ | |||
| put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ | |||
| } else { | |||
| put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ | |||
| put_bits(&s->pb, 2, 0x3); /* number of blocks = 6 */ | |||
| } | |||
| put_bits(&s->pb, 3, s->channel_mode); /* audio coding mode */ | |||
| put_bits(&s->pb, 1, s->lfe_on); /* LFE channel indicator */ | |||
| put_bits(&s->pb, 5, s->bitstream_id); /* bitstream id (EAC3=16) */ | |||
| put_bits(&s->pb, 5, -opt->dialogue_level); /* dialogue normalization level */ | |||
| put_bits(&s->pb, 1, 0); /* no compression gain */ | |||
| put_bits(&s->pb, 1, 0); /* no mixing metadata */ | |||
| /* TODO: mixing metadata */ | |||
| put_bits(&s->pb, 1, 0); /* no info metadata */ | |||
| /* TODO: info metadata */ | |||
| put_bits(&s->pb, 1, 0); /* no additional bit stream info */ | |||
| /* frame header */ | |||
| put_bits(&s->pb, 1, 1); /* exponent strategy syntax = each block */ | |||
| put_bits(&s->pb, 1, 0); /* aht enabled = no */ | |||
| put_bits(&s->pb, 2, 0); /* snr offset strategy = 1 */ | |||
| put_bits(&s->pb, 1, 0); /* transient pre-noise processing enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* block switch syntax enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* dither flag syntax enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* bit allocation model syntax enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* fast gain codes enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* dba syntax enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* skip field syntax enabled = no */ | |||
| put_bits(&s->pb, 1, 0); /* spx enabled = no */ | |||
| /* coupling strategy use flags */ | |||
| if (s->channel_mode > AC3_CHMODE_MONO) { | |||
| put_bits(&s->pb, 1, s->blocks[0].cpl_in_use); | |||
| for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) { | |||
| AC3Block *block = &s->blocks[blk]; | |||
| put_bits(&s->pb, 1, block->new_cpl_strategy); | |||
| if (block->new_cpl_strategy) | |||
| put_bits(&s->pb, 1, block->cpl_in_use); | |||
| } | |||
| } | |||
| /* exponent strategy */ | |||
| for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | |||
| for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) | |||
| put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); | |||
| if (s->lfe_on) { | |||
| for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | |||
| put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]); | |||
| } | |||
| /* E-AC-3 to AC-3 converter exponent strategy (unfortunately not optional...) */ | |||
| for (ch = 1; ch <= s->fbw_channels; ch++) | |||
| put_bits(&s->pb, 5, 0); | |||
| /* snr offsets */ | |||
| put_bits(&s->pb, 6, s->coarse_snr_offset); | |||
| put_bits(&s->pb, 4, s->fine_snr_offset[1]); | |||
| /* block start info */ | |||
| put_bits(&s->pb, 1, 0); | |||
| } | |||
| @@ -0,0 +1,44 @@ | |||
| /* | |||
| * E-AC-3 encoder | |||
| * Copyright (c) 2011 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 | |||
| * E-AC-3 encoder | |||
| */ | |||
| #ifndef AVCODEC_EAC3ENC_H | |||
| #define AVCODEC_EAC3ENC_H | |||
| #include "ac3enc.h" | |||
| /** | |||
| * Set coupling states. | |||
| * This determines whether certain flags must be written to the bitstream or | |||
| * whether they will be implicitly already known by the decoder. | |||
| */ | |||
| void ff_eac3_set_cpl_states(AC3EncodeContext *s); | |||
| /** | |||
| * Write the E-AC-3 frame header to the output bitstream. | |||
| */ | |||
| void ff_eac3_output_frame_header(AC3EncodeContext *s); | |||
| #endif /* AVCODEC_EAC3ENC_H */ | |||
| @@ -151,8 +151,6 @@ static int biquad_init_coeffs(void *avc, struct FFIIRFilterCoeffs *c, | |||
| // during filtering, the delay state will include the gain multiplication | |||
| c->cx[0] = lrintf(x0 / c->gain); | |||
| c->cx[1] = lrintf(x1 / c->gain); | |||
| c->cy[0] /= c->gain; | |||
| c->cy[1] /= c->gain; | |||
| return 0; | |||
| } | |||
| @@ -19,8 +19,8 @@ | |||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
| */ | |||
| #include "libavcodec/mlp.h" | |||
| #include "dsputil.h" | |||
| #include "mlp.h" | |||
| static void ff_mlp_filter_channel(int32_t *state, const int32_t *coeff, | |||
| int firorder, int iirorder, | |||
| @@ -30,8 +30,6 @@ | |||
| #include "libavutil/colorspace.h" | |||
| #include "libavutil/imgutils.h" | |||
| //#define DEBUG_PACKET_CONTENTS | |||
| #define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) | |||
| enum SegmentType { | |||
| @@ -403,21 +401,18 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, | |||
| const uint8_t *buf_end; | |||
| uint8_t segment_type; | |||
| int segment_length; | |||
| #ifdef DEBUG_PACKET_CONTENTS | |||
| int i; | |||
| av_log(avctx, AV_LOG_INFO, "PGS sub packet:\n"); | |||
| av_dlog(avctx, "PGS sub packet:\n"); | |||
| for (i = 0; i < buf_size; i++) { | |||
| av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); | |||
| av_dlog(avctx, "%02x ", buf[i]); | |||
| if (i % 16 == 15) | |||
| av_log(avctx, AV_LOG_INFO, "\n"); | |||
| av_dlog(avctx, "\n"); | |||
| } | |||
| if (i & 15) | |||
| av_log(avctx, AV_LOG_INFO, "\n"); | |||
| #endif | |||
| av_dlog(avctx, "\n"); | |||
| *data_size = 0; | |||
| @@ -18,8 +18,7 @@ | |||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
| */ | |||
| //#define DEBUG_ALIGNMENT | |||
| #ifdef DEBUG_ALIGNMENT | |||
| #ifdef DEBUG | |||
| #define ASSERT_ALIGNED(ptr) assert(((unsigned long)ptr&0x0000000F)); | |||
| #else | |||
| #define ASSERT_ALIGNED(ptr) ; | |||
| @@ -26,7 +26,6 @@ | |||
| * | |||
| */ | |||
| #define DEBUG | |||
| #include <limits.h> | |||
| #include "avcodec.h" | |||
| #include "get_bits.h" | |||
| @@ -304,7 +303,6 @@ static int shorten_decode_frame(AVCodecContext *avctx, | |||
| s->bitstream_size= buf_size; | |||
| if(buf_size < s->max_framesize){ | |||
| //av_dlog(avctx, "wanna more data ... %d\n", buf_size); | |||
| *data_size = 0; | |||
| return input_buf_size; | |||
| } | |||
| @@ -22,7 +22,7 @@ | |||
| */ | |||
| #include "avcodec.h" | |||
| #include "libavcodec/bytestream.h" | |||
| #include "bytestream.h" | |||
| static av_cold int encode_init(AVCodecContext *avctx) | |||
| { | |||
| @@ -3398,7 +3398,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) | |||
| VC1Context *v = avctx->priv_data; | |||
| MpegEncContext *s = &v->s; | |||
| GetBitContext gb; | |||
| int i; | |||
| int i, cur_width, cur_height; | |||
| if (!avctx->extradata_size || !avctx->extradata) return -1; | |||
| if (!(avctx->flags & CODEC_FLAG_GRAY)) | |||
| @@ -3419,8 +3419,8 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) | |||
| if (vc1_init_common(v) < 0) return -1; | |||
| ff_vc1dsp_init(&v->vc1dsp); | |||
| avctx->coded_width = avctx->width; | |||
| avctx->coded_height = avctx->height; | |||
| cur_width = avctx->coded_width = avctx->width; | |||
| cur_height = avctx->coded_height = avctx->height; | |||
| if (avctx->codec_id == CODEC_ID_WMV3) | |||
| { | |||
| int count = 0; | |||
| @@ -3491,6 +3491,19 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) | |||
| } | |||
| v->res_sprite = (avctx->codec_tag == MKTAG('W','V','P','2')); | |||
| } | |||
| // Sequence header information may not have been parsed | |||
| // yet when ff_msmpeg4_decode_init was called the fist time | |||
| // above. If sequence information changes, we need to call | |||
| // it again. | |||
| if (cur_width != avctx->width || | |||
| cur_height != avctx->height) { | |||
| MPV_common_end(s); | |||
| if(ff_msmpeg4_decode_init(avctx) < 0) | |||
| return -1; | |||
| avctx->coded_width = avctx->width; | |||
| avctx->coded_height = avctx->height; | |||
| } | |||
| avctx->profile = v->profile; | |||
| if (v->profile == PROFILE_ADVANCED) | |||
| avctx->level = v->level; | |||
| @@ -20,6 +20,7 @@ | |||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
| */ | |||
| #include <inttypes.h> | |||
| #include <math.h> | |||
| #define ALT_BITSTREAM_READER_LE | |||
| @@ -1089,6 +1090,9 @@ static int vorbis_floor0_decode(vorbis_context *vc, | |||
| for (i = 0; i < order; i++) | |||
| lsp[i] = 2.0f * cos(lsp[i]); | |||
| av_dlog(NULL, "floor0 synth: map_size = %"PRIu32"; m = %d; wstep = %f\n", | |||
| vf->map_size[blockflag], order, wstep); | |||
| i = 0; | |||
| while (i < vf->map_size[blockflag]) { | |||
| int j, iter_cond = vf->map[blockflag][i]; | |||
| @@ -124,132 +124,132 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth | |||
| { | |||
| int mm_flags = av_get_cpu_flags(); | |||
| if (bit_depth == 8) { | |||
| #if HAVE_YASM | |||
| if (mm_flags & AV_CPU_FLAG_MMX) { | |||
| h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx; | |||
| h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx; | |||
| h->pred8x8 [VERT_PRED8x8] = ff_pred8x8_vertical_mmx; | |||
| h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; | |||
| if (codec_id == CODEC_ID_VP8) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx; | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx; | |||
| h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx; | |||
| } else { | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx; | |||
| if (codec_id == CODEC_ID_SVQ3) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx; | |||
| } else if (codec_id == CODEC_ID_RV40) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx; | |||
| if (bit_depth == 8) { | |||
| if (mm_flags & AV_CPU_FLAG_MMX) { | |||
| h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx; | |||
| h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx; | |||
| h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_mmx; | |||
| h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; | |||
| if (codec_id == CODEC_ID_VP8) { | |||
| h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmx; | |||
| h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmx; | |||
| h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx; | |||
| } else { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx; | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx; | |||
| if (codec_id == CODEC_ID_SVQ3) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx; | |||
| } else if (codec_id == CODEC_ID_RV40) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx; | |||
| } else { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| if (mm_flags & AV_CPU_FLAG_MMX2) { | |||
| h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; | |||
| h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext; | |||
| h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext; | |||
| h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext; | |||
| h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext; | |||
| h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext; | |||
| h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext; | |||
| h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_mmxext; | |||
| h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext; | |||
| h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext; | |||
| h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext; | |||
| h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext; | |||
| h->pred4x4 [DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_mmxext; | |||
| h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext; | |||
| h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext; | |||
| h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext; | |||
| if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264) | |||
| h->pred4x4 [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext; | |||
| if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) | |||
| h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext; | |||
| if (codec_id != CODEC_ID_RV40) { | |||
| h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext; | |||
| } | |||
| if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { | |||
| h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; | |||
| h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; | |||
| } | |||
| if (codec_id == CODEC_ID_VP8) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext; | |||
| h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext; | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext; | |||
| h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext; | |||
| h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext; | |||
| } else { | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2; | |||
| if (codec_id == CODEC_ID_SVQ3) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx2; | |||
| } else if (codec_id == CODEC_ID_RV40) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx2; | |||
| if (mm_flags & AV_CPU_FLAG_MMX2) { | |||
| h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; | |||
| h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext; | |||
| h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext; | |||
| h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext; | |||
| h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext; | |||
| h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext; | |||
| h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext; | |||
| h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_mmxext; | |||
| h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext; | |||
| h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext; | |||
| h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext; | |||
| h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext; | |||
| h->pred4x4 [DIAG_DOWN_RIGHT_PRED ] = ff_pred4x4_down_right_mmxext; | |||
| h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext; | |||
| h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext; | |||
| h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext; | |||
| if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264) { | |||
| h->pred4x4 [DIAG_DOWN_LEFT_PRED] = ff_pred4x4_down_left_mmxext; | |||
| } | |||
| if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { | |||
| h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext; | |||
| } | |||
| if (codec_id != CODEC_ID_RV40) { | |||
| h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext; | |||
| } | |||
| if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { | |||
| h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; | |||
| h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; | |||
| } | |||
| if (codec_id == CODEC_ID_VP8) { | |||
| h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmxext; | |||
| h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext; | |||
| h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmxext; | |||
| h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext; | |||
| h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext; | |||
| } else { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx2; | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2; | |||
| if (codec_id == CODEC_ID_SVQ3) { | |||
| h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_mmx2; | |||
| } else if (codec_id == CODEC_ID_RV40) { | |||
| h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_rv40_mmx2; | |||
| } else { | |||
| h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_h264_mmx2; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| if (mm_flags & AV_CPU_FLAG_SSE) { | |||
| h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse; | |||
| } | |||
| if (mm_flags & AV_CPU_FLAG_SSE) { | |||
| h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse; | |||
| } | |||
| if (mm_flags & AV_CPU_FLAG_SSE2) { | |||
| h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2; | |||
| h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2; | |||
| h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2; | |||
| h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2; | |||
| h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2; | |||
| h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2; | |||
| if (codec_id == CODEC_ID_VP8) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2; | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2; | |||
| } else { | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_sse2; | |||
| if (codec_id == CODEC_ID_SVQ3) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2; | |||
| } else if (codec_id == CODEC_ID_RV40) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2; | |||
| if (mm_flags & AV_CPU_FLAG_SSE2) { | |||
| h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2; | |||
| h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2; | |||
| h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_sse2; | |||
| h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2; | |||
| h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2; | |||
| h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2; | |||
| if (codec_id == CODEC_ID_VP8) { | |||
| h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_sse2; | |||
| h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_sse2; | |||
| } else { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2; | |||
| h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_plane_sse2; | |||
| if (codec_id == CODEC_ID_SVQ3) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2; | |||
| } else if (codec_id == CODEC_ID_RV40) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2; | |||
| } else { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| if (mm_flags & AV_CPU_FLAG_SSSE3) { | |||
| h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; | |||
| h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3; | |||
| h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3; | |||
| h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3; | |||
| h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3; | |||
| h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3; | |||
| h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3; | |||
| h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3; | |||
| h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_ssse3; | |||
| h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3; | |||
| h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3; | |||
| h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3; | |||
| h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3; | |||
| if (codec_id == CODEC_ID_VP8) { | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3; | |||
| h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; | |||
| } else { | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3; | |||
| if (codec_id == CODEC_ID_SVQ3) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3; | |||
| } else if (codec_id == CODEC_ID_RV40) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3; | |||
| if (mm_flags & AV_CPU_FLAG_SSSE3) { | |||
| h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; | |||
| h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3; | |||
| h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3; | |||
| h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3; | |||
| h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3; | |||
| h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3; | |||
| h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3; | |||
| h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3; | |||
| h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_ssse3; | |||
| h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3; | |||
| h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3; | |||
| h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3; | |||
| h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3; | |||
| if (codec_id == CODEC_ID_VP8) { | |||
| h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_ssse3; | |||
| h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; | |||
| } else { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3; | |||
| h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3; | |||
| if (codec_id == CODEC_ID_SVQ3) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3; | |||
| } else if (codec_id == CODEC_ID_RV40) { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3; | |||
| } else { | |||
| h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| #endif | |||
| } else if (bit_depth == 10) { | |||
| #if HAVE_YASM | |||
| if (mm_flags & AV_CPU_FLAG_MMX2) { | |||
| h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; | |||
| h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; | |||
| @@ -270,13 +270,13 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth | |||
| h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3; | |||
| } | |||
| #if HAVE_AVX | |||
| if (mm_flags&AV_CPU_FLAG_AVX) { | |||
| if (mm_flags & AV_CPU_FLAG_AVX) { | |||
| h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx; | |||
| h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx; | |||
| h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_avx; | |||
| h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_avx; | |||
| } | |||
| #endif /* HAVE_AVX */ | |||
| #endif /* HAVE_YASM */ | |||
| } | |||
| #endif /* HAVE_YASM */ | |||
| } | |||
| @@ -1254,7 +1254,7 @@ static int avi_load_index(AVFormatContext *s) | |||
| 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 (url_feof(pb)) | |||
| @@ -1262,7 +1262,7 @@ static int avi_load_index(AVFormatContext *s) | |||
| tag = avio_rl32(pb); | |||
| size = avio_rl32(pb); | |||
| #ifdef DEBUG_SEEK | |||
| printf("tag=%c%c%c%c size=0x%x\n", | |||
| av_log(s, AV_LOG_DEBUG, "tag=%c%c%c%c size=0x%x\n", | |||
| tag & 0xff, | |||
| (tag >> 8) & 0xff, | |||
| (tag >> 16) & 0xff, | |||
| @@ -28,7 +28,7 @@ | |||
| #include <string.h> | |||
| #include "libavutil/intreadwrite.h" | |||
| #include "libavutil/avstring.h" | |||
| #include "libavformat/internal.h" | |||
| #include "internal.h" | |||
| #include "mms.h" | |||
| #include "asf.h" | |||
| #include "http.h" | |||
| @@ -23,7 +23,6 @@ | |||
| #include <limits.h> | |||
| //#define DEBUG | |||
| //#define DEBUG_METADATA | |||
| //#define MOV_EXPORT_ALL_METADATA | |||
| #include "libavutil/intreadwrite.h" | |||
| @@ -215,11 +214,9 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) | |||
| av_metadata_set2(&c->fc->metadata, key2, str, 0); | |||
| } | |||
| } | |||
| #ifdef DEBUG_METADATA | |||
| av_log(c->fc, AV_LOG_DEBUG, "lang \"%3s\" ", language); | |||
| av_log(c->fc, AV_LOG_DEBUG, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %lld\n", | |||
| key, str, (char*)&atom.type, str_size, atom.size); | |||
| #endif | |||
| av_dlog(c->fc, "lang \"%3s\" ", language); | |||
| av_dlog(c->fc, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %"PRId64"\n", | |||
| key, str, (char*)&atom.type, str_size, atom.size); | |||
| return 0; | |||
| } | |||
| @@ -586,9 +586,6 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, | |||
| int64_t pos, pts, dts; | |||
| pos = *ppos; | |||
| #ifdef DEBUG_SEEK | |||
| printf("read_dts: pos=0x%"PRIx64" next=%d -> ", pos, find_next); | |||
| #endif | |||
| if (avio_seek(s->pb, pos, SEEK_SET) < 0) | |||
| return AV_NOPTS_VALUE; | |||
| @@ -596,7 +593,7 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, | |||
| len = mpegps_read_pes_header(s, &pos, &startcode, &pts, &dts); | |||
| if (len < 0) { | |||
| #ifdef DEBUG_SEEK | |||
| printf("none (ret=%d)\n", len); | |||
| av_log(s, AV_LOG_DEBUG, "none (ret=%d)\n", len); | |||
| #endif | |||
| return AV_NOPTS_VALUE; | |||
| } | |||
| @@ -607,7 +604,8 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, | |||
| avio_skip(s->pb, len); | |||
| } | |||
| #ifdef DEBUG_SEEK | |||
| printf("pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", pos, dts, dts / 90000.0); | |||
| av_log(s, AV_LOG_DEBUG, "pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", | |||
| pos, dts, dts / 90000.0); | |||
| #endif | |||
| *ppos = pos; | |||
| return dts; | |||
| @@ -31,9 +31,6 @@ | |||
| #include "rdt.h" | |||
| #include "url.h" | |||
| //#define DEBUG | |||
| //#define DEBUG_RTP_TCP | |||
| static int rtsp_read_play(AVFormatContext *s) | |||
| { | |||
| RTSPState *rt = s->priv_data; | |||
| @@ -191,9 +188,7 @@ int ff_rtsp_tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, | |||
| int id, len, i, ret; | |||
| RTSPStream *rtsp_st; | |||
| #ifdef DEBUG_RTP_TCP | |||
| av_dlog(s, "tcp_read_packet:\n"); | |||
| #endif | |||
| redo: | |||
| for (;;) { | |||
| RTSPMessageHeader reply; | |||
| @@ -212,9 +207,7 @@ redo: | |||
| return -1; | |||
| id = buf[0]; | |||
| len = AV_RB16(buf + 1); | |||
| #ifdef DEBUG_RTP_TCP | |||
| av_dlog(s, "id=%d len=%d\n", id, len); | |||
| #endif | |||
| if (len > buf_size || len < 12) | |||
| goto redo; | |||
| /* get the data */ | |||
| @@ -23,8 +23,8 @@ | |||
| * audio conversion routines | |||
| */ | |||
| #include "libavutil/avutil.h" | |||
| #include "libavutil/avstring.h" | |||
| #include "avstring.h" | |||
| #include "avutil.h" | |||
| #include "audioconvert.h" | |||
| static const char * const channel_names[] = { | |||
| @@ -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 7 | |||
| #define LIBAVUTIL_VERSION_MICRO 0 | |||
| #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | |||
| LIBAVUTIL_VERSION_MINOR, \ | |||
| @@ -60,6 +60,9 @@ | |||
| #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. | |||
| @@ -26,7 +26,7 @@ | |||
| * see http://joe.hotchkiss.com/programming/eval/eval.html | |||
| */ | |||
| #include "libavutil/avutil.h" | |||
| #include "avutil.h" | |||
| #include "eval.h" | |||
| typedef struct Parser { | |||
| @@ -23,7 +23,7 @@ | |||
| #include "imgutils.h" | |||
| #include "internal.h" | |||
| #include "libavutil/pixdesc.h" | |||
| #include "pixdesc.h" | |||
| void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], | |||
| const AVPixFmtDescriptor *pixdesc) | |||
| @@ -24,8 +24,8 @@ | |||
| * misc image utilities | |||
| */ | |||
| #include "libavutil/pixdesc.h" | |||
| #include "avutil.h" | |||
| #include "pixdesc.h" | |||
| /** | |||
| * Compute the max pixel step for each plane of an image with a | |||
| @@ -19,7 +19,7 @@ | |||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
| */ | |||
| #include "libavutil/intmath.h" | |||
| #include <stdint.h> | |||
| /* a*inverse[b]>>32 == a/b for all 0<=a<=16909558 && 2<=b<=256 | |||
| * for a>16909558, is an overestimate by less than 1 part in 1<<24 */ | |||
| @@ -24,11 +24,12 @@ | |||
| #include <strings.h> | |||
| #include <sys/time.h> | |||
| #include <time.h> | |||
| #include "avstring.h" | |||
| #include "avutil.h" | |||
| #include "eval.h" | |||
| #include "random_seed.h" | |||
| #include "parseutils.h" | |||
| #include "libavutil/avutil.h" | |||
| #include "libavutil/eval.h" | |||
| #include "libavutil/avstring.h" | |||
| #include "libavutil/random_seed.h" | |||
| typedef struct { | |||
| const char *abbr; | |||
| @@ -19,7 +19,7 @@ | |||
| #ifndef AVUTIL_PARSEUTILS_H | |||
| #define AVUTIL_PARSEUTILS_H | |||
| #include "libavutil/rational.h" | |||
| #include "rational.h" | |||
| /** | |||
| * @file | |||
| @@ -66,11 +66,19 @@ char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sam | |||
| return buf; | |||
| } | |||
| int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt) | |||
| { | |||
| return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? | |||
| 0 : sample_fmt_info[sample_fmt].bits >> 3; | |||
| } | |||
| #if FF_API_GET_BITS_PER_SAMPLE_FMT | |||
| int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) | |||
| { | |||
| 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, | |||
| @@ -60,14 +60,22 @@ enum AVSampleFormat av_get_sample_fmt(const char *name); | |||
| */ | |||
| 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); | |||
| /** | |||
| * Fill channel data pointers and linesizes for samples with sample | |||
| @@ -403,15 +403,19 @@ static void hScale_altivec_real(int16_t *dst, int dstW, | |||
| void ff_sws_init_swScale_altivec(SwsContext *c) | |||
| { | |||
| enum PixelFormat dstFormat = c->dstFormat; | |||
| if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) | |||
| return; | |||
| c->hScale = hScale_altivec_real; | |||
| c->yuv2yuvX = yuv2yuvX_altivec_real; | |||
| if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat)) { | |||
| c->yuv2yuvX = yuv2yuvX_altivec_real; | |||
| } | |||
| /* The following list of supported dstFormat values should | |||
| * match what's found in the body of ff_yuv2packedX_altivec() */ | |||
| if (!(c->flags & SWS_BITEXACT) && !c->alpPixBuf && | |||
| if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->alpPixBuf && | |||
| (c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA || | |||
| c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 || | |||
| c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)) { | |||
| @@ -353,17 +353,20 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, | |||
| output_pixel(&aDest[i], val); | |||
| } | |||
| } | |||
| #undef output_pixel | |||
| } | |||
| #define yuv2NBPS(bits, BE_LE, is_be) \ | |||
| static void yuv2yuvX ## bits ## BE_LE ## _c(const int16_t *lumFilter, \ | |||
| static void yuv2yuvX ## bits ## BE_LE ## _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, \ | |||
| uint16_t *dest, uint16_t *uDest, uint16_t *vDest, \ | |||
| uint16_t *aDest, int dstW, int chrDstW) \ | |||
| uint8_t *_dest, uint8_t *_uDest, uint8_t *_vDest, \ | |||
| uint8_t *_aDest, int dstW, int chrDstW) \ | |||
| { \ | |||
| uint16_t *dest = (uint16_t *) _dest, *uDest = (uint16_t *) _uDest, \ | |||
| *vDest = (uint16_t *) _vDest, *aDest = (uint16_t *) _aDest; \ | |||
| yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \ | |||
| chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ | |||
| alpSrc, \ | |||
| @@ -377,7 +380,7 @@ 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, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW, | |||
| enum PixelFormat dstFormat) | |||
| @@ -452,9 +455,13 @@ static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, const int16_t ** | |||
| 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, | |||
| 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,6 +1155,14 @@ static void abgrToA_c(int16_t *dst, const uint8_t *src, int width, uint32_t *unu | |||
| } | |||
| } | |||
| 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]<<6; | |||
| } | |||
| } | |||
| #define BGR2UV(type, name, shr, shg, shb, shp, maskr, maskg, maskb, RU, GU, BU, RV, GV, BV, S) \ | |||
| static void name ## _c(int16_t *dstU, int16_t *dstV, const uint8_t *src, const uint8_t *dummy, int width, uint32_t *unused)\ | |||
| {\ | |||
| @@ -1616,8 +1631,6 @@ static inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, | |||
| void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12; | |||
| 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,10 +1674,6 @@ static inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *dst2, int ds | |||
| 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*2+78, 16); | |||
| c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); | |||
| @@ -1687,6 +1696,37 @@ static inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *dst2, int ds | |||
| c->chrConvertRange(dst1, dst2, dstWidth); | |||
| } | |||
| static av_always_inline void | |||
| find_c_packed_planar_out_funcs(SwsContext *c, | |||
| yuv2planar1_fn *yuv2yuv1, yuv2planarX_fn *yuv2yuvX, | |||
| yuv2packed1_fn *yuv2packed1, yuv2packed2_fn *yuv2packed2, | |||
| yuv2packedX_fn *yuv2packedX) | |||
| { | |||
| enum PixelFormat dstFormat = c->dstFormat; | |||
| if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { | |||
| *yuv2yuvX = yuv2nv12X_c; | |||
| } else if (is16BPS(dstFormat)) { | |||
| *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX16BE_c : yuv2yuvX16LE_c; | |||
| } else if (is9_OR_10BPS(dstFormat)) { | |||
| if (dstFormat == PIX_FMT_YUV420P9BE || dstFormat == PIX_FMT_YUV420P9LE) { | |||
| *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX9BE_c : yuv2yuvX9LE_c; | |||
| } else { | |||
| *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX10BE_c : yuv2yuvX10LE_c; | |||
| } | |||
| } else { | |||
| *yuv2yuv1 = yuv2yuv1_c; | |||
| *yuv2yuvX = yuv2yuvX_c; | |||
| } | |||
| if(c->flags & SWS_FULL_CHR_H_INT) { | |||
| *yuv2packedX = yuv2rgbX_c_full; | |||
| } else { | |||
| *yuv2packed1 = yuv2packed1_c; | |||
| *yuv2packed2 = yuv2packed2_c; | |||
| *yuv2packedX = yuv2packedX_c; | |||
| } | |||
| } | |||
| #define DEBUG_SWSCALE_BUFFERS 0 | |||
| #define DEBUG_BUFFERS(...) if (DEBUG_SWSCALE_BUFFERS) av_log(c, AV_LOG_DEBUG, __VA_ARGS__) | |||
| @@ -1731,6 +1771,11 @@ static int swScale(SwsContext *c, const uint8_t* src[], | |||
| 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; | |||
| @@ -1869,37 +1914,31 @@ static int swScale(SwsContext *c, const uint8_t* src[], | |||
| #if HAVE_MMX | |||
| updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf); | |||
| #endif | |||
| if (dstY < dstH-2) { | |||
| if (dstY >= dstH-2) { | |||
| // hmm looks like we can't use MMX here without overwriting this array's tail | |||
| find_c_packed_planar_out_funcs(c, &yuv2yuv1, &yuv2yuvX, | |||
| &yuv2packed1, &yuv2packed2, | |||
| &yuv2packedX); | |||
| } | |||
| { | |||
| const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | |||
| 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, lumDither, chrDither); | |||
| } else { //General YV12 | |||
| c->yuv2yuvX(c, | |||
| yuv2yuvX(c, | |||
| vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, | |||
| vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, | |||
| chrVSrcPtr, vChrFilterSize, | |||
| @@ -1908,94 +1947,28 @@ static int swScale(SwsContext *c, const uint8_t* src[], | |||
| } else { | |||
| assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | |||
| assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); | |||
| if (vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB | |||
| if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB | |||
| int chrAlpha= vChrFilter[2*dstY+1]; | |||
| if(flags & SWS_FULL_CHR_H_INT) { | |||
| yuv2rgbX_c_full(c, //FIXME write a packed1_full function | |||
| vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | |||
| vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, | |||
| chrVSrcPtr, vChrFilterSize, | |||
| alpSrcPtr, dest, dstW, dstY); | |||
| } else { | |||
| c->yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1), | |||
| *chrVSrcPtr, *(chrVSrcPtr+1), | |||
| alpPixBuf ? *alpSrcPtr : NULL, | |||
| dest, dstW, chrAlpha, dstFormat, flags, dstY); | |||
| } | |||
| } else if (vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB | |||
| yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1), | |||
| *chrVSrcPtr, *(chrVSrcPtr+1), | |||
| alpPixBuf ? *alpSrcPtr : NULL, | |||
| dest, dstW, chrAlpha, dstFormat, flags, dstY); | |||
| } else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB | |||
| int lumAlpha= vLumFilter[2*dstY+1]; | |||
| int chrAlpha= vChrFilter[2*dstY+1]; | |||
| lumMmxFilter[2]= | |||
| lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001; | |||
| chrMmxFilter[2]= | |||
| chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001; | |||
| if(flags & SWS_FULL_CHR_H_INT) { | |||
| yuv2rgbX_c_full(c, //FIXME write a packed2_full function | |||
| vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | |||
| vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | |||
| alpSrcPtr, dest, dstW, dstY); | |||
| } else { | |||
| c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1), | |||
| *chrVSrcPtr, *(chrVSrcPtr+1), | |||
| alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL, | |||
| dest, dstW, lumAlpha, chrAlpha, dstY); | |||
| } | |||
| yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1), | |||
| *chrVSrcPtr, *(chrVSrcPtr+1), | |||
| alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL, | |||
| dest, dstW, lumAlpha, chrAlpha, dstY); | |||
| } else { //general RGB | |||
| if(flags & SWS_FULL_CHR_H_INT) { | |||
| yuv2rgbX_c_full(c, | |||
| vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | |||
| vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | |||
| alpSrcPtr, dest, dstW, dstY); | |||
| } else { | |||
| c->yuv2packedX(c, | |||
| vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | |||
| vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | |||
| alpSrcPtr, dest, dstW, dstY); | |||
| } | |||
| } | |||
| } | |||
| } else { // hmm looks like we can't use MMX here without overwriting this array's tail | |||
| const int16_t **lumSrcPtr= (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | |||
| 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 | |||
| yuv2nv12X_c(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 | |||
| const int chrSkipMask= (1<<c->chrDstVSubSample)-1; | |||
| if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | |||
| if (is16BPS(dstFormat) || is9_OR_10BPS(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 { | |||
| yuv2yuvX_c(c, vLumFilter+dstY*vLumFilterSize, | |||
| lumSrcPtr, vLumFilterSize, | |||
| vChrFilter+chrDstY*vChrFilterSize, | |||
| chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | |||
| alpSrcPtr, dest, uDest, vDest, aDest, | |||
| dstW, chrDstW, lumDither, chrDither); | |||
| } | |||
| } else { | |||
| assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | |||
| assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); | |||
| if(flags & SWS_FULL_CHR_H_INT) { | |||
| yuv2rgbX_c_full(c, | |||
| vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | |||
| vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | |||
| alpSrcPtr, dest, dstW, dstY); | |||
| } else { | |||
| yuv2packedX_c(c, | |||
| vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | |||
| vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | |||
| alpSrcPtr, dest, dstW, dstY); | |||
| yuv2packedX(c, | |||
| vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | |||
| vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | |||
| alpSrcPtr, dest, dstW, dstY); | |||
| } | |||
| } | |||
| } | |||
| @@ -2024,17 +1997,13 @@ static void sws_init_swScale_c(SwsContext *c) | |||
| { | |||
| enum PixelFormat srcFormat = c->srcFormat; | |||
| c->yuv2nv12X = yuv2nv12X_c; | |||
| c->yuv2yuv1 = yuv2yuv1_c; | |||
| c->yuv2yuvX = yuv2yuvX_c; | |||
| c->yuv2packed1 = yuv2packed1_c; | |||
| c->yuv2packed2 = yuv2packed2_c; | |||
| c->yuv2packedX = yuv2packedX_c; | |||
| find_c_packed_planar_out_funcs(c, &c->yuv2yuv1, &c->yuv2yuvX, | |||
| &c->yuv2packed1, &c->yuv2packed2, | |||
| &c->yuv2packedX); | |||
| c->hScale = hScale_c; | |||
| if (c->flags & SWS_FAST_BILINEAR) | |||
| { | |||
| if (c->flags & SWS_FAST_BILINEAR) { | |||
| c->hyscale_fast = hyscale_fast_c; | |||
| c->hcscale_fast = hcscale_fast_c; | |||
| } | |||
| @@ -2133,28 +2102,18 @@ static void sws_init_swScale_c(SwsContext *c) | |||
| } | |||
| 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; | |||
| } | |||
| } | |||
| if(isAnyRGB(c->srcFormat) || c->srcFormat == PIX_FMT_PAL8) | |||
| c->hScale16= hScale16_c; | |||
| switch (srcFormat) { | |||
| case PIX_FMT_GRAY8A : | |||
| c->alpSrcOffset = 1; | |||
| break; | |||
| case PIX_FMT_RGB32 : | |||
| case PIX_FMT_BGR32 : | |||
| c->alpSrcOffset = 3; | |||
| break; | |||
| } | |||
| if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { | |||
| if (c->srcRange) { | |||
| c->lumConvertRange = lumRangeFromJpeg_c; | |||
| @@ -59,6 +59,41 @@ typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[], | |||
| int srcStride[], int srcSliceY, int srcSliceH, | |||
| uint8_t* dst[], int dstStride[]); | |||
| 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, 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 { | |||
| /** | |||
| @@ -256,46 +291,11 @@ typedef struct SwsContext { | |||
| #endif | |||
| /* function pointers for swScale() */ | |||
| void (*yuv2nv12X )(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, | |||
| uint8_t *dest, uint8_t *uDest, | |||
| int dstW, int chrDstW, int dstFormat, const uint8_t *lumDither, const uint8_t *chrDither); | |||
| void (*yuv2yuv1 )(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, const uint8_t *lumDither, const uint8_t *chrDither); | |||
| void (*yuv2yuvX )(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); | |||
| void (*yuv2packed1)(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); | |||
| void (*yuv2packed2)(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); | |||
| void (*yuv2packedX)(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); | |||
| yuv2planar1_fn yuv2yuv1; | |||
| yuv2planarX_fn yuv2yuvX; | |||
| yuv2packed1_fn yuv2packed1; | |||
| yuv2packed2_fn yuv2packed2; | |||
| yuv2packedX_fn yuv2packedX; | |||
| void (*lumToYV12)(uint8_t *dst, const uint8_t *src, | |||
| int width, uint32_t *pal); ///< Unscaled conversion of luma plane to YV12 for horizontal scaler. | |||
| @@ -323,10 +323,6 @@ typedef struct SwsContext { | |||
| 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,56 +2351,64 @@ static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *d | |||
| 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) && 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 { | |||
| 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; | |||
| case PIX_FMT_BGR24: | |||
| case PIX_FMT_BGR24: | |||
| c->yuv2packed1 = RENAME(yuv2bgr24_1); | |||
| c->yuv2packed2 = RENAME(yuv2bgr24_2); | |||
| break; | |||
| case PIX_FMT_RGB555: | |||
| case PIX_FMT_RGB555: | |||
| c->yuv2packed1 = RENAME(yuv2rgb555_1); | |||
| c->yuv2packed2 = RENAME(yuv2rgb555_2); | |||
| break; | |||
| case PIX_FMT_RGB565: | |||
| case PIX_FMT_RGB565: | |||
| c->yuv2packed1 = RENAME(yuv2rgb565_1); | |||
| c->yuv2packed2 = RENAME(yuv2rgb565_2); | |||
| break; | |||
| case PIX_FMT_YUYV422: | |||
| case PIX_FMT_YUYV422: | |||
| c->yuv2packed1 = RENAME(yuv2yuyv422_1); | |||
| c->yuv2packed2 = RENAME(yuv2yuyv422_2); | |||
| break; | |||
| default: | |||
| default: | |||
| break; | |||
| } | |||
| } | |||
| } | |||