History

Merge remote-tracking branch 'qatar/master'

* 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

Michael Niedermayer committed 15 years ago

Commit d552f612 parents 7d89f7c ac4a85443 files · +804 −729Browse files

Unified · Split

43 files
  1. configure +1 −1
  2. doc/APIchanges +4 −0
  3. ffplay.c +4 −8
  4. libavcodec/Makefile +2 −1
  5. libavcodec/aac_tablegen.h +1 −1
  6. libavcodec/ac3.h +0 −1
  7. libavcodec/ac3enc.c +6 −251
  8. libavcodec/ac3enc.h +214 −0
  9. libavcodec/bitstream.c +6 −20
  10. libavcodec/dnxhdenc.h +3 −2
  11. libavcodec/dv.c +7 −21
  12. libavcodec/dvbsub_parser.c +4 −12
  13. libavcodec/dvbsubdec.c +16 −32
  14. libavcodec/eac3enc.c +131 −0
  15. libavcodec/eac3enc.h +44 −0
  16. libavcodec/iirfilter.c +0 −2
  17. libavcodec/mlpdsp.c +1 −1
  18. libavcodec/pgssubdec.c +4 −9
  19. libavcodec/ppc/h264_template_altivec.c +1 −2
  20. libavcodec/shorten.c +0 −2
  21. libavcodec/v210enc.c +1 −1
  22. libavcodec/vc1dec.c +16 −3
  23. libavcodec/vorbisdec.c +4 −0
  24. libavcodec/x86/h264_intrapred_init.c +110 −110
  25. libavformat/avidec.c +2 −2
  26. libavformat/mmsh.c +1 −1
  27. libavformat/mov.c +3 −6
  28. libavformat/mpeg.c +3 −5
  29. libavformat/rtspdec.c +0 −7
  30. libavutil/audioconvert.c +2 −2
  31. libavutil/avutil.h +5 −2
  32. libavutil/eval.c +1 −1
  33. libavutil/imgutils.c +1 −1
  34. libavutil/imgutils.h +1 −1
  35. libavutil/inverse.c +1 −1
  36. libavutil/parseutils.c +5 −4
  37. libavutil/parseutils.h +1 −1
  38. libavutil/samplefmt.c +8 −0
  39. libavutil/samplefmt.h +11 −3
  40. libswscale/ppc/swscale_altivec.c +6 −2
  41. libswscale/swscale.c +93 −134
  42. libswscale/swscale_internal.h +40 −44
  43. libswscale/x86/swscale_template.c +40 −32
