* 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
Unified · Split
| @@ -107,7 +107,7 @@ Configuration options: · 106 unmodified lines | |||
| 107 | --disable-mdct disable MDCT code | 107 | --disable-mdct disable MDCT code |
| 108 | --disable-rdft disable RDFT code | 108 | --disable-rdft disable RDFT code |
| 109 | --enable-vaapi enable VAAPI code | 109 | --enable-vaapi enable VAAPI code |
| 110 | --disable-vdpau disable VDPAU code | 110 | --enable-vdpau enable VDPAU code |
| 111 | --disable-dxva2 disable DXVA2 code | 111 | --disable-dxva2 disable DXVA2 code |
| 112 | --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary) | 112 | --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary) |
| 113 | --enable-hardcoded-tables use hardcoded tables instead of runtime generation | 113 | --enable-hardcoded-tables use hardcoded tables instead of runtime generation |
| @@ -50,6 +50,10 @@ API changes, most recent first: · 49 unmodified lines | |||
| 50 | 2011-05-XX - XXXXXX - lavfi 2.6.0 - avcodec.h | 50 | 2011-05-XX - XXXXXX - lavfi 2.6.0 - avcodec.h |
| 51 | Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h. | 51 | Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h. |
| 52 | 52 | ||
| 53 | 2011-06-07 - a6703fa - lavu 51.4.0 - av_get_bytes_per_sample() | ||
| 54 | Add av_get_bytes_per_sample() in libavutil/samplefmt.h. | ||
| 55 | Deprecate av_get_bits_per_sample_fmt(). | ||
| 56 | |||
| 53 | 2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h | 57 | 2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h |
| 54 | Add av_opt_free convenience function. | 58 | Add av_opt_free convenience function. |
| 55 | 59 | ||
| @@ -54,9 +54,6 @@ · 53 unmodified lines | |||
| 54 | const char program_name[] = "ffplay"; | 54 | const char program_name[] = "ffplay"; |
| 55 | const int program_birth_year = 2003; | 55 | const int program_birth_year = 2003; |
| 56 | 56 | ||
| 57 | //#define DEBUG | ||
| 58 | //#define DEBUG_SYNC | ||
| 59 | |||
| 60 | #define MAX_QUEUE_SIZE (15 * 1024 * 1024) | 57 | #define MAX_QUEUE_SIZE (15 * 1024 * 1024) |
| 61 | #define MIN_AUDIOQ_SIZE (20 * 16 * 1024) | 58 | #define MIN_AUDIOQ_SIZE (20 * 16 * 1024) |
| 62 | #define MIN_FRAMES 5 | 59 | #define MIN_FRAMES 5 |
| @@ -1052,10 +1049,9 @@ static double compute_target_time(double frame_current_pts, VideoState *is) · 989 unmodified lines | |||
| 1052 | } | 1049 | } |
| 1053 | } | 1050 | } |
| 1054 | is->frame_timer += delay; | 1051 | is->frame_timer += delay; |
| 1055 | #if defined(DEBUG_SYNC) | 1052 | |
| 1056 | printf("video: delay=%0.3f actual_delay=%0.3f pts=%0.3f A-V=%f\n", | 1053 | av_dlog(NULL, "video: delay=%0.3f pts=%0.3f A-V=%f\n", |
| 1057 | delay, actual_delay, frame_current_pts, -diff); | 1054 | delay, frame_current_pts, -diff); |
| 1058 | #endif | ||
| 1059 | 1055 | ||
| 1060 | return is->frame_timer; | 1056 | return is->frame_timer; |
| 1061 | } | 1057 | } |
| @@ -2033,7 +2029,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) · 971 unmodified lines | |||
| 2033 | n = 2 * dec->channels; | 2029 | n = 2 * dec->channels; |
| 2034 | is->audio_clock += (double)data_size / | 2030 | is->audio_clock += (double)data_size / |
| 2035 | (double)(n * dec->sample_rate); | 2031 | (double)(n * dec->sample_rate); |
| 2036 | #if defined(DEBUG_SYNC) | 2032 | #ifdef DEBUG |
| 2037 | { | 2033 | { |
| 2038 | static double last_clock; | 2034 | static double last_clock; |
| 2039 | printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n", | 2035 | printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n", |
| @@ -127,7 +127,8 @@ OBJS-$(CONFIG_DVVIDEO_DECODER) += dv.o dvdata.o · 126 unmodified lines | |||
| 127 | OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o dvdata.o | 127 | OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o dvdata.o |
| 128 | OBJS-$(CONFIG_DXA_DECODER) += dxa.o | 128 | OBJS-$(CONFIG_DXA_DECODER) += dxa.o |
| 129 | OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3dec_data.o | 129 | OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3dec_data.o |
| 130 | OBJS-$(CONFIG_EAC3_ENCODER) += ac3enc_float.o ac3tab.o ac3.o kbdwin.o | 130 | OBJS-$(CONFIG_EAC3_ENCODER) += eac3enc.o ac3enc_float.o ac3tab.o \ |
| 131 | ac3.o kbdwin.o | ||
| 131 | OBJS-$(CONFIG_EACMV_DECODER) += eacmv.o | 132 | OBJS-$(CONFIG_EACMV_DECODER) += eacmv.o |
| 132 | OBJS-$(CONFIG_EAMAD_DECODER) += eamad.o eaidct.o mpeg12.o \ | 133 | OBJS-$(CONFIG_EAMAD_DECODER) += eamad.o eaidct.o mpeg12.o \ |
| 133 | mpeg12data.o mpegvideo.o \ | 134 | mpeg12data.o mpegvideo.o \ |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | |||
| 29 | #include "libavcodec/aac_tables.h" | 29 | #include "libavcodec/aac_tables.h" |
| 30 | #else | 30 | #else |
| 31 | #include "libavutil/mathematics.h" | 31 | #include "libavutil/mathematics.h" |
| 32 | #include "libavcodec/aac.h" | 32 | #include "aac.h" |
| 33 | float ff_aac_pow2sf_tab[428]; | 33 | float ff_aac_pow2sf_tab[428]; |
| 34 | 34 | ||
| 35 | void ff_aac_tableinit(void) | 35 | void ff_aac_tableinit(void) |
| @@ -164,7 +164,6 @@ typedef struct AC3EncOptions { · 163 unmodified lines | |||
| 164 | int cpl_start; | 164 | int cpl_start; |
| 165 | } AC3EncOptions; | 165 | } AC3EncOptions; |
| 166 | 166 | ||
| 167 | |||
| 168 | void ff_ac3_common_init(void); | 167 | void ff_ac3_common_init(void); |
| 169 | 168 | ||
| 170 | extern const int64_t ff_ac3_channel_layouts[]; | 169 | extern const int64_t ff_ac3_channel_layouts[]; |
| @@ -26,7 +26,6 @@ · 25 unmodified lines | |||
| 26 | * The simplest AC-3 encoder. | 26 | * The simplest AC-3 encoder. |
| 27 | */ | 27 | */ |
| 28 | 28 | ||
| 29 | //#define DEBUG | ||
| 30 | //#define ASSERT_LEVEL 2 | 29 | //#define ASSERT_LEVEL 2 |
| 31 | 30 | ||
| 32 | #include <stdint.h> | 31 | #include <stdint.h> |
| @@ -44,153 +43,8 @@ · 11 unmodified lines | |||
| 44 | #include "audioconvert.h" | 43 | #include "audioconvert.h" |
| 45 | #include "fft.h" | 44 | #include "fft.h" |
| 46 | 45 | ||
| 47 | 46 | #include "ac3enc.h" | |
| 48 | #ifndef CONFIG_AC3ENC_FLOAT | 47 | #include "eac3enc.h" |
| 49 | #define CONFIG_AC3ENC_FLOAT 0 | ||
| 50 | #endif | ||
| 51 | |||
| 52 | |||
| 53 | /** Maximum number of exponent groups. +1 for separate DC exponent. */ | ||
| 54 | #define AC3_MAX_EXP_GROUPS 85 | ||
| 55 | |||
| 56 | #if CONFIG_AC3ENC_FLOAT | ||
| 57 | #define MAC_COEF(d,a,b) ((d)+=(a)*(b)) | ||
| 58 | typedef float SampleType; | ||
| 59 | typedef float CoefType; | ||
| 60 | typedef float CoefSumType; | ||
| 61 | #else | ||
| 62 | #define MAC_COEF(d,a,b) MAC64(d,a,b) | ||
| 63 | typedef int16_t SampleType; | ||
| 64 | typedef int32_t CoefType; | ||
| 65 | typedef int64_t CoefSumType; | ||
| 66 | #endif | ||
| 67 | |||
| 68 | typedef struct AC3MDCTContext { | ||
| 69 | const SampleType *window; ///< MDCT window function | ||
| 70 | FFTContext fft; ///< FFT context for MDCT calculation | ||
| 71 | } AC3MDCTContext; | ||
| 72 | |||
| 73 | |||
| 74 | /** | ||
| 75 | * Data for a single audio block. | ||
| 76 | */ | ||
| 77 | typedef struct AC3Block { | ||
| 78 | CoefType **mdct_coef; ///< MDCT coefficients | ||
| 79 | int32_t **fixed_coef; ///< fixed-point MDCT coefficients | ||
| 80 | uint8_t **exp; ///< original exponents | ||
| 81 | uint8_t **grouped_exp; ///< grouped exponents | ||
| 82 | int16_t **psd; ///< psd per frequency bin | ||
| 83 | int16_t **band_psd; ///< psd per critical band | ||
| 84 | int16_t **mask; ///< masking curve | ||
| 85 | uint16_t **qmant; ///< quantized mantissas | ||
| 86 | uint8_t **cpl_coord_exp; ///< coupling coord exponents (cplcoexp) | ||
| 87 | uint8_t **cpl_coord_mant; ///< coupling coord mantissas (cplcomant) | ||
| 88 | uint8_t coeff_shift[AC3_MAX_CHANNELS]; ///< fixed-point coefficient shift values | ||
| 89 | uint8_t new_rematrixing_strategy; ///< send new rematrixing flags in this block | ||
| 90 | int num_rematrixing_bands; ///< number of rematrixing bands | ||
| 91 | uint8_t rematrixing_flags[4]; ///< rematrixing flags | ||
| 92 | int new_cpl_strategy; ///< send new coupling strategy | ||
| 93 | int cpl_in_use; ///< coupling in use for this block (cplinu) | ||
| 94 | uint8_t channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl) | ||
| 95 | int num_cpl_channels; ///< number of channels in coupling | ||
| 96 | uint8_t new_cpl_coords; ///< send new coupling coordinates (cplcoe) | ||
| 97 | uint8_t cpl_master_exp[AC3_MAX_CHANNELS]; ///< coupling coord master exponents (mstrcplco) | ||
| 98 | int new_snr_offsets; ///< send new SNR offsets | ||
| 99 | int new_cpl_leak; ///< send new coupling leak info | ||
| 100 | int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant) | ||
| 101 | } AC3Block; | ||
| 102 | |||
| 103 | /** | ||
| 104 | * AC-3 encoder private context. | ||
| 105 | */ | ||
| 106 | typedef struct AC3EncodeContext { | ||
| 107 | AVClass *av_class; ///< AVClass used for AVOption | ||
| 108 | AC3EncOptions options; ///< encoding options | ||
| 109 | PutBitContext pb; ///< bitstream writer context | ||
| 110 | DSPContext dsp; | ||
| 111 | AC3DSPContext ac3dsp; ///< AC-3 optimized functions | ||
| 112 | AC3MDCTContext mdct; ///< MDCT context | ||
| 113 | |||
| 114 | AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info | ||
| 115 | |||
| 116 | int eac3; ///< indicates if this is E-AC-3 vs. AC-3 | ||
| 117 | int bitstream_id; ///< bitstream id (bsid) | ||
| 118 | int bitstream_mode; ///< bitstream mode (bsmod) | ||
| 119 | |||
| 120 | int bit_rate; ///< target bit rate, in bits-per-second | ||
| 121 | int sample_rate; ///< sampling frequency, in Hz | ||
| 122 | |||
| 123 | int frame_size_min; ///< minimum frame size in case rounding is necessary | ||
| 124 | int frame_size; ///< current frame size in bytes | ||
| 125 | int frame_size_code; ///< frame size code (frmsizecod) | ||
| 126 | uint16_t crc_inv[2]; | ||
| 127 | int64_t bits_written; ///< bit count (used to avg. bitrate) | ||
| 128 | int64_t samples_written; ///< sample count (used to avg. bitrate) | ||
| 129 | |||
| 130 | int fbw_channels; ///< number of full-bandwidth channels (nfchans) | ||
| 131 | int channels; ///< total number of channels (nchans) | ||
| 132 | int lfe_on; ///< indicates if there is an LFE channel (lfeon) | ||
| 133 | int lfe_channel; ///< channel index of the LFE channel | ||
| 134 | int has_center; ///< indicates if there is a center channel | ||
| 135 | int has_surround; ///< indicates if there are one or more surround channels | ||
| 136 | int channel_mode; ///< channel mode (acmod) | ||
| 137 | const uint8_t *channel_map; ///< channel map used to reorder channels | ||
| 138 | |||
| 139 | int center_mix_level; ///< center mix level code | ||
| 140 | int surround_mix_level; ///< surround mix level code | ||
| 141 | int ltrt_center_mix_level; ///< Lt/Rt center mix level code | ||
| 142 | int ltrt_surround_mix_level; ///< Lt/Rt surround mix level code | ||
| 143 | int loro_center_mix_level; ///< Lo/Ro center mix level code | ||
| 144 | int loro_surround_mix_level; ///< Lo/Ro surround mix level code | ||
| 145 | |||
| 146 | int cutoff; ///< user-specified cutoff frequency, in Hz | ||
| 147 | int bandwidth_code; ///< bandwidth code (0 to 60) (chbwcod) | ||
| 148 | int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin (strtmant) | ||
| 149 | int cpl_end_freq; ///< coupling channel end frequency bin | ||
| 150 | |||
| 151 | int cpl_on; ///< coupling turned on for this frame | ||
| 152 | int cpl_enabled; ///< coupling enabled for all frames | ||
| 153 | int num_cpl_subbands; ///< number of coupling subbands (ncplsubnd) | ||
| 154 | int num_cpl_bands; ///< number of coupling bands (ncplbnd) | ||
| 155 | uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS]; ///< number of coeffs in each coupling band | ||
| 156 | |||
| 157 | int rematrixing_enabled; ///< stereo rematrixing enabled | ||
| 158 | |||
| 159 | /* bitrate allocation control */ | ||
| 160 | int slow_gain_code; ///< slow gain code (sgaincod) | ||
| 161 | int slow_decay_code; ///< slow decay code (sdcycod) | ||
| 162 | int fast_decay_code; ///< fast decay code (fdcycod) | ||
| 163 | int db_per_bit_code; ///< dB/bit code (dbpbcod) | ||
| 164 | int floor_code; ///< floor code (floorcod) | ||
| 165 | AC3BitAllocParameters bit_alloc; ///< bit allocation parameters | ||
| 166 | int coarse_snr_offset; ///< coarse SNR offsets (csnroffst) | ||
| 167 | int fast_gain_code[AC3_MAX_CHANNELS]; ///< fast gain codes (signal-to-mask ratio) (fgaincod) | ||
| 168 | int fine_snr_offset[AC3_MAX_CHANNELS]; ///< fine SNR offsets (fsnroffst) | ||
| 169 | int frame_bits_fixed; ///< number of non-coefficient bits for fixed parameters | ||
| 170 | int frame_bits; ///< all frame bits except exponents and mantissas | ||
| 171 | int exponent_bits; ///< number of bits used for exponents | ||
| 172 | |||
| 173 | SampleType **planar_samples; | ||
| 174 | uint8_t *bap_buffer; | ||
| 175 | uint8_t *bap1_buffer; | ||
| 176 | CoefType *mdct_coef_buffer; | ||
| 177 | int32_t *fixed_coef_buffer; | ||
| 178 | uint8_t *exp_buffer; | ||
| 179 | uint8_t *grouped_exp_buffer; | ||
| 180 | int16_t *psd_buffer; | ||
| 181 | int16_t *band_psd_buffer; | ||
| 182 | int16_t *mask_buffer; | ||
| 183 | uint16_t *qmant_buffer; | ||
| 184 | uint8_t *cpl_coord_exp_buffer; | ||
| 185 | uint8_t *cpl_coord_mant_buffer; | ||
| 186 | |||
| 187 | uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies | ||
| 188 | uint8_t exp_ref_block[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< reference blocks for EXP_REUSE | ||
| 189 | uint8_t *ref_bap [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap) | ||
| 190 | int ref_bap_set; ///< indicates if ref_bap pointers have been set | ||
| 191 | |||
| 192 | DECLARE_ALIGNED(32, SampleType, windowed_samples)[AC3_WINDOW_SIZE]; | ||
| 193 | } AC3EncodeContext; | ||
| 194 | 48 | ||
| 195 | typedef struct AC3Mant { | 49 | typedef struct AC3Mant { |
| 196 | uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; ///< mantissa pointers for bap=1,2,4 | 50 | 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) · 518 unmodified lines | |||
| 715 | } | 569 | } |
| 716 | } | 570 | } |
| 717 | 571 | ||
| 718 | if (s->eac3) { | 572 | if (CONFIG_EAC3_ENCODER && s->eac3) |
| 719 | /* set first cpl coords */ | 573 | ff_eac3_set_cpl_states(s); |
| 720 | int first_cpl_coords[AC3_MAX_CHANNELS]; | ||
| 721 | for (ch = 1; ch <= s->fbw_channels; ch++) | ||
| 722 | first_cpl_coords[ch] = 1; | ||
| 723 | for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | ||
| 724 | AC3Block *block = &s->blocks[blk]; | ||
| 725 | for (ch = 1; ch <= s->fbw_channels; ch++) { | ||
| 726 | if (block->channel_in_cpl[ch]) { | ||
| 727 | if (first_cpl_coords[ch]) { | ||
| 728 | block->new_cpl_coords = 2; | ||
| 729 | first_cpl_coords[ch] = 0; | ||
| 730 | } | ||
| 731 | } else { | ||
| 732 | first_cpl_coords[ch] = 1; | ||
| 733 | } | ||
| 734 | } | ||
| 735 | } | ||
| 736 | |||
| 737 | /* set first cpl leak */ | ||
| 738 | for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | ||
| 739 | AC3Block *block = &s->blocks[blk]; | ||
| 740 | if (block->cpl_in_use) { | ||
| 741 | block->new_cpl_leak = 2; | ||
| 742 | break; | ||
| 743 | } | ||
| 744 | } | ||
| 745 | } | ||
| 746 | #endif /* CONFIG_AC3ENC_FLOAT */ | 574 | #endif /* CONFIG_AC3ENC_FLOAT */ |
| 747 | } | 575 | } |
| 748 | 576 | ||
| @@ -1879,79 +1707,6 @@ static void ac3_output_frame_header(AC3EncodeContext *s) · 1130 unmodified lines | |||
| 1879 | } | 1707 | } |
| 1880 | 1708 | ||
| 1881 | 1709 | ||
| 1882 | /** | ||
| 1883 | * Write the E-AC-3 frame header to the output bitstream. | ||
| 1884 | */ | ||
| 1885 | static void eac3_output_frame_header(AC3EncodeContext *s) | ||
| 1886 | { | ||
| 1887 | int blk, ch; | ||
| 1888 | AC3EncOptions *opt = &s->options; | ||
| 1889 | |||
| 1890 | put_bits(&s->pb, 16, 0x0b77); /* sync word */ | ||
| 1891 | |||
| 1892 | /* BSI header */ | ||
| 1893 | put_bits(&s->pb, 2, 0); /* stream type = independent */ | ||
| 1894 | put_bits(&s->pb, 3, 0); /* substream id = 0 */ | ||
| 1895 | put_bits(&s->pb, 11, (s->frame_size / 2) - 1); /* frame size */ | ||
| 1896 | if (s->bit_alloc.sr_shift) { | ||
| 1897 | put_bits(&s->pb, 2, 0x3); /* fscod2 */ | ||
| 1898 | put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ | ||
| 1899 | } else { | ||
| 1900 | put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ | ||
| 1901 | put_bits(&s->pb, 2, 0x3); /* number of blocks = 6 */ | ||
| 1902 | } | ||
| 1903 | put_bits(&s->pb, 3, s->channel_mode); /* audio coding mode */ | ||
| 1904 | put_bits(&s->pb, 1, s->lfe_on); /* LFE channel indicator */ | ||
| 1905 | put_bits(&s->pb, 5, s->bitstream_id); /* bitstream id (EAC3=16) */ | ||
| 1906 | put_bits(&s->pb, 5, -opt->dialogue_level); /* dialogue normalization level */ | ||
| 1907 | put_bits(&s->pb, 1, 0); /* no compression gain */ | ||
| 1908 | put_bits(&s->pb, 1, 0); /* no mixing metadata */ | ||
| 1909 | /* TODO: mixing metadata */ | ||
| 1910 | put_bits(&s->pb, 1, 0); /* no info metadata */ | ||
| 1911 | /* TODO: info metadata */ | ||
| 1912 | put_bits(&s->pb, 1, 0); /* no additional bit stream info */ | ||
| 1913 | |||
| 1914 | /* frame header */ | ||
| 1915 | put_bits(&s->pb, 1, 1); /* exponent strategy syntax = each block */ | ||
| 1916 | put_bits(&s->pb, 1, 0); /* aht enabled = no */ | ||
| 1917 | put_bits(&s->pb, 2, 0); /* snr offset strategy = 1 */ | ||
| 1918 | put_bits(&s->pb, 1, 0); /* transient pre-noise processing enabled = no */ | ||
| 1919 | put_bits(&s->pb, 1, 0); /* block switch syntax enabled = no */ | ||
| 1920 | put_bits(&s->pb, 1, 0); /* dither flag syntax enabled = no */ | ||
| 1921 | put_bits(&s->pb, 1, 0); /* bit allocation model syntax enabled = no */ | ||
| 1922 | put_bits(&s->pb, 1, 0); /* fast gain codes enabled = no */ | ||
| 1923 | put_bits(&s->pb, 1, 0); /* dba syntax enabled = no */ | ||
| 1924 | put_bits(&s->pb, 1, 0); /* skip field syntax enabled = no */ | ||
| 1925 | put_bits(&s->pb, 1, 0); /* spx enabled = no */ | ||
| 1926 | /* coupling strategy use flags */ | ||
| 1927 | if (s->channel_mode > AC3_CHMODE_MONO) { | ||
| 1928 | put_bits(&s->pb, 1, s->blocks[0].cpl_in_use); | ||
| 1929 | for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) { | ||
| 1930 | AC3Block *block = &s->blocks[blk]; | ||
| 1931 | put_bits(&s->pb, 1, block->new_cpl_strategy); | ||
| 1932 | if (block->new_cpl_strategy) | ||
| 1933 | put_bits(&s->pb, 1, block->cpl_in_use); | ||
| 1934 | } | ||
| 1935 | } | ||
| 1936 | /* exponent strategy */ | ||
| 1937 | for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | ||
| 1938 | for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) | ||
| 1939 | put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); | ||
| 1940 | if (s->lfe_on) { | ||
| 1941 | for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | ||
| 1942 | put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]); | ||
| 1943 | } | ||
| 1944 | /* E-AC-3 to AC-3 converter exponent strategy (unfortunately not optional...) */ | ||
| 1945 | for (ch = 1; ch <= s->fbw_channels; ch++) | ||
| 1946 | put_bits(&s->pb, 5, 0); | ||
| 1947 | /* snr offsets */ | ||
| 1948 | put_bits(&s->pb, 6, s->coarse_snr_offset); | ||
| 1949 | put_bits(&s->pb, 4, s->fine_snr_offset[1]); | ||
| 1950 | /* block start info */ | ||
| 1951 | put_bits(&s->pb, 1, 0); | ||
| 1952 | } | ||
| 1953 | |||
| 1954 | |||
| 1955 | /** | 1710 | /** |
| 1956 | * Write one audio block to the output bitstream. | 1711 | * Write one audio block to the output bitstream. |
| 1957 | */ | 1712 | */ |
| @@ -2235,8 +1990,8 @@ static void output_frame(AC3EncodeContext *s, unsigned char *frame) · 277 unmodified lines | |||
| 2235 | 1990 | ||
| 2236 | init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE); | 1991 | init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE); |
| 2237 | 1992 | ||
| 2238 | if (s->eac3) | 1993 | if (CONFIG_EAC3_ENCODER && s->eac3) |
| 2239 | eac3_output_frame_header(s); | 1994 | ff_eac3_output_frame_header(s); |
| 2240 | else | 1995 | else |
| 2241 | ac3_output_frame_header(s); | 1996 | ac3_output_frame_header(s); |
| 2242 | 1997 | ||
| @@ -0,0 +1,214 @@ | |||
| 1 | /* | ||
| 2 | * AC-3 encoder & E-AC-3 encoder common header | ||
| 3 | * Copyright (c) 2000 Fabrice Bellard | ||
| 4 | * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com> | ||
| 5 | * | ||
| 6 | * This file is part of Libav. | ||
| 7 | * | ||
| 8 | * Libav is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU Lesser General Public | ||
| 10 | * License as published by the Free Software Foundation; either | ||
| 11 | * version 2.1 of the License, or (at your option) any later version. | ||
| 12 | * | ||
| 13 | * Libav is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * Lesser General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU Lesser General Public | ||
| 19 | * License along with Libav; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 21 | */ | ||
| 22 | |||
| 23 | /** | ||
| 24 | * @file | ||
| 25 | * AC-3 encoder & E-AC-3 encoder common header | ||
| 26 | */ | ||
| 27 | |||
| 28 | #ifndef AVCODEC_AC3ENC_H | ||
| 29 | #define AVCODEC_AC3ENC_H | ||
| 30 | |||
| 31 | #include <stdint.h> | ||
| 32 | #include "ac3.h" | ||
| 33 | #include "ac3dsp.h" | ||
| 34 | #include "avcodec.h" | ||
| 35 | #include "dsputil.h" | ||
| 36 | #include "put_bits.h" | ||
| 37 | #include "fft.h" | ||
| 38 | |||
| 39 | #ifndef CONFIG_AC3ENC_FLOAT | ||
| 40 | #define CONFIG_AC3ENC_FLOAT 0 | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #if CONFIG_AC3ENC_FLOAT | ||
| 44 | #define MAC_COEF(d,a,b) ((d)+=(a)*(b)) | ||
| 45 | typedef float SampleType; | ||
| 46 | typedef float CoefType; | ||
| 47 | typedef float CoefSumType; | ||
| 48 | #else | ||
| 49 | #define MAC_COEF(d,a,b) MAC64(d,a,b) | ||
| 50 | typedef int16_t SampleType; | ||
| 51 | typedef int32_t CoefType; | ||
| 52 | typedef int64_t CoefSumType; | ||
| 53 | #endif | ||
| 54 | |||
| 55 | typedef struct AC3MDCTContext { | ||
| 56 | const SampleType *window; ///< MDCT window function | ||
| 57 | FFTContext fft; ///< FFT context for MDCT calculation | ||
| 58 | } AC3MDCTContext; | ||
| 59 | #if 0 | ||
| 60 | /** | ||
| 61 | * Encoding Options used by AVOption. | ||
| 62 | */ | ||
| 63 | typedef struct AC3EncOptions { | ||
| 64 | /* AC-3 metadata options*/ | ||
| 65 | int dialogue_level; | ||
| 66 | int bitstream_mode; | ||
| 67 | float center_mix_level; | ||
| 68 | float surround_mix_level; | ||
| 69 | int dolby_surround_mode; | ||
| 70 | int audio_production_info; | ||
| 71 | int mixing_level; | ||
| 72 | int room_type; | ||
| 73 | int copyright; | ||
| 74 | int original; | ||
| 75 | int extended_bsi_1; | ||
| 76 | int preferred_stereo_downmix; | ||
| 77 | float ltrt_center_mix_level; | ||
| 78 | float ltrt_surround_mix_level; | ||
| 79 | float loro_center_mix_level; | ||
| 80 | float loro_surround_mix_level; | ||
| 81 | int extended_bsi_2; | ||
| 82 | int dolby_surround_ex_mode; | ||
| 83 | int dolby_headphone_mode; | ||
| 84 | int ad_converter_type; | ||
| 85 | |||
| 86 | /* other encoding options */ | ||
| 87 | int allow_per_frame_metadata; | ||
| 88 | int stereo_rematrixing; | ||
| 89 | int channel_coupling; | ||
| 90 | int cpl_start; | ||
| 91 | } AC3EncOptions; | ||
| 92 | #endif | ||
| 93 | /** | ||
| 94 | * Data for a single audio block. | ||
| 95 | */ | ||
| 96 | typedef struct AC3Block { | ||
| 97 | CoefType **mdct_coef; ///< MDCT coefficients | ||
| 98 | int32_t **fixed_coef; ///< fixed-point MDCT coefficients | ||
| 99 | uint8_t **exp; ///< original exponents | ||
| 100 | uint8_t **grouped_exp; ///< grouped exponents | ||
| 101 | int16_t **psd; ///< psd per frequency bin | ||
| 102 | int16_t **band_psd; ///< psd per critical band | ||
| 103 | int16_t **mask; ///< masking curve | ||
| 104 | uint16_t **qmant; ///< quantized mantissas | ||
| 105 | uint8_t **cpl_coord_exp; ///< coupling coord exponents (cplcoexp) | ||
| 106 | uint8_t **cpl_coord_mant; ///< coupling coord mantissas (cplcomant) | ||
| 107 | uint8_t coeff_shift[AC3_MAX_CHANNELS]; ///< fixed-point coefficient shift values | ||
| 108 | uint8_t new_rematrixing_strategy; ///< send new rematrixing flags in this block | ||
| 109 | int num_rematrixing_bands; ///< number of rematrixing bands | ||
| 110 | uint8_t rematrixing_flags[4]; ///< rematrixing flags | ||
| 111 | int new_cpl_strategy; ///< send new coupling strategy | ||
| 112 | int cpl_in_use; ///< coupling in use for this block (cplinu) | ||
| 113 | uint8_t channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl) | ||
| 114 | int num_cpl_channels; ///< number of channels in coupling | ||
| 115 | uint8_t new_cpl_coords; ///< send new coupling coordinates (cplcoe) | ||
| 116 | uint8_t cpl_master_exp[AC3_MAX_CHANNELS]; ///< coupling coord master exponents (mstrcplco) | ||
| 117 | int new_snr_offsets; ///< send new SNR offsets | ||
| 118 | int new_cpl_leak; ///< send new coupling leak info | ||
| 119 | int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant) | ||
| 120 | } AC3Block; | ||
| 121 | |||
| 122 | /** | ||
| 123 | * AC-3 encoder private context. | ||
| 124 | */ | ||
| 125 | typedef struct AC3EncodeContext { | ||
| 126 | AVClass *av_class; ///< AVClass used for AVOption | ||
| 127 | AC3EncOptions options; ///< encoding options | ||
| 128 | PutBitContext pb; ///< bitstream writer context | ||
| 129 | DSPContext dsp; | ||
| 130 | AC3DSPContext ac3dsp; ///< AC-3 optimized functions | ||
| 131 | AC3MDCTContext mdct; ///< MDCT context | ||
| 132 | |||
| 133 | AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info | ||
| 134 | |||
| 135 | int eac3; ///< indicates if this is E-AC-3 vs. AC-3 | ||
| 136 | int bitstream_id; ///< bitstream id (bsid) | ||
| 137 | int bitstream_mode; ///< bitstream mode (bsmod) | ||
| 138 | |||
| 139 | int bit_rate; ///< target bit rate, in bits-per-second | ||
| 140 | int sample_rate; ///< sampling frequency, in Hz | ||
| 141 | |||
| 142 | int frame_size_min; ///< minimum frame size in case rounding is necessary | ||
| 143 | int frame_size; ///< current frame size in bytes | ||
| 144 | int frame_size_code; ///< frame size code (frmsizecod) | ||
| 145 | uint16_t crc_inv[2]; | ||
| 146 | int64_t bits_written; ///< bit count (used to avg. bitrate) | ||
| 147 | int64_t samples_written; ///< sample count (used to avg. bitrate) | ||
| 148 | |||
| 149 | int fbw_channels; ///< number of full-bandwidth channels (nfchans) | ||
| 150 | int channels; ///< total number of channels (nchans) | ||
| 151 | int lfe_on; ///< indicates if there is an LFE channel (lfeon) | ||
| 152 | int lfe_channel; ///< channel index of the LFE channel | ||
| 153 | int has_center; ///< indicates if there is a center channel | ||
| 154 | int has_surround; ///< indicates if there are one or more surround channels | ||
| 155 | int channel_mode; ///< channel mode (acmod) | ||
| 156 | const uint8_t *channel_map; ///< channel map used to reorder channels | ||
| 157 | |||
| 158 | int center_mix_level; ///< center mix level code | ||
| 159 | int surround_mix_level; ///< surround mix level code | ||
| 160 | int ltrt_center_mix_level; ///< Lt/Rt center mix level code | ||
| 161 | int ltrt_surround_mix_level; ///< Lt/Rt surround mix level code | ||
| 162 | int loro_center_mix_level; ///< Lo/Ro center mix level code | ||
| 163 | int loro_surround_mix_level; ///< Lo/Ro surround mix level code | ||
| 164 | |||
| 165 | int cutoff; ///< user-specified cutoff frequency, in Hz | ||
| 166 | int bandwidth_code; ///< bandwidth code (0 to 60) (chbwcod) | ||
| 167 | int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin (strtmant) | ||
| 168 | int cpl_end_freq; ///< coupling channel end frequency bin | ||
| 169 | |||
| 170 | int cpl_on; ///< coupling turned on for this frame | ||
| 171 | int cpl_enabled; ///< coupling enabled for all frames | ||
| 172 | int num_cpl_subbands; ///< number of coupling subbands (ncplsubnd) | ||
| 173 | int num_cpl_bands; ///< number of coupling bands (ncplbnd) | ||
| 174 | uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS]; ///< number of coeffs in each coupling band | ||
| 175 | |||
| 176 | int rematrixing_enabled; ///< stereo rematrixing enabled | ||
| 177 | |||
| 178 | /* bitrate allocation control */ | ||
| 179 | int slow_gain_code; ///< slow gain code (sgaincod) | ||
| 180 | int slow_decay_code; ///< slow decay code (sdcycod) | ||
| 181 | int fast_decay_code; ///< fast decay code (fdcycod) | ||
| 182 | int db_per_bit_code; ///< dB/bit code (dbpbcod) | ||
| 183 | int floor_code; ///< floor code (floorcod) | ||
| 184 | AC3BitAllocParameters bit_alloc; ///< bit allocation parameters | ||
| 185 | int coarse_snr_offset; ///< coarse SNR offsets (csnroffst) | ||
| 186 | int fast_gain_code[AC3_MAX_CHANNELS]; ///< fast gain codes (signal-to-mask ratio) (fgaincod) | ||
| 187 | int fine_snr_offset[AC3_MAX_CHANNELS]; ///< fine SNR offsets (fsnroffst) | ||
| 188 | int frame_bits_fixed; ///< number of non-coefficient bits for fixed parameters | ||
| 189 | int frame_bits; ///< all frame bits except exponents and mantissas | ||
| 190 | int exponent_bits; ///< number of bits used for exponents | ||
| 191 | |||
| 192 | SampleType **planar_samples; | ||
| 193 | uint8_t *bap_buffer; | ||
| 194 | uint8_t *bap1_buffer; | ||
| 195 | CoefType *mdct_coef_buffer; | ||
| 196 | int32_t *fixed_coef_buffer; | ||
| 197 | uint8_t *exp_buffer; | ||
| 198 | uint8_t *grouped_exp_buffer; | ||
| 199 | int16_t *psd_buffer; | ||
| 200 | int16_t *band_psd_buffer; | ||
| 201 | int16_t *mask_buffer; | ||
| 202 | uint16_t *qmant_buffer; | ||
| 203 | uint8_t *cpl_coord_exp_buffer; | ||
| 204 | uint8_t *cpl_coord_mant_buffer; | ||
| 205 | |||
| 206 | uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies | ||
| 207 | uint8_t exp_ref_block[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< reference blocks for EXP_REUSE | ||
| 208 | uint8_t *ref_bap [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap) | ||
| 209 | int ref_bap_set; ///< indicates if ref_bap pointers have been set | ||
| 210 | |||
| 211 | DECLARE_ALIGNED(32, SampleType, windowed_samples)[AC3_WINDOW_SIZE]; | ||
| 212 | } AC3EncodeContext; | ||
| 213 | |||
| 214 | #endif /* AVCODEC_AC3ENC_H */ | ||
| @@ -83,8 +83,6 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) · 82 unmodified lines | |||
| 83 | 83 | ||
| 84 | /* VLC decoding */ | 84 | /* VLC decoding */ |
| 85 | 85 | ||
| 86 | //#define DEBUG_VLC | ||
| 87 | |||
| 88 | #define GET_DATA(v, table, i, wrap, size) \ | 86 | #define GET_DATA(v, table, i, wrap, size) \ |
| 89 | {\ | 87 | {\ |
| 90 | const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ | 88 | 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, · 73 unmodified lines | |||
| 164 | 162 | ||
| 165 | table_size = 1 << table_nb_bits; | 163 | table_size = 1 << table_nb_bits; |
| 166 | table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); | 164 | table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); |
| 167 | #ifdef DEBUG_VLC | 165 | av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); |
| 168 | av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n", | ||
| 169 | table_index, table_size); | ||
| 170 | #endif | ||
| 171 | if (table_index < 0) | 166 | if (table_index < 0) |
| 172 | return -1; | 167 | return -1; |
| 173 | table = &vlc->table[table_index]; | 168 | table = &vlc->table[table_index]; |
| @@ -182,9 +177,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, · 8 unmodified lines | |||
| 182 | n = codes[i].bits; | 177 | n = codes[i].bits; |
| 183 | code = codes[i].code; | 178 | code = codes[i].code; |
| 184 | symbol = codes[i].symbol; | 179 | symbol = codes[i].symbol; |
| 185 | #if defined(DEBUG_VLC) && 0 | 180 | av_dlog(NULL, "i=%d n=%d code=0x%x\n", i, n, code); |
| 186 | av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code); | ||
| 187 | #endif | ||
| 188 | if (n <= table_nb_bits) { | 181 | if (n <= table_nb_bits) { |
| 189 | /* no need to add another table */ | 182 | /* no need to add another table */ |
| 190 | j = code >> (32 - table_nb_bits); | 183 | j = code >> (32 - table_nb_bits); |
| @@ -195,10 +188,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, · 4 unmodified lines | |||
| 195 | inc = 1 << n; | 188 | inc = 1 << n; |
| 196 | } | 189 | } |
| 197 | for (k = 0; k < nb; k++) { | 190 | for (k = 0; k < nb; k++) { |
| 198 | #ifdef DEBUG_VLC | 191 | av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); |
| 199 | av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", | ||
| 200 | j, i, n); | ||
| 201 | #endif | ||
| 202 | if (table[j][1] /*bits*/ != 0) { | 192 | if (table[j][1] /*bits*/ != 0) { |
| 203 | av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); | 193 | av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); |
| 204 | return -1; | 194 | return -1; |
| @@ -228,10 +218,8 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, · 23 unmodified lines | |||
| 228 | subtable_bits = FFMIN(subtable_bits, table_nb_bits); | 218 | subtable_bits = FFMIN(subtable_bits, table_nb_bits); |
| 229 | j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; | 219 | j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; |
| 230 | table[j][1] = -subtable_bits; | 220 | table[j][1] = -subtable_bits; |
| 231 | #ifdef DEBUG_VLC | 221 | av_dlog(NULL, "%4x: n=%d (subtable)\n", |
| 232 | av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n", | 222 | j, codes[i].bits + table_nb_bits); |
| 233 | j, codes[i].bits + table_nb_bits); | ||
| 234 | #endif | ||
| 235 | index = build_table(vlc, subtable_bits, k-i, codes+i, flags); | 223 | index = build_table(vlc, subtable_bits, k-i, codes+i, flags); |
| 236 | if (index < 0) | 224 | if (index < 0) |
| 237 | return -1; | 225 | return -1; |
| @@ -293,9 +281,7 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, · 55 unmodified lines | |||
| 293 | vlc->table_size = 0; | 281 | vlc->table_size = 0; |
| 294 | } | 282 | } |
| 295 | 283 | ||
| 296 | #ifdef DEBUG_VLC | 284 | av_dlog(NULL, "build table nb_codes=%d\n", nb_codes); |
| 297 | av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); | ||
| 298 | #endif | ||
| 299 | 285 | ||
| 300 | buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); | 286 | buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); |
| 301 | 287 | ||
| @@ -25,8 +25,9 @@ · 24 unmodified lines | |||
| 25 | #define AVCODEC_DNXHDENC_H | 25 | #define AVCODEC_DNXHDENC_H |
| 26 | 26 | ||
| 27 | #include <stdint.h> | 27 | #include <stdint.h> |
| 28 | #include "libavcodec/mpegvideo.h" | 28 | |
| 29 | #include "libavcodec/dnxhddata.h" | 29 | #include "mpegvideo.h" |
| 30 | #include "dnxhddata.h" | ||
| 30 | 31 | ||
| 31 | typedef struct { | 32 | typedef struct { |
| 32 | uint16_t mb; | 33 | uint16_t mb; |
| @@ -358,9 +358,6 @@ static av_cold int dvvideo_init_encoder(AVCodecContext *avctx) · 357 unmodified lines | |||
| 358 | return dvvideo_init(avctx); | 358 | return dvvideo_init(avctx); |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | // #define VLC_DEBUG | ||
| 362 | // #define printf(...) av_log(NULL, AV_LOG_ERROR, __VA_ARGS__) | ||
| 363 | |||
| 364 | typedef struct BlockInfo { | 361 | typedef struct BlockInfo { |
| 365 | const uint32_t *factor_table; | 362 | const uint32_t *factor_table; |
| 366 | const uint8_t *scan_table; | 363 | const uint8_t *scan_table; |
| @@ -404,9 +401,8 @@ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) · 37 unmodified lines | |||
| 404 | 401 | ||
| 405 | /* get the AC coefficients until last_index is reached */ | 402 | /* get the AC coefficients until last_index is reached */ |
| 406 | for (;;) { | 403 | for (;;) { |
| 407 | #ifdef VLC_DEBUG | 404 | av_dlog(NULL, "%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, gb, 16), |
| 408 | printf("%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, gb, 16), re_index); | 405 | re_index); |
| 409 | #endif | ||
| 410 | /* our own optimized GET_RL_VLC */ | 406 | /* our own optimized GET_RL_VLC */ |
| 411 | index = NEG_USR32(re_cache, TEX_VLC_BITS); | 407 | index = NEG_USR32(re_cache, TEX_VLC_BITS); |
| 412 | vlc_len = dv_rl_vlc[index].len; | 408 | vlc_len = dv_rl_vlc[index].len; |
| @@ -427,9 +423,7 @@ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) · 14 unmodified lines | |||
| 427 | } | 423 | } |
| 428 | re_index += vlc_len; | 424 | re_index += vlc_len; |
| 429 | 425 | ||
| 430 | #ifdef VLC_DEBUG | 426 | av_dlog(NULL, "run=%d level=%d\n", run, level); |
| 431 | printf("run=%d level=%d\n", run, level); | ||
| 432 | #endif | ||
| 433 | pos += run; | 427 | pos += run; |
| 434 | if (pos >= 64) | 428 | if (pos >= 64) |
| 435 | break; | 429 | break; |
| @@ -533,9 +527,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) · 97 unmodified lines | |||
| 533 | mb->pos = 0; | 527 | mb->pos = 0; |
| 534 | mb->partial_bit_count = 0; | 528 | mb->partial_bit_count = 0; |
| 535 | 529 | ||
| 536 | #ifdef VLC_DEBUG | 530 | av_dlog(avctx, "MB block: %d, %d ", mb_index, j); |
| 537 | printf("MB block: %d, %d ", mb_index, j); | ||
| 538 | #endif | ||
| 539 | dv_decode_ac(&gb, mb, block); | 531 | dv_decode_ac(&gb, mb, block); |
| 540 | 532 | ||
| 541 | /* write the remaining bits in a new buffer only if the | 533 | /* 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) · 6 unmodified lines | |||
| 548 | } | 540 | } |
| 549 | 541 | ||
| 550 | /* pass 2 : we can do it just after */ | 542 | /* pass 2 : we can do it just after */ |
| 551 | #ifdef VLC_DEBUG | 543 | av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); |
| 552 | printf("***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); | ||
| 553 | #endif | ||
| 554 | block = block1; | 544 | block = block1; |
| 555 | mb = mb1; | 545 | mb = mb1; |
| 556 | init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb)); | 546 | 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) · 13 unmodified lines | |||
| 570 | } | 560 | } |
| 571 | 561 | ||
| 572 | /* we need a pass other the whole video segment */ | 562 | /* we need a pass other the whole video segment */ |
| 573 | #ifdef VLC_DEBUG | 563 | av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb)); |
| 574 | printf("***pass 3 size=%d\n", put_bits_count(&vs_pb)); | ||
| 575 | #endif | ||
| 576 | block = &sblock[0][0]; | 564 | block = &sblock[0][0]; |
| 577 | mb = mb_data; | 565 | mb = mb_data; |
| 578 | init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb)); | 566 | 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) · 1 unmodified line | |||
| 580 | for (mb_index = 0; mb_index < 5; mb_index++) { | 568 | for (mb_index = 0; mb_index < 5; mb_index++) { |
| 581 | for (j = 0; j < s->sys->bpm; j++) { | 569 | for (j = 0; j < s->sys->bpm; j++) { |
| 582 | if (mb->pos < 64) { | 570 | if (mb->pos < 64) { |
| 583 | #ifdef VLC_DEBUG | 571 | av_dlog(avctx, "start %d:%d\n", mb_index, j); |
| 584 | printf("start %d:%d\n", mb_index, j); | ||
| 585 | #endif | ||
| 586 | dv_decode_ac(&gb, mb, block); | 572 | dv_decode_ac(&gb, mb, block); |
| 587 | } | 573 | } |
| 588 | if (mb->pos >= 64 && mb->pos < 127) | 574 | if (mb->pos >= 64 && mb->pos < 127) |
| @@ -22,9 +22,6 @@ · 21 unmodified lines | |||
| 22 | #include "dsputil.h" | 22 | #include "dsputil.h" |
| 23 | #include "get_bits.h" | 23 | #include "get_bits.h" |
| 24 | 24 | ||
| 25 | //#define DEBUG | ||
| 26 | //#define DEBUG_PACKET_CONTENTS | ||
| 27 | |||
| 28 | /* Parser (mostly) copied from dvdsub.c */ | 25 | /* Parser (mostly) copied from dvdsub.c */ |
| 29 | 26 | ||
| 30 | #define PARSE_BUF_SIZE (65536) | 27 | #define PARSE_BUF_SIZE (65536) |
| @@ -53,25 +50,20 @@ static int dvbsub_parse(AVCodecParserContext *s, · 22 unmodified lines | |||
| 53 | { | 50 | { |
| 54 | DVBSubParseContext *pc = s->priv_data; | 51 | DVBSubParseContext *pc = s->priv_data; |
| 55 | uint8_t *p, *p_end; | 52 | uint8_t *p, *p_end; |
| 56 | int len, buf_pos = 0; | 53 | int i, len, buf_pos = 0; |
| 57 | 54 | ||
| 58 | av_dlog(avctx, "DVB parse packet pts=%"PRIx64", lpts=%"PRIx64", cpts=%"PRIx64":\n", | 55 | av_dlog(avctx, "DVB parse packet pts=%"PRIx64", lpts=%"PRIx64", cpts=%"PRIx64":\n", |
| 59 | s->pts, s->last_pts, s->cur_frame_pts[s->cur_frame_start_index]); | 56 | s->pts, s->last_pts, s->cur_frame_pts[s->cur_frame_start_index]); |
| 60 | 57 | ||
| 61 | #ifdef DEBUG_PACKET_CONTENTS | ||
| 62 | int i; | ||
| 63 | |||
| 64 | for (i=0; i < buf_size; i++) | 58 | for (i=0; i < buf_size; i++) |
| 65 | { | 59 | { |
| 66 | av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); | 60 | av_dlog(avctx, "%02x ", buf[i]); |
| 67 | if (i % 16 == 15) | 61 | if (i % 16 == 15) |
| 68 | av_log(avctx, AV_LOG_INFO, "\n"); | 62 | av_dlog(avctx, "\n"); |
| 69 | } | 63 | } |
| 70 | 64 | ||
| 71 | if (i % 16 != 0) | 65 | if (i % 16 != 0) |
| 72 | av_log(avctx, AV_LOG_INFO, "\n"); | 66 | av_dlog(avctx, "\n"); |
| 73 | |||
| 74 | #endif | ||
| 75 | 67 | ||
| 76 | *poutbuf = NULL; | 68 | *poutbuf = NULL; |
| 77 | *poutbuf_size = 0; | 69 | *poutbuf_size = 0; |
| @@ -24,10 +24,6 @@ · 23 unmodified lines | |||
| 24 | #include "bytestream.h" | 24 | #include "bytestream.h" |
| 25 | #include "libavutil/colorspace.h" | 25 | #include "libavutil/colorspace.h" |
| 26 | 26 | ||
| 27 | //#define DEBUG | ||
| 28 | //#define DEBUG_PACKET_CONTENTS | ||
| 29 | //#define DEBUG_SAVE_IMAGES | ||
| 30 | |||
| 31 | #define DVBSUB_PAGE_SEGMENT 0x10 | 27 | #define DVBSUB_PAGE_SEGMENT 0x10 |
| 32 | #define DVBSUB_REGION_SEGMENT 0x11 | 28 | #define DVBSUB_REGION_SEGMENT 0x11 |
| 33 | #define DVBSUB_CLUT_SEGMENT 0x12 | 29 | #define DVBSUB_CLUT_SEGMENT 0x12 |
| @@ -37,7 +33,7 @@ · 3 unmodified lines | |||
| 37 | 33 | ||
| 38 | #define cm (ff_cropTbl + MAX_NEG_CROP) | 34 | #define cm (ff_cropTbl + MAX_NEG_CROP) |
| 39 | 35 | ||
| 40 | #ifdef DEBUG_SAVE_IMAGES | 36 | #ifdef DEBUG |
| 41 | #undef fprintf | 37 | #undef fprintf |
| 42 | #if 0 | 38 | #if 0 |
| 43 | static void png_save(const char *filename, uint8_t *bitmap, int w, int h, | 39 | 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 · 724 unmodified lines | |||
| 768 | av_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size, | 764 | av_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size, |
| 769 | top_bottom ? "bottom" : "top"); | 765 | top_bottom ? "bottom" : "top"); |
| 770 | 766 | ||
| 771 | #ifdef DEBUG_PACKET_CONTENTS | ||
| 772 | for (i = 0; i < buf_size; i++) { | 767 | for (i = 0; i < buf_size; i++) { |
| 773 | if (i % 16 == 0) | 768 | if (i % 16 == 0) |
| 774 | av_log(avctx, AV_LOG_INFO, "0x%08p: ", buf+i); | 769 | av_dlog(avctx, "0x%8p: ", buf+i); |
| 775 | 770 | ||
| 776 | av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); | 771 | av_dlog(avctx, "%02x ", buf[i]); |
| 777 | if (i % 16 == 15) | 772 | if (i % 16 == 15) |
| 778 | av_log(avctx, AV_LOG_INFO, "\n"); | 773 | av_dlog(avctx, "\n"); |
| 779 | } | 774 | } |
| 780 | 775 | ||
| 781 | if (i % 16) | 776 | if (i % 16) |
| 782 | av_log(avctx, AV_LOG_INFO, "\n"); | 777 | av_dlog(avctx, "\n"); |
| 783 | |||
| 784 | #endif | ||
| 785 | 778 | ||
| 786 | if (region == 0) | 779 | if (region == 0) |
| 787 | return; | 780 | return; |
| @@ -930,27 +923,22 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx, · 142 unmodified lines | |||
| 930 | DVBSubContext *ctx = avctx->priv_data; | 923 | DVBSubContext *ctx = avctx->priv_data; |
| 931 | 924 | ||
| 932 | const uint8_t *buf_end = buf + buf_size; | 925 | const uint8_t *buf_end = buf + buf_size; |
| 933 | int clut_id; | 926 | int i, clut_id; |
| 934 | DVBSubCLUT *clut; | 927 | DVBSubCLUT *clut; |
| 935 | int entry_id, depth , full_range; | 928 | int entry_id, depth , full_range; |
| 936 | int y, cr, cb, alpha; | 929 | int y, cr, cb, alpha; |
| 937 | int r, g, b, r_add, g_add, b_add; | 930 | int r, g, b, r_add, g_add, b_add; |
| 938 | 931 | ||
| 939 | #ifdef DEBUG_PACKET_CONTENTS | 932 | av_dlog(avctx, "DVB clut packet:\n"); |
| 940 | int i; | ||
| 941 | |||
| 942 | av_log(avctx, AV_LOG_INFO, "DVB clut packet:\n"); | ||
| 943 | 933 | ||
| 944 | for (i=0; i < buf_size; i++) { | 934 | for (i=0; i < buf_size; i++) { |
| 945 | av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); | 935 | av_dlog(avctx, "%02x ", buf[i]); |
| 946 | if (i % 16 == 15) | 936 | if (i % 16 == 15) |
| 947 | av_log(avctx, AV_LOG_INFO, "\n"); | 937 | av_dlog(avctx, "\n"); |
| 948 | } | 938 | } |
| 949 | 939 | ||
| 950 | if (i % 16) | 940 | if (i % 16) |
| 951 | av_log(avctx, AV_LOG_INFO, "\n"); | 941 | av_dlog(avctx, "\n"); |
| 952 | |||
| 953 | #endif | ||
| 954 | 942 | ||
| 955 | clut_id = *buf++; | 943 | clut_id = *buf++; |
| 956 | buf += 1; | 944 | buf += 1; |
| @@ -1194,7 +1182,7 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx, · 237 unmodified lines | |||
| 1194 | } | 1182 | } |
| 1195 | 1183 | ||
| 1196 | 1184 | ||
| 1197 | #ifdef DEBUG_SAVE_IMAGES | 1185 | #ifdef DEBUG |
| 1198 | static void save_display_set(DVBSubContext *ctx) | 1186 | static void save_display_set(DVBSubContext *ctx) |
| 1199 | { | 1187 | { |
| 1200 | DVBSubRegion *region; | 1188 | DVBSubRegion *region; |
| @@ -1404,7 +1392,7 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, · 203 unmodified lines | |||
| 1404 | 1392 | ||
| 1405 | sub->num_rects = i; | 1393 | sub->num_rects = i; |
| 1406 | 1394 | ||
| 1407 | #ifdef DEBUG_SAVE_IMAGES | 1395 | #ifdef DEBUG |
| 1408 | save_display_set(ctx); | 1396 | save_display_set(ctx); |
| 1409 | #endif | 1397 | #endif |
| 1410 | 1398 | ||
| @@ -1423,22 +1411,18 @@ static int dvbsub_decode(AVCodecContext *avctx, · 12 unmodified lines | |||
| 1423 | int segment_type; | 1411 | int segment_type; |
| 1424 | int page_id; | 1412 | int page_id; |
| 1425 | int segment_length; | 1413 | int segment_length; |
| 1426 | |||
| 1427 | #ifdef DEBUG_PACKET_CONTENTS | ||
| 1428 | int i; | 1414 | int i; |
| 1429 | 1415 | ||
| 1430 | av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n"); | 1416 | av_dlog(avctx, "DVB sub packet:\n"); |
| 1431 | 1417 | ||
| 1432 | for (i=0; i < buf_size; i++) { | 1418 | for (i=0; i < buf_size; i++) { |
| 1433 | av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); | 1419 | av_dlog(avctx, "%02x ", buf[i]); |
| 1434 | if (i % 16 == 15) | 1420 | if (i % 16 == 15) |
| 1435 | av_log(avctx, AV_LOG_INFO, "\n"); | 1421 | av_dlog(avctx, "\n"); |
| 1436 | } | 1422 | } |
| 1437 | 1423 | ||
| 1438 | if (i % 16) | 1424 | if (i % 16) |
| 1439 | av_log(avctx, AV_LOG_INFO, "\n"); | 1425 | av_dlog(avctx, "\n"); |
| 1440 | |||
| 1441 | #endif | ||
| 1442 | 1426 | ||
| 1443 | if (buf_size <= 6 || *buf != 0x0f) { | 1427 | if (buf_size <= 6 || *buf != 0x0f) { |
| 1444 | av_dlog(avctx, "incomplete or broken packet"); | 1428 | av_dlog(avctx, "incomplete or broken packet"); |
| @@ -0,0 +1,131 @@ | |||
| 1 | /* | ||
| 2 | * E-AC-3 encoder | ||
| 3 | * Copyright (c) 2011 Justin Ruggles <justin.ruggles@gmail.com> | ||
| 4 | * | ||
| 5 | * This file is part of Libav. | ||
| 6 | * | ||
| 7 | * Libav is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * Libav is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with Libav; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @file | ||
| 24 | * E-AC-3 encoder | ||
| 25 | */ | ||
| 26 | |||
| 27 | #define CONFIG_AC3ENC_FLOAT 1 | ||
| 28 | #include "ac3enc.h" | ||
| 29 | #include "eac3enc.h" | ||
| 30 | |||
| 31 | void ff_eac3_set_cpl_states(AC3EncodeContext *s) | ||
| 32 | { | ||
| 33 | int ch, blk; | ||
| 34 | int first_cpl_coords[AC3_MAX_CHANNELS]; | ||
| 35 | |||
| 36 | /* set first cpl coords */ | ||
| 37 | for (ch = 1; ch <= s->fbw_channels; ch++) | ||
| 38 | first_cpl_coords[ch] = 1; | ||
| 39 | for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | ||
| 40 | AC3Block *block = &s->blocks[blk]; | ||
| 41 | for (ch = 1; ch <= s->fbw_channels; ch++) { | ||
| 42 | if (block->channel_in_cpl[ch]) { | ||
| 43 | if (first_cpl_coords[ch]) { | ||
| 44 | block->new_cpl_coords = 2; | ||
| 45 | first_cpl_coords[ch] = 0; | ||
| 46 | } | ||
| 47 | } else { | ||
| 48 | first_cpl_coords[ch] = 1; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | /* set first cpl leak */ | ||
| 54 | for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | ||
| 55 | AC3Block *block = &s->blocks[blk]; | ||
| 56 | if (block->cpl_in_use) { | ||
| 57 | block->new_cpl_leak = 2; | ||
| 58 | break; | ||
| 59 | } | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | |||
| 64 | void ff_eac3_output_frame_header(AC3EncodeContext *s) | ||
| 65 | { | ||
| 66 | int blk, ch; | ||
| 67 | AC3EncOptions *opt = &s->options; | ||
| 68 | |||
| 69 | put_bits(&s->pb, 16, 0x0b77); /* sync word */ | ||
| 70 | |||
| 71 | /* BSI header */ | ||
| 72 | put_bits(&s->pb, 2, 0); /* stream type = independent */ | ||
| 73 | put_bits(&s->pb, 3, 0); /* substream id = 0 */ | ||
| 74 | put_bits(&s->pb, 11, (s->frame_size / 2) - 1); /* frame size */ | ||
| 75 | if (s->bit_alloc.sr_shift) { | ||
| 76 | put_bits(&s->pb, 2, 0x3); /* fscod2 */ | ||
| 77 | put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ | ||
| 78 | } else { | ||
| 79 | put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ | ||
| 80 | put_bits(&s->pb, 2, 0x3); /* number of blocks = 6 */ | ||
| 81 | } | ||
| 82 | put_bits(&s->pb, 3, s->channel_mode); /* audio coding mode */ | ||
| 83 | put_bits(&s->pb, 1, s->lfe_on); /* LFE channel indicator */ | ||
| 84 | put_bits(&s->pb, 5, s->bitstream_id); /* bitstream id (EAC3=16) */ | ||
| 85 | put_bits(&s->pb, 5, -opt->dialogue_level); /* dialogue normalization level */ | ||
| 86 | put_bits(&s->pb, 1, 0); /* no compression gain */ | ||
| 87 | put_bits(&s->pb, 1, 0); /* no mixing metadata */ | ||
| 88 | /* TODO: mixing metadata */ | ||
| 89 | put_bits(&s->pb, 1, 0); /* no info metadata */ | ||
| 90 | /* TODO: info metadata */ | ||
| 91 | put_bits(&s->pb, 1, 0); /* no additional bit stream info */ | ||
| 92 | |||
| 93 | /* frame header */ | ||
| 94 | put_bits(&s->pb, 1, 1); /* exponent strategy syntax = each block */ | ||
| 95 | put_bits(&s->pb, 1, 0); /* aht enabled = no */ | ||
| 96 | put_bits(&s->pb, 2, 0); /* snr offset strategy = 1 */ | ||
| 97 | put_bits(&s->pb, 1, 0); /* transient pre-noise processing enabled = no */ | ||
| 98 | put_bits(&s->pb, 1, 0); /* block switch syntax enabled = no */ | ||
| 99 | put_bits(&s->pb, 1, 0); /* dither flag syntax enabled = no */ | ||
| 100 | put_bits(&s->pb, 1, 0); /* bit allocation model syntax enabled = no */ | ||
| 101 | put_bits(&s->pb, 1, 0); /* fast gain codes enabled = no */ | ||
| 102 | put_bits(&s->pb, 1, 0); /* dba syntax enabled = no */ | ||
| 103 | put_bits(&s->pb, 1, 0); /* skip field syntax enabled = no */ | ||
| 104 | put_bits(&s->pb, 1, 0); /* spx enabled = no */ | ||
| 105 | /* coupling strategy use flags */ | ||
| 106 | if (s->channel_mode > AC3_CHMODE_MONO) { | ||
| 107 | put_bits(&s->pb, 1, s->blocks[0].cpl_in_use); | ||
| 108 | for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) { | ||
| 109 | AC3Block *block = &s->blocks[blk]; | ||
| 110 | put_bits(&s->pb, 1, block->new_cpl_strategy); | ||
| 111 | if (block->new_cpl_strategy) | ||
| 112 | put_bits(&s->pb, 1, block->cpl_in_use); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | /* exponent strategy */ | ||
| 116 | for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | ||
| 117 | for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) | ||
| 118 | put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); | ||
| 119 | if (s->lfe_on) { | ||
| 120 | for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | ||
| 121 | put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]); | ||
| 122 | } | ||
| 123 | /* E-AC-3 to AC-3 converter exponent strategy (unfortunately not optional...) */ | ||
| 124 | for (ch = 1; ch <= s->fbw_channels; ch++) | ||
| 125 | put_bits(&s->pb, 5, 0); | ||
| 126 | /* snr offsets */ | ||
| 127 | put_bits(&s->pb, 6, s->coarse_snr_offset); | ||
| 128 | put_bits(&s->pb, 4, s->fine_snr_offset[1]); | ||
| 129 | /* block start info */ | ||
| 130 | put_bits(&s->pb, 1, 0); | ||
| 131 | } | ||
| @@ -0,0 +1,44 @@ | |||
| 1 | /* | ||
| 2 | * E-AC-3 encoder | ||
| 3 | * Copyright (c) 2011 Justin Ruggles <justin.ruggles@gmail.com> | ||
| 4 | * | ||
| 5 | * This file is part of Libav. | ||
| 6 | * | ||
| 7 | * Libav is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * Libav is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with Libav; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @file | ||
| 24 | * E-AC-3 encoder | ||
| 25 | */ | ||
| 26 | |||
| 27 | #ifndef AVCODEC_EAC3ENC_H | ||
| 28 | #define AVCODEC_EAC3ENC_H | ||
| 29 | |||
| 30 | #include "ac3enc.h" | ||
| 31 | |||
| 32 | /** | ||
| 33 | * Set coupling states. | ||
| 34 | * This determines whether certain flags must be written to the bitstream or | ||
| 35 | * whether they will be implicitly already known by the decoder. | ||
| 36 | */ | ||
| 37 | void ff_eac3_set_cpl_states(AC3EncodeContext *s); | ||
| 38 | |||
| 39 | /** | ||
| 40 | * Write the E-AC-3 frame header to the output bitstream. | ||
| 41 | */ | ||
| 42 | void ff_eac3_output_frame_header(AC3EncodeContext *s); | ||
| 43 | |||
| 44 | #endif /* AVCODEC_EAC3ENC_H */ | ||
| @@ -151,8 +151,6 @@ static int biquad_init_coeffs(void *avc, struct FFIIRFilterCoeffs *c, · 150 unmodified lines | |||
| 151 | // during filtering, the delay state will include the gain multiplication | 151 | // during filtering, the delay state will include the gain multiplication |
| 152 | c->cx[0] = lrintf(x0 / c->gain); | 152 | c->cx[0] = lrintf(x0 / c->gain); |
| 153 | c->cx[1] = lrintf(x1 / c->gain); | 153 | c->cx[1] = lrintf(x1 / c->gain); |
| 154 | c->cy[0] /= c->gain; | ||
| 155 | c->cy[1] /= c->gain; | ||
| 156 | 154 | ||
| 157 | return 0; | 155 | return 0; |
| 158 | } | 156 | } |
| @@ -19,8 +19,8 @@ · 18 unmodified lines | |||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include "libavcodec/mlp.h" | ||
| 23 | #include "dsputil.h" | 22 | #include "dsputil.h" |
| 23 | #include "mlp.h" | ||
| 24 | 24 | ||
| 25 | static void ff_mlp_filter_channel(int32_t *state, const int32_t *coeff, | 25 | static void ff_mlp_filter_channel(int32_t *state, const int32_t *coeff, |
| 26 | int firorder, int iirorder, | 26 | int firorder, int iirorder, |
| @@ -30,8 +30,6 @@ · 29 unmodified lines | |||
| 30 | #include "libavutil/colorspace.h" | 30 | #include "libavutil/colorspace.h" |
| 31 | #include "libavutil/imgutils.h" | 31 | #include "libavutil/imgutils.h" |
| 32 | 32 | ||
| 33 | //#define DEBUG_PACKET_CONTENTS | ||
| 34 | |||
| 35 | #define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) | 33 | #define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) |
| 36 | 34 | ||
| 37 | enum SegmentType { | 35 | enum SegmentType { |
| @@ -403,21 +401,18 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, · 365 unmodified lines | |||
| 403 | const uint8_t *buf_end; | 401 | const uint8_t *buf_end; |
| 404 | uint8_t segment_type; | 402 | uint8_t segment_type; |
| 405 | int segment_length; | 403 | int segment_length; |
| 406 | |||
| 407 | #ifdef DEBUG_PACKET_CONTENTS | ||
| 408 | int i; | 404 | int i; |
| 409 | 405 | ||
| 410 | av_log(avctx, AV_LOG_INFO, "PGS sub packet:\n"); | 406 | av_dlog(avctx, "PGS sub packet:\n"); |
| 411 | 407 | ||
| 412 | for (i = 0; i < buf_size; i++) { | 408 | for (i = 0; i < buf_size; i++) { |
| 413 | av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); | 409 | av_dlog(avctx, "%02x ", buf[i]); |
| 414 | if (i % 16 == 15) | 410 | if (i % 16 == 15) |
| 415 | av_log(avctx, AV_LOG_INFO, "\n"); | 411 | av_dlog(avctx, "\n"); |
| 416 | } | 412 | } |
| 417 | 413 | ||
| 418 | if (i & 15) | 414 | if (i & 15) |
| 419 | av_log(avctx, AV_LOG_INFO, "\n"); | 415 | av_dlog(avctx, "\n"); |
| 420 | #endif | ||
| 421 | 416 | ||
| 422 | *data_size = 0; | 417 | *data_size = 0; |
| 423 | 418 | ||
| @@ -18,8 +18,7 @@ · 17 unmodified lines | |||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | //#define DEBUG_ALIGNMENT | 21 | #ifdef DEBUG |
| 22 | #ifdef DEBUG_ALIGNMENT | ||
| 23 | #define ASSERT_ALIGNED(ptr) assert(((unsigned long)ptr&0x0000000F)); | 22 | #define ASSERT_ALIGNED(ptr) assert(((unsigned long)ptr&0x0000000F)); |
| 24 | #else | 23 | #else |
| 25 | #define ASSERT_ALIGNED(ptr) ; | 24 | #define ASSERT_ALIGNED(ptr) ; |
| @@ -26,7 +26,6 @@ · 25 unmodified lines | |||
| 26 | * | 26 | * |
| 27 | */ | 27 | */ |
| 28 | 28 | ||
| 29 | #define DEBUG | ||
| 30 | #include <limits.h> | 29 | #include <limits.h> |
| 31 | #include "avcodec.h" | 30 | #include "avcodec.h" |
| 32 | #include "get_bits.h" | 31 | #include "get_bits.h" |
| @@ -304,7 +303,6 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 271 unmodified lines | |||
| 304 | s->bitstream_size= buf_size; | 303 | s->bitstream_size= buf_size; |
| 305 | 304 | ||
| 306 | if(buf_size < s->max_framesize){ | 305 | if(buf_size < s->max_framesize){ |
| 307 | //av_dlog(avctx, "wanna more data ... %d\n", buf_size); | ||
| 308 | *data_size = 0; | 306 | *data_size = 0; |
| 309 | return input_buf_size; | 307 | return input_buf_size; |
| 310 | } | 308 | } |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #include "avcodec.h" | 24 | #include "avcodec.h" |
| 25 | #include "libavcodec/bytestream.h" | 25 | #include "bytestream.h" |
| 26 | 26 | ||
| 27 | static av_cold int encode_init(AVCodecContext *avctx) | 27 | static av_cold int encode_init(AVCodecContext *avctx) |
| 28 | { | 28 | { |
| @@ -3398,7 +3398,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 3397 unmodified lines | |||
| 3398 | VC1Context *v = avctx->priv_data; | 3398 | VC1Context *v = avctx->priv_data; |
| 3399 | MpegEncContext *s = &v->s; | 3399 | MpegEncContext *s = &v->s; |
| 3400 | GetBitContext gb; | 3400 | GetBitContext gb; |
| 3401 | int i; | 3401 | int i, cur_width, cur_height; |
| 3402 | 3402 | ||
| 3403 | if (!avctx->extradata_size || !avctx->extradata) return -1; | 3403 | if (!avctx->extradata_size || !avctx->extradata) return -1; |
| 3404 | if (!(avctx->flags & CODEC_FLAG_GRAY)) | 3404 | if (!(avctx->flags & CODEC_FLAG_GRAY)) |
| @@ -3419,8 +3419,8 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 14 unmodified lines | |||
| 3419 | if (vc1_init_common(v) < 0) return -1; | 3419 | if (vc1_init_common(v) < 0) return -1; |
| 3420 | ff_vc1dsp_init(&v->vc1dsp); | 3420 | ff_vc1dsp_init(&v->vc1dsp); |
| 3421 | 3421 | ||
| 3422 | avctx->coded_width = avctx->width; | 3422 | cur_width = avctx->coded_width = avctx->width; |
| 3423 | avctx->coded_height = avctx->height; | 3423 | cur_height = avctx->coded_height = avctx->height; |
| 3424 | if (avctx->codec_id == CODEC_ID_WMV3) | 3424 | if (avctx->codec_id == CODEC_ID_WMV3) |
| 3425 | { | 3425 | { |
| 3426 | int count = 0; | 3426 | int count = 0; |
| @@ -3491,6 +3491,19 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 64 unmodified lines | |||
| 3491 | } | 3491 | } |
| 3492 | v->res_sprite = (avctx->codec_tag == MKTAG('W','V','P','2')); | 3492 | v->res_sprite = (avctx->codec_tag == MKTAG('W','V','P','2')); |
| 3493 | } | 3493 | } |
| 3494 | // Sequence header information may not have been parsed | ||
| 3495 | // yet when ff_msmpeg4_decode_init was called the fist time | ||
| 3496 | // above. If sequence information changes, we need to call | ||
| 3497 | // it again. | ||
| 3498 | if (cur_width != avctx->width || | ||
| 3499 | cur_height != avctx->height) { | ||
| 3500 | MPV_common_end(s); | ||
| 3501 | if(ff_msmpeg4_decode_init(avctx) < 0) | ||
| 3502 | return -1; | ||
| 3503 | avctx->coded_width = avctx->width; | ||
| 3504 | avctx->coded_height = avctx->height; | ||
| 3505 | } | ||
| 3506 | |||
| 3494 | avctx->profile = v->profile; | 3507 | avctx->profile = v->profile; |
| 3495 | if (v->profile == PROFILE_ADVANCED) | 3508 | if (v->profile == PROFILE_ADVANCED) |
| 3496 | avctx->level = v->level; | 3509 | avctx->level = v->level; |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | |||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <inttypes.h> | ||
| 23 | #include <math.h> | 24 | #include <math.h> |
| 24 | 25 | ||
| 25 | #define ALT_BITSTREAM_READER_LE | 26 | #define ALT_BITSTREAM_READER_LE |
| @@ -1089,6 +1090,9 @@ static int vorbis_floor0_decode(vorbis_context *vc, · 1063 unmodified lines | |||
| 1089 | for (i = 0; i < order; i++) | 1090 | for (i = 0; i < order; i++) |
| 1090 | lsp[i] = 2.0f * cos(lsp[i]); | 1091 | lsp[i] = 2.0f * cos(lsp[i]); |
| 1091 | 1092 | ||
| 1093 | av_dlog(NULL, "floor0 synth: map_size = %"PRIu32"; m = %d; wstep = %f\n", | ||
| 1094 | vf->map_size[blockflag], order, wstep); | ||
| 1095 | |||
| 1092 | i = 0; | 1096 | i = 0; |
| 1093 | while (i < vf->map_size[blockflag]) { | 1097 | while (i < vf->map_size[blockflag]) { |
| 1094 | int j, iter_cond = vf->map[blockflag][i]; | 1098 | 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 · 123 unmodified lines | |||
| 124 | { | 124 | { |
| 125 | int mm_flags = av_get_cpu_flags(); | 125 | int mm_flags = av_get_cpu_flags(); |
| 126 | 126 | ||
| 127 | if (bit_depth == 8) { | ||
| 128 | #if HAVE_YASM | 127 | #if HAVE_YASM |
| 129 | if (mm_flags & AV_CPU_FLAG_MMX) { | 128 | if (bit_depth == 8) { |
| 130 | h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx; | 129 | if (mm_flags & AV_CPU_FLAG_MMX) { |
| 131 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx; | 130 | h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx; |
| 132 | h->pred8x8 [VERT_PRED8x8] = ff_pred8x8_vertical_mmx; | 131 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx; |
| 133 | h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; | 132 | h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_mmx; |
| 134 | if (codec_id == CODEC_ID_VP8) { | 133 | h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; |
| 135 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx; | 134 | if (codec_id == CODEC_ID_VP8) { |
| 136 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx; | 135 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmx; |
| 137 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx; | 136 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmx; |
| 138 | } else { | 137 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx; |
| 139 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx; | ||
| 140 | if (codec_id == CODEC_ID_SVQ3) { | ||
| 141 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx; | ||
| 142 | } else if (codec_id == CODEC_ID_RV40) { | ||
| 143 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx; | ||
| 144 | } else { | 138 | } else { |
| 145 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx; | 139 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx; |
| 140 | if (codec_id == CODEC_ID_SVQ3) { | ||
| 141 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx; | ||
| 142 | } else if (codec_id == CODEC_ID_RV40) { | ||
| 143 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx; | ||
| 144 | } else { | ||
| 145 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx; | ||
| 146 | } | ||
| 146 | } | 147 | } |
| 147 | } | 148 | } |
| 148 | } | ||
| 149 | 149 | ||
| 150 | if (mm_flags & AV_CPU_FLAG_MMX2) { | 150 | if (mm_flags & AV_CPU_FLAG_MMX2) { |
| 151 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; | 151 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; |
| 152 | h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext; | 152 | h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext; |
| 153 | h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext; | 153 | h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext; |
| 154 | h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext; | 154 | h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext; |
| 155 | h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext; | 155 | h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext; |
| 156 | h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext; | 156 | h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext; |
| 157 | h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext; | 157 | h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext; |
| 158 | h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_mmxext; | 158 | h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_mmxext; |
| 159 | h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext; | 159 | h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext; |
| 160 | h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext; | 160 | h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext; |
| 161 | h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext; | 161 | h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext; |
| 162 | h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext; | 162 | h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext; |
| 163 | h->pred4x4 [DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_mmxext; | 163 | h->pred4x4 [DIAG_DOWN_RIGHT_PRED ] = ff_pred4x4_down_right_mmxext; |
| 164 | h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext; | 164 | h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext; |
| 165 | h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext; | 165 | h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext; |
| 166 | h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext; | 166 | h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext; |
| 167 | if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264) | 167 | if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264) { |
| 168 | h->pred4x4 [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext; | 168 | h->pred4x4 [DIAG_DOWN_LEFT_PRED] = ff_pred4x4_down_left_mmxext; |
| 169 | if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) | 169 | } |
| 170 | h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext; | 170 | if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { |
| 171 | if (codec_id != CODEC_ID_RV40) { | 171 | h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext; |
| 172 | h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext; | 172 | } |
| 173 | } | 173 | if (codec_id != CODEC_ID_RV40) { |
| 174 | if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { | 174 | h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext; |
| 175 | h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; | 175 | } |
| 176 | h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; | 176 | if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { |
| 177 | } | 177 | h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; |
| 178 | if (codec_id == CODEC_ID_VP8) { | 178 | h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; |
| 179 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext; | 179 | } |
| 180 | h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext; | 180 | if (codec_id == CODEC_ID_VP8) { |
| 181 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext; | 181 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmxext; |
| 182 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext; | 182 | h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext; |
| 183 | h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext; | 183 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmxext; |
| 184 | } else { | 184 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext; |
| 185 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2; | 185 | h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext; |
| 186 | if (codec_id == CODEC_ID_SVQ3) { | ||
| 187 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx2; | ||
| 188 | } else if (codec_id == CODEC_ID_RV40) { | ||
| 189 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx2; | ||
| 190 | } else { | 186 | } else { |
| 191 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx2; | 187 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2; |
| 188 | if (codec_id == CODEC_ID_SVQ3) { | ||
| 189 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_mmx2; | ||
| 190 | } else if (codec_id == CODEC_ID_RV40) { | ||
| 191 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_rv40_mmx2; | ||
| 192 | } else { | ||
| 193 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_h264_mmx2; | ||
| 194 | } | ||
| 192 | } | 195 | } |
| 193 | } | 196 | } |
| 194 | } | ||
| 195 | 197 | ||
| 196 | if (mm_flags & AV_CPU_FLAG_SSE) { | 198 | if (mm_flags & AV_CPU_FLAG_SSE) { |
| 197 | h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse; | 199 | h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse; |
| 198 | } | 200 | } |
| 199 | 201 | ||
| 200 | if (mm_flags & AV_CPU_FLAG_SSE2) { | 202 | if (mm_flags & AV_CPU_FLAG_SSE2) { |
| 201 | h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2; | 203 | h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2; |
| 202 | h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2; | 204 | h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2; |
| 203 | h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2; | 205 | h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_sse2; |
| 204 | h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2; | 206 | h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2; |
| 205 | h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2; | 207 | h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2; |
| 206 | h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2; | 208 | h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2; |
| 207 | if (codec_id == CODEC_ID_VP8) { | 209 | if (codec_id == CODEC_ID_VP8) { |
| 208 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2; | 210 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_sse2; |
| 209 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2; | 211 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_sse2; |
| 210 | } else { | ||
| 211 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_sse2; | ||
| 212 | if (codec_id == CODEC_ID_SVQ3) { | ||
| 213 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2; | ||
| 214 | } else if (codec_id == CODEC_ID_RV40) { | ||
| 215 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2; | ||
| 216 | } else { | 212 | } else { |
| 217 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2; | 213 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_plane_sse2; |
| 214 | if (codec_id == CODEC_ID_SVQ3) { | ||
| 215 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2; | ||
| 216 | } else if (codec_id == CODEC_ID_RV40) { | ||
| 217 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2; | ||
| 218 | } else { | ||
| 219 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2; | ||
| 220 | } | ||
| 218 | } | 221 | } |
| 219 | } | 222 | } |
| 220 | } | ||
| 221 | 223 | ||
| 222 | if (mm_flags & AV_CPU_FLAG_SSSE3) { | 224 | if (mm_flags & AV_CPU_FLAG_SSSE3) { |
| 223 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; | 225 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; |
| 224 | h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3; | 226 | h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3; |
| 225 | h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3; | 227 | h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3; |
| 226 | h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3; | 228 | h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3; |
| 227 | h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3; | 229 | h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3; |
| 228 | h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3; | 230 | h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3; |
| 229 | h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3; | 231 | h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3; |
| 230 | h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3; | 232 | h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3; |
| 231 | h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_ssse3; | 233 | h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_ssse3; |
| 232 | h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3; | 234 | h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3; |
| 233 | h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3; | 235 | h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3; |
| 234 | h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3; | 236 | h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3; |
| 235 | h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3; | 237 | h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3; |
| 236 | if (codec_id == CODEC_ID_VP8) { | 238 | if (codec_id == CODEC_ID_VP8) { |
| 237 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3; | 239 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_ssse3; |
| 238 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; | 240 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; |
| 239 | } else { | ||
| 240 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3; | ||
| 241 | if (codec_id == CODEC_ID_SVQ3) { | ||
| 242 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3; | ||
| 243 | } else if (codec_id == CODEC_ID_RV40) { | ||
| 244 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3; | ||
| 245 | } else { | 241 | } else { |
| 246 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3; | 242 | h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3; |
| 243 | if (codec_id == CODEC_ID_SVQ3) { | ||
| 244 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3; | ||
| 245 | } else if (codec_id == CODEC_ID_RV40) { | ||
| 246 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3; | ||
| 247 | } else { | ||
| 248 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3; | ||
| 249 | } | ||
| 247 | } | 250 | } |
| 248 | } | 251 | } |
| 249 | } | ||
| 250 | #endif | ||
| 251 | } else if (bit_depth == 10) { | 252 | } else if (bit_depth == 10) { |
| 252 | #if HAVE_YASM | ||
| 253 | if (mm_flags & AV_CPU_FLAG_MMX2) { | 253 | if (mm_flags & AV_CPU_FLAG_MMX2) { |
| 254 | h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; | 254 | h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; |
| 255 | h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; | 255 | 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 · 14 unmodified lines | |||
| 270 | h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3; | 270 | h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3; |
| 271 | } | 271 | } |
| 272 | #if HAVE_AVX | 272 | #if HAVE_AVX |
| 273 | if (mm_flags&AV_CPU_FLAG_AVX) { | 273 | if (mm_flags & AV_CPU_FLAG_AVX) { |
| 274 | h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx; | 274 | h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx; |
| 275 | h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx; | 275 | h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx; |
| 276 | h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_avx; | 276 | h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_avx; |
| 277 | h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_avx; | 277 | h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_avx; |
| 278 | } | 278 | } |
| 279 | #endif /* HAVE_AVX */ | 279 | #endif /* HAVE_AVX */ |
| 280 | #endif /* HAVE_YASM */ | ||
| 281 | } | 280 | } |
| 281 | #endif /* HAVE_YASM */ | ||
| 282 | } | 282 | } |
| @@ -1254,7 +1254,7 @@ static int avi_load_index(AVFormatContext *s) · 1253 unmodified lines | |||
| 1254 | if (avio_seek(pb, avi->movi_end, SEEK_SET) < 0) | 1254 | if (avio_seek(pb, avi->movi_end, SEEK_SET) < 0) |
| 1255 | goto the_end; // maybe truncated file | 1255 | goto the_end; // maybe truncated file |
| 1256 | #ifdef DEBUG_SEEK | 1256 | #ifdef DEBUG_SEEK |
| 1257 | printf("movi_end=0x%"PRIx64"\n", avi->movi_end); | 1257 | av_log(s, AV_LOG_DEBUG, "movi_end=0x%"PRIx64"\n", avi->movi_end); |
| 1258 | #endif | 1258 | #endif |
| 1259 | for(;;) { | 1259 | for(;;) { |
| 1260 | if (url_feof(pb)) | 1260 | if (url_feof(pb)) |
| @@ -1262,7 +1262,7 @@ static int avi_load_index(AVFormatContext *s) · 1 unmodified line | |||
| 1262 | tag = avio_rl32(pb); | 1262 | tag = avio_rl32(pb); |
| 1263 | size = avio_rl32(pb); | 1263 | size = avio_rl32(pb); |
| 1264 | #ifdef DEBUG_SEEK | 1264 | #ifdef DEBUG_SEEK |
| 1265 | printf("tag=%c%c%c%c size=0x%x\n", | 1265 | av_log(s, AV_LOG_DEBUG, "tag=%c%c%c%c size=0x%x\n", |
| 1266 | tag & 0xff, | 1266 | tag & 0xff, |
| 1267 | (tag >> 8) & 0xff, | 1267 | (tag >> 8) & 0xff, |
| 1268 | (tag >> 16) & 0xff, | 1268 | (tag >> 16) & 0xff, |
| @@ -28,7 +28,7 @@ · 27 unmodified lines | |||
| 28 | #include <string.h> | 28 | #include <string.h> |
| 29 | #include "libavutil/intreadwrite.h" | 29 | #include "libavutil/intreadwrite.h" |
| 30 | #include "libavutil/avstring.h" | 30 | #include "libavutil/avstring.h" |
| 31 | #include "libavformat/internal.h" | 31 | #include "internal.h" |
| 32 | #include "mms.h" | 32 | #include "mms.h" |
| 33 | #include "asf.h" | 33 | #include "asf.h" |
| 34 | #include "http.h" | 34 | #include "http.h" |
| @@ -23,7 +23,6 @@ · 22 unmodified lines | |||
| 23 | #include <limits.h> | 23 | #include <limits.h> |
| 24 | 24 | ||
| 25 | //#define DEBUG | 25 | //#define DEBUG |
| 26 | //#define DEBUG_METADATA | ||
| 27 | //#define MOV_EXPORT_ALL_METADATA | 26 | //#define MOV_EXPORT_ALL_METADATA |
| 28 | 27 | ||
| 29 | #include "libavutil/intreadwrite.h" | 28 | #include "libavutil/intreadwrite.h" |
| @@ -215,11 +214,9 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 185 unmodified lines | |||
| 215 | av_metadata_set2(&c->fc->metadata, key2, str, 0); | 214 | av_metadata_set2(&c->fc->metadata, key2, str, 0); |
| 216 | } | 215 | } |
| 217 | } | 216 | } |
| 218 | #ifdef DEBUG_METADATA | 217 | av_dlog(c->fc, "lang \"%3s\" ", language); |
| 219 | av_log(c->fc, AV_LOG_DEBUG, "lang \"%3s\" ", language); | 218 | av_dlog(c->fc, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %"PRId64"\n", |
| 220 | av_log(c->fc, AV_LOG_DEBUG, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %lld\n", | 219 | key, str, (char*)&atom.type, str_size, atom.size); |
| 221 | key, str, (char*)&atom.type, str_size, atom.size); | ||
| 222 | #endif | ||
| 223 | 220 | ||
| 224 | return 0; | 221 | return 0; |
| 225 | } | 222 | } |
| @@ -586,9 +586,6 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, · 585 unmodified lines | |||
| 586 | int64_t pos, pts, dts; | 586 | int64_t pos, pts, dts; |
| 587 | 587 | ||
| 588 | pos = *ppos; | 588 | pos = *ppos; |
| 589 | #ifdef DEBUG_SEEK | ||
| 590 | printf("read_dts: pos=0x%"PRIx64" next=%d -> ", pos, find_next); | ||
| 591 | #endif | ||
| 592 | if (avio_seek(s->pb, pos, SEEK_SET) < 0) | 589 | if (avio_seek(s->pb, pos, SEEK_SET) < 0) |
| 593 | return AV_NOPTS_VALUE; | 590 | return AV_NOPTS_VALUE; |
| 594 | 591 | ||
| @@ -596,7 +593,7 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, · 1 unmodified line | |||
| 596 | len = mpegps_read_pes_header(s, &pos, &startcode, &pts, &dts); | 593 | len = mpegps_read_pes_header(s, &pos, &startcode, &pts, &dts); |
| 597 | if (len < 0) { | 594 | if (len < 0) { |
| 598 | #ifdef DEBUG_SEEK | 595 | #ifdef DEBUG_SEEK |
| 599 | printf("none (ret=%d)\n", len); | 596 | av_log(s, AV_LOG_DEBUG, "none (ret=%d)\n", len); |
| 600 | #endif | 597 | #endif |
| 601 | return AV_NOPTS_VALUE; | 598 | return AV_NOPTS_VALUE; |
| 602 | } | 599 | } |
| @@ -607,7 +604,8 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, · 4 unmodified lines | |||
| 607 | avio_skip(s->pb, len); | 604 | avio_skip(s->pb, len); |
| 608 | } | 605 | } |
| 609 | #ifdef DEBUG_SEEK | 606 | #ifdef DEBUG_SEEK |
| 610 | printf("pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", pos, dts, dts / 90000.0); | 607 | av_log(s, AV_LOG_DEBUG, "pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", |
| 608 | pos, dts, dts / 90000.0); | ||
| 611 | #endif | 609 | #endif |
| 612 | *ppos = pos; | 610 | *ppos = pos; |
| 613 | return dts; | 611 | return dts; |
| @@ -31,9 +31,6 @@ · 30 unmodified lines | |||
| 31 | #include "rdt.h" | 31 | #include "rdt.h" |
| 32 | #include "url.h" | 32 | #include "url.h" |
| 33 | 33 | ||
| 34 | //#define DEBUG | ||
| 35 | //#define DEBUG_RTP_TCP | ||
| 36 | |||
| 37 | static int rtsp_read_play(AVFormatContext *s) | 34 | static int rtsp_read_play(AVFormatContext *s) |
| 38 | { | 35 | { |
| 39 | RTSPState *rt = s->priv_data; | 36 | RTSPState *rt = s->priv_data; |
| @@ -191,9 +188,7 @@ int ff_rtsp_tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, · 151 unmodified lines | |||
| 191 | int id, len, i, ret; | 188 | int id, len, i, ret; |
| 192 | RTSPStream *rtsp_st; | 189 | RTSPStream *rtsp_st; |
| 193 | 190 | ||
| 194 | #ifdef DEBUG_RTP_TCP | ||
| 195 | av_dlog(s, "tcp_read_packet:\n"); | 191 | av_dlog(s, "tcp_read_packet:\n"); |
| 196 | #endif | ||
| 197 | redo: | 192 | redo: |
| 198 | for (;;) { | 193 | for (;;) { |
| 199 | RTSPMessageHeader reply; | 194 | RTSPMessageHeader reply; |
| @@ -212,9 +207,7 @@ redo: · 12 unmodified lines | |||
| 212 | return -1; | 207 | return -1; |
| 213 | id = buf[0]; | 208 | id = buf[0]; |
| 214 | len = AV_RB16(buf + 1); | 209 | len = AV_RB16(buf + 1); |
| 215 | #ifdef DEBUG_RTP_TCP | ||
| 216 | av_dlog(s, "id=%d len=%d\n", id, len); | 210 | av_dlog(s, "id=%d len=%d\n", id, len); |
| 217 | #endif | ||
| 218 | if (len > buf_size || len < 12) | 211 | if (len > buf_size || len < 12) |
| 219 | goto redo; | 212 | goto redo; |
| 220 | /* get the data */ | 213 | /* get the data */ |
| @@ -23,8 +23,8 @@ · 22 unmodified lines | |||
| 23 | * audio conversion routines | 23 | * audio conversion routines |
| 24 | */ | 24 | */ |
| 25 | 25 | ||
| 26 | #include "libavutil/avutil.h" | 26 | #include "avstring.h" |
| 27 | #include "libavutil/avstring.h" | 27 | #include "avutil.h" |
| 28 | #include "audioconvert.h" | 28 | #include "audioconvert.h" |
| 29 | 29 | ||
| 30 | static const char * const channel_names[] = { | 30 | static const char * const channel_names[] = { |
| @@ -40,8 +40,8 @@ · 39 unmodified lines | |||
| 40 | #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) | 40 | #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) |
| 41 | 41 | ||
| 42 | #define LIBAVUTIL_VERSION_MAJOR 51 | 42 | #define LIBAVUTIL_VERSION_MAJOR 51 |
| 43 | #define LIBAVUTIL_VERSION_MINOR 6 | 43 | #define LIBAVUTIL_VERSION_MINOR 7 |
| 44 | #define LIBAVUTIL_VERSION_MICRO 1 | 44 | #define LIBAVUTIL_VERSION_MICRO 0 |
| 45 | 45 | ||
| 46 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | 46 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| 47 | LIBAVUTIL_VERSION_MINOR, \ | 47 | LIBAVUTIL_VERSION_MINOR, \ |
| @@ -60,6 +60,9 @@ · 12 unmodified lines | |||
| 60 | #ifndef FF_API_OLD_EVAL_NAMES | 60 | #ifndef FF_API_OLD_EVAL_NAMES |
| 61 | #define FF_API_OLD_EVAL_NAMES (LIBAVUTIL_VERSION_MAJOR < 52) | 61 | #define FF_API_OLD_EVAL_NAMES (LIBAVUTIL_VERSION_MAJOR < 52) |
| 62 | #endif | 62 | #endif |
| 63 | #ifndef FF_API_GET_BITS_PER_SAMPLE_FMT | ||
| 64 | #define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 52) | ||
| 65 | #endif | ||
| 63 | 66 | ||
| 64 | /** | 67 | /** |
| 65 | * Return the LIBAVUTIL_VERSION_INT constant. | 68 | * Return the LIBAVUTIL_VERSION_INT constant. |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | |||
| 26 | * see http://joe.hotchkiss.com/programming/eval/eval.html | 26 | * see http://joe.hotchkiss.com/programming/eval/eval.html |
| 27 | */ | 27 | */ |
| 28 | 28 | ||
| 29 | #include "libavutil/avutil.h" | 29 | #include "avutil.h" |
| 30 | #include "eval.h" | 30 | #include "eval.h" |
| 31 | 31 | ||
| 32 | typedef struct Parser { | 32 | typedef struct Parser { |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | |||
| 23 | 23 | ||
| 24 | #include "imgutils.h" | 24 | #include "imgutils.h" |
| 25 | #include "internal.h" | 25 | #include "internal.h" |
| 26 | #include "libavutil/pixdesc.h" | 26 | #include "pixdesc.h" |
| 27 | 27 | ||
| 28 | void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], | 28 | void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], |
| 29 | const AVPixFmtDescriptor *pixdesc) | 29 | const AVPixFmtDescriptor *pixdesc) |
| @@ -24,8 +24,8 @@ · 23 unmodified lines | |||
| 24 | * misc image utilities | 24 | * misc image utilities |
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #include "libavutil/pixdesc.h" | ||
| 28 | #include "avutil.h" | 27 | #include "avutil.h" |
| 28 | #include "pixdesc.h" | ||
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | * Compute the max pixel step for each plane of an image with a | 31 | * Compute the max pixel step for each plane of an image with a |
| @@ -19,7 +19,7 @@ · 18 unmodified lines | |||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include "libavutil/intmath.h" | 22 | #include <stdint.h> |
| 23 | 23 | ||
| 24 | /* a*inverse[b]>>32 == a/b for all 0<=a<=16909558 && 2<=b<=256 | 24 | /* a*inverse[b]>>32 == a/b for all 0<=a<=16909558 && 2<=b<=256 |
| 25 | * for a>16909558, is an overestimate by less than 1 part in 1<<24 */ | 25 | * for a>16909558, is an overestimate by less than 1 part in 1<<24 */ |
| @@ -24,11 +24,12 @@ · 23 unmodified lines | |||
| 24 | #include <strings.h> | 24 | #include <strings.h> |
| 25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
| 26 | #include <time.h> | 26 | #include <time.h> |
| 27 | |||
| 28 | #include "avstring.h" | ||
| 29 | #include "avutil.h" | ||
| 30 | #include "eval.h" | ||
| 31 | #include "random_seed.h" | ||
| 27 | #include "parseutils.h" | 32 | #include "parseutils.h" |
| 28 | #include "libavutil/avutil.h" | ||
| 29 | #include "libavutil/eval.h" | ||
| 30 | #include "libavutil/avstring.h" | ||
| 31 | #include "libavutil/random_seed.h" | ||
| 32 | 33 | ||
| 33 | typedef struct { | 34 | typedef struct { |
| 34 | const char *abbr; | 35 | const char *abbr; |
| @@ -19,7 +19,7 @@ · 18 unmodified lines | |||
| 19 | #ifndef AVUTIL_PARSEUTILS_H | 19 | #ifndef AVUTIL_PARSEUTILS_H |
| 20 | #define AVUTIL_PARSEUTILS_H | 20 | #define AVUTIL_PARSEUTILS_H |
| 21 | 21 | ||
| 22 | #include "libavutil/rational.h" | 22 | #include "rational.h" |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | * @file | 25 | * @file |
| @@ -66,11 +66,19 @@ char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sam · 65 unmodified lines | |||
| 66 | return buf; | 66 | return buf; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt) | ||
| 70 | { | ||
| 71 | return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? | ||
| 72 | 0 : sample_fmt_info[sample_fmt].bits >> 3; | ||
| 73 | } | ||
| 74 | |||
| 75 | #if FF_API_GET_BITS_PER_SAMPLE_FMT | ||
| 69 | int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) | 76 | int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) |
| 70 | { | 77 | { |
| 71 | return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? | 78 | return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? |
| 72 | 0 : sample_fmt_info[sample_fmt].bits; | 79 | 0 : sample_fmt_info[sample_fmt].bits; |
| 73 | } | 80 | } |
| 81 | #endif | ||
| 74 | 82 | ||
| 75 | int av_samples_fill_arrays(uint8_t *pointers[8], int linesizes[8], | 83 | int av_samples_fill_arrays(uint8_t *pointers[8], int linesizes[8], |
| 76 | uint8_t *buf, int nb_channels, int nb_samples, | 84 | uint8_t *buf, int nb_channels, int nb_samples, |
| @@ -60,14 +60,22 @@ enum AVSampleFormat av_get_sample_fmt(const char *name); · 59 unmodified lines | |||
| 60 | */ | 60 | */ |
| 61 | char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); | 61 | char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); |
| 62 | 62 | ||
| 63 | #if FF_API_GET_BITS_PER_SAMPLE_FMT | ||
| 63 | /** | 64 | /** |
| 64 | * Return sample format bits per sample. | 65 | * @deprecated Use av_get_bytes_per_sample() instead. |
| 66 | */ | ||
| 67 | attribute_deprecated | ||
| 68 | int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); | ||
| 69 | #endif | ||
| 70 | |||
| 71 | /** | ||
| 72 | * Return number of bytes per sample. | ||
| 65 | * | 73 | * |
| 66 | * @param sample_fmt the sample format | 74 | * @param sample_fmt the sample format |
| 67 | * @return number of bits per sample or zero if unknown for the given | 75 | * @return number of bytes per sample or zero if unknown for the given |
| 68 | * sample format | 76 | * sample format |
| 69 | */ | 77 | */ |
| 70 | int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); | 78 | int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt); |
| 71 | 79 | ||
| 72 | /** | 80 | /** |
| 73 | * Fill channel data pointers and linesizes for samples with sample | 81 | * Fill channel data pointers and linesizes for samples with sample |
| @@ -403,15 +403,19 @@ static void hScale_altivec_real(int16_t *dst, int dstW, · 402 unmodified lines | |||
| 403 | 403 | ||
| 404 | void ff_sws_init_swScale_altivec(SwsContext *c) | 404 | void ff_sws_init_swScale_altivec(SwsContext *c) |
| 405 | { | 405 | { |
| 406 | enum PixelFormat dstFormat = c->dstFormat; | ||
| 407 | |||
| 406 | if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) | 408 | if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) |
| 407 | return; | 409 | return; |
| 408 | 410 | ||
| 409 | c->hScale = hScale_altivec_real; | 411 | c->hScale = hScale_altivec_real; |
| 410 | c->yuv2yuvX = yuv2yuvX_altivec_real; | 412 | if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat)) { |
| 413 | c->yuv2yuvX = yuv2yuvX_altivec_real; | ||
| 414 | } | ||
| 411 | 415 | ||
| 412 | /* The following list of supported dstFormat values should | 416 | /* The following list of supported dstFormat values should |
| 413 | * match what's found in the body of ff_yuv2packedX_altivec() */ | 417 | * match what's found in the body of ff_yuv2packedX_altivec() */ |
| 414 | if (!(c->flags & SWS_BITEXACT) && !c->alpPixBuf && | 418 | if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->alpPixBuf && |
| 415 | (c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA || | 419 | (c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA || |
| 416 | c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 || | 420 | c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 || |
| 417 | c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)) { | 421 | 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, · 352 unmodified lines | |||
| 353 | output_pixel(&aDest[i], val); | 353 | output_pixel(&aDest[i], val); |
| 354 | } | 354 | } |
| 355 | } | 355 | } |
| 356 | #undef output_pixel | ||
| 356 | } | 357 | } |
| 357 | 358 | ||
| 358 | #define yuv2NBPS(bits, BE_LE, is_be) \ | 359 | #define yuv2NBPS(bits, BE_LE, is_be) \ |
| 359 | static void yuv2yuvX ## bits ## BE_LE ## _c(const int16_t *lumFilter, \ | 360 | static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFilter, \ |
| 360 | const int16_t **lumSrc, int lumFilterSize, \ | 361 | const int16_t **lumSrc, int lumFilterSize, \ |
| 361 | const int16_t *chrFilter, const int16_t **chrUSrc, \ | 362 | const int16_t *chrFilter, const int16_t **chrUSrc, \ |
| 362 | const int16_t **chrVSrc, \ | 363 | const int16_t **chrVSrc, \ |
| 363 | int chrFilterSize, const int16_t **alpSrc, \ | 364 | int chrFilterSize, const int16_t **alpSrc, \ |
| 364 | uint16_t *dest, uint16_t *uDest, uint16_t *vDest, \ | 365 | uint8_t *_dest, uint8_t *_uDest, uint8_t *_vDest, \ |
| 365 | uint16_t *aDest, int dstW, int chrDstW) \ | 366 | uint8_t *_aDest, int dstW, int chrDstW) \ |
| 366 | { \ | 367 | { \ |
| 368 | uint16_t *dest = (uint16_t *) _dest, *uDest = (uint16_t *) _uDest, \ | ||
| 369 | *vDest = (uint16_t *) _vDest, *aDest = (uint16_t *) _aDest; \ | ||
| 367 | yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \ | 370 | yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \ |
| 368 | chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ | 371 | chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ |
| 369 | alpSrc, \ | 372 | alpSrc, \ |
| @@ -377,7 +380,7 @@ yuv2NBPS(10, LE, 0); · 7 unmodified lines | |||
| 377 | yuv2NBPS(16, BE, 1); | 380 | yuv2NBPS(16, BE, 1); |
| 378 | yuv2NBPS(16, LE, 0); | 381 | yuv2NBPS(16, LE, 0); |
| 379 | 382 | ||
| 380 | static inline void yuv2yuvX16_c(const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, | 383 | static inline void yuv2yuvX16_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, |
| 381 | const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, | 384 | const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, |
| 382 | const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW, | 385 | const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW, |
| 383 | enum PixelFormat dstFormat) | 386 | enum PixelFormat dstFormat) |
| @@ -452,9 +455,13 @@ static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, const int16_t ** · 68 unmodified lines | |||
| 452 | static inline void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, | 455 | static inline void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, |
| 453 | const int16_t *chrFilter, const int16_t **chrUSrc, | 456 | const int16_t *chrFilter, const int16_t **chrUSrc, |
| 454 | const int16_t **chrVSrc, int chrFilterSize, | 457 | const int16_t **chrVSrc, int chrFilterSize, |
| 455 | uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, int dstFormat, | 458 | const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, |
| 459 | uint8_t *vDest, uint8_t *aDest, | ||
| 460 | int dstW, int chrDstW, | ||
| 456 | const uint8_t *lumDither, const uint8_t *chrDither) | 461 | const uint8_t *lumDither, const uint8_t *chrDither) |
| 457 | { | 462 | { |
| 463 | enum PixelFormat dstFormat = c->dstFormat; | ||
| 464 | |||
| 458 | //FIXME Optimize (just quickly written not optimized..) | 465 | //FIXME Optimize (just quickly written not optimized..) |
| 459 | int i; | 466 | int i; |
| 460 | for (i=0; i<dstW; i++) { | 467 | 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 · 687 unmodified lines | |||
| 1148 | } | 1155 | } |
| 1149 | } | 1156 | } |
| 1150 | 1157 | ||
| 1158 | static void rgbaToA_c(int16_t *dst, const uint8_t *src, int width, uint32_t *unused) | ||
| 1159 | { | ||
| 1160 | int i; | ||
| 1161 | for (i=0; i<width; i++) { | ||
| 1162 | dst[i]= src[4*i+3]<<6; | ||
| 1163 | } | ||
| 1164 | } | ||
| 1165 | |||
| 1151 | #define BGR2UV(type, name, shr, shg, shb, shp, maskr, maskg, maskb, RU, GU, BU, RV, GV, BV, S) \ | 1166 | #define BGR2UV(type, name, shr, shg, shb, shp, maskr, maskg, maskb, RU, GU, BU, RV, GV, BV, S) \ |
| 1152 | static void name ## _c(int16_t *dstU, int16_t *dstV, const uint8_t *src, const uint8_t *dummy, int width, uint32_t *unused)\ | 1167 | static void name ## _c(int16_t *dstU, int16_t *dstV, const uint8_t *src, const uint8_t *dummy, int width, uint32_t *unused)\ |
| 1153 | {\ | 1168 | {\ |
| @@ -1616,8 +1631,6 @@ static inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, · 462 unmodified lines | |||
| 1616 | void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12; | 1631 | void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12; |
| 1617 | void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange; | 1632 | void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange; |
| 1618 | 1633 | ||
| 1619 | src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset; | ||
| 1620 | |||
| 1621 | if (toYV12) { | 1634 | if (toYV12) { |
| 1622 | toYV12(formatConvBuffer, src, srcW, pal); | 1635 | toYV12(formatConvBuffer, src, srcW, pal); |
| 1623 | src= formatConvBuffer; | 1636 | src= formatConvBuffer; |
| @@ -1661,10 +1674,6 @@ static inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *dst2, int ds · 37 unmodified lines | |||
| 1661 | const int16_t *hChrFilterPos, int hChrFilterSize, | 1674 | const int16_t *hChrFilterPos, int hChrFilterSize, |
| 1662 | uint8_t *formatConvBuffer, uint32_t *pal) | 1675 | uint8_t *formatConvBuffer, uint32_t *pal) |
| 1663 | { | 1676 | { |
| 1664 | |||
| 1665 | src1 += c->chrSrcOffset; | ||
| 1666 | src2 += c->chrSrcOffset; | ||
| 1667 | |||
| 1668 | if (c->chrToYV12) { | 1677 | if (c->chrToYV12) { |
| 1669 | uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16); | 1678 | uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16); |
| 1670 | c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); | 1679 | 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 · 16 unmodified lines | |||
| 1687 | c->chrConvertRange(dst1, dst2, dstWidth); | 1696 | c->chrConvertRange(dst1, dst2, dstWidth); |
| 1688 | } | 1697 | } |
| 1689 | 1698 | ||
| 1699 | static av_always_inline void | ||
| 1700 | find_c_packed_planar_out_funcs(SwsContext *c, | ||
| 1701 | yuv2planar1_fn *yuv2yuv1, yuv2planarX_fn *yuv2yuvX, | ||
| 1702 | yuv2packed1_fn *yuv2packed1, yuv2packed2_fn *yuv2packed2, | ||
| 1703 | yuv2packedX_fn *yuv2packedX) | ||
| 1704 | { | ||
| 1705 | enum PixelFormat dstFormat = c->dstFormat; | ||
| 1706 | |||
| 1707 | if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { | ||
| 1708 | *yuv2yuvX = yuv2nv12X_c; | ||
| 1709 | } else if (is16BPS(dstFormat)) { | ||
| 1710 | *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX16BE_c : yuv2yuvX16LE_c; | ||
| 1711 | } else if (is9_OR_10BPS(dstFormat)) { | ||
| 1712 | if (dstFormat == PIX_FMT_YUV420P9BE || dstFormat == PIX_FMT_YUV420P9LE) { | ||
| 1713 | *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX9BE_c : yuv2yuvX9LE_c; | ||
| 1714 | } else { | ||
| 1715 | *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX10BE_c : yuv2yuvX10LE_c; | ||
| 1716 | } | ||
| 1717 | } else { | ||
| 1718 | *yuv2yuv1 = yuv2yuv1_c; | ||
| 1719 | *yuv2yuvX = yuv2yuvX_c; | ||
| 1720 | } | ||
| 1721 | if(c->flags & SWS_FULL_CHR_H_INT) { | ||
| 1722 | *yuv2packedX = yuv2rgbX_c_full; | ||
| 1723 | } else { | ||
| 1724 | *yuv2packed1 = yuv2packed1_c; | ||
| 1725 | *yuv2packed2 = yuv2packed2_c; | ||
| 1726 | *yuv2packedX = yuv2packedX_c; | ||
| 1727 | } | ||
| 1728 | } | ||
| 1729 | |||
| 1690 | #define DEBUG_SWSCALE_BUFFERS 0 | 1730 | #define DEBUG_SWSCALE_BUFFERS 0 |
| 1691 | #define DEBUG_BUFFERS(...) if (DEBUG_SWSCALE_BUFFERS) av_log(c, AV_LOG_DEBUG, __VA_ARGS__) | 1731 | #define DEBUG_BUFFERS(...) if (DEBUG_SWSCALE_BUFFERS) av_log(c, AV_LOG_DEBUG, __VA_ARGS__) |
| 1692 | 1732 | ||
| @@ -1731,6 +1771,11 @@ static int swScale(SwsContext *c, const uint8_t* src[], · 38 unmodified lines | |||
| 1731 | int lastDstY; | 1771 | int lastDstY; |
| 1732 | uint32_t *pal=c->pal_yuv; | 1772 | uint32_t *pal=c->pal_yuv; |
| 1733 | int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat); | 1773 | int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat); |
| 1774 | yuv2planar1_fn yuv2yuv1 = c->yuv2yuv1; | ||
| 1775 | yuv2planarX_fn yuv2yuvX = c->yuv2yuvX; | ||
| 1776 | yuv2packed1_fn yuv2packed1 = c->yuv2packed1; | ||
| 1777 | yuv2packed2_fn yuv2packed2 = c->yuv2packed2; | ||
| 1778 | yuv2packedX_fn yuv2packedX = c->yuv2packedX; | ||
| 1734 | 1779 | ||
| 1735 | /* vars which will change and which we need to store back in the context */ | 1780 | /* vars which will change and which we need to store back in the context */ |
| 1736 | int dstY= c->dstY; | 1781 | int dstY= c->dstY; |
| @@ -1869,37 +1914,31 @@ static int swScale(SwsContext *c, const uint8_t* src[], · 132 unmodified lines | |||
| 1869 | #if HAVE_MMX | 1914 | #if HAVE_MMX |
| 1870 | updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf); | 1915 | updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf); |
| 1871 | #endif | 1916 | #endif |
| 1872 | if (dstY < dstH-2) { | 1917 | if (dstY >= dstH-2) { |
| 1918 | // hmm looks like we can't use MMX here without overwriting this array's tail | ||
| 1919 | find_c_packed_planar_out_funcs(c, &yuv2yuv1, &yuv2yuvX, | ||
| 1920 | &yuv2packed1, &yuv2packed2, | ||
| 1921 | &yuv2packedX); | ||
| 1922 | } | ||
| 1923 | |||
| 1924 | { | ||
| 1873 | const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | 1925 | const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; |
| 1874 | const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | 1926 | const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; |
| 1875 | const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | 1927 | const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; |
| 1876 | const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; | 1928 | const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; |
| 1877 | if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { | 1929 | |
| 1878 | const int chrSkipMask= (1<<c->chrDstVSubSample)-1; | 1930 | if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like |
| 1879 | if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi | ||
| 1880 | c->yuv2nv12X(c, | ||
| 1881 | vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, | ||
| 1882 | vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | ||
| 1883 | dest, uDest, dstW, chrDstW, dstFormat, lumDither, chrDither); | ||
| 1884 | } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like | ||
| 1885 | const int chrSkipMask= (1<<c->chrDstVSubSample)-1; | 1931 | const int chrSkipMask= (1<<c->chrDstVSubSample)-1; |
| 1886 | if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | 1932 | if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi |
| 1887 | if (is16BPS(dstFormat) || isNBPS(dstFormat)) { | 1933 | if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12 |
| 1888 | yuv2yuvX16_c(vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, | ||
| 1889 | vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, | ||
| 1890 | chrVSrcPtr, vChrFilterSize, | ||
| 1891 | alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, | ||
| 1892 | (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW, | ||
| 1893 | dstFormat); | ||
| 1894 | } else if (vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12 | ||
| 1895 | const int16_t *lumBuf = lumSrcPtr[0]; | 1934 | const int16_t *lumBuf = lumSrcPtr[0]; |
| 1896 | const int16_t *chrUBuf= chrUSrcPtr[0]; | 1935 | const int16_t *chrUBuf= chrUSrcPtr[0]; |
| 1897 | const int16_t *chrVBuf= chrVSrcPtr[0]; | 1936 | const int16_t *chrVBuf= chrVSrcPtr[0]; |
| 1898 | const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL; | 1937 | const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL; |
| 1899 | c->yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest, | 1938 | yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest, |
| 1900 | uDest, vDest, aDest, dstW, chrDstW, lumDither, chrDither); | 1939 | uDest, vDest, aDest, dstW, chrDstW, lumDither, chrDither); |
| 1901 | } else { //General YV12 | 1940 | } else { //General YV12 |
| 1902 | c->yuv2yuvX(c, | 1941 | yuv2yuvX(c, |
| 1903 | vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, | 1942 | vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, |
| 1904 | vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, | 1943 | vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, |
| 1905 | chrVSrcPtr, vChrFilterSize, | 1944 | chrVSrcPtr, vChrFilterSize, |
| @@ -1908,94 +1947,28 @@ static int swScale(SwsContext *c, const uint8_t* src[], · 2 unmodified lines | |||
| 1908 | } else { | 1947 | } else { |
| 1909 | assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | 1948 | assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); |
| 1910 | assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); | 1949 | assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); |
| 1911 | if (vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB | 1950 | if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB |
| 1912 | int chrAlpha= vChrFilter[2*dstY+1]; | 1951 | int chrAlpha= vChrFilter[2*dstY+1]; |
| 1913 | if(flags & SWS_FULL_CHR_H_INT) { | 1952 | yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1), |
| 1914 | yuv2rgbX_c_full(c, //FIXME write a packed1_full function | 1953 | *chrVSrcPtr, *(chrVSrcPtr+1), |
| 1915 | vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | 1954 | alpPixBuf ? *alpSrcPtr : NULL, |
| 1916 | vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, | 1955 | dest, dstW, chrAlpha, dstFormat, flags, dstY); |
| 1917 | chrVSrcPtr, vChrFilterSize, | 1956 | } else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB |
| 1918 | alpSrcPtr, dest, dstW, dstY); | ||
| 1919 | } else { | ||
| 1920 | c->yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1), | ||
| 1921 | *chrVSrcPtr, *(chrVSrcPtr+1), | ||
| 1922 | alpPixBuf ? *alpSrcPtr : NULL, | ||
| 1923 | dest, dstW, chrAlpha, dstFormat, flags, dstY); | ||
| 1924 | } | ||
| 1925 | } else if (vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB | ||
| 1926 | int lumAlpha= vLumFilter[2*dstY+1]; | 1957 | int lumAlpha= vLumFilter[2*dstY+1]; |
| 1927 | int chrAlpha= vChrFilter[2*dstY+1]; | 1958 | int chrAlpha= vChrFilter[2*dstY+1]; |
| 1928 | lumMmxFilter[2]= | 1959 | lumMmxFilter[2]= |
| 1929 | lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001; | 1960 | lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001; |
| 1930 | chrMmxFilter[2]= | 1961 | chrMmxFilter[2]= |
| 1931 | chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001; | 1962 | chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001; |
| 1932 | if(flags & SWS_FULL_CHR_H_INT) { | 1963 | yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1), |
| 1933 | yuv2rgbX_c_full(c, //FIXME write a packed2_full function | 1964 | *chrVSrcPtr, *(chrVSrcPtr+1), |
| 1934 | vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | 1965 | alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL, |
| 1935 | vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | 1966 | dest, dstW, lumAlpha, chrAlpha, dstY); |
| 1936 | alpSrcPtr, dest, dstW, dstY); | ||
| 1937 | } else { | ||
| 1938 | c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1), | ||
| 1939 | *chrVSrcPtr, *(chrVSrcPtr+1), | ||
| 1940 | alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL, | ||
| 1941 | dest, dstW, lumAlpha, chrAlpha, dstY); | ||
| 1942 | } | ||
| 1943 | } else { //general RGB | 1967 | } else { //general RGB |
| 1944 | if(flags & SWS_FULL_CHR_H_INT) { | 1968 | yuv2packedX(c, |
| 1945 | yuv2rgbX_c_full(c, | 1969 | vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, |
| 1946 | vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | 1970 | vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, |
| 1947 | vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | 1971 | alpSrcPtr, dest, dstW, dstY); |
| 1948 | alpSrcPtr, dest, dstW, dstY); | ||
| 1949 | } else { | ||
| 1950 | c->yuv2packedX(c, | ||
| 1951 | vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | ||
| 1952 | vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | ||
| 1953 | alpSrcPtr, dest, dstW, dstY); | ||
| 1954 | } | ||
| 1955 | } | ||
| 1956 | } | ||
| 1957 | } else { // hmm looks like we can't use MMX here without overwriting this array's tail | ||
| 1958 | const int16_t **lumSrcPtr= (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | ||
| 1959 | const int16_t **chrUSrcPtr= (const int16_t **)chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | ||
| 1960 | const int16_t **chrVSrcPtr= (const int16_t **)chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | ||
| 1961 | const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; | ||
| 1962 | if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { | ||
| 1963 | const int chrSkipMask= (1<<c->chrDstVSubSample)-1; | ||
| 1964 | if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi | ||
| 1965 | yuv2nv12X_c(c, vLumFilter+dstY*vLumFilterSize, | ||
| 1966 | lumSrcPtr, vLumFilterSize, | ||
| 1967 | vChrFilter+chrDstY*vChrFilterSize, | ||
| 1968 | chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | ||
| 1969 | dest, uDest, dstW, chrDstW, dstFormat, lumDither, chrDither); | ||
| 1970 | } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 | ||
| 1971 | const int chrSkipMask= (1<<c->chrDstVSubSample)-1; | ||
| 1972 | if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | ||
| 1973 | if (is16BPS(dstFormat) || is9_OR_10BPS(dstFormat)) { | ||
| 1974 | yuv2yuvX16_c(vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, | ||
| 1975 | vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | ||
| 1976 | alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW, | ||
| 1977 | dstFormat); | ||
| 1978 | } else { | ||
| 1979 | yuv2yuvX_c(c, vLumFilter+dstY*vLumFilterSize, | ||
| 1980 | lumSrcPtr, vLumFilterSize, | ||
| 1981 | vChrFilter+chrDstY*vChrFilterSize, | ||
| 1982 | chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | ||
| 1983 | alpSrcPtr, dest, uDest, vDest, aDest, | ||
| 1984 | dstW, chrDstW, lumDither, chrDither); | ||
| 1985 | } | ||
| 1986 | } else { | ||
| 1987 | assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | ||
| 1988 | assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); | ||
| 1989 | if(flags & SWS_FULL_CHR_H_INT) { | ||
| 1990 | yuv2rgbX_c_full(c, | ||
| 1991 | vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | ||
| 1992 | vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | ||
| 1993 | alpSrcPtr, dest, dstW, dstY); | ||
| 1994 | } else { | ||
| 1995 | yuv2packedX_c(c, | ||
| 1996 | vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | ||
| 1997 | vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | ||
| 1998 | alpSrcPtr, dest, dstW, dstY); | ||
| 1999 | } | 1972 | } |
| 2000 | } | 1973 | } |
| 2001 | } | 1974 | } |
| @@ -2024,17 +1997,13 @@ static void sws_init_swScale_c(SwsContext *c) · 22 unmodified lines | |||
| 2024 | { | 1997 | { |
| 2025 | enum PixelFormat srcFormat = c->srcFormat; | 1998 | enum PixelFormat srcFormat = c->srcFormat; |
| 2026 | 1999 | ||
| 2027 | c->yuv2nv12X = yuv2nv12X_c; | 2000 | find_c_packed_planar_out_funcs(c, &c->yuv2yuv1, &c->yuv2yuvX, |
| 2028 | c->yuv2yuv1 = yuv2yuv1_c; | 2001 | &c->yuv2packed1, &c->yuv2packed2, |
| 2029 | c->yuv2yuvX = yuv2yuvX_c; | 2002 | &c->yuv2packedX); |
| 2030 | c->yuv2packed1 = yuv2packed1_c; | ||
| 2031 | c->yuv2packed2 = yuv2packed2_c; | ||
| 2032 | c->yuv2packedX = yuv2packedX_c; | ||
| 2033 | 2003 | ||
| 2034 | c->hScale = hScale_c; | 2004 | c->hScale = hScale_c; |
| 2035 | 2005 | ||
| 2036 | if (c->flags & SWS_FAST_BILINEAR) | 2006 | if (c->flags & SWS_FAST_BILINEAR) { |
| 2037 | { | ||
| 2038 | c->hyscale_fast = hyscale_fast_c; | 2007 | c->hyscale_fast = hyscale_fast_c; |
| 2039 | c->hcscale_fast = hcscale_fast_c; | 2008 | c->hcscale_fast = hcscale_fast_c; |
| 2040 | } | 2009 | } |
| @@ -2133,28 +2102,18 @@ static void sws_init_swScale_c(SwsContext *c) · 92 unmodified lines | |||
| 2133 | } | 2102 | } |
| 2134 | if (c->alpPixBuf) { | 2103 | if (c->alpPixBuf) { |
| 2135 | switch (srcFormat) { | 2104 | switch (srcFormat) { |
| 2136 | case PIX_FMT_RGB32 : | 2105 | case PIX_FMT_BGRA: |
| 2137 | case PIX_FMT_RGB32_1: | 2106 | case PIX_FMT_RGBA: c->alpToYV12 = rgbaToA_c; break; |
| 2138 | case PIX_FMT_BGR32 : | 2107 | case PIX_FMT_ABGR: |
| 2139 | case PIX_FMT_BGR32_1: c->alpToYV12 = abgrToA_c; break; | 2108 | case PIX_FMT_ARGB: c->alpToYV12 = abgrToA_c; break; |
| 2140 | case PIX_FMT_GRAY8A : c->alpToYV12 = yuy2ToY_c; break; | 2109 | case PIX_FMT_Y400A: c->alpToYV12 = uyvyToY_c; break; |
| 2141 | case PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; break; | 2110 | case PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; break; |
| 2142 | } | 2111 | } |
| 2143 | } | 2112 | } |
| 2144 | 2113 | ||
| 2145 | if(isAnyRGB(c->srcFormat) || c->srcFormat == PIX_FMT_PAL8) | 2114 | if(isAnyRGB(c->srcFormat) || c->srcFormat == PIX_FMT_PAL8) |
| 2146 | c->hScale16= hScale16_c; | 2115 | c->hScale16= hScale16_c; |
| 2147 | 2116 | ||
| 2148 | switch (srcFormat) { | ||
| 2149 | case PIX_FMT_GRAY8A : | ||
| 2150 | c->alpSrcOffset = 1; | ||
| 2151 | break; | ||
| 2152 | case PIX_FMT_RGB32 : | ||
| 2153 | case PIX_FMT_BGR32 : | ||
| 2154 | c->alpSrcOffset = 3; | ||
| 2155 | break; | ||
| 2156 | } | ||
| 2157 | |||
| 2158 | if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { | 2117 | if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { |
| 2159 | if (c->srcRange) { | 2118 | if (c->srcRange) { |
| 2160 | c->lumConvertRange = lumRangeFromJpeg_c; | 2119 | c->lumConvertRange = lumRangeFromJpeg_c; |
| @@ -59,6 +59,41 @@ typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[], · 58 unmodified lines | |||
| 59 | int srcStride[], int srcSliceY, int srcSliceH, | 59 | int srcStride[], int srcSliceY, int srcSliceH, |
| 60 | uint8_t* dst[], int dstStride[]); | 60 | uint8_t* dst[], int dstStride[]); |
| 61 | 61 | ||
| 62 | typedef void (*yuv2planar1_fn) (struct SwsContext *c, | ||
| 63 | const int16_t *lumSrc, const int16_t *chrUSrc, | ||
| 64 | const int16_t *chrVSrc, const int16_t *alpSrc, | ||
| 65 | uint8_t *dest, | ||
| 66 | uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, | ||
| 67 | int dstW, int chrDstW, const uint8_t *lumDither, const uint8_t *chrDither); | ||
| 68 | typedef void (*yuv2planarX_fn) (struct SwsContext *c, | ||
| 69 | const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, | ||
| 70 | const int16_t *chrFilter, const int16_t **chrUSrc, | ||
| 71 | const int16_t **chrVSrc, int chrFilterSize, | ||
| 72 | const int16_t **alpSrc, | ||
| 73 | uint8_t *dest, | ||
| 74 | uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, | ||
| 75 | int dstW, int chrDstW, const uint8_t *lumDither, const uint8_t *chrDither); | ||
| 76 | typedef void (*yuv2packed1_fn) (struct SwsContext *c, | ||
| 77 | const uint16_t *buf0, | ||
| 78 | const uint16_t *ubuf0, const uint16_t *ubuf1, | ||
| 79 | const uint16_t *vbuf0, const uint16_t *vbuf1, | ||
| 80 | const uint16_t *abuf0, | ||
| 81 | uint8_t *dest, | ||
| 82 | int dstW, int uvalpha, int dstFormat, int flags, int y); | ||
| 83 | typedef void (*yuv2packed2_fn) (struct SwsContext *c, | ||
| 84 | const uint16_t *buf0, const uint16_t *buf1, | ||
| 85 | const uint16_t *ubuf0, const uint16_t *ubuf1, | ||
| 86 | const uint16_t *vbuf0, const uint16_t *vbuf1, | ||
| 87 | const uint16_t *abuf0, const uint16_t *abuf1, | ||
| 88 | uint8_t *dest, | ||
| 89 | int dstW, int yalpha, int uvalpha, int y); | ||
| 90 | typedef void (*yuv2packedX_fn) (struct SwsContext *c, | ||
| 91 | const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, | ||
| 92 | const int16_t *chrFilter, const int16_t **chrUSrc, | ||
| 93 | const int16_t **chrVSrc, int chrFilterSize, | ||
| 94 | const int16_t **alpSrc, uint8_t *dest, | ||
| 95 | int dstW, int dstY); | ||
| 96 | |||
| 62 | /* This struct should be aligned on at least a 32-byte boundary. */ | 97 | /* This struct should be aligned on at least a 32-byte boundary. */ |
| 63 | typedef struct SwsContext { | 98 | typedef struct SwsContext { |
| 64 | /** | 99 | /** |
| @@ -256,46 +291,11 @@ typedef struct SwsContext { · 191 unmodified lines | |||
| 256 | #endif | 291 | #endif |
| 257 | 292 | ||
| 258 | /* function pointers for swScale() */ | 293 | /* function pointers for swScale() */ |
| 259 | void (*yuv2nv12X )(struct SwsContext *c, | 294 | yuv2planar1_fn yuv2yuv1; |
| 260 | const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, | 295 | yuv2planarX_fn yuv2yuvX; |
| 261 | const int16_t *chrFilter, const int16_t **chrUSrc, | 296 | yuv2packed1_fn yuv2packed1; |
| 262 | const int16_t **chrVSrc, int chrFilterSize, | 297 | yuv2packed2_fn yuv2packed2; |
| 263 | uint8_t *dest, uint8_t *uDest, | 298 | yuv2packedX_fn yuv2packedX; |
| 264 | int dstW, int chrDstW, int dstFormat, const uint8_t *lumDither, const uint8_t *chrDither); | ||
| 265 | void (*yuv2yuv1 )(struct SwsContext *c, | ||
| 266 | const int16_t *lumSrc, const int16_t *chrUSrc, | ||
| 267 | const int16_t *chrVSrc, const int16_t *alpSrc, | ||
| 268 | uint8_t *dest, | ||
| 269 | uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, | ||
| 270 | int dstW, int chrDstW, const uint8_t *lumDither, const uint8_t *chrDither); | ||
| 271 | void (*yuv2yuvX )(struct SwsContext *c, | ||
| 272 | const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, | ||
| 273 | const int16_t *chrFilter, const int16_t **chrUSrc, | ||
| 274 | const int16_t **chrVSrc, int chrFilterSize, | ||
| 275 | const int16_t **alpSrc, | ||
| 276 | uint8_t *dest, | ||
| 277 | uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, | ||
| 278 | int dstW, int chrDstW, const uint8_t *lumDither, const uint8_t *chrDither); | ||
| 279 | void (*yuv2packed1)(struct SwsContext *c, | ||
| 280 | const uint16_t *buf0, | ||
| 281 | const uint16_t *ubuf0, const uint16_t *ubuf1, | ||
| 282 | const uint16_t *vbuf0, const uint16_t *vbuf1, | ||
| 283 | const uint16_t *abuf0, | ||
| 284 | uint8_t *dest, | ||
| 285 | int dstW, int uvalpha, int dstFormat, int flags, int y); | ||
| 286 | void (*yuv2packed2)(struct SwsContext *c, | ||
| 287 | const uint16_t *buf0, const uint16_t *buf1, | ||
| 288 | const uint16_t *ubuf0, const uint16_t *ubuf1, | ||
| 289 | const uint16_t *vbuf0, const uint16_t *vbuf1, | ||
| 290 | const uint16_t *abuf0, const uint16_t *abuf1, | ||
| 291 | uint8_t *dest, | ||
| 292 | int dstW, int yalpha, int uvalpha, int y); | ||
| 293 | void (*yuv2packedX)(struct SwsContext *c, | ||
| 294 | const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, | ||
| 295 | const int16_t *chrFilter, const int16_t **chrUSrc, | ||
| 296 | const int16_t **chrVSrc, int chrFilterSize, | ||
| 297 | const int16_t **alpSrc, uint8_t *dest, | ||
| 298 | int dstW, int dstY); | ||
| 299 | 299 | ||
| 300 | void (*lumToYV12)(uint8_t *dst, const uint8_t *src, | 300 | void (*lumToYV12)(uint8_t *dst, const uint8_t *src, |
| 301 | int width, uint32_t *pal); ///< Unscaled conversion of luma plane to YV12 for horizontal scaler. | 301 | int width, uint32_t *pal); ///< Unscaled conversion of luma plane to YV12 for horizontal scaler. |
| @@ -323,10 +323,6 @@ typedef struct SwsContext { · 21 unmodified lines | |||
| 323 | void (*lumConvertRange)(int16_t *dst, int width); ///< Color range conversion function for luma plane if needed. | 323 | void (*lumConvertRange)(int16_t *dst, int width); ///< Color range conversion function for luma plane if needed. |
| 324 | void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width); ///< Color range conversion function for chroma planes if needed. | 324 | void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width); ///< Color range conversion function for chroma planes if needed. |
| 325 | 325 | ||
| 326 | int lumSrcOffset; ///< Offset given to luma src pointers passed to horizontal input functions. | ||
| 327 | int chrSrcOffset; ///< Offset given to chroma src pointers passed to horizontal input functions. | ||
| 328 | int alpSrcOffset; ///< Offset given to alpha src pointers passed to horizontal input functions. | ||
| 329 | |||
| 330 | int needs_hcscale; ///< Set if there are chroma planes to be converted. | 326 | int needs_hcscale; ///< Set if there are chroma planes to be converted. |
| 331 | 327 | ||
| 332 | } SwsContext; | 328 | } SwsContext; |
| @@ -2351,56 +2351,64 @@ static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *d · 2350 unmodified lines | |||
| 2351 | 2351 | ||
| 2352 | static void RENAME(sws_init_swScale)(SwsContext *c) | 2352 | static void RENAME(sws_init_swScale)(SwsContext *c) |
| 2353 | { | 2353 | { |
| 2354 | enum PixelFormat srcFormat = c->srcFormat; | 2354 | enum PixelFormat srcFormat = c->srcFormat, |
| 2355 | 2355 | dstFormat = c->dstFormat; | |
| 2356 | if (!(c->flags & SWS_BITEXACT)) { | 2356 | |
| 2357 | if (c->flags & SWS_ACCURATE_RND) { | 2357 | if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && dstFormat != PIX_FMT_NV12 |
| 2358 | c->yuv2yuv1 = RENAME(yuv2yuv1_ar ); | 2358 | && dstFormat != PIX_FMT_NV21 && !(c->flags & SWS_BITEXACT)) { |
| 2359 | c->yuv2yuvX = RENAME(yuv2yuvX_ar ); | 2359 | if (c->flags & SWS_ACCURATE_RND) { |
| 2360 | switch (c->dstFormat) { | 2360 | c->yuv2yuv1 = RENAME(yuv2yuv1_ar ); |
| 2361 | case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break; | 2361 | c->yuv2yuvX = RENAME(yuv2yuvX_ar ); |
| 2362 | case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break; | 2362 | if (!(c->flags & SWS_FULL_CHR_H_INT)) { |
| 2363 | case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X_ar); break; | 2363 | switch (c->dstFormat) { |
| 2364 | case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X_ar); break; | 2364 | case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break; |
| 2365 | case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break; | 2365 | case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break; |
| 2366 | default: break; | 2366 | case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X_ar); break; |
| 2367 | case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X_ar); break; | ||
| 2368 | case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break; | ||
| 2369 | default: break; | ||
| 2370 | } | ||
| 2371 | } | ||
| 2372 | } else { | ||
| 2373 | int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat); | ||
| 2374 | c->yuv2yuv1 = should_dither ? RENAME(yuv2yuv1_ar ) : RENAME(yuv2yuv1 ); | ||
| 2375 | c->yuv2yuvX = RENAME(yuv2yuvX ); | ||
| 2376 | if (!(c->flags & SWS_FULL_CHR_H_INT)) { | ||
| 2377 | switch (c->dstFormat) { | ||
| 2378 | case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break; | ||
| 2379 | case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break; | ||
| 2380 | case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X); break; | ||
| 2381 | case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X); break; | ||
| 2382 | case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break; | ||
| 2383 | default: break; | ||
| 2384 | } | ||
| 2385 | } | ||
| 2367 | } | 2386 | } |
| 2368 | } else { | 2387 | if (!(c->flags & SWS_FULL_CHR_H_INT)) { |
| 2369 | int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat); | ||
| 2370 | c->yuv2yuv1 = should_dither ? RENAME(yuv2yuv1_ar ) : RENAME(yuv2yuv1 ); | ||
| 2371 | c->yuv2yuvX = RENAME(yuv2yuvX ); | ||
| 2372 | switch (c->dstFormat) { | 2388 | switch (c->dstFormat) { |
| 2373 | case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break; | 2389 | case PIX_FMT_RGB32: |
| 2374 | case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break; | ||
| 2375 | case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X); break; | ||
| 2376 | case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X); break; | ||
| 2377 | case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break; | ||
| 2378 | default: break; | ||
| 2379 | } | ||
| 2380 | } | ||
| 2381 | switch (c->dstFormat) { | ||
| 2382 | case PIX_FMT_RGB32: | ||
| 2383 | c->yuv2packed1 = RENAME(yuv2rgb32_1); | 2390 | c->yuv2packed1 = RENAME(yuv2rgb32_1); |
| 2384 | c->yuv2packed2 = RENAME(yuv2rgb32_2); | 2391 | c->yuv2packed2 = RENAME(yuv2rgb32_2); |
| 2385 | break; | 2392 | break; |
| 2386 | case PIX_FMT_BGR24: | 2393 | case PIX_FMT_BGR24: |
| 2387 | c->yuv2packed1 = RENAME(yuv2bgr24_1); | 2394 | c->yuv2packed1 = RENAME(yuv2bgr24_1); |
| 2388 | c->yuv2packed2 = RENAME(yuv2bgr24_2); | 2395 | c->yuv2packed2 = RENAME(yuv2bgr24_2); |
| 2389 | break; | 2396 | break; |
| 2390 | case PIX_FMT_RGB555: | 2397 | case PIX_FMT_RGB555: |
| 2391 | c->yuv2packed1 = RENAME(yuv2rgb555_1); | 2398 | c->yuv2packed1 = RENAME(yuv2rgb555_1); |
| 2392 | c->yuv2packed2 = RENAME(yuv2rgb555_2); | 2399 | c->yuv2packed2 = RENAME(yuv2rgb555_2); |
| 2393 | break; | 2400 | break; |
| 2394 | case PIX_FMT_RGB565: | 2401 | case PIX_FMT_RGB565: |
| 2395 | c->yuv2packed1 = RENAME(yuv2rgb565_1); | 2402 | c->yuv2packed1 = RENAME(yuv2rgb565_1); |
| 2396 | c->yuv2packed2 = RENAME(yuv2rgb565_2); | 2403 | c->yuv2packed2 = RENAME(yuv2rgb565_2); |
| 2397 | break; | 2404 | break; |
| 2398 | case PIX_FMT_YUYV422: | 2405 | case PIX_FMT_YUYV422: |
| 2399 | c->yuv2packed1 = RENAME(yuv2yuyv422_1); | 2406 | c->yuv2packed1 = RENAME(yuv2yuyv422_1); |
| 2400 | c->yuv2packed2 = RENAME(yuv2yuyv422_2); | 2407 | c->yuv2packed2 = RENAME(yuv2yuyv422_2); |
| 2401 | break; | 2408 | break; |
| 2402 | default: | 2409 | default: |
| 2403 | break; | 2410 | break; |
| 2411 | } | ||
| 2404 | } | 2412 | } |
| 2405 | } | 2413 | } |
| 2406 | 2414 | ||