configure+1−1
@@ -107,7 +107,7 @@ Configuration options: · 106 unmodified lines
107107 --disable-mdct disable MDCT code
108108 --disable-rdft disable RDFT code
109109 --enable-vaapi enable VAAPI code
110− --disable-vdpau disable VDPAU code
110+ --enable-vdpau enable VDPAU code
111111 --disable-dxva2 disable DXVA2 code
112112 --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
113113 --enable-hardcoded-tables use hardcoded tables instead of runtime generation
doc/APIchanges+4−0
@@ -50,6 +50,10 @@ API changes, most recent first: · 49 unmodified lines
5050 2011-05-XX - XXXXXX - lavfi 2.6.0 - avcodec.h
5151 Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h.
5252
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+
5357 2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h
5458 Add av_opt_free convenience function.
5559
ffplay.c+4−8
@@ -54,9 +54,6 @@ · 53 unmodified lines
5454 const char program_name[] = "ffplay";
5555 const int program_birth_year = 2003;
5656
57−//#define DEBUG
58−//#define DEBUG_SYNC
59−
6057 #define MAX_QUEUE_SIZE (15 * 1024 * 1024)
6158 #define MIN_AUDIOQ_SIZE (20 * 16 * 1024)
6259 #define MIN_FRAMES 5
@@ -1052,10 +1049,9 @@ static double compute_target_time(double frame_current_pts, VideoState *is) · 989 unmodified lines
10521049 }
10531050 }
10541051 is->frame_timer += delay;
1055−#if defined(DEBUG_SYNC)
1056− printf("video: delay=%0.3f actual_delay=%0.3f pts=%0.3f A-V=%f\n",
1057− delay, actual_delay, frame_current_pts, -diff);
1058−#endif
1052+
1053+ av_dlog(NULL, "video: delay=%0.3f pts=%0.3f A-V=%f\n",
1054+ delay, frame_current_pts, -diff);
10591055
10601056 return is->frame_timer;
10611057 }
@@ -2033,7 +2029,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) · 971 unmodified lines
20332029 n = 2 * dec->channels;
20342030 is->audio_clock += (double)data_size /
20352031 (double)(n * dec->sample_rate);
2036−#if defined(DEBUG_SYNC)
2032+#ifdef DEBUG
20372033 {
20382034 static double last_clock;
20392035 printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n",
libavcodec/Makefile+2−1
@@ -127,7 +127,8 @@ OBJS-$(CONFIG_DVVIDEO_DECODER) += dv.o dvdata.o · 126 unmodified lines
127127 OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o dvdata.o
128128 OBJS-$(CONFIG_DXA_DECODER) += dxa.o
129129 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
131132 OBJS-$(CONFIG_EACMV_DECODER) += eacmv.o
132133 OBJS-$(CONFIG_EAMAD_DECODER) += eamad.o eaidct.o mpeg12.o \
133134 mpeg12data.o mpegvideo.o \
libavcodec/aac_tablegen.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 #include "libavcodec/aac_tables.h"
3030 #else
3131 #include "libavutil/mathematics.h"
32−#include "libavcodec/aac.h"
32+#include "aac.h"
3333 float ff_aac_pow2sf_tab[428];
3434
3535 void ff_aac_tableinit(void)
libavcodec/ac3.h+0−1
@@ -164,7 +164,6 @@ typedef struct AC3EncOptions { · 163 unmodified lines
164164 int cpl_start;
165165 } AC3EncOptions;
166166
167−
168167 void ff_ac3_common_init(void);
169168
170169 extern const int64_t ff_ac3_channel_layouts[];
libavcodec/ac3enc.c+6−251
@@ -26,7 +26,6 @@ · 25 unmodified lines
2626 * The simplest AC-3 encoder.
2727 */
2828
29−//#define DEBUG
3029 //#define ASSERT_LEVEL 2
3130
3231 #include <stdint.h>
@@ -44,153 +43,8 @@ · 11 unmodified lines
4443 #include "audioconvert.h"
4544 #include "fft.h"
4645
47−
48−#ifndef CONFIG_AC3ENC_FLOAT
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;
46+#include "ac3enc.h"
47+#include "eac3enc.h"
19448
19549 typedef struct AC3Mant {
19650 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
715569 }
716570 }
717571
718− if (s->eac3) {
719− /* set first cpl coords */
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− }
572+ if (CONFIG_EAC3_ENCODER && s->eac3)
573+ ff_eac3_set_cpl_states(s);
746574 #endif /* CONFIG_AC3ENC_FLOAT */
747575 }
748576
@@ -1879,79 +1707,6 @@ static void ac3_output_frame_header(AC3EncodeContext *s) · 1130 unmodified lines
18791707 }
18801708
18811709
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−
19551710 /**
19561711 * Write one audio block to the output bitstream.
19571712 */
@@ -2235,8 +1990,8 @@ static void output_frame(AC3EncodeContext *s, unsigned char *frame) · 277 unmodified lines
22351990
22361991 init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
22371992
2238− if (s->eac3)
2239− eac3_output_frame_header(s);
1993+ if (CONFIG_EAC3_ENCODER && s->eac3)
1994+ ff_eac3_output_frame_header(s);
22401995 else
22411996 ac3_output_frame_header(s);
22421997
libavcodec/ac3enc.h+214−0
@@ -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 */
libavcodec/bitstream.c+6−20
@@ -83,8 +83,6 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) · 82 unmodified lines
8383
8484 /* VLC decoding */
8585
86−//#define DEBUG_VLC
87−
8886 #define GET_DATA(v, table, i, wrap, size) \
8987 {\
9088 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
164162
165163 table_size = 1 << table_nb_bits;
166164 table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC);
167−#ifdef DEBUG_VLC
168− av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n",
169− table_index, table_size);
170−#endif
165+ av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
171166 if (table_index < 0)
172167 return -1;
173168 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
182177 n = codes[i].bits;
183178 code = codes[i].code;
184179 symbol = codes[i].symbol;
185−#if defined(DEBUG_VLC) && 0
186− av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code);
187−#endif
180+ av_dlog(NULL, "i=%d n=%d code=0x%x\n", i, n, code);
188181 if (n <= table_nb_bits) {
189182 /* no need to add another table */
190183 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
195188 inc = 1 << n;
196189 }
197190 for (k = 0; k < nb; k++) {
198−#ifdef DEBUG_VLC
199− av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
200− j, i, n);
201−#endif
191+ av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n);
202192 if (table[j][1] /*bits*/ != 0) {
203193 av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
204194 return -1;
@@ -228,10 +218,8 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, · 23 unmodified lines
228218 subtable_bits = FFMIN(subtable_bits, table_nb_bits);
229219 j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix;
230220 table[j][1] = -subtable_bits;
231−#ifdef DEBUG_VLC
232− av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n",
233− j, codes[i].bits + table_nb_bits);
234−#endif
221+ av_dlog(NULL, "%4x: n=%d (subtable)\n",
222+ j, codes[i].bits + table_nb_bits);
235223 index = build_table(vlc, subtable_bits, k-i, codes+i, flags);
236224 if (index < 0)
237225 return -1;
@@ -293,9 +281,7 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, · 55 unmodified lines
293281 vlc->table_size = 0;
294282 }
295283
296−#ifdef DEBUG_VLC
297− av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes);
298−#endif
284+ av_dlog(NULL, "build table nb_codes=%d\n", nb_codes);
299285
300286 buf = av_malloc((nb_codes+1)*sizeof(VLCcode));
301287
libavcodec/dnxhdenc.h+3−2
@@ -25,8 +25,9 @@ · 24 unmodified lines
2525 #define AVCODEC_DNXHDENC_H
2626
2727 #include <stdint.h>
28−#include "libavcodec/mpegvideo.h"
29−#include "libavcodec/dnxhddata.h"
28+
29+#include "mpegvideo.h"
30+#include "dnxhddata.h"
3031
3132 typedef struct {
3233 uint16_t mb;
libavcodec/dv.c+7−21
@@ -358,9 +358,6 @@ static av_cold int dvvideo_init_encoder(AVCodecContext *avctx) · 357 unmodified lines
358358 return dvvideo_init(avctx);
359359 }
360360
361−// #define VLC_DEBUG
362−// #define printf(...) av_log(NULL, AV_LOG_ERROR, __VA_ARGS__)
363−
364361 typedef struct BlockInfo {
365362 const uint32_t *factor_table;
366363 const uint8_t *scan_table;
@@ -404,9 +401,8 @@ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) · 37 unmodified lines
404401
405402 /* get the AC coefficients until last_index is reached */
406403 for (;;) {
407−#ifdef VLC_DEBUG
408− printf("%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, gb, 16), re_index);
409−#endif
404+ av_dlog(NULL, "%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, gb, 16),
405+ re_index);
410406 /* our own optimized GET_RL_VLC */
411407 index = NEG_USR32(re_cache, TEX_VLC_BITS);
412408 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
427423 }
428424 re_index += vlc_len;
429425
430−#ifdef VLC_DEBUG
431− printf("run=%d level=%d\n", run, level);
432−#endif
426+ av_dlog(NULL, "run=%d level=%d\n", run, level);
433427 pos += run;
434428 if (pos >= 64)
435429 break;
@@ -533,9 +527,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) · 97 unmodified lines
533527 mb->pos = 0;
534528 mb->partial_bit_count = 0;
535529
536−#ifdef VLC_DEBUG
537− printf("MB block: %d, %d ", mb_index, j);
538−#endif
530+ av_dlog(avctx, "MB block: %d, %d ", mb_index, j);
539531 dv_decode_ac(&gb, mb, block);
540532
541533 /* 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
548540 }
549541
550542 /* pass 2 : we can do it just after */
551−#ifdef VLC_DEBUG
552− printf("***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index);
553−#endif
543+ av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index);
554544 block = block1;
555545 mb = mb1;
556546 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
570560 }
571561
572562 /* we need a pass other the whole video segment */
573−#ifdef VLC_DEBUG
574− printf("***pass 3 size=%d\n", put_bits_count(&vs_pb));
575−#endif
563+ av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb));
576564 block = &sblock[0][0];
577565 mb = mb_data;
578566 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
580568 for (mb_index = 0; mb_index < 5; mb_index++) {
581569 for (j = 0; j < s->sys->bpm; j++) {
582570 if (mb->pos < 64) {
583−#ifdef VLC_DEBUG
584− printf("start %d:%d\n", mb_index, j);
585−#endif
571+ av_dlog(avctx, "start %d:%d\n", mb_index, j);
586572 dv_decode_ac(&gb, mb, block);
587573 }
588574 if (mb->pos >= 64 && mb->pos < 127)
libavcodec/dvbsub_parser.c+4−12
@@ -22,9 +22,6 @@ · 21 unmodified lines
2222 #include "dsputil.h"
2323 #include "get_bits.h"
2424
25−//#define DEBUG
26−//#define DEBUG_PACKET_CONTENTS
27−
2825 /* Parser (mostly) copied from dvdsub.c */
2926
3027 #define PARSE_BUF_SIZE (65536)
@@ -53,25 +50,20 @@ static int dvbsub_parse(AVCodecParserContext *s, · 22 unmodified lines
5350 {
5451 DVBSubParseContext *pc = s->priv_data;
5552 uint8_t *p, *p_end;
56− int len, buf_pos = 0;
53+ int i, len, buf_pos = 0;
5754
5855 av_dlog(avctx, "DVB parse packet pts=%"PRIx64", lpts=%"PRIx64", cpts=%"PRIx64":\n",
5956 s->pts, s->last_pts, s->cur_frame_pts[s->cur_frame_start_index]);
6057
61−#ifdef DEBUG_PACKET_CONTENTS
62− int i;
63−
6458 for (i=0; i < buf_size; i++)
6559 {
66− av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);
60+ av_dlog(avctx, "%02x ", buf[i]);
6761 if (i % 16 == 15)
68− av_log(avctx, AV_LOG_INFO, "\n");
62+ av_dlog(avctx, "\n");
6963 }
7064
7165 if (i % 16 != 0)
72− av_log(avctx, AV_LOG_INFO, "\n");
73−
74−#endif
66+ av_dlog(avctx, "\n");
7567
7668 *poutbuf = NULL;
7769 *poutbuf_size = 0;
libavcodec/dvbsubdec.c+16−32
@@ -24,10 +24,6 @@ · 23 unmodified lines
2424 #include "bytestream.h"
2525 #include "libavutil/colorspace.h"
2626
27−//#define DEBUG
28−//#define DEBUG_PACKET_CONTENTS
29−//#define DEBUG_SAVE_IMAGES
30−
3127 #define DVBSUB_PAGE_SEGMENT 0x10
3228 #define DVBSUB_REGION_SEGMENT 0x11
3329 #define DVBSUB_CLUT_SEGMENT 0x12
@@ -37,7 +33,7 @@ · 3 unmodified lines
3733
3834 #define cm (ff_cropTbl + MAX_NEG_CROP)
3935
40−#ifdef DEBUG_SAVE_IMAGES
36+#ifdef DEBUG
4137 #undef fprintf
4238 #if 0
4339 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
768764 av_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size,
769765 top_bottom ? "bottom" : "top");
770766
771−#ifdef DEBUG_PACKET_CONTENTS
772767 for (i = 0; i < buf_size; i++) {
773768 if (i % 16 == 0)
774− av_log(avctx, AV_LOG_INFO, "0x%08p: ", buf+i);
769+ av_dlog(avctx, "0x%8p: ", buf+i);
775770
776− av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);
771+ av_dlog(avctx, "%02x ", buf[i]);
777772 if (i % 16 == 15)
778− av_log(avctx, AV_LOG_INFO, "\n");
773+ av_dlog(avctx, "\n");
779774 }
780775
781776 if (i % 16)
782− av_log(avctx, AV_LOG_INFO, "\n");
783−
784−#endif
777+ av_dlog(avctx, "\n");
785778
786779 if (region == 0)
787780 return;
@@ -930,27 +923,22 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx, · 142 unmodified lines
930923 DVBSubContext *ctx = avctx->priv_data;
931924
932925 const uint8_t *buf_end = buf + buf_size;
933− int clut_id;
926+ int i, clut_id;
934927 DVBSubCLUT *clut;
935928 int entry_id, depth , full_range;
936929 int y, cr, cb, alpha;
937930 int r, g, b, r_add, g_add, b_add;
938931
939−#ifdef DEBUG_PACKET_CONTENTS
940− int i;
941−
942− av_log(avctx, AV_LOG_INFO, "DVB clut packet:\n");
932+ av_dlog(avctx, "DVB clut packet:\n");
943933
944934 for (i=0; i < buf_size; i++) {
945− av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);
935+ av_dlog(avctx, "%02x ", buf[i]);
946936 if (i % 16 == 15)
947− av_log(avctx, AV_LOG_INFO, "\n");
937+ av_dlog(avctx, "\n");
948938 }
949939
950940 if (i % 16)
951− av_log(avctx, AV_LOG_INFO, "\n");
952−
953−#endif
941+ av_dlog(avctx, "\n");
954942
955943 clut_id = *buf++;
956944 buf += 1;
@@ -1194,7 +1182,7 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx, · 237 unmodified lines
11941182 }
11951183
11961184
1197−#ifdef DEBUG_SAVE_IMAGES
1185+#ifdef DEBUG
11981186 static void save_display_set(DVBSubContext *ctx)
11991187 {
12001188 DVBSubRegion *region;
@@ -1404,7 +1392,7 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, · 203 unmodified lines
14041392
14051393 sub->num_rects = i;
14061394
1407−#ifdef DEBUG_SAVE_IMAGES
1395+#ifdef DEBUG
14081396 save_display_set(ctx);
14091397 #endif
14101398
@@ -1423,22 +1411,18 @@ static int dvbsub_decode(AVCodecContext *avctx, · 12 unmodified lines
14231411 int segment_type;
14241412 int page_id;
14251413 int segment_length;
1426−
1427−#ifdef DEBUG_PACKET_CONTENTS
14281414 int i;
14291415
1430− av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n");
1416+ av_dlog(avctx, "DVB sub packet:\n");
14311417
14321418 for (i=0; i < buf_size; i++) {
1433− av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);
1419+ av_dlog(avctx, "%02x ", buf[i]);
14341420 if (i % 16 == 15)
1435− av_log(avctx, AV_LOG_INFO, "\n");
1421+ av_dlog(avctx, "\n");
14361422 }
14371423
14381424 if (i % 16)
1439− av_log(avctx, AV_LOG_INFO, "\n");
1440−
1441−#endif
1425+ av_dlog(avctx, "\n");
14421426
14431427 if (buf_size <= 6 || *buf != 0x0f) {
14441428 av_dlog(avctx, "incomplete or broken packet");
libavcodec/eac3enc.c+131−0
@@ -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+}
libavcodec/eac3enc.h+44−0
@@ -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 */
libavcodec/iirfilter.c+0−2
@@ -151,8 +151,6 @@ static int biquad_init_coeffs(void *avc, struct FFIIRFilterCoeffs *c, · 150 unmodified lines
151151 // during filtering, the delay state will include the gain multiplication
152152 c->cx[0] = lrintf(x0 / c->gain);
153153 c->cx[1] = lrintf(x1 / c->gain);
154− c->cy[0] /= c->gain;
155− c->cy[1] /= c->gain;
156154
157155 return 0;
158156 }
libavcodec/mlpdsp.c+1−1
@@ -19,8 +19,8 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121
22−#include "libavcodec/mlp.h"
2322 #include "dsputil.h"
23+#include "mlp.h"
2424
2525 static void ff_mlp_filter_channel(int32_t *state, const int32_t *coeff,
2626 int firorder, int iirorder,
libavcodec/pgssubdec.c+4−9
@@ -30,8 +30,6 @@ · 29 unmodified lines
3030 #include "libavutil/colorspace.h"
3131 #include "libavutil/imgutils.h"
3232
33−//#define DEBUG_PACKET_CONTENTS
34−
3533 #define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
3634
3735 enum SegmentType {
@@ -403,21 +401,18 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, · 365 unmodified lines
403401 const uint8_t *buf_end;
404402 uint8_t segment_type;
405403 int segment_length;
406−
407−#ifdef DEBUG_PACKET_CONTENTS
408404 int i;
409405
410− av_log(avctx, AV_LOG_INFO, "PGS sub packet:\n");
406+ av_dlog(avctx, "PGS sub packet:\n");
411407
412408 for (i = 0; i < buf_size; i++) {
413− av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);
409+ av_dlog(avctx, "%02x ", buf[i]);
414410 if (i % 16 == 15)
415− av_log(avctx, AV_LOG_INFO, "\n");
411+ av_dlog(avctx, "\n");
416412 }
417413
418414 if (i & 15)
419− av_log(avctx, AV_LOG_INFO, "\n");
420−#endif
415+ av_dlog(avctx, "\n");
421416
422417 *data_size = 0;
423418
libavcodec/ppc/h264_template_altivec.c+1−2
@@ -18,8 +18,7 @@ · 17 unmodified lines
1818 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919 */
2020
21−//#define DEBUG_ALIGNMENT
22−#ifdef DEBUG_ALIGNMENT
21+#ifdef DEBUG
2322 #define ASSERT_ALIGNED(ptr) assert(((unsigned long)ptr&0x0000000F));
2423 #else
2524 #define ASSERT_ALIGNED(ptr) ;
libavcodec/shorten.c+0−2
@@ -26,7 +26,6 @@ · 25 unmodified lines
2626 *
2727 */
2828
29−#define DEBUG
3029 #include <limits.h>
3130 #include "avcodec.h"
3231 #include "get_bits.h"
@@ -304,7 +303,6 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 271 unmodified lines
304303 s->bitstream_size= buf_size;
305304
306305 if(buf_size < s->max_framesize){
307− //av_dlog(avctx, "wanna more data ... %d\n", buf_size);
308306 *data_size = 0;
309307 return input_buf_size;
310308 }
libavcodec/v210enc.c+1−1
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 */
2323
2424 #include "avcodec.h"
25−#include "libavcodec/bytestream.h"
25+#include "bytestream.h"
2626
2727 static av_cold int encode_init(AVCodecContext *avctx)
2828 {
libavcodec/vc1dec.c+16−3
@@ -3398,7 +3398,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 3397 unmodified lines
33983398 VC1Context *v = avctx->priv_data;
33993399 MpegEncContext *s = &v->s;
34003400 GetBitContext gb;
3401− int i;
3401+ int i, cur_width, cur_height;
34023402
34033403 if (!avctx->extradata_size || !avctx->extradata) return -1;
34043404 if (!(avctx->flags & CODEC_FLAG_GRAY))
@@ -3419,8 +3419,8 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 14 unmodified lines
34193419 if (vc1_init_common(v) < 0) return -1;
34203420 ff_vc1dsp_init(&v->vc1dsp);
34213421
3422− avctx->coded_width = avctx->width;
3423− avctx->coded_height = avctx->height;
3422+ cur_width = avctx->coded_width = avctx->width;
3423+ cur_height = avctx->coded_height = avctx->height;
34243424 if (avctx->codec_id == CODEC_ID_WMV3)
34253425 {
34263426 int count = 0;
@@ -3491,6 +3491,19 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 64 unmodified lines
34913491 }
34923492 v->res_sprite = (avctx->codec_tag == MKTAG('W','V','P','2'));
34933493 }
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+
34943507 avctx->profile = v->profile;
34953508 if (v->profile == PROFILE_ADVANCED)
34963509 avctx->level = v->level;
libavcodec/vorbisdec.c+4−0
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2121 */
2222
23+#include <inttypes.h>
2324 #include <math.h>
2425
2526 #define ALT_BITSTREAM_READER_LE
@@ -1089,6 +1090,9 @@ static int vorbis_floor0_decode(vorbis_context *vc, · 1063 unmodified lines
10891090 for (i = 0; i < order; i++)
10901091 lsp[i] = 2.0f * cos(lsp[i]);
10911092
1093+ av_dlog(NULL, "floor0 synth: map_size = %"PRIu32"; m = %d; wstep = %f\n",
1094+ vf->map_size[blockflag], order, wstep);
1095+
10921096 i = 0;
10931097 while (i < vf->map_size[blockflag]) {
10941098 int j, iter_cond = vf->map[blockflag][i];
libavcodec/x86/h264_intrapred_init.c+110−110
@@ -124,132 +124,132 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 123 unmodified lines
124124 {
125125 int mm_flags = av_get_cpu_flags();
126126
127− if (bit_depth == 8) {
128127 #if HAVE_YASM
129− if (mm_flags & AV_CPU_FLAG_MMX) {
130− h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx;
131− h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx;
132− h->pred8x8 [VERT_PRED8x8] = ff_pred8x8_vertical_mmx;
133− h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx;
134− if (codec_id == CODEC_ID_VP8) {
135− h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx;
136− h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx;
137− h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx;
138− } else {
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;
128+ if (bit_depth == 8) {
129+ if (mm_flags & AV_CPU_FLAG_MMX) {
130+ h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx;
131+ h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx;
132+ h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_mmx;
133+ h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx;
134+ if (codec_id == CODEC_ID_VP8) {
135+ h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmx;
136+ h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmx;
137+ h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx;
144138 } 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+ }
146147 }
147148 }
148− }
149149
150− if (mm_flags & AV_CPU_FLAG_MMX2) {
151− h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
152− h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext;
153− h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext;
154− h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext;
155− h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext;
156− h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext;
157− h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext;
158− h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_mmxext;
159− h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext;
160− h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext;
161− h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext;
162− h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext;
163− h->pred4x4 [DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_mmxext;
164− h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext;
165− h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext;
166− h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext;
167− if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264)
168− h->pred4x4 [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext;
169− if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264)
170− h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext;
171− if (codec_id != CODEC_ID_RV40) {
172− h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext;
173− }
174− if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) {
175− h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext;
176− h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext;
177− }
178− if (codec_id == CODEC_ID_VP8) {
179− h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext;
180− h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext;
181− h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext;
182− h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext;
183− h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext;
184− } else {
185− h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2;
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;
150+ if (mm_flags & AV_CPU_FLAG_MMX2) {
151+ h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
152+ h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext;
153+ h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext;
154+ h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext;
155+ h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext;
156+ h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext;
157+ h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext;
158+ h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_mmxext;
159+ h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext;
160+ h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext;
161+ h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext;
162+ h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext;
163+ h->pred4x4 [DIAG_DOWN_RIGHT_PRED ] = ff_pred4x4_down_right_mmxext;
164+ h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext;
165+ h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext;
166+ h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext;
167+ if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264) {
168+ h->pred4x4 [DIAG_DOWN_LEFT_PRED] = ff_pred4x4_down_left_mmxext;
169+ }
170+ if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) {
171+ h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext;
172+ }
173+ if (codec_id != CODEC_ID_RV40) {
174+ h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext;
175+ }
176+ if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) {
177+ h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext;
178+ h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext;
179+ }
180+ if (codec_id == CODEC_ID_VP8) {
181+ h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmxext;
182+ h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext;
183+ h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmxext;
184+ h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext;
185+ h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext;
190186 } 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+ }
192195 }
193196 }
194− }
195197
196− if (mm_flags & AV_CPU_FLAG_SSE) {
197− h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse;
198− }
198+ if (mm_flags & AV_CPU_FLAG_SSE) {
199+ h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse;
200+ }
199201
200− if (mm_flags & AV_CPU_FLAG_SSE2) {
201− h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2;
202− h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2;
203− h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2;
204− h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2;
205− h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2;
206− h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2;
207− if (codec_id == CODEC_ID_VP8) {
208− h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2;
209− 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;
202+ if (mm_flags & AV_CPU_FLAG_SSE2) {
203+ h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2;
204+ h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2;
205+ h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_sse2;
206+ h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2;
207+ h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2;
208+ h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2;
209+ if (codec_id == CODEC_ID_VP8) {
210+ h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_sse2;
211+ h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_sse2;
216212 } 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+ }
218221 }
219222 }
220− }
221223
222− if (mm_flags & AV_CPU_FLAG_SSSE3) {
223− h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
224− h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3;
225− h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3;
226− h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3;
227− h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3;
228− h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3;
229− h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3;
230− h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3;
231− h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_ssse3;
232− h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3;
233− h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3;
234− h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3;
235− h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3;
236− if (codec_id == CODEC_ID_VP8) {
237− h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3;
238− 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;
224+ if (mm_flags & AV_CPU_FLAG_SSSE3) {
225+ h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
226+ h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3;
227+ h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3;
228+ h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3;
229+ h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3;
230+ h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3;
231+ h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3;
232+ h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3;
233+ h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_ssse3;
234+ h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3;
235+ h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3;
236+ h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3;
237+ h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3;
238+ if (codec_id == CODEC_ID_VP8) {
239+ h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_ssse3;
240+ h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3;
245241 } 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+ }
247250 }
248251 }
249− }
250−#endif
251252 } else if (bit_depth == 10) {
252−#if HAVE_YASM
253253 if (mm_flags & AV_CPU_FLAG_MMX2) {
254254 h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext;
255255 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
270270 h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3;
271271 }
272272 #if HAVE_AVX
273− if (mm_flags&AV_CPU_FLAG_AVX) {
273+ if (mm_flags & AV_CPU_FLAG_AVX) {
274274 h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx;
275275 h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx;
276276 h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_avx;
277277 h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_avx;
278278 }
279279 #endif /* HAVE_AVX */
280−#endif /* HAVE_YASM */
281280 }
281+#endif /* HAVE_YASM */
282282 }
libavformat/avidec.c+2−2
@@ -1254,7 +1254,7 @@ static int avi_load_index(AVFormatContext *s) · 1253 unmodified lines
12541254 if (avio_seek(pb, avi->movi_end, SEEK_SET) < 0)
12551255 goto the_end; // maybe truncated file
12561256 #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);
12581258 #endif
12591259 for(;;) {
12601260 if (url_feof(pb))
@@ -1262,7 +1262,7 @@ static int avi_load_index(AVFormatContext *s) · 1 unmodified line
12621262 tag = avio_rl32(pb);
12631263 size = avio_rl32(pb);
12641264 #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",
12661266 tag & 0xff,
12671267 (tag >> 8) & 0xff,
12681268 (tag >> 16) & 0xff,
libavformat/mmsh.c+1−1
@@ -28,7 +28,7 @@ · 27 unmodified lines
2828 #include <string.h>
2929 #include "libavutil/intreadwrite.h"
3030 #include "libavutil/avstring.h"
31−#include "libavformat/internal.h"
31+#include "internal.h"
3232 #include "mms.h"
3333 #include "asf.h"
3434 #include "http.h"
libavformat/mov.c+3−6
@@ -23,7 +23,6 @@ · 22 unmodified lines
2323 #include <limits.h>
2424
2525 //#define DEBUG
26−//#define DEBUG_METADATA
2726 //#define MOV_EXPORT_ALL_METADATA
2827
2928 #include "libavutil/intreadwrite.h"
@@ -215,11 +214,9 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 185 unmodified lines
215214 av_metadata_set2(&c->fc->metadata, key2, str, 0);
216215 }
217216 }
218−#ifdef DEBUG_METADATA
219− av_log(c->fc, AV_LOG_DEBUG, "lang \"%3s\" ", language);
220− av_log(c->fc, AV_LOG_DEBUG, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %lld\n",
221− key, str, (char*)&atom.type, str_size, atom.size);
222−#endif
217+ av_dlog(c->fc, "lang \"%3s\" ", language);
218+ av_dlog(c->fc, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %"PRId64"\n",
219+ key, str, (char*)&atom.type, str_size, atom.size);
223220
224221 return 0;
225222 }
libavformat/mpeg.c+3−5
@@ -586,9 +586,6 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, · 585 unmodified lines
586586 int64_t pos, pts, dts;
587587
588588 pos = *ppos;
589−#ifdef DEBUG_SEEK
590− printf("read_dts: pos=0x%"PRIx64" next=%d -> ", pos, find_next);
591−#endif
592589 if (avio_seek(s->pb, pos, SEEK_SET) < 0)
593590 return AV_NOPTS_VALUE;
594591
@@ -596,7 +593,7 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, · 1 unmodified line
596593 len = mpegps_read_pes_header(s, &pos, &startcode, &pts, &dts);
597594 if (len < 0) {
598595 #ifdef DEBUG_SEEK
599− printf("none (ret=%d)\n", len);
596+ av_log(s, AV_LOG_DEBUG, "none (ret=%d)\n", len);
600597 #endif
601598 return AV_NOPTS_VALUE;
602599 }
@@ -607,7 +604,8 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, · 4 unmodified lines
607604 avio_skip(s->pb, len);
608605 }
609606 #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);
611609 #endif
612610 *ppos = pos;
613611 return dts;
libavformat/rtspdec.c+0−7
@@ -31,9 +31,6 @@ · 30 unmodified lines
3131 #include "rdt.h"
3232 #include "url.h"
3333
34−//#define DEBUG
35−//#define DEBUG_RTP_TCP
36−
3734 static int rtsp_read_play(AVFormatContext *s)
3835 {
3936 RTSPState *rt = s->priv_data;
@@ -191,9 +188,7 @@ int ff_rtsp_tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, · 151 unmodified lines
191188 int id, len, i, ret;
192189 RTSPStream *rtsp_st;
193190
194−#ifdef DEBUG_RTP_TCP
195191 av_dlog(s, "tcp_read_packet:\n");
196−#endif
197192 redo:
198193 for (;;) {
199194 RTSPMessageHeader reply;
@@ -212,9 +207,7 @@ redo: · 12 unmodified lines
212207 return -1;
213208 id = buf[0];
214209 len = AV_RB16(buf + 1);
215−#ifdef DEBUG_RTP_TCP
216210 av_dlog(s, "id=%d len=%d\n", id, len);
217−#endif
218211 if (len > buf_size || len < 12)
219212 goto redo;
220213 /* get the data */
libavutil/audioconvert.c+2−2
@@ -23,8 +23,8 @@ · 22 unmodified lines
2323 * audio conversion routines
2424 */
2525
26−#include "libavutil/avutil.h"
27−#include "libavutil/avstring.h"
26+#include "avstring.h"
27+#include "avutil.h"
2828 #include "audioconvert.h"
2929
3030 static const char * const channel_names[] = {
libavutil/avutil.h+5−2
@@ -40,8 +40,8 @@ · 39 unmodified lines
4040 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
4141
4242 #define LIBAVUTIL_VERSION_MAJOR 51
43−#define LIBAVUTIL_VERSION_MINOR 6
44−#define LIBAVUTIL_VERSION_MICRO 1
43+#define LIBAVUTIL_VERSION_MINOR 7
44+#define LIBAVUTIL_VERSION_MICRO 0
4545
4646 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
4747 LIBAVUTIL_VERSION_MINOR, \
@@ -60,6 +60,9 @@ · 12 unmodified lines
6060 #ifndef FF_API_OLD_EVAL_NAMES
6161 #define FF_API_OLD_EVAL_NAMES (LIBAVUTIL_VERSION_MAJOR < 52)
6262 #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
6366
6467 /**
6568 * Return the LIBAVUTIL_VERSION_INT constant.
libavutil/eval.c+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
2626 * see http://joe.hotchkiss.com/programming/eval/eval.html
2727 */
2828
29−#include "libavutil/avutil.h"
29+#include "avutil.h"
3030 #include "eval.h"
3131
3232 typedef struct Parser {
libavutil/imgutils.c+1−1
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323
2424 #include "imgutils.h"
2525 #include "internal.h"
26−#include "libavutil/pixdesc.h"
26+#include "pixdesc.h"
2727
2828 void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
2929 const AVPixFmtDescriptor *pixdesc)
libavutil/imgutils.h+1−1
@@ -24,8 +24,8 @@ · 23 unmodified lines
2424 * misc image utilities
2525 */
2626
27−#include "libavutil/pixdesc.h"
2827 #include "avutil.h"
28+#include "pixdesc.h"
2929
3030 /**
3131 * Compute the max pixel step for each plane of an image with a
libavutil/inverse.c+1−1
@@ -19,7 +19,7 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121
22−#include "libavutil/intmath.h"
22+#include <stdint.h>
2323
2424 /* a*inverse[b]>>32 == a/b for all 0<=a<=16909558 && 2<=b<=256
2525 * for a>16909558, is an overestimate by less than 1 part in 1<<24 */
libavutil/parseutils.c+5−4
@@ -24,11 +24,12 @@ · 23 unmodified lines
2424 #include <strings.h>
2525 #include <sys/time.h>
2626 #include <time.h>
27+
28+#include "avstring.h"
29+#include "avutil.h"
30+#include "eval.h"
31+#include "random_seed.h"
2732 #include "parseutils.h"
28−#include "libavutil/avutil.h"
29−#include "libavutil/eval.h"
30−#include "libavutil/avstring.h"
31−#include "libavutil/random_seed.h"
3233
3334 typedef struct {
3435 const char *abbr;
libavutil/parseutils.h+1−1
@@ -19,7 +19,7 @@ · 18 unmodified lines
1919 #ifndef AVUTIL_PARSEUTILS_H
2020 #define AVUTIL_PARSEUTILS_H
2121
22−#include "libavutil/rational.h"
22+#include "rational.h"
2323
2424 /**
2525 * @file
libavutil/samplefmt.c+8−0
@@ -66,11 +66,19 @@ char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sam · 65 unmodified lines
6666 return buf;
6767 }
6868
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
6976 int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt)
7077 {
7178 return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ?
7279 0 : sample_fmt_info[sample_fmt].bits;
7380 }
81+#endif
7482
7583 int av_samples_fill_arrays(uint8_t *pointers[8], int linesizes[8],
7684 uint8_t *buf, int nb_channels, int nb_samples,
libavutil/samplefmt.h+11−3
@@ -60,14 +60,22 @@ enum AVSampleFormat av_get_sample_fmt(const char *name); · 59 unmodified lines
6060 */
6161 char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
6262
63+#if FF_API_GET_BITS_PER_SAMPLE_FMT
6364 /**
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.
6573 *
6674 * @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
6876 * sample format
6977 */
70−int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
78+int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt);
7179
7280 /**
7381 * Fill channel data pointers and linesizes for samples with sample
libswscale/ppc/swscale_altivec.c+6−2
@@ -403,15 +403,19 @@ static void hScale_altivec_real(int16_t *dst, int dstW, · 402 unmodified lines
403403
404404 void ff_sws_init_swScale_altivec(SwsContext *c)
405405 {
406+ enum PixelFormat dstFormat = c->dstFormat;
407+
406408 if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
407409 return;
408410
409411 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+ }
411415
412416 /* The following list of supported dstFormat values should
413417 * 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 &&
415419 (c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA ||
416420 c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 ||
417421 c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)) {
libswscale/swscale.c+93−134
@@ -353,17 +353,20 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, · 352 unmodified lines
353353 output_pixel(&aDest[i], val);
354354 }
355355 }
356+#undef output_pixel
356357 }
357358
358359 #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, \
360361 const int16_t **lumSrc, int lumFilterSize, \
361362 const int16_t *chrFilter, const int16_t **chrUSrc, \
362363 const int16_t **chrVSrc, \
363364 int chrFilterSize, const int16_t **alpSrc, \
364− uint16_t *dest, uint16_t *uDest, uint16_t *vDest, \
365− uint16_t *aDest, int dstW, int chrDstW) \
365+ uint8_t *_dest, uint8_t *_uDest, uint8_t *_vDest, \
366+ uint8_t *_aDest, int dstW, int chrDstW) \
366367 { \
368+ uint16_t *dest = (uint16_t *) _dest, *uDest = (uint16_t *) _uDest, \
369+ *vDest = (uint16_t *) _vDest, *aDest = (uint16_t *) _aDest; \
367370 yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \
368371 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
369372 alpSrc, \
@@ -377,7 +380,7 @@ yuv2NBPS(10, LE, 0); · 7 unmodified lines
377380 yuv2NBPS(16, BE, 1);
378381 yuv2NBPS(16, LE, 0);
379382
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,
381384 const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize,
382385 const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW,
383386 enum PixelFormat dstFormat)
@@ -452,9 +455,13 @@ static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, const int16_t ** · 68 unmodified lines
452455 static inline void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
453456 const int16_t *chrFilter, const int16_t **chrUSrc,
454457 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,
456461 const uint8_t *lumDither, const uint8_t *chrDither)
457462 {
463+ enum PixelFormat dstFormat = c->dstFormat;
464+
458465 //FIXME Optimize (just quickly written not optimized..)
459466 int i;
460467 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
11481155 }
11491156 }
11501157
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+
11511166 #define BGR2UV(type, name, shr, shg, shb, shp, maskr, maskg, maskb, RU, GU, BU, RV, GV, BV, S) \
11521167 static void name ## _c(int16_t *dstU, int16_t *dstV, const uint8_t *src, const uint8_t *dummy, int width, uint32_t *unused)\
11531168 {\
@@ -1616,8 +1631,6 @@ static inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, · 462 unmodified lines
16161631 void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
16171632 void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
16181633
1619− src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset;
1620−
16211634 if (toYV12) {
16221635 toYV12(formatConvBuffer, src, srcW, pal);
16231636 src= formatConvBuffer;
@@ -1661,10 +1674,6 @@ static inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *dst2, int ds · 37 unmodified lines
16611674 const int16_t *hChrFilterPos, int hChrFilterSize,
16621675 uint8_t *formatConvBuffer, uint32_t *pal)
16631676 {
1664−
1665− src1 += c->chrSrcOffset;
1666− src2 += c->chrSrcOffset;
1667−
16681677 if (c->chrToYV12) {
16691678 uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16);
16701679 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
16871696 c->chrConvertRange(dst1, dst2, dstWidth);
16881697 }
16891698
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+
16901730 #define DEBUG_SWSCALE_BUFFERS 0
16911731 #define DEBUG_BUFFERS(...) if (DEBUG_SWSCALE_BUFFERS) av_log(c, AV_LOG_DEBUG, __VA_ARGS__)
16921732
@@ -1731,6 +1771,11 @@ static int swScale(SwsContext *c, const uint8_t* src[], · 38 unmodified lines
17311771 int lastDstY;
17321772 uint32_t *pal=c->pal_yuv;
17331773 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;
17341779
17351780 /* vars which will change and which we need to store back in the context */
17361781 int dstY= c->dstY;
@@ -1869,37 +1914,31 @@ static int swScale(SwsContext *c, const uint8_t* src[], · 132 unmodified lines
18691914 #if HAVE_MMX
18701915 updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf);
18711916 #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+ {
18731925 const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
18741926 const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
18751927 const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
18761928 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) {
1878− const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
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
1929+
1930+ if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like
18851931 const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
18861932 if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
1887− if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
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
1933+ if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12
18951934 const int16_t *lumBuf = lumSrcPtr[0];
18961935 const int16_t *chrUBuf= chrUSrcPtr[0];
18971936 const int16_t *chrVBuf= chrVSrcPtr[0];
18981937 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,
19001939 uDest, vDest, aDest, dstW, chrDstW, lumDither, chrDither);
19011940 } else { //General YV12
1902− c->yuv2yuvX(c,
1941+ yuv2yuvX(c,
19031942 vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
19041943 vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr,
19051944 chrVSrcPtr, vChrFilterSize,
@@ -1908,94 +1947,28 @@ static int swScale(SwsContext *c, const uint8_t* src[], · 2 unmodified lines
19081947 } else {
19091948 assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
19101949 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
19121951 int chrAlpha= vChrFilter[2*dstY+1];
1913− if(flags & SWS_FULL_CHR_H_INT) {
1914− yuv2rgbX_c_full(c, //FIXME write a packed1_full function
1915− vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
1916− vChrFilter+dstY*vChrFilterSize, chrUSrcPtr,
1917− chrVSrcPtr, vChrFilterSize,
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
1952+ yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1),
1953+ *chrVSrcPtr, *(chrVSrcPtr+1),
1954+ alpPixBuf ? *alpSrcPtr : NULL,
1955+ dest, dstW, chrAlpha, dstFormat, flags, dstY);
1956+ } else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB
19261957 int lumAlpha= vLumFilter[2*dstY+1];
19271958 int chrAlpha= vChrFilter[2*dstY+1];
19281959 lumMmxFilter[2]=
19291960 lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001;
19301961 chrMmxFilter[2]=
19311962 chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001;
1932− if(flags & SWS_FULL_CHR_H_INT) {
1933− yuv2rgbX_c_full(c, //FIXME write a packed2_full function
1934− vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
1935− vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
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− }
1963+ yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1),
1964+ *chrVSrcPtr, *(chrVSrcPtr+1),
1965+ alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL,
1966+ dest, dstW, lumAlpha, chrAlpha, dstY);
19431967 } else { //general RGB
1944− if(flags & SWS_FULL_CHR_H_INT) {
1945− yuv2rgbX_c_full(c,
1946− vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
1947− vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
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);
1968+ yuv2packedX(c,
1969+ vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
1970+ vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
1971+ alpSrcPtr, dest, dstW, dstY);
19991972 }
20001973 }
20011974 }
@@ -2024,17 +1997,13 @@ static void sws_init_swScale_c(SwsContext *c) · 22 unmodified lines
20241997 {
20251998 enum PixelFormat srcFormat = c->srcFormat;
20261999
2027− c->yuv2nv12X = yuv2nv12X_c;
2028− c->yuv2yuv1 = yuv2yuv1_c;
2029− c->yuv2yuvX = yuv2yuvX_c;
2030− c->yuv2packed1 = yuv2packed1_c;
2031− c->yuv2packed2 = yuv2packed2_c;
2032− c->yuv2packedX = yuv2packedX_c;
2000+ find_c_packed_planar_out_funcs(c, &c->yuv2yuv1, &c->yuv2yuvX,
2001+ &c->yuv2packed1, &c->yuv2packed2,
2002+ &c->yuv2packedX);
20332003
20342004 c->hScale = hScale_c;
20352005
2036− if (c->flags & SWS_FAST_BILINEAR)
2037− {
2006+ if (c->flags & SWS_FAST_BILINEAR) {
20382007 c->hyscale_fast = hyscale_fast_c;
20392008 c->hcscale_fast = hcscale_fast_c;
20402009 }
@@ -2133,28 +2102,18 @@ static void sws_init_swScale_c(SwsContext *c) · 92 unmodified lines
21332102 }
21342103 if (c->alpPixBuf) {
21352104 switch (srcFormat) {
2136− case PIX_FMT_RGB32 :
2137− case PIX_FMT_RGB32_1:
2138− case PIX_FMT_BGR32 :
2139− case PIX_FMT_BGR32_1: c->alpToYV12 = abgrToA_c; break;
2140− case PIX_FMT_GRAY8A : c->alpToYV12 = yuy2ToY_c; break;
2141− case PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; break;
2105+ case PIX_FMT_BGRA:
2106+ case PIX_FMT_RGBA: c->alpToYV12 = rgbaToA_c; break;
2107+ case PIX_FMT_ABGR:
2108+ case PIX_FMT_ARGB: c->alpToYV12 = abgrToA_c; break;
2109+ case PIX_FMT_Y400A: c->alpToYV12 = uyvyToY_c; break;
2110+ case PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; break;
21422111 }
21432112 }
21442113
21452114 if(isAnyRGB(c->srcFormat) || c->srcFormat == PIX_FMT_PAL8)
21462115 c->hScale16= hScale16_c;
21472116
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−
21582117 if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {
21592118 if (c->srcRange) {
21602119 c->lumConvertRange = lumRangeFromJpeg_c;
libswscale/swscale_internal.h+40−44
@@ -59,6 +59,41 @@ typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[], · 58 unmodified lines
5959 int srcStride[], int srcSliceY, int srcSliceH,
6060 uint8_t* dst[], int dstStride[]);
6161
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+
6297 /* This struct should be aligned on at least a 32-byte boundary. */
6398 typedef struct SwsContext {
6499 /**
@@ -256,46 +291,11 @@ typedef struct SwsContext { · 191 unmodified lines
256291 #endif
257292
258293 /* function pointers for swScale() */
259− void (*yuv2nv12X )(struct SwsContext *c,
260− const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
261− const int16_t *chrFilter, const int16_t **chrUSrc,
262− const int16_t **chrVSrc, int chrFilterSize,
263− uint8_t *dest, uint8_t *uDest,
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);
294+ yuv2planar1_fn yuv2yuv1;
295+ yuv2planarX_fn yuv2yuvX;
296+ yuv2packed1_fn yuv2packed1;
297+ yuv2packed2_fn yuv2packed2;
298+ yuv2packedX_fn yuv2packedX;
299299
300300 void (*lumToYV12)(uint8_t *dst, const uint8_t *src,
301301 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
323323 void (*lumConvertRange)(int16_t *dst, int width); ///< Color range conversion function for luma plane if needed.
324324 void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width); ///< Color range conversion function for chroma planes if needed.
325325
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−
330326 int needs_hcscale; ///< Set if there are chroma planes to be converted.
331327
332328 } SwsContext;
libswscale/x86/swscale_template.c+40−32
@@ -2351,56 +2351,64 @@ static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *d · 2350 unmodified lines
23512351
23522352 static void RENAME(sws_init_swScale)(SwsContext *c)
23532353 {
2354− enum PixelFormat srcFormat = c->srcFormat;
2355−
2356− if (!(c->flags & SWS_BITEXACT)) {
2357− if (c->flags & SWS_ACCURATE_RND) {
2358− c->yuv2yuv1 = RENAME(yuv2yuv1_ar );
2359− c->yuv2yuvX = RENAME(yuv2yuvX_ar );
2360− switch (c->dstFormat) {
2361− case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break;
2362− case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break;
2363− case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X_ar); break;
2364− case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X_ar); break;
2365− case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break;
2366− default: break;
2354+ enum PixelFormat srcFormat = c->srcFormat,
2355+ dstFormat = c->dstFormat;
2356+
2357+ if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && dstFormat != PIX_FMT_NV12
2358+ && dstFormat != PIX_FMT_NV21 && !(c->flags & SWS_BITEXACT)) {
2359+ if (c->flags & SWS_ACCURATE_RND) {
2360+ c->yuv2yuv1 = RENAME(yuv2yuv1_ar );
2361+ c->yuv2yuvX = RENAME(yuv2yuvX_ar );
2362+ if (!(c->flags & SWS_FULL_CHR_H_INT)) {
2363+ switch (c->dstFormat) {
2364+ case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break;
2365+ case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); 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+ }
23672386 }
2368− } else {
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 );
2387+ if (!(c->flags & SWS_FULL_CHR_H_INT)) {
23722388 switch (c->dstFormat) {
2373− case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break;
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:
2389+ case PIX_FMT_RGB32:
23832390 c->yuv2packed1 = RENAME(yuv2rgb32_1);
23842391 c->yuv2packed2 = RENAME(yuv2rgb32_2);
23852392 break;
2386− case PIX_FMT_BGR24:
2393+ case PIX_FMT_BGR24:
23872394 c->yuv2packed1 = RENAME(yuv2bgr24_1);
23882395 c->yuv2packed2 = RENAME(yuv2bgr24_2);
23892396 break;
2390− case PIX_FMT_RGB555:
2397+ case PIX_FMT_RGB555:
23912398 c->yuv2packed1 = RENAME(yuv2rgb555_1);
23922399 c->yuv2packed2 = RENAME(yuv2rgb555_2);
23932400 break;
2394− case PIX_FMT_RGB565:
2401+ case PIX_FMT_RGB565:
23952402 c->yuv2packed1 = RENAME(yuv2rgb565_1);
23962403 c->yuv2packed2 = RENAME(yuv2rgb565_2);
23972404 break;
2398− case PIX_FMT_YUYV422:
2405+ case PIX_FMT_YUYV422:
23992406 c->yuv2packed1 = RENAME(yuv2yuyv422_1);
24002407 c->yuv2packed2 = RENAME(yuv2yuyv422_2);
24012408 break;
2402− default:
2409+ default:
24032410 break;
2411+ }
24042412 }
24052413 }
24062414

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